diff --git a/Essentials/nbproject/build-impl.xml b/Essentials/nbproject/build-impl.xml index 1b4d850b0..1a7dc9a70 100644 --- a/Essentials/nbproject/build-impl.xml +++ b/Essentials/nbproject/build-impl.xml @@ -601,6 +601,13 @@ is divided into following sections: + + + + + + + @@ -1037,6 +1044,13 @@ is divided into following sections: + + + + + + + diff --git a/Essentials/nbproject/genfiles.properties b/Essentials/nbproject/genfiles.properties index 783a664fe..50c2f50f9 100644 --- a/Essentials/nbproject/genfiles.properties +++ b/Essentials/nbproject/genfiles.properties @@ -3,8 +3,8 @@ build.xml.script.CRC32=3233ee78 build.xml.stylesheet.CRC32=28e38971@1.38.2.45 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=ab78ce15 -nbproject/build-impl.xml.script.CRC32=47c899ce +nbproject/build-impl.xml.data.CRC32=d763eebb +nbproject/build-impl.xml.script.CRC32=4f38ed38 nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45 nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15 nbproject/profiler-build-impl.xml.script.CRC32=abda56ed diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties index 66f740371..47a285424 100644 --- a/Essentials/nbproject/project.properties +++ b/Essentials/nbproject/project.properties @@ -29,13 +29,12 @@ excludes= file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar file.reference.Permissions.jar=..\\lib\\Permissions.jar -file.reference.Register.jar=../lib/Register.jar includes=** jar.compress=false javac.classpath=\ ${file.reference.Permissions.jar}:\ ${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\ - ${file.reference.Register.jar} + ${reference.Register.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false @@ -63,6 +62,8 @@ javadoc.windowtitle= meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false platform.active=default_platform +project.Register=../Register +reference.Register.jar=${project.Register}/dist/Register.jar run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} diff --git a/Essentials/nbproject/project.xml b/Essentials/nbproject/project.xml index aa1a9f770..819be6f4a 100644 --- a/Essentials/nbproject/project.xml +++ b/Essentials/nbproject/project.xml @@ -1,19 +1,28 @@ - - - org.netbeans.modules.java.j2seproject - - - Essentials - - - - - - - - - ../lib\nblibraries.properties - - - - + + + org.netbeans.modules.java.j2seproject + + + Essentials + + + + + + + + + ../lib\nblibraries.properties + + + + Register + jar + + jar + clean + jar + + + + diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 462488595..4af52b662 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -188,7 +188,7 @@ public class Essentials extends JavaPlugin pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.High, this); pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.High, this); attachEcoListeners(); - + if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2) { getServer().createWorld(settings.getNetherName(), World.Environment.NETHER); diff --git a/EssentialsiConomyBridge5/src/com/iConomy/iConomy.java b/EssentialsiConomyBridge5/src/com/iConomy/iConomy.java index 6cf7eb6d8..e5e920a56 100644 --- a/EssentialsiConomyBridge5/src/com/iConomy/iConomy.java +++ b/EssentialsiConomyBridge5/src/com/iConomy/iConomy.java @@ -47,7 +47,7 @@ public class iConomy extends JavaPlugin { logger.log(Level.WARNING, "Version mismatch! Please update all Essentials jars to the same version."); } - Essentials.getStatic().setIConomyFallback(false); + Essentials.getStatic().setRegisterFallback(false); diff --git a/Register/README b/Register/README new file mode 100644 index 000000000..84f8166d5 --- /dev/null +++ b/Register/README @@ -0,0 +1,7 @@ +/* + * Register - Bukkit Economy API for all Major Economies + * + * @author: Nijikokun + * @copyright: Copyright (C) 2011 + * @license: GNUv3 Affero License + */ \ No newline at end of file diff --git a/Register/build.xml b/Register/build.xml new file mode 100644 index 000000000..230fa8618 --- /dev/null +++ b/Register/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project Register. + + + diff --git a/Register/lib/BOSEconomy.jar b/Register/lib/BOSEconomy.jar new file mode 100644 index 000000000..bba5231f9 Binary files /dev/null and b/Register/lib/BOSEconomy.jar differ diff --git a/Register/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/Register/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar new file mode 100644 index 000000000..0cc8675c8 Binary files /dev/null and b/Register/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/Register/lib/Essentials.jar b/Register/lib/Essentials.jar new file mode 100644 index 000000000..9045e3bd4 Binary files /dev/null and b/Register/lib/Essentials.jar differ diff --git a/Register/lib/iCo4.jar b/Register/lib/iCo4.jar new file mode 100644 index 000000000..6cb256b66 Binary files /dev/null and b/Register/lib/iCo4.jar differ diff --git a/Register/lib/iCo5.jar b/Register/lib/iCo5.jar new file mode 100644 index 000000000..71a5d7141 Binary files /dev/null and b/Register/lib/iCo5.jar differ diff --git a/Register/lib/nblibraries.properties b/Register/lib/nblibraries.properties new file mode 100644 index 000000000..03b52d682 --- /dev/null +++ b/Register/lib/nblibraries.properties @@ -0,0 +1,2 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar diff --git a/Register/manifest.mf b/Register/manifest.mf new file mode 100644 index 000000000..328e8e5bc --- /dev/null +++ b/Register/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/Register/nbproject/build-impl.xml b/Register/nbproject/build-impl.xml new file mode 100644 index 000000000..150d18d12 --- /dev/null +++ b/Register/nbproject/build-impl.xml @@ -0,0 +1,1066 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + Must select one file in the IDE or set profile.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Register/nbproject/genfiles.properties b/Register/nbproject/genfiles.properties new file mode 100644 index 000000000..8a7a58e85 --- /dev/null +++ b/Register/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=c796020e +build.xml.script.CRC32=51c04dce +build.xml.stylesheet.CRC32=28e38971@1.43.1.45 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=c796020e +nbproject/build-impl.xml.script.CRC32=33bbc379 +nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45 diff --git a/Register/nbproject/project.properties b/Register/nbproject/project.properties new file mode 100644 index 000000000..8e2cbca09 --- /dev/null +++ b/Register/nbproject/project.properties @@ -0,0 +1,81 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/Register.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +file.reference.BOSEconomy.jar=lib/BOSEconomy.jar +file.reference.bukkit-0.0.1-SNAPSHOT.jar=../lib/bukkit-0.0.1-SNAPSHOT.jar +file.reference.Essentials.jar=lib/Essentials.jar +file.reference.iCo4.jar=lib/iCo4.jar +file.reference.iCo5.jar=lib/iCo5.jar +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.BOSEconomy.jar}:\ + ${file.reference.Essentials.jar}:\ + ${file.reference.iCo4.jar}:\ + ${file.reference.iCo5.jar}:\ + ${file.reference.bukkit-0.0.1-SNAPSHOT.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.6 +javac.target=1.6 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/Register/nbproject/project.xml b/Register/nbproject/project.xml new file mode 100644 index 000000000..f90903c5e --- /dev/null +++ b/Register/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.java.j2seproject + + + Register + + + + + + + + + ./lib/nblibraries.properties + + + diff --git a/Register/src/com/essentials/register/payment/Method.java b/Register/src/com/essentials/register/payment/Method.java new file mode 100644 index 000000000..935a9bb00 --- /dev/null +++ b/Register/src/com/essentials/register/payment/Method.java @@ -0,0 +1,48 @@ +package com.nijikokun.register.payment; + +public interface Method { + public Object getPlugin(); + public String getName(); + public String getVersion(); + public String format(double amount); + public boolean hasBanks(); + public boolean hasBank(String bank); + public boolean hasAccount(String name); + public boolean hasBankAccount(String bank, String name); + public MethodAccount getAccount(String name); + public MethodBankAccount getBankAccount(String bank, String name); + + public interface MethodAccount { + public double balance(); + 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 + public String toString(); + } + + public interface MethodBankAccount { + public double balance(); + public String getBankName(); + public int getBankId(); + 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 + public String toString(); + } +} diff --git a/Register/src/com/essentials/register/payment/MethodBOSEconomy.java b/Register/src/com/essentials/register/payment/MethodBOSEconomy.java new file mode 100644 index 000000000..7e0babe68 --- /dev/null +++ b/Register/src/com/essentials/register/payment/MethodBOSEconomy.java @@ -0,0 +1,180 @@ +package com.nijikokun.register.payment; + +import cosine.boseconomy.BOSEconomy; + +public class MethodBOSEconomy implements Method { + private BOSEconomy BOSEconomy; + + public MethodBOSEconomy(BOSEconomy BOSEconomy) { + this.BOSEconomy = BOSEconomy; + } + + public BOSEconomy getPlugin() { + return this.BOSEconomy; + } + + public String getName() { + return "BOSEconomy"; + } + + public String getVersion() { + return "0.6.2"; + } + + 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); + } + + public MethodAccount getAccount(String name) { + if(!hasAccount(name)) return null; + return new BOSEAccount(name, this.BOSEconomy); + } + + public MethodBankAccount getBankAccount(String bank, String name) { + return new BOSEBankAccount(bank, name, BOSEconomy); + } + + public class BOSEAccount implements MethodAccount { + private String name; + private BOSEconomy BOSEconomy; + + public BOSEAccount(String name, BOSEconomy bOSEconomy) { + this.name = name; + this.BOSEconomy = bOSEconomy; + } + + public double balance() { + return Double.valueOf(this.BOSEconomy.getPlayerMoney(this.name)); + } + + public boolean add(double amount) { + int IntAmount = (int)Math.ceil(amount); + int balance = (int)this.balance(); + 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 class BOSEBankAccount implements MethodBankAccount { + private String bank; + private String name; + private BOSEconomy BOSEconomy; + + public BOSEBankAccount(String bank, String name, BOSEconomy bOSEconomy) { + this.name = name; + this.bank = bank; + this.BOSEconomy = bOSEconomy; + } + + public String getBankName() { + return this.bank; + } + + public int getBankId() { + return -1; + } + + public double balance() { + return Double.valueOf(this.BOSEconomy.getBankMoney(name)); + } + + public boolean add(double amount) { + int IntAmount = (int)Math.ceil(amount); + int balance = (int)this.balance(); + return this.BOSEconomy.setBankMoney(this.name, (balance + IntAmount), false); + } + + public boolean subtract(double amount) { + int IntAmount = (int)Math.ceil(amount); + int balance = (int)this.balance(); + return this.BOSEconomy.setBankMoney(this.name, (balance - IntAmount), false); + } + + public boolean multiply(double amount) { + int IntAmount = (int)Math.ceil(amount); + int balance = (int)this.balance(); + return this.BOSEconomy.setBankMoney(this.name, (balance * IntAmount), false); + } + + public boolean divide(double amount) { + int IntAmount = (int)Math.ceil(amount); + int balance = (int)this.balance(); + return this.BOSEconomy.setBankMoney(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 this.BOSEconomy.removeBank(bank); + } + } +} \ No newline at end of file diff --git a/Register/src/com/essentials/register/payment/MethodEEco.java b/Register/src/com/essentials/register/payment/MethodEEco.java new file mode 100644 index 000000000..e8e52a93d --- /dev/null +++ b/Register/src/com/essentials/register/payment/MethodEEco.java @@ -0,0 +1,106 @@ +package com.nijikokun.register.payment; + +import com.earth2me.essentials.Essentials; +import com.earth2me.essentials.api.Economy; + +public class MethodEEco implements Method { + private Essentials Essentials; + + public MethodEEco(Essentials Essentials) { + this.Essentials = Essentials; + } + + public Essentials getPlugin() { + return this.Essentials; + } + + public String getName() { + return "EssentialsEco"; + } + + public String getVersion() { + return "2.2"; + } + + public String format(double amount) { + return Economy.format(amount); + } + + public boolean hasBanks() { + return false; + } + + public boolean hasBank(String bank) { + return false; + } + + public boolean hasAccount(String name) { + return Economy.accountExist(name); + } + + public boolean hasBankAccount(String bank, String name) { + return false; + } + + public MethodAccount getAccount(String name) { + if(!hasAccount(name)) return null; + return new EEcoAccount(name); + } + + public MethodBankAccount getBankAccount(String bank, String name) { + return null; + } + + public class EEcoAccount implements MethodAccount { + private String name; + + public EEcoAccount(String name) { + this.name = name; + } + + public double balance() { + return Economy.getMoney(this.name); + } + + public boolean add(double amount) { + Economy.add(name, amount); + return true; + } + + public boolean subtract(double amount) { + Economy.subtract(name, amount); + return true; + } + + public boolean multiply(double amount) { + Economy.multiply(name, amount); + return true; + } + + public boolean divide(double amount) { + Economy.divide(name, amount); + return true; + } + + public boolean hasEnough(double amount) { + return Economy.hasEnough(name, amount); + } + + public boolean hasOver(double amount) { + return Economy.hasMore(name, amount); + } + + public boolean hasUnder(double amount) { + return Economy.hasLess(name, amount); + } + + public boolean isNegative() { + return Economy.isNegative(name); + } + + public boolean remove() { + Economy.removeAccount(name); + return true; + } + } +} \ No newline at end of file diff --git a/Register/src/com/essentials/register/payment/MethodiCo4.java b/Register/src/com/essentials/register/payment/MethodiCo4.java new file mode 100644 index 000000000..47448deae --- /dev/null +++ b/Register/src/com/essentials/register/payment/MethodiCo4.java @@ -0,0 +1,114 @@ +package com.nijikokun.register.payment; + +import com.nijiko.coelho.iConomy.iConomy; +import com.nijiko.coelho.iConomy.system.Account; + +public class MethodiCo4 implements Method { + private iConomy iConomy; + + public MethodiCo4(iConomy iConomy) { + this.iConomy = iConomy; + } + + public iConomy getPlugin() { + return this.iConomy; + } + + public String getName() { + return "iConomy"; + } + + public String getVersion() { + return "4"; + } + + public String format(double amount) { + return this.iConomy.getBank().format(amount); + } + + public boolean hasBanks() { + return false; + } + + public boolean hasBank(String bank) { + return false; + } + + public boolean hasAccount(String name) { + return this.iConomy.getBank().hasAccount(name); + } + + public boolean hasBankAccount(String bank, String name) { + return false; + } + + public MethodAccount getAccount(String name) { + return new iCoAccount(this.iConomy.getBank().getAccount(name)); + } + + public MethodBankAccount getBankAccount(String bank, String name) { + return null; + } + + public 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 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; + } + } +} diff --git a/Register/src/com/essentials/register/payment/MethodiCo5.java b/Register/src/com/essentials/register/payment/MethodiCo5.java new file mode 100644 index 000000000..1927d9fcf --- /dev/null +++ b/Register/src/com/essentials/register/payment/MethodiCo5.java @@ -0,0 +1,191 @@ +package com.nijikokun.register.payment; + +import com.iConomy.iConomy; +import com.iConomy.system.Account; +import com.iConomy.system.BankAccount; +import com.iConomy.system.Holdings; +import com.iConomy.util.Constants; + +public class MethodiCo5 implements Method { + private iConomy iConomy; + + public MethodiCo5(iConomy iConomy) { + this.iConomy = iConomy; + } + + public iConomy getPlugin() { + return this.iConomy; + } + + public String getName() { + return "iConomy"; + } + + public String getVersion() { + return "5"; + } + + public String format(double amount) { + return this.iConomy.format(amount); + } + + public boolean hasBanks() { + return Constants.Banking; + } + + public boolean hasBank(String bank) { + return (!hasBanks()) ? false : this.iConomy.Banks.exists(bank); + } + + public boolean hasAccount(String name) { + return this.iConomy.hasAccount(name); + } + + public boolean hasBankAccount(String bank, String name) { + return (hasBank(bank)) ? false : this.iConomy.getBank(name).hasAccount(name); + } + + public MethodAccount getAccount(String name) { + return new iCoAccount(this.iConomy.getAccount(name)); + } + + public MethodBankAccount getBankAccount(String bank, String name) { + return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name)); + } + + public class iCoAccount implements MethodAccount { + private Account account; + private Holdings holdings; + + public iCoAccount(Account account) { + this.account = account; + this.holdings = account.getHoldings(); + } + + public Account getiCoAccount() { + return account; + } + + public double balance() { + return this.holdings.balance(); + } + + public boolean add(double amount) { + if(this.holdings == null) return false; + this.holdings.add(amount); + return true; + } + + public boolean subtract(double amount) { + if(this.holdings == null) return false; + this.holdings.subtract(amount); + return true; + } + + public boolean multiply(double amount) { + if(this.holdings == null) return false; + this.holdings.multiply(amount); + return true; + } + + public boolean divide(double amount) { + if(this.holdings == null) return false; + this.holdings.divide(amount); + return true; + } + + public boolean hasEnough(double amount) { + return this.holdings.hasEnough(amount); + } + + public boolean hasOver(double amount) { + return this.holdings.hasOver(amount); + } + + public boolean hasUnder(double amount) { + return this.holdings.hasUnder(amount); + } + + public boolean isNegative() { + return this.holdings.isNegative(); + } + + public boolean remove() { + if(this.account == null) return false; + this.account.remove(); + return true; + } + } + + public class iCoBankAccount implements MethodBankAccount { + private BankAccount account; + private Holdings holdings; + + public iCoBankAccount(BankAccount account) { + this.account = account; + this.holdings = account.getHoldings(); + } + + public BankAccount getiCoBankAccount() { + return account; + } + + public String getBankName() { + return this.account.getBankName(); + } + + public int getBankId() { + return this.account.getBankId(); + } + + public double balance() { + return this.holdings.balance(); + } + + public boolean add(double amount) { + if(this.holdings == null) return false; + this.holdings.add(amount); + return true; + } + + public boolean subtract(double amount) { + if(this.holdings == null) return false; + this.holdings.subtract(amount); + return true; + } + + public boolean multiply(double amount) { + if(this.holdings == null) return false; + this.holdings.multiply(amount); + return true; + } + + public boolean divide(double amount) { + if(this.holdings == null) return false; + this.holdings.divide(amount); + return true; + } + + public boolean hasEnough(double amount) { + return this.holdings.hasEnough(amount); + } + + public boolean hasOver(double amount) { + return this.holdings.hasOver(amount); + } + + public boolean hasUnder(double amount) { + return this.holdings.hasUnder(amount); + } + + public boolean isNegative() { + return this.holdings.isNegative(); + } + + public boolean remove() { + if(this.account == null) return false; + this.account.remove(); + return true; + } + } +} diff --git a/Register/src/com/essentials/register/payment/Methods.java b/Register/src/com/essentials/register/payment/Methods.java new file mode 100644 index 000000000..7cf340940 --- /dev/null +++ b/Register/src/com/essentials/register/payment/Methods.java @@ -0,0 +1,76 @@ +package com.nijikokun.register.payment; + +import com.iConomy.iConomy; +import cosine.boseconomy.BOSEconomy; +import com.earth2me.essentials.Essentials; + +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.PluginDescriptionFile; + +public class Methods { + private Method Method = null; + public Plugin method = null; + + public boolean setMethod(Plugin method) { + PluginManager loader = method.getServer().getPluginManager(); + + if(method.isEnabled()) { + PluginDescriptionFile info = method.getDescription(); + String name = info.getName(); + + if(name.equalsIgnoreCase("iconomy")) { + if(method.getClass().getName().equals("com.iConomy.iConomy")) + Method = new MethodiCo5((iConomy)method); + else { Method = new MethodiCo4((com.nijiko.coelho.iConomy.iConomy)method); } + } else if(name.equalsIgnoreCase("boseconomy")) { + Method = new MethodBOSEconomy((BOSEconomy)method); + } else if(name.equalsIgnoreCase("essentials")) { + Method = new MethodEEco((Essentials)method); + } + } + + if(!hasMethod()) { + if(loader.getPlugin("iConomy") != null) { + method = loader.getPlugin("iConomy"); + if(method.getClass().getName().equals("com.iConomy.iConomy")) + Method = new MethodiCo5((iConomy)method); + else { Method = new MethodiCo4((com.nijiko.coelho.iConomy.iConomy)method); } + } else if(loader.getPlugin("BOSEconomy") != null) { + method = loader.getPlugin("BOSEconomy"); + Method = new MethodBOSEconomy((BOSEconomy)method); + } else if(loader.getPlugin("Essentials") != null) { + method = loader.getPlugin("Essentials"); + Method = new MethodEEco((Essentials)method); + } + } + + return hasMethod(); + } + + public boolean checkDisabled(Plugin method) { + PluginDescriptionFile info = method.getDescription(); + String name = info.getName(); + + if(name.equalsIgnoreCase("iconomy")) { + if(method.getClass().getName().equals("com.iConomy.iConomy")) + Method = null; + else { Method = null; } + } else if(name.equalsIgnoreCase("boseconomy")) { + Method = null; + } else if(name.equalsIgnoreCase("essentials")) { + Method = null; + } + + return (Method == null); + } + + public boolean hasMethod() { + return (Method != null); + } + + public Method getMethod() { + return Method; + } + +}