diff options
34 files changed, 1335 insertions, 933 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 518e853bb..c98671d94 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -188,6 +188,7 @@ public class Essentials extends JavaPlugin implements IEssentials pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this); pm.registerEvent(Type.ENTITY_COMBUST, entityListener, Priority.Lowest, this); pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this); + pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this); jail = new Jail(this); final JailPlayerListener jailPlayerListener = new JailPlayerListener(this); diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index ce97726dc..2eda73540 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -8,6 +8,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityListener; +import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.inventory.ItemStack; @@ -80,4 +81,13 @@ public class EssentialsEntityListener extends EntityListener } } } + + @Override + public void onFoodLevelChange(FoodLevelChangeEvent event) + { + if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled()) + { + event.setFoodLevel(20); + } + } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 9ba02b5c3..2f690910f 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -94,21 +94,15 @@ public class EssentialsPlayerListener extends PlayerListener final Location from = event.getFrom(); final Location to = event.getTo().clone(); to.setX(from.getX()); - to.setY(from.getY()); + to.setY(from.getBlock().getTypeId() == 0 ? from.getY() - 1 : from.getY()); to.setZ(from.getZ()); - try - { - event.setTo(Util.getSafeDestination(to)); - } - catch (Exception ex) - { - event.setTo(to); - } + event.setTo(to); return; } Location afk = user.getAfkPosition(); - if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9) { + if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9) + { user.updateActivity(true); } @@ -307,20 +301,21 @@ 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()); user.setNPC(false); final long currentTime = System.currentTimeMillis(); - user.checkBanTimeout(currentTime); + boolean banExpired = user.checkBanTimeout(currentTime); user.checkMuteTimeout(currentTime); user.checkJailTimeout(currentTime); - if (user.isBanned()) + if (banExpired == false && (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")); + event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : Util.i18n("defaultBanReason")); return; } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java index e64496171..6b92d7aa2 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java @@ -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."); } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java index ab19450f8..f3b447dae 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java @@ -26,10 +26,6 @@ public class EssentialsTimer implements Runnable onlineUsers.add(user); user.setLastOnlineActivity(currentTime); user.checkActivity(); - // Food for god mode - if (user.isGodModeEnabled() && user.getFoodLevel() < 20) { - user.setFoodLevel(20); - } } final Iterator<User> iterator = onlineUsers.iterator(); diff --git a/Essentials/src/com/earth2me/essentials/Mob.java b/Essentials/src/com/earth2me/essentials/Mob.java index df4a5b72f..d937ba0fb 100644 --- a/Essentials/src/com/earth2me/essentials/Mob.java +++ b/Essentials/src/com/earth2me/essentials/Mob.java @@ -26,11 +26,10 @@ public enum Mob SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER), SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID), ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE), - MONSTER("Monster", Enemies.ENEMY, CreatureType.MONSTER), WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF), CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER), - ENDERMAN("Enderman", Enemies.ENEMY, CreatureType.ENDERMAN), - SILVERFISH("Silverfish", Enemies.ENEMY, CreatureType.SILVERFISH); + ENDERMAN("Enderman", Enemies.ENEMY, "", CreatureType.ENDERMAN), + SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH); public static final Logger logger = Logger.getLogger("Minecraft"); diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java index 199526648..07092d0bb 100644 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java @@ -701,5 +701,17 @@ public class OfflinePlayer implements Player { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public boolean isSprinting() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSprinting(boolean bln) + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/Essentials/src/com/earth2me/essentials/PlayerWrapper.java b/Essentials/src/com/earth2me/essentials/PlayerWrapper.java index 8876e804a..2b6dd92ad 100644 --- a/Essentials/src/com/earth2me/essentials/PlayerWrapper.java +++ b/Essentials/src/com/earth2me/essentials/PlayerWrapper.java @@ -731,5 +731,17 @@ public class PlayerWrapper implements Player { return base.getBedSpawnLocation(); } + + @Override + public boolean isSprinting() + { + return base.isSprinting(); + } + + @Override + public void setSprinting(boolean bln) + { + base.setSprinting(bln); + } } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 665da17a6..5bcbd7311 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -220,7 +220,7 @@ public class Settings implements ISettings @Override public boolean isNetherEnabled() { - return config.getBoolean("nether.enabled", true); + return config.getBoolean("nether.enabled", false); } @Override @@ -362,7 +362,7 @@ public class Settings implements ISettings if (config.getBoolean("nether.use-1to1-ratio", false)) { return 1.0; } - return config.getDouble("nether.ratio", 16.0); + return config.getDouble("nether.ratio", 8.0); } @Override diff --git a/Essentials/src/com/earth2me/essentials/TargetBlock.java b/Essentials/src/com/earth2me/essentials/TargetBlock.java index d1f2e5cbb..3d45afc55 100644 --- a/Essentials/src/com/earth2me/essentials/TargetBlock.java +++ b/Essentials/src/com/earth2me/essentials/TargetBlock.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; /** * Original authors: toi & Raphfrk */ +@Deprecated public class TargetBlock { private transient final Location location; diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 2f4fc2951..b68e93656 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -20,14 +20,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser private transient long lastOnlineActivity; private transient long lastActivity = System.currentTimeMillis(); private boolean hidden = false; - private transient boolean godStateBeforeAfk; private transient Location afkPosition; User(final Player base, final IEssentials ess) { super(base, ess); teleport = new Teleport(this, ess); - godStateBeforeAfk = isGodModeEnabled(); afkPosition = getLocation(); } @@ -348,15 +346,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser public void setAfk(final boolean set) { this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set); - if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers()) - { - godStateBeforeAfk = isGodModeEnabled(); - setGodModeEnabled(true); - } - if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers()) - { - setGodModeEnabled(godStateBeforeAfk); - } if (set && !isAfk()) { afkPosition = getLocation(); } @@ -381,7 +370,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser this.hidden = hidden; } - public void checkJailTimeout(final long currentTime) + //Returns true if status expired during this check + public boolean checkJailTimeout(final long currentTime) { if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed()) { @@ -396,26 +386,34 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser catch (Exception ex) { } + return true; } + return false; } - public void checkMuteTimeout(final long currentTime) + //Returns true if status expired during this check + public boolean checkMuteTimeout(final long currentTime) { if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted()) { setMuteTimeout(0); sendMessage(Util.i18n("canTalkAgain")); setMuted(false); + return true; } + return false; } - public void checkBanTimeout(final long currentTime) + //Returns true if status expired during this check + public boolean checkBanTimeout(final long currentTime) { if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned()) { setBanTimeout(0); setBanned(false); + return true; } + return false; } public void updateActivity(final boolean broadcast) @@ -451,7 +449,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser } } final long autoafk = ess.getSettings().getAutoAfk(); - if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis()) + if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk")) { setAfk(true); if (!isHidden()) { @@ -464,4 +462,19 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser { return afkPosition; } + + @Override + public boolean toggleGodModeEnabled() + { + if (!isGodModeEnabled()) { + setFoodLevel(20); + } + return super.toggleGodModeEnabled(); + } + + @Override + public boolean isGodModeEnabled() + { + return super.isGodModeEnabled() || (isAfk() && ess.getSettings().getFreezeAfkPlayers()); + } } diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 75d126c3e..f0a461b70 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -58,6 +58,7 @@ public abstract class UserData extends PlayerExtension implements IConf isSocialSpyEnabled = _isSocialSpyEnabled(); isNPC = _isNPC(); arePowerToolsEnabled = _arePowerToolsEnabled(); + kitTimestamps = _getKitTimestamps(); } private double money; @@ -154,6 +155,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(); @@ -161,7 +164,12 @@ public abstract class UserData extends PlayerExtension implements IConf public void delHome(String name) throws Exception { - if (getHome(name) != null) + String search = name; + if (!homes.containsKey(search)) + { + search = Util.sanitizeFileName(name); + } + if (homes.containsKey(search)) { homes.remove(name); config.removeProperty("homes." + name); @@ -241,12 +249,13 @@ public abstract class UserData extends PlayerExtension implements IConf } - public void clearAllPowertools() { + public void clearAllPowertools() + { powertools.clear(); config.setProperty("powertools", powertools); config.save(); } - + public List<String> getPowertool(ItemStack stack) { return (List<String>)powertools.get(stack.getTypeId()); @@ -265,12 +274,11 @@ public abstract class UserData extends PlayerExtension implements IConf config.setProperty("powertools", powertools); config.save(); } - + public boolean hasPowerTools() { return powertools.size() > 0; } - private Location lastLocation; private Location _getLastLocation() @@ -292,6 +300,10 @@ public abstract class UserData extends PlayerExtension implements IConf public void setLastLocation(Location loc) { + if (loc == null || loc.getWorld() == null) + { + return; + } lastLocation = loc; config.setProperty("lastlocation", loc); config.save(); @@ -779,31 +791,57 @@ public abstract class UserData extends PlayerExtension implements IConf config.setProperty("npc", set); config.save(); } - private boolean arePowerToolsEnabled; - + public boolean arePowerToolsEnabled() { return arePowerToolsEnabled; } - + public void setPowerToolsEnabled(boolean set) { arePowerToolsEnabled = set; config.setProperty("powertoolsenabled", set); config.save(); } - + public boolean togglePowerToolsEnabled() { boolean ret = !arePowerToolsEnabled(); setPowerToolsEnabled(ret); return ret; } - + private boolean _arePowerToolsEnabled() { return config.getBoolean("powertoolsenabled", true); } - + private Map<String, Object> kitTimestamps; + + private Map<String, Object> _getKitTimestamps() + { + final Object map = config.getProperty("timestamps.kits"); + + if (map instanceof Map) + { + return (Map<String, Object>)map; + } + else + { + return new HashMap<String, Object>(); + } + } + + public Long getKitTimestamp(final String name) + { + final Number num = (Number)kitTimestamps.get(name.toLowerCase()); + return num == null ? null : num.longValue(); + } + + public void setKitTimestamp(final String name, final long time) + { + kitTimestamps.put(name.toLowerCase(), time); + config.setProperty("timestamps.kits", kitTimestamps); + config.save(); + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java index aa60c9168..1d80b6a17 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java @@ -31,7 +31,7 @@ public class Commanddelhome extends EssentialsCommand } else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others"))) { - user = getPlayer(server, args, 0); + user = getPlayer(server, args, 0, true); name = args[1]; } else diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java index 2ee2661e6..16b9fca2a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java @@ -45,17 +45,17 @@ 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()) { - throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer")); + user.getTeleport().respawn(ess.getSpawn(), charge); } - else if ((homes.size() == 1) && u == user) + else if (homes.isEmpty()) { - user.getTeleport().home(u, homes.get(0), charge); + throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer")); } - else if (ess.getSettings().spawnIfNoHome()) + else if (homes.size() == 1 && u.equals(user)) { - user.getTeleport().respawn(ess.getSpawn(), charge); + user.getTeleport().home(u, homes.get(0), charge); } else { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java index 8b6dc8182..07710d40a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java @@ -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(); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java index 75cc83887..ae7963c5e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java @@ -15,22 +15,20 @@ import org.bukkit.inventory.ItemStack; public class Commandkit extends EssentialsCommand { - static private final Map<User, Map<String, Long>> kitPlayers = new HashMap<User, Map<String, Long>>(); - public Commandkit() { super("kit"); } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { try { - Map<String, Object> kits = ess.getSettings().getKits(); - StringBuilder list = new StringBuilder(); + final Map<String, Object> kits = ess.getSettings().getKits(); + final StringBuilder list = new StringBuilder(); for (String k : kits.keySet()) { if (user.isAuthorized("essentials.kit." + k.toLowerCase())) @@ -56,8 +54,8 @@ public class Commandkit extends EssentialsCommand { try { - String kitName = args[0].toLowerCase(); - Object kit = ess.getSettings().getKit(kitName); + final String kitName = args[0].toLowerCase(); + final Object kit = ess.getSettings().getKit(kitName); List<String> items; if (!user.isAuthorized("essentials.kit." + kitName)) @@ -70,39 +68,26 @@ public class Commandkit extends EssentialsCommand { //System.out.println("Kit is timed"); - Map<String, Object> els = (Map<String, Object>)kit; + final Map<String, Object> els = (Map<String, Object>)kit; items = (List<String>)els.get("items"); - double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L; - Calendar c = new GregorianCalendar(); - c.add(Calendar.SECOND, (int)delay); - c.add(Calendar.MILLISECOND, (int)((delay*1000.0)%1000.0)); + final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L; + final Calendar c = new GregorianCalendar(); + c.add(Calendar.SECOND, -(int)delay); + c.add(Calendar.MILLISECOND, -(int)((delay*1000.0)%1000.0)); - long time = c.getTimeInMillis(); - Calendar now = new GregorianCalendar(); - - Map<String, Long> kitTimes; - if (!kitPlayers.containsKey(user)) - { - kitTimes = new HashMap<String, Long>(); - kitTimes.put(kitName, time); - kitPlayers.put(user, kitTimes); - } - else - { - kitTimes = kitPlayers.get(user); - if (!kitTimes.containsKey(kitName)) - { - kitTimes.put(kitName, time); - } - else if (kitTimes.get(kitName) < now.getTimeInMillis()) - { - kitTimes.put(kitName, time); - } - else - { - user.sendMessage(Util.format("kitTimed", Util.formatDateDiff(kitTimes.get(kitName)))); - return; - } + final long mintime = c.getTimeInMillis(); + + final Long lastTime = user.getKitTimestamp(kitName); + if (lastTime == null || lastTime < mintime) { + final Calendar now = new GregorianCalendar(); + user.setKitTimestamp(kitName, now.getTimeInMillis()); + } else { + final Calendar future = new GregorianCalendar(); + future.setTimeInMillis(lastTime); + future.add(Calendar.SECOND, (int)delay); + future.add(Calendar.MILLISECOND, (int)((delay*1000.0)%1000.0)); + user.sendMessage(Util.format("kitTimed", Util.formatDateDiff(future.getTimeInMillis()))); + return; } } catch (Exception ex) @@ -110,7 +95,7 @@ public class Commandkit extends EssentialsCommand items = (List<String>)kit; } - Trade charge = new Trade("kit-" + kitName, ess); + final Trade charge = new Trade("kit-" + kitName, ess); try { charge.isAffordableFor(user); @@ -124,11 +109,11 @@ public class Commandkit extends EssentialsCommand boolean spew = false; for (String d : items) { - String[] parts = d.split("[^0-9]+", 3); - int id = Material.getMaterial(Integer.parseInt(parts[0])).getId(); - int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1; - short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0; - HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data)); + final String[] parts = d.split("[^0-9]+", 3); + final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId(); + final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1; + final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0; + final HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data)); for (ItemStack itemStack : overfilled.values()) { user.getWorld().dropItemNaturally(user.getLocation(), itemStack); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java index a98fabbd2..e08a6c8e5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java @@ -64,6 +64,6 @@ public class Commandmail extends EssentialsCommand user.setMails(null); throw new Exception(Util.i18n("mailCleared")); } - throw new NotEnoughArgumentsException(); + throw new NoChargeException(); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java index 2eb580ea4..115bb20ef 100755 --- a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java @@ -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())); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index f46264582..3ea3aae40 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -56,11 +56,6 @@ public class Commandspawnmob extends EssentialsCommand } } - if (ess.getSettings().getProtectPreventSpawn(mobType.toLowerCase()) - || (mountType != null && ess.getSettings().getProtectPreventSpawn(mountType.toLowerCase()))) - { - throw new Exception(Util.i18n("unableToSpawnMob")); - } Entity spawnedMob = null; Mob mob = null; @@ -72,6 +67,12 @@ public class Commandspawnmob extends EssentialsCommand { throw new Exception(Util.i18n("invalidMob")); } + + if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase())) + { + throw new Exception(Util.i18n("unableToSpawnMob")); + } + int[] ignore = { 8, 9 @@ -79,8 +80,7 @@ public class Commandspawnmob extends EssentialsCommand Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock(); if (block == null) { - user.sendMessage(Util.i18n("unableToSpawnMob")); - return; + throw new Exception(Util.i18n("unableToSpawnMob")); } Location loc = block.getLocation(); Location sloc = Util.getSafeDestination(loc); @@ -90,8 +90,7 @@ public class Commandspawnmob extends EssentialsCommand } catch (MobException e) { - user.sendMessage(Util.i18n("unableToSpawnMob")); - return; + throw new Exception(Util.i18n("unableToSpawnMob")); } if (mountType != null) @@ -102,14 +101,18 @@ public class Commandspawnmob extends EssentialsCommand user.sendMessage(Util.i18n("invalidMob")); return; } + + if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase())) + { + throw new Exception(Util.i18n("unableToSpawnMob")); + } try { spawnedMount = mobMount.spawn(user, server, loc); } catch (MobException e) { - user.sendMessage(Util.i18n("unableToSpawnMob")); - return; + throw new Exception(Util.i18n("unableToSpawnMob")); } spawnedMob.setPassenger(spawnedMount); } @@ -144,8 +147,7 @@ public class Commandspawnmob extends EssentialsCommand } catch (MobException e) { - user.sendMessage(Util.i18n("unableToSpawnMob")); - return; + throw new Exception(Util.i18n("unableToSpawnMob")); } spawnedMob.setPassenger(spawnedMount); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java index 72bb2b65f..687396f53 100755 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java @@ -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")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java index 8bc921d64..4877c2aeb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java @@ -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")); } diff --git a/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java index 90b905113..b30a7c0c7 100644 --- a/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java @@ -3,17 +3,20 @@ package com.earth2me.essentials.perm; import de.bananaco.permissions.Permissions; import de.bananaco.permissions.interfaces.PermissionSet; import de.bananaco.permissions.worlds.WorldPermissionsManager; +import de.bananaco.permissions.info.InfoReader; import java.util.List; import org.bukkit.entity.Player; -public class BPermissionsHandler extends SuperpermsHandler +public class BPermissionsHandler implements IPermissionsHandler { private final transient WorldPermissionsManager wpm; - + private final transient InfoReader info; public BPermissionsHandler() { wpm = Permissions.getWorldPermissionsManager(); + info = new InfoReader(); + info.instantiate(); } @Override @@ -48,4 +51,28 @@ public class BPermissionsHandler extends SuperpermsHandler } return groups.contains(group); } + + @Override + public boolean canBuild(final Player base, final String group) + { + return hasPermission(base, "essentials.build") || hasPermission(base, "bPermissions.build"); + } + + @Override + public String getPrefix(final Player base) + { + return info.getPrefix(base); + } + + @Override + public String getSuffix(final Player base) + { + return info.getSuffix(base); + } + + @Override + public boolean hasPermission(final Player base, final String node) + { + return base.hasPermission(node); + } } diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java index d47c3c8a4..b3cc62979 100644 --- a/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java @@ -74,4 +74,10 @@ public class PermissionsBukkitHandler extends SuperpermsHandler } return false; } + + @Override + public boolean canBuild(Player base, String group) + { + return base.hasPermission("essentials.build") || base.hasPermission("permissions.build"); + } } diff --git a/Essentials/src/com/earth2me/essentials/register/payment/Method.java b/Essentials/src/com/earth2me/essentials/register/payment/Method.java index 7394f6b2f..f8bd814ef 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/Method.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/Method.java @@ -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 @@ -42,6 +42,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. * * @param amount Double diff --git a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java index 3dc7a2c63..0fc65534f 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java @@ -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>(); + + static + { + _init(); + } /** - * Initialize Method class + * Implement all methods along with their respective name & class. */ - public Methods() + private static void _init() { - this._init(); + 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"); } /** - * 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. + * Used by the plugin to setup version + * + * @param v version */ - public Methods(String preferred) + public static void setVersion(String v) { - this._init(); + version = v; + } - if (this.Dependencies.contains(preferred)) - { - this.preferred = preferred; - } + /** + * Use to reset methods during disable + */ + public static void reset() + { + version = null; + self = false; + Method = null; + preferred = ""; + Attachables.clear(); } /** - * Implement all methods along with their respective name & class. - * - * @see #Methods() - * @see #Methods(java.lang.String) + * Use to get version of Register plugin + * @return version */ - private void _init() + public static String getVersion() { - 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()); + 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; } } @@ -240,11 +240,27 @@ public class Methods } /** + * 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); } } diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java index 8400eebd0..7c83c9b76 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java @@ -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; - - public BOSEconomy getPlugin() { - return this.BOSEconomy; - } - - public String getName() { - return "BOSEconomy"; - } - - 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 boolean hasBanks() { - return true; - } - - public boolean hasBank(String bank) { - return this.BOSEconomy.bankExists(bank); - } - - public boolean hasAccount(String name) { - return this.BOSEconomy.playerRegistered(name, false); - } - - public boolean hasBankAccount(String bank, String name) { - return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name); - } - - public MethodAccount getAccount(String name) { - if(!hasAccount(name)) return null; - return new BOSEAccount(name, this.BOSEconomy); - } - - public MethodBankAccount getBankAccount(String bank, String name) { - if(!hasBankAccount(bank, name)) return null; - return new BOSEBankAccount(bank, BOSEconomy); - } - - public boolean isCompatible(Plugin plugin) { - return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && plugin.getDescription().getVersion().equals("0.6.2"); - } - - public void setPlugin(Plugin plugin) { - BOSEconomy = (BOSEconomy)plugin; - } - - public class BOSEAccount implements MethodAccount { - private String name; - private BOSEconomy BOSEconomy; - - public BOSEAccount(String name, BOSEconomy bOSEconomy) { - this.name = name; - this.BOSEconomy = bOSEconomy; - } - - public double balance() { - return (double) this.BOSEconomy.getPlayerMoney(this.name); - } - - public boolean set(double amount) { - int IntAmount = (int)Math.ceil(amount); - return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false); - } - - public boolean add(double amount) { - int IntAmount = (int)Math.ceil(amount); - return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false); - } - - 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 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 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 false; - } - } - - public class BOSEBankAccount implements MethodBankAccount { - private final String bank; - private final BOSEconomy BOSEconomy; - - public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) { - this.bank = bank; - this.BOSEconomy = bOSEconomy; - } - - public String getBankName() { - return this.bank; - } - - public int getBankId() { - return -1; - } - - public double balance() { - return (double) this.BOSEconomy.getBankMoney(bank); - } - - public boolean set(double amount) { - int IntAmount = (int)Math.ceil(amount); - return this.BOSEconomy.setBankMoney(bank, IntAmount, true); - } - - 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 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); - } - } +@SuppressWarnings("deprecation") +public class BOSE6 implements Method +{ + private BOSEconomy BOSEconomy; + + public BOSEconomy getPlugin() + { + return this.BOSEconomy; + } + + public String getName() + { + return "BOSEconomy"; + } + + public String getVersion() + { + return "0.6.2"; + } + + public int fractionalDigits() + { + return 0; + } + + public String format(double amount) + { + String currency = this.BOSEconomy.getMoneyNamePlural(); + + if (amount == 1) + { + currency = this.BOSEconomy.getMoneyName(); + } + + return amount + " " + currency; + } + + public boolean hasBanks() + { + return true; + } + + public boolean hasBank(String bank) + { + return this.BOSEconomy.bankExists(bank); + } + + public boolean hasAccount(String name) + { + return this.BOSEconomy.playerRegistered(name, false); + } + + public boolean hasBankAccount(String bank, String name) + { + return this.BOSEconomy.isBankOwner(bank, name) + || this.BOSEconomy.isBankMember(bank, name); + } + + public MethodAccount getAccount(String name) + { + if (!hasAccount(name)) + { + return null; + } + + return new BOSEAccount(name, this.BOSEconomy); + } + + public MethodBankAccount getBankAccount(String bank, String name) + { + if (!hasBankAccount(bank, name)) + { + return null; + } + + return new BOSEBankAccount(bank, BOSEconomy); + } + + public boolean isCompatible(Plugin plugin) + { + return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") + && plugin instanceof BOSEconomy + && plugin.getDescription().getVersion().equals("0.6.2"); + } + + public void setPlugin(Plugin plugin) + { + BOSEconomy = (BOSEconomy)plugin; + } + + + public class BOSEAccount implements MethodAccount + { + private final String name; + private final BOSEconomy BOSEconomy; + + public BOSEAccount(String name, BOSEconomy bOSEconomy) + { + this.name = name; + this.BOSEconomy = bOSEconomy; + } + + public double balance() + { + return (double)this.BOSEconomy.getPlayerMoney(this.name); + } + + public boolean set(double amount) + { + int IntAmount = (int)Math.ceil(amount); + return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false); + } + + public boolean add(double amount) + { + int IntAmount = (int)Math.ceil(amount); + return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false); + } + + 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 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 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 false; + } + } + + + public class BOSEBankAccount implements MethodBankAccount + { + private final String bank; + private final BOSEconomy BOSEconomy; + + public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) + { + this.bank = bank; + this.BOSEconomy = bOSEconomy; + } + + public String getBankName() + { + return this.bank; + } + + public int getBankId() + { + return -1; + } + + public double balance() + { + return (double)this.BOSEconomy.getBankMoney(bank); + } + + public boolean set(double amount) + { + int IntAmount = (int)Math.ceil(amount); + return this.BOSEconomy.setBankMoney(bank, IntAmount, true); + } + + 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 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); + } + } }
\ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java index 3b0f53c4d..288e4a5c5 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java @@ -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 BOSEconomy getPlugin() { - return this.BOSEconomy; - } - - public String getName() { - return "BOSEconomy"; - } - - public String getVersion() { - return "0.7.0"; - } - - public String format(double amount) { - String currency = this.BOSEconomy.getMoneyNamePlural(); - if(amount == 1) currency = this.BOSEconomy.getMoneyName(); - return amount + " " + currency; - } - - public boolean hasBanks() { - return true; - } - - public boolean hasBank(String bank) { - return this.BOSEconomy.bankExists(bank); - } - - public boolean hasAccount(String name) { - return this.BOSEconomy.playerRegistered(name, false); - } - - public boolean hasBankAccount(String bank, String name) { - return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name); - } - - public MethodAccount getAccount(String name) { - if(!hasAccount(name)) return null; - return new BOSEAccount(name, this.BOSEconomy); - } - - public MethodBankAccount getBankAccount(String bank, String name) { - if(!hasBankAccount(bank, name)) return null; - return new BOSEBankAccount(bank, BOSEconomy); - } - - public boolean isCompatible(Plugin plugin) { - return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && !plugin.getDescription().getVersion().equals("0.6.2"); - } - - public void setPlugin(Plugin plugin) { - BOSEconomy = (BOSEconomy)plugin; - } - - public class BOSEAccount implements MethodAccount { - private String name; - private BOSEconomy BOSEconomy; - - public BOSEAccount(String name, BOSEconomy bOSEconomy) { - this.name = name; - this.BOSEconomy = bOSEconomy; - } - - public double balance() { - return this.BOSEconomy.getPlayerMoneyDouble(this.name); - } - - public boolean set(double amount) { - return this.BOSEconomy.setPlayerMoney(this.name, amount, false); - } - - 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 boolean multiply(double amount) { - double balance = this.balance(); - return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false); - } - - public boolean divide(double amount) { - double balance = this.balance(); - return this.BOSEconomy.setPlayerMoney(this.name, (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 false; - } - } - - public class BOSEBankAccount implements MethodBankAccount { - private String bank; - private BOSEconomy BOSEconomy; - - public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) { - this.bank = bank; - this.BOSEconomy = bOSEconomy; - } - - public String getBankName() { - return this.bank; - } - - public int getBankId() { - return -1; - } - - public double balance() { - return this.BOSEconomy.getBankMoneyDouble(bank); - } - - 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 boolean subtract(double amount) { - double balance = this.balance(); - return this.BOSEconomy.setBankMoney(bank, (balance - amount), false); - } - - 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); - } - } +public class BOSE7 implements Method +{ + private BOSEconomy BOSEconomy; + + public BOSEconomy getPlugin() + { + return this.BOSEconomy; + } + + public String getName() + { + return "BOSEconomy"; + } + + 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 boolean hasBanks() + { + return true; + } + + public boolean hasBank(String bank) + { + return this.BOSEconomy.bankExists(bank); + } + + public boolean hasAccount(String name) + { + return this.BOSEconomy.playerRegistered(name, false); + } + + public boolean hasBankAccount(String bank, String name) + { + return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name); + } + + public MethodAccount getAccount(String name) + { + if (!hasAccount(name)) + { + return null; + } + + return new BOSEAccount(name, this.BOSEconomy); + } + + public MethodBankAccount getBankAccount(String bank, String name) + { + if (!hasBankAccount(bank, name)) + { + return null; + } + + return new BOSEBankAccount(bank, BOSEconomy); + } + + public boolean isCompatible(Plugin plugin) + { + return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") + && plugin instanceof BOSEconomy + && !plugin.getDescription().getVersion().equals("0.6.2"); + } + + public void setPlugin(Plugin plugin) + { + BOSEconomy = (BOSEconomy)plugin; + } + + + public class BOSEAccount implements MethodAccount + { + private String name; + private BOSEconomy BOSEconomy; + + public BOSEAccount(String name, BOSEconomy bOSEconomy) + { + this.name = name; + this.BOSEconomy = bOSEconomy; + } + + public double balance() + { + return this.BOSEconomy.getPlayerMoneyDouble(this.name); + } + + public boolean set(double amount) + { + return this.BOSEconomy.setPlayerMoney(this.name, amount, false); + } + + 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 boolean multiply(double amount) + { + double balance = this.balance(); + return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false); + } + + public boolean divide(double amount) + { + double balance = this.balance(); + return this.BOSEconomy.setPlayerMoney(this.name, (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 false; + } + } + + + public class BOSEBankAccount implements MethodBankAccount + { + private String bank; + private BOSEconomy BOSEconomy; + + public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) + { + this.bank = bank; + this.BOSEconomy = bOSEconomy; + } + + public String getBankName() + { + return this.bank; + } + + public int getBankId() + { + return -1; + } + + public double balance() + { + return this.BOSEconomy.getBankMoneyDouble(bank); + } + + 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 boolean subtract(double amount) + { + double balance = this.balance(); + return this.BOSEconomy.setBankMoney(bank, (balance - amount), false); + } + + 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); + } + } }
\ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java index 8ea709c19..6248b1b91 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java @@ -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 Object getPlugin() { - return this.currencyList; - } - - public String getName() { - return "MultiCurrency"; - } - - public String getVersion() { - return "0.09"; - } - - public String format(double amount) { - return amount + " Currency"; - } - - public boolean hasBanks() { - return false; - } - - public boolean hasBank(String bank) { - return false; - } - - public boolean hasAccount(String name) { - return true; - } - - public boolean hasBankAccount(String bank, String name) { - return false; - } - - public MethodAccount getAccount(String name) { - return new MCurrencyAccount(name); - } - - public MethodBankAccount getBankAccount(String bank, String name) { - return null; - } - - public boolean isCompatible(Plugin plugin) { - return plugin.getDescription().getName().equalsIgnoreCase(getName()) && plugin instanceof Currency; - } - - public void setPlugin(Plugin plugin) { - currencyList = (Currency) plugin; - } - - public class MCurrencyAccount implements MethodAccount{ - private String name; - - public MCurrencyAccount(String name) { - this.name = name; - } - - public double balance() { - return CurrencyList.getValue((String) CurrencyList.maxCurrency(name)[0], name); - } - - public boolean set(double amount) { - CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, amount); - return true; - } - - public boolean add(double amount) { - return CurrencyList.add(name, amount); - } - - public boolean subtract(double amount) { - return CurrencyList.subtract(name, amount); - } - - public boolean multiply(double amount) { - return CurrencyList.multiply(name, amount); - } - - public boolean divide(double amount) { - return CurrencyList.divide(name, amount); - } - - public boolean hasEnough(double amount) { - return CurrencyList.hasEnough(name, amount); - } - - public boolean hasOver(double amount) { - return CurrencyList.hasOver(name, amount); - } - - public boolean hasUnder(double amount) { - return CurrencyList.hasUnder(name, amount); - } - - public boolean isNegative() { - return CurrencyList.isNegative(name); - } - - public boolean remove() { - return CurrencyList.remove(name); - } - } +public class MCUR implements Method +{ + private Currency currencyList; + + public Object getPlugin() + { + return this.currencyList; + } + + public String getName() + { + return "MultiCurrency"; + } + + public String getVersion() + { + return "0.09"; + } + + public int fractionalDigits() + { + return -1; + } + + public String format(double amount) + { + return amount + " Currency"; + } + + public boolean hasBanks() + { + return false; + } + + public boolean hasBank(String bank) + { + return false; + } + + public boolean hasAccount(String name) + { + return true; + } + + public boolean hasBankAccount(String bank, String name) + { + return false; + } + + public MethodAccount getAccount(String name) + { + return new MCurrencyAccount(name); + } + + public MethodBankAccount getBankAccount(String bank, String name) + { + return null; + } + + public boolean isCompatible(Plugin plugin) + { + return (plugin.getDescription().getName().equalsIgnoreCase("Currency") + || plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency")) + && plugin instanceof Currency; + } + + public void setPlugin(Plugin plugin) + { + currencyList = (Currency)plugin; + } + + + public class MCurrencyAccount implements MethodAccount + { + private String name; + + public MCurrencyAccount(String name) + { + this.name = name; + } + + public double balance() + { + return CurrencyList.getValue((String)CurrencyList.maxCurrency(name)[0], name); + } + + public boolean set(double amount) + { + CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, amount); + return true; + } + + public boolean add(double amount) + { + return CurrencyList.add(name, amount); + } + + public boolean subtract(double amount) + { + return CurrencyList.subtract(name, amount); + } + + public boolean multiply(double amount) + { + return CurrencyList.multiply(name, amount); + } + + public boolean divide(double amount) + { + return CurrencyList.divide(name, amount); + } + + public boolean hasEnough(double amount) + { + return CurrencyList.hasEnough(name, amount); + } + + public boolean hasOver(double amount) + { + return CurrencyList.hasOver(name, amount); + } + + public boolean hasUnder(double amount) + { + return CurrencyList.hasUnder(name, amount); + } + + public boolean isNegative() + { + return CurrencyList.isNegative(name); + } + + public boolean remove() + { + return CurrencyList.remove(name); + } + } } diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java index 933959586..fcdb7c43b 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java @@ -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 iConomy getPlugin() { - return this.iConomy; - } - - public String getName() { - return "iConomy"; - } - - public String getVersion() { - return "4"; - } - - public String format(double amount) { - return this.iConomy.getBank().format(amount); - } - - public boolean hasBanks() { - return false; - } - - public boolean hasBank(String bank) { - return false; - } - - public boolean hasAccount(String name) { - return this.iConomy.getBank().hasAccount(name); - } - - public boolean hasBankAccount(String bank, String name) { - return false; - } - - public MethodAccount getAccount(String name) { - return new iCoAccount(this.iConomy.getBank().getAccount(name)); - } - - 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 void setPlugin(Plugin plugin) { - iConomy = (iConomy)plugin; - } - - public class iCoAccount implements MethodAccount { - private Account account; - - public iCoAccount(Account account) { - this.account = account; - } - - public Account getiCoAccount() { - return account; - } - - 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 boolean add(double amount) { - if(this.account == null) return false; - this.account.add(amount); - return true; - } - - public boolean subtract(double amount) { - if(this.account == null) return false; - this.account.subtract(amount); - return true; - } - - public boolean multiply(double amount) { - if(this.account == null) return false; - this.account.multiply(amount); - return true; - } - - public boolean divide(double amount) { - if(this.account == null) return false; - this.account.divide(amount); - 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; - } - } +public class iCo4 implements Method +{ + private iConomy iConomy; + + public iConomy getPlugin() + { + return this.iConomy; + } + + public String getName() + { + return "iConomy"; + } + + public String getVersion() + { + return "4"; + } + + public int fractionalDigits() + { + return 2; + } + + public String format(double amount) + { + return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount); + } + + public boolean hasBanks() + { + return false; + } + + public boolean hasBank(String bank) + { + return false; + } + + public boolean hasAccount(String name) + { + return com.nijiko.coelho.iConomy.iConomy.getBank().hasAccount(name); + } + + public boolean hasBankAccount(String bank, String name) + { + return false; + } + + public MethodAccount getAccount(String name) + { + return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name)); + } + + 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 void setPlugin(Plugin plugin) + { + iConomy = (iConomy)plugin; + } + + + public class iCoAccount implements MethodAccount + { + private Account account; + + public iCoAccount(Account account) + { + this.account = account; + } + + public Account getiCoAccount() + { + return account; + } + + 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 boolean add(double amount) + { + if (this.account == null) + { + return false; + } + this.account.add(amount); + return true; + } + + public boolean subtract(double amount) + { + if (this.account == null) + { + return false; + } + this.account.subtract(amount); + return true; + } + + public boolean multiply(double amount) + { + if (this.account == null) + { + return false; + } + this.account.multiply(amount); + return true; + } + + public boolean divide(double amount) + { + if (this.account == null) + { + return false; + } + this.account.divide(amount); + 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; + } + } } diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java index bcd6deb6d..462cb76d5 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java @@ -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) diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java index d890bc6df..b74367173 100644 --- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java +++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java @@ -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 iConomy getPlugin() { - return this.iConomy; - } - - public String getName() { - return "iConomy"; - } - - public String getVersion() { - return "6"; - } - - public String format(double amount) { - return this.iConomy.format(amount); - } - - public boolean hasBanks() { - return false; - } - - public boolean hasBank(String bank) { - return false; - } - - public boolean hasAccount(String name) { - return (new Accounts()).exists(name); - } - - public boolean hasBankAccount(String bank, String name) { - return false; - } - - public MethodAccount getAccount(String name) { - return new iCoAccount((new Accounts()).get(name)); - } - - public MethodBankAccount getBankAccount(String bank, String name) { - return null; - } - - public boolean isCompatible(Plugin plugin) { - try { Class.forName("com.iCo6.IO"); } - catch(Exception e) { return false; } - - 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 class iCoAccount implements MethodAccount { - private Account account; - private Holdings holdings; - - public iCoAccount(Account account) { - this.account = account; - this.holdings = account.getHoldings(); - } - - public Account getiCoAccount() { - return account; - } - - public double balance() { - return this.holdings.getBalance(); - } - - public boolean set(double amount) { - if(this.holdings == null) return false; - this.holdings.setBalance(amount); - return true; - } - - public boolean add(double amount) { - if(this.holdings == null) return false; - this.holdings.add(amount); - return true; - } - - public boolean subtract(double amount) { - if(this.holdings == null) return false; - this.holdings.subtract(amount); - return true; - } - - public boolean multiply(double amount) { - if(this.holdings == null) return false; - this.holdings.multiply(amount); - return true; - } - - public boolean divide(double amount) { - if(this.holdings == null) return false; - this.holdings.divide(amount); - return true; - } - - public boolean hasEnough(double amount) { - return this.holdings.hasEnough(amount); - } - - public boolean hasOver(double amount) { - return this.holdings.hasOver(amount); - } - - public boolean hasUnder(double amount) { - return this.holdings.hasUnder(amount); - } - - public boolean isNegative() { - return this.holdings.isNegative(); - } - - public boolean remove() { - if(this.account == null) return false; - this.account.remove(); - return true; - } - } +public class iCo6 implements Method +{ + private iConomy iConomy; + + public iConomy getPlugin() + { + return this.iConomy; + } + + public String getName() + { + return "iConomy"; + } + + public String getVersion() + { + return "6"; + } + + public int fractionalDigits() + { + return 2; + } + + public String format(double amount) + { + return com.iCo6.iConomy.format(amount); + } + + public boolean hasBanks() + { + return false; + } + + public boolean hasBank(String bank) + { + return false; + } + + public boolean hasAccount(String name) + { + return (new Accounts()).exists(name); + } + + public boolean hasBankAccount(String bank, String name) + { + return false; + } + + public MethodAccount getAccount(String name) + { + return new iCoAccount((new Accounts()).get(name)); + } + + 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.iCo6.iConomy") + && plugin instanceof iConomy; + } + + 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 Account getiCoAccount() + { + return account; + } + + public double balance() + { + return this.holdings.getBalance(); + } + + public boolean set(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.setBalance(amount); + return true; + } + + public boolean add(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.add(amount); + return true; + } + + public boolean subtract(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.subtract(amount); + return true; + } + + public boolean multiply(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.multiply(amount); + return true; + } + + public boolean divide(double amount) + { + if (this.holdings == null) + { + return false; + } + this.holdings.divide(amount); + return true; + } + + public boolean hasEnough(double amount) + { + return this.holdings.hasEnough(amount); + } + + public boolean hasOver(double amount) + { + return this.holdings.hasOver(amount); + } + + public boolean hasUnder(double amount) + { + return this.holdings.hasUnder(amount); + } + + public boolean isNegative() + { + return this.holdings.isNegative(); + } + + public boolean remove() + { + if (this.account == null) + { + return false; + } + this.account.remove(); + return true; + } + } } diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 6edf0244d..ee956b0fc 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -79,14 +79,11 @@ reclaim-onlogout: false # Should primitive spawn protection be enabled? For most servers, this should be flase; it is better to use a third-party plugin to protect it. spawn-protection: false -# Nether settings (switch between worlds with "/world nether" and "/world normal") -# Sets whether the nether system is enabled, what folder to save the world in, and whether portals should teleport players between worlds. +# Nether settings +# Sets wether you want to change the default behaviour of the nether portals. nether: - enabled: false - folder: nether portals-enabled: false generate-exit-portals: false - ratio: 16 # Mob limit on spawnmob spawnmob-limit: 10 @@ -422,6 +419,9 @@ protect: squid: false zombie: false wolf: false + cave_spider: false + enderman: false + silverfish: false # Maximum height the creeper should explode. -1 allows them to explode everywhere. # Set prevent.creeper-explosion to true, if you want to disable creeper explosions. diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index d90d788eb..c756d4384 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -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} diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index a9dc9c9a8..ea73ccc56 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -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} |