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