Add permission for online/offline opening (Resolves #129)

This commit is contained in:
Phoenix616 2020-05-29 00:44:34 +01:00 committed by Adam
parent 34199d12a4
commit 5405b7d7b9
5 changed files with 22 additions and 4 deletions

View file

@ -104,10 +104,20 @@ public class OpenInvCommand implements TabExecutor {
boolean online = target.isOnline();
if (!online) {
// Try loading the player's data
onlineTarget = this.plugin.loadPlayer(target);
if (Permissions.OPENOFFLINE.hasPermission(player)) {
// Try loading the player's data
onlineTarget = this.plugin.loadPlayer(target);
} else {
plugin.sendMessage(player, "messages.error.permissionPlayerOffline");
return;
}
} else {
onlineTarget = target.getPlayer();
if (Permissions.OPENONLINE.hasPermission(player)) {
onlineTarget = target.getPlayer();
} else {
plugin.sendMessage(player, "messages.error.permissionPlayerOnline");
return;
}
}
if (onlineTarget == null) {

View file

@ -33,7 +33,9 @@ public enum Permissions {
SEARCH("search"),
EDITINV("editinv"),
EDITENDER("editender"),
OPENSELF("openself");
OPENSELF("openself"),
OPENONLINE("openonline"),
OPENOFFLINE("openoffline");
private final String permission;

View file

@ -9,6 +9,8 @@ messages:
permissionEnderAll: '&cYou''re not allowed to access other players'' ender chests.'
permissionExempt: '&c%target%''s inventory is protected.'
permissionCrossWorld: '&c%target% is not in your world.'
permissionPlayerOnline: '&cYou''re not allowed to open the inventory of online players.'
permissionPlayerOffline: '&cYou''re not allowed to open the inventory of offline players.'
commandException: '&cAn error occurred. Please check console for details.'
info:
containerBlocked: 'You are opening a blocked container.'

View file

@ -25,6 +25,8 @@ permissions:
OpenInv.anychest: true
OpenInv.searchenchant: true
OpenInv.searchcontainer: true
OpenInv.openonline: true
OpenInv.openoffline: true
commands:
openinv:

View file

@ -9,6 +9,8 @@ messages:
permissionEnderAll: '&cVoce nao tem permissao para abrir baus de ender de outros jogadores.'
permissionExempt: '&cO inventario de %target% e protegido.'
permissionCrossWorld: '&c%target% nao esta no seu mundo.'
permissionPlayerOnline: '&cVoce nao tem permissao para abrir o inventario de jogadores online.'
permissionPlayerOffline: '&cVoce nao tem permissao para abrir o inventario de jogadores offline.'
commandException: '&cUm erro ocorreu. Por favor cheque o console para detalhes.'
info:
containerBlocked: 'Voce esta abrindo um recipiente bloqueado.'