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;