diff --git a/src/net/spoothie/chairs/Chairs.java b/src/net/spoothie/chairs/Chairs.java index 32e9d43..36a49fd 100644 --- a/src/net/spoothie/chairs/Chairs.java +++ b/src/net/spoothie/chairs/Chairs.java @@ -39,6 +39,7 @@ public class Chairs extends JavaPlugin { public void onEnable() { instance = this; ignoreList = new ChairsIgnoreList(); + ignoreList.load(); pm = this.getServer().getPluginManager(); pluginFolder = getDataFolder(); configFile = new File(pluginFolder, "config.yml"); @@ -101,14 +102,25 @@ public class Chairs extends JavaPlugin { } } - if (pm.getPermission("chairs.sit") != null) { - pm.removePermission("chairs.sit"); + ArrayList perms = new ArrayList(); + perms.add("chairs.sit"); + perms.add("chairs.reload"); + perms.add("chairs.self"); + for (String s : perms) { + if (pm.getPermission(s) != null) { + pm.removePermission(s); + } } + PermissionDefault pd; if (opsOverridePerms) { - pm.addPermission(new Permission("chairs.sit","Allows players to sit on blocks",PermissionDefault.OP)); + pd = PermissionDefault.OP; } else { - pm.addPermission(new Permission("chairs.sit","Allows players to sit on blocks",PermissionDefault.FALSE)); + pd = PermissionDefault.FALSE; } + + pm.addPermission(new Permission("chairs.sit","Allow player to sit on a block.",pd)); + pm.addPermission(new Permission("chairs.reload","Allow player to reload the Chairs configuration.",pd)); + pm.addPermission(new Permission("chairs.self","Allow player to self disable or enable sitting.",pd)); } // Send sit packet to all online players diff --git a/src/net/spoothie/chairs/ChairsCommand.java b/src/net/spoothie/chairs/ChairsCommand.java index 6f6a124..2f43f3d 100644 --- a/src/net/spoothie/chairs/ChairsCommand.java +++ b/src/net/spoothie/chairs/ChairsCommand.java @@ -4,6 +4,7 @@ */ package net.spoothie.chairs; +import java.io.Console; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -30,7 +31,7 @@ public class ChairsCommand implements CommandExecutor { return false; } if (args[0].equalsIgnoreCase("reload")) { - if (sender.hasPermission("chairs.reload")) { + if (sender.hasPermission("chairs.reload") || !(sender instanceof Player)) { plugin.reloadConfig(); plugin.loadConfig(); sender.sendMessage("Chairs configuration file reloaded."); @@ -41,7 +42,7 @@ public class ChairsCommand implements CommandExecutor { if (sender instanceof Player) { Player p = (Player) sender; if (args[0].equalsIgnoreCase("on")) { - if (p.hasPermission("chairs.self")) { + if (p.hasPermission("chairs.self") || !plugin.permissions) { ignoreList.removePlayer(p.getName()); p.sendMessage(ChatColor.GRAY + "You have enabled chairs for yourself!"); } else { @@ -49,7 +50,7 @@ public class ChairsCommand implements CommandExecutor { } } if (args[0].equalsIgnoreCase("off")) { - if (p.hasPermission("chairs.self")) { + if (p.hasPermission("chairs.self") || !plugin.permissions) { ignoreList.addPlayer(p.getName()); p.sendMessage(ChatColor.GRAY + "You have disabled chairs for yourself!"); } else { diff --git a/src/net/spoothie/chairs/ChairsIgnoreList.java b/src/net/spoothie/chairs/ChairsIgnoreList.java index 83fc5aa..71c6e8d 100644 --- a/src/net/spoothie/chairs/ChairsIgnoreList.java +++ b/src/net/spoothie/chairs/ChairsIgnoreList.java @@ -16,10 +16,6 @@ public class ChairsIgnoreList implements Serializable{ private static ArrayList ignoreList = new ArrayList(); private static final String IGNORE_FILE = "plugins/Chairs/ignores.ser"; - public void ChairsIgnoreList() { - this.load(); - } - @SuppressWarnings("unchecked") public void load() { File file = new File(IGNORE_FILE); @@ -57,12 +53,12 @@ public class ChairsIgnoreList implements Serializable{ if (ignoreList.contains(s)) { return; } - Chairs.get().logInfo("Adding " + s + " to ignore list."); + //Chairs.get().logInfo("Adding " + s + " to ignore list."); ignoreList.add(s); } public void removePlayer(String s) { - Chairs.get().logInfo("Removing " + s + " from ignore list."); + //Chairs.get().logInfo("Removing " + s + " from ignore list."); ignoreList.remove(s); } diff --git a/src/net/spoothie/chairs/EventListener.java b/src/net/spoothie/chairs/EventListener.java index f68450f..9af50de 100644 --- a/src/net/spoothie/chairs/EventListener.java +++ b/src/net/spoothie/chairs/EventListener.java @@ -270,11 +270,12 @@ public class EventListener implements Listener { // Go through the blocks next to the clicked block and check if there are any further stairs. for (int i = 1; i <= plugin.maxChairWidth; i++) { Block relative = block.getRelative(face, i); - - if (plugin.allowedBlocks.contains(relative.getType()) && ((Stairs) relative.getState().getData()).getDescendingDirection() == ((Stairs) block.getState().getData()).getDescendingDirection()) { - width++; - } else { - break; + if (relative.getState().getData() instanceof Stairs) { + if (plugin.allowedBlocks.contains(relative.getType()) && ((Stairs) relative.getState().getData()).getDescendingDirection() == ((Stairs) block.getState().getData()).getDescendingDirection()) { + width++; + } else { + break; + } } } diff --git a/src/plugin.yml b/src/plugin.yml index dfa57af..4c756ed 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -12,10 +12,3 @@ commands: / reload - reloads the configuration / off - disable chairs for self / on - enable chairs for self -permissions: - chairs.reload: - description: Reload configuration - default: op - chairs.self: - description: Allow player to turn chairs off and on - default: false \ No newline at end of file