diff --git a/com/Acrobot/ChestShop/ChestShop.java b/com/Acrobot/ChestShop/ChestShop.java index d80088a..5a219cc 100644 --- a/com/Acrobot/ChestShop/ChestShop.java +++ b/com/Acrobot/ChestShop/ChestShop.java @@ -13,7 +13,6 @@ import com.Acrobot.ChestShop.Logging.FileWriterQueue; import com.Acrobot.ChestShop.Protection.MaskChest; import com.avaje.ebean.EbeanServer; import com.lennardf1989.bukkitex.Database; -import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.event.Event; import org.bukkit.event.Listener; @@ -125,9 +124,7 @@ public class ChestShop extends JavaPlugin { config.getString("database.url"), config.getString("database.username"), config.getString("database.password"), - config.getString("database.isolation"), - false, - true + config.getString("database.isolation") ); DB = database.getDatabase(); diff --git a/com/Acrobot/ChestShop/Config/Config.java b/com/Acrobot/ChestShop/Config/Config.java index a870e0d..f8011ba 100644 --- a/com/Acrobot/ChestShop/Config/Config.java +++ b/com/Acrobot/ChestShop/Config/Config.java @@ -1,6 +1,6 @@ package com.Acrobot.ChestShop.Config; -import com.LRFLEW.register.payment.forChestShop.Methods; +import com.nijikokun.register.payment.forChestShop.Methods; /** * @author Acrobot @@ -10,7 +10,7 @@ public class Config { public static void setup(ConfigObject cfg) { config = cfg; - Methods.preferred = Config.getString(Property.PREFERRED_ECONOMY_PLUGIN); + Methods.setPreferred(Config.getString(Property.PREFERRED_ECONOMY_PLUGIN)); } public static boolean getBoolean(Property value) { diff --git a/com/Acrobot/ChestShop/Config/Language.java b/com/Acrobot/ChestShop/Config/Language.java index f32e53d..12d06a9 100644 --- a/com/Acrobot/ChestShop/Config/Language.java +++ b/com/Acrobot/ChestShop/Config/Language.java @@ -37,7 +37,9 @@ public enum Language { SHOP_CREATED("Shop successfully created!"), NO_PERMISSION("You don't have permissions to do that!"), - INCORRECT_ITEM_ID("You have specified invalid item id!"); + INCORRECT_ITEM_ID("You have specified invalid item id!"), + + TOWNY_CANNOT_CREATE_SHOP_HERE("You can't create shop here!"); private final String text; diff --git a/com/Acrobot/ChestShop/Config/Property.java b/com/Acrobot/ChestShop/Config/Property.java index 6c3910b..45f8984 100644 --- a/com/Acrobot/ChestShop/Config/Property.java +++ b/com/Acrobot/ChestShop/Config/Property.java @@ -24,7 +24,8 @@ public enum Property { MASK_CHESTS_AS_OTHER_BLOCKS(false, "Do you want to mask shop chests as other blocks? HIGHLY EXPERIMENTAL, CAN LAG!"), SHOW_MESSAGE_OUT_OF_STOCK(true, "Do you want to show \"Out of stock\" messages?"), SHOW_TRANSACTION_INFORMATION_CLIENT(true, "Do you want to show \"You bought/sold... \" messages?"), - SHOW_TRANSACTION_INFORMATION_OWNER(true, "Do you want to show \"Somebody bought/sold... \" messages?"); + SHOW_TRANSACTION_INFORMATION_OWNER(true, "Do you want to show \"Somebody bought/sold... \" messages?"), + TOWNY_INTEGRATION(false, "Do you want to only let people build inside shop plots?"); private final Object value; diff --git a/com/Acrobot/ChestShop/Economy.java b/com/Acrobot/ChestShop/Economy.java index 6274c74..ca97a09 100644 --- a/com/Acrobot/ChestShop/Economy.java +++ b/com/Acrobot/ChestShop/Economy.java @@ -1,7 +1,7 @@ package com.Acrobot.ChestShop; import com.Acrobot.ChestShop.Utils.uLongName; -import com.LRFLEW.register.payment.forChestShop.Method; +import com.nijikokun.register.payment.forChestShop.Method; /** * @author Acrobot diff --git a/com/Acrobot/ChestShop/Listeners/blockBreak.java b/com/Acrobot/ChestShop/Listeners/blockBreak.java index bbaf84b..d0b33b5 100644 --- a/com/Acrobot/ChestShop/Listeners/blockBreak.java +++ b/com/Acrobot/ChestShop/Listeners/blockBreak.java @@ -11,14 +11,14 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.material.PistonBaseMaterial; /** * @author Acrobot */ public class blockBreak extends BlockListener { public static boolean cancellingBlockBreak(Block block, Player player) { - if (player != null && (Permission.has(player, Permission.ADMIN) || Permission.has(player, Permission.MOD))) return false; - + if (block == null || (player != null && (Permission.has(player, Permission.ADMIN) || Permission.has(player, Permission.MOD)))) return false; if (uSign.isSign(block)) block.getState().update(); Sign sign = uBlock.findRestrictedSign(block); @@ -54,8 +54,10 @@ public class blockBreak extends BlockListener { } public void onBlockPistonRetract(BlockPistonRetractEvent event) { - try{ - if (!uSign.isSign(event.getRetractLocation().getBlock()) && cancellingBlockBreak(event.getRetractLocation().getBlock(), null)) event.setCancelled(true); - } catch (Exception ignored){} + if (cancellingBlockBreak(getRetractBlock(event), null)) event.setCancelled(true); + } + + private static Block getRetractBlock(BlockPistonRetractEvent event) { + return event.getBlock().getState().getData() instanceof PistonBaseMaterial ? event.getRetractLocation().getBlock() : null; } } diff --git a/com/Acrobot/ChestShop/Listeners/playerInteract.java b/com/Acrobot/ChestShop/Listeners/playerInteract.java index 17bb4ce..bc9f8d3 100644 --- a/com/Acrobot/ChestShop/Listeners/playerInteract.java +++ b/com/Acrobot/ChestShop/Listeners/playerInteract.java @@ -12,6 +12,7 @@ import com.Acrobot.ChestShop.Utils.uLongName; import com.Acrobot.ChestShop.Utils.uSign; import net.minecraft.server.IInventory; import net.minecraft.server.InventoryLargeChest; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Chest; @@ -50,7 +51,7 @@ public class playerInteract extends PlayerListener { } } - if (!uSign.isSign(block)) return; //It's not a sign! + if (!uSign.isSign(block)) return; Sign sign = (Sign) block.getState(); if (!uSign.isValid(sign) || !enoughTimeHasPassed(player) || player.isSneaking()) return; @@ -59,8 +60,8 @@ public class playerInteract extends PlayerListener { if (action == Action.RIGHT_CLICK_BLOCK) event.setCancelled(true); - if (uLongName.stripName(player.getName()).equals(sign.getLine(0)) && (action != Action.LEFT_CLICK_BLOCK || !Config.getBoolean(Property.ALLOW_LEFT_CLICK_DESTROYING))) { - showChestGUI(player, block); + if (uLongName.stripName(player.getName()).equals(sign.getLine(0))) { + if (action != Action.LEFT_CLICK_BLOCK || !Config.getBoolean(Property.ALLOW_LEFT_CLICK_DESTROYING)) showChestGUI(player, block); return; } @@ -96,9 +97,7 @@ public class playerInteract extends PlayerListener { IInventory inventory = ((CraftInventory) chest.getInventory()).getInventory(); chest = uBlock.findNeighbor(chest); - if (chest != null) { //There is also a neighbor chest - inventory = new InventoryLargeChest(player.getName() + "'s Shop", inventory, ((CraftInventory) chest.getInventory()).getInventory()); - } + if (chest != null) inventory = new InventoryLargeChest(player.getName() + "'s Shop", inventory, ((CraftInventory) chest.getInventory()).getInventory()); ((CraftPlayer) player).getHandle().a(inventory); //Show inventory on the screen } diff --git a/com/Acrobot/ChestShop/Listeners/pluginDisable.java b/com/Acrobot/ChestShop/Listeners/pluginDisable.java index 88b1545..b174093 100644 --- a/com/Acrobot/ChestShop/Listeners/pluginDisable.java +++ b/com/Acrobot/ChestShop/Listeners/pluginDisable.java @@ -1,7 +1,7 @@ package com.Acrobot.ChestShop.Listeners; import com.Acrobot.ChestShop.Economy; -import com.LRFLEW.register.payment.forChestShop.Methods; +import com.nijikokun.register.payment.forChestShop.Methods; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.ServerListener; diff --git a/com/Acrobot/ChestShop/Listeners/pluginEnable.java b/com/Acrobot/ChestShop/Listeners/pluginEnable.java index b375d6c..847d27d 100644 --- a/com/Acrobot/ChestShop/Listeners/pluginEnable.java +++ b/com/Acrobot/ChestShop/Listeners/pluginEnable.java @@ -8,10 +8,13 @@ import com.Acrobot.ChestShop.Protection.Plugins.DeadboltPlugin; import com.Acrobot.ChestShop.Protection.Plugins.LWCplugin; import com.Acrobot.ChestShop.Protection.Plugins.LockettePlugin; import com.Acrobot.ChestShop.Protection.Security; -import com.LRFLEW.register.payment.forChestShop.Methods; +import com.Acrobot.ChestShop.Utils.uNumber; +import com.Acrobot.ChestShop.Utils.uTowny; import com.daemitus.deadbolt.Deadbolt; import com.griefcraft.lwc.LWCPlugin; import com.nijikokun.bukkit.Permissions.Permissions; +import com.nijikokun.register.payment.forChestShop.Methods; +import com.palmergames.bukkit.towny.Towny; import info.somethingodd.bukkit.OddItem.OddItem; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener; @@ -57,6 +60,13 @@ public class pluginEnable extends ServerListener { } else if (name.equals("OddItem")) { if (Odd.oddItem != null) return; Odd.oddItem = (OddItem) plugin; + } else if (name.equals("Towny")) { + if (uTowny.towny != null) return; + int versionNumber = 0; + String[] split = plugin.getDescription().getVersion().split("\\."); + for (int i = 0; i < 4; i++) if (split.length >= i+1 && uNumber.isInteger(split[i])) versionNumber += (Math.pow(10, (3 - i) << 1) * Integer.parseInt(split[i])); //EPIC CODE RIGHT HERE + if(versionNumber < 760047){ System.out.println(ChestShop.chatPrefix + "Your Towny version is outdated! Need version AT LEAST 0.76.0.47! - Your version is " + plugin.getDescription().getVersion()); return; } + uTowny.towny = (Towny) plugin; } PluginDescriptionFile description = plugin.getDescription(); System.out.println(ChestShop.chatPrefix + description.getName() + " version " + description.getVersion() + " loaded."); diff --git a/com/Acrobot/ChestShop/Listeners/signChange.java b/com/Acrobot/ChestShop/Listeners/signChange.java index de8ee49..3cf4dfe 100644 --- a/com/Acrobot/ChestShop/Listeners/signChange.java +++ b/com/Acrobot/ChestShop/Listeners/signChange.java @@ -9,10 +9,7 @@ import com.Acrobot.ChestShop.Permission; import com.Acrobot.ChestShop.Protection.Plugins.Default; import com.Acrobot.ChestShop.Protection.Security; import com.Acrobot.ChestShop.Signs.restrictedSign; -import com.Acrobot.ChestShop.Utils.uBlock; -import com.Acrobot.ChestShop.Utils.uLongName; -import com.Acrobot.ChestShop.Utils.uNumber; -import com.Acrobot.ChestShop.Utils.uSign; +import com.Acrobot.ChestShop.Utils.*; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -92,6 +89,13 @@ public class signChange extends BlockListener { } Block chestBlock = chest.getBlock(); + + if(!uTowny.canBuild(player, signBlock.getLocation(), chestBlock.getLocation())){ + player.sendMessage(Config.getLocal(Language.TOWNY_CANNOT_CREATE_SHOP_HERE)); + dropSign(event); + return; + } + boolean canAccess = !Security.isProtected(chestBlock) || Security.canAccess(player, chestBlock); if (!(Security.protection instanceof Default) && canAccess) { diff --git a/com/Acrobot/ChestShop/Utils/uTowny.java b/com/Acrobot/ChestShop/Utils/uTowny.java new file mode 100644 index 0000000..66681e8 --- /dev/null +++ b/com/Acrobot/ChestShop/Utils/uTowny.java @@ -0,0 +1,36 @@ +package com.Acrobot.ChestShop.Utils; + +import com.Acrobot.ChestShop.Config.Config; +import com.Acrobot.ChestShop.Config.Property; +import com.palmergames.bukkit.towny.Towny; +import com.palmergames.bukkit.towny.object.TownBlock; +import com.palmergames.bukkit.towny.object.TownBlockType; +import com.palmergames.bukkit.towny.object.TownyPermission; +import org.bukkit.Location; +import org.bukkit.entity.Player; + + +/** + * @author Acrobot + */ +public class uTowny { + public static Towny towny; + + public static boolean isInsideShopPlot(Location chestlocation, Location signLocation) { + return towny.getTownyUniverse().getTownBlock(chestlocation).getType() == TownBlockType.COMMERCIAL && towny.getTownyUniverse().getTownBlock(signLocation).getType() == TownBlockType.COMMERCIAL; + } + + public static boolean isPlotOwner(Player player, Location chestLocation, Location signLocation){ + return isBlockOwner(player, chestLocation) && isBlockOwner(player, signLocation); + } + + public static boolean canBuild(Player player, Location chestLocation, Location signLocation){ + return towny == null || !Config.getBoolean(Property.TOWNY_INTEGRATION) || (isInsideShopPlot(chestLocation, signLocation) && isPlotOwner(player, chestLocation, signLocation)); + } + + private static boolean isBlockOwner(Player player, Location location){ + try{ + return towny.getTownyUniverse().getTownBlock(location).isOwner(towny.getTownyUniverse().getResident(player.getName())); + } catch (Exception ex){ return false; } + } +} diff --git a/com/lennardf1989/bukkitex/Database.java b/com/lennardf1989/bukkitex/Database.java index 37a1cda..3898cf5 100644 --- a/com/lennardf1989/bukkitex/Database.java +++ b/com/lennardf1989/bukkitex/Database.java @@ -59,14 +59,12 @@ public abstract class Database { * @param username Username required to access the database * @param password Password belonging to the username, may be empty * @param isolation Isolation type. For example: SERIALIZABLE, also see TransactionIsolation - * @param logging If set to false, all logging will be disabled - * @param rebuild If set to true, all tables will be dropped and recreated. Be sure to create a backup before doing so! */ - public void initializeDatabase(String driver, String url, String username, String password, String isolation, boolean logging, boolean rebuild) { + public void initializeDatabase(String driver, String url, String username, String password, String isolation) { //Logging needs to be set back to the original level, no matter what happens try { //Disable all logging - disableDatabaseLogging(logging); + disableDatabaseLogging(false); //Prepare the database prepareDatabase(driver, url, username, password, isolation); @@ -75,12 +73,12 @@ public abstract class Database { loadDatabase(); //Create all tables - installDatabase(rebuild); + installDatabase(true); } catch (Exception ex) { throw new RuntimeException("An exception has occured while initializing the database", ex); } finally { //Enable all logging - enableDatabaseLogging(logging); + enableDatabaseLogging(false); } } diff --git a/com/LRFLEW/register/payment/forChestShop/Method.java b/com/nijikokun/register/payment/forChestShop/Method.java similarity index 98% rename from com/LRFLEW/register/payment/forChestShop/Method.java rename to com/nijikokun/register/payment/forChestShop/Method.java index f23caed..198f2f4 100644 --- a/com/LRFLEW/register/payment/forChestShop/Method.java +++ b/com/nijikokun/register/payment/forChestShop/Method.java @@ -1,4 +1,4 @@ -package com.LRFLEW.register.payment.forChestShop; +package com.nijikokun.register.payment.forChestShop; import org.bukkit.plugin.Plugin; @@ -14,11 +14,11 @@ public interface Method { * Encodes the Plugin into an Object disguised as the Plugin. * If you want the original Plugin Class you must cast it to the correct * Plugin, to do so you have to verify the name and or version then cast. - * + *
** if(method.getName().equalsIgnoreCase("iConomy")) * iConomy plugin = ((iConomy)method.getPlugin());- * + * * @return
Object
* @see #getName()
* @see #getVersion()
@@ -38,11 +38,11 @@ public interface Method {
* @return String
Plugin version.
*/
public String getVersion();
-
+
/**
* Returns the amount of decimal places that get stored
* NOTE: it will return -1 if there is no rounding
- *
+ *
* @return int
for each decimal place
*/
public int fractionalDigits();
@@ -127,15 +127,25 @@ public interface Method {
*/
public interface MethodAccount {
public double balance();
+
public boolean set(double amount);
+
public boolean add(double amount);
+
public boolean subtract(double amount);
+
public boolean multiply(double amount);
+
public boolean divide(double amount);
+
public boolean hasEnough(double amount);
+
public boolean hasOver(double amount);
+
public boolean hasUnder(double amount);
+
public boolean isNegative();
+
public boolean remove();
@Override
@@ -147,17 +157,29 @@ public interface Method {
*/
public interface MethodBankAccount {
public double balance();
+
public String getBankName();
+
public int getBankId();
+
public boolean set(double amount);
+
public boolean add(double amount);
+
public boolean subtract(double amount);
+
public boolean multiply(double amount);
+
public boolean divide(double amount);
+
public boolean hasEnough(double amount);
+
public boolean hasOver(double amount);
+
public boolean hasUnder(double amount);
+
public boolean isNegative();
+
public boolean remove();
@Override
diff --git a/com/LRFLEW/register/payment/forChestShop/Methods.java b/com/nijikokun/register/payment/forChestShop/Methods.java
similarity index 71%
rename from com/LRFLEW/register/payment/forChestShop/Methods.java
rename to com/nijikokun/register/payment/forChestShop/Methods.java
index f7cb558..9cd9b93 100644
--- a/com/LRFLEW/register/payment/forChestShop/Methods.java
+++ b/com/nijikokun/register/payment/forChestShop/Methods.java
@@ -1,4 +1,4 @@
-package com.LRFLEW.register.payment.forChestShop;
+package com.nijikokun.register.payment.forChestShop;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@@ -15,9 +15,10 @@ import java.util.Set;
* Methods also allows you to set a preferred method of payment before it captures
* payment plugins in the initialization process.
*
- * in server.properties:
+ * in bukkit.yml
:
* * * @author: Nijikokun- * economy=iConomy + * economy: + * preferred: "iConomy" *
boolean
True on success, False on failure.
*/
public static boolean setMethod(PluginManager manager) {
- if (hasMethod()) return true;
- if (self) { self = false; return false; }
+ if (hasMethod())
+ return true;
+
+ if (self) {
+ self = false;
+ return false;
+ }
int count = 0;
boolean match = false;
Plugin plugin;
for (String name : Dependencies) {
- if (hasMethod()) break;
+ if (hasMethod())
+ break;
+
plugin = manager.getPlugin(name);
- if (plugin == null) continue;
+ if (plugin == null)
+ continue;
Method current = createMethod(plugin);
- if (current == null) continue;
+ if (current == null)
+ continue;
if (preferred.isEmpty())
Method = current;
- else {
+ else
Attachables.add(current);
- }
}
if (!preferred.isEmpty()) {
do {
- if (hasMethod()) {
+ if (hasMethod())
match = true;
- } else {
+ else {
for (Method attached : Attachables) {
- if (attached == null) continue;
+ if (attached == null)
+ continue;
if (hasMethod()) {
match = true;
break;
}
- if (preferred.isEmpty()) Method = attached;
+ if (preferred.isEmpty())
+ Method = attached;
- if (count == 0) {
+ if (count == 0)
if (preferred.equalsIgnoreCase(attached.getName()))
Method = attached;
- } else {
- Method = attached;
- }
+
+ else
+ Method = attached;
}
count++;
@@ -181,6 +193,20 @@ public class Methods {
return hasMethod();
}
+ /**
+ * Sets the preferred economy
+ *
+ * @return boolean
+ */
+ public static boolean setPreferred(String check) {
+ if (Dependencies.contains(check)) {
+ preferred = check;
+ return true;
+ }
+
+ return false;
+ }
+
/**
* Grab the existing and initialized (hopefully) Method Class.
*
@@ -198,8 +224,12 @@ public class Methods {
* @return boolean
*/
public static boolean checkDisabled(Plugin method) {
- if (!hasMethod()) return true;
- if (Method.isCompatible(method)) Method = null;
+ if (!hasMethod())
+ return true;
+
+ if (Method.isCompatible(method))
+ Method = null;
+
return (Method == null);
}
}
diff --git a/com/LRFLEW/register/payment/forChestShop/methods/BOSE6.java b/com/nijikokun/register/payment/forChestShop/methods/BOSE6.java
similarity index 75%
rename from com/LRFLEW/register/payment/forChestShop/methods/BOSE6.java
rename to com/nijikokun/register/payment/forChestShop/methods/BOSE6.java
index fe68890..9c69c3b 100644
--- a/com/LRFLEW/register/payment/forChestShop/methods/BOSE6.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/BOSE6.java
@@ -1,7 +1,6 @@
-package com.LRFLEW.register.payment.forChestShop.methods;
-
-import com.LRFLEW.register.payment.forChestShop.Method;
+package com.nijikokun.register.payment.forChestShop.methods;
+import com.nijikokun.register.payment.forChestShop.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
@@ -27,14 +26,17 @@ public class BOSE6 implements Method {
public String getVersion() {
return "0.6.2";
}
-
+
public int fractionalDigits() {
- return 0;
+ return 0;
}
public String format(double amount) {
String currency = this.BOSEconomy.getMoneyNamePlural();
- if(amount == 1) currency = this.BOSEconomy.getMoneyName();
+
+ if (amount == 1)
+ currency = this.BOSEconomy.getMoneyName();
+
return amount + " " + currency;
}
@@ -51,25 +53,32 @@ public class BOSE6 implements Method {
}
public boolean hasBankAccount(String bank, String name) {
- return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
+ return this.BOSEconomy.isBankOwner(bank, name)
+ || this.BOSEconomy.isBankMember(bank, name);
}
public MethodAccount getAccount(String name) {
- if(!hasAccount(name)) return null;
+ if (!hasAccount(name))
+ return null;
+
return new BOSEAccount(name, this.BOSEconomy);
}
public MethodBankAccount getBankAccount(String bank, String name) {
- if(!hasBankAccount(bank, name)) return null;
+ if (!hasBankAccount(bank, name))
+ return null;
+
return new BOSEBankAccount(bank, BOSEconomy);
}
public boolean isCompatible(Plugin plugin) {
- return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && plugin.getDescription().getVersion().equals("0.6.2");
+ return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
+ && plugin instanceof BOSEconomy
+ && plugin.getDescription().getVersion().equals("0.6.2");
}
public void setPlugin(Plugin plugin) {
- BOSEconomy = (BOSEconomy)plugin;
+ BOSEconomy = (BOSEconomy) plugin;
}
public static class BOSEAccount implements MethodAccount {
@@ -81,35 +90,35 @@ public class BOSE6 implements Method {
this.BOSEconomy = bOSEconomy;
}
- public double balance() {
+ public double balance() {
return (double) this.BOSEconomy.getPlayerMoney(this.name);
}
public boolean set(double amount) {
- int IntAmount = (int)Math.ceil(amount);
+ int IntAmount = (int) Math.ceil(amount);
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
}
public boolean add(double amount) {
- int IntAmount = (int)Math.ceil(amount);
+ int IntAmount = (int) Math.ceil(amount);
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
}
public boolean subtract(double amount) {
- int IntAmount = (int)Math.ceil(amount);
- int balance = (int)this.balance();
+ int IntAmount = (int) Math.ceil(amount);
+ int balance = (int) this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
}
public boolean multiply(double amount) {
- int IntAmount = (int)Math.ceil(amount);
- int balance = (int)this.balance();
+ int IntAmount = (int) Math.ceil(amount);
+ int balance = (int) this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
}
public boolean divide(double amount) {
- int IntAmount = (int)Math.ceil(amount);
- int balance = (int)this.balance();
+ int IntAmount = (int) Math.ceil(amount);
+ int balance = (int) this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
}
@@ -156,31 +165,31 @@ public class BOSE6 implements Method {
}
public boolean set(double amount) {
- int IntAmount = (int)Math.ceil(amount);
+ int IntAmount = (int) Math.ceil(amount);
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
}
public boolean add(double amount) {
- int IntAmount = (int)Math.ceil(amount);
- int balance = (int)this.balance();
+ int IntAmount = (int) Math.ceil(amount);
+ int balance = (int) this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
}
public boolean subtract(double amount) {
- int IntAmount = (int)Math.ceil(amount);
- int balance = (int)this.balance();
+ int IntAmount = (int) Math.ceil(amount);
+ int balance = (int) this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false);
}
public boolean multiply(double amount) {
- int IntAmount = (int)Math.ceil(amount);
- int balance = (int)this.balance();
+ int IntAmount = (int) Math.ceil(amount);
+ int balance = (int) this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
}
public boolean divide(double amount) {
- int IntAmount = (int)Math.ceil(amount);
- int balance = (int)this.balance();
+ int IntAmount = (int) Math.ceil(amount);
+ int balance = (int) this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
}
diff --git a/com/LRFLEW/register/payment/forChestShop/methods/BOSE7.java b/com/nijikokun/register/payment/forChestShop/methods/BOSE7.java
similarity index 90%
rename from com/LRFLEW/register/payment/forChestShop/methods/BOSE7.java
rename to com/nijikokun/register/payment/forChestShop/methods/BOSE7.java
index b0bee2a..3a116b4 100644
--- a/com/LRFLEW/register/payment/forChestShop/methods/BOSE7.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/BOSE7.java
@@ -1,7 +1,6 @@
-package com.LRFLEW.register.payment.forChestShop.methods;
-
-import com.LRFLEW.register.payment.forChestShop.Method;
+package com.nijikokun.register.payment.forChestShop.methods;
+import com.nijikokun.register.payment.forChestShop.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
@@ -27,14 +26,17 @@ public class BOSE7 implements Method {
public String getVersion() {
return "0.7.0";
}
-
+
public int fractionalDigits() {
- return this.BOSEconomy.getFractionalDigits();
+ return this.BOSEconomy.getFractionalDigits();
}
public String format(double amount) {
String currency = this.BOSEconomy.getMoneyNamePlural();
- if(amount == 1) currency = this.BOSEconomy.getMoneyName();
+
+ if (amount == 1)
+ currency = this.BOSEconomy.getMoneyName();
+
return amount + " " + currency;
}
@@ -55,21 +57,27 @@ public class BOSE7 implements Method {
}
public MethodAccount getAccount(String name) {
- if(!hasAccount(name)) return null;
+ if (!hasAccount(name))
+ return null;
+
return new BOSEAccount(name, this.BOSEconomy);
}
public MethodBankAccount getBankAccount(String bank, String name) {
- if(!hasBankAccount(bank, name)) return null;
+ if (!hasBankAccount(bank, name))
+ return null;
+
return new BOSEBankAccount(bank, BOSEconomy);
}
public boolean isCompatible(Plugin plugin) {
- return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && !plugin.getDescription().getVersion().equals("0.6.2");
+ return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
+ && plugin instanceof BOSEconomy
+ && !plugin.getDescription().getVersion().equals("0.6.2");
}
public void setPlugin(Plugin plugin) {
- BOSEconomy = (BOSEconomy)plugin;
+ BOSEconomy = (BOSEconomy) plugin;
}
public static class BOSEAccount implements MethodAccount {
diff --git a/com/LRFLEW/register/payment/forChestShop/methods/EE17.java b/com/nijikokun/register/payment/forChestShop/methods/EE17.java
similarity index 94%
rename from com/LRFLEW/register/payment/forChestShop/methods/EE17.java
rename to com/nijikokun/register/payment/forChestShop/methods/EE17.java
index c4fed2e..4057a3d 100644
--- a/com/LRFLEW/register/payment/forChestShop/methods/EE17.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/EE17.java
@@ -1,12 +1,10 @@
-package com.LRFLEW.register.payment.forChestShop.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
-import com.LRFLEW.register.payment.forChestShop.Method;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.api.Economy;
import com.earth2me.essentials.api.NoLoanPermittedException;
import com.earth2me.essentials.api.UserDoesNotExistException;
-
-
+import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
/**
@@ -33,9 +31,9 @@ public class EE17 implements Method {
public String getVersion() {
return "2.2";
}
-
+
public int fractionalDigits() {
- return -1;
+ return -1;
}
public String format(double amount) {
@@ -59,23 +57,25 @@ public class EE17 implements Method {
}
public MethodAccount getAccount(String name) {
- if(!hasAccount(name)) return null;
+ if (!hasAccount(name))
+ return null;
+
return new EEcoAccount(name);
}
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
-
- public boolean isCompatible(Plugin plugin) {
- try { Class.forName("com.earth2me.essentials.api.Economy"); }
- catch(Exception e) { return false; }
- return plugin.getDescription().getName().equalsIgnoreCase("essentials") && plugin instanceof Essentials;
+ public boolean isCompatible(Plugin plugin) {
+ try { Class.forName("com.earth2me.essentials.api.Economy"); } catch (Exception e) { return false; }
+
+ return plugin.getDescription().getName().equalsIgnoreCase("essentials")
+ && plugin instanceof Essentials;
}
public void setPlugin(Plugin plugin) {
- Essentials = (Essentials)plugin;
+ Essentials = (Essentials) plugin;
}
public static class EEcoAccount implements MethodAccount {
diff --git a/com/LRFLEW/register/payment/forChestShop/methods/MCUR.java b/com/nijikokun/register/payment/forChestShop/methods/MCUR.java
similarity index 91%
rename from com/LRFLEW/register/payment/forChestShop/methods/MCUR.java
rename to com/nijikokun/register/payment/forChestShop/methods/MCUR.java
index cd64a4d..e5e189f 100644
--- a/com/LRFLEW/register/payment/forChestShop/methods/MCUR.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/MCUR.java
@@ -1,10 +1,8 @@
-package com.LRFLEW.register.payment.forChestShop.methods;
-
-import com.LRFLEW.register.payment.forChestShop.Method;
+package com.nijikokun.register.payment.forChestShop.methods;
+import com.nijikokun.register.payment.forChestShop.Method;
import me.ashtheking.currency.Currency;
import me.ashtheking.currency.CurrencyList;
-
import org.bukkit.plugin.Plugin;
/**
@@ -28,9 +26,9 @@ public class MCUR implements Method {
public String getVersion() {
return "0.09";
}
-
+
public int fractionalDigits() {
- return -1;
+ return -1;
}
public String format(double amount) {
@@ -63,15 +61,15 @@ public class MCUR implements Method {
public boolean isCompatible(Plugin plugin) {
return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
- || plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
- && plugin instanceof Currency;
+ || plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
+ && plugin instanceof Currency;
}
public void setPlugin(Plugin plugin) {
currencyList = (Currency) plugin;
}
- public static class MCurrencyAccount implements MethodAccount{
+ public static class MCurrencyAccount implements MethodAccount {
private String name;
public MCurrencyAccount(String name) {
diff --git a/com/LRFLEW/register/payment/forChestShop/methods/iCo4.java b/com/nijikokun/register/payment/forChestShop/methods/iCo4.java
similarity index 81%
rename from com/LRFLEW/register/payment/forChestShop/methods/iCo4.java
rename to com/nijikokun/register/payment/forChestShop/methods/iCo4.java
index 101e857..dfdfec7 100644
--- a/com/LRFLEW/register/payment/forChestShop/methods/iCo4.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/iCo4.java
@@ -1,10 +1,8 @@
-package com.LRFLEW.register.payment.forChestShop.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
-import com.LRFLEW.register.payment.forChestShop.Method;
import com.nijiko.coelho.iConomy.iConomy;
import com.nijiko.coelho.iConomy.system.Account;
-
-
+import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
/**
@@ -28,12 +26,12 @@ public class iCo4 implements Method {
public String getVersion() {
return "4";
}
-
+
public int fractionalDigits() {
- return 2;
+ return 2;
}
- public String format(double amount) {
+ public String format(double amount) {
return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount);
}
@@ -60,17 +58,17 @@ public class iCo4 implements Method {
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
-
+
public boolean isCompatible(Plugin plugin) {
- return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
- && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
- && plugin instanceof iConomy;
+ return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
+ && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
+ && plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {
- iConomy = (iConomy)plugin;
+ iConomy = (iConomy) plugin;
}
-
+
public static class iCoAccount implements MethodAccount {
private Account account;
@@ -87,31 +85,31 @@ public class iCo4 implements Method {
}
public boolean set(double amount) {
- if(this.account == null) return false;
+ if (this.account == null) return false;
this.account.setBalance(amount);
return true;
}
public boolean add(double amount) {
- if(this.account == null) return false;
+ if (this.account == null) return false;
this.account.add(amount);
return true;
}
public boolean subtract(double amount) {
- if(this.account == null) return false;
+ if (this.account == null) return false;
this.account.subtract(amount);
return true;
}
public boolean multiply(double amount) {
- if(this.account == null) return false;
+ if (this.account == null) return false;
this.account.multiply(amount);
return true;
}
public boolean divide(double amount) {
- if(this.account == null) return false;
+ if (this.account == null) return false;
this.account.divide(amount);
return true;
}
@@ -133,7 +131,7 @@ public class iCo4 implements Method {
}
public boolean remove() {
- if(this.account == null) return false;
+ if (this.account == null) return false;
this.account.remove();
return true;
}
diff --git a/com/LRFLEW/register/payment/forChestShop/methods/iCo5.java b/com/nijikokun/register/payment/forChestShop/methods/iCo5.java
similarity index 83%
rename from com/LRFLEW/register/payment/forChestShop/methods/iCo5.java
rename to com/nijikokun/register/payment/forChestShop/methods/iCo5.java
index 4e95385..7108966 100644
--- a/com/LRFLEW/register/payment/forChestShop/methods/iCo5.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/iCo5.java
@@ -1,13 +1,11 @@
-package com.LRFLEW.register.payment.forChestShop.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
-import com.LRFLEW.register.payment.forChestShop.Method;
import com.iConomy.iConomy;
import com.iConomy.system.Account;
import com.iConomy.system.BankAccount;
import com.iConomy.system.Holdings;
import com.iConomy.util.Constants;
-
-
+import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
/**
@@ -31,12 +29,12 @@ public class iCo5 implements Method {
public String getVersion() {
return "5";
}
-
+
public int fractionalDigits() {
- return 2;
+ return 2;
}
- public String format(double amount) {
+ public String format(double amount) {
return com.iConomy.iConomy.format(amount);
}
@@ -65,13 +63,13 @@ public class iCo5 implements Method {
}
public boolean isCompatible(Plugin plugin) {
- return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
- && plugin.getClass().getName().equals("com.iConomy.iConomy")
- && plugin instanceof iConomy;
+ return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
+ && plugin.getClass().getName().equals("com.iConomy.iConomy")
+ && plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {
- iConomy = (iConomy)plugin;
+ iConomy = (iConomy) plugin;
}
public static class iCoAccount implements MethodAccount {
@@ -92,31 +90,31 @@ public class iCo5 implements Method {
}
public boolean set(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.set(amount);
return true;
}
public boolean add(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public boolean subtract(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public boolean multiply(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public boolean divide(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
@@ -138,7 +136,7 @@ public class iCo5 implements Method {
}
public boolean remove() {
- if(this.account == null) return false;
+ if (this.account == null) return false;
this.account.remove();
return true;
}
@@ -170,31 +168,31 @@ public class iCo5 implements Method {
}
public boolean set(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.set(amount);
return true;
}
public boolean add(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public boolean subtract(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public boolean multiply(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public boolean divide(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
@@ -216,7 +214,7 @@ public class iCo5 implements Method {
}
public boolean remove() {
- if(this.account == null) return false;
+ if (this.account == null) return false;
this.account.remove();
return true;
}
diff --git a/com/LRFLEW/register/payment/forChestShop/methods/iCo6.java b/com/nijikokun/register/payment/forChestShop/methods/iCo6.java
similarity index 81%
rename from com/LRFLEW/register/payment/forChestShop/methods/iCo6.java
rename to com/nijikokun/register/payment/forChestShop/methods/iCo6.java
index 10603ad..89c2436 100644
--- a/com/LRFLEW/register/payment/forChestShop/methods/iCo6.java
+++ b/com/nijikokun/register/payment/forChestShop/methods/iCo6.java
@@ -1,12 +1,10 @@
-package com.LRFLEW.register.payment.forChestShop.methods;
+package com.nijikokun.register.payment.forChestShop.methods;
-import com.LRFLEW.register.payment.forChestShop.Method;
import com.iCo6.iConomy;
import com.iCo6.system.Account;
import com.iCo6.system.Accounts;
import com.iCo6.system.Holdings;
-
-
+import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
/**
@@ -30,12 +28,12 @@ public class iCo6 implements Method {
public String getVersion() {
return "6";
}
-
+
public int fractionalDigits() {
- return 2;
+ return 2;
}
- public String format(double amount) {
+ public String format(double amount) {
return com.iCo6.iConomy.format(amount);
}
@@ -64,13 +62,13 @@ public class iCo6 implements Method {
}
public boolean isCompatible(Plugin plugin) {
- return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
- && plugin.getClass().getName().equals("com.iCo6.iConomy")
- && plugin instanceof iConomy;
+ return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
+ && plugin.getClass().getName().equals("com.iCo6.iConomy")
+ && plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {
- iConomy = (iConomy)plugin;
+ iConomy = (iConomy) plugin;
}
public static class iCoAccount implements MethodAccount {
@@ -91,31 +89,31 @@ public class iCo6 implements Method {
}
public boolean set(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.setBalance(amount);
return true;
}
public boolean add(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public boolean subtract(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public boolean multiply(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public boolean divide(double amount) {
- if(this.holdings == null) return false;
+ if (this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
@@ -137,7 +135,7 @@ public class iCo6 implements Method {
}
public boolean remove() {
- if(this.account == null) return false;
+ if (this.account == null) return false;
this.account.remove();
return true;
}
diff --git a/plugin.yml b/plugin.yml
index 328e431..6e3eb17 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -2,7 +2,7 @@ name: ChestShop
main: com.Acrobot.ChestShop.ChestShop
-version: 3.12
+version: 3.2
author: Acrobot
@@ -10,7 +10,7 @@ description: >
A chest shop for economy plugins.
-softdepend: [Permissions, LWC, Lockette, Deadbolt, OddItem]
+softdepend: [Permissions, LWC, Lockette, Deadbolt, OddItem, Towny]
commands:
iteminfo:
aliases: [iinfo]