diff --git a/src/main/java/com/loganmagnan/eventcore/commands/BypassModeCommand.java b/src/main/java/com/loganmagnan/eventcore/commands/BypassModeCommand.java new file mode 100644 index 0000000..3c4ba0c --- /dev/null +++ b/src/main/java/com/loganmagnan/eventcore/commands/BypassModeCommand.java @@ -0,0 +1,34 @@ +package com.loganmagnan.eventcore.commands; + +import com.loganmagnan.eventcore.EventCore; +import com.loganmagnan.eventcore.utils.ColorUtils; +import com.loganmagnan.eventcore.utils.Constants; +import com.loganmagnan.eventcore.utils.command.BaseCommand; +import com.loganmagnan.eventcore.utils.command.Command; +import com.loganmagnan.eventcore.utils.command.CommandArguments; +import org.bukkit.entity.Player; + +public class BypassModeCommand extends BaseCommand { + + private EventCore main = EventCore.getInstance(); + + @Command(name = "bypassmode", permission = "eventcore.command.bypassmode", aliases = {"bypass", "build", "buildmode"}) + @Override + public void executeAs(CommandArguments command) { + Player player = command.getPlayer(); + + String[] args = command.getArgs(); + + if (args.length == 0) { + if (this.main.getStaffManager().getPlayersBypassed().contains(player.getUniqueId())) { + this.main.getStaffManager().getPlayersBypassed().remove(player.getUniqueId()); + + player.sendMessage(ColorUtils.getMessageType(Constants.COMMAND_MESSAGES.get("bypass-mode.disabled").get(0))); + } else { + this.main.getStaffManager().getPlayersBypassed().add(player.getUniqueId()); + + player.sendMessage(ColorUtils.getMessageType(Constants.COMMAND_MESSAGES.get("bypass-mode.enabled").get(0))); + } + } + } +} diff --git a/src/main/java/com/loganmagnan/eventcore/listeners/AsyncPlayerChatListener.java b/src/main/java/com/loganmagnan/eventcore/listeners/AsyncPlayerChatListener.java index 32f701a..6daa7fb 100644 --- a/src/main/java/com/loganmagnan/eventcore/listeners/AsyncPlayerChatListener.java +++ b/src/main/java/com/loganmagnan/eventcore/listeners/AsyncPlayerChatListener.java @@ -27,7 +27,7 @@ public class AsyncPlayerChatListener implements Listener { return; } - if (!player.hasPermission(Constants.PERMISSION_NODES.get("chat-bypass"))) { + if (!player.hasPermission(Constants.PERMISSION_NODES.get("chat.bypass"))) { if (this.main.getCooldownManager().isOnChatCooldown(player.getUniqueId())) { int minutes = this.main.getCooldownManager().getChatCooldownTime(player.getUniqueId()) / 60; int seconds = this.main.getCooldownManager().getChatCooldownTime(player.getUniqueId()) % 60; diff --git a/src/main/java/com/loganmagnan/eventcore/listeners/StaffModeListener.java b/src/main/java/com/loganmagnan/eventcore/listeners/StaffModeListener.java index b8920ac..323c07f 100644 --- a/src/main/java/com/loganmagnan/eventcore/listeners/StaffModeListener.java +++ b/src/main/java/com/loganmagnan/eventcore/listeners/StaffModeListener.java @@ -60,6 +60,10 @@ public class StaffModeListener implements Listener { return; } + if (this.main.getStaffManager().getPlayersBypassed().contains(player.getUniqueId())) { + return; + } + event.setCancelled(true); } @@ -71,6 +75,10 @@ public class StaffModeListener implements Listener { return; } + if (this.main.getStaffManager().getPlayersBypassed().contains(player.getUniqueId())) { + return; + } + event.setCancelled(true); } @@ -110,6 +118,10 @@ public class StaffModeListener implements Listener { return; } + if (this.main.getStaffManager().getPlayersBypassed().contains(player.getUniqueId())) { + return; + } + event.setCancelled(true); } @@ -127,6 +139,10 @@ public class StaffModeListener implements Listener { return; } + if (this.main.getStaffManager().getPlayersBypassed().contains(player.getUniqueId())) { + return; + } + event.setCancelled(true); } @@ -138,6 +154,10 @@ public class StaffModeListener implements Listener { return; } + if (this.main.getStaffManager().getPlayersBypassed().contains(player.getUniqueId())) { + return; + } + event.setCancelled(true); } diff --git a/src/main/java/com/loganmagnan/eventcore/managers/StaffManager.java b/src/main/java/com/loganmagnan/eventcore/managers/StaffManager.java index d74ce41..fdf983a 100644 --- a/src/main/java/com/loganmagnan/eventcore/managers/StaffManager.java +++ b/src/main/java/com/loganmagnan/eventcore/managers/StaffManager.java @@ -20,6 +20,7 @@ public class StaffManager { private List playersInStaffMode = new ArrayList(); private List playersVanished = new ArrayList(); private List playersHidingStaff = new ArrayList(); + private List playersBypassed = new ArrayList(); private Map cachedInventories = new HashMap(); diff --git a/src/main/java/com/loganmagnan/eventcore/menusystem/menus/ChatManagementMenu.java b/src/main/java/com/loganmagnan/eventcore/menusystem/menus/ChatManagementMenu.java index b4bfb2b..2140e32 100644 --- a/src/main/java/com/loganmagnan/eventcore/menusystem/menus/ChatManagementMenu.java +++ b/src/main/java/com/loganmagnan/eventcore/menusystem/menus/ChatManagementMenu.java @@ -74,7 +74,7 @@ public class ChatManagementMenu extends Menu { ColorUtils.getMessageType("&bToggle Chat"), ColorUtils.getMessageType( Arrays.asList( - "&fMuted: " + (this.main.getChatManager().isMuted() ? "&aYes" : "&4No"), + "&fMuted: " + (this.main.getChatManager().isMuted() ? "&aYes" : "&cNo"), "&fToggled By: &b" + (this.main.getChatManager().getToggledBy() == null ? "None" : this.main.getServer().getOfflinePlayer(this.main.getChatManager().getToggledBy()).getName()), "&fLast Toggled: &b" + (this.main.getChatManager().getLastToggledTime() == 0 ? "Never" : Utils.getTimeAsAString(this.main.getChatManager().getLastToggledTime())), "", diff --git a/src/main/java/com/loganmagnan/eventcore/menusystem/menus/StaffOnlineMenu.java b/src/main/java/com/loganmagnan/eventcore/menusystem/menus/StaffOnlineMenu.java index 7937835..7bcdef3 100644 --- a/src/main/java/com/loganmagnan/eventcore/menusystem/menus/StaffOnlineMenu.java +++ b/src/main/java/com/loganmagnan/eventcore/menusystem/menus/StaffOnlineMenu.java @@ -112,8 +112,8 @@ public class StaffOnlineMenu extends PaginatedMenu { } List lore = new ArrayList(); - lore.add(ColorUtils.getMessageType("&fStaff Mode: " + (this.main.getStaffManager().isPlayerInStaffMode(playerOnline) ? "&aEnabled" : "&4Disabled"))); - lore.add(ColorUtils.getMessageType("&fVanish: " + (this.main.getStaffManager().isPlayerVanished(playerOnline) ? "&aEnabled" : "&4Disabled"))); + lore.add(ColorUtils.getMessageType("&fStaff Mode: " + (this.main.getStaffManager().isPlayerInStaffMode(playerOnline) ? "&aEnabled" : "&cDisabled"))); + lore.add(ColorUtils.getMessageType("&fVanish: " + (this.main.getStaffManager().isPlayerVanished(playerOnline) ? "&aEnabled" : "&cDisabled"))); lore.add(ColorUtils.getMessageType("")); lore.add(ColorUtils.getMessageType("&bClick to teleport")); diff --git a/src/main/java/com/loganmagnan/eventcore/utils/Constants.java b/src/main/java/com/loganmagnan/eventcore/utils/Constants.java index 9bf1b4a..51fdf70 100644 --- a/src/main/java/com/loganmagnan/eventcore/utils/Constants.java +++ b/src/main/java/com/loganmagnan/eventcore/utils/Constants.java @@ -28,6 +28,10 @@ public class Constants { COMMAND_MESSAGES.put("staff-mode.enabled", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.COMMANDS.STAFF-MODE.ENABLED"))); COMMAND_MESSAGES.put("staff-mode.disabled", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.COMMANDS.STAFF-MODE.DISABLED"))); + // /bypassmode + COMMAND_MESSAGES.put("bypass-mode.enabled", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.COMMANDS.BYPASS-MODE.ENABLED"))); + COMMAND_MESSAGES.put("bypass-mode.disabled", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.COMMANDS.BYPASS-MODE.DISABLED"))); + // AsyncPlayerChatEvent LISTENER_MESSAGES.put("chat-muted", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.LISTENERS.CHAT-MUTED"))); LISTENER_MESSAGES.put("chat-cooldown", this.main.getMessagesConfig().getConfig().getStringList("MESSAGES.LISTENERS.CHAT-COOLDOWN")); @@ -43,6 +47,7 @@ public class Constants { STAFF_MANAGEMENT_MESSAGES.put("vanish.disabled", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.STAFF-MANAGEMENT.VANISH.DISABLED"))); // Permission Nodes - PERMISSION_NODES.put("chat-bypass", this.main.getMainConfig().getConfig().getString("PERMISSION-NODES.CHAT-BYPASS")); + PERMISSION_NODES.put("chat.bypass", this.main.getMainConfig().getConfig().getString("PERMISSION-NODES.CHAT-BYPASS")); + PERMISSION_NODES.put("staff-mode.bypass", this.main.getMainConfig().getConfig().getString("PERMISSION-NODES.STAFF-MODE-BYPASS")); } } diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index 61dd628..1c0c413 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -19,6 +19,9 @@ MESSAGES: STAFF-MODE: # Permission Node - eventcore.command.staffmode ENABLED: "&bYou've &aenabled &bstaff mode" DISABLED: "&bYou've &cdisabled &bstaff mode" + BYPASS-MODE: # Permission Node - eventcore.command.bypassmode + ENABLED: "&bYou've &aenabled &bbypass mode" + DISABLED: "&bYou've &cdisabled &bbypass mode" LISTENERS: CHAT-MUTED: "&cChat is muted" CHAT-COOLDOWN: