mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-02 13:31:54 +01:00
Working with ico 5.0 plugins. Not sure about banks . . no plugins to test it with . . . yet! Reverse compatability broken, ico decided to switch packages.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1327 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
897810fe41
commit
a46bc7448b
@ -1,12 +1,8 @@
|
||||
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!
|
||||
@ -14,42 +10,10 @@ import org.bukkit.plugin.PluginManager;
|
||||
* @author Xeology
|
||||
*/
|
||||
|
||||
public class iConomy extends JavaPlugin
|
||||
{
|
||||
public static Bank Bank = null;
|
||||
public class iConomy{
|
||||
public static Bank Bank = new Bank();
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
Plugin p = pm.getPlugin("Essentials");
|
||||
if (p != null)
|
||||
{
|
||||
if (!pm.isPluginEnabled(p))
|
||||
{
|
||||
pm.enablePlugin(p);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
Bank = new Bank();
|
||||
|
||||
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()
|
||||
{
|
||||
|
53
EssentialsiConomyBridge5/src/com/iConomy/banks.java
Normal file
53
EssentialsiConomyBridge5/src/com/iConomy/banks.java
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
package com.iConomy;
|
||||
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
|
||||
|
||||
|
||||
public class banks
|
||||
{
|
||||
|
||||
|
||||
public int count(String name){
|
||||
int count=0;
|
||||
int breaker = 0;
|
||||
for (int ctr = 1; breaker != 1; ctr++)
|
||||
{
|
||||
if (ctr == 1)
|
||||
{
|
||||
if (Economy.accountExist(name + "-bank"))
|
||||
{
|
||||
count = count + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
breaker = 1;
|
||||
}
|
||||
}
|
||||
if (Economy.accountExist(name + "-bank" + Integer.toString(ctr)) && ctr != 1)
|
||||
{
|
||||
count = count + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
breaker = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
27
EssentialsiConomyBridge5/src/com/iConomy/existCheck.java
Normal file
27
EssentialsiConomyBridge5/src/com/iConomy/existCheck.java
Normal file
@ -0,0 +1,27 @@
|
||||
package com.iConomy;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
double amount=12;
|
||||
return false;
|
||||
}
|
||||
}
|
96
EssentialsiConomyBridge5/src/com/iConomy/iConomy.java
Normal file
96
EssentialsiConomyBridge5/src/com/iConomy/iConomy.java
Normal file
@ -0,0 +1,96 @@
|
||||
package com.iConomy;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.iConomy.system.Account;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import com.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
|
||||
*/
|
||||
public class iConomy extends JavaPlugin
|
||||
{
|
||||
public static Bank Bank=null;
|
||||
public static boolean Banking = true;
|
||||
public static boolean BankingMultiple = true;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
Bank=new Bank("hello");
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
Plugin p = pm.getPlugin("Essentials");
|
||||
if (p != null)
|
||||
{
|
||||
if (!pm.isPluginEnabled(p))
|
||||
{
|
||||
pm.enablePlugin(p);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
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 String format(double amount)
|
||||
{
|
||||
return Economy.format(amount);
|
||||
}
|
||||
|
||||
public static String format(String account)
|
||||
{
|
||||
return getAccount(account).getHoldings().toString();
|
||||
}
|
||||
|
||||
public static String format(String bank, String account)
|
||||
{
|
||||
return (new Bank(bank)).getAccount(account).getHoldings().toString();
|
||||
}
|
||||
|
||||
public static Account getAccount(String name)
|
||||
{
|
||||
return Bank.getAccount(name);
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasAccount(String name)
|
||||
{
|
||||
if (!existCheck.exist(name))
|
||||
{
|
||||
if (!Economy.accountExist(name))
|
||||
{
|
||||
Economy.newAccount(name);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
107
EssentialsiConomyBridge5/src/com/iConomy/system/Account.java
Normal file
107
EssentialsiConomyBridge5/src/com/iConomy/system/Account.java
Normal file
@ -0,0 +1,107 @@
|
||||
package com.iConomy.system;
|
||||
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.iConomy.existCheck;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class Account
|
||||
{
|
||||
|
||||
private String name;
|
||||
|
||||
public Holdings getHoldings()
|
||||
{
|
||||
return new Holdings(name, this.name);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Essentials does not support hidden accounts.
|
||||
* @return false
|
||||
*/
|
||||
public boolean setHidden(boolean hidden)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//Simply set the account variable type?
|
||||
public Account(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ArrayList<Bank> withBanks()
|
||||
{
|
||||
ArrayList<Bank> banks = new ArrayList<Bank>();
|
||||
if (Economy.accountExist(name + "-bank"))
|
||||
{
|
||||
Bank bank = new Bank("EcoBanks");
|
||||
banks.add(bank);
|
||||
return banks;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<Bank> getBankAccounts()
|
||||
{
|
||||
ArrayList<Bank> banks = new ArrayList<Bank>();
|
||||
int breaker = 0;
|
||||
Bank bank;
|
||||
for (int ctr = 1; breaker != 1; ctr++)
|
||||
{
|
||||
if (ctr == 1)
|
||||
{
|
||||
if (Economy.accountExist(name + "-bank"))
|
||||
{
|
||||
bank = new Bank(name + "-bank");
|
||||
banks.add(bank);
|
||||
}
|
||||
else
|
||||
{
|
||||
breaker = 1;
|
||||
}
|
||||
}
|
||||
if (Economy.accountExist(name + "-bank" + Integer.toString(ctr)) && ctr != 1)
|
||||
{
|
||||
bank = new Bank(name + "-bank" + Integer.toString(ctr));
|
||||
banks.add(bank);
|
||||
}
|
||||
else
|
||||
{
|
||||
breaker = 1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Essentials does not support hidden accounts.
|
||||
* @return false
|
||||
*/
|
||||
public boolean isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public Bank getMainBank()
|
||||
{
|
||||
Bank bank = null;
|
||||
if (!Economy.accountExist(name + "-bank"))
|
||||
{
|
||||
Economy.newAccount(name + "-bank");
|
||||
bank = new Bank(name + "-bank");
|
||||
return bank;
|
||||
}
|
||||
bank = new Bank(name + "-bank");
|
||||
return bank;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
64
EssentialsiConomyBridge5/src/com/iConomy/system/Bank.java
Normal file
64
EssentialsiConomyBridge5/src/com/iConomy/system/Bank.java
Normal file
@ -0,0 +1,64 @@
|
||||
package com.iConomy.system;
|
||||
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.iConomy.existCheck;
|
||||
|
||||
|
||||
public class Bank
|
||||
{
|
||||
private String id = null;
|
||||
private String name = null;
|
||||
|
||||
public Bank(String name)
|
||||
{
|
||||
this.id = name;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
//Fake currency!
|
||||
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 (!Economy.accountExist(account))
|
||||
{
|
||||
Economy.newAccount(account);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//simply switches the name to an account type?
|
||||
public Account getAccount(String name)
|
||||
{
|
||||
return new Account(name);
|
||||
}
|
||||
|
||||
//Fake remove account
|
||||
public void removeAccount(String name)
|
||||
{
|
||||
if (!existCheck.exist(name))
|
||||
{
|
||||
if (Economy.accountExist(name))
|
||||
{
|
||||
Economy.removeAccount(name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Economy.setMoney(name, 0);
|
||||
}
|
||||
|
||||
public void createAccount(String account)
|
||||
{
|
||||
if (!Economy.accountExist(account))
|
||||
{
|
||||
Economy.newAccount(account);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.iConomy.system;
|
||||
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
|
||||
|
||||
public class BankAccount
|
||||
{
|
||||
private String BankName;
|
||||
private String BankId;
|
||||
private String AccountName;
|
||||
|
||||
public BankAccount(String BankName, String BankId, String AccountName)
|
||||
{
|
||||
this.BankName = BankName;
|
||||
this.BankId = BankId;
|
||||
this.AccountName = AccountName;
|
||||
}
|
||||
|
||||
public String getBankName()
|
||||
{
|
||||
return this.BankName;
|
||||
}
|
||||
|
||||
public String getBankId()
|
||||
{
|
||||
return this.BankId;
|
||||
}
|
||||
|
||||
public void getAccountName(String AccountName)
|
||||
{
|
||||
this.AccountName = AccountName;
|
||||
}
|
||||
|
||||
public Holdings getHoldings()
|
||||
{
|
||||
return new Holdings(this.BankId, this.AccountName, true);
|
||||
}
|
||||
|
||||
public void remove(String name)
|
||||
{
|
||||
if (Economy.accountExist(BankId))
|
||||
{
|
||||
Economy.removeAccount(BankId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
135
EssentialsiConomyBridge5/src/com/iConomy/system/Holdings.java
Normal file
135
EssentialsiConomyBridge5/src/com/iConomy/system/Holdings.java
Normal file
@ -0,0 +1,135 @@
|
||||
package com.iConomy.system;
|
||||
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.iConomy.existCheck;
|
||||
|
||||
|
||||
public class Holdings
|
||||
{
|
||||
private String name = "";
|
||||
private boolean bank = false;
|
||||
private String bankId = null;
|
||||
|
||||
public Holdings(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Holdings(String id, String name)
|
||||
{
|
||||
this.bankId = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Holdings(String id, String name, boolean bank)
|
||||
{
|
||||
this.bank = bank;
|
||||
this.bankId = id;
|
||||
this.name = name;
|
||||
}
|
||||
public boolean isBank() {
|
||||
return bank;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return get();
|
||||
}
|
||||
|
||||
public double get()
|
||||
{
|
||||
if (!existCheck.exist(name))
|
||||
{
|
||||
if (Economy.accountExist(name))
|
||||
{
|
||||
return Economy.getMoney(name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return Economy.getMoney(name);
|
||||
}
|
||||
|
||||
public void set(double bal)
|
||||
{
|
||||
if (!existCheck.exist(name))
|
||||
{
|
||||
if (Economy.accountExist(name))
|
||||
{
|
||||
Economy.setMoney(name, bal);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Economy.setMoney(name, bal);
|
||||
}
|
||||
|
||||
public void add(double money)
|
||||
{
|
||||
if (!existCheck.exist(name))
|
||||
{
|
||||
if (Economy.accountExist(name))
|
||||
{
|
||||
Economy.add(name, money);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Economy.add(name, money);
|
||||
}
|
||||
|
||||
public void divide(double money)
|
||||
{
|
||||
if (!existCheck.exist(name))
|
||||
{
|
||||
if (Economy.accountExist(name))
|
||||
{
|
||||
Economy.divide(name, money);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Economy.divide(name, money);
|
||||
}
|
||||
|
||||
public void multiply(double money)
|
||||
{
|
||||
if (!existCheck.exist(name))
|
||||
{
|
||||
if (Economy.accountExist(name))
|
||||
{
|
||||
Economy.multiply(name, money);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Economy.multiply(name, money);
|
||||
}
|
||||
|
||||
public void subtract(double money)
|
||||
{
|
||||
if (!existCheck.exist(name))
|
||||
{
|
||||
if (Economy.accountExist(name))
|
||||
{
|
||||
Economy.subtract(name, money);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Economy.subtract(name, money);
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
this.set(0);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return amount <= this.get();
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return amount < this.get();
|
||||
}
|
||||
|
||||
public boolean isNegative()
|
||||
{
|
||||
return this.get() < 0.0;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
name: iConomy
|
||||
version: 5.0
|
||||
main: com.nijiko.coelho.iConomy.iConomy
|
||||
main: com.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