From 638712566a5c11ee879b5562b2cf4e04610881cd Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 25 Jun 2018 14:35:31 -0700 Subject: [PATCH] Added leave and join settings for money, inventory --- .../us/tastybento/bskyblock/Settings.java | 112 ++++++++++++++++++ .../api/configuration/WorldSettings.java | 30 +++++ .../managers/IslandWorldManager.java | 43 +++++++ 3 files changed, 185 insertions(+) diff --git a/src/main/java/us/tastybento/bskyblock/Settings.java b/src/main/java/us/tastybento/bskyblock/Settings.java index 8db97a69a..ba9d51773 100644 --- a/src/main/java/us/tastybento/bskyblock/Settings.java +++ b/src/main/java/us/tastybento/bskyblock/Settings.java @@ -306,6 +306,40 @@ public class Settings implements DataObject, WorldSettings { @ConfigEntry(path = "island.reset.kicked-keep-inventory") private boolean kickedKeepInventory = false; + @ConfigComment("What the plugin should reset when the player joins or creates an island") + @ConfigComment("Reset Money - if this is true, will reset the player's money to the starting money") + @ConfigComment("Recommendation is that this is set to true, but if you run multi-worlds") + @ConfigComment("make sure your economy handles multi-worlds too.") + @ConfigEntry(path = "island.reset.on-join.money") + private boolean onJoinResetMoney = false; + + @ConfigComment("Reset inventory - if true, the player's inventory will be cleared.") + @ConfigComment("Note: if you have MultiInv running or a similar inventory control plugin, that") + @ConfigComment("plugin may still reset the inventory when the world changes.") + @ConfigEntry(path = "island.reset.on-join.inventory") + private boolean onJoinResetInventory = false; + + @ConfigComment("Reset Ender Chest - if true, the player's Ender Chest will be cleared.") + @ConfigEntry(path = "island.reset.on-join.ender-chest") + private boolean onJoinResetEnderChest = false; + + @ConfigComment("What the plugin should reset when the player leaves or is kicked from an island") + @ConfigComment("Reset Money - if this is true, will reset the player's money to the starting money") + @ConfigComment("Recommendation is that this is set to true, but if you run multi-worlds") + @ConfigComment("make sure your economy handles multi-worlds too.") + @ConfigEntry(path = "island.reset.on-leave.money") + private boolean onLeaveResetMoney = false; + + @ConfigComment("Reset inventory - if true, the player's inventory will be cleared.") + @ConfigComment("Note: if you have MultiInv running or a similar inventory control plugin, that") + @ConfigComment("plugin may still reset the inventory when the world changes.") + @ConfigEntry(path = "island.reset.on-leave.inventory") + private boolean onLeaveResetInventory = false; + + @ConfigComment("Reset Ender Chest - if true, the player's Ender Chest will be cleared.") + @ConfigEntry(path = "island.reset.on-leave.ender-chest") + private boolean onLeaveResetEnderChest = false; + @ConfigEntry(path = "island.make-island-if-none") private boolean makeIslandIfNone = false; @ConfigComment("Immediately teleport player to their island (home 1 if it exists) when entering the world") @@ -1449,6 +1483,84 @@ public class Settings implements DataObject, WorldSettings { public void setRemoveMobsWhitelist(Set removeMobsWhitelist) { this.removeMobsWhitelist = removeMobsWhitelist; } + /** + * @return the onJoinResetMoney + */ + @Override + public boolean isOnJoinResetMoney() { + return onJoinResetMoney; + } + /** + * @return the onJoinResetInventory + */ + @Override + public boolean isOnJoinResetInventory() { + return onJoinResetInventory; + } + /** + * @return the onJoinResetEnderChest + */ + @Override + public boolean isOnJoinResetEnderChest() { + return onJoinResetEnderChest; + } + /** + * @return the onLeaveResetMoney + */ + @Override + public boolean isOnLeaveResetMoney() { + return onLeaveResetMoney; + } + /** + * @return the onLeaveResetInventory + */ + @Override + public boolean isOnLeaveResetInventory() { + return onLeaveResetInventory; + } + /** + * @return the onLeaveResetEnderChest + */ + @Override + public boolean isOnLeaveResetEnderChest() { + return onLeaveResetEnderChest; + } + /** + * @param onJoinResetMoney the onJoinResetMoney to set + */ + public void setOnJoinResetMoney(boolean onJoinResetMoney) { + this.onJoinResetMoney = onJoinResetMoney; + } + /** + * @param onJoinResetInventory the onJoinResetInventory to set + */ + public void setOnJoinResetInventory(boolean onJoinResetInventory) { + this.onJoinResetInventory = onJoinResetInventory; + } + /** + * @param onJoinResetEnderChest the onJoinResetEnderChest to set + */ + public void setOnJoinResetEnderChest(boolean onJoinResetEnderChest) { + this.onJoinResetEnderChest = onJoinResetEnderChest; + } + /** + * @param onLeaveResetMoney the onLeaveResetMoney to set + */ + public void setOnLeaveResetMoney(boolean onLeaveResetMoney) { + this.onLeaveResetMoney = onLeaveResetMoney; + } + /** + * @param onLeaveResetInventory the onLeaveResetInventory to set + */ + public void setOnLeaveResetInventory(boolean onLeaveResetInventory) { + this.onLeaveResetInventory = onLeaveResetInventory; + } + /** + * @param onLeaveResetEnderChest the onLeaveResetEnderChest to set + */ + public void setOnLeaveResetEnderChest(boolean onLeaveResetEnderChest) { + this.onLeaveResetEnderChest = onLeaveResetEnderChest; + } } \ No newline at end of file diff --git a/src/main/java/us/tastybento/bskyblock/api/configuration/WorldSettings.java b/src/main/java/us/tastybento/bskyblock/api/configuration/WorldSettings.java index 65c29318c..b2a3bf7fc 100644 --- a/src/main/java/us/tastybento/bskyblock/api/configuration/WorldSettings.java +++ b/src/main/java/us/tastybento/bskyblock/api/configuration/WorldSettings.java @@ -152,4 +152,34 @@ public interface WorldSettings { */ Set getRemoveMobsWhitelist(); + /** + * @return the onJoinResetMoney + */ + public boolean isOnJoinResetMoney(); + + /** + * @return the onJoinResetInventory + */ + public boolean isOnJoinResetInventory(); + + /** + * @return the onJoinResetEnderChest + */ + public boolean isOnJoinResetEnderChest(); + + /** + * @return the onLeaveResetMoney + */ + public boolean isOnLeaveResetMoney(); + + /** + * @return the onLeaveResetInventory + */ + public boolean isOnLeaveResetInventory(); + + /** + * @return the onLeaveResetEnderChest + */ + public boolean isOnLeaveResetEnderChest(); + } diff --git a/src/main/java/us/tastybento/bskyblock/managers/IslandWorldManager.java b/src/main/java/us/tastybento/bskyblock/managers/IslandWorldManager.java index 76380597d..04a73ecbf 100644 --- a/src/main/java/us/tastybento/bskyblock/managers/IslandWorldManager.java +++ b/src/main/java/us/tastybento/bskyblock/managers/IslandWorldManager.java @@ -495,4 +495,47 @@ public class IslandWorldManager { public Set getRemoveMobsWhitelist(World world) { return worldSettings.get(Util.getWorld(world)).getRemoveMobsWhitelist(); } + + /** + * @return the onJoinResetMoney + */ + public boolean isOnJoinResetMoney(World world) { + return worldSettings.get(Util.getWorld(world)).isOnJoinResetMoney(); + } + + /** + * @return the onJoinResetInventory + */ + public boolean isOnJoinResetInventory(World world) { + return worldSettings.get(Util.getWorld(world)).isOnJoinResetInventory(); + } + + /** + * @return the onJoinResetEnderChest + */ + public boolean isOnJoinResetEnderChest(World world) { + return worldSettings.get(Util.getWorld(world)).isOnJoinResetEnderChest(); + } + + /** + * @return the onLeaveResetMoney + */ + public boolean isOnLeaveResetMoney(World world) { + return worldSettings.get(Util.getWorld(world)).isOnLeaveResetMoney(); + } + + /** + * @return the onLeaveResetInventory + */ + public boolean isOnLeaveResetInventory(World world) { + return worldSettings.get(Util.getWorld(world)).isOnLeaveResetInventory(); + } + + /** + * @return the onLeaveResetEnderChest + */ + public boolean isOnLeaveResetEnderChest(World world) { + return worldSettings.get(Util.getWorld(world)).isOnLeaveResetEnderChest(); + } + }