diff --git a/pom.xml b/pom.xml
index b55321c..11b8959 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.drtshock
PlayerVaults
- 3.5.6
+ 3.5.7
PlayerVaults
http://dev.bukkit.org/bukkit-plugins/playervaults/
diff --git a/src/main/java/com/drtshock/playervaults/PlayerVaults.java b/src/main/java/com/drtshock/playervaults/PlayerVaults.java
index 168aab6..dcb3cd8 100644
--- a/src/main/java/com/drtshock/playervaults/PlayerVaults.java
+++ b/src/main/java/com/drtshock/playervaults/PlayerVaults.java
@@ -18,6 +18,7 @@ package com.drtshock.playervaults;
import com.drtshock.playervaults.commands.*;
import com.drtshock.playervaults.listeners.Listeners;
+import com.drtshock.playervaults.listeners.SignListener;
import com.drtshock.playervaults.listeners.VaultPreloadListener;
import com.drtshock.playervaults.tasks.Cleanup;
import com.drtshock.playervaults.tasks.UUIDConversion;
@@ -90,7 +91,6 @@ public class PlayerVaults extends JavaPlugin {
debug("check update", System.currentTimeMillis());
getCommand("pv").setExecutor(new VaultCommand());
getCommand("pvdel").setExecutor(new DeleteCommand());
- getCommand("pvsign").setExecutor(new SignCommand());
getCommand("workbench").setExecutor(new WorkbenchCommand());
getCommand("pvconvert").setExecutor(new ConvertCommand());
debug("registered commands", System.currentTimeMillis());
@@ -130,7 +130,10 @@ public class PlayerVaults extends JavaPlugin {
player.closeInventory();
}
- saveSignsFile();
+
+ if (getConfig().getBoolean("cleanup.enable", false)) {
+ saveSignsFile();
+ }
}
@Override
@@ -196,6 +199,12 @@ public class PlayerVaults extends JavaPlugin {
}
private void loadSigns() {
+ if (!getConfig().getBoolean("signs-enabled", true)) {
+ return;
+ }
+
+ getCommand("pvsign").setExecutor(new SignCommand());
+ getServer().getPluginManager().registerEvents(new SignListener(this), this);
File signs = new File(getDataFolder(), "signs.yml");
if (!signs.exists()) {
try {
@@ -227,6 +236,10 @@ public class PlayerVaults extends JavaPlugin {
}
private void saveSignsFile() {
+ if (!getConfig().getBoolean("signs-enabled", true)) {
+ return;
+ }
+
saveQueued = false;
try {
signs.save(this.signsFile);
diff --git a/src/main/java/com/drtshock/playervaults/listeners/Listeners.java b/src/main/java/com/drtshock/playervaults/listeners/Listeners.java
index 0b68984..692c331 100644
--- a/src/main/java/com/drtshock/playervaults/listeners/Listeners.java
+++ b/src/main/java/com/drtshock/playervaults/listeners/Listeners.java
@@ -31,9 +31,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
-import org.bukkit.event.block.BlockBreakEvent;
-import org.bukkit.event.block.BlockPhysicsEvent;
-import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
@@ -101,125 +98,6 @@ public class Listeners implements Listener {
}
}
- @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
- public void onInteract(PlayerInteractEvent event) {
- Player player = event.getPlayer();
- if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
- if (PlayerVaults.getInstance().getInVault().containsKey(player.getName())) {
- Block block = event.getClickedBlock();
- // Different inventories that we don't want the player to open.
- if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.ENDER_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE || block.getType() == Material.BREWING_STAND || block.getType() == Material.ENCHANTMENT_TABLE || block.getType() == Material.BEACON) {
- event.setCancelled(true);
- }
- }
- }
- if (PlayerVaults.getInstance().getSetSign().containsKey(player.getName())) {
- int i = PlayerVaults.getInstance().getSetSign().get(player.getName()).getChest();
- boolean self = PlayerVaults.getInstance().getSetSign().get(player.getName()).isSelf();
- String owner = self ? null : PlayerVaults.getInstance().getSetSign().get(player.getName()).getOwner();
- PlayerVaults.getInstance().getSetSign().remove(player.getName());
- event.setCancelled(true);
- if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
- if (event.getClickedBlock().getType() == Material.WALL_SIGN || event.getClickedBlock().getType() == Material.SIGN_POST) {
- Sign s = (Sign) event.getClickedBlock().getState();
- Location l = s.getLocation();
- String world = l.getWorld().getName();
- int x = l.getBlockX();
- int y = l.getBlockY();
- int z = l.getBlockZ();
- if (self) {
- plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".self", true);
- } else {
- plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".owner", owner);
- }
- plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".chest", i);
- plugin.saveSigns();
- player.sendMessage(Lang.TITLE.toString() + Lang.SET_SIGN);
- } else {
- player.sendMessage(Lang.TITLE.toString() + Lang.NOT_A_SIGN);
- }
- } else {
- player.sendMessage(Lang.TITLE.toString() + Lang.NOT_A_SIGN);
- }
- return;
- }
- Block b = event.getClickedBlock();
- if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
- if (b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST) {
- Location l = b.getLocation();
- String world = l.getWorld().getName();
- int x = l.getBlockX();
- int y = l.getBlockY();
- int z = l.getBlockZ();
- if (plugin.getSigns().getKeys(false).contains(world + ";;" + x + ";;" + y + ";;" + z)) {
- int num = PlayerVaults.getInstance().getSigns().getInt(world + ";;" + x + ";;" + y + ";;" + z + ".chest", 1);
- if (player.hasPermission("playervaults.signs.use") || player.hasPermission("playervaults.signs.bypass")) {
- boolean self = PlayerVaults.getInstance().getSigns().getBoolean(world + ";;" + x + ";;" + y + ";;" + z + ".self", false);
- String owner = self ? player.getName() : PlayerVaults.getInstance().getSigns().getString(world + ";;" + x + ";;" + y + ";;" + z + ".owner");
- OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(owner != null ? owner : event.getPlayer().getName()); // Not best way but :\
- if (offlinePlayer == null || !offlinePlayer.hasPlayedBefore()) {
- player.sendMessage(Lang.TITLE.toString() + Lang.VAULT_DOES_NOT_EXIST.toString());
- return;
- }
- if (self) {
- // We already checked that they can use signs, now lets check if they have this many vaults.
- if (VaultOperations.checkPerms(player, num)) {
- Inventory inv = UUIDVaultManager.getInstance().loadOwnVault(player, num, VaultOperations.getMaxVaultSize(player));
- player.openInventory(inv);
- } else {
- player.sendMessage(Lang.TITLE.toString() + Lang.NO_PERMS.toString());
- return; // Otherwise it would try to add vault view info down there.
- }
- } else {
- Inventory inv = UUIDVaultManager.getInstance().loadOtherVault(offlinePlayer.getUniqueId(), num, VaultOperations.getMaxVaultSize(offlinePlayer));
- if (inv == null) {
- player.sendMessage(Lang.TITLE.toString() + Lang.VAULT_DOES_NOT_EXIST.toString());
- } else {
- player.openInventory(inv);
- }
- }
- PlayerVaults.getInstance().getInVault().put(player.getUniqueId().toString(), new VaultViewInfo((self) ? player.getName() : owner, num));
- event.setCancelled(true);
- player.sendMessage(Lang.TITLE.toString() + Lang.OPEN_WITH_SIGN.toString().replace("%v", String.valueOf(num)).replace("%p", (self) ? player.getName() : owner));
- } else {
- player.sendMessage(Lang.TITLE.toString() + Lang.NO_PERMS);
- }
- }
- }
- }
- }
-
- @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
- public void onBlockPhysics(BlockPhysicsEvent event) {
- blockChangeCheck(event.getBlock().getLocation());
- }
-
- @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
- public void onEntityChangeBlock(EntityChangeBlockEvent event) {
- blockChangeCheck(event.getBlock().getLocation());
- }
-
- @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
- public void onBlockBreak(BlockBreakEvent event) {
- blockChangeCheck(event.getBlock().getLocation());
- }
-
- /**
- * Check if the location given is a sign, and if so, remove it from the signs.yml file
- *
- * @param location The location to check
- */
- public void blockChangeCheck(Location location) {
- String world = location.getWorld().getName();
- int x = location.getBlockX();
- int y = location.getBlockY();
- int z = location.getBlockZ();
- if (plugin.getSigns().getKeys(false).contains(world + ";;" + x + ";;" + y + ";;" + z)) {
- plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z, null);
- plugin.saveSigns();
- }
- }
-
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onInteractEntity(PlayerInteractEntityEvent event) {
Player player = event.getPlayer();
diff --git a/src/main/java/com/drtshock/playervaults/listeners/SignListener.java b/src/main/java/com/drtshock/playervaults/listeners/SignListener.java
new file mode 100644
index 0000000..deb406d
--- /dev/null
+++ b/src/main/java/com/drtshock/playervaults/listeners/SignListener.java
@@ -0,0 +1,155 @@
+package com.drtshock.playervaults.listeners;
+
+import com.drtshock.playervaults.PlayerVaults;
+import com.drtshock.playervaults.util.Lang;
+import com.drtshock.playervaults.vaultmanagement.UUIDVaultManager;
+import com.drtshock.playervaults.vaultmanagement.VaultOperations;
+import com.drtshock.playervaults.vaultmanagement.VaultViewInfo;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.block.Block;
+import org.bukkit.block.Sign;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.block.BlockBreakEvent;
+import org.bukkit.event.block.BlockPhysicsEvent;
+import org.bukkit.event.entity.EntityChangeBlockEvent;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.inventory.Inventory;
+
+public class SignListener implements Listener {
+
+ private PlayerVaults plugin;
+
+ public SignListener(PlayerVaults plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ public void onInteract(PlayerInteractEvent event) {
+ Player player = event.getPlayer();
+ if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+ if (PlayerVaults.getInstance().getInVault().containsKey(player.getName())) {
+ Block block = event.getClickedBlock();
+ // Different inventories that we don't want the player to open.
+ if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.ENDER_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE || block.getType() == Material.BREWING_STAND || block.getType() == Material.ENCHANTMENT_TABLE || block.getType() == Material.BEACON) {
+ event.setCancelled(true);
+ }
+ }
+ }
+ if (PlayerVaults.getInstance().getSetSign().containsKey(player.getName())) {
+ int i = PlayerVaults.getInstance().getSetSign().get(player.getName()).getChest();
+ boolean self = PlayerVaults.getInstance().getSetSign().get(player.getName()).isSelf();
+ String owner = self ? null : PlayerVaults.getInstance().getSetSign().get(player.getName()).getOwner();
+ PlayerVaults.getInstance().getSetSign().remove(player.getName());
+ event.setCancelled(true);
+ if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+ if (event.getClickedBlock().getType() == Material.WALL_SIGN || event.getClickedBlock().getType() == Material.SIGN_POST) {
+ Sign s = (Sign) event.getClickedBlock().getState();
+ Location l = s.getLocation();
+ String world = l.getWorld().getName();
+ int x = l.getBlockX();
+ int y = l.getBlockY();
+ int z = l.getBlockZ();
+ if (self) {
+ plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".self", true);
+ } else {
+ plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".owner", owner);
+ }
+ plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".chest", i);
+ plugin.saveSigns();
+ player.sendMessage(Lang.TITLE.toString() + Lang.SET_SIGN);
+ } else {
+ player.sendMessage(Lang.TITLE.toString() + Lang.NOT_A_SIGN);
+ }
+ } else {
+ player.sendMessage(Lang.TITLE.toString() + Lang.NOT_A_SIGN);
+ }
+ return;
+ }
+ Block b = event.getClickedBlock();
+ if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+ if (b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST) {
+ Location l = b.getLocation();
+ String world = l.getWorld().getName();
+ int x = l.getBlockX();
+ int y = l.getBlockY();
+ int z = l.getBlockZ();
+ if (plugin.getSigns().getKeys(false).contains(world + ";;" + x + ";;" + y + ";;" + z)) {
+ int num = PlayerVaults.getInstance().getSigns().getInt(world + ";;" + x + ";;" + y + ";;" + z + ".chest", 1);
+ if (player.hasPermission("playervaults.signs.use") || player.hasPermission("playervaults.signs.bypass")) {
+ boolean self = PlayerVaults.getInstance().getSigns().getBoolean(world + ";;" + x + ";;" + y + ";;" + z + ".self", false);
+ String owner = self ? player.getName() : PlayerVaults.getInstance().getSigns().getString(world + ";;" + x + ";;" + y + ";;" + z + ".owner");
+ OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(owner != null ? owner : event.getPlayer().getName()); // Not best way but :\
+ if (offlinePlayer == null || !offlinePlayer.hasPlayedBefore()) {
+ player.sendMessage(Lang.TITLE.toString() + Lang.VAULT_DOES_NOT_EXIST.toString());
+ return;
+ }
+ if (self) {
+ // We already checked that they can use signs, now lets check if they have this many vaults.
+ if (VaultOperations.checkPerms(player, num)) {
+ Inventory inv = UUIDVaultManager.getInstance().loadOwnVault(player, num, VaultOperations.getMaxVaultSize(player));
+ player.openInventory(inv);
+ } else {
+ player.sendMessage(Lang.TITLE.toString() + Lang.NO_PERMS.toString());
+ return; // Otherwise it would try to add vault view info down there.
+ }
+ } else {
+ Inventory inv = UUIDVaultManager.getInstance().loadOtherVault(offlinePlayer.getUniqueId(), num, VaultOperations.getMaxVaultSize(offlinePlayer));
+ if (inv == null) {
+ player.sendMessage(Lang.TITLE.toString() + Lang.VAULT_DOES_NOT_EXIST.toString());
+ } else {
+ player.openInventory(inv);
+ }
+ }
+ PlayerVaults.getInstance().getInVault().put(player.getUniqueId().toString(), new VaultViewInfo((self) ? player.getName() : owner, num));
+ event.setCancelled(true);
+ player.sendMessage(Lang.TITLE.toString() + Lang.OPEN_WITH_SIGN.toString().replace("%v", String.valueOf(num)).replace("%p", (self) ? player.getName() : owner));
+ } else {
+ player.sendMessage(Lang.TITLE.toString() + Lang.NO_PERMS);
+ }
+ }
+ }
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ public void onBlockPhysics(BlockPhysicsEvent event) {
+ blockChangeCheck(event.getBlock().getLocation());
+ }
+
+ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
+ blockChangeCheck(event.getBlock().getLocation());
+ }
+
+ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ public void onBlockBreak(BlockBreakEvent event) {
+ blockChangeCheck(event.getBlock().getLocation());
+ }
+
+ /**
+ * Check if the location given is a sign, and if so, remove it from the signs.yml file
+ *
+ * @param location The location to check
+ */
+ public void blockChangeCheck(Location location) {
+ if (plugin.getSigns().getKeys(false).isEmpty()) {
+ return; // Save us a check.
+ }
+
+ String world = location.getWorld().getName();
+ int x = location.getBlockX();
+ int y = location.getBlockY();
+ int z = location.getBlockZ();
+ if (plugin.getSigns().getKeys(false).contains(world + ";;" + x + ";;" + y + ";;" + z)) {
+ plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z, null);
+ plugin.saveSigns();
+ }
+ }
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 04787f6..3263cc8 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -14,6 +14,12 @@ download-update: false
# Should probably only enabled this if you're working with drtshock to fix something.
debug: false
+# Signs
+# Do you want to enable signs?
+# You can checkout the project page for info on what this is if you don't know.
+# This can save some performance on servers with 250+ players if disabled.
+signs-enabled: false
+
# Settings here are for economy integration. playervaults.free bypasses it.
economy:
enabled: false