1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-24 21:31:32 +02: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:
snowleo
2011-05-02 18:22:17 +00:00
parent 2af13fd062
commit 79c0ef69c4
20 changed files with 347 additions and 317 deletions

View File

@@ -1,78 +1,78 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=EssentialsiConomyBridge
application.vendor=schlex
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}/EssentialsiConomyBridge.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.bukkit-0.0.1-SNAPSHOT.jar=..\\lib\\bukkit-0.0.1-SNAPSHOT.jar
file.reference.Essentials.jar=..\\Essentials\\dist\\Essentials.jar
file.reference.Essentials.jar=..\\lib\\bukkit-0.0.1-SNAPSHOT.jar
includes=**
jar.compress=false
javac.classpath=\
${reference.Essentials.jar}:\
${file.reference.bukkit-0.0.1-SNAPSHOT.jar}
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
project.Essentials=../Essentials
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
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
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=EssentialsiConomyBridge
application.vendor=schlex
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}/EssentialsiConomyBridge.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.bukkit-0.0.1-SNAPSHOT.jar=..\\lib\\bukkit-0.0.1-SNAPSHOT.jar
file.reference.Essentials.jar=..\\Essentials\\dist\\Essentials.jar
file.reference.Essentials.jar=..\\lib\\bukkit-0.0.1-SNAPSHOT.jar
includes=**
jar.compress=false
javac.classpath=\
${reference.Essentials.jar}:\
${file.reference.bukkit-0.0.1-SNAPSHOT.jar}
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
project.Essentials=../Essentials
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
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

View File

@@ -1,19 +1,25 @@
package com.nijiko.coelho.iConomy;
import java.util.logging.Logger;
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!
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!");
public static boolean exist(String name)
{
if (name == null)
{
logger.info("Essentials iConomy Bridge - Whatever plugin is calling for users that are null is BROKEN!");
return false;
}
if (Bukkit.getServer().getPlayer(name)!=null){
return true;
}
if (Bukkit.getServer().getPlayer(name) != null)
{
return true;
}
return false;
}
}

View File

@@ -1,39 +1,58 @@
package com.nijiko.coelho.iConomy;
import com.earth2me.essentials.Essentials;
import org.bukkit.plugin.java.JavaPlugin;
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!
//@author Xeology
/**
* 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;
private static final Logger logger = Logger.getLogger("Minecraft");
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 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
public void onEnable() {
Bank=new Bank();
String version = this.getDescription().getDescription().replaceAll(".*: ", "");
if (!version.equals(Essentials.getStatic().getDescription().getVersion()))
{
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
public static Bank getBank() {
return Bank;
}
public static Bank getBank()
{
return Bank;
}
}

View File

@@ -1,6 +1,6 @@
package com.nijiko.coelho.iConomy.system;
import com.earth2me.essentials.EcoAPI;
import com.earth2me.essentials.api.Economy;
import com.nijiko.coelho.iConomy.existCheck;
@@ -8,13 +8,15 @@ public class Account
{
private String name;
//Fake getname
public String getName()
{
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)
{
return true;
@@ -26,122 +28,118 @@ public class Account
this.name = name;
}
//Fake return balance
public double getBalance()
{
if (!existCheck.exist(name))
{
if (EcoAPI.accountExist(name))
if (Economy.accountExist(name))
{
return EcoAPI.getMoney(name);
return Economy.getMoney(name);
}
return 0;
}
return EcoAPI.getMoney(name);
return Economy.getMoney(name);
}
//Fake Set balance
public void setBalance(double bal)
{
if (!existCheck.exist(name))
{
if (EcoAPI.accountExist(name))
if (Economy.accountExist(name))
{
EcoAPI.setMoney(name, bal);
Economy.setMoney(name, bal);
}
return;
}
EcoAPI.setMoney(name, bal);
Economy.setMoney(name, bal);
}
//Fake add balance
public void add(double money)
{
if (!existCheck.exist(name))
{
if (EcoAPI.accountExist(name))
if (Economy.accountExist(name))
{
EcoAPI.add(name, money);
Economy.add(name, money);
}
return;
}
EcoAPI.add(name, money);
Economy.add(name, money);
}
//Fake divide balance
public void divide(double money)
{
if (!existCheck.exist(name))
{
if (EcoAPI.accountExist(name))
if (Economy.accountExist(name))
{
EcoAPI.divide(name, money);
Economy.divide(name, money);
}
return;
}
EcoAPI.divide(name, money);
Economy.divide(name, money);
}
//Fake multiply balance
public void multiply(double money)
{
if (!existCheck.exist(name))
{
if (EcoAPI.accountExist(name))
if (Economy.accountExist(name))
{
EcoAPI.multiply(name, money);
Economy.multiply(name, money);
}
return;
}
EcoAPI.multiply(name, money);
Economy.multiply(name, money);
}
//Fake subtract balance
public void subtract(double money)
{
if (!existCheck.exist(name))
{
if (EcoAPI.accountExist(name))
if (Economy.accountExist(name))
{
EcoAPI.subtract(name, money);
Economy.subtract(name, money);
}
return;
}
EcoAPI.subtract(name, money);
Economy.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!
/**
* Essentials does not support hidden accounts.
* @return false
*/
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
/**
* Because some plugins like to use depricated methods I must save
* admins' log from the overflow of dumb
*/
@Deprecated
public void save()
{
}

View File

@@ -1,53 +1,56 @@
package com.nijiko.coelho.iConomy.system;
import com.earth2me.essentials.EcoAPI;
import com.earth2me.essentials.api.Economy;
import com.nijiko.coelho.iConomy.existCheck;
public class Bank {
//The fake formatter
public String format(double amount) {
return EcoAPI.format(amount);
}
public class Bank
{
//The fake formatter
public String format(double amount)
{
return Economy.format(amount);
}
//Fake currency!
public String getCurrency() {
return EcoAPI.getCurrency();
}
public String getCurrency()
{
return Economy.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);
}
public boolean hasAccount(String account)
{
if (!existCheck.exist(account))
{
if (!Economy.accountExist(account))
{
Economy.newAccount(account);
}
}
return true;
}
//simply switches the name to an account type?
public Account getAccount(String name){
Account Account=null;
Account=new Account(name);
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);
public void removeAccount(String name)
{
if (!existCheck.exist(name))
{
if (Economy.accountExist(name))
{
Economy.removeAccount(name);
}
return;
}
EcoAPI.setMoney(name, 0);
Economy.setMoney(name, 0);
}
}

View File

@@ -1,3 +1,6 @@
name: iConomy
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]