mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-24 11:54:35 +08:00
Cleanup of the iConomyBridge Code
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1321 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
2af13fd062
commit
79c0ef69c4
@ -27,7 +27,7 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
|||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
excludes=
|
||||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||||
file.reference.EssentialsiConomyBridge.jar=..\\lib\\EssentialsiConomyBridge.jar
|
file.reference.iConomy.jar=../lib/iConomy.jar
|
||||||
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
|
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
|
||||||
file.reference.Permissions.jar=..\\lib\\Permissions.jar
|
file.reference.Permissions.jar=..\\lib\\Permissions.jar
|
||||||
includes=**
|
includes=**
|
||||||
@ -35,7 +35,7 @@ jar.compress=false
|
|||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
${file.reference.Permissions.jar}:\
|
${file.reference.Permissions.jar}:\
|
||||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
||||||
${file.reference.EssentialsiConomyBridge.jar}
|
${file.reference.iConomy.jar}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=
|
javac.compilerargs=
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
|
@ -41,6 +41,7 @@ public class Essentials extends JavaPlugin
|
|||||||
private Backup backup;
|
private Backup backup;
|
||||||
private Map<String, User> users = new HashMap<String, User>();
|
private Map<String, User> users = new HashMap<String, User>();
|
||||||
private EssentialsTimer timer;
|
private EssentialsTimer timer;
|
||||||
|
private boolean iConomyFallback = true;
|
||||||
|
|
||||||
public Essentials()
|
public Essentials()
|
||||||
{
|
{
|
||||||
@ -605,4 +606,12 @@ public class Essentials extends JavaPlugin
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIConomyFallback(boolean iConomyFallback) {
|
||||||
|
this.iConomyFallback = iConomyFallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIConomyFallbackEnabled() {
|
||||||
|
return iConomyFallback;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.craftbukkit.block.CraftSign;
|
import org.bukkit.craftbukkit.block.CraftSign;
|
||||||
@ -12,7 +11,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class EssentialsEcoBlockListener extends BlockListener
|
public class EssentialsEcoBlockListener extends BlockListener
|
||||||
{
|
{
|
||||||
public static DecimalFormat df = new DecimalFormat("0.##");
|
|
||||||
Essentials ess;
|
Essentials ess;
|
||||||
|
|
||||||
public EssentialsEcoBlockListener(Essentials ess)
|
public EssentialsEcoBlockListener(Essentials ess)
|
||||||
@ -116,8 +114,8 @@ public class EssentialsEcoBlockListener extends BlockListener
|
|||||||
{
|
{
|
||||||
throw new Exception("Don't sell air.");
|
throw new Exception("Don't sell air.");
|
||||||
}
|
}
|
||||||
String d = df.format(Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", "")));
|
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
|
||||||
event.setLine(3, "$" + d);
|
event.setLine(3, Util.formatCurrency(price));
|
||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
@ -141,8 +139,8 @@ public class EssentialsEcoBlockListener extends BlockListener
|
|||||||
{
|
{
|
||||||
throw new Exception("Don't buy air.");
|
throw new Exception("Don't buy air.");
|
||||||
}
|
}
|
||||||
String d = df.format(Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", "")));
|
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
|
||||||
event.setLine(3, "$" + d);
|
event.setLine(3, Util.formatCurrency(price));
|
||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
|
@ -125,7 +125,7 @@ public class EssentialsEcoPlayerListener extends PlayerListener
|
|||||||
user.updateInventory();
|
user.updateInventory();
|
||||||
}
|
}
|
||||||
r1 = 0;
|
r1 = 0;
|
||||||
sign.setLine(1, (m1 ? "$" + q1 : q1 + " " + l1[1]) + ":" + r1);
|
sign.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]) + ":" + r1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -177,8 +177,8 @@ public class EssentialsEcoPlayerListener extends PlayerListener
|
|||||||
r2 -= q2;
|
r2 -= q2;
|
||||||
|
|
||||||
sign.setLine(0, "§1[Trade]");
|
sign.setLine(0, "§1[Trade]");
|
||||||
sign.setLine(1, (m1 ? "$" + q1 : q1 + " " + l1[1]) + ":" + r1);
|
sign.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]) + ":" + r1);
|
||||||
sign.setLine(2, (m2 ? "$" + q2 : q2 + " " + l2[1]) + ":" + r2);
|
sign.setLine(2, (m2 ? Util.formatCurrency(q2) : (int)q2 + " " + l2[1]) + ":" + r2);
|
||||||
|
|
||||||
user.sendMessage("§7Trade completed.");
|
user.sendMessage("§7Trade completed.");
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo
|
|||||||
private boolean teleportRequestHere;
|
private boolean teleportRequestHere;
|
||||||
private Teleport teleport;
|
private Teleport teleport;
|
||||||
private long lastActivity;
|
private long lastActivity;
|
||||||
private static DecimalFormat df = new DecimalFormat("0.##");
|
|
||||||
|
|
||||||
User(Player base, Essentials ess)
|
User(Player base, Essentials ess)
|
||||||
{
|
{
|
||||||
@ -86,8 +85,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setMoney(getMoney() + value);
|
setMoney(getMoney() + value);
|
||||||
String d = df.format(Double.parseDouble(Double.toString(value)));
|
sendMessage("§a" + Util.formatCurrency(value) + " has been added to your account.");
|
||||||
sendMessage("§a$" + d + " has been added to your account.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void payUser(User reciever, double value) throws Exception
|
public void payUser(User reciever, double value) throws Exception
|
||||||
@ -104,9 +102,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo
|
|||||||
{
|
{
|
||||||
setMoney(getMoney() - value);
|
setMoney(getMoney() - value);
|
||||||
reciever.setMoney(reciever.getMoney() + value);
|
reciever.setMoney(reciever.getMoney() + value);
|
||||||
String d = df.format(Double.parseDouble(Double.toString(value)));
|
sendMessage("§a" + Util.formatCurrency(value) + " has been sent to " + reciever.getDisplayName());
|
||||||
sendMessage("§a$" + d + " has been sent to " + reciever.getDisplayName());
|
reciever.sendMessage("§a" + Util.formatCurrency(value) + " has been recieved from " + getDisplayName());
|
||||||
reciever.sendMessage("§a$" + d + " has been recieved from " + getDisplayName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,8 +114,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setMoney(getMoney() - value);
|
setMoney(getMoney() - value);
|
||||||
String d = df.format(Double.parseDouble(Double.toString(value)));
|
sendMessage("§c$" + Util.formatCurrency(value) + " has been taken from your account.");
|
||||||
sendMessage("§c$" + d + " has been taken from your account.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void charge(String cmd) throws Exception
|
public void charge(String cmd) throws Exception
|
||||||
|
@ -63,28 +63,33 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||||||
{
|
{
|
||||||
return config.getDouble("money", ess.getSettings().getStartingBalance());
|
return config.getDouble("money", ess.getSettings().getStartingBalance());
|
||||||
}
|
}
|
||||||
|
if (ess.isIConomyFallbackEnabled())
|
||||||
try
|
|
||||||
{
|
{
|
||||||
return com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(getName()).getBalance();
|
try
|
||||||
}
|
{
|
||||||
catch (Throwable ex)
|
return com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(getName()).getBalance();
|
||||||
{
|
}
|
||||||
return ess.getSettings().getStartingBalance();
|
catch (Throwable ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return ess.getSettings().getStartingBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoney(double value)
|
public void setMoney(double value)
|
||||||
{
|
{
|
||||||
try
|
if (ess.isIConomyFallbackEnabled())
|
||||||
{
|
{
|
||||||
com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(getName()).setBalance(value);
|
try
|
||||||
}
|
{
|
||||||
catch (Throwable ex)
|
com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(getName()).setBalance(value);
|
||||||
{
|
}
|
||||||
config.setProperty("money", value);
|
catch (Throwable ex)
|
||||||
config.save();
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
config.setProperty("money", value);
|
||||||
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasHome()
|
public boolean hasHome()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -256,19 +257,9 @@ public class Util
|
|||||||
}
|
}
|
||||||
return isBlockAboveAir(world, x, y, z);
|
return isBlockAboveAir(world, x, y, z);
|
||||||
}
|
}
|
||||||
public static boolean detectFay()
|
|
||||||
{
|
private static DecimalFormat df = new DecimalFormat("0.##");
|
||||||
try
|
public static String formatCurrency(double value) {
|
||||||
{
|
return "$"+df.format(value);
|
||||||
if (com.nijiko.coelho.iConomy.iConomy.isFay())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable ex)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials.api;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@ -8,10 +11,9 @@ import java.text.DecimalFormat;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
|
||||||
|
public class Economy
|
||||||
public class EcoAPI
|
|
||||||
{
|
{
|
||||||
protected static Essentials ess=Essentials.getStatic();
|
protected static Essentials ess = Essentials.getStatic();
|
||||||
|
|
||||||
//Does the file exists?
|
//Does the file exists?
|
||||||
protected static boolean accountCreated(String name)
|
protected static boolean accountCreated(String name)
|
||||||
@ -314,7 +316,6 @@ public class EcoAPI
|
|||||||
//Eco remove account, only use this for NPCS!
|
//Eco remove account, only use this for NPCS!
|
||||||
public static void removeAccount(String name)
|
public static void removeAccount(String name)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!exist(name))
|
if (!exist(name))
|
||||||
{
|
{
|
||||||
if (accountCreated(name))
|
if (accountCreated(name))
|
@ -4,13 +4,13 @@ import org.bukkit.Server;
|
|||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.earth2me.essentials.ItemDb;
|
import com.earth2me.essentials.ItemDb;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import java.text.DecimalFormat;
|
import com.earth2me.essentials.Util;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
public class Commandworth extends EssentialsCommand
|
public class Commandworth extends EssentialsCommand
|
||||||
{
|
{
|
||||||
private static DecimalFormat df = new DecimalFormat("0.##");
|
|
||||||
public Commandworth()
|
public Commandworth()
|
||||||
{
|
{
|
||||||
super("worth");
|
super("worth");
|
||||||
@ -47,8 +47,9 @@ public class Commandworth extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
user.charge(this);
|
user.charge(this);
|
||||||
String d = df.format(Double.parseDouble(Double.toString(worth)));
|
user.sendMessage("§7Stack of "
|
||||||
String d2 = df.format(Double.parseDouble(Double.toString(Double.parseDouble(d)*amount)));
|
+ is.getType().toString().toLowerCase().replace("_", "")
|
||||||
user.sendMessage("§7Stack of " + is.getType().toString().toLowerCase().replace("_", "") + " worth §c$" + d2 + "§7 (" + amount + " item(s) at $" + d + " each)");
|
+ " worth §c$" + Util.formatCurrency(worth*amount) + "§7 ("
|
||||||
|
+ amount + " item(s) at $" + Util.formatCurrency(worth) + " each)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ main: com.earth2me.essentials.Essentials
|
|||||||
version: TeamCity
|
version: TeamCity
|
||||||
website: http://www.earth2me.net:8001/
|
website: http://www.earth2me.net:8001/
|
||||||
description: Provides an essential, core set of commands for Bukkit.
|
description: Provides an essential, core set of commands for Bukkit.
|
||||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo]
|
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
|
||||||
commands:
|
commands:
|
||||||
afk:
|
afk:
|
||||||
description: Marks you as away-from-keyboard.
|
description: Marks you as away-from-keyboard.
|
||||||
|
@ -5,4 +5,4 @@ main: com.earth2me.essentials.chat.EssentialsChat
|
|||||||
version: TeamCity
|
version: TeamCity
|
||||||
website: http://www.earth2me.net:8001/
|
website: http://www.earth2me.net:8001/
|
||||||
description: Provides chat control features for Essentials. Requires Permissions.
|
description: Provides chat control features for Essentials. Requires Permissions.
|
||||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo]
|
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
|
@ -5,4 +5,4 @@ main: com.earth2me.essentials.geoip.EssentialsGeoIP
|
|||||||
version: TeamCity
|
version: TeamCity
|
||||||
website: http://www.earth2me.net:8001/
|
website: http://www.earth2me.net:8001/
|
||||||
description: Shows the country or city of a user on login and /whois.
|
description: Shows the country or city of a user on login and /whois.
|
||||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo]
|
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
|
@ -5,4 +5,4 @@ main: com.earth2me.essentials.protect.EssentialsProtect
|
|||||||
version: TeamCity
|
version: TeamCity
|
||||||
website: http://www.earth2me.net:8001/
|
website: http://www.earth2me.net:8001/
|
||||||
description: Provides protection for various parts of the world.
|
description: Provides protection for various parts of the world.
|
||||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo]
|
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
|
@ -5,7 +5,7 @@ main: com.earth2me.essentials.spawn.EssentialsSpawn
|
|||||||
version: TeamCity
|
version: TeamCity
|
||||||
website: http://www.earth2me.net:8001/
|
website: http://www.earth2me.net:8001/
|
||||||
description: Provides spawn control commands, utilizing Essentials.
|
description: Provides spawn control commands, utilizing Essentials.
|
||||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo]
|
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
|
||||||
commands:
|
commands:
|
||||||
setspawn:
|
setspawn:
|
||||||
description: Set the spawnpoint to your current position.
|
description: Set the spawnpoint to your current position.
|
||||||
|
@ -1,19 +1,25 @@
|
|||||||
package com.nijiko.coelho.iConomy;
|
package com.nijiko.coelho.iConomy;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class existCheck {
|
|
||||||
|
|
||||||
|
public class existCheck
|
||||||
|
{
|
||||||
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||||
//We have to make sure the user exists!
|
//We have to make sure the user exists!
|
||||||
|
public static boolean exist(String name)
|
||||||
|
{
|
||||||
|
|
||||||
public static boolean exist(String name){
|
if (name == null)
|
||||||
if (name==null){
|
{
|
||||||
System.out.println("Essentials iConpomy Bridge - Whatever plugin is calling for users that are null is BROKEN!");
|
logger.info("Essentials iConomy Bridge - Whatever plugin is calling for users that are null is BROKEN!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Bukkit.getServer().getPlayer(name)!=null){
|
if (Bukkit.getServer().getPlayer(name) != null)
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,39 +1,58 @@
|
|||||||
package com.nijiko.coelho.iConomy;
|
package com.nijiko.coelho.iConomy;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import com.nijiko.coelho.iConomy.system.Bank;
|
import com.nijiko.coelho.iConomy.system.Bank;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
//This is not iConomy and I take NO credit for iConomy!
|
/**
|
||||||
//This is FayConomy, a iConomy Essentials Eco bridge!
|
* This is not iConomy and I take NO credit for iConomy!
|
||||||
//@author Xeology
|
* This is FayConomy, a iConomy Essentials Eco bridge!
|
||||||
|
* @author Xeology
|
||||||
|
*/
|
||||||
|
|
||||||
//Pretend we are iConomy
|
public class iConomy extends JavaPlugin
|
||||||
|
{
|
||||||
|
public static Bank Bank = null;
|
||||||
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
public class iConomy extends JavaPlugin{
|
@Override
|
||||||
public static Bank Bank=null;
|
public void onDisable()
|
||||||
|
{
|
||||||
//This is for the Essentials to detect FayConomy!
|
|
||||||
|
|
||||||
public static boolean isFay(){
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onEnable()
|
||||||
}
|
{
|
||||||
|
PluginManager pm = this.getServer().getPluginManager();
|
||||||
|
Plugin p = pm.getPlugin("Essentials");
|
||||||
|
if (p != null)
|
||||||
|
{
|
||||||
|
if (!pm.isPluginEnabled(p))
|
||||||
|
{
|
||||||
|
pm.enablePlugin(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
String version = this.getDescription().getDescription().replaceAll(".*: ", "");
|
||||||
public void onEnable() {
|
if (!version.equals(Essentials.getStatic().getDescription().getVersion()))
|
||||||
Bank=new Bank();
|
{
|
||||||
|
logger.log(Level.WARNING, "Version mismatch! Please update all Essentials jars to the same version.");
|
||||||
|
}
|
||||||
|
Essentials.getStatic().setIConomyFallback(false);
|
||||||
|
|
||||||
//Can not announce my plugin.yml file, this is NOT iConomy!
|
Bank = new Bank();
|
||||||
|
|
||||||
System.out.println("Essentials iConomy Bridge v1.0 iz in ur Bukkitz emulating ur iConomyz!");
|
logger.info("Loaded " + this.getDescription().getDescription() + " by " + Essentials.AUTHORS);
|
||||||
|
logger.info("Make sure you don't have iConomy installed, if you use this.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake bank
|
//Fake bank
|
||||||
|
public static Bank getBank()
|
||||||
public static Bank getBank() {
|
{
|
||||||
return Bank;
|
return Bank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.nijiko.coelho.iConomy.system;
|
package com.nijiko.coelho.iConomy.system;
|
||||||
|
|
||||||
import com.earth2me.essentials.EcoAPI;
|
import com.earth2me.essentials.api.Economy;
|
||||||
import com.nijiko.coelho.iConomy.existCheck;
|
import com.nijiko.coelho.iConomy.existCheck;
|
||||||
|
|
||||||
|
|
||||||
@ -8,13 +8,15 @@ public class Account
|
|||||||
{
|
{
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
//Fake getname
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Essentials doesnt have hidden accounts so just say yeah whatever!
|
/**
|
||||||
|
* Essentials does not support hidden accounts.
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
public boolean setHidden(boolean hidden)
|
public boolean setHidden(boolean hidden)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -26,122 +28,118 @@ public class Account
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake return balance
|
|
||||||
public double getBalance()
|
public double getBalance()
|
||||||
{
|
{
|
||||||
if (!existCheck.exist(name))
|
if (!existCheck.exist(name))
|
||||||
{
|
{
|
||||||
if (EcoAPI.accountExist(name))
|
if (Economy.accountExist(name))
|
||||||
{
|
{
|
||||||
return EcoAPI.getMoney(name);
|
return Economy.getMoney(name);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return EcoAPI.getMoney(name);
|
return Economy.getMoney(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake Set balance
|
|
||||||
public void setBalance(double bal)
|
public void setBalance(double bal)
|
||||||
{
|
{
|
||||||
if (!existCheck.exist(name))
|
if (!existCheck.exist(name))
|
||||||
{
|
{
|
||||||
if (EcoAPI.accountExist(name))
|
if (Economy.accountExist(name))
|
||||||
{
|
{
|
||||||
EcoAPI.setMoney(name, bal);
|
Economy.setMoney(name, bal);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EcoAPI.setMoney(name, bal);
|
Economy.setMoney(name, bal);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake add balance
|
|
||||||
public void add(double money)
|
public void add(double money)
|
||||||
{
|
{
|
||||||
if (!existCheck.exist(name))
|
if (!existCheck.exist(name))
|
||||||
{
|
{
|
||||||
if (EcoAPI.accountExist(name))
|
if (Economy.accountExist(name))
|
||||||
{
|
{
|
||||||
EcoAPI.add(name, money);
|
Economy.add(name, money);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EcoAPI.add(name, money);
|
Economy.add(name, money);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake divide balance
|
|
||||||
public void divide(double money)
|
public void divide(double money)
|
||||||
{
|
{
|
||||||
if (!existCheck.exist(name))
|
if (!existCheck.exist(name))
|
||||||
{
|
{
|
||||||
if (EcoAPI.accountExist(name))
|
if (Economy.accountExist(name))
|
||||||
{
|
{
|
||||||
EcoAPI.divide(name, money);
|
Economy.divide(name, money);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EcoAPI.divide(name, money);
|
Economy.divide(name, money);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake multiply balance
|
|
||||||
public void multiply(double money)
|
public void multiply(double money)
|
||||||
{
|
{
|
||||||
if (!existCheck.exist(name))
|
if (!existCheck.exist(name))
|
||||||
{
|
{
|
||||||
if (EcoAPI.accountExist(name))
|
if (Economy.accountExist(name))
|
||||||
{
|
{
|
||||||
EcoAPI.multiply(name, money);
|
Economy.multiply(name, money);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EcoAPI.multiply(name, money);
|
Economy.multiply(name, money);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake subtract balance
|
|
||||||
public void subtract(double money)
|
public void subtract(double money)
|
||||||
{
|
{
|
||||||
if (!existCheck.exist(name))
|
if (!existCheck.exist(name))
|
||||||
{
|
{
|
||||||
if (EcoAPI.accountExist(name))
|
if (Economy.accountExist(name))
|
||||||
{
|
{
|
||||||
EcoAPI.subtract(name, money);
|
Economy.subtract(name, money);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EcoAPI.subtract(name, money);
|
Economy.subtract(name, money);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fake reset balance!
|
|
||||||
public void resetBalance()
|
public void resetBalance()
|
||||||
{
|
{
|
||||||
this.setBalance(0);
|
this.setBalance(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fake bal check
|
|
||||||
public boolean hasEnough(double amount)
|
public boolean hasEnough(double amount)
|
||||||
{
|
{
|
||||||
return amount <= this.getBalance();
|
return amount <= this.getBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
//fake another balance check
|
|
||||||
public boolean hasOver(double amount)
|
public boolean hasOver(double amount)
|
||||||
{
|
{
|
||||||
return amount < this.getBalance();
|
return amount < this.getBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Again we dont have hidden accounts here!
|
/**
|
||||||
|
* Essentials does not support hidden accounts.
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
public boolean isHidden()
|
public boolean isHidden()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake is negative check!
|
|
||||||
public boolean isNegative()
|
public boolean isNegative()
|
||||||
{
|
{
|
||||||
return this.getBalance() < 0.0;
|
return this.getBalance() < 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Because some plugins like to use depricated methods I must save
|
/**
|
||||||
//admins' log from the overflow of dumb
|
* Because some plugins like to use depricated methods I must save
|
||||||
|
* admins' log from the overflow of dumb
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,53 +1,56 @@
|
|||||||
package com.nijiko.coelho.iConomy.system;
|
package com.nijiko.coelho.iConomy.system;
|
||||||
|
|
||||||
import com.earth2me.essentials.EcoAPI;
|
import com.earth2me.essentials.api.Economy;
|
||||||
import com.nijiko.coelho.iConomy.existCheck;
|
import com.nijiko.coelho.iConomy.existCheck;
|
||||||
|
|
||||||
|
|
||||||
public class Bank {
|
public class Bank
|
||||||
|
{
|
||||||
//The fake formatter
|
//The fake formatter
|
||||||
|
public String format(double amount)
|
||||||
public String format(double amount) {
|
{
|
||||||
return EcoAPI.format(amount);
|
return Economy.format(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake currency!
|
//Fake currency!
|
||||||
|
public String getCurrency()
|
||||||
public String getCurrency() {
|
{
|
||||||
return EcoAPI.getCurrency();
|
return Economy.getCurrency();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake "does player have an account?" but essentials eco doesnt need to make one, so TRUE, unless its an NPC.
|
//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)
|
||||||
public boolean hasAccount(String account) {
|
{
|
||||||
if (!existCheck.exist(account)){
|
if (!existCheck.exist(account))
|
||||||
if (!EcoAPI.accountExist(account)){
|
{
|
||||||
EcoAPI.newAccount(account);
|
if (!Economy.accountExist(account))
|
||||||
|
{
|
||||||
|
Economy.newAccount(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//simply switches the name to an account type?
|
//simply switches the name to an account type?
|
||||||
|
public Account getAccount(String name)
|
||||||
public Account getAccount(String name){
|
{
|
||||||
Account Account=null;
|
Account Account = null;
|
||||||
Account=new Account(name);
|
Account = new Account(name);
|
||||||
hasAccount(name);
|
hasAccount(name);
|
||||||
return Account;
|
return Account;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fake remove account
|
//Fake remove account
|
||||||
|
public void removeAccount(String name)
|
||||||
public void removeAccount(String name){
|
{
|
||||||
if (!existCheck.exist(name)){
|
if (!existCheck.exist(name))
|
||||||
if (EcoAPI.accountExist(name)){
|
{
|
||||||
EcoAPI.removeAccount(name);
|
if (Economy.accountExist(name))
|
||||||
|
{
|
||||||
|
Economy.removeAccount(name);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EcoAPI.setMoney(name, 0);
|
Economy.setMoney(name, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
name: iConomy
|
name: iConomy
|
||||||
version: 4.65
|
version: 4.65
|
||||||
main: com.nijiko.coelho.iConomy.iConomy
|
main: com.nijiko.coelho.iConomy.iConomy
|
||||||
|
website: http://www.earth2me.net:8001/
|
||||||
|
description: "Essentials iConomy Bridge version: TeamCity"
|
||||||
|
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
|
||||||
|
Loading…
Reference in New Issue
Block a user