Fix OpenInv/OpenEnder permissions logic a little bit

/openender should respect exempt and crossworld permissions
/openinv should allow opening of own inventory if exempt without override
This commit is contained in:
Jikoo 2016-11-25 22:26:25 -05:00
parent a10c61168a
commit d7eec528e4
2 changed files with 30 additions and 18 deletions

View file

@ -113,11 +113,20 @@ public class OpenEnderPluginCommand implements CommandExecutor {
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");
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
openEnderHistory.put(player, onlineTarget.getName());

View file

@ -115,21 +115,24 @@ public class OpenInvPluginCommand implements CommandExecutor {
}
// Permissions checks
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;
}
// Crosswork check
// 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;
}
// Self-open check
if (!Permissions.OPENSELF.hasPermission(player) && onlineTarget.equals(player)) {
player.sendMessage(ChatColor.RED + "You're not allowed to openinv yourself.");
return;
}
// Record the target