summaryrefslogtreecommitdiffstats
path: root/EssentialsiConomyBridge/src/com/nijiko
diff options
context:
space:
mode:
authorxeology <xeology@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-02 09:56:40 +0000
committerxeology <xeology@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-02 09:56:40 +0000
commit9d961980e8745bad3a4a1cc4009cdd59de1647cc (patch)
tree7464c3d4ccccfcc6bf0deed77c49e44240445856 /EssentialsiConomyBridge/src/com/nijiko
parente327aee283121e5f18134bdf237d7d7585879dd9 (diff)
downloadEssentials-9d961980e8745bad3a4a1cc4009cdd59de1647cc.tar
Essentials-9d961980e8745bad3a4a1cc4009cdd59de1647cc.tar.gz
Essentials-9d961980e8745bad3a4a1cc4009cdd59de1647cc.tar.lz
Essentials-9d961980e8745bad3a4a1cc4009cdd59de1647cc.tar.xz
Essentials-9d961980e8745bad3a4a1cc4009cdd59de1647cc.zip
FayConomy is now EssentialsiConomyBridge, done and ported, fully functional. Relies on EcoAPI!
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1316 e251c2fe-e539-e718-e476-b85c1f46cddb
Diffstat (limited to 'EssentialsiConomyBridge/src/com/nijiko')
-rw-r--r--EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/existCheck.java19
-rw-r--r--EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/iConomy.java39
-rw-r--r--EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/system/Account.java149
-rw-r--r--EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/system/Bank.java53
4 files changed, 260 insertions, 0 deletions
diff --git a/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/existCheck.java b/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/existCheck.java
new file mode 100644
index 000000000..e0966fa3f
--- /dev/null
+++ b/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/existCheck.java
@@ -0,0 +1,19 @@
+package com.nijiko.coelho.iConomy;
+
+import org.bukkit.Bukkit;
+
+public class existCheck {
+
+ //We have to make sure the user exists!
+
+ public static boolean exist(String name){
+ if (name==null){
+ System.out.println("Essentials iConpomy Bridge - Whatever plugin is calling for users that are null is BROKEN!");
+ return false;
+ }
+ if (Bukkit.getServer().getPlayer(name)!=null){
+ return true;
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/iConomy.java b/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/iConomy.java
new file mode 100644
index 000000000..1690040b0
--- /dev/null
+++ b/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/iConomy.java
@@ -0,0 +1,39 @@
+package com.nijiko.coelho.iConomy;
+
+import org.bukkit.plugin.java.JavaPlugin;
+import com.nijiko.coelho.iConomy.system.Bank;
+
+//This is not iConomy and I take NO credit for iConomy!
+//This is FayConomy, a iConomy Essentials Eco bridge!
+//@author Xeology
+
+//Pretend we are iConomy
+
+public class iConomy extends JavaPlugin{
+ public static Bank Bank=null;
+
+ //This is for the Essentials to detect FayConomy!
+
+ public static boolean isFay(){
+ return true;
+ }
+
+ @Override
+ public void onDisable() {
+ }
+
+ @Override
+ public void onEnable() {
+ Bank=new Bank();
+
+ //Can not announce my plugin.yml file, this is NOT iConomy!
+
+ System.out.println("Essentials iConomy Bridge v1.0 iz in ur Bukkitz emulating ur iConomyz!");
+ }
+
+ //Fake bank
+
+ public static Bank getBank() {
+ return Bank;
+ }
+}
diff --git a/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/system/Account.java b/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/system/Account.java
new file mode 100644
index 000000000..740b31f58
--- /dev/null
+++ b/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/system/Account.java
@@ -0,0 +1,149 @@
+package com.nijiko.coelho.iConomy.system;
+
+import com.earth2me.essentials.EcoAPI;
+import com.nijiko.coelho.iConomy.existCheck;
+
+
+public class Account
+{
+ private String name;
+
+ //Fake getname
+ public String getName()
+ {
+ return name;
+ }
+
+ //Essentials doesnt have hidden accounts so just say yeah whatever!
+ public boolean setHidden(boolean hidden)
+ {
+ return true;
+ }
+
+ //Simply set the account variable type?
+ public Account(String name)
+ {
+ this.name = name;
+ }
+
+ //Fake return balance
+ public double getBalance()
+ {
+ if (!existCheck.exist(name))
+ {
+ if (EcoAPI.accountExist(name))
+ {
+ return EcoAPI.getMoney(name);
+ }
+ return 0;
+ }
+ return EcoAPI.getMoney(name);
+ }
+
+ //Fake Set balance
+ public void setBalance(double bal)
+ {
+ if (!existCheck.exist(name))
+ {
+ if (EcoAPI.accountExist(name))
+ {
+ EcoAPI.setMoney(name, bal);
+ }
+ return;
+ }
+ EcoAPI.setMoney(name, bal);
+ }
+
+ //Fake add balance
+ public void add(double money)
+ {
+ if (!existCheck.exist(name))
+ {
+ if (EcoAPI.accountExist(name))
+ {
+ EcoAPI.add(name, money);
+ }
+ return;
+ }
+ EcoAPI.add(name, money);
+ }
+
+ //Fake divide balance
+ public void divide(double money)
+ {
+ if (!existCheck.exist(name))
+ {
+ if (EcoAPI.accountExist(name))
+ {
+ EcoAPI.divide(name, money);
+ }
+ return;
+ }
+ EcoAPI.divide(name, money);
+ }
+
+ //Fake multiply balance
+ public void multiply(double money)
+ {
+ if (!existCheck.exist(name))
+ {
+ if (EcoAPI.accountExist(name))
+ {
+ EcoAPI.multiply(name, money);
+ }
+ return;
+ }
+ EcoAPI.multiply(name, money);
+ }
+
+ //Fake subtract balance
+ public void subtract(double money)
+ {
+ if (!existCheck.exist(name))
+ {
+ if (EcoAPI.accountExist(name))
+ {
+ EcoAPI.subtract(name, money);
+ }
+ return;
+ }
+ EcoAPI.subtract(name, money);
+ }
+
+ //fake reset balance!
+ public void resetBalance()
+ {
+ this.setBalance(0);
+ }
+
+ //fake bal check
+ public boolean hasEnough(double amount)
+ {
+ return amount <= this.getBalance();
+ }
+
+ //fake another balance check
+ public boolean hasOver(double amount)
+ {
+ return amount < this.getBalance();
+ }
+
+ //Again we dont have hidden accounts here!
+ public boolean isHidden()
+ {
+ return false;
+ }
+
+ //Fake is negative check!
+ public boolean isNegative()
+ {
+ return this.getBalance() < 0.0;
+ }
+
+ //Because some plugins like to use depricated methods I must save
+ //admins' log from the overflow of dumb
+ public void save()
+ {
+ }
+;
+}
diff --git a/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/system/Bank.java b/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/system/Bank.java
new file mode 100644
index 000000000..b70803dda
--- /dev/null
+++ b/EssentialsiConomyBridge/src/com/nijiko/coelho/iConomy/system/Bank.java
@@ -0,0 +1,53 @@
+package com.nijiko.coelho.iConomy.system;
+
+import com.earth2me.essentials.EcoAPI;
+import com.nijiko.coelho.iConomy.existCheck;
+
+
+public class Bank {
+
+ //The fake formatter
+
+ public String format(double amount) {
+ return EcoAPI.format(amount);
+ }
+
+ //Fake currency!
+
+ public String getCurrency() {
+ return EcoAPI.getCurrency();
+ }
+
+ //Fake "does player have an account?" but essentials eco doesnt need to make one, so TRUE, unless its an NPC.
+
+ public boolean hasAccount(String account) {
+ if (!existCheck.exist(account)){
+ if (!EcoAPI.accountExist(account)){
+ EcoAPI.newAccount(account);
+ }
+ }
+ return true;
+ }
+
+ //simply switches the name to an account type?
+
+ public Account getAccount(String name){
+ Account Account=null;
+ Account=new Account(name);
+ hasAccount(name);
+ return Account;
+ }
+
+ //Fake remove account
+
+ public void removeAccount(String name){
+ if (!existCheck.exist(name)){
+ if (EcoAPI.accountExist(name)){
+ EcoAPI.removeAccount(name);
+ }
+ return;
+ }
+ EcoAPI.setMoney(name, 0);
+ }
+
+}