diff --git a/src/config.yml b/src/config.yml index 4acaed1..66cc49f 100644 --- a/src/config.yml +++ b/src/config.yml @@ -34,4 +34,5 @@ notify-player: true upside-down-check: true seat-occupied-check: true upper-step-check: true -per-item-perms: true \ No newline at end of file +per-item-perms: true +ops-override-perms: false \ No newline at end of file diff --git a/src/net/spoothie/chairs/Chairs.java b/src/net/spoothie/chairs/Chairs.java index 22a550a..aeee2d3 100644 --- a/src/net/spoothie/chairs/Chairs.java +++ b/src/net/spoothie/chairs/Chairs.java @@ -15,13 +15,15 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.v1_4_6.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; public class Chairs extends JavaPlugin { public List allowedBlocks = new ArrayList(); - public boolean sneaking, autoRotate, signCheck, permissions, notifyplayer; + public boolean sneaking, autoRotate, signCheck, permissions, notifyplayer, opsOverridePerms; public boolean invertedStairCheck, seatOccupiedCheck, invertedStepCheck, perItemPerms; public double sittingHeight, distance; public int maxChairWidth; @@ -36,7 +38,7 @@ public class Chairs extends JavaPlugin { @Override public void onEnable() { - + pm = this.getServer().getPluginManager(); pluginFolder = getDataFolder(); configFile = new File(pluginFolder, "config.yml"); createConfig(); @@ -45,7 +47,6 @@ public class Chairs extends JavaPlugin { loadConfig(); EventListener eventListener = new EventListener(this); getServer().getPluginManager().registerEvents(eventListener, this); - pm = this.getServer().getPluginManager(); } @Override @@ -83,6 +84,7 @@ public class Chairs extends JavaPlugin { seatOccupiedCheck = getConfig().getBoolean("seat-occupied-check"); invertedStepCheck = getConfig().getBoolean("upper-step-check"); perItemPerms = getConfig().getBoolean("per-item-perms"); + opsOverridePerms = getConfig().getBoolean("ops-override-perms"); for (String type : getConfig().getStringList("allowed-blocks")) { try { @@ -96,6 +98,15 @@ public class Chairs extends JavaPlugin { logInfo("ERROR: " + e.getMessage()); } } + + if (pm.getPermission("chairs.sit") != null) { + pm.removePermission("chairs.sit"); + } + if (opsOverridePerms) { + pm.addPermission(new Permission("chairs.sit","Allows players to sit on blocks",PermissionDefault.OP)); + } else { + pm.addPermission(new Permission("chairs.sit","Allows players to sit on blocks",PermissionDefault.FALSE)); + } } @Override diff --git a/src/net/spoothie/chairs/EventListener.java b/src/net/spoothie/chairs/EventListener.java index 1b6e2e5..5c05c0e 100644 --- a/src/net/spoothie/chairs/EventListener.java +++ b/src/net/spoothie/chairs/EventListener.java @@ -21,6 +21,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.material.Stairs; import org.bukkit.material.Step; +import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; public class EventListener implements Listener { @@ -73,10 +74,10 @@ public class EventListener implements Listener { plugin.sit.remove(pName); } } - + @EventHandler public void onBlockDestroy(BlockBreakEvent event) { - Block block = event.getBlock(); + Block block = event.getBlock(); if (!plugin.sit.isEmpty()) { ArrayList standList = new ArrayList(); for (String s : plugin.sit.keySet()) { @@ -89,13 +90,13 @@ public class EventListener implements Listener { plugin.sendStand(player); } standList.clear(); - } + } } @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (event.hasBlock() && event.getAction() == Action.RIGHT_CLICK_BLOCK) { - Block block = event.getClickedBlock(); + Block block = event.getClickedBlock(); Stairs stairs = null; Step step = null; double sh = plugin.sittingHeight; @@ -113,24 +114,22 @@ public class EventListener implements Listener { return; } } - if (plugin.perItemPerms) { + if (plugin.perItemPerms) { if (plugin.pm.getPermission("chairs.sit." + block.getTypeId()) == null) { - plugin.pm.addPermission(new org.bukkit.permissions.Permission( - "chairs.sit." + block.getTypeId(), - "Allow players to sit on a '" + block.getType().name() + "'", - PermissionDefault.FALSE)); + plugin.pm.addPermission(new Permission("chairs.sit." + block.getTypeId(), + "Allow players to sit on a '" + block.getType().name() + "'", + PermissionDefault.FALSE)); } if (plugin.pm.getPermission("chairs.sit." + block.getType().toString()) == null) { - plugin.pm.addPermission(new org.bukkit.permissions.Permission( - "chairs.sit." + block.getType().toString(), - "Allow players to sit on a '" + block.getType().name() + "'", - PermissionDefault.FALSE)); - } + plugin.pm.addPermission(new Permission("chairs.sit." + block.getType().toString(), + "Allow players to sit on a '" + block.getType().name() + "'", + PermissionDefault.FALSE)); + } } if (plugin.allowedBlocks.contains(block.getType()) || (player.hasPermission("chairs.sit." + block.getTypeId()) && plugin.perItemPerms) - || (player.hasPermission("chairs.sit." + block.getType().toString())&& plugin.perItemPerms) ) { - + || (player.hasPermission("chairs.sit." + block.getType().toString()) && plugin.perItemPerms)) { + int chairwidth = 1; // Check if block beneath chair is solid. @@ -140,10 +139,10 @@ public class EventListener implements Listener { if (block.getRelative(BlockFace.DOWN).isEmpty()) { return; } - if (!net.minecraft.server.v1_4_6.Block.byId[block.getTypeId()].material.isSolid()) { + if (!net.minecraft.server.v1_4_6.Block.byId[block.getTypeId()].material.isSolid()) { return; - } - + } + // Check if player is sitting. if (plugin.sit.containsKey(event.getPlayer().getName())) { plugin.sit.remove(player.getName()); @@ -227,16 +226,16 @@ public class EventListener implements Listener { plocation.add(0.5D, (sh - 0.5D), 0.5D); switch (stairs.getDescendingDirection()) { case NORTH: - plocation.setYaw(90); - break; - case EAST: plocation.setYaw(180); break; + case EAST: + plocation.setYaw(-90); + break; case SOUTH: - plocation.setYaw(270); + plocation.setYaw(0); break; case WEST: - plocation.setYaw(0); + plocation.setYaw(90); } player.teleport(plocation); } else { @@ -253,7 +252,7 @@ public class EventListener implements Listener { Timer timer = new Timer(); long delay = 1 * 2000; - timer.schedule(new sendSitTask(), delay); + timer.schedule(new sendSitTask(), delay); } } } diff --git a/src/plugin.yml b/src/plugin.yml index 9a5bf69..1d26b38 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,5 +1,5 @@ name: Chairs -version: 1.13.2 +version: 1.13.5 description: Let players sit on blocks. authors: - spoothie @@ -8,8 +8,4 @@ main: net.spoothie.chairs.Chairs commands: chairs: description: Reloads the Chairs configuration file. - usage: /chairs reload -permissions: - chairs.sit: - description: Allows players to sit on blocks. - default: false \ No newline at end of file + usage: /chairs reload \ No newline at end of file