* 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:
parent
311f090934
commit
34920d7cee
@ -39,6 +39,7 @@ public class Chairs extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
ignoreList = new ChairsIgnoreList();
|
ignoreList = new ChairsIgnoreList();
|
||||||
|
ignoreList.load();
|
||||||
pm = this.getServer().getPluginManager();
|
pm = this.getServer().getPluginManager();
|
||||||
pluginFolder = getDataFolder();
|
pluginFolder = getDataFolder();
|
||||||
configFile = new File(pluginFolder, "config.yml");
|
configFile = new File(pluginFolder, "config.yml");
|
||||||
@ -101,14 +102,25 @@ public class Chairs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pm.getPermission("chairs.sit") != null) {
|
ArrayList<String> perms = new ArrayList<String>();
|
||||||
pm.removePermission("chairs.sit");
|
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) {
|
if (opsOverridePerms) {
|
||||||
pm.addPermission(new Permission("chairs.sit","Allows players to sit on blocks",PermissionDefault.OP));
|
pd = PermissionDefault.OP;
|
||||||
} else {
|
} 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
|
// Send sit packet to all online players
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.spoothie.chairs;
|
package net.spoothie.chairs;
|
||||||
|
|
||||||
|
import java.io.Console;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -30,7 +31,7 @@ public class ChairsCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
if (sender.hasPermission("chairs.reload")) {
|
if (sender.hasPermission("chairs.reload") || !(sender instanceof Player)) {
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
plugin.loadConfig();
|
plugin.loadConfig();
|
||||||
sender.sendMessage("Chairs configuration file reloaded.");
|
sender.sendMessage("Chairs configuration file reloaded.");
|
||||||
@ -41,7 +42,7 @@ public class ChairsCommand implements CommandExecutor {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (args[0].equalsIgnoreCase("on")) {
|
if (args[0].equalsIgnoreCase("on")) {
|
||||||
if (p.hasPermission("chairs.self")) {
|
if (p.hasPermission("chairs.self") || !plugin.permissions) {
|
||||||
ignoreList.removePlayer(p.getName());
|
ignoreList.removePlayer(p.getName());
|
||||||
p.sendMessage(ChatColor.GRAY + "You have enabled chairs for yourself!");
|
p.sendMessage(ChatColor.GRAY + "You have enabled chairs for yourself!");
|
||||||
} else {
|
} else {
|
||||||
@ -49,7 +50,7 @@ public class ChairsCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("off")) {
|
if (args[0].equalsIgnoreCase("off")) {
|
||||||
if (p.hasPermission("chairs.self")) {
|
if (p.hasPermission("chairs.self") || !plugin.permissions) {
|
||||||
ignoreList.addPlayer(p.getName());
|
ignoreList.addPlayer(p.getName());
|
||||||
p.sendMessage(ChatColor.GRAY + "You have disabled chairs for yourself!");
|
p.sendMessage(ChatColor.GRAY + "You have disabled chairs for yourself!");
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,10 +16,6 @@ public class ChairsIgnoreList implements Serializable{
|
|||||||
private static ArrayList<String> ignoreList = new ArrayList<String>();
|
private static ArrayList<String> ignoreList = new ArrayList<String>();
|
||||||
private static final String IGNORE_FILE = "plugins/Chairs/ignores.ser";
|
private static final String IGNORE_FILE = "plugins/Chairs/ignores.ser";
|
||||||
|
|
||||||
public void ChairsIgnoreList() {
|
|
||||||
this.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void load() {
|
public void load() {
|
||||||
File file = new File(IGNORE_FILE);
|
File file = new File(IGNORE_FILE);
|
||||||
@ -57,12 +53,12 @@ public class ChairsIgnoreList implements Serializable{
|
|||||||
if (ignoreList.contains(s)) {
|
if (ignoreList.contains(s)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Chairs.get().logInfo("Adding " + s + " to ignore list.");
|
//Chairs.get().logInfo("Adding " + s + " to ignore list.");
|
||||||
ignoreList.add(s);
|
ignoreList.add(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(String 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);
|
ignoreList.remove(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,13 +270,14 @@ public class EventListener implements Listener {
|
|||||||
// Go through the blocks next to the clicked block and check if there are any further stairs.
|
// 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++) {
|
for (int i = 1; i <= plugin.maxChairWidth; i++) {
|
||||||
Block relative = block.getRelative(face, i);
|
Block relative = block.getRelative(face, i);
|
||||||
|
if (relative.getState().getData() instanceof Stairs) {
|
||||||
if (plugin.allowedBlocks.contains(relative.getType()) && ((Stairs) relative.getState().getData()).getDescendingDirection() == ((Stairs) block.getState().getData()).getDescendingDirection()) {
|
if (plugin.allowedBlocks.contains(relative.getType()) && ((Stairs) relative.getState().getData()).getDescendingDirection() == ((Stairs) block.getState().getData()).getDescendingDirection()) {
|
||||||
width++;
|
width++;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,3 @@ commands:
|
|||||||
/<command> reload - reloads the configuration
|
/<command> reload - reloads the configuration
|
||||||
/<command> off - disable chairs for self
|
/<command> off - disable chairs for self
|
||||||
/<command> on - enable 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
|
|
Loading…
Reference in New Issue
Block a user