From 8d371df8f546bb25e11d760f0ab4d725b323b571 Mon Sep 17 00:00:00 2001 From: Shevchik Date: Sun, 25 Dec 2016 00:28:16 +0300 Subject: [PATCH] Add support for disabling chairs in specific worlds --- src/com/cnaude/chairs/core/Chairs.java | 4 ++++ src/com/cnaude/chairs/listeners/TrySitEventListener.java | 3 +++ src/config.yml | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/cnaude/chairs/core/Chairs.java b/src/com/cnaude/chairs/core/Chairs.java index babdf2c..b1479c1 100644 --- a/src/com/cnaude/chairs/core/Chairs.java +++ b/src/com/cnaude/chairs/core/Chairs.java @@ -36,6 +36,7 @@ public class Chairs extends JavaPlugin { public final HashMap validChairs = new HashMap<>(); public final List validSigns = new ArrayList(); public final HashSet sitDisabledCommands = new HashSet<>(); + public final HashSet disabledWorlds = new HashSet<>(); public boolean autoRotate, signCheck, notifyplayer; public boolean ignoreIfBlockInHand; public double distance; @@ -130,6 +131,9 @@ public class Chairs extends JavaPlugin { sitDisabledCommands.clear(); sitDisabledCommands.addAll(config.getStringList("sit-restrictions.commands.list")); + disabledWorlds.clear(); + disabledWorlds.addAll(config.getStringList("disabled-worlds")); + msgSitting = ChatColor.translateAlternateColorCodes('&',config.getString("messages.sitting")); msgStanding = ChatColor.translateAlternateColorCodes('&',config.getString("messages.standing")); msgOccupied = ChatColor.translateAlternateColorCodes('&',config.getString("messages.occupied")); diff --git a/src/com/cnaude/chairs/listeners/TrySitEventListener.java b/src/com/cnaude/chairs/listeners/TrySitEventListener.java index cd9f395..b9a160c 100644 --- a/src/com/cnaude/chairs/listeners/TrySitEventListener.java +++ b/src/com/cnaude/chairs/listeners/TrySitEventListener.java @@ -48,6 +48,9 @@ public class TrySitEventListener implements Listener { if (plugin.sitDisabled.contains(player.getUniqueId())) { return false; } + if (plugin.disabledWorlds.contains(player.getWorld().getName())) { + return false; + } // Check for permissions if (!player.hasPermission("chairs.sit")) { diff --git a/src/config.yml b/src/config.yml index 7f46591..00f9a92 100644 --- a/src/config.yml +++ b/src/config.yml @@ -21,7 +21,7 @@ # commands: # all: If set to true, restricts using all commands while sitting # list: List of commands which player can't use while sitting -# notify-player: If set to true, messages are sent to players to notify about sit/leave/occupied/... +# disabled-worlds: List of worlds in which sitting is disabled # ------ sit-blocks: - WOOD_STAIRS:0.7 @@ -61,7 +61,7 @@ sit-restrictions: all: false list: - /examplecommand -notify-player: true +disabled-worlds: [] messages: sitting: '&7You are now sitting.' standing: '&7You are no longer sitting.'