* Fixed ClassCastException when non stair is next to a stair.

* Added /chairs [off|on]  - Allows players to individually disable or enable chairs for themselves.
This commit is contained in:
cnaude 2013-01-04 19:38:11 -07:00
parent 311f090934
commit 34920d7cee
5 changed files with 28 additions and 25 deletions

View File

@ -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<String> perms = new ArrayList<String>();
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

View File

@ -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 {

View File

@ -16,10 +16,6 @@ public class ChairsIgnoreList implements Serializable{
private static ArrayList<String> ignoreList = new ArrayList<String>();
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);
}

View File

@ -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;
}
}
}

View File

@ -12,10 +12,3 @@ commands:
/<command> reload - reloads the configuration
/<command> off - disable chairs for self
/<command> 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