diff --git a/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java b/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java
index c432c5ae..6d03fbdc 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java
@@ -38,6 +38,7 @@ import io.github.dre2n.dungeonsxl.listener.HangingListener;
import io.github.dre2n.dungeonsxl.listener.PlayerListener;
import io.github.dre2n.dungeonsxl.listener.WorldListener;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.player.DPlayers;
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
@@ -124,6 +125,7 @@ public class DungeonsXL extends BRPlugin {
// Load Language 2
loadMessageConfig(new File(getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
loadDCommands();
+ DPermissions.register();
loadGameTypes();
loadRequirementTypes();
loadRewardTypes();
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/BreakCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/BreakCommand.java
index 9cc5324e..1f7a0735 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/BreakCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/BreakCommand.java
@@ -22,6 +22,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -38,7 +39,7 @@ public class BreakCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_BREAK));
- setPermission("dxl.break");
+ setPermission(DPermissions.BREAK.getNode());
setPlayerCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/ChatCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/ChatCommand.java
index cbcb8cbc..1644c12d 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/ChatCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/ChatCommand.java
@@ -21,6 +21,7 @@ import io.github.dre2n.commons.config.MessageConfig;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -38,7 +39,7 @@ public class ChatCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_CHAT));
- setPermission("dxl.chat");
+ setPermission(DPermissions.CHAT.getNode());
setPlayerCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/ChatSpyCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/ChatSpyCommand.java
index f26a00cf..f99a17c8 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/ChatSpyCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/ChatSpyCommand.java
@@ -22,6 +22,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -38,7 +39,7 @@ public class ChatSpyCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_CHATSPY));
- setPermission("dxl.chatspy");
+ setPermission(DPermissions.CHAT_SPY.getNode());
setPlayerCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/CreateCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/CreateCommand.java
index f48cabb6..e2ae435b 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/CreateCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/CreateCommand.java
@@ -21,6 +21,7 @@ import io.github.dre2n.commons.config.MessageConfig;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import org.bukkit.command.CommandSender;
@@ -40,7 +41,7 @@ public class CreateCommand extends BRCommand {
setMaxArgs(1);
setCommand("create");
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_CREATE));
- setPermission("dxl.create");
+ setPermission(DPermissions.CREATE.getNode());
setPlayerCommand(true);
setConsoleCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/EditCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/EditCommand.java
index 6fe5c5ae..a64a353c 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/EditCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/EditCommand.java
@@ -21,7 +21,9 @@ import io.github.dre2n.commons.config.MessageConfig;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
+import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import org.bukkit.command.CommandSender;
@@ -52,7 +54,7 @@ public class EditCommand extends BRCommand {
DGroup dGroup = DGroup.getByPlayer(player);
DPlayer dPlayer = DPlayer.getByPlayer(player);
- if (!(EditWorld.isInvitedPlayer(mapName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit"))) {
+ if (!(EditWorld.isInvitedPlayer(mapName, player.getUniqueId(), player.getName()) || DPermissions.hasPermission(player, DPermissions.EDIT))) {
MessageUtil.sendMessage(player, messageConfig.getMessage(DMessages.ERROR_NO_PERMISSIONS));
return;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java
index ce110cc2..9182c74c 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/EnterCommand.java
@@ -22,7 +22,9 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.game.Game;
+import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -40,7 +42,7 @@ public class EnterCommand extends BRCommand {
setMaxArgs(2);
setCommand("enter");
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_ENTER));
- setPermission("dxl.enter");
+ setPermission(DPermissions.ENTER.getNode());
setPlayerCommand(true);
}
@@ -72,7 +74,7 @@ public class EnterCommand extends BRCommand {
joining = new DGroup(captain, game.getWorld().getMapName(), game.getDungeon() != null);
}
- if (joining.getCaptain() != captain && !sender.hasPermission("dxl.bypass")) {
+ if (joining.getCaptain() != captain && !DPermissions.hasPermission(sender, DPermissions.BYPASS)) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(DMessages.ERROR_NOT_CAPTAIN));
return;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/EscapeCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/EscapeCommand.java
index 1f191533..e0750406 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/EscapeCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/EscapeCommand.java
@@ -22,6 +22,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import org.bukkit.command.CommandSender;
@@ -40,7 +41,7 @@ public class EscapeCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_ESCAPE));
- setPermission("dxl.escape");
+ setPermission(DPermissions.ESCAPE.getNode());
setPlayerCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/GameCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/GameCommand.java
index de9ee969..ef461f9e 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/GameCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/GameCommand.java
@@ -23,6 +23,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.GameWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -40,7 +41,7 @@ public class GameCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_GAME));
- setPermission("dxl.game");
+ setPermission(DPermissions.GAME.getNode());
setPlayerCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/GroupCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/GroupCommand.java
index 11f2928b..ca19f095 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/GroupCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/GroupCommand.java
@@ -24,7 +24,9 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupDisbandEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
+import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -42,7 +44,7 @@ public class GroupCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(2);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_GROUP));
- setPermission("dxl.group");
+ setPermission(DPermissions.GROUP.getNode());
setPlayerCommand(true);
}
@@ -91,7 +93,7 @@ public class GroupCommand extends BRCommand {
createGroup();
return;
- } else if (args[1].equalsIgnoreCase("disband") && sender.hasPermission("dxl.group.admin")) {
+ } else if (args[1].equalsIgnoreCase("disband") && DPermissions.hasPermission(sender, DPermissions.GROUP_ADMIN)) {
disbandGroup(DGroup.getByName(args[2]));
return;
@@ -99,7 +101,7 @@ public class GroupCommand extends BRCommand {
joinGroup(DGroup.getByName(args[2]));
return;
- } else if (args[1].equalsIgnoreCase("show") && sender.hasPermission("dxl.group.admin")) {
+ } else if (args[1].equalsIgnoreCase("show") && DPermissions.hasPermission(sender, DPermissions.GROUP_ADMIN)) {
showGroup(DGroup.getByName(args[2]));
return;
}
@@ -191,7 +193,7 @@ public class GroupCommand extends BRCommand {
return;
}
- if (!dGroup.getInvitedPlayers().contains(player) && !player.hasPermission("dxl.bypass")) {
+ if (!dGroup.getInvitedPlayers().contains(player) && !DPermissions.hasPermission(player, DPermissions.BYPASS)) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(DMessages.ERROR_NOT_INVITED, args[2]));
return;
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/HelpCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/HelpCommand.java
index c93831af..1726b1e2 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/HelpCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/HelpCommand.java
@@ -22,6 +22,7 @@ import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import java.util.ArrayList;
import java.util.Set;
import org.bukkit.command.CommandSender;
@@ -39,7 +40,7 @@ public class HelpCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(1);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_HELP));
- setPermission("dxl.help");
+ setPermission(DPermissions.HELP.getNode());
setPlayerCommand(true);
setConsoleCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/InviteCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/InviteCommand.java
index ed2bca10..02b9dd35 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/InviteCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/InviteCommand.java
@@ -22,6 +22,7 @@ import io.github.dre2n.commons.util.UUIDUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import org.bukkit.command.CommandSender;
@@ -38,7 +39,7 @@ public class InviteCommand extends BRCommand {
setMaxArgs(2);
setCommand("invite");
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_INVITE));
- setPermission("dxl.invite");
+ setPermission(DPermissions.INVITE.getNode());
setPlayerCommand(true);
setConsoleCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java
index 23e80b67..4a8f40a1 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/LeaveCommand.java
@@ -24,6 +24,7 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEscapeEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerLeaveDGroupEvent;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.world.GameWorld;
import org.bukkit.command.CommandSender;
@@ -42,7 +43,7 @@ public class LeaveCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_LEAVE));
- setPermission("dxl.leave");
+ setPermission(DPermissions.LEAVE.getNode());
setPlayerCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/ListCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/ListCommand.java
index 4d3f7b89..abf3e090 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/ListCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/ListCommand.java
@@ -24,6 +24,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import io.github.dre2n.dungeonsxl.world.GameWorld;
import java.io.File;
@@ -44,7 +45,7 @@ public class ListCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(3);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_LIST));
- setPermission("dxl.list");
+ setPermission(DPermissions.LIST.getNode());
setPlayerCommand(true);
setConsoleCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/LivesCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/LivesCommand.java
index c77725a0..c814d079 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/LivesCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/LivesCommand.java
@@ -21,6 +21,7 @@ import io.github.dre2n.commons.config.MessageConfig;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@@ -39,7 +40,7 @@ public class LivesCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(1);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_LIVES));
- setPermission("dxl.lives");
+ setPermission(DPermissions.LIVES.getNode());
setPlayerCommand(true);
setConsoleCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/MainCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/MainCommand.java
index 3ea8f464..52cdb491 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/MainCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/MainCommand.java
@@ -24,6 +24,7 @@ import static io.github.dre2n.commons.util.messageutil.FatLetters.*;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@@ -40,7 +41,7 @@ public class MainCommand extends BRCommand {
public MainCommand() {
setCommand("main");
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_MAIN));
- setPermission("dxl.main");
+ setPermission(DPermissions.MAIN.getNode());
setPlayerCommand(true);
setConsoleCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java
index a23a6826..f69918db 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/MsgCommand.java
@@ -23,6 +23,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import java.io.File;
import org.bukkit.ChatColor;
@@ -42,7 +43,7 @@ public class MsgCommand extends BRCommand {
setMaxArgs(-1);
setCommand("msg");
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_MSG));
- setPermission("dxl.msg");
+ setPermission(DPermissions.MESSAGE.getNode());
setPlayerCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java
index 306615c2..d54d3291 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/PlayCommand.java
@@ -25,7 +25,9 @@ import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
+import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import io.github.dre2n.dungeonsxl.world.GameWorld;
@@ -46,7 +48,7 @@ public class PlayCommand extends BRCommand {
setMinArgs(1);
setMaxArgs(2);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_PLAY));
- setPermission("dxl.play");
+ setPermission(DPermissions.PLAY.getNode());
setPlayerCommand(true);
}
@@ -113,7 +115,7 @@ public class PlayCommand extends BRCommand {
DGroup dGroup = DGroup.getByPlayer(player);
if (dGroup != null) {
- if (!dGroup.getCaptain().equals(player) && !player.hasPermission("dxl.bypass")) {
+ if (!dGroup.getCaptain().equals(player) && !DPermissions.hasPermission(player, DPermissions.BYPASS)) {
MessageUtil.sendMessage(player, messageConfig.getMessage(DMessages.ERROR_NOT_CAPTAIN));
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/PortalCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/PortalCommand.java
index 5772d7a0..bcf754ea 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/PortalCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/PortalCommand.java
@@ -23,6 +23,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
@@ -42,7 +43,7 @@ public class PortalCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_PORTAL));
- setPermission("dxl.portal");
+ setPermission(DPermissions.PORTAL.getNode());
setPlayerCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/ReloadCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/ReloadCommand.java
index a3e181b9..c979e751 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/ReloadCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/ReloadCommand.java
@@ -23,6 +23,7 @@ import io.github.dre2n.commons.config.MessageConfig;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@@ -41,7 +42,7 @@ public class ReloadCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_RELOAD));
- setPermission("dxl.reload");
+ setPermission(DPermissions.RELOAD.getNode());
setPlayerCommand(true);
setConsoleCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/SaveCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/SaveCommand.java
index 90dd53ca..32c3c9dd 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/SaveCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/SaveCommand.java
@@ -21,6 +21,7 @@ import io.github.dre2n.commons.config.MessageConfig;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -38,7 +39,7 @@ public class SaveCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_SAVE));
- setPermission("dxl.save");
+ setPermission(DPermissions.SAVE.getNode());
setPlayerCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/TestCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/TestCommand.java
index 718f87a4..b7462453 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/TestCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/TestCommand.java
@@ -24,6 +24,7 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.world.GameWorld;
import org.bukkit.command.CommandSender;
@@ -42,7 +43,7 @@ public class TestCommand extends BRCommand {
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_TEST));
- setPermission("dxl.test");
+ setPermission(DPermissions.TEST.getNode());
setPlayerCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/UninviteCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/UninviteCommand.java
index 584f76cf..b76985bf 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/command/UninviteCommand.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/command/UninviteCommand.java
@@ -22,6 +22,7 @@ import io.github.dre2n.commons.util.UUIDUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import org.bukkit.command.CommandSender;
@@ -38,7 +39,7 @@ public class UninviteCommand extends BRCommand {
setMinArgs(2);
setMaxArgs(2);
setHelp(messageConfig.getMessage(DMessages.HELP_CMD_UNINVITE));
- setPermission("dxl.uninvite");
+ setPermission(DPermissions.UNINVITE.getNode());
setPlayerCommand(true);
setConsoleCommand(true);
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java b/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java
index b2199716..0096c31c 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java
@@ -29,6 +29,7 @@ import io.github.dre2n.dungeonsxl.global.GlobalProtection;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.global.LeaveSign;
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayers;
import io.github.dre2n.dungeonsxl.sign.DSign;
import io.github.dre2n.dungeonsxl.task.RedstoneEventTask;
@@ -160,7 +161,7 @@ public class BlockListener implements Listener {
// Group Signs
if (editWorld == null) {
- if (!player.hasPermission("dxl.sign")) {
+ if (!DPermissions.hasPermission(player, DPermissions.SIGN)) {
return;
}
@@ -219,8 +220,9 @@ public class BlockListener implements Listener {
return;
}
- if (!player.hasPermission(dsign.getType().getBuildPermission())) {
+ if (!DPermissions.hasPermission(player, dsign.getType().getBuildPermission())) {
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.ERROR_NO_PERMISSIONS));
+ return;
}
if (dsign.check()) {
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java b/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java
index 6f4ddd2e..91c7bdd0 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java
@@ -33,6 +33,7 @@ import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.global.LeaveSign;
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.player.DPlayers;
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
@@ -155,13 +156,13 @@ public class PlayerListener implements Listener {
if (GameWorld.getByWorld(player.getWorld()) != null || EditWorld.getByWorld(player.getWorld()) != null) {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (clickedBlock.getType() == Material.ENDER_CHEST) {
- if (!player.hasPermission("dxl.bypass")) {
+ if (!DPermissions.hasPermission(player, DPermissions.BYPASS)) {
MessageUtil.sendMessage(player, messageConfig.getMessage(DMessages.ERROR_ENDERCHEST));
event.setCancelled(true);
}
} else if (clickedBlock.getType() == Material.BED_BLOCK) {
- if (!player.hasPermission("dxl.bypass")) {
+ if (!DPermissions.hasPermission(player, DPermissions.BYPASS)) {
MessageUtil.sendMessage(player, messageConfig.getMessage(DMessages.ERROR_BED));
event.setCancelled(true);
}
@@ -173,7 +174,7 @@ public class PlayerListener implements Listener {
if (GameWorld.getByWorld(player.getWorld()) != null) {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (clickedBlock.getType() == Material.DISPENSER) {
- if (!player.hasPermission("dxl.bypass")) {
+ if (!DPermissions.hasPermission(player, DPermissions.BYPASS)) {
MessageUtil.sendMessage(player, messageConfig.getMessage(DMessages.ERROR_DISPENSER));
event.setCancelled(true);
}
@@ -319,7 +320,7 @@ public class PlayerListener implements Listener {
return;
}
- if (dPlayer.isEditing() && !plugin.getMainConfig().getDropItems() && !player.hasPermission("dxl.insecure")) {
+ if (dPlayer.isEditing() && !plugin.getMainConfig().getDropItems() && !DPermissions.hasPermission(player, DPermissions.INSECURE)) {
event.setCancelled(true);
}
@@ -425,7 +426,7 @@ public class PlayerListener implements Listener {
return;
}
- if (!player.hasPermission("dxl.bypass")) {
+ if (!DPermissions.hasPermission(player, DPermissions.BYPASS)) {
event.setCancelled(true);
}
}
@@ -560,7 +561,7 @@ public class PlayerListener implements Listener {
// Deny Player Cmds
@EventHandler(priority = EventPriority.HIGH)
public void onCommand(PlayerCommandPreprocessEvent event) {
- if (event.getPlayer().hasPermission("dxl.bypass")) {
+ if (DPermissions.hasPermission(event.getPlayer(), DPermissions.BYPASS)) {
return;
}
@@ -575,7 +576,7 @@ public class PlayerListener implements Listener {
GameWorld gameWorld = GameWorld.getByWorld(dPlayer.getWorld());
if (dPlayer.isEditing()) {
- if (event.getPlayer().hasPermission("dxl.cmdedit")) {
+ if (DPermissions.hasPermission(event.getPlayer(), DPermissions.CMD_EDIT)) {
return;
} else {
@@ -614,7 +615,7 @@ public class PlayerListener implements Listener {
GameChest.onOpenInventory(event);
- if (!plugin.getMainConfig().getOpenInventories() && !event.getPlayer().hasPermission("dxl.insecure")) {
+ if (!plugin.getMainConfig().getOpenInventories() && !DPermissions.hasPermission(event.getPlayer(), DPermissions.INSECURE)) {
World world = event.getPlayer().getWorld();
if (event.getInventory().getType() != InventoryType.CREATIVE && EditWorld.getByWorld(world) != null) {
event.setCancelled(true);
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DGlobalPlayer.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DGlobalPlayer.java
index d64a26c3..746e31bf 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/player/DGlobalPlayer.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DGlobalPlayer.java
@@ -28,6 +28,8 @@ import org.bukkit.inventory.ItemStack;
*/
public class DGlobalPlayer {
+ protected static DungeonsXL plugin = DungeonsXL.getInstance();
+
protected Player player;
private boolean breakMode;
@@ -40,7 +42,7 @@ public class DGlobalPlayer {
public DGlobalPlayer(Player player) {
this.player = player;
- DungeonsXL.getInstance().getDPlayers().addPlayer(this);
+ plugin.getDPlayers().addPlayer(this);
}
public DGlobalPlayer(DGlobalPlayer dPlayer) {
@@ -51,7 +53,7 @@ public class DGlobalPlayer {
respawnInventory = dPlayer.getRespawnInventory();
respawnArmor = dPlayer.getRespawnArmor();
- DungeonsXL.getInstance().getDPlayers().addPlayer(this);
+ plugin.getDPlayers().addPlayer(this);
}
/**
@@ -157,4 +159,22 @@ public class DGlobalPlayer {
this.respawnArmor = respawnArmor;
}
+ /**
+ * @param permission
+ * the permission to check
+ * @return if the player has the permission
+ */
+ public boolean hasPermission(DPermissions permission) {
+ return DPermissions.hasPermission(player, permission);
+ }
+
+ /**
+ * @param permission
+ * the permission to check
+ * @return if the player has the permission
+ */
+ public boolean hasPermission(String permission) {
+ return DPermissions.hasPermission(player, permission);
+ }
+
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java
new file mode 100644
index 00000000..7c1a40bd
--- /dev/null
+++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2016 Daniel Saukel
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package io.github.dre2n.dungeonsxl.player;
+
+import io.github.dre2n.commons.util.EnumUtil;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.bukkit.Bukkit;
+import org.bukkit.command.CommandSender;
+import org.bukkit.permissions.Permission;
+import org.bukkit.permissions.PermissionDefault;
+import static org.bukkit.permissions.PermissionDefault.*;
+
+/**
+ * @author Daniel Saukel
+ */
+public enum DPermissions {
+
+ // Main nodes
+ BREAK("break", OP),
+ BYPASS("bypass", OP),
+ CHAT("chat", TRUE),
+ CHAT_SPY("chatspy", OP),
+ CMD_EDIT("cmdedit", OP),
+ CREATE("create", OP),
+ EDIT("edit", OP),
+ ENTER("enter", OP),
+ ESCAPE("escape", TRUE),
+ GAME("game", TRUE),
+ GROUP("group", OP),
+ GROUP_ADMIN("group.admin", OP, GROUP),
+ HELP("help", TRUE),
+ IGNORE_REQUIREMENTS("ignorerequirements", OP),
+ IGNORE_TIME_LIMIT("ignoretimelimit", OP),
+ INVITE("invite", OP),
+ INSECURE("insecure", OP),
+ LEAVE("leave", TRUE),
+ LIST("list", OP),
+ LIVES("lives", TRUE),
+ MAIN("main", TRUE),
+ MESSAGE("msg", OP),
+ PLAY("play", OP),
+ PORTAL("portal", OP),
+ RELOAD("reload", OP),
+ SAVE("save", OP),
+ SIGN("sign", OP),
+ TEST("test", OP),
+ UNINVITE("uninvite", OP),
+ // Kits
+ ADMINISTRATOR("*", OP),
+ HALF_EDITOR("halfeditor", OP, ESCAPE, LIST, MESSAGE, SAVE),
+ FULL_EDITOR("fulleditor", OP, HALF_EDITOR, EDIT, PLAY, SIGN, TEST),
+ HALF_PLAYER("halfplayer", TRUE, CHAT, ESCAPE, GAME, HELP, LEAVE, LIVES, MAIN),
+ FULL_PLAYER("fullplayer", OP, HALF_PLAYER, GROUP);
+
+ public static final String PREFIX = "dxl.";
+
+ private String node;
+ private PermissionDefault isDefault;
+ private List children = new ArrayList<>();
+
+ DPermissions(String node, PermissionDefault isDefault) {
+ this.node = node;
+ this.isDefault = isDefault;
+ }
+
+ DPermissions(String node, PermissionDefault isDefault, DPermissions... children) {
+ this(node, isDefault);
+ this.children = Arrays.asList(children);
+ }
+
+ /**
+ * @return the permission node String
+ */
+ public String getNode() {
+ return PREFIX + node;
+ }
+
+ /**
+ * @return if a player has the node by default
+ */
+ public PermissionDefault isDefault() {
+ return isDefault;
+ }
+
+ /**
+ * @return if the node has children
+ */
+ public boolean hasChildren() {
+ return !children.isEmpty();
+ }
+
+ /**
+ * @return the child permissions
+ */
+ public List getChildren() {
+ return children;
+ }
+
+ /**
+ * @param node
+ * the node String, with or without "dxl."
+ * @return
+ * the DPermissions value
+ */
+ public static DPermissions getByNode(String node) {
+ for (DPermissions permission : values()) {
+ if (permission.getNode().equals(node) || permission.node.equals(node)) {
+ return permission;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param permission
+ * the permission to check
+ * @return if the player has the permission
+ */
+ public static boolean hasPermission(CommandSender sender, DPermissions permission) {
+ if (sender.hasPermission(permission.getNode())) {
+ return true;
+ }
+
+ for (DPermissions parent : DPermissions.values()) {
+ if (parent.getChildren().contains(permission) && sender.hasPermission(parent.getNode())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @param permission
+ * the permission to check
+ * @return if the player has the permission
+ */
+ public static boolean hasPermission(CommandSender sender, String permission) {
+ DPermissions dPermission = null;
+ if (EnumUtil.isValidEnum(DPermissions.class, permission)) {
+ dPermission = DPermissions.valueOf(permission);
+
+ } else if (DPermissions.getByNode(permission) != null) {
+ dPermission = DPermissions.getByNode(permission);
+ }
+
+ if (dPermission == null) {
+ return false;
+ }
+
+ return hasPermission(sender, dPermission);
+ }
+
+ /**
+ * Registers the permissions.
+ */
+ public static void register() {
+ for (DPermissions permission : values()) {
+ Bukkit.getPluginManager().addPermission(new Permission(permission.getNode(), permission.isDefault()));
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DPlayer.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DPlayer.java
index 7d501852..37bc08ee 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/player/DPlayer.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DPlayer.java
@@ -22,7 +22,6 @@ import io.github.dre2n.commons.config.MessageConfig;
import io.github.dre2n.commons.util.NumberUtil;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
-import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
@@ -67,7 +66,6 @@ import org.bukkit.potion.PotionEffect;
*/
public class DPlayer extends DGlobalPlayer {
- protected static DungeonsXL plugin = DungeonsXL.getInstance();
protected static MessageConfig messageConfig = plugin.getMessageConfig();
// Variables
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/sign/DSignTypeDefault.java b/src/main/java/io/github/dre2n/dungeonsxl/sign/DSignTypeDefault.java
index 0c2dc6bd..c1cf3b20 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/sign/DSignTypeDefault.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/sign/DSignTypeDefault.java
@@ -16,32 +16,34 @@
*/
package io.github.dre2n.dungeonsxl.sign;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
+
/**
* @author Daniel Saukel
*/
public enum DSignTypeDefault implements DSignType {
- BLOCK("Block", "dxl.sign.block", false, BlockSign.class),
- CHECKPOINT("Checkpoint", "dxl.sign.checkpoint", false, CheckpointSign.class),
- CHEST("Chest", "dxl.sign.chest", false, ChestSign.class),
- CHUNK_UPDATER("ChunkUpdater", "dxl.sign.chunkupdater", true, ChunkUpdaterSign.class),
- CLASSES("Classes", "dxl.sign.classes", true, ClassesSign.class),
- COMMAND("CMD", "dxl.sign.cmd", false, CommandSign.class),
- END("End", "dxl.sign.end", false, EndSign.class),
- FLOOR("Floor", "dxl.sign.floor", false, FloorSign.class),
- INTERACT("Interact", "dxl.sign.interact", true, InteractSign.class),
- LEAVE("Leave", "dxl.sign.leave", true, LeaveSign.class),
- LOBBY("Lobby", "dxl.sign.lobby", true, LobbySign.class),
- MOB("Mob", "dxl.sign.mob", false, DMobSign.class),
- MESSAGE("MSG", "dxl.sign.msg", false, MessageSign.class),
- MYTHIC_MOBS("MythicMobs", "dxl.sign.mob", false, MythicMobsSign.class),
- PLACE("Place", "dxl.sign.place", false, PlaceSign.class),
- READY("Ready", "dxl.sign.ready", true, ReadySign.class),
- REDSTONE("Redstone", "dxl.sign.redstone", false, RedstoneSign.class),
- SOUND_MESSAGE("SoundMSG", "dxl.sign.soundmsg", false, SoundMessageSign.class),
- START("Start", "dxl.sign.start", true, StartSign.class),
- TRIGGER("Trigger", "dxl.sign.trigger", true, TriggerSign.class),
- WAVE("Wave", "dxl.sign.wave", false, WaveSign.class);
+ BLOCK("Block", "block", false, BlockSign.class),
+ CHECKPOINT("Checkpoint", "checkpoint", false, CheckpointSign.class),
+ CHEST("Chest", "chest", false, ChestSign.class),
+ CHUNK_UPDATER("ChunkUpdater", "chunkupdater", true, ChunkUpdaterSign.class),
+ CLASSES("Classes", "classes", true, ClassesSign.class),
+ COMMAND("CMD", "cmd", false, CommandSign.class),
+ END("End", "end", false, EndSign.class),
+ FLOOR("Floor", "floor", false, FloorSign.class),
+ INTERACT("Interact", "interact", true, InteractSign.class),
+ LEAVE("Leave", "leave", true, LeaveSign.class),
+ LOBBY("Lobby", "lobby", true, LobbySign.class),
+ MOB("Mob", "mob", false, DMobSign.class),
+ MESSAGE("MSG", "msg", false, MessageSign.class),
+ MYTHIC_MOBS("MythicMobs", "mob", false, MythicMobsSign.class),
+ PLACE("Place", "place", false, PlaceSign.class),
+ READY("Ready", "ready", true, ReadySign.class),
+ REDSTONE("Redstone", "redstone", false, RedstoneSign.class),
+ SOUND_MESSAGE("SoundMSG", "soundmsg", false, SoundMessageSign.class),
+ START("Start", "start", true, StartSign.class),
+ TRIGGER("Trigger", "trigger", true, TriggerSign.class),
+ WAVE("Wave", "wave", false, WaveSign.class);
private String name;
private String buildPermission;
@@ -62,7 +64,7 @@ public enum DSignTypeDefault implements DSignType {
@Override
public String getBuildPermission() {
- return buildPermission;
+ return DPermissions.SIGN.getNode() + "." + buildPermission;
}
@Override
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/task/SecureModeTask.java b/src/main/java/io/github/dre2n/dungeonsxl/task/SecureModeTask.java
index 63ad912a..f1e43db0 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/task/SecureModeTask.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/task/SecureModeTask.java
@@ -19,6 +19,7 @@ package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -38,7 +39,7 @@ public class SecureModeTask extends BukkitRunnable {
}
if (!(dGlobalPlayer instanceof DPlayer || dGlobalPlayer instanceof DEditPlayer)) {
- if (player.getWorld().getName().startsWith("DXL_Game_") | player.getWorld().getName().startsWith("DXL_Edit_") && !player.hasPermission("dxl.insecure")) {
+ if (player.getWorld().getName().startsWith("DXL_Game_") | player.getWorld().getName().startsWith("DXL_Edit_") && !DPermissions.hasPermission(player, DPermissions.INSECURE)) {
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
}
}
diff --git a/src/main/java/io/github/dre2n/dungeonsxl/world/GameWorld.java b/src/main/java/io/github/dre2n/dungeonsxl/world/GameWorld.java
index 24189e7b..d2cb9531 100644
--- a/src/main/java/io/github/dre2n/dungeonsxl/world/GameWorld.java
+++ b/src/main/java/io/github/dre2n/dungeonsxl/world/GameWorld.java
@@ -31,6 +31,7 @@ import io.github.dre2n.dungeonsxl.game.GameChest;
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.player.DGroup;
+import io.github.dre2n.dungeonsxl.player.DPermissions;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.sign.DSign;
@@ -558,7 +559,7 @@ public class GameWorld {
}
public static boolean canPlayDungeon(String map, Player player) {
- if (player.hasPermission("dxl.ignoretimelimit")) {
+ if (DPermissions.hasPermission(player, DPermissions.IGNORE_TIME_LIMIT)) {
return true;
}
@@ -583,7 +584,7 @@ public class GameWorld {
}
public static boolean canPlayDungeon(String dungeon, DGroup dGroup) {
- if (dGroup.getCaptain().hasPermission("dxl.ignoretimelimit")) {
+ if (DPermissions.hasPermission(dGroup.getCaptain(), DPermissions.IGNORE_TIME_LIMIT)) {
return true;
}
@@ -619,7 +620,7 @@ public class GameWorld {
}
public static boolean checkRequirements(String map, Player player) {
- if (player.hasPermission("dxl.ignorerequirements")) {
+ if (DPermissions.hasPermission(player, DPermissions.IGNORE_REQUIREMENTS)) {
return true;
}
@@ -693,7 +694,7 @@ public class GameWorld {
}
public static boolean checkRequirements(String map, DGroup dGroup) {
- if (dGroup.getCaptain().hasPermission("dxl.ignorerequirements")) {
+ if (DPermissions.hasPermission(dGroup.getCaptain(), DPermissions.IGNORE_REQUIREMENTS)) {
return true;
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index e5f540b8..072ee2f3 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -9,62 +9,3 @@ commands:
dungeonsxl:
description: Reference command for DungeonsXL.
aliases: [dxl,dungeon]
-permissions:
- dxl.break:
- default: op
- dxl.chat:
- default: true
- dxl.chatspy:
- default: op
- dxl.create:
- default: op
- dxl.edit:
- default: op
- dxl.enter:
- default: op
- dxl.escape:
- default: true
- dxl.game:
- default: true
- dxl.group:
- default: op
- dxl.group.admin:
- default: op
- dxl.help:
- default: true
- dxl.invite:
- default: op
- dxl.leave:
- default: true
- dxl.list:
- default: true
- dxl.lives:
- default: true
- dxl.main:
- default: true
- dxl.msg:
- default: op
- dxl.play:
- default: op
- dxl.portal:
- default: op
- dxl.reload:
- default: op
- dxl.save:
- default: op
- dxl.test:
- default: op
- dxl.uninvite:
- default: op
- dxl.ignoretimelimit:
- default: op
- dxl.ignorerequirements:
- default: op
- dxl.sign:
- default: op
- dxl.bypass:
- default: op
- dxl.cmdedit:
- default: op
- dxl.insecure:
- default: op