From 9f5efa2e6e163113560fc7cf7873466e8dee5382 Mon Sep 17 00:00:00 2001 From: Shevchik Date: Mon, 18 May 2015 14:53:42 +0400 Subject: [PATCH] Add back chairs on/off command --- src/com/cnaude/chairs/commands/ChairsCommand.java | 10 ++++++++++ src/com/cnaude/chairs/core/Chairs.java | 1 + .../cnaude/chairs/listeners/TrySitEventListener.java | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/src/com/cnaude/chairs/commands/ChairsCommand.java b/src/com/cnaude/chairs/commands/ChairsCommand.java index 014ea90..a0dd8c2 100644 --- a/src/com/cnaude/chairs/commands/ChairsCommand.java +++ b/src/com/cnaude/chairs/commands/ChairsCommand.java @@ -38,6 +38,16 @@ public class ChairsCommand implements CommandExecutor { sender.sendMessage(plugin.msgNoPerm); } } + if (sender instanceof Player) { + Player player = (Player) sender; + if (args[0].equalsIgnoreCase("off")) { + plugin.sitDisabled.add(player.getName()); + player.sendMessage("Disabled sitting"); + } else if (args[0].equalsIgnoreCase("on")) { + plugin.sitDisabled.remove(player.getName()); + player.sendMessage("Enabled sitting"); + } + } return true; } diff --git a/src/com/cnaude/chairs/core/Chairs.java b/src/com/cnaude/chairs/core/Chairs.java index fca9270..5b76dcc 100644 --- a/src/com/cnaude/chairs/core/Chairs.java +++ b/src/com/cnaude/chairs/core/Chairs.java @@ -25,6 +25,7 @@ import com.cnaude.chairs.vehiclearrow.NMSAccess; public class Chairs extends JavaPlugin { + public HashSet sitDisabled = new HashSet(); public ChairEffects chairEffects; public List allowedBlocks; public List validSigns; diff --git a/src/com/cnaude/chairs/listeners/TrySitEventListener.java b/src/com/cnaude/chairs/listeners/TrySitEventListener.java index 2aa9016..9951890 100644 --- a/src/com/cnaude/chairs/listeners/TrySitEventListener.java +++ b/src/com/cnaude/chairs/listeners/TrySitEventListener.java @@ -42,6 +42,12 @@ public class TrySitEventListener implements Listener { } private boolean sitAllowed(Player player, Block block) { + + // Check for sitting disabled + if (plugin.sitDisabled.contains(player.getName())) { + return false; + } + // Check for permissions if (!player.hasPermission("chairs.sit")) { return false;