mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-23 00:15:08 +00:00
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:
parent
a10c61168a
commit
d7eec528e4
2 changed files with 30 additions and 18 deletions
|
@ -113,11 +113,20 @@ public class OpenEnderPluginCommand implements CommandExecutor {
|
||||||
onlineTarget = target.getPlayer();
|
onlineTarget = target.getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!onlineTarget.equals(player)) {
|
||||||
if (!onlineTarget.equals(player) && !Permissions.ENDERCHEST_ALL.hasPermission(player)) {
|
if (!Permissions.ENDERCHEST_ALL.hasPermission(player)) {
|
||||||
player.sendMessage(ChatColor.RED + "You do not have permission to access other player's enderchest");
|
player.sendMessage(ChatColor.RED + "You do not have permission to access other players' enderchests.");
|
||||||
return;
|
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
|
// Record the target
|
||||||
openEnderHistory.put(player, onlineTarget.getName());
|
openEnderHistory.put(player, onlineTarget.getName());
|
||||||
|
|
|
@ -115,21 +115,24 @@ public class OpenInvPluginCommand implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permissions checks
|
// 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)) {
|
if (!Permissions.OVERRIDE.hasPermission(player) && Permissions.EXEMPT.hasPermission(onlineTarget)) {
|
||||||
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + "'s inventory is protected!");
|
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + "'s inventory is protected!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crosswork check
|
// Crossworld check
|
||||||
if ((!Permissions.CROSSWORLD.hasPermission(player) && !Permissions.OVERRIDE.hasPermission(player)) && onlineTarget.getWorld() != player.getWorld()) {
|
if ((!Permissions.CROSSWORLD.hasPermission(player) && !Permissions.OVERRIDE.hasPermission(player)) && onlineTarget.getWorld() != player.getWorld()) {
|
||||||
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + " is not in your world!");
|
player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + " is not in your world!");
|
||||||
return;
|
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
|
// Record the target
|
||||||
|
|
Loading…
Reference in a new issue