- Added a warning if spawn-radius isn't set to 0

- Deleted a few outdated plugins from built-in Register
- System.out -> System.err for errors
- Blocked buying if you're holding a sign in your hand (allows, for example, for sign editors to work)
- Updated Heroes package
- Fixed WG integration (no longer throws errors, but uses ugly workaround)
- Fixed a small bug in Register plugin loading message
- Removed version checking for OddItem, WorldGuard and LWC
This commit is contained in:
Acrobot 2012-03-06 19:41:14 +01:00
parent 0e22503c9b
commit e87f5f4f11
22 changed files with 185 additions and 776 deletions

View File

@ -9,7 +9,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest;
import org.bukkit.inventory.Inventory;
/**
* Temporary class until this is fixed in Bukkit
* Temporary class until this is fixed in Bukkit RB
* @author Acrobot
*/
public class bInventoryFix {

View File

@ -53,6 +53,8 @@ public class ChestShop extends JavaPlugin {
pluginEnable.initializePlugins();
warnAboutSpawnProtection();
if (Config.getBoolean(Property.LOG_TO_DATABASE) || Config.getBoolean(Property.GENERATE_STATISTICS_PAGE)) setupDB();
if (Config.getBoolean(Property.GENERATE_STATISTICS_PAGE)) scheduleTask(new Generator(), 300L, (long) Config.getDouble(Property.STATISTICS_PAGE_GENERATION_INTERVAL) * 20L);
if (Config.getBoolean(Property.LOG_TO_FILE)) scheduleTask(new FileWriterQueue(), 201L, 201L);
@ -89,10 +91,17 @@ public class ChestShop extends JavaPlugin {
try{
new Metrics().beginMeasuringPlugin(this);
} catch (Exception ex){
System.out.println(chatPrefix + "There was an error while submitting statistics.");
System.err.println(chatPrefix + "There was an error while submitting statistics.");
}
}
///////////////////// WARN ABOUT SPAWN PROTECTION ///////////////////////////
private static void warnAboutSpawnProtection() {
if (getBukkitConfig().getInt("settings.spawn-radius") > 0)
System.err.println(ChestShop.chatPrefix + "WARNING! Your spawn-radius in bukkit.yml isn't set to 0! " +
"You won't be able to sell to shops built near spawn!");
}
///////////////////// DATABASE STUFF ////////////////////////////////
private static YamlConfiguration getBukkitConfig() {
return YamlConfiguration.loadConfiguration(new File("bukkit.yml"));

View File

@ -93,4 +93,4 @@ public class MinecraftChest implements ChestObject {
private static int removeItem(ItemStack item, short durability, int amount, Chest chest) {
return uInventory.remove(chest.getInventory(), item, amount, durability);
}
}
}

View File

@ -0,0 +1,57 @@
package com.Acrobot.ChestShop.Chests;
import com.Acrobot.ChestShop.Utils.uBlock;
import com.Acrobot.ChestShop.Utils.uInventory;
import org.bukkit.block.Chest;
import org.bukkit.inventory.ItemStack;
/**
* @author Acrobot
*/
public class MinecraftChest_forNewBukkit implements ChestObject {
private final Chest chest;
public MinecraftChest_forNewBukkit(Chest chest) {
this.chest = chest;
}
public ItemStack[] getContents() {
return chest.getInventory().getContents();
}
public void setSlot(int slot, ItemStack item) {
chest.getInventory().setItem(slot, item);
}
public void clearSlot(int slot) {
chest.getInventory().setItem(slot, null);
}
public void addItem(ItemStack item, int amount) {
uInventory.add(chest.getInventory(), item, amount);
}
public void removeItem(ItemStack item, short durability, int amount) {
uInventory.remove(chest.getInventory(), item, amount, durability);
}
public int amount(ItemStack item, short durability) {
return uInventory.amount(chest.getInventory(), item, durability);
}
public boolean hasEnough(ItemStack item, int amount, short durability) {
return amount(item, durability) >= amount;
}
public boolean fits(ItemStack item, int amount, short durability) {
return uInventory.fits(chest.getInventory(), item, amount, durability) <= 0;
}
public int getSize() {
return chest.getInventory().getSize();
}
public Chest getNeighbor() {
return uBlock.findNeighbor(chest);
}
}

View File

@ -53,7 +53,7 @@ public class ConfigObject {
fw.write(string);
fw.close();
} catch (Exception e) {
System.out.println("Couldn't write to file - " + file.getName());
System.err.println("Couldn't write to file - " + file.getName());
}
}

View File

@ -28,7 +28,7 @@ public class Generator implements Runnable {
row = fileToString("row");
footer = fileToString("footer");
if (row.isEmpty()) System.out.println(ChestShop.chatPrefix + "You lack the necessary HTML files in your plugins/ChestShop/HTML folder!");
if (row.isEmpty()) System.err.println(ChestShop.chatPrefix + "You lack the necessary HTML files in your plugins/ChestShop/HTML folder!");
generateStats();
}

View File

@ -5,30 +5,34 @@ package com.Acrobot.ChestShop.Economy;
*/
public class NoProvider implements EcoPlugin{
public boolean hasAccount(String player) {
System.out.println("[ChestShop] You haven't got any economy plugin!");
printError();
return false;
}
public void add(String player, double amount) {
System.out.println("[ChestShop] You haven't got any economy plugin!");
printError();
}
public void subtract(String player, double amount) {
System.out.println("[ChestShop] You haven't got any economy plugin!");
printError();
}
public boolean hasEnough(String player, double amount) {
System.out.println("[ChestShop] You haven't got any economy plugin!");
printError();
return false;
}
public double balance(String player) {
System.out.println("[ChestShop] You haven't got any economy plugin!");
printError();
return 0;
}
public String format(double amount) {
System.out.println("[ChestShop] You haven't got any economy plugin!");
printError();
return null;
}
private static void printError() {
System.err.println("[ChestShop] You haven't got any economy plugin!");
}
}

View File

@ -41,6 +41,7 @@ public class playerInteract implements Listener {
Block block = event.getClickedBlock();
Player player = event.getPlayer();
if (player.getItemInHand() != null && player.getItemInHand().getType() == Material.SIGN) return;
if (Config.getBoolean(Property.USE_BUILT_IN_PROTECTION) && block.getType() == Material.CHEST) {
Default protection = new Default();
if (!hasAdminPermissions(player) && (protection.isProtected(block) && !protection.canAccess(player, block))) {

View File

@ -9,11 +9,10 @@ import com.Acrobot.ChestShop.Protection.Plugins.*;
import com.Acrobot.ChestShop.Protection.Security;
import com.Acrobot.ChestShop.Utils.WorldGuard.uWorldGuard;
import com.Acrobot.ChestShop.Utils.uHeroes;
import com.Acrobot.ChestShop.Utils.uNumber;
import com.Acrobot.ChestShop.Utils.uSign;
import com.daemitus.deadbolt.Deadbolt;
import com.griefcraft.lwc.LWCPlugin;
import com.herocraftonline.dev.heroes.Heroes;
import com.herocraftonline.heroes.Heroes;
import com.nijikokun.register.payment.forChestShop.Method;
import com.nijikokun.register.payment.forChestShop.Methods;
import com.palmergames.bukkit.towny.Towny;
@ -48,7 +47,7 @@ public class pluginEnable {
}
Register.eco = m;
com.Acrobot.ChestShop.Economy.Economy.economy = new Register();
System.out.println(ChestShop.chatPrefix + m.getName() + " version " + m.getName() + " loaded.");
System.out.println(ChestShop.chatPrefix + m.getName() + " version " + m.getVersion() + " loaded.");
}
}
@ -63,20 +62,16 @@ public class pluginEnable {
DeadboltPlugin.deadbolt = (Deadbolt) plugin;
Security.protections.add(new DeadboltPlugin());
} else if (name.equals("OddItem")) {
if (plugin.getDescription().getVersion().startsWith("0.7")) { System.out.println(generateOutdatedVersion(name, plugin.getDescription().getVersion(), "0.8")); return; }
Odd.isInitialized = true;
} else if (name.equals("Towny")) {
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(generateOutdatedVersion(name, plugin.getDescription().getVersion(), "0.76.0.47")); return; }
uSign.towny = (Towny) plugin;
} else if (name.equals("WorldGuard")) {
uWorldGuard.worldGuard = (WorldGuardPlugin) plugin;
uWorldGuard.wg = (WorldGuardPlugin) plugin;
uWorldGuard.injectHax(); //Inject hax into WorldGuard
} else if (name.equals("Vault")) {
if (com.Acrobot.ChestShop.Economy.Economy.economy != null) return;
RegisteredServiceProvider<Economy> rsp = ChestShop.getBukkitServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) return;
Vault.economy = rsp.getProvider();
if (Vault.economy == null) return;
com.Acrobot.ChestShop.Economy.Economy.economy = new Vault();

View File

@ -9,8 +9,8 @@ import com.Acrobot.ChestShop.Items.Items;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Protection.Security;
import com.Acrobot.ChestShop.Signs.restrictedSign;
import com.Acrobot.ChestShop.Utils.*;
import com.Acrobot.ChestShop.Utils.WorldGuard.uWorldGuard;
import com.Acrobot.ChestShop.Utils.*;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -87,9 +87,11 @@ public class signChange implements Listener {
}
Block chestBlock = chest.getBlock();
boolean cantBuildTowny = uSign.towny != null && !uTowny.canBuild(player, signBlock.getLocation(), chestBlock.getLocation());
boolean canBuildTowny = uSign.towny == null || uTowny.canBuild(player, signBlock.getLocation(), chest.getLocation());
boolean canBuildWorldGuard = uWorldGuard.wg == null || uWorldGuard.canBuildShopHere(signBlock.getLocation());
boolean bothActive = uSign.towny != null && uWorldGuard.wg != null;
if (!uWorldGuard.canBuildShopHere(signBlock.getLocation()) && cantBuildTowny){
if (((!canBuildTowny || !canBuildWorldGuard) && !bothActive) || (bothActive && !canBuildTowny && !canBuildWorldGuard)) {
player.sendMessage(Config.getLocal(Language.TOWNY_CANNOT_CREATE_SHOP_HERE));
dropSign(event);
return;
@ -140,7 +142,7 @@ public class signChange implements Listener {
private static boolean canCreateShop(Player player, int ID, boolean buy, boolean sell) {
if (Permission.has(player, Permission.SHOP_CREATION_ID + Integer.toString(ID))) return true;
if (buy && !Permission.has(player, Permission.SHOP_CREATION_BUY)) return false;
if (sell && !Permission.has(player, Permission.SHOP_CREATION_SELL)) return false;

View File

@ -194,7 +194,7 @@ public class Metrics {
// Each post thereafter will be a ping
firstPost = false;
} catch (IOException e) {
System.out.println("[Metrics] " + e.getMessage());
System.err.println("[Metrics] " + e.getMessage());
}
}
}, 0, PING_INTERVAL * 1200);

View File

@ -3,7 +3,6 @@ package com.Acrobot.ChestShop.Protection.Plugins;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Protection.Protection;
import com.griefcraft.lwc.LWC;
import com.griefcraft.model.ProtectionTypes;
import com.griefcraft.modules.limits.LimitsModule;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -32,13 +31,9 @@ public class LWCplugin implements Protection {
public boolean protect(String name, Block block) {
if (lwc.findProtection(block) != null) return false;
Player player = ChestShop.getBukkitServer().getPlayer(name);
try {
if (player != null && limitsModule.hasReachedLimit(player, block)) return false;
} catch (NoSuchMethodError e) {
System.out.println(ChestShop.chatPrefix + "Your LWC plugin is outdated!");
}
if (player != null && limitsModule.hasReachedLimit(player, block)) return false;
lwc.getPhysicalDatabase().registerProtection(block.getTypeId(), ProtectionTypes.PRIVATE, block.getWorld().getName(), name, "", block.getX(), block.getY(), block.getZ());
lwc.getPhysicalDatabase().registerProtection(block.getTypeId(), com.griefcraft.model.Protection.Type.PUBLIC, block.getWorld().getName(), name, "", block.getX(), block.getY(), block.getZ());
return true;
}
}

View File

@ -0,0 +1,14 @@
package com.Acrobot.ChestShop.Utils.WorldGuard;
import com.sk89q.worldguard.protection.flags.StateFlag;
/**
* @author Acrobot
*/
public class ChestShopFlag extends StateFlag {
public static ChestShopFlag flag = new ChestShopFlag();
public ChestShopFlag() {
super("chestshop", false);
}
}

View File

@ -0,0 +1,60 @@
package com.Acrobot.ChestShop.Utils.WorldGuard;
import com.Acrobot.ChestShop.ChestShop;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.GlobalRegionManager;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.Flag;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author Acrobot
*/
public class JavaWorkaround {
public static boolean setAllowsFlag(ApplicableRegionSet set) {
return set.allows(ChestShopFlag.flag);
}
private static List elements() {
List<Flag> elements = new ArrayList(Arrays.asList(DefaultFlag.getFlags()));
elements.add(ChestShopFlag.flag);
return elements;
}
public static void injectHax() {
try {
Field field = DefaultFlag.class.getDeclaredField("flagsList");
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.setAccessible(true);
List<Flag> elements = elements();
Flag<?> list[] = new Flag<?>[elements.size()];
for (int i = 0; i < elements.size(); i++) {
list[i] = elements.get(i);
}
field.set(null, list);
Field grm = WorldGuardPlugin.class.getDeclaredField("globalRegionManager");
grm.setAccessible(true);
GlobalRegionManager globalRegionManager = (GlobalRegionManager) grm.get(ChestShop.getBukkitServer().getPluginManager().getPlugin("WorldGuard"));
globalRegionManager.preload();
} catch (Exception e) {
System.err.println(ChestShop.chatPrefix + "Oh noes! Something wrong happened! Be sure to paste that in your bug report:");
e.printStackTrace();
}
}
}

View File

@ -1,87 +1,37 @@
package com.Acrobot.ChestShop.Utils.WorldGuard;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.sk89q.worldguard.bukkit.BukkitUtil;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.GlobalRegionManager;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import org.bukkit.Location;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author Acrobot
*/
public class uWorldGuard {
public static WorldGuardPlugin worldGuard;
private static final ChestShopFlag flag = new ChestShopFlag();
/*public static boolean isNotOutsideWGplot(Location l2) {
return worldGuard == null || !Config.getBoolean(Property.WORLDGUARD_INTEGRATION) || worldGuard.getGlobalRegionManager().get(l2.getWorld()).getApplicableRegions(BukkitUtil.toVector(l2)).size() != 0;
}*/
public static WorldGuardPlugin wg;
public static void injectHax() {
if (!Config.getBoolean(Property.WORLDGUARD_INTEGRATION)) return;
if (!Config.getBoolean(Property.WORLDGUARD_INTEGRATION) || wg == null) return;
try {
Field field = DefaultFlag.class.getDeclaredField("flagsList");
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.setAccessible(true);
List<Flag> elements = new ArrayList(Arrays.asList(DefaultFlag.getFlags()));
elements.add(flag);
Flag<?> list[] = new Flag<?>[elements.size()];
for (int i = 0; i < elements.size(); i++) {
list[i] = elements.get(i);
}
field.set(null, list);
Field grm = WorldGuardPlugin.class.getDeclaredField("globalRegionManager");
grm.setAccessible(true);
GlobalRegionManager globalRegionManager = (GlobalRegionManager) grm.get(ChestShop.getBukkitServer().getPluginManager().getPlugin("WorldGuard"));
globalRegionManager.preload();
} catch (Exception e) {
System.out.println(ChestShop.chatPrefix + "Oh noes! Something wrong happened! Be sure to paste that in your bug report:");
e.printStackTrace();
}
JavaWorkaround.injectHax();
}
public static boolean canBuildShopHere(Location loc) {
return turnedOn() && canCreateShops(getRegions(loc));
return !turnedOn() || canCreateShops(getRegions(loc));
}
public static boolean canCreateShops(ApplicableRegionSet set){
return set.allows(flag);
public static boolean canCreateShops(ApplicableRegionSet set) {
return JavaWorkaround.setAllowsFlag(set);
}
public static ApplicableRegionSet getRegions(Location loc) {
return worldGuard.getGlobalRegionManager().get(loc.getWorld()).getApplicableRegions(BukkitUtil.toVector(loc));
return wg.getGlobalRegionManager().get(loc.getWorld()).getApplicableRegions(BukkitUtil.toVector(loc));
}
private static boolean turnedOn() {
return worldGuard != null && Config.getBoolean(Property.WORLDGUARD_INTEGRATION);
}
private static class ChestShopFlag extends StateFlag {
public ChestShopFlag() {
super("chestshop", false);
}
return wg != null && Config.getBoolean(Property.WORLDGUARD_INTEGRATION);
}
}

View File

@ -2,9 +2,9 @@ package com.Acrobot.ChestShop.Utils;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.herocraftonline.dev.heroes.Heroes;
import com.herocraftonline.dev.heroes.classes.HeroClass;
import com.herocraftonline.dev.heroes.hero.Hero;
import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero;
import com.herocraftonline.heroes.characters.classes.HeroClass;
import org.bukkit.entity.Player;
/**
@ -14,8 +14,8 @@ public class uHeroes {
public static Heroes heroes;
public static void addHeroExp(Player p) {
if (uHeroes.heroes != null) {
Hero hero = uHeroes.heroes.getHeroManager().getHero(p);
if (heroes != null) {
Hero hero = heroes.getHeroManager().getHero(p);
if (hero.hasParty()) {
hero.getParty().gainExp(Config.getDouble(Property.HEROES_EXP), HeroClass.ExperienceType.EXTERNAL, p.getLocation());
} else {

View File

@ -18,13 +18,9 @@ public class Methods {
"3co"
};
private static final Method[] methods = new Method[]{
new iCo4(),
new iCo5(),
new iCo6(),
new BOSE6(),
new BOSE7(),
new MCUR(),
new ECO3(),
new EE17()
};

View File

@ -1,234 +0,0 @@
package com.nijikokun.register.payment.forChestShop.methods;
import com.nijikokun.register.payment.forChestShop.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
/**
* BOSEconomy 6 Implementation of Method
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
@SuppressWarnings("deprecation")
public class BOSE6 implements Method {
private BOSEconomy BOSEconomy;
public BOSEconomy getPlugin() {
return this.BOSEconomy;
}
public String getName() {
return "BOSEconomy";
}
public String getVersion() {
return "0.6.2";
}
public int fractionalDigits() {
return 0;
}
public String format(double amount) {
String currency = this.BOSEconomy.getMoneyNamePlural();
if(amount == 1)
currency = this.BOSEconomy.getMoneyName();
return amount + " " + currency;
}
public boolean hasBanks() {
return true;
}
public boolean hasBank(String bank) {
return this.BOSEconomy.bankExists(bank);
}
public boolean hasAccount(String name) {
return this.BOSEconomy.playerRegistered(name, false);
}
public boolean hasBankAccount(String bank, String name) {
return this.BOSEconomy.isBankOwner(bank, name)
|| this.BOSEconomy.isBankMember(bank, name);
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
this.BOSEconomy.registerPlayer(name);
return true;
}
public boolean createAccount(String name, double balance) {
if(hasAccount(name))
return false;
this.BOSEconomy.registerPlayer(name);
this.BOSEconomy.setPlayerMoney(name, balance, false);
return true;
}
public MethodAccount getAccount(String name) {
if(!hasAccount(name))
return null;
return new BOSEAccount(name, this.BOSEconomy);
}
public MethodBankAccount getBankAccount(String bank, String name) {
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");
}
public void setPlugin(Plugin plugin) {
BOSEconomy = (BOSEconomy) plugin;
}
public static class BOSEAccount implements MethodAccount {
private final String name;
private final BOSEconomy BOSEconomy;
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
this.name = name;
this.BOSEconomy = bOSEconomy;
}
public double balance() {
return (double) this.BOSEconomy.getPlayerMoney(this.name);
}
public boolean set(double 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);
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
}
public boolean subtract(double amount) {
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();
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();
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
}
public boolean hasEnough(double amount) {
return (this.balance() >= amount);
}
public boolean hasOver(double amount) {
return (this.balance() > amount);
}
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public boolean isNegative() {
return (this.balance() < 0);
}
public boolean remove() {
return false;
}
}
public static class BOSEBankAccount implements MethodBankAccount {
private final String bank;
private final BOSEconomy BOSEconomy;
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
this.bank = bank;
this.BOSEconomy = bOSEconomy;
}
public String getBankName() {
return this.bank;
}
public int getBankId() {
return -1;
}
public double balance() {
return (double) this.BOSEconomy.getBankMoney(bank);
}
public boolean set(double 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();
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
}
public boolean subtract(double amount) {
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();
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
}
public boolean divide(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
}
public boolean hasEnough(double amount) {
return (this.balance() >= amount);
}
public boolean hasOver(double amount) {
return (this.balance() > amount);
}
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public boolean isNegative() {
return (this.balance() < 0);
}
public boolean remove() {
return this.BOSEconomy.removeBank(bank);
}
}
}

View File

@ -1,137 +0,0 @@
package com.nijikokun.register.payment.forChestShop.methods;
import com.nijikokun.register.payment.forChestShop.Method;
import me.ic3d.eco.ECO;
import org.bukkit.plugin.Plugin;
/**
* 3co implementation of Method.
*
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class ECO3 implements Method {
private ECO eco;
public Object getPlugin() {
return this.eco;
}
public String getName() {
return "3co";
}
public String getVersion() {
return "2.0";
}
public int fractionalDigits() {
return 0;
}
public String format(double amount) {
return (int) Math.ceil(amount) + " " + (amount == 1 ? eco.singularCurrency : eco.pluralCurrency);
}
public boolean hasBanks() {
return false;
}
public boolean hasBank(String bank) {
return false;
}
public boolean hasAccount(String name) {
return eco.hasAccount(name);
}
public boolean hasBankAccount(String bank, String name) {
return false;
}
public boolean createAccount(String name) {
if (hasAccount(name)) return false;
eco.createAccount(name, 0);
return true;
}
public boolean createAccount(String name, double balance) {
if (hasAccount(name)) return false;
eco.createAccount(name, (int) balance);
return true;
}
public MethodAccount getAccount(String name) {
if (!hasAccount(name)) createAccount(name); //Still somehow fails - it's 3co's issue
return new ECO3Account(name);
}
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equals("3co") && plugin.getClass().getName().equals("me.ic3d.eco.ECO") && plugin instanceof ECO;
}
public void setPlugin(Plugin plugin) {
this.eco = (ECO) plugin;
}
public class ECO3Account implements MethodAccount {
private String name;
public ECO3Account(String name) {
this.name = name;
}
public double balance() {
return eco.getMoney(name);
}
public boolean set(double amount) {
eco.setMoney(name, (int) Math.ceil(amount));
return true;
}
public boolean add(double amount) {
set(balance() + amount);
return true;
}
public boolean subtract(double amount) {
set(balance() - amount);
return true;
}
public boolean multiply(double amount) {
set(balance() * amount);
return true;
}
public boolean divide(double amount) {
set(balance() / amount);
return true;
}
public boolean hasEnough(double amount) {
return eco.hasEnough(name, (int) Math.ceil(amount));
}
public boolean hasOver(double amount) {
return balance() > amount;
}
public boolean hasUnder(double amount) {
return balance() < amount;
}
public boolean isNegative() {
return balance() < 0;
}
public boolean remove() {
return false;
}
}
}

View File

@ -1,136 +0,0 @@
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;
/**
* MultiCurrency Method implementation.
*
* @author Acrobot
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class MCUR implements Method {
private Currency currencyList;
public Object getPlugin() {
return this.currencyList;
}
public String getName() {
return "MultiCurrency";
}
public String getVersion() {
return "0.09";
}
public int fractionalDigits() {
return -1;
}
public String format(double amount) {
return amount + " Currency";
}
public boolean hasBanks() {
return false;
}
public boolean hasBank(String bank) {
return false;
}
public boolean hasAccount(String name) {
return true;
}
public boolean hasBankAccount(String bank, String name) {
return false;
}
public boolean createAccount(String name) {
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, 0);
return true;
}
public boolean createAccount(String name, double balance) {
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, balance);
return true;
}
public MethodAccount getAccount(String name) {
return new MCurrencyAccount(name);
}
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
public boolean isCompatible(Plugin plugin) {
return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
&& plugin instanceof Currency;
}
public void setPlugin(Plugin plugin) {
currencyList = (Currency) plugin;
}
public static class MCurrencyAccount implements MethodAccount{
private String name;
public MCurrencyAccount(String name) {
this.name = name;
}
public double balance() {
return CurrencyList.getValue((String) CurrencyList.maxCurrency(name)[0], name);
}
public boolean set(double amount) {
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, amount);
return true;
}
public boolean add(double amount) {
return CurrencyList.add(name, amount);
}
public boolean subtract(double amount) {
return CurrencyList.subtract(name, amount);
}
public boolean multiply(double amount) {
return CurrencyList.multiply(name, amount);
}
public boolean divide(double amount) {
return CurrencyList.divide(name, amount);
}
public boolean hasEnough(double amount) {
return CurrencyList.hasEnough(name, amount);
}
public boolean hasOver(double amount) {
return CurrencyList.hasOver(name, amount);
}
public boolean hasUnder(double amount) {
return CurrencyList.hasUnder(name, amount);
}
public boolean isNegative() {
return CurrencyList.isNegative(name);
}
public boolean remove() {
return CurrencyList.remove(name);
}
}
}

View File

@ -1,167 +0,0 @@
package com.nijikokun.register.payment.forChestShop.methods;
import com.nijikokun.register.payment.forChestShop.Method;
import com.nijiko.coelho.iConomy.iConomy;
import com.nijiko.coelho.iConomy.system.Account;
import org.bukkit.plugin.Plugin;
/**
* iConomy 4 Implementation of Method
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class iCo4 implements Method {
private iConomy iConomy;
public iConomy getPlugin() {
return this.iConomy;
}
public String getName() {
return "iConomy";
}
public String getVersion() {
return "4";
}
public int fractionalDigits() {
return 2;
}
public String format(double amount) {
return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount);
}
public boolean hasBanks() {
return false;
}
public boolean hasBank(String bank) {
return false;
}
public boolean hasAccount(String name) {
return com.nijiko.coelho.iConomy.iConomy.getBank().hasAccount(name);
}
public boolean hasBankAccount(String bank, String name) {
return false;
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
try {
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name);
} catch(Exception E) {
return false;
}
return true;
}
public boolean createAccount(String name, double balance) {
if(hasAccount(name))
return false;
try {
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name, balance);
} catch(Exception E) {
return false;
}
return true;
}
public MethodAccount getAccount(String name) {
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
}
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;
}
public void setPlugin(Plugin plugin) {
iConomy = (iConomy)plugin;
}
public static class iCoAccount implements MethodAccount {
private Account account;
public iCoAccount(Account account) {
this.account = account;
}
public Account getiCoAccount() {
return account;
}
public double balance() {
return this.account.getBalance();
}
public boolean set(double amount) {
if(this.account == null) return false;
this.account.setBalance(amount);
return true;
}
public boolean add(double amount) {
if(this.account == null) return false;
this.account.add(amount);
return true;
}
public boolean subtract(double amount) {
if(this.account == null) return false;
this.account.subtract(amount);
return true;
}
public boolean multiply(double amount) {
if(this.account == null) return false;
this.account.multiply(amount);
return true;
}
public boolean divide(double amount) {
if(this.account == null) return false;
this.account.divide(amount);
return true;
}
public boolean hasEnough(double amount) {
return this.account.hasEnough(amount);
}
public boolean hasOver(double amount) {
return this.account.hasOver(amount);
}
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public boolean isNegative() {
return this.account.isNegative();
}
public boolean remove() {
if(this.account == null) return false;
this.account.remove();
return true;
}
}
}

View File

@ -2,7 +2,7 @@ name: ChestShop
main: com.Acrobot.ChestShop.ChestShop
version: 3.36
version: 3.37
author: Acrobot