mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-20 05:21:21 +02:00
Merge branch 'essmaster' into essrelease
This commit is contained in:
@@ -307,6 +307,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Disconnecting user " + event.getPlayer().toString() + " due to " + event.getResult().toString());
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
@@ -316,11 +317,12 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
user.checkBanTimeout(currentTime);
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
|
||||
if (user.isBanned())
|
||||
|
||||
if (user.isBanned() || event.getResult() == Result.KICK_BANNED)
|
||||
{
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
|
||||
LOGGER.log(Level.INFO, "Banned for '" + banReason + "'");
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : Util.i18n("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -21,10 +21,9 @@ public class EssentialsPluginListener extends ServerListener implements IConf
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(event.getPlugin()))
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +34,7 @@ public class EssentialsPluginListener extends ServerListener implements IConf
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
|
||||
{
|
||||
ess.getPaymentMethod().reset();
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
@@ -154,6 +154,8 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
{
|
||||
//Invalid names will corrupt the yaml
|
||||
name = Util.sanitizeFileName(name);
|
||||
homes.put(name, loc);
|
||||
config.setProperty("homes." + name, loc);
|
||||
config.save();
|
||||
|
@@ -45,18 +45,18 @@ public class Commandhome extends EssentialsCommand
|
||||
catch (NotEnoughArgumentsException e)
|
||||
{
|
||||
List<String> homes = u.getHomes();
|
||||
if (homes.isEmpty())
|
||||
if (homes.isEmpty() && u.equals(user) && ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
user.getTeleport().respawn(ess.getSpawn(), charge);
|
||||
}
|
||||
else if (homes.isEmpty())
|
||||
{
|
||||
throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
|
||||
}
|
||||
else if ((homes.size() == 1) && u == user)
|
||||
else if (homes.size() == 1 && u.equals(user))
|
||||
{
|
||||
user.getTeleport().home(u, homes.get(0), charge);
|
||||
}
|
||||
else if (ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
user.getTeleport().respawn(ess.getSpawn(), charge);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("homes", Util.joinList(homes)));
|
||||
|
@@ -49,5 +49,6 @@ public class Commandinvsee extends EssentialsCommand
|
||||
user.getInventory().setContents(invUserStack);
|
||||
user.sendMessage(Util.format("invSee", invUser.getDisplayName()));
|
||||
user.sendMessage(Util.i18n("invSeeHelp"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@@ -64,6 +64,6 @@ public class Commandmail extends EssentialsCommand
|
||||
user.setMails(null);
|
||||
throw new Exception(Util.i18n("mailCleared"));
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -97,29 +96,31 @@ public class Commandptime extends EssentialsCommand
|
||||
*/
|
||||
private void getUsersTime(final CommandSender sender, final Collection<User> users)
|
||||
{
|
||||
if (users.size() > 1)
|
||||
if (users.size() > 1)
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimePlayers"));
|
||||
}
|
||||
|
||||
for (User user : users)
|
||||
|
||||
for (User user : users)
|
||||
{
|
||||
if(user.getPlayerTimeOffset() == 0)
|
||||
if (user.getPlayerTimeOffset() == 0)
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeNormal", user.getName()));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
String time = DescParseTickFormat.format(user.getPlayerTime());
|
||||
if(!user.isPlayerTimeRelative())
|
||||
if (!user.isPlayerTimeRelative())
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeCurrentFixed", user.getName(), time));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeCurrent", user.getName(), time));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,7 +178,8 @@ public class Commandptime extends EssentialsCommand
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeSetFixed", time, msg.toString()));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeSet", time, msg.toString()));
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ public class Commandtime extends EssentialsCommand
|
||||
{
|
||||
worldSelector = args[1];
|
||||
}
|
||||
Set<World> worlds = getWorlds(server, sender, worldSelector);
|
||||
final Set<World> worlds = getWorlds(server, sender, worldSelector);
|
||||
|
||||
// If no arguments we are reading the time
|
||||
if (args.length == 0)
|
||||
@@ -34,7 +34,7 @@ public class Commandtime extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
|
||||
User user = ess.getUser(sender);
|
||||
final User user = ess.getUser(sender);
|
||||
if (user != null && !user.isAuthorized("essentials.time.set"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("timeSetPermission"));
|
||||
|
@@ -21,11 +21,9 @@ public class Commandunban extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
String name;
|
||||
try
|
||||
{
|
||||
User u = getPlayer(server, args, 0, true);
|
||||
name = u.getName();
|
||||
final User u = getPlayer(server, args, 0, true);
|
||||
u.setBanned(false);
|
||||
sender.sendMessage(Util.i18n("unbannedPlayer"));
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* Method.java
|
||||
* Interface to be implemented by a payment method.
|
||||
*
|
||||
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
|
||||
* @copyright Copyright (C) 2011
|
||||
@@ -41,6 +41,14 @@ public interface Method
|
||||
*/
|
||||
public String getVersion();
|
||||
|
||||
/**
|
||||
* Returns the amount of decimal places that get stored
|
||||
* NOTE: it will return -1 if there is no rounding
|
||||
*
|
||||
* @return <code>int</code> for each decimal place
|
||||
*/
|
||||
public int fractionalDigits();
|
||||
|
||||
/**
|
||||
* Formats amounts into this payment methods style of currency display.
|
||||
*
|
||||
|
@@ -5,9 +5,6 @@ import java.util.Set;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>Methods</code> initializes Methods that utilize the Method interface
|
||||
@@ -15,15 +12,13 @@ import java.util.Set;
|
||||
*
|
||||
* Allowing you to check whether a payment method exists or not.
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* Methods methods = new Methods();
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* Methods also allows you to set a preferred method of payment before it captures
|
||||
* payment plugins in the initialization process.
|
||||
*
|
||||
* in <code>bukkit.yml</code>:
|
||||
* <blockquote><pre>
|
||||
* Methods methods = new Methods("iConomy");
|
||||
* economy:
|
||||
* preferred: "iConomy"
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun)
|
||||
@@ -32,51 +27,62 @@ import java.util.Set;
|
||||
*/
|
||||
public class Methods
|
||||
{
|
||||
private boolean self = false;
|
||||
private Method Method = null;
|
||||
private String preferred = "";
|
||||
private Set<Method> Methods = new HashSet<Method>();
|
||||
private Set<String> Dependencies = new HashSet<String>();
|
||||
private Set<Method> Attachables = new HashSet<Method>();
|
||||
private static String version = null;
|
||||
private static boolean self = false;
|
||||
private static Method Method = null;
|
||||
private static String preferred = "";
|
||||
private static Set<Method> Methods = new HashSet<Method>();
|
||||
private static Set<String> Dependencies = new HashSet<String>();
|
||||
private static Set<Method> Attachables = new HashSet<Method>();
|
||||
|
||||
/**
|
||||
* Initialize Method class
|
||||
*/
|
||||
public Methods()
|
||||
static
|
||||
{
|
||||
this._init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes <code>Methods</code> class utilizing a "preferred" payment method check before
|
||||
* returning the first method that was initialized.
|
||||
*
|
||||
* @param preferred Payment method that is most preferred for this setup.
|
||||
*/
|
||||
public Methods(String preferred)
|
||||
{
|
||||
this._init();
|
||||
|
||||
if (this.Dependencies.contains(preferred))
|
||||
{
|
||||
this.preferred = preferred;
|
||||
}
|
||||
_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement all methods along with their respective name & class.
|
||||
*
|
||||
* @see #Methods()
|
||||
* @see #Methods(java.lang.String)
|
||||
*/
|
||||
private void _init()
|
||||
private static void _init()
|
||||
{
|
||||
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
|
||||
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
|
||||
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo6());
|
||||
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
|
||||
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
|
||||
this.addMethod("MultiCurrency", new com.earth2me.essentials.register.payment.methods.MCUR());
|
||||
addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo6());
|
||||
addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
|
||||
addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
|
||||
addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
|
||||
addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
|
||||
addMethod("Currency", new com.earth2me.essentials.register.payment.methods.MCUR());
|
||||
Dependencies.add("MultiCurrency");
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the plugin to setup version
|
||||
*
|
||||
* @param v version
|
||||
*/
|
||||
public static void setVersion(String v)
|
||||
{
|
||||
version = v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to reset methods during disable
|
||||
*/
|
||||
public static void reset()
|
||||
{
|
||||
version = null;
|
||||
self = false;
|
||||
Method = null;
|
||||
preferred = "";
|
||||
Attachables.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to get version of Register plugin
|
||||
* @return version
|
||||
*/
|
||||
public static String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +92,7 @@ public class Methods
|
||||
* @return <code>Set<String></code> - Array of payment methods that are loaded.
|
||||
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||
*/
|
||||
public Set<String> getDependencies()
|
||||
public static Set<String> getDependencies()
|
||||
{
|
||||
return Dependencies;
|
||||
}
|
||||
@@ -98,7 +104,7 @@ public class Methods
|
||||
* @param plugin Plugin data from bukkit, Internal Class file.
|
||||
* @return Method <em>or</em> Null
|
||||
*/
|
||||
public Method createMethod(Plugin plugin)
|
||||
public static Method createMethod(Plugin plugin)
|
||||
{
|
||||
for (Method method : Methods)
|
||||
{
|
||||
@@ -112,7 +118,7 @@ public class Methods
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addMethod(String name, Method method)
|
||||
private static void addMethod(String name, Method method)
|
||||
{
|
||||
Dependencies.add(name);
|
||||
Methods.add(method);
|
||||
@@ -125,7 +131,7 @@ public class Methods
|
||||
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||
* @see #checkDisabled(org.bukkit.plugin.Plugin)
|
||||
*/
|
||||
public boolean hasMethod()
|
||||
public static boolean hasMethod()
|
||||
{
|
||||
return (Method != null);
|
||||
}
|
||||
@@ -134,15 +140,16 @@ public class Methods
|
||||
* Checks Plugin Class against a multitude of checks to verify it's usability
|
||||
* as a payment method.
|
||||
*
|
||||
* @param method Plugin data from bukkit, Internal Class file.
|
||||
* @param <code>PluginManager</code> the plugin manager for the server
|
||||
* @return <code>boolean</code> True on success, False on failure.
|
||||
*/
|
||||
public boolean setMethod(Plugin method)
|
||||
public static boolean setMethod(PluginManager manager)
|
||||
{
|
||||
if (hasMethod())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (self)
|
||||
{
|
||||
self = false;
|
||||
@@ -152,44 +159,37 @@ public class Methods
|
||||
int count = 0;
|
||||
boolean match = false;
|
||||
Plugin plugin = null;
|
||||
PluginManager manager = method.getServer().getPluginManager();
|
||||
|
||||
for (String name : this.getDependencies())
|
||||
for (String name : getDependencies())
|
||||
{
|
||||
if (hasMethod())
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (method.getDescription().getName().equals(name))
|
||||
{
|
||||
plugin = method;
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin = manager.getPlugin(name);
|
||||
}
|
||||
|
||||
plugin = manager.getPlugin(name);
|
||||
if (plugin == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Method current = this.createMethod(plugin);
|
||||
Method current = createMethod(plugin);
|
||||
if (current == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.preferred.isEmpty())
|
||||
if (preferred.isEmpty())
|
||||
{
|
||||
this.Method = current;
|
||||
Method = current;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Attachables.add(current);
|
||||
Attachables.add(current);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.preferred.isEmpty())
|
||||
if (!preferred.isEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
@@ -199,7 +199,7 @@ public class Methods
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Method attached : this.Attachables)
|
||||
for (Method attached : Attachables)
|
||||
{
|
||||
if (attached == null)
|
||||
{
|
||||
@@ -212,21 +212,21 @@ public class Methods
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.preferred.isEmpty())
|
||||
if (preferred.isEmpty())
|
||||
{
|
||||
this.Method = attached;
|
||||
Method = attached;
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (this.preferred.equalsIgnoreCase(attached.getName()))
|
||||
if (preferred.equalsIgnoreCase(attached.getName()))
|
||||
{
|
||||
this.Method = attached;
|
||||
Method = attached;
|
||||
}
|
||||
else
|
||||
{
|
||||
Method = attached;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Method = attached;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,12 +239,28 @@ public class Methods
|
||||
return hasMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preferred economy
|
||||
*
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
public static boolean setPreferred(String check)
|
||||
{
|
||||
if (getDependencies().contains(check))
|
||||
{
|
||||
preferred = check;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab the existing and initialized (hopefully) Method Class.
|
||||
*
|
||||
* @return <code>Method</code> <em>or</em> <code>Null</code>
|
||||
*/
|
||||
public Method getMethod()
|
||||
public static Method getMethod()
|
||||
{
|
||||
return Method;
|
||||
}
|
||||
@@ -256,16 +272,18 @@ public class Methods
|
||||
* @param method Plugin data from bukkit, Internal Class file.
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
public boolean checkDisabled(Plugin method)
|
||||
public static boolean checkDisabled(Plugin method)
|
||||
{
|
||||
if (!hasMethod())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Method.isCompatible(method))
|
||||
{
|
||||
Method = null;
|
||||
}
|
||||
|
||||
return (Method == null);
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* BOSEconomy 6 Implementation of Method
|
||||
*
|
||||
@@ -11,191 +13,256 @@ import org.bukkit.plugin.Plugin;
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class BOSE6 implements Method {
|
||||
private BOSEconomy BOSEconomy;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BOSE6 implements Method
|
||||
{
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEconomy getPlugin() {
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
public BOSEconomy getPlugin()
|
||||
{
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "BOSEconomy";
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return "BOSEconomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.6.2";
|
||||
}
|
||||
public String getVersion()
|
||||
{
|
||||
return "0.6.2";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
|
||||
return amount + " " + currency;
|
||||
}
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return true;
|
||||
}
|
||||
public String format(double amount)
|
||||
{
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
if (amount == 1)
|
||||
{
|
||||
currency = this.BOSEconomy.getMoneyName();
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
return amount + " " + currency;
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
public boolean hasBanks()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if(!hasAccount(name)) return null;
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
if(!hasBankAccount(bank, name)) return null;
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return this.BOSEconomy.isBankOwner(bank, name)
|
||||
|| this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
if (!hasAccount(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public class BOSEAccount implements MethodAccount {
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
if (!hasBankAccount(bank, name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return (double) this.BOSEconomy.getPlayerMoney(this.name);
|
||||
}
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
||||
&& plugin instanceof BOSEconomy
|
||||
&& plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
public void setPlugin(Plugin plugin)
|
||||
{
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
|
||||
}
|
||||
public class BOSEAccount implements MethodAccount
|
||||
{
|
||||
private final String name;
|
||||
private final BOSEconomy BOSEconomy;
|
||||
|
||||
public boolean divide(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
|
||||
}
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy)
|
||||
{
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return (double)this.BOSEconomy.getPlayerMoney(this.name);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
public boolean set(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
public boolean add(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
|
||||
}
|
||||
|
||||
public class BOSEBankAccount implements MethodBankAccount {
|
||||
private final String bank;
|
||||
private final BOSEconomy BOSEconomy;
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
|
||||
}
|
||||
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.bank;
|
||||
}
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return -1;
|
||||
}
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return (double) this.BOSEconomy.getBankMoney(bank);
|
||||
}
|
||||
public boolean isNegative()
|
||||
{
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
|
||||
}
|
||||
public boolean remove()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false);
|
||||
}
|
||||
public class BOSEBankAccount implements MethodBankAccount
|
||||
{
|
||||
private final String bank;
|
||||
private final BOSEconomy BOSEconomy;
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
|
||||
}
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy)
|
||||
{
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
|
||||
}
|
||||
public String getBankName()
|
||||
{
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
public int getBankId()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return (double)this.BOSEconomy.getBankMoney(bank);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
public boolean set(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
public boolean add(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return this.BOSEconomy.removeBank(bank);
|
||||
}
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative()
|
||||
{
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove()
|
||||
{
|
||||
return this.BOSEconomy.removeBank(bank);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,11 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* BOSEconomy 7 Implementation of Method
|
||||
*
|
||||
@@ -12,182 +14,244 @@ import org.bukkit.plugin.Plugin;
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class BOSE7 implements Method
|
||||
{
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public class BOSE7 implements Method {
|
||||
private BOSEconomy BOSEconomy;
|
||||
public BOSEconomy getPlugin()
|
||||
{
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
|
||||
public BOSEconomy getPlugin() {
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return "BOSEconomy";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "BOSEconomy";
|
||||
}
|
||||
public String getVersion()
|
||||
{
|
||||
return "0.7.0";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.7.0";
|
||||
}
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return this.BOSEconomy.getFractionalDigits();
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
|
||||
return amount + " " + currency;
|
||||
}
|
||||
public String format(double amount)
|
||||
{
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
|
||||
public boolean hasBanks() {
|
||||
return true;
|
||||
}
|
||||
if (amount == 1)
|
||||
{
|
||||
currency = this.BOSEconomy.getMoneyName();
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
return amount + " " + currency;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
public boolean hasBanks()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if(!hasAccount(name)) return null;
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
if(!hasBankAccount(bank, name)) return null;
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && !plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
if (!hasAccount(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
|
||||
public class BOSEAccount implements MethodAccount {
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
if (!hasBankAccount(bank, name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.BOSEconomy.getPlayerMoneyDouble(this.name);
|
||||
}
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
||||
&& plugin instanceof BOSEconomy
|
||||
&& !plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
public void setPlugin(Plugin plugin)
|
||||
{
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
|
||||
}
|
||||
public class BOSEAccount implements MethodAccount
|
||||
{
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
|
||||
}
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy)
|
||||
{
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return this.BOSEconomy.getPlayerMoneyDouble(this.name);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
public boolean set(double amount)
|
||||
{
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
public boolean add(double amount)
|
||||
{
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
|
||||
}
|
||||
|
||||
public class BOSEBankAccount implements MethodBankAccount {
|
||||
private String bank;
|
||||
private BOSEconomy BOSEconomy;
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.bank;
|
||||
}
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return -1;
|
||||
}
|
||||
public boolean isNegative()
|
||||
{
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.BOSEconomy.getBankMoneyDouble(bank);
|
||||
}
|
||||
public boolean remove()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
return this.BOSEconomy.setBankMoney(bank, amount, true);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false);
|
||||
}
|
||||
public class BOSEBankAccount implements MethodBankAccount
|
||||
{
|
||||
private String bank;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false);
|
||||
}
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy)
|
||||
{
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance * amount), false);
|
||||
}
|
||||
public String getBankName()
|
||||
{
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance / amount), false);
|
||||
}
|
||||
public int getBankId()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return this.BOSEconomy.getBankMoneyDouble(bank);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
public boolean set(double amount)
|
||||
{
|
||||
return this.BOSEconomy.setBankMoney(bank, amount, true);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
public boolean add(double amount)
|
||||
{
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return this.BOSEconomy.removeBank(bank);
|
||||
}
|
||||
}
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance * amount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance / amount), false);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative()
|
||||
{
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove()
|
||||
{
|
||||
return this.BOSEconomy.removeBank(bank);
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,6 +7,7 @@ import me.ashtheking.currency.CurrencyList;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* MultiCurrency Method implementation.
|
||||
*
|
||||
@@ -14,107 +15,141 @@ import org.bukkit.plugin.Plugin;
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class MCUR implements Method {
|
||||
private Currency currencyList;
|
||||
public class MCUR implements Method
|
||||
{
|
||||
private Currency currencyList;
|
||||
|
||||
public Object getPlugin() {
|
||||
return this.currencyList;
|
||||
}
|
||||
public Object getPlugin()
|
||||
{
|
||||
return this.currencyList;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "MultiCurrency";
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return "MultiCurrency";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.09";
|
||||
}
|
||||
public String getVersion()
|
||||
{
|
||||
return "0.09";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return amount + " Currency";
|
||||
}
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
public String format(double amount)
|
||||
{
|
||||
return amount + " Currency";
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasBanks()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return true;
|
||||
}
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new MCurrencyAccount(name);
|
||||
}
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new MCurrencyAccount(name);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase(getName()) && plugin instanceof Currency;
|
||||
}
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
currencyList = (Currency) plugin;
|
||||
}
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
|
||||
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
|
||||
&& plugin instanceof Currency;
|
||||
}
|
||||
|
||||
public class MCurrencyAccount implements MethodAccount{
|
||||
private String name;
|
||||
public void setPlugin(Plugin plugin)
|
||||
{
|
||||
currencyList = (Currency)plugin;
|
||||
}
|
||||
|
||||
public MCurrencyAccount(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return CurrencyList.getValue((String) CurrencyList.maxCurrency(name)[0], name);
|
||||
}
|
||||
public class MCurrencyAccount implements MethodAccount
|
||||
{
|
||||
private String name;
|
||||
|
||||
public boolean set(double amount) {
|
||||
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, amount);
|
||||
return true;
|
||||
}
|
||||
public MCurrencyAccount(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
return CurrencyList.add(name, amount);
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return CurrencyList.getValue((String)CurrencyList.maxCurrency(name)[0], name);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
return CurrencyList.subtract(name, amount);
|
||||
}
|
||||
public boolean set(double amount)
|
||||
{
|
||||
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
return CurrencyList.multiply(name, amount);
|
||||
}
|
||||
public boolean add(double amount)
|
||||
{
|
||||
return CurrencyList.add(name, amount);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
return CurrencyList.divide(name, amount);
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
return CurrencyList.subtract(name, amount);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return CurrencyList.hasEnough(name, amount);
|
||||
}
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
return CurrencyList.multiply(name, amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return CurrencyList.hasOver(name, amount);
|
||||
}
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
return CurrencyList.divide(name, amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return CurrencyList.hasUnder(name, amount);
|
||||
}
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return CurrencyList.hasEnough(name, amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return CurrencyList.isNegative(name);
|
||||
}
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return CurrencyList.hasOver(name, amount);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return CurrencyList.remove(name);
|
||||
}
|
||||
}
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return CurrencyList.hasUnder(name, amount);
|
||||
}
|
||||
|
||||
public boolean isNegative()
|
||||
{
|
||||
return CurrencyList.isNegative(name);
|
||||
}
|
||||
|
||||
public boolean remove()
|
||||
{
|
||||
return CurrencyList.remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,13 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.nijiko.coelho.iConomy.system.Account;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* iConomy 4 Implementation of Method
|
||||
*
|
||||
@@ -14,122 +15,175 @@ import org.bukkit.plugin.Plugin;
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class iCo4 implements Method {
|
||||
private iConomy iConomy;
|
||||
public class iCo4 implements Method
|
||||
{
|
||||
private iConomy iConomy;
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iConomy;
|
||||
}
|
||||
public iConomy getPlugin()
|
||||
{
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "iConomy";
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return "iConomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "4";
|
||||
}
|
||||
public String getVersion()
|
||||
{
|
||||
return "4";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return this.iConomy.getBank().format(amount);
|
||||
}
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
public String format(double amount)
|
||||
{
|
||||
return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasBanks()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.iConomy.getBank().hasAccount(name);
|
||||
}
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return com.nijiko.coelho.iConomy.iConomy.getBank().hasAccount(name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new iCoAccount(this.iConomy.getBank().getAccount(name));
|
||||
}
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy") && plugin instanceof iConomy;
|
||||
}
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
|
||||
public class iCoAccount implements MethodAccount {
|
||||
private Account account;
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public iCoAccount(Account account) {
|
||||
this.account = account;
|
||||
}
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||
&& plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
|
||||
&& plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public Account getiCoAccount() {
|
||||
return account;
|
||||
}
|
||||
public void setPlugin(Plugin plugin)
|
||||
{
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.account.getBalance();
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
public class iCoAccount implements MethodAccount
|
||||
{
|
||||
private Account account;
|
||||
|
||||
public boolean add(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.add(amount);
|
||||
return true;
|
||||
}
|
||||
public iCoAccount(Account account)
|
||||
{
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
public Account getiCoAccount()
|
||||
{
|
||||
return account;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return this.account.getBalance();
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.divide(amount);
|
||||
return true;
|
||||
}
|
||||
public boolean set(double amount)
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.account.hasEnough(amount);
|
||||
}
|
||||
public boolean add(double amount)
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.account.hasOver(amount);
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.account.isNegative();
|
||||
}
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if(this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return this.account.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return this.account.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative()
|
||||
{
|
||||
return this.account.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove()
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import com.iConomy.iConomy;
|
||||
import com.iConomy.system.Account;
|
||||
import com.iConomy.system.BankAccount;
|
||||
import com.iConomy.system.Holdings;
|
||||
import com.iConomy.util.Constants;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@@ -37,9 +37,14 @@ public class iCo5 implements Method
|
||||
return "5";
|
||||
}
|
||||
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String format(double amount)
|
||||
{
|
||||
return this.iConomy.format(amount);
|
||||
return com.iConomy.iConomy.format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBanks()
|
||||
@@ -49,32 +54,34 @@ public class iCo5 implements Method
|
||||
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return (hasBanks()) && this.iConomy.Banks.exists(bank);
|
||||
return (hasBanks()) && com.iConomy.iConomy.Banks.exists(bank);
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return this.iConomy.hasAccount(name);
|
||||
return com.iConomy.iConomy.hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return (hasBank(bank)) && this.iConomy.getBank(bank).hasAccount(name);
|
||||
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new iCoAccount(this.iConomy.getAccount(name));
|
||||
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
|
||||
return new iCoBankAccount(com.iConomy.iConomy.getBank(bank).getAccount(name));
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||
&& plugin.getClass().getName().equals("com.iConomy.iConomy")
|
||||
&& plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin)
|
||||
|
@@ -1,14 +1,15 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import com.iCo6.iConomy;
|
||||
import com.iCo6.system.Account;
|
||||
import com.iCo6.system.Accounts;
|
||||
import com.iCo6.system.Holdings;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* iConomy 6 Implementation of Method
|
||||
*
|
||||
@@ -16,127 +17,177 @@ import org.bukkit.plugin.Plugin;
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class iCo6 implements Method {
|
||||
private iConomy iConomy;
|
||||
public class iCo6 implements Method
|
||||
{
|
||||
private iConomy iConomy;
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iConomy;
|
||||
}
|
||||
public iConomy getPlugin()
|
||||
{
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "iConomy";
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return "iConomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "6";
|
||||
}
|
||||
public String getVersion()
|
||||
{
|
||||
return "6";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return this.iConomy.format(amount);
|
||||
}
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
public String format(double amount)
|
||||
{
|
||||
return com.iCo6.iConomy.format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasBanks()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return (new Accounts()).exists(name);
|
||||
}
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return (new Accounts()).exists(name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new iCoAccount((new Accounts()).get(name));
|
||||
}
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new iCoAccount((new Accounts()).get(name));
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
try { Class.forName("com.iCo6.IO"); }
|
||||
catch(Exception e) { return false; }
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iCo6.iConomy") && plugin instanceof iConomy;
|
||||
}
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||
&& plugin.getClass().getName().equals("com.iCo6.iConomy")
|
||||
&& plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
public void setPlugin(Plugin plugin)
|
||||
{
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
|
||||
public class iCoAccount implements MethodAccount {
|
||||
private Account account;
|
||||
private Holdings holdings;
|
||||
|
||||
public iCoAccount(Account account) {
|
||||
this.account = account;
|
||||
this.holdings = account.getHoldings();
|
||||
}
|
||||
public class iCoAccount implements MethodAccount
|
||||
{
|
||||
private Account account;
|
||||
private Holdings holdings;
|
||||
|
||||
public Account getiCoAccount() {
|
||||
return account;
|
||||
}
|
||||
public iCoAccount(Account account)
|
||||
{
|
||||
this.account = account;
|
||||
this.holdings = account.getHoldings();
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.holdings.getBalance();
|
||||
}
|
||||
public Account getiCoAccount()
|
||||
{
|
||||
return account;
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return this.holdings.getBalance();
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
public boolean set(double amount)
|
||||
{
|
||||
if (this.holdings == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.holdings.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
public boolean add(double amount)
|
||||
{
|
||||
if (this.holdings == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
if (this.holdings == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
if (this.holdings == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.holdings.hasEnough(amount);
|
||||
}
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
if (this.holdings == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.holdings.hasOver(amount);
|
||||
}
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return this.holdings.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return this.holdings.hasUnder(amount);
|
||||
}
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return this.holdings.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.holdings.isNegative();
|
||||
}
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return this.holdings.hasUnder(amount);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if(this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean isNegative()
|
||||
{
|
||||
return this.holdings.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove()
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ deleteJail = \u00a77Jail {0} has been removed.
|
||||
deleteWarp = \u00a77Warp {0} has been removed.
|
||||
deniedAccessCommand = {0} was denied access to command.
|
||||
dependancyDownloaded = [Essentials] Dependancy {0} downloaded successfully.
|
||||
dependancyException = [Essentials] An error occured when trying to download a dependacy
|
||||
dependancyException = [Essentials] An error occurred when trying to download a dependacy
|
||||
dependancyNotFound = [Essentials] A required dependancy was not found, downloading now.
|
||||
depth = \u00a77You are at sea level.
|
||||
depthAboveSea = \u00a77You are {0} block(s) above sea level.
|
||||
@@ -171,7 +171,7 @@ mobsAvailable = \u00a77Mobs: {0}
|
||||
mobSpawnError = Error while changing mob spawner.
|
||||
mobSpawnLimit = Mob quantity limited to server limit
|
||||
mobSpawnTarget = Target block must be a mob spawner.
|
||||
moneyRecievedFrom = \u00a7a{0} has been recieved from {1}
|
||||
moneyRecievedFrom = \u00a7a{0} has been received from {1}
|
||||
moneySentTo = \u00a7a{0} has been sent to {1}
|
||||
moneyTaken = {0} taken from your bank account.
|
||||
month = month
|
||||
@@ -265,7 +265,7 @@ requestAcceptedFrom = \u00a77{0} accepted your teleport request.
|
||||
requestDenied = \u00a77Teleport request denied.
|
||||
requestDeniedFrom = \u00a77{0} denied your teleport request.
|
||||
requestSent = \u00a77Request sent to {0}\u00a77.
|
||||
returnPlayerToJailError = Error occured when trying to return player to jail.
|
||||
returnPlayerToJailError = Error occurred when trying to return player to jail.
|
||||
second = second
|
||||
seconds = seconds
|
||||
seenOffline = Player {0} is offline since {1}
|
||||
|
@@ -54,7 +54,7 @@ deleteJail = \u00a77Jail {0} has been removed.
|
||||
deleteWarp = \u00a77Warp {0} has been removed.
|
||||
deniedAccessCommand = {0} was denied access to command.
|
||||
dependancyDownloaded = [Essentials] Dependancy {0} downloaded successfully.
|
||||
dependancyException = [Essentials] An error occured when trying to download a dependacy
|
||||
dependancyException = [Essentials] An error occurred when trying to download a dependacy
|
||||
dependancyNotFound = [Essentials] A required dependancy was not found, downloading now.
|
||||
depth = \u00a77You are at sea level.
|
||||
depthAboveSea = \u00a77You are {0} block(s) above sea level.
|
||||
@@ -170,7 +170,7 @@ missingPrefixSuffix = Missing a prefix or suffix for {0}
|
||||
mobSpawnError = Error while changing mob spawner.
|
||||
mobSpawnLimit = Mob quantity limited to server limit
|
||||
mobSpawnTarget = Target block must be a mob spawner.
|
||||
moneyRecievedFrom = \u00a7a{0} has been recieved from {1}
|
||||
moneyRecievedFrom = \u00a7a{0} has been received from {1}
|
||||
moneySentTo = \u00a7a{0} has been sent to {1}
|
||||
moneyTaken = {0} taken from your bank account.
|
||||
month = month
|
||||
@@ -264,7 +264,7 @@ requestAcceptedFrom = \u00a77{0} accepted your teleport request.
|
||||
requestDenied = \u00a77Teleport request denied.
|
||||
requestDeniedFrom = \u00a77{0} denied your teleport request
|
||||
requestSent = \u00a77Request sent to {0}\u00a77.
|
||||
returnPlayerToJailError = Error occured when trying to return player to jail.
|
||||
returnPlayerToJailError = Error occurred when trying to return player to jail.
|
||||
second = second
|
||||
seconds = seconds
|
||||
seenOffline = Player {0} is offline since {1}
|
||||
|
@@ -13,4 +13,12 @@ v 1.1:
|
||||
- Push updates to superperms for all valid GM commands.
|
||||
- All GroupManager commands issued by players are now echoed in the console.
|
||||
- Reverted WorldHolder static change to maintain backward plugin compatibility.
|
||||
- Update to handle 'getDescription().getPermissions(') returning a list (CB 1172).
|
||||
- Update to handle 'getDescription().getPermissions(') returning a list (CB 1172).
|
||||
- Fix for null in PLAYER_TELEPORT for bukkit perms.
|
||||
- Fixed wasteful updating of perms on a manload.
|
||||
- manulistp now accepts an additional + to list ALL Superperms effective permissions (/manulistp <name> +).
|
||||
- manucheckp also outputs superperms results.
|
||||
- Removed superperms update on plugins unloading. Unneeded and created undesired lag on shutdown.
|
||||
- Added a BukkitPermsUpdateTask to only update superperms once on a load/reload.
|
||||
- Fix for GM not checking inheritance for known superperms nodes.
|
||||
- Optimized getAllPlayersPermissions and fixed pushing unknown perms to superperms.
|
@@ -7,6 +7,7 @@ package org.anjocaido.groupmanager;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
import org.anjocaido.groupmanager.permissions.BukkitPermissions;
|
||||
import org.anjocaido.groupmanager.utils.GroupManagerPermissions;
|
||||
import org.anjocaido.groupmanager.Tasks.BukkitPermsUpdateTask;
|
||||
import org.anjocaido.groupmanager.data.Variables;
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
@@ -50,7 +51,7 @@ public class GroupManager extends JavaPlugin {
|
||||
private WorldsHolder worldsHolder;
|
||||
private boolean validateOnlinePlayer = true;
|
||||
private boolean isReady = false;
|
||||
public static boolean isLoaded = false;
|
||||
private static boolean isLoaded = false;
|
||||
private GMConfiguration config;
|
||||
private GMLoggerHandler ch;
|
||||
public static BukkitPermissions BukkitPermissions;
|
||||
@@ -62,7 +63,7 @@ public class GroupManager extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
isLoaded = false;
|
||||
setLoaded(false);
|
||||
|
||||
if (worldsHolder != null) {
|
||||
worldsHolder.saveChanges();
|
||||
@@ -96,11 +97,30 @@ public class GroupManager extends JavaPlugin {
|
||||
BukkitPermissions = new BukkitPermissions(this);
|
||||
|
||||
enableScheduler();
|
||||
isLoaded = true;
|
||||
|
||||
/*
|
||||
* Schedule a Bukiit Permissions update for 1 tick later.
|
||||
* All plugins will be loaded by then
|
||||
*/
|
||||
|
||||
if (getServer().getScheduler().scheduleSyncDelayedTask(this, new BukkitPermsUpdateTask(),1) == -1) {
|
||||
GroupManager.logger.severe("Could not schedule superperms Update.");
|
||||
setLoaded(true);
|
||||
}
|
||||
|
||||
//setLoaded(true);
|
||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
|
||||
}
|
||||
|
||||
public InputStream getResourceAsStream(String fileName) {
|
||||
public static boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
public static void setLoaded(boolean isLoaded) {
|
||||
GroupManager.isLoaded = isLoaded;
|
||||
}
|
||||
|
||||
public InputStream getResourceAsStream(String fileName) {
|
||||
return this.getClassLoader().getResourceAsStream(fileName);
|
||||
}
|
||||
|
||||
@@ -637,16 +657,18 @@ public class GroupManager extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
//VALIDANDO ARGUMENTOS
|
||||
if (args.length != 1) {
|
||||
sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player>)");
|
||||
if ((args.length == 0) || (args.length > 2)) {
|
||||
sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> (+))");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (validateOnlinePlayer) {
|
||||
match = this.getServer().matchPlayer(args[0]);
|
||||
if (match.size() != 1) {
|
||||
sender.sendMessage(ChatColor.RED + "Player not found!");
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
targetPlayer = this.getServer().getPlayer(match.get(0).getName());
|
||||
}
|
||||
if (match != null) {
|
||||
auxUser = dataHolder.getUser(match.get(0).getName());
|
||||
@@ -683,6 +705,18 @@ public class GroupManager extends JavaPlugin {
|
||||
sender.sendMessage(ChatColor.YELLOW + "And all permissions from subgroups: " + auxString);
|
||||
}
|
||||
}
|
||||
|
||||
//bukkit perms
|
||||
if ((args.length == 2) && (args[1].equalsIgnoreCase("+"))) {
|
||||
if (targetPlayer != null) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Superperms reports: ");
|
||||
for(String line: BukkitPermissions.listPerms(targetPlayer))
|
||||
sender.sendMessage(ChatColor.YELLOW + line);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
case manucheckp:
|
||||
//VALIDANDO ESTADO DO SENDER
|
||||
@@ -695,12 +729,14 @@ public class GroupManager extends JavaPlugin {
|
||||
sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> <permission>)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (validateOnlinePlayer) {
|
||||
match = this.getServer().matchPlayer(args[0]);
|
||||
if (match.size() != 1) {
|
||||
sender.sendMessage(ChatColor.RED + "Player not found!");
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
targetPlayer = this.getServer().getPlayer(match.get(0).getName());
|
||||
}
|
||||
if (match != null) {
|
||||
auxUser = dataHolder.getUser(match.get(0).getName());
|
||||
@@ -730,6 +766,13 @@ public class GroupManager extends JavaPlugin {
|
||||
}
|
||||
sender.sendMessage(ChatColor.YELLOW + "Permission Node: " + permissionResult.accessLevel);
|
||||
}
|
||||
|
||||
// superperms
|
||||
if (targetPlayer != null) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "SuperPerms reports Node: " + targetPlayer.hasPermission(args[1]));
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
case mangaddp:
|
||||
//VALIDANDO ESTADO DO SENDER
|
||||
@@ -1423,9 +1466,14 @@ public class GroupManager extends JavaPlugin {
|
||||
auxString += " ";
|
||||
}
|
||||
}
|
||||
|
||||
isLoaded = false; // Disable Bukkit Perms update
|
||||
|
||||
worldsHolder.loadWorld(auxString);
|
||||
sender.sendMessage("The request to world '" + auxString + "' was sent.");
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
BukkitPermissions.updateAllPlayers();
|
||||
|
||||
return true;
|
||||
@@ -1437,6 +1485,9 @@ public class GroupManager extends JavaPlugin {
|
||||
}
|
||||
//WORKING
|
||||
config.load();
|
||||
|
||||
isLoaded = false;
|
||||
|
||||
if (args.length > 0) {
|
||||
auxString = "";
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
@@ -1453,6 +1504,8 @@ public class GroupManager extends JavaPlugin {
|
||||
}
|
||||
worldsHolder.mirrorSetUp();
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
BukkitPermissions.updateAllPlayers();
|
||||
|
||||
return true;
|
||||
|
@@ -0,0 +1,27 @@
|
||||
package org.anjocaido.groupmanager.Tasks;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
|
||||
/*
|
||||
*
|
||||
* Created by ElgarL
|
||||
*
|
||||
*/
|
||||
|
||||
public class BukkitPermsUpdateTask implements Runnable {
|
||||
|
||||
public BukkitPermsUpdateTask() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Signal loaded and update BukkitPermissions.
|
||||
GroupManager.setLoaded(true);
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
|
||||
GroupManager.logger.info("Bukkit Permissions Updated!");
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -90,7 +90,7 @@ public class Group extends DataUnit implements Cloneable {
|
||||
inherits.add(inherit.getName().toLowerCase());
|
||||
}
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded)
|
||||
if (GroupManager.isLoaded())
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class Group extends DataUnit implements Cloneable {
|
||||
variables.addVar(key, temp.getVarObject(key));
|
||||
}
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded)
|
||||
if (GroupManager.isLoaded())
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
}
|
||||
}
|
||||
|
@@ -104,8 +104,9 @@ public class User extends DataUnit implements Cloneable {
|
||||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
flagAsChanged();
|
||||
if ((GroupManager.isLoaded) && (GroupManager.BukkitPermissions.player_join = false))
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
if (GroupManager.isLoaded())
|
||||
if(GroupManager.BukkitPermissions.player_join = false)
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,8 +119,9 @@ public class User extends DataUnit implements Cloneable {
|
||||
group = getDataSource().getGroup(group.getName());
|
||||
this.group = group.getName();
|
||||
flagAsChanged();
|
||||
if ((GroupManager.isLoaded) && (GroupManager.BukkitPermissions.player_join = false))
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
if (GroupManager.isLoaded())
|
||||
if (GroupManager.BukkitPermissions.player_join = false)
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
}
|
||||
|
||||
public void addSubGroup(Group subGroup) {
|
||||
@@ -133,7 +135,8 @@ public class User extends DataUnit implements Cloneable {
|
||||
removeSubGroup(subGroup);
|
||||
subGroups.add(subGroup.getName());
|
||||
flagAsChanged();
|
||||
if ((GroupManager.isLoaded) && (GroupManager.BukkitPermissions.player_join = false))
|
||||
if (GroupManager.isLoaded())
|
||||
if (GroupManager.BukkitPermissions.player_join = false)
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
}
|
||||
|
||||
@@ -153,8 +156,9 @@ public class User extends DataUnit implements Cloneable {
|
||||
try {
|
||||
if (subGroups.remove(subGroup.getName())) {
|
||||
flagAsChanged();
|
||||
if ((GroupManager.isLoaded) && (GroupManager.BukkitPermissions.player_join = false))
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
if (GroupManager.isLoaded())
|
||||
if (GroupManager.BukkitPermissions.player_join = false)
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -197,7 +201,8 @@ public class User extends DataUnit implements Cloneable {
|
||||
variables.addVar(key, temp.getVarObject(key));
|
||||
}
|
||||
flagAsChanged();
|
||||
if ((GroupManager.isLoaded) && (GroupManager.BukkitPermissions.player_join = false))
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
if (GroupManager.isLoaded())
|
||||
if (GroupManager.BukkitPermissions.player_join = false)
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
}
|
||||
}
|
||||
|
@@ -81,73 +81,24 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns All permissions (including inheritance) of player name.
|
||||
* Returns All permissions (including inheritance and sub groups) for the player.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllPlayersPermissions(String userName) {
|
||||
|
||||
User user = ph.getUser(userName);
|
||||
List<String> playerPermArray = new ArrayList<String>(user.getPermissionList());
|
||||
List<String> playerMainGroupPermArray = new ArrayList<String>(user.getGroup().getPermissionList());
|
||||
List<String> subGroupsPermArray = new ArrayList<String>();
|
||||
List<String> returnPermArray = new ArrayList<String>();
|
||||
List<String> playerPermArray = new ArrayList<String>(ph.getUser(userName).getPermissionList());
|
||||
|
||||
for (String subGroup : user.subGroupListStringCopy()) {
|
||||
subGroupsPermArray.addAll(ph.getGroup(subGroup).getPermissionList());
|
||||
for (String group : getGroups(userName)) {
|
||||
for (String perm : ph.getGroup(group).getPermissionList()) {
|
||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm)))
|
||||
playerPermArray.add(perm);
|
||||
}
|
||||
}
|
||||
|
||||
for (String permission : subGroupsPermArray) {
|
||||
/*
|
||||
* Add each Negated permission
|
||||
* unless it's being overridden by a higher permission
|
||||
*/
|
||||
if (permission.startsWith("-")
|
||||
&& !playerMainGroupPermArray.contains(permission.substring(1))
|
||||
&& !playerPermArray.contains(permission.substring(1))
|
||||
&& !playerMainGroupPermArray.contains("*")
|
||||
&& !playerPermArray.contains("*")) {
|
||||
if (!returnPermArray.contains(permission)) {
|
||||
returnPermArray.add(permission);
|
||||
}
|
||||
} else
|
||||
if (!returnPermArray.contains(permission)
|
||||
&& !playerMainGroupPermArray.contains("-"+permission)
|
||||
&& !playerPermArray.contains("-"+permission)) {
|
||||
returnPermArray.add(permission);
|
||||
}
|
||||
}
|
||||
|
||||
for (String permission : playerMainGroupPermArray) {
|
||||
/*
|
||||
* Add each Negated permission
|
||||
* unless it's being overridden by a higher permission
|
||||
*/
|
||||
if (permission.startsWith("-")
|
||||
&& !playerPermArray.contains(permission.substring(1))
|
||||
&& !playerMainGroupPermArray.contains("*")
|
||||
&& !playerPermArray.contains("*")) {
|
||||
if (!returnPermArray.contains(permission)) {
|
||||
returnPermArray.add(permission);
|
||||
}
|
||||
} else
|
||||
if (!returnPermArray.contains(permission)
|
||||
&& !playerPermArray.contains("-"+permission)) {
|
||||
returnPermArray.add(permission);
|
||||
}
|
||||
}
|
||||
|
||||
for (String permission : playerPermArray) {
|
||||
/*
|
||||
* Add each permission
|
||||
*/
|
||||
if (!returnPermArray.contains(permission)) {
|
||||
returnPermArray.add(permission);
|
||||
}
|
||||
}
|
||||
|
||||
return returnPermArray;
|
||||
|
||||
return playerPermArray;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +110,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
* And verify the player 'MyAdmin', which is Admin, it will return true for both
|
||||
* Admin or Moderator groups.
|
||||
*
|
||||
* Mas if you haave a player 'MyModerator', which is Moderator,
|
||||
* Mas if you have a player 'MyModerator', which is Moderator,
|
||||
* it will give false if you pass Admin in group parameter.
|
||||
*
|
||||
* @param name
|
||||
|
@@ -26,7 +26,6 @@ import java.util.Set;
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
||||
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -43,6 +42,7 @@ import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
//import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@@ -106,7 +106,7 @@ public class BukkitPermissions {
|
||||
}
|
||||
|
||||
public void updatePermissions(Player player, String world) {
|
||||
if (player == null || !this.plugin.isEnabled()) {
|
||||
if (player == null || !GroupManager.isLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,15 +131,10 @@ public class BukkitPermissions {
|
||||
}
|
||||
|
||||
// find matching permissions
|
||||
PermissionCheckResult permissionResult;
|
||||
Boolean value;
|
||||
for (Permission permission : registeredPermissions) {
|
||||
permissionResult = worldData.getPermissionsHandler().checkFullUserPermission(user, permission.getName());
|
||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.FOUND))
|
||||
value = true;
|
||||
else
|
||||
value = false;
|
||||
|
||||
value = worldData.getPermissionsHandler().checkUserPermission(user, permission.getName());
|
||||
|
||||
attachment.setPermission(permission, value);
|
||||
}
|
||||
|
||||
@@ -158,19 +153,28 @@ public class BukkitPermissions {
|
||||
}
|
||||
}
|
||||
player.recalculatePermissions();
|
||||
|
||||
/*
|
||||
// List perms for this player
|
||||
GroupManager.logger.info("Attachment Permissions:");
|
||||
}
|
||||
|
||||
public List<String> listPerms(Player player) {
|
||||
List<String> perms = new ArrayList<String>();
|
||||
|
||||
/*
|
||||
// All permissions registered with Bukkit for this player
|
||||
PermissionAttachment attachment = this.attachments.get(player);
|
||||
|
||||
// List perms for this player
|
||||
perms.add("Attachment Permissions:");
|
||||
for(Map.Entry<String, Boolean> entry : attachment.getPermissions().entrySet()){
|
||||
GroupManager.logger.info(" " + entry.getKey() + " = " + entry.getValue());
|
||||
perms.add(" " + entry.getKey() + " = " + entry.getValue());
|
||||
}
|
||||
*/
|
||||
|
||||
GroupManager.logger.info("Effective Permissions:");
|
||||
perms.add("Effective Permissions:");
|
||||
for(PermissionAttachmentInfo info : player.getEffectivePermissions()){
|
||||
GroupManager.logger.info(" " + info.getPermission() + " = " + info.getValue());
|
||||
if (info.getValue() == true)
|
||||
perms.add(" " + info.getPermission() + " = " + info.getValue());
|
||||
}
|
||||
*/
|
||||
return perms;
|
||||
}
|
||||
|
||||
public void updateAllPlayers() {
|
||||
@@ -195,11 +199,9 @@ public class BukkitPermissions {
|
||||
|
||||
@Override
|
||||
public void onPlayerPortal(PlayerPortalEvent event) { // will portal into another world
|
||||
if(event.getPlayer().getWorld().equals(event.getTo().getWorld())){ // only if world actually changed
|
||||
return;
|
||||
if(!event.getFrom().getWorld().equals(event.getTo().getWorld())){ // only if world actually changed
|
||||
updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
|
||||
}
|
||||
|
||||
updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,6 +218,9 @@ public class BukkitPermissions {
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (!GroupManager.isLoaded())
|
||||
return;
|
||||
|
||||
attachments.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
@@ -229,14 +234,17 @@ public class BukkitPermissions {
|
||||
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (!GroupManager.isLoaded())
|
||||
return;
|
||||
|
||||
collectPermissions();
|
||||
updateAllPlayers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
collectPermissions();
|
||||
updateAllPlayers();
|
||||
//collectPermissions();
|
||||
//updateAllPlayers();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user