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
This commit is contained in:
xeology 2011-05-02 09:56:40 +00:00
parent e327aee283
commit 9d961980e8
5 changed files with 263 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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()
{
}
;
}

View file

@ -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);
}
}

View file

@ -0,0 +1,3 @@
name: iConomy
version: 4.65
main: com.nijiko.coelho.iConomy.iConomy