Add permission for online/offline opening (Resolves #129) #136
@@ -104,10 +104,20 @@ public class OpenInvCommand implements TabExecutor {
 | 
				
			|||||||
        boolean online = target.isOnline();
 | 
					        boolean online = target.isOnline();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!online) {
 | 
					        if (!online) {
 | 
				
			||||||
            // Try loading the player's data
 | 
					            if (Permissions.OPENOFFLINE.hasPermission(player)) {
 | 
				
			||||||
            onlineTarget = this.plugin.loadPlayer(target);
 | 
					                // Try loading the player's data
 | 
				
			||||||
 | 
					                onlineTarget = this.plugin.loadPlayer(target);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                plugin.sendMessage(player, "messages.error.permissionPlayerOffline");
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            onlineTarget = target.getPlayer();
 | 
					            if (Permissions.OPENONLINE.hasPermission(player)) {
 | 
				
			||||||
 | 
					                onlineTarget = target.getPlayer();
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                plugin.sendMessage(player, "messages.error.permissionPlayerOnline");
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (onlineTarget == null) {
 | 
					        if (onlineTarget == null) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,9 @@ public enum Permissions {
 | 
				
			|||||||
    SEARCH("search"),
 | 
					    SEARCH("search"),
 | 
				
			||||||
    EDITINV("editinv"),
 | 
					    EDITINV("editinv"),
 | 
				
			||||||
    EDITENDER("editender"),
 | 
					    EDITENDER("editender"),
 | 
				
			||||||
    OPENSELF("openself");
 | 
					    OPENSELF("openself"),
 | 
				
			||||||
 | 
					    OPENONLINE("openonline"),
 | 
				
			||||||
 | 
					    OPENOFFLINE("openoffline");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final String permission;
 | 
					    private final String permission;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,8 @@ messages:
 | 
				
			|||||||
    permissionEnderAll: '&cYou''re not allowed to access other players'' ender chests.'
 | 
					    permissionEnderAll: '&cYou''re not allowed to access other players'' ender chests.'
 | 
				
			||||||
    permissionExempt: '&c%target%''s inventory is protected.'
 | 
					    permissionExempt: '&c%target%''s inventory is protected.'
 | 
				
			||||||
    permissionCrossWorld: '&c%target% is not in your world.'
 | 
					    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.'
 | 
					    commandException: '&cAn error occurred. Please check console for details.'
 | 
				
			||||||
  info:
 | 
					  info:
 | 
				
			||||||
    containerBlocked: 'You are opening a blocked container.'
 | 
					    containerBlocked: 'You are opening a blocked container.'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,8 @@ permissions:
 | 
				
			|||||||
      OpenInv.anychest: true
 | 
					      OpenInv.anychest: true
 | 
				
			||||||
      OpenInv.searchenchant: true
 | 
					      OpenInv.searchenchant: true
 | 
				
			||||||
      OpenInv.searchcontainer: true
 | 
					      OpenInv.searchcontainer: true
 | 
				
			||||||
 | 
					      OpenInv.openonline: true
 | 
				
			||||||
 | 
					      OpenInv.openoffline: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
commands:
 | 
					commands:
 | 
				
			||||||
  openinv:
 | 
					  openinv:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,8 @@ messages:
 | 
				
			|||||||
    permissionEnderAll: '&cVoce nao tem permissao para abrir baus de ender de outros jogadores.'
 | 
					    permissionEnderAll: '&cVoce nao tem permissao para abrir baus de ender de outros jogadores.'
 | 
				
			||||||
    permissionExempt: '&cO inventario de %target% e protegido.'
 | 
					    permissionExempt: '&cO inventario de %target% e protegido.'
 | 
				
			||||||
    permissionCrossWorld: '&c%target% nao esta no seu mundo.'
 | 
					    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.'
 | 
					    commandException: '&cUm erro ocorreu. Por favor cheque o console para detalhes.'
 | 
				
			||||||
  info:
 | 
					  info:
 | 
				
			||||||
    containerBlocked: 'Voce esta abrindo um recipiente bloqueado.'
 | 
					    containerBlocked: 'Voce esta abrindo um recipiente bloqueado.'
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user