Skip to content

Commit

Permalink
Fix OpenInv/OpenEnder permissions logic a little bit
Browse files Browse the repository at this point in the history
/openender should respect exempt and crossworld permissions
/openinv should allow opening of own inventory if exempt without override
  • Loading branch information
Jikoo committed Nov 26, 2016
1 parent a10c611 commit d7eec52
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,19 @@ private void openInventory(Player player, OfflinePlayer target) {
onlineTarget = target.getPlayer();
}


if (!onlineTarget.equals(player) && !Permissions.ENDERCHEST_ALL.hasPermission(player)) {
player.sendMessage(ChatColor.RED + "You do not have permission to access other player's enderchest");
return;
if (!onlineTarget.equals(player)) {
if (!Permissions.ENDERCHEST_ALL.hasPermission(player)) {
player.sendMessage(ChatColor.RED + "You do not have permission to access other players' enderchests.");
return;
}
if (!Permissions.CROSSWORLD.hasPermission(player) && !player.getWorld().equals(onlineTarget.getWorld())) {
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + " is not in your world!");
return;
}
if (!Permissions.OVERRIDE.hasPermission(player) && Permissions.EXEMPT.hasPermission(onlineTarget)) {
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + "'s inventory is protected!");
return;
}
}

// Record the target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,24 @@ private void openInventory(Player player, OfflinePlayer target) {
}

// Permissions checks
if (!Permissions.OVERRIDE.hasPermission(player) && Permissions.EXEMPT.hasPermission(onlineTarget)) {
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + "'s inventory is protected!");
return;
}

// Crosswork check
if ((!Permissions.CROSSWORLD.hasPermission(player) && !Permissions.OVERRIDE.hasPermission(player)) && onlineTarget.getWorld() != player.getWorld()) {
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + " is not in your world!");
return;
}
if (onlineTarget.equals(player)) {
// Self-open check
if (!Permissions.OPENSELF.hasPermission(player)) {
player.sendMessage(ChatColor.RED + "You're not allowed to openinv yourself.");
return;
}
} else {
// Protected check
if (!Permissions.OVERRIDE.hasPermission(player) && Permissions.EXEMPT.hasPermission(onlineTarget)) {
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + "'s inventory is protected!");
return;
}

// Self-open check
if (!Permissions.OPENSELF.hasPermission(player) && onlineTarget.equals(player)) {
player.sendMessage(ChatColor.RED + "You're not allowed to openinv yourself.");
return;
// Crossworld check
if ((!Permissions.CROSSWORLD.hasPermission(player) && !Permissions.OVERRIDE.hasPermission(player)) && onlineTarget.getWorld() != player.getWorld()) {
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + " is not in your world!");
return;
}
}

// Record the target
Expand Down

0 comments on commit d7eec52

Please sign in to comment.