[Version 0.6.10]
- Added Register support as opposed to iConomy
This commit is contained in:
parent
02f83cb19b
commit
13e4d9a6b2
2
README
2
README
@ -191,6 +191,8 @@ createConflict=Gate conflicts with existing gate
|
||||
=============
|
||||
Changes
|
||||
=============
|
||||
[Version 0.6.10]
|
||||
- Added Register support as opposed to iConomy
|
||||
[Version 0.6.9]
|
||||
- Added UTF8 support for lang files (With or without BOM)
|
||||
[Version 0.6.8]
|
||||
|
@ -47,8 +47,6 @@ import org.bukkit.util.config.Configuration;
|
||||
|
||||
// Permissions
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
// iConomy
|
||||
import com.iConomy.*;
|
||||
|
||||
/**
|
||||
* Stargate.java - A customizeable portal plugin for Bukkit
|
||||
@ -121,8 +119,9 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
// Check to see if iConomy/Permissions is loaded yet.
|
||||
permissions = (Permissions)checkPlugin("Permissions");
|
||||
if (iConomyHandler.useiConomy)
|
||||
iConomyHandler.iconomy = (iConomy)checkPlugin("iConomy");
|
||||
if (iConomyHandler.setupiConomy(pm)) {
|
||||
log.info("[Stargate] Register v" + iConomyHandler.register.getDescription().getVersion() + " found");
|
||||
}
|
||||
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
|
||||
@ -998,10 +997,8 @@ public class Stargate extends JavaPlugin {
|
||||
private class sListener extends ServerListener {
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (iConomyHandler.useiConomy && iConomyHandler.iconomy == null) {
|
||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("iConomy")) {
|
||||
iConomyHandler.iconomy = (iConomy)checkPlugin(event.getPlugin());
|
||||
}
|
||||
if (iConomyHandler.setupiConomy(event.getPlugin())) {
|
||||
log.info("[Stargate] Register v" + iConomyHandler.register.getDescription().getVersion() + " found");
|
||||
}
|
||||
if (permissions == null) {
|
||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("Permissions")) {
|
||||
@ -1012,9 +1009,8 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (iConomyHandler.useiConomy && event.getPlugin() == iConomyHandler.iconomy) {
|
||||
log.info("[Stargate] iConomy plugin lost.");
|
||||
iConomyHandler.iconomy = null;
|
||||
if (iConomyHandler.checkLost(event.getPlugin())) {
|
||||
log.info("[Stargate] Register plugin lost.");
|
||||
}
|
||||
if (event.getPlugin() == permissions) {
|
||||
log.info("[Stargate] Permissions plugin lost.");
|
||||
|
@ -1,8 +1,12 @@
|
||||
package net.TheDgtl.Stargate;
|
||||
|
||||
import com.iConomy.*;
|
||||
import com.iConomy.system.Account;
|
||||
import com.iConomy.system.Holdings;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.nijikokun.register.Register;
|
||||
import com.nijikokun.register.payment.Method;
|
||||
import com.nijikokun.register.payment.Method.MethodAccount;
|
||||
import com.nijikokun.register.payment.Methods;
|
||||
|
||||
/**
|
||||
* iConomyHandler.java
|
||||
@ -12,7 +16,7 @@ import com.iConomy.system.Holdings;
|
||||
public class iConomyHandler {
|
||||
public static String pName = "Stargate";
|
||||
public static boolean useiConomy = false;
|
||||
public static iConomy iconomy = null;
|
||||
public static Register register = null;
|
||||
|
||||
public static int useCost = 0;
|
||||
public static int createCost = 0;
|
||||
@ -22,37 +26,45 @@ public class iConomyHandler {
|
||||
public static boolean freeGatesGreen = false;
|
||||
|
||||
public static double getBalance(String player) {
|
||||
if (useiConomy && iconomy != null) {
|
||||
Account acc = iConomy.getAccount(player);
|
||||
if (acc == null) {
|
||||
Stargate.debug("ich::getBalance", "Error fetching iConomy account for " + player);
|
||||
if (useiConomy && register != null) {
|
||||
Method method = Methods.getMethod();
|
||||
if (method == null) {
|
||||
return 0;
|
||||
}
|
||||
return acc.getHoldings().balance();
|
||||
|
||||
MethodAccount acc = method.getAccount(player);
|
||||
if (acc == null) {
|
||||
Stargate.debug("ich::getBalance", "Error fetching Register account for " + player);
|
||||
return 0;
|
||||
}
|
||||
return acc.balance();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean chargePlayer(String player, String target, double amount) {
|
||||
if (useiConomy && iconomy != null) {
|
||||
if (useiConomy && register != null) {
|
||||
// Check for a payment method
|
||||
Method method = Methods.getMethod();
|
||||
if (method == null) {
|
||||
return true;
|
||||
}
|
||||
// No point going from a player to themself
|
||||
if (player.equals(target)) return true;
|
||||
|
||||
Account acc = iConomy.getAccount(player);
|
||||
MethodAccount acc = method.getAccount(player);
|
||||
if (acc == null) {
|
||||
Stargate.debug("ich::chargePlayer", "Error fetching iConomy account for " + player);
|
||||
Stargate.debug("ich::chargePlayer", "Error fetching Register account for " + player);
|
||||
return false;
|
||||
}
|
||||
Holdings hold = acc.getHoldings();
|
||||
|
||||
if (!hold.hasEnough(amount)) return false;
|
||||
hold.subtract(amount);
|
||||
if (!acc.hasEnough(amount)) return false;
|
||||
acc.subtract(amount);
|
||||
|
||||
if (target != null) {
|
||||
Account tAcc = iConomy.getAccount(target);
|
||||
MethodAccount tAcc = method.getAccount(target);
|
||||
if (tAcc != null) {
|
||||
Holdings tHold = tAcc.getHoldings();
|
||||
tHold.add(amount);
|
||||
tAcc.add(amount);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -61,10 +73,36 @@ public class iConomyHandler {
|
||||
}
|
||||
|
||||
public static boolean useiConomy() {
|
||||
return (useiConomy && iconomy != null);
|
||||
return (useiConomy && register != null && Methods.getMethod() != null);
|
||||
}
|
||||
|
||||
public static String format(int amt) {
|
||||
return iConomy.format(amt);
|
||||
Method method = Methods.getMethod();
|
||||
if (method == null) {
|
||||
return Integer.toString(amt);
|
||||
}
|
||||
return method.format(amt);
|
||||
}
|
||||
|
||||
public static boolean setupiConomy(PluginManager pm) {
|
||||
if (!useiConomy) return false;
|
||||
Plugin p = pm.getPlugin("Register");
|
||||
return setupiConomy(p);
|
||||
}
|
||||
|
||||
public static boolean setupiConomy(Plugin p) {
|
||||
if (!useiConomy) return false;
|
||||
if (p == null || !p.isEnabled()) return false;
|
||||
if (!p.getDescription().getName().equals("Register")) return false;
|
||||
register = (Register)p;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean checkLost(Plugin p) {
|
||||
if (p.equals(register)) {
|
||||
register = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: Stargate
|
||||
main: net.TheDgtl.Stargate.Stargate
|
||||
version: 0.6.9
|
||||
version: 0.6.10
|
||||
description: Stargate mod for Bukkit
|
||||
author: Drakia
|
||||
website: http://www.thedgtl.net
|
||||
|
Loading…
Reference in New Issue
Block a user