1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-26 06:09:15 +02:00

Merge branch 'essmaster' into groupmanager

This commit is contained in:
KHobbits
2011-10-04 09:43:34 +01:00
46 changed files with 1461 additions and 875 deletions

View File

@@ -188,6 +188,7 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this); pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this);
pm.registerEvent(Type.ENTITY_COMBUST, 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.ENTITY_DEATH, entityListener, Priority.Lowest, this);
pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this);
jail = new Jail(this); jail = new Jail(this);
final JailPlayerListener jailPlayerListener = new JailPlayerListener(this); final JailPlayerListener jailPlayerListener = new JailPlayerListener(this);

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials; package com.earth2me.essentials;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
@@ -93,7 +94,7 @@ public class EssentialsBlockListener extends BlockListener
return; return;
} }
boolean unlimitedForUser = user.hasUnlimited(is); boolean unlimitedForUser = user.hasUnlimited(is);
if (unlimitedForUser) if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
{ {
ess.scheduleSyncDelayedTask( ess.scheduleSyncDelayedTask(
new Runnable() new Runnable()

View File

@@ -8,6 +8,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityListener; import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -80,4 +81,15 @@ public class EssentialsEntityListener extends EntityListener
} }
} }
} }
@Override
public void onFoodLevelChange(FoodLevelChangeEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
//TODO: Remove the following line, when we're happy to remove backwards compatability with 1185.
event.setFoodLevel(20);
event.setCancelled(true);
}
}
} }

View File

@@ -46,11 +46,11 @@ public class EssentialsPlayerListener extends PlayerListener
public void onPlayerRespawn(final PlayerRespawnEvent event) public void onPlayerRespawn(final PlayerRespawnEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
user.setDisplayName(user.getNick()); user.setDisplayNick(user.getNick());
updateCompass(user); updateCompass(user);
if (ess.getSettings().changeDisplayName()) if (ess.getSettings().changeDisplayName())
{ {
user.setDisplayName(user.getNick()); user.setDisplayNick(user.getNick());
} }
} }
@@ -76,7 +76,7 @@ public class EssentialsPlayerListener extends PlayerListener
user.updateActivity(true); user.updateActivity(true);
if (ess.getSettings().changeDisplayName()) if (ess.getSettings().changeDisplayName())
{ {
user.setDisplayName(user.getNick()); user.setDisplayNick(user.getNick());
} }
} }
@@ -94,21 +94,15 @@ public class EssentialsPlayerListener extends PlayerListener
final Location from = event.getFrom(); final Location from = event.getFrom();
final Location to = event.getTo().clone(); final Location to = event.getTo().clone();
to.setX(from.getX()); to.setX(from.getX());
to.setY(from.getY()); to.setY(from.getBlock().getTypeId() == 0 ? from.getY() - 1 : from.getY());
to.setZ(from.getZ()); to.setZ(from.getZ());
try event.setTo(to);
{
event.setTo(Util.getSafeDestination(to));
}
catch (Exception ex)
{
event.setTo(to);
}
return; return;
} }
Location afk = user.getAfkPosition(); 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); user.updateActivity(true);
} }
@@ -268,7 +262,7 @@ public class EssentialsPlayerListener extends PlayerListener
if (ess.getSettings().changeDisplayName()) if (ess.getSettings().changeDisplayName())
{ {
user.setDisplayName(user.getNick()); user.setDisplayNick(user.getNick());
} }
user.updateActivity(false); user.updateActivity(false);
if (user.isAuthorized("essentials.sleepingignored")) if (user.isAuthorized("essentials.sleepingignored"))
@@ -307,20 +301,21 @@ public class EssentialsPlayerListener extends PlayerListener
{ {
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED) 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; return;
} }
User user = ess.getUser(event.getPlayer()); User user = ess.getUser(event.getPlayer());
user.setNPC(false); user.setNPC(false);
final long currentTime = System.currentTimeMillis(); final long currentTime = System.currentTimeMillis();
user.checkBanTimeout(currentTime); boolean banExpired = user.checkBanTimeout(currentTime);
user.checkMuteTimeout(currentTime); user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime); user.checkJailTimeout(currentTime);
if (user.isBanned()) if (banExpired == false && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
{ {
final String banReason = user.getBanReason(); 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; return;
} }
@@ -356,7 +351,7 @@ public class EssentialsPlayerListener extends PlayerListener
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().changeDisplayName()) if (ess.getSettings().changeDisplayName())
{ {
user.setDisplayName(user.getNick()); user.setDisplayNick(user.getNick());
} }
updateCompass(user); updateCompass(user);
} }

View File

@@ -21,10 +21,9 @@ public class EssentialsPluginListener extends ServerListener implements IConf
public void onPluginEnable(final PluginEnableEvent event) public void onPluginEnable(final PluginEnableEvent event)
{ {
ess.getPermissionsHandler().checkPermissions(); 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() + ")"); 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 // 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())) 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."); LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
} }
} }

View File

@@ -26,10 +26,6 @@ public class EssentialsTimer implements Runnable
onlineUsers.add(user); onlineUsers.add(user);
user.setLastOnlineActivity(currentTime); user.setLastOnlineActivity(currentTime);
user.checkActivity(); user.checkActivity();
// Food for god mode
if (user.isGodModeEnabled() && user.getFoodLevel() < 20) {
user.setFoodLevel(20);
}
} }
final Iterator<User> iterator = onlineUsers.iterator(); final Iterator<User> iterator = onlineUsers.iterator();

View File

@@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.BlockChangeDelegate; import org.bukkit.BlockChangeDelegate;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot; import org.bukkit.ChunkSnapshot;
import org.bukkit.Difficulty;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.TreeType; import org.bukkit.TreeType;
@@ -437,4 +438,21 @@ public class FakeWorld implements World
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public Difficulty getDifficulty()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setDifficulty(Difficulty difficulty)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getSeaLevel()
{
throw new UnsupportedOperationException("Not supported yet.");
}
} }

View File

@@ -73,7 +73,11 @@ public interface ISettings extends IConf
boolean getRespawnAtHome(); boolean getRespawnAtHome();
int getMultipleHomes(); List getMultipleHomes();
int getHomeLimit(String set);
int getHomeLimit(User user);
boolean getSortListByGroups(); boolean getSortListByGroups();

View File

@@ -26,11 +26,10 @@ public enum Mob
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER), SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID), SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE), ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
MONSTER("Monster", Enemies.ENEMY, CreatureType.MONSTER),
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF), WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF),
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER), CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
ENDERMAN("Enderman", Enemies.ENEMY, CreatureType.ENDERMAN), ENDERMAN("Enderman", Enemies.ENEMY, "", CreatureType.ENDERMAN),
SILVERFISH("Silverfish", Enemies.ENEMY, CreatureType.SILVERFISH); SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH);
public static final Logger logger = Logger.getLogger("Minecraft"); public static final Logger logger = Logger.getLogger("Minecraft");

View File

@@ -702,4 +702,27 @@ public class OfflinePlayer implements Player
throw new UnsupportedOperationException("Not supported yet."); 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.");
}
@Override
public void setPlayerListName(String name)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getPlayerListName()
{
throw new UnsupportedOperationException("Not supported yet.");
}
} }

View File

@@ -732,4 +732,28 @@ public class PlayerWrapper implements Player
return base.getBedSpawnLocation(); return base.getBedSpawnLocation();
} }
@Override
public boolean isSprinting()
{
return base.isSprinting();
}
@Override
public void setSprinting(boolean bln)
{
base.setSprinting(bln);
}
@Override
public void setPlayerListName(String name)
{
base.setPlayerListName(name);
}
@Override
public String getPlayerListName()
{
return base.getPlayerListName();
}
} }

View File

@@ -31,18 +31,46 @@ public class Settings implements ISettings
return config.getBoolean("respawn-at-home", false); return config.getBoolean("respawn-at-home", false);
} }
@Override
public int getMultipleHomes()
{
return config.getInt("multiple-homes", 5);
}
@Override @Override
public boolean getBedSetsHome() public boolean getBedSetsHome()
{ {
return config.getBoolean("bed-sethome", false); return config.getBoolean("bed-sethome", false);
} }
@Override
public List<String> getMultipleHomes()
{
return config.getKeys("sethome-multiple");
}
@Override
public int getHomeLimit(final User user)
{
final List<String> homeList = getMultipleHomes();
if (homeList == null)
{
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
// return getHomeLimit("default");
return config.getInt("multiple-homes", 5);
}
int limit = getHomeLimit("default");
for (String set : homeList)
{
logger.log(Level.INFO, "Found home set: " + set);
if (user.hasPermission("essentials.sethome.multiple." + set) && limit < getHomeLimit(set))
{
limit = getHomeLimit(set);
}
}
return limit;
}
@Override
public int getHomeLimit(final String set)
{
return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3));
}
@Override @Override
public int getChatRadius() public int getChatRadius()
{ {
@@ -84,7 +112,10 @@ public class Settings implements ISettings
{ {
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0))) for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
{ {
if (!c.equalsIgnoreCase(label)) continue; if (!c.equalsIgnoreCase(label))
{
continue;
}
return true; return true;
} }
return config.getBoolean("disable-" + label.toLowerCase(), false); return config.getBoolean("disable-" + label.toLowerCase(), false);
@@ -101,7 +132,10 @@ public class Settings implements ISettings
{ {
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0))) for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
{ {
if (!c.equalsIgnoreCase(label)) continue; if (!c.equalsIgnoreCase(label))
{
continue;
}
return true; return true;
} }
return config.getBoolean("restrict-" + label.toLowerCase(), false); return config.getBoolean("restrict-" + label.toLowerCase(), false);
@@ -112,7 +146,10 @@ public class Settings implements ISettings
{ {
for (String c : config.getStringList("player-commands", new ArrayList<String>(0))) for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
{ {
if (!c.equalsIgnoreCase(label)) continue; if (!c.equalsIgnoreCase(label))
{
continue;
}
return true; return true;
} }
return false; return false;
@@ -126,7 +163,9 @@ public class Settings implements ISettings
for (String c : config.getStringList("overridden-commands", defaultList)) for (String c : config.getStringList("overridden-commands", defaultList))
{ {
if (!c.equalsIgnoreCase(name)) if (!c.equalsIgnoreCase(name))
{
continue; continue;
}
return true; return true;
} }
return config.getBoolean("override-" + name.toLowerCase(), false); return config.getBoolean("override-" + name.toLowerCase(), false);
@@ -143,7 +182,9 @@ public class Settings implements ISettings
{ {
double cost = config.getDouble("command-costs." + label, 0.0); double cost = config.getDouble("command-costs." + label, 0.0);
if (cost == 0.0) if (cost == 0.0)
{
cost = config.getDouble("cost-" + label, 0.0); cost = config.getDouble("cost-" + label, 0.0);
}
return cost; return cost;
} }
@@ -171,7 +212,8 @@ public class Settings implements ISettings
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits"); Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
for (Map.Entry<String, Object> entry : kits.entrySet()) for (Map.Entry<String, Object> entry : kits.entrySet())
{ {
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_'))) { if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
{
return entry.getValue(); return entry.getValue();
} }
} }
@@ -190,9 +232,13 @@ public class Settings implements ISettings
String colorName = config.getString("ops-name-color", null); String colorName = config.getString("ops-name-color", null);
if (colorName == null) if (colorName == null)
{
return ChatColor.RED; return ChatColor.RED;
if("none".equalsIgnoreCase(colorName) || colorName.isEmpty()) }
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
{
throw new Exception(); throw new Exception();
}
try try
{ {
@@ -220,7 +266,7 @@ public class Settings implements ISettings
@Override @Override
public boolean isNetherEnabled() public boolean isNetherEnabled()
{ {
return config.getBoolean("nether.enabled", true); return config.getBoolean("nether.enabled", false);
} }
@Override @Override
@@ -236,7 +282,7 @@ public class Settings implements ISettings
} }
@Override @Override
public boolean hidePermissionlessHelp() public boolean hidePermissionlessHelp()
{ {
return config.getBoolean("hide-permissionless-help", true); return config.getBoolean("hide-permissionless-help", true);
} }
@@ -301,8 +347,9 @@ public class Settings implements ISettings
{ {
return config.getString("newbies.spawnpoint", "default"); return config.getString("newbies.spawnpoint", "default");
} }
@Override @Override
public boolean getPerWarpPermission() public boolean getPerWarpPermission()
{ {
return config.getBoolean("per-warp-permission", false); return config.getBoolean("per-warp-permission", false);
} }
@@ -314,7 +361,8 @@ public class Settings implements ISettings
} }
@Override @Override
public void reloadConfig() { public void reloadConfig()
{
config.load(); config.load();
} }
@@ -322,16 +370,21 @@ public class Settings implements ISettings
public List<Integer> itemSpawnBlacklist() public List<Integer> itemSpawnBlacklist()
{ {
final List<Integer> epItemSpwn = new ArrayList<Integer>(); final List<Integer> epItemSpwn = new ArrayList<Integer>();
for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) { for (String itemName : config.getString("item-spawn-blacklist", "").split(","))
{
itemName = itemName.trim(); itemName = itemName.trim();
if (itemName.isEmpty()) { if (itemName.isEmpty())
{
continue; continue;
} }
ItemStack is; ItemStack is;
try { try
{
is = ess.getItemDb().get(itemName); is = ess.getItemDb().get(itemName);
epItemSpwn.add(is.getTypeId()); epItemSpwn.add(is.getTypeId());
} catch (Exception ex) { }
catch (Exception ex)
{
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist")); logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
} }
} }
@@ -359,10 +412,11 @@ public class Settings implements ISettings
@Override @Override
public double getNetherRatio() public double getNetherRatio()
{ {
if (config.getBoolean("nether.use-1to1-ratio", false)) { if (config.getBoolean("nether.use-1to1-ratio", false))
{
return 1.0; return 1.0;
} }
return config.getDouble("nether.ratio", 16.0); return config.getDouble("nether.ratio", 8.0);
} }
@Override @Override
@@ -374,7 +428,7 @@ public class Settings implements ISettings
@Override @Override
public boolean warnOnSmite() public boolean warnOnSmite()
{ {
return config.getBoolean("warn-on-smite" ,true); return config.getBoolean("warn-on-smite", true);
} }
@Override @Override
@@ -410,23 +464,28 @@ public class Settings implements ISettings
@Override @Override
public boolean getProtectPreventSpawn(final String creatureName) public boolean getProtectPreventSpawn(final String creatureName)
{ {
return config.getBoolean("protect.prevent.spawn."+creatureName, false); return config.getBoolean("protect.prevent.spawn." + creatureName, false);
} }
@Override @Override
public List<Integer> getProtectList(final String configName) public List<Integer> getProtectList(final String configName)
{ {
final List<Integer> list = new ArrayList<Integer>(); final List<Integer> list = new ArrayList<Integer>();
for (String itemName : config.getString(configName, "").split(",")) { for (String itemName : config.getString(configName, "").split(","))
{
itemName = itemName.trim(); itemName = itemName.trim();
if (itemName.isEmpty()) { if (itemName.isEmpty())
{
continue; continue;
} }
ItemStack itemStack; ItemStack itemStack;
try { try
{
itemStack = ess.getItemDb().get(itemName); itemStack = ess.getItemDb().get(itemName);
list.add(itemStack.getTypeId()); list.add(itemStack.getTypeId());
} catch (Exception ex) { }
catch (Exception ex)
{
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName)); logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
} }
} }
@@ -444,12 +503,13 @@ public class Settings implements ISettings
{ {
return config.getBoolean(configName, def); return config.getBoolean(configName, def);
} }
private final static double MAXMONEY = 10000000000000.0; private final static double MAXMONEY = 10000000000000.0;
public double getMaxMoney() public double getMaxMoney()
{ {
double max = config.getDouble("max-money", MAXMONEY); double max = config.getDouble("max-money", MAXMONEY);
if (Math.abs(max) > MAXMONEY) { if (Math.abs(max) > MAXMONEY)
{
max = max < 0 ? -MAXMONEY : MAXMONEY; max = max < 0 ? -MAXMONEY : MAXMONEY;
} }
return max; return max;

View File

@@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
/** /**
* Original authors: toi & Raphfrk * Original authors: toi & Raphfrk
*/ */
@Deprecated
public class TargetBlock public class TargetBlock
{ {
private transient final Location location; private transient final Location location;

View File

@@ -20,14 +20,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private transient long lastOnlineActivity; private transient long lastOnlineActivity;
private transient long lastActivity = System.currentTimeMillis(); private transient long lastActivity = System.currentTimeMillis();
private boolean hidden = false; private boolean hidden = false;
private transient boolean godStateBeforeAfk;
private transient Location afkPosition; private transient Location afkPosition;
User(final Player base, final IEssentials ess) User(final Player base, final IEssentials ess)
{ {
super(base, ess); super(base, ess);
teleport = new Teleport(this, ess); teleport = new Teleport(this, ess);
godStateBeforeAfk = isGodModeEnabled();
afkPosition = getLocation(); afkPosition = getLocation();
} }
@@ -285,6 +283,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return nickname.toString(); return nickname.toString();
} }
public void setDisplayNick(String name)
{
setDisplayName(name);
setPlayerListName(name);
}
public Teleport getTeleport() public Teleport getTeleport()
{ {
return teleport; return teleport;
@@ -348,15 +352,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public void setAfk(final boolean set) public void setAfk(final boolean set)
{ {
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : 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()) { if (set && !isAfk()) {
afkPosition = getLocation(); afkPosition = getLocation();
} }
@@ -381,7 +376,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
this.hidden = hidden; 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()) if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
{ {
@@ -396,26 +392,34 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
catch (Exception ex) 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()) if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
{ {
setMuteTimeout(0); setMuteTimeout(0);
sendMessage(Util.i18n("canTalkAgain")); sendMessage(Util.i18n("canTalkAgain"));
setMuted(false); 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()) if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
{ {
setBanTimeout(0); setBanTimeout(0);
setBanned(false); setBanned(false);
return true;
} }
return false;
} }
public void updateActivity(final boolean broadcast) public void updateActivity(final boolean broadcast)
@@ -451,7 +455,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
} }
} }
final long autoafk = ess.getSettings().getAutoAfk(); 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); setAfk(true);
if (!isHidden()) { if (!isHidden()) {
@@ -464,4 +468,19 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{ {
return afkPosition; return afkPosition;
} }
@Override
public boolean toggleGodModeEnabled()
{
if (!isGodModeEnabled()) {
setFoodLevel(20);
}
return super.toggleGodModeEnabled();
}
@Override
public boolean isGodModeEnabled()
{
return super.isGodModeEnabled() || (isAfk() && ess.getSettings().getFreezeAfkPlayers());
}
} }

View File

@@ -58,6 +58,7 @@ public abstract class UserData extends PlayerExtension implements IConf
isSocialSpyEnabled = _isSocialSpyEnabled(); isSocialSpyEnabled = _isSocialSpyEnabled();
isNPC = _isNPC(); isNPC = _isNPC();
arePowerToolsEnabled = _arePowerToolsEnabled(); arePowerToolsEnabled = _arePowerToolsEnabled();
kitTimestamps = _getKitTimestamps();
} }
private double money; private double money;
@@ -154,6 +155,8 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setHome(String name, Location loc) public void setHome(String name, Location loc)
{ {
//Invalid names will corrupt the yaml
name = Util.sanitizeFileName(name);
homes.put(name, loc); homes.put(name, loc);
config.setProperty("homes." + name, loc); config.setProperty("homes." + name, loc);
config.save(); config.save();
@@ -161,7 +164,12 @@ public abstract class UserData extends PlayerExtension implements IConf
public void delHome(String name) throws Exception 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); homes.remove(name);
config.removeProperty("homes." + name); config.removeProperty("homes." + name);
@@ -241,7 +249,8 @@ public abstract class UserData extends PlayerExtension implements IConf
} }
public void clearAllPowertools() { public void clearAllPowertools()
{
powertools.clear(); powertools.clear();
config.setProperty("powertools", powertools); config.setProperty("powertools", powertools);
config.save(); config.save();
@@ -270,7 +279,6 @@ public abstract class UserData extends PlayerExtension implements IConf
{ {
return powertools.size() > 0; return powertools.size() > 0;
} }
private Location lastLocation; private Location lastLocation;
private Location _getLastLocation() private Location _getLastLocation()
@@ -292,6 +300,10 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setLastLocation(Location loc) public void setLastLocation(Location loc)
{ {
if (loc == null || loc.getWorld() == null)
{
return;
}
lastLocation = loc; lastLocation = loc;
config.setProperty("lastlocation", loc); config.setProperty("lastlocation", loc);
config.save(); config.save();
@@ -779,7 +791,6 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("npc", set); config.setProperty("npc", set);
config.save(); config.save();
} }
private boolean arePowerToolsEnabled; private boolean arePowerToolsEnabled;
public boolean arePowerToolsEnabled() public boolean arePowerToolsEnabled()
@@ -805,5 +816,32 @@ public abstract class UserData extends PlayerExtension implements IConf
{ {
return config.getBoolean("powertoolsenabled", true); 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();
}
} }

View File

@@ -227,30 +227,36 @@ public class Util
AIR_MATERIALS.add(Material.SAPLING.getId()); AIR_MATERIALS.add(Material.SAPLING.getId());
AIR_MATERIALS.add(Material.POWERED_RAIL.getId()); AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId()); AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId());
AIR_MATERIALS.add(Material.LONG_GRASS.getId());
AIR_MATERIALS.add(Material.DEAD_BUSH.getId()); AIR_MATERIALS.add(Material.DEAD_BUSH.getId());
AIR_MATERIALS.add(Material.RAILS.getId());
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId()); AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
AIR_MATERIALS.add(Material.RED_ROSE.getId()); AIR_MATERIALS.add(Material.RED_ROSE.getId());
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId()); AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
AIR_MATERIALS.add(Material.TORCH.getId());
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
AIR_MATERIALS.add(Material.SEEDS.getId()); AIR_MATERIALS.add(Material.SEEDS.getId());
AIR_MATERIALS.add(Material.SIGN_POST.getId()); AIR_MATERIALS.add(Material.SIGN_POST.getId());
AIR_MATERIALS.add(Material.WALL_SIGN.getId()); AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
AIR_MATERIALS.add(Material.LADDER.getId()); AIR_MATERIALS.add(Material.LADDER.getId());
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId()); AIR_MATERIALS.add(Material.RAILS.getId());
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId()); AIR_MATERIALS.add(Material.WALL_SIGN.getId());
AIR_MATERIALS.add(Material.LEVER.getId());
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId()); AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId()); AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
AIR_MATERIALS.add(Material.TORCH.getId()); AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
AIR_MATERIALS.add(Material.SOIL.getId()); AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId()); AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId()); AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
AIR_MATERIALS.add(Material.TRAP_DOOR.getId()); AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
AIR_MATERIALS.add(Material.STONE_BUTTON.getId()); AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
AIR_MATERIALS.add(Material.STONE_PLATE.getId()); AIR_MATERIALS.add(Material.MELON_STEM.getId());
AIR_MATERIALS.add(Material.WOOD_PLATE.getId()); AIR_MATERIALS.add(Material.VINE.getId());
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId()); //TODO: Add 1.9 materials
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
} }
public static Location getSafeDestination(final Location loc) throws Exception public static Location getSafeDestination(final Location loc) throws Exception
@@ -260,9 +266,9 @@ public class Util
throw new Exception(Util.i18n("destinationNotSet")); throw new Exception(Util.i18n("destinationNotSet"));
} }
final World world = loc.getWorld(); final World world = loc.getWorld();
int x = (int)Math.round(loc.getX()); int x = loc.getBlockX();
int y = (int)Math.round(loc.getY()); int y = (int)Math.round(loc.getY());
int z = (int)Math.round(loc.getZ()); int z = loc.getBlockZ();
while (isBlockAboveAir(world, x, y, z)) while (isBlockAboveAir(world, x, y, z))
{ {

View File

@@ -31,7 +31,7 @@ public class Commanddelhome extends EssentialsCommand
} }
else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others"))) 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]; name = args[1];
} }
else else

View File

@@ -34,6 +34,7 @@ public class Commandheal extends EssentialsCommand
user.healCooldown(); user.healCooldown();
} }
user.setHealth(20); user.setHealth(20);
user.setFoodLevel(20);
user.sendMessage(Util.i18n("heal")); user.sendMessage(Util.i18n("heal"));
} }

View File

@@ -45,18 +45,18 @@ public class Commandhome extends EssentialsCommand
catch (NotEnoughArgumentsException e) catch (NotEnoughArgumentsException e)
{ {
List<String> homes = u.getHomes(); 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")); 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); user.getTeleport().home(u, homes.get(0), charge);
} }
else if (ess.getSettings().spawnIfNoHome())
{
user.getTeleport().respawn(ess.getSpawn(), charge);
}
else else
{ {
user.sendMessage(Util.format("homes", Util.joinList(homes))); user.sendMessage(Util.format("homes", Util.joinList(homes)));

View File

@@ -49,5 +49,6 @@ public class Commandinvsee extends EssentialsCommand
user.getInventory().setContents(invUserStack); user.getInventory().setContents(invUserStack);
user.sendMessage(Util.format("invSee", invUser.getDisplayName())); user.sendMessage(Util.format("invSee", invUser.getDisplayName()));
user.sendMessage(Util.i18n("invSeeHelp")); user.sendMessage(Util.i18n("invSeeHelp"));
throw new NoChargeException();
} }
} }

View File

@@ -15,22 +15,20 @@ import org.bukkit.inventory.ItemStack;
public class Commandkit extends EssentialsCommand public class Commandkit extends EssentialsCommand
{ {
static private final Map<User, Map<String, Long>> kitPlayers = new HashMap<User, Map<String, Long>>();
public Commandkit() public Commandkit()
{ {
super("kit"); super("kit");
} }
@Override @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) if (args.length < 1)
{ {
try try
{ {
Map<String, Object> kits = ess.getSettings().getKits(); final Map<String, Object> kits = ess.getSettings().getKits();
StringBuilder list = new StringBuilder(); final StringBuilder list = new StringBuilder();
for (String k : kits.keySet()) for (String k : kits.keySet())
{ {
if (user.isAuthorized("essentials.kit." + k.toLowerCase())) if (user.isAuthorized("essentials.kit." + k.toLowerCase()))
@@ -56,8 +54,8 @@ public class Commandkit extends EssentialsCommand
{ {
try try
{ {
String kitName = args[0].toLowerCase(); final String kitName = args[0].toLowerCase();
Object kit = ess.getSettings().getKit(kitName); final Object kit = ess.getSettings().getKit(kitName);
List<String> items; List<String> items;
if (!user.isAuthorized("essentials.kit." + kitName)) if (!user.isAuthorized("essentials.kit." + kitName))
@@ -70,39 +68,26 @@ public class Commandkit extends EssentialsCommand
{ {
//System.out.println("Kit is timed"); //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"); items = (List<String>)els.get("items");
double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L; final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
Calendar c = new GregorianCalendar(); final Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, (int)delay); c.add(Calendar.SECOND, -(int)delay);
c.add(Calendar.MILLISECOND, (int)((delay*1000.0)%1000.0)); c.add(Calendar.MILLISECOND, -(int)((delay*1000.0)%1000.0));
long time = c.getTimeInMillis(); final long mintime = c.getTimeInMillis();
Calendar now = new GregorianCalendar();
Map<String, Long> kitTimes; final Long lastTime = user.getKitTimestamp(kitName);
if (!kitPlayers.containsKey(user)) if (lastTime == null || lastTime < mintime) {
{ final Calendar now = new GregorianCalendar();
kitTimes = new HashMap<String, Long>(); user.setKitTimestamp(kitName, now.getTimeInMillis());
kitTimes.put(kitName, time); } else {
kitPlayers.put(user, kitTimes); final Calendar future = new GregorianCalendar();
} future.setTimeInMillis(lastTime);
else future.add(Calendar.SECOND, (int)delay);
{ future.add(Calendar.MILLISECOND, (int)((delay*1000.0)%1000.0));
kitTimes = kitPlayers.get(user); user.sendMessage(Util.format("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
if (!kitTimes.containsKey(kitName)) return;
{
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;
}
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -110,7 +95,7 @@ public class Commandkit extends EssentialsCommand
items = (List<String>)kit; items = (List<String>)kit;
} }
Trade charge = new Trade("kit-" + kitName, ess); final Trade charge = new Trade("kit-" + kitName, ess);
try try
{ {
charge.isAffordableFor(user); charge.isAffordableFor(user);
@@ -124,11 +109,11 @@ public class Commandkit extends EssentialsCommand
boolean spew = false; boolean spew = false;
for (String d : items) for (String d : items)
{ {
String[] parts = d.split("[^0-9]+", 3); final String[] parts = d.split("[^0-9]+", 3);
int id = Material.getMaterial(Integer.parseInt(parts[0])).getId(); final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1; final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0; final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data)); final HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
for (ItemStack itemStack : overfilled.values()) for (ItemStack itemStack : overfilled.values())
{ {
user.getWorld().dropItemNaturally(user.getLocation(), itemStack); user.getWorld().dropItemNaturally(user.getLocation(), itemStack);

View File

@@ -23,13 +23,15 @@ public class Commandmail extends EssentialsCommand
List<String> mail = user.getMails(); List<String> mail = user.getMails();
if (mail.isEmpty()) if (mail.isEmpty())
{ {
throw new Exception(Util.i18n("noMail")); user.sendMessage(Util.i18n("noMail"));
throw new NoChargeException();
} }
for (String s : mail) for (String s : mail)
{ {
user.sendMessage(s); user.sendMessage(s);
} }
throw new Exception(Util.i18n("mailClear")); user.sendMessage(Util.i18n("mailClear"));
return;
} }
if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{ {
@@ -62,7 +64,8 @@ public class Commandmail extends EssentialsCommand
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{ {
user.setMails(null); user.setMails(null);
throw new Exception(Util.i18n("mailCleared")); user.sendMessage(Util.i18n("mailCleared"));
return;
} }
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }

View File

@@ -41,7 +41,7 @@ public class Commandnick extends EssentialsCommand
String nick = args[0]; String nick = args[0];
if ("off".equalsIgnoreCase(nick) || user.getName().equalsIgnoreCase(nick)) if ("off".equalsIgnoreCase(nick) || user.getName().equalsIgnoreCase(nick))
{ {
user.setDisplayName(user.getName()); user.setDisplayNick(user.getName());
user.setNickname(null); user.setNickname(null);
user.sendMessage(Util.i18n("nickNoMore")); user.sendMessage(Util.i18n("nickNoMore"));
return; return;
@@ -67,7 +67,7 @@ public class Commandnick extends EssentialsCommand
} }
} }
user.setDisplayName(ess.getSettings().getNicknamePrefix() + nick); user.setDisplayNick(ess.getSettings().getNicknamePrefix() + nick);
user.setNickname(nick); user.setNickname(nick);
user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7.")); user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7."));
} }
@@ -95,13 +95,13 @@ public class Commandnick extends EssentialsCommand
String nick = args[1]; String nick = args[1];
if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick)) if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick))
{ {
target.setDisplayName(target.getName()); target.setDisplayNick(target.getName());
target.setNickname(null); target.setNickname(null);
target.sendMessage(Util.i18n("nickNoMore")); target.sendMessage(Util.i18n("nickNoMore"));
} }
else else
{ {
target.setDisplayName(ess.getSettings().getNicknamePrefix() + nick); target.setDisplayNick(ess.getSettings().getNicknamePrefix() + nick);
target.setNickname(nick); target.setNickname(nick);
target.sendMessage(Util.format("nickSet", target.getDisplayName() + "§7.")); target.sendMessage(Util.format("nickSet", target.getDisplayName() + "§7."));
} }

View File

@@ -11,7 +11,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import org.bukkit.ChatColor;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -104,17 +103,19 @@ public class Commandptime extends EssentialsCommand
for (User user : users) for (User user : users)
{ {
if(user.getPlayerTimeOffset() == 0) if (user.getPlayerTimeOffset() == 0)
{ {
sender.sendMessage(Util.format("pTimeNormal", user.getName())); sender.sendMessage(Util.format("pTimeNormal", user.getName()));
} }
else { else
{
String time = DescParseTickFormat.format(user.getPlayerTime()); String time = DescParseTickFormat.format(user.getPlayerTime());
if(!user.isPlayerTimeRelative()) if (!user.isPlayerTimeRelative())
{ {
sender.sendMessage(Util.format("pTimeCurrentFixed", user.getName(), time)); sender.sendMessage(Util.format("pTimeCurrentFixed", user.getName(), time));
} }
else { else
{
sender.sendMessage(Util.format("pTimeCurrent", user.getName(), time)); sender.sendMessage(Util.format("pTimeCurrent", user.getName(), time));
} }
} }
@@ -177,7 +178,8 @@ public class Commandptime extends EssentialsCommand
{ {
sender.sendMessage(Util.format("pTimeSetFixed", time, msg.toString())); sender.sendMessage(Util.format("pTimeSetFixed", time, msg.toString()));
} }
else { else
{
sender.sendMessage(Util.format("pTimeSet", time, msg.toString())); sender.sendMessage(Util.format("pTimeSet", time, msg.toString()));
} }
} }

View File

@@ -28,14 +28,14 @@ public class Commandsethome extends EssentialsCommand
{ {
if (user.isAuthorized("essentials.sethome.multiple")) if (user.isAuthorized("essentials.sethome.multiple"))
{ {
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getMultipleHomes()) if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
|| (user.getHomes().contains(args[0].toLowerCase()))) || (user.getHomes().contains(args[0].toLowerCase())))
{ {
user.setHome(args[0].toLowerCase()); user.setHome(args[0].toLowerCase());
} }
else else
{ {
throw new Exception(Util.format("maxHomes", ess.getSettings().getMultipleHomes())); throw new Exception(Util.format("maxHomes", ess.getSettings().getHomeLimit(user)));
} }
} }

View File

@@ -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; Entity spawnedMob = null;
Mob mob = null; Mob mob = null;
@@ -72,6 +67,12 @@ public class Commandspawnmob extends EssentialsCommand
{ {
throw new Exception(Util.i18n("invalidMob")); throw new Exception(Util.i18n("invalidMob"));
} }
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase()))
{
throw new Exception(Util.i18n("unableToSpawnMob"));
}
int[] ignore = int[] ignore =
{ {
8, 9 8, 9
@@ -79,8 +80,7 @@ public class Commandspawnmob extends EssentialsCommand
Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock(); Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock();
if (block == null) if (block == null)
{ {
user.sendMessage(Util.i18n("unableToSpawnMob")); throw new Exception(Util.i18n("unableToSpawnMob"));
return;
} }
Location loc = block.getLocation(); Location loc = block.getLocation();
Location sloc = Util.getSafeDestination(loc); Location sloc = Util.getSafeDestination(loc);
@@ -90,8 +90,7 @@ public class Commandspawnmob extends EssentialsCommand
} }
catch (MobException e) catch (MobException e)
{ {
user.sendMessage(Util.i18n("unableToSpawnMob")); throw new Exception(Util.i18n("unableToSpawnMob"));
return;
} }
if (mountType != null) if (mountType != null)
@@ -102,14 +101,18 @@ public class Commandspawnmob extends EssentialsCommand
user.sendMessage(Util.i18n("invalidMob")); user.sendMessage(Util.i18n("invalidMob"));
return; return;
} }
if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase()))
{
throw new Exception(Util.i18n("unableToSpawnMob"));
}
try try
{ {
spawnedMount = mobMount.spawn(user, server, loc); spawnedMount = mobMount.spawn(user, server, loc);
} }
catch (MobException e) catch (MobException e)
{ {
user.sendMessage(Util.i18n("unableToSpawnMob")); throw new Exception(Util.i18n("unableToSpawnMob"));
return;
} }
spawnedMob.setPassenger(spawnedMount); spawnedMob.setPassenger(spawnedMount);
} }
@@ -144,8 +147,7 @@ public class Commandspawnmob extends EssentialsCommand
} }
catch (MobException e) catch (MobException e)
{ {
user.sendMessage(Util.i18n("unableToSpawnMob")); throw new Exception(Util.i18n("unableToSpawnMob"));
return;
} }
spawnedMob.setPassenger(spawnedMount); spawnedMob.setPassenger(spawnedMount);
} }

View File

@@ -25,7 +25,7 @@ public class Commandtime extends EssentialsCommand
{ {
worldSelector = args[1]; 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 no arguments we are reading the time
if (args.length == 0) if (args.length == 0)
@@ -34,7 +34,7 @@ public class Commandtime extends EssentialsCommand
return; return;
} }
User user = ess.getUser(sender); final User user = ess.getUser(sender);
if (user != null && !user.isAuthorized("essentials.time.set")) if (user != null && !user.isAuthorized("essentials.time.set"))
{ {
user.sendMessage(Util.i18n("timeSetPermission")); user.sendMessage(Util.i18n("timeSetPermission"));

View File

@@ -21,11 +21,9 @@ public class Commandunban extends EssentialsCommand
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
String name;
try try
{ {
User u = getPlayer(server, args, 0, true); final User u = getPlayer(server, args, 0, true);
name = u.getName();
u.setBanned(false); u.setBanned(false);
sender.sendMessage(Util.i18n("unbannedPlayer")); sender.sendMessage(Util.i18n("unbannedPlayer"));
} }

View File

@@ -3,17 +3,20 @@ package com.earth2me.essentials.perm;
import de.bananaco.permissions.Permissions; import de.bananaco.permissions.Permissions;
import de.bananaco.permissions.interfaces.PermissionSet; import de.bananaco.permissions.interfaces.PermissionSet;
import de.bananaco.permissions.worlds.WorldPermissionsManager; import de.bananaco.permissions.worlds.WorldPermissionsManager;
import de.bananaco.permissions.info.InfoReader;
import java.util.List; import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class BPermissionsHandler extends SuperpermsHandler public class BPermissionsHandler implements IPermissionsHandler
{ {
private final transient WorldPermissionsManager wpm; private final transient WorldPermissionsManager wpm;
private final transient InfoReader info;
public BPermissionsHandler() public BPermissionsHandler()
{ {
wpm = Permissions.getWorldPermissionsManager(); wpm = Permissions.getWorldPermissionsManager();
info = new InfoReader();
info.instantiate();
} }
@Override @Override
@@ -48,4 +51,28 @@ public class BPermissionsHandler extends SuperpermsHandler
} }
return groups.contains(group); 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);
}
} }

View File

@@ -74,4 +74,10 @@ public class PermissionsBukkitHandler extends SuperpermsHandler
} }
return false; return false;
} }
@Override
public boolean canBuild(Player base, String group)
{
return base.hasPermission("essentials.build") || base.hasPermission("permissions.build");
}
} }

View File

@@ -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) * @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright Copyright (C) 2011 * @copyright Copyright (C) 2011
@@ -41,6 +41,14 @@ public interface Method
*/ */
public String getVersion(); 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. * Formats amounts into this payment methods style of currency display.
* *

View File

@@ -5,9 +5,6 @@ import java.util.Set;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import java.util.HashSet;
import java.util.Set;
/** /**
* The <code>Methods</code> initializes Methods that utilize the Method interface * 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. * 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 * Methods also allows you to set a preferred method of payment before it captures
* payment plugins in the initialization process. * payment plugins in the initialization process.
* *
* in <code>bukkit.yml</code>:
* <blockquote><pre> * <blockquote><pre>
* Methods methods = new Methods("iConomy"); * economy:
* preferred: "iConomy"
* </pre></blockquote> * </pre></blockquote>
* *
* @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun) * @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun)
@@ -32,51 +27,62 @@ import java.util.Set;
*/ */
public class Methods public class Methods
{ {
private boolean self = false; private static String version = null;
private Method Method = null; private static boolean self = false;
private String preferred = ""; private static Method Method = null;
private Set<Method> Methods = new HashSet<Method>(); private static String preferred = "";
private Set<String> Dependencies = new HashSet<String>(); private static Set<Method> Methods = new HashSet<Method>();
private Set<Method> Attachables = new HashSet<Method>(); private static Set<String> Dependencies = new HashSet<String>();
private static Set<Method> Attachables = new HashSet<Method>();
/** static
* Initialize Method class
*/
public Methods()
{ {
this._init(); _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;
}
} }
/** /**
* Implement all methods along with their respective name & class. * 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()); addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo6());
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5()); addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo6()); addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6()); addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7()); addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
this.addMethod("MultiCurrency", new com.earth2me.essentials.register.payment.methods.MCUR()); 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. * @return <code>Set<String></code> - Array of payment methods that are loaded.
* @see #setMethod(org.bukkit.plugin.Plugin) * @see #setMethod(org.bukkit.plugin.Plugin)
*/ */
public Set<String> getDependencies() public static Set<String> getDependencies()
{ {
return Dependencies; return Dependencies;
} }
@@ -98,7 +104,7 @@ public class Methods
* @param plugin Plugin data from bukkit, Internal Class file. * @param plugin Plugin data from bukkit, Internal Class file.
* @return Method <em>or</em> Null * @return Method <em>or</em> Null
*/ */
public Method createMethod(Plugin plugin) public static Method createMethod(Plugin plugin)
{ {
for (Method method : Methods) for (Method method : Methods)
{ {
@@ -112,7 +118,7 @@ public class Methods
return null; return null;
} }
private void addMethod(String name, Method method) private static void addMethod(String name, Method method)
{ {
Dependencies.add(name); Dependencies.add(name);
Methods.add(method); Methods.add(method);
@@ -125,7 +131,7 @@ public class Methods
* @see #setMethod(org.bukkit.plugin.Plugin) * @see #setMethod(org.bukkit.plugin.Plugin)
* @see #checkDisabled(org.bukkit.plugin.Plugin) * @see #checkDisabled(org.bukkit.plugin.Plugin)
*/ */
public boolean hasMethod() public static boolean hasMethod()
{ {
return (Method != null); return (Method != null);
} }
@@ -134,15 +140,16 @@ public class Methods
* Checks Plugin Class against a multitude of checks to verify it's usability * Checks Plugin Class against a multitude of checks to verify it's usability
* as a payment method. * 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. * @return <code>boolean</code> True on success, False on failure.
*/ */
public boolean setMethod(Plugin method) public static boolean setMethod(PluginManager manager)
{ {
if (hasMethod()) if (hasMethod())
{ {
return true; return true;
} }
if (self) if (self)
{ {
self = false; self = false;
@@ -152,44 +159,37 @@ public class Methods
int count = 0; int count = 0;
boolean match = false; boolean match = false;
Plugin plugin = null; Plugin plugin = null;
PluginManager manager = method.getServer().getPluginManager();
for (String name : this.getDependencies()) for (String name : getDependencies())
{ {
if (hasMethod()) if (hasMethod())
{ {
break; break;
} }
if (method.getDescription().getName().equals(name))
{ plugin = manager.getPlugin(name);
plugin = method;
}
else
{
plugin = manager.getPlugin(name);
}
if (plugin == null) if (plugin == null)
{ {
continue; continue;
} }
Method current = this.createMethod(plugin); Method current = createMethod(plugin);
if (current == null) if (current == null)
{ {
continue; continue;
} }
if (this.preferred.isEmpty()) if (preferred.isEmpty())
{ {
this.Method = current; Method = current;
} }
else else
{ {
this.Attachables.add(current); Attachables.add(current);
} }
} }
if (!this.preferred.isEmpty()) if (!preferred.isEmpty())
{ {
do do
{ {
@@ -199,7 +199,7 @@ public class Methods
} }
else else
{ {
for (Method attached : this.Attachables) for (Method attached : Attachables)
{ {
if (attached == null) if (attached == null)
{ {
@@ -212,21 +212,21 @@ public class Methods
break; break;
} }
if (this.preferred.isEmpty()) if (preferred.isEmpty())
{ {
this.Method = attached; Method = attached;
} }
if (count == 0) 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(); 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. * Grab the existing and initialized (hopefully) Method Class.
* *
* @return <code>Method</code> <em>or</em> <code>Null</code> * @return <code>Method</code> <em>or</em> <code>Null</code>
*/ */
public Method getMethod() public static Method getMethod()
{ {
return Method; return Method;
} }
@@ -256,16 +272,18 @@ public class Methods
* @param method Plugin data from bukkit, Internal Class file. * @param method Plugin data from bukkit, Internal Class file.
* @return <code>boolean</code> * @return <code>boolean</code>
*/ */
public boolean checkDisabled(Plugin method) public static boolean checkDisabled(Plugin method)
{ {
if (!hasMethod()) if (!hasMethod())
{ {
return true; return true;
} }
if (Method.isCompatible(method)) if (Method.isCompatible(method))
{ {
Method = null; Method = null;
} }
return (Method == null); return (Method == null);
} }
} }

View File

@@ -1,9 +1,11 @@
package com.earth2me.essentials.register.payment.methods; package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method; import com.earth2me.essentials.register.payment.Method;
import cosine.boseconomy.BOSEconomy; import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
/** /**
* BOSEconomy 6 Implementation of Method * BOSEconomy 6 Implementation of Method
* *
@@ -11,191 +13,256 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011 * @copyright (c) 2011
* @license AOL license <http://aol.nexua.org> * @license AOL license <http://aol.nexua.org>
*/ */
public class BOSE6 implements Method { @SuppressWarnings("deprecation")
private BOSEconomy BOSEconomy; public class BOSE6 implements Method
{
private BOSEconomy BOSEconomy;
public BOSEconomy getPlugin() { public BOSEconomy getPlugin()
return this.BOSEconomy; {
} return this.BOSEconomy;
}
public String getName() { public String getName()
return "BOSEconomy"; {
} return "BOSEconomy";
}
public String getVersion() { public String getVersion()
return "0.6.2"; {
} return "0.6.2";
}
public String format(double amount) { public int fractionalDigits()
String currency = this.BOSEconomy.getMoneyNamePlural(); {
if(amount == 1) currency = this.BOSEconomy.getMoneyName(); return 0;
return amount + " " + currency; }
}
public boolean hasBanks() { public String format(double amount)
return true; {
} String currency = this.BOSEconomy.getMoneyNamePlural();
public boolean hasBank(String bank) { if (amount == 1)
return this.BOSEconomy.bankExists(bank); {
} currency = this.BOSEconomy.getMoneyName();
}
public boolean hasAccount(String name) { return amount + " " + currency;
return this.BOSEconomy.playerRegistered(name, false); }
}
public boolean hasBankAccount(String bank, String name) { public boolean hasBanks()
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name); {
} return true;
}
public MethodAccount getAccount(String name) { public boolean hasBank(String bank)
if(!hasAccount(name)) return null; {
return new BOSEAccount(name, this.BOSEconomy); return this.BOSEconomy.bankExists(bank);
} }
public MethodBankAccount getBankAccount(String bank, String name) { public boolean hasAccount(String name)
if(!hasBankAccount(bank, name)) return null; {
return new BOSEBankAccount(bank, BOSEconomy); return this.BOSEconomy.playerRegistered(name, false);
} }
public boolean isCompatible(Plugin plugin) { public boolean hasBankAccount(String bank, String name)
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && plugin.getDescription().getVersion().equals("0.6.2"); {
} return this.BOSEconomy.isBankOwner(bank, name)
|| this.BOSEconomy.isBankMember(bank, name);
}
public void setPlugin(Plugin plugin) { public MethodAccount getAccount(String name)
BOSEconomy = (BOSEconomy)plugin; {
} if (!hasAccount(name))
{
return null;
}
public class BOSEAccount implements MethodAccount { return new BOSEAccount(name, this.BOSEconomy);
private String name; }
private BOSEconomy BOSEconomy;
public BOSEAccount(String name, BOSEconomy bOSEconomy) { public MethodBankAccount getBankAccount(String bank, String name)
this.name = name; {
this.BOSEconomy = bOSEconomy; if (!hasBankAccount(bank, name))
} {
return null;
}
public double balance() { return new BOSEBankAccount(bank, BOSEconomy);
return (double) this.BOSEconomy.getPlayerMoney(this.name); }
}
public boolean set(double amount) { public boolean isCompatible(Plugin plugin)
int IntAmount = (int)Math.ceil(amount); {
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false); return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
} && plugin instanceof BOSEconomy
&& plugin.getDescription().getVersion().equals("0.6.2");
}
public boolean add(double amount) { public void setPlugin(Plugin plugin)
int IntAmount = (int)Math.ceil(amount); {
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false); 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) { public class BOSEAccount implements MethodAccount
int IntAmount = (int)Math.ceil(amount); {
int balance = (int)this.balance(); private final String name;
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false); private final BOSEconomy BOSEconomy;
}
public boolean divide(double amount) { public BOSEAccount(String name, BOSEconomy bOSEconomy)
int IntAmount = (int)Math.ceil(amount); {
int balance = (int)this.balance(); this.name = name;
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false); this.BOSEconomy = bOSEconomy;
} }
public boolean hasEnough(double amount) { public double balance()
return (this.balance() >= amount); {
} return (double)this.BOSEconomy.getPlayerMoney(this.name);
}
public boolean hasOver(double amount) { public boolean set(double amount)
return (this.balance() > amount); {
} int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
}
public boolean hasUnder(double amount) { public boolean add(double amount)
return (this.balance() < amount); {
} int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
}
public boolean isNegative() { public boolean subtract(double amount)
return (this.balance() < 0); {
} int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
}
public boolean remove() { public boolean multiply(double amount)
return false; {
} 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 { public boolean divide(double amount)
private final String bank; {
private final BOSEconomy BOSEconomy; 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) { public boolean hasEnough(double amount)
this.bank = bank; {
this.BOSEconomy = bOSEconomy; return (this.balance() >= amount);
} }
public String getBankName() { public boolean hasOver(double amount)
return this.bank; {
} return (this.balance() > amount);
}
public int getBankId() { public boolean hasUnder(double amount)
return -1; {
} return (this.balance() < amount);
}
public double balance() { public boolean isNegative()
return (double) this.BOSEconomy.getBankMoney(bank); {
} return (this.balance() < 0);
}
public boolean set(double amount) { public boolean remove()
int IntAmount = (int)Math.ceil(amount); {
return this.BOSEconomy.setBankMoney(bank, IntAmount, true); 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) { public class BOSEBankAccount implements MethodBankAccount
int IntAmount = (int)Math.ceil(amount); {
int balance = (int)this.balance(); private final String bank;
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false); private final BOSEconomy BOSEconomy;
}
public boolean multiply(double amount) { public BOSEBankAccount(String bank, BOSEconomy bOSEconomy)
int IntAmount = (int)Math.ceil(amount); {
int balance = (int)this.balance(); this.bank = bank;
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false); this.BOSEconomy = bOSEconomy;
} }
public boolean divide(double amount) { public String getBankName()
int IntAmount = (int)Math.ceil(amount); {
int balance = (int)this.balance(); return this.bank;
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false); }
}
public boolean hasEnough(double amount) { public int getBankId()
return (this.balance() >= amount); {
} return -1;
}
public boolean hasOver(double amount) { public double balance()
return (this.balance() > amount); {
} return (double)this.BOSEconomy.getBankMoney(bank);
}
public boolean hasUnder(double amount) { public boolean set(double amount)
return (this.balance() < amount); {
} int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
}
public boolean isNegative() { public boolean add(double amount)
return (this.balance() < 0); {
} int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
}
public boolean remove() { public boolean subtract(double amount)
return this.BOSEconomy.removeBank(bank); {
} 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);
}
}
} }

View File

@@ -1,9 +1,11 @@
package com.earth2me.essentials.register.payment.methods; package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method; import com.earth2me.essentials.register.payment.Method;
import cosine.boseconomy.BOSEconomy; import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
/** /**
* BOSEconomy 7 Implementation of Method * BOSEconomy 7 Implementation of Method
* *
@@ -12,182 +14,244 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011 * @copyright (c) 2011
* @license AOL license <http://aol.nexua.org> * @license AOL license <http://aol.nexua.org>
*/ */
public class BOSE7 implements Method
{
private BOSEconomy BOSEconomy;
public class BOSE7 implements Method { public BOSEconomy getPlugin()
private BOSEconomy BOSEconomy; {
return this.BOSEconomy;
}
public BOSEconomy getPlugin() { public String getName()
return this.BOSEconomy; {
} return "BOSEconomy";
}
public String getName() { public String getVersion()
return "BOSEconomy"; {
} return "0.7.0";
}
public String getVersion() { public int fractionalDigits()
return "0.7.0"; {
} return this.BOSEconomy.getFractionalDigits();
}
public String format(double amount) { public String format(double amount)
String currency = this.BOSEconomy.getMoneyNamePlural(); {
if(amount == 1) currency = this.BOSEconomy.getMoneyName(); String currency = this.BOSEconomy.getMoneyNamePlural();
return amount + " " + currency;
}
public boolean hasBanks() { if (amount == 1)
return true; {
} currency = this.BOSEconomy.getMoneyName();
}
public boolean hasBank(String bank) { return amount + " " + currency;
return this.BOSEconomy.bankExists(bank); }
}
public boolean hasAccount(String name) { public boolean hasBanks()
return this.BOSEconomy.playerRegistered(name, false); {
} return true;
}
public boolean hasBankAccount(String bank, String name) { public boolean hasBank(String bank)
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name); {
} return this.BOSEconomy.bankExists(bank);
}
public MethodAccount getAccount(String name) { public boolean hasAccount(String name)
if(!hasAccount(name)) return null; {
return new BOSEAccount(name, this.BOSEconomy); return this.BOSEconomy.playerRegistered(name, false);
} }
public MethodBankAccount getBankAccount(String bank, String name) { public boolean hasBankAccount(String bank, String name)
if(!hasBankAccount(bank, name)) return null; {
return new BOSEBankAccount(bank, BOSEconomy); return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
} }
public boolean isCompatible(Plugin plugin) { public MethodAccount getAccount(String name)
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && !plugin.getDescription().getVersion().equals("0.6.2"); {
} if (!hasAccount(name))
{
return null;
}
public void setPlugin(Plugin plugin) { return new BOSEAccount(name, this.BOSEconomy);
BOSEconomy = (BOSEconomy)plugin; }
}
public class BOSEAccount implements MethodAccount { public MethodBankAccount getBankAccount(String bank, String name)
private String name; {
private BOSEconomy BOSEconomy; if (!hasBankAccount(bank, name))
{
return null;
}
public BOSEAccount(String name, BOSEconomy bOSEconomy) { return new BOSEBankAccount(bank, BOSEconomy);
this.name = name; }
this.BOSEconomy = bOSEconomy;
}
public double balance() { public boolean isCompatible(Plugin plugin)
return this.BOSEconomy.getPlayerMoneyDouble(this.name); {
} return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
&& plugin instanceof BOSEconomy
&& !plugin.getDescription().getVersion().equals("0.6.2");
}
public boolean set(double amount) { public void setPlugin(Plugin plugin)
return this.BOSEconomy.setPlayerMoney(this.name, amount, false); {
} BOSEconomy = (BOSEconomy)plugin;
}
public boolean add(double amount) {
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
}
public boolean subtract(double amount) { public class BOSEAccount implements MethodAccount
double balance = this.balance(); {
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false); private String name;
} private BOSEconomy BOSEconomy;
public boolean multiply(double amount) { public BOSEAccount(String name, BOSEconomy bOSEconomy)
double balance = this.balance(); {
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false); this.name = name;
} this.BOSEconomy = bOSEconomy;
}
public boolean divide(double amount) { public double balance()
double balance = this.balance(); {
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false); return this.BOSEconomy.getPlayerMoneyDouble(this.name);
} }
public boolean hasEnough(double amount) { public boolean set(double amount)
return (this.balance() >= amount); {
} return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
}
public boolean hasOver(double amount) { public boolean add(double amount)
return (this.balance() > amount); {
} return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
}
public boolean hasUnder(double amount) { public boolean subtract(double amount)
return (this.balance() < amount); {
} double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
}
public boolean isNegative() { public boolean multiply(double amount)
return (this.balance() < 0); {
} double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
}
public boolean remove() { public boolean divide(double amount)
return false; {
} double balance = this.balance();
} return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
}
public class BOSEBankAccount implements MethodBankAccount { public boolean hasEnough(double amount)
private String bank; {
private BOSEconomy BOSEconomy; return (this.balance() >= amount);
}
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) { public boolean hasOver(double amount)
this.bank = bank; {
this.BOSEconomy = bOSEconomy; return (this.balance() > amount);
} }
public String getBankName() { public boolean hasUnder(double amount)
return this.bank; {
} return (this.balance() < amount);
}
public int getBankId() { public boolean isNegative()
return -1; {
} return (this.balance() < 0);
}
public double balance() { public boolean remove()
return this.BOSEconomy.getBankMoneyDouble(bank); {
} return false;
}
}
public boolean set(double amount) {
return this.BOSEconomy.setBankMoney(bank, amount, true);
}
public boolean add(double amount) { public class BOSEBankAccount implements MethodBankAccount
double balance = this.balance(); {
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false); private String bank;
} private BOSEconomy BOSEconomy;
public boolean subtract(double amount) { public BOSEBankAccount(String bank, BOSEconomy bOSEconomy)
double balance = this.balance(); {
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false); this.bank = bank;
} this.BOSEconomy = bOSEconomy;
}
public boolean multiply(double amount) { public String getBankName()
double balance = this.balance(); {
return this.BOSEconomy.setBankMoney(bank, (balance * amount), false); return this.bank;
} }
public boolean divide(double amount) { public int getBankId()
double balance = this.balance(); {
return this.BOSEconomy.setBankMoney(bank, (balance / amount), false); return -1;
} }
public boolean hasEnough(double amount) { public double balance()
return (this.balance() >= amount); {
} return this.BOSEconomy.getBankMoneyDouble(bank);
}
public boolean hasOver(double amount) { public boolean set(double amount)
return (this.balance() > amount); {
} return this.BOSEconomy.setBankMoney(bank, amount, true);
}
public boolean hasUnder(double amount) { public boolean add(double amount)
return (this.balance() < amount); {
} double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false);
}
public boolean isNegative() { public boolean subtract(double amount)
return (this.balance() < 0); {
} double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false);
}
public boolean remove() { public boolean multiply(double amount)
return this.BOSEconomy.removeBank(bank); {
} 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);
}
}
} }

View File

@@ -7,6 +7,7 @@ import me.ashtheking.currency.CurrencyList;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
/** /**
* MultiCurrency Method implementation. * MultiCurrency Method implementation.
* *
@@ -14,107 +15,141 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011 * @copyright (c) 2011
* @license AOL license <http://aol.nexua.org> * @license AOL license <http://aol.nexua.org>
*/ */
public class MCUR implements Method { public class MCUR implements Method
private Currency currencyList; {
private Currency currencyList;
public Object getPlugin() { public Object getPlugin()
return this.currencyList; {
} return this.currencyList;
}
public String getName() { public String getName()
return "MultiCurrency"; {
} return "MultiCurrency";
}
public String getVersion() { public String getVersion()
return "0.09"; {
} return "0.09";
}
public String format(double amount) { public int fractionalDigits()
return amount + " Currency"; {
} return -1;
}
public boolean hasBanks() { public String format(double amount)
return false; {
} return amount + " Currency";
}
public boolean hasBank(String bank) { public boolean hasBanks()
return false; {
} return false;
}
public boolean hasAccount(String name) { public boolean hasBank(String bank)
return true; {
} return false;
}
public boolean hasBankAccount(String bank, String name) { public boolean hasAccount(String name)
return false; {
} return true;
}
public MethodAccount getAccount(String name) { public boolean hasBankAccount(String bank, String name)
return new MCurrencyAccount(name); {
} return false;
}
public MethodBankAccount getBankAccount(String bank, String name) { public MethodAccount getAccount(String name)
return null; {
} return new MCurrencyAccount(name);
}
public boolean isCompatible(Plugin plugin) { public MethodBankAccount getBankAccount(String bank, String name)
return plugin.getDescription().getName().equalsIgnoreCase(getName()) && plugin instanceof Currency; {
} return null;
}
public void setPlugin(Plugin plugin) { public boolean isCompatible(Plugin plugin)
currencyList = (Currency) plugin; {
} return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
&& plugin instanceof Currency;
}
public class MCurrencyAccount implements MethodAccount{ public void setPlugin(Plugin plugin)
private String name; {
currencyList = (Currency)plugin;
}
public MCurrencyAccount(String name) {
this.name = name;
}
public double balance() { public class MCurrencyAccount implements MethodAccount
return CurrencyList.getValue((String) CurrencyList.maxCurrency(name)[0], name); {
} private String name;
public boolean set(double amount) { public MCurrencyAccount(String name)
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, amount); {
return true; this.name = name;
} }
public boolean add(double amount) { public double balance()
return CurrencyList.add(name, amount); {
} return CurrencyList.getValue((String)CurrencyList.maxCurrency(name)[0], name);
}
public boolean subtract(double amount) { public boolean set(double amount)
return CurrencyList.subtract(name, amount); {
} CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, amount);
return true;
}
public boolean multiply(double amount) { public boolean add(double amount)
return CurrencyList.multiply(name, amount); {
} return CurrencyList.add(name, amount);
}
public boolean divide(double amount) { public boolean subtract(double amount)
return CurrencyList.divide(name, amount); {
} return CurrencyList.subtract(name, amount);
}
public boolean hasEnough(double amount) { public boolean multiply(double amount)
return CurrencyList.hasEnough(name, amount); {
} return CurrencyList.multiply(name, amount);
}
public boolean hasOver(double amount) { public boolean divide(double amount)
return CurrencyList.hasOver(name, amount); {
} return CurrencyList.divide(name, amount);
}
public boolean hasUnder(double amount) { public boolean hasEnough(double amount)
return CurrencyList.hasUnder(name, amount); {
} return CurrencyList.hasEnough(name, amount);
}
public boolean isNegative() { public boolean hasOver(double amount)
return CurrencyList.isNegative(name); {
} return CurrencyList.hasOver(name, amount);
}
public boolean remove() { public boolean hasUnder(double amount)
return CurrencyList.remove(name); {
} return CurrencyList.hasUnder(name, amount);
} }
public boolean isNegative()
{
return CurrencyList.isNegative(name);
}
public boolean remove()
{
return CurrencyList.remove(name);
}
}
} }

View File

@@ -1,12 +1,13 @@
package com.earth2me.essentials.register.payment.methods; 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.iConomy;
import com.nijiko.coelho.iConomy.system.Account; import com.nijiko.coelho.iConomy.system.Account;
import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
/** /**
* iConomy 4 Implementation of Method * iConomy 4 Implementation of Method
* *
@@ -14,122 +15,175 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011 * @copyright (c) 2011
* @license AOL license <http://aol.nexua.org> * @license AOL license <http://aol.nexua.org>
*/ */
public class iCo4 implements Method { public class iCo4 implements Method
private iConomy iConomy; {
private iConomy iConomy;
public iConomy getPlugin() { public iConomy getPlugin()
return this.iConomy; {
} return this.iConomy;
}
public String getName() { public String getName()
return "iConomy"; {
} return "iConomy";
}
public String getVersion() { public String getVersion()
return "4"; {
} return "4";
}
public String format(double amount) { public int fractionalDigits()
return this.iConomy.getBank().format(amount); {
} return 2;
}
public boolean hasBanks() { public String format(double amount)
return false; {
} return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount);
}
public boolean hasBank(String bank) { public boolean hasBanks()
return false; {
} return false;
}
public boolean hasAccount(String name) { public boolean hasBank(String bank)
return this.iConomy.getBank().hasAccount(name); {
} return false;
}
public boolean hasBankAccount(String bank, String name) { public boolean hasAccount(String name)
return false; {
} return com.nijiko.coelho.iConomy.iConomy.getBank().hasAccount(name);
}
public MethodAccount getAccount(String name) { public boolean hasBankAccount(String bank, String name)
return new iCoAccount(this.iConomy.getBank().getAccount(name)); {
} return false;
}
public MethodBankAccount getBankAccount(String bank, String name) { public MethodAccount getAccount(String name)
return null; {
} return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
}
public boolean isCompatible(Plugin plugin) { public MethodBankAccount getBankAccount(String bank, String name)
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy") && plugin instanceof iConomy; {
} return null;
}
public void setPlugin(Plugin plugin) { public boolean isCompatible(Plugin plugin)
iConomy = (iConomy)plugin; {
} return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
&& plugin instanceof iConomy;
}
public class iCoAccount implements MethodAccount { public void setPlugin(Plugin plugin)
private Account account; {
iConomy = (iConomy)plugin;
}
public iCoAccount(Account account) {
this.account = account;
}
public Account getiCoAccount() { public class iCoAccount implements MethodAccount
return account; {
} private Account account;
public double balance() { public iCoAccount(Account account)
return this.account.getBalance(); {
} this.account = account;
}
public boolean set(double amount) { public Account getiCoAccount()
if(this.account == null) return false; {
this.account.setBalance(amount); return account;
return true; }
}
public boolean add(double amount) { public double balance()
if(this.account == null) return false; {
this.account.add(amount); return this.account.getBalance();
return true; }
}
public boolean subtract(double amount) { public boolean set(double amount)
if(this.account == null) return false; {
this.account.subtract(amount); if (this.account == null)
return true; {
} return false;
}
this.account.setBalance(amount);
return true;
}
public boolean multiply(double amount) { public boolean add(double amount)
if(this.account == null) return false; {
this.account.multiply(amount); if (this.account == null)
return true; {
} return false;
}
this.account.add(amount);
return true;
}
public boolean divide(double amount) { public boolean subtract(double amount)
if(this.account == null) return false; {
this.account.divide(amount); if (this.account == null)
return true; {
} return false;
}
this.account.subtract(amount);
return true;
}
public boolean hasEnough(double amount) { public boolean multiply(double amount)
return this.account.hasEnough(amount); {
} if (this.account == null)
{
return false;
}
this.account.multiply(amount);
return true;
}
public boolean hasOver(double amount) { public boolean divide(double amount)
return this.account.hasOver(amount); {
} if (this.account == null)
{
return false;
}
this.account.divide(amount);
return true;
}
public boolean hasUnder(double amount) { public boolean hasEnough(double amount)
return (this.balance() < amount); {
} return this.account.hasEnough(amount);
}
public boolean isNegative() { public boolean hasOver(double amount)
return this.account.isNegative(); {
} return this.account.hasOver(amount);
}
public boolean remove() { public boolean hasUnder(double amount)
if(this.account == null) return false; {
this.account.remove(); return (this.balance() < amount);
return true; }
}
} public boolean isNegative()
{
return this.account.isNegative();
}
public boolean remove()
{
if (this.account == null)
{
return false;
}
this.account.remove();
return true;
}
}
} }

View File

@@ -1,12 +1,12 @@
package com.earth2me.essentials.register.payment.methods; package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import com.iConomy.iConomy; import com.iConomy.iConomy;
import com.iConomy.system.Account; import com.iConomy.system.Account;
import com.iConomy.system.BankAccount; import com.iConomy.system.BankAccount;
import com.iConomy.system.Holdings; import com.iConomy.system.Holdings;
import com.iConomy.util.Constants; import com.iConomy.util.Constants;
import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@@ -37,9 +37,14 @@ public class iCo5 implements Method
return "5"; return "5";
} }
public int fractionalDigits()
{
return 2;
}
public String format(double amount) public String format(double amount)
{ {
return this.iConomy.format(amount); return com.iConomy.iConomy.format(amount);
} }
public boolean hasBanks() public boolean hasBanks()
@@ -49,32 +54,34 @@ public class iCo5 implements Method
public boolean hasBank(String bank) 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) public boolean hasAccount(String name)
{ {
return this.iConomy.hasAccount(name); return com.iConomy.iConomy.hasAccount(name);
} }
public boolean hasBankAccount(String bank, String 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) 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) 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) 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) public void setPlugin(Plugin plugin)

View File

@@ -1,14 +1,15 @@
package com.earth2me.essentials.register.payment.methods; package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import com.iCo6.iConomy; import com.iCo6.iConomy;
import com.iCo6.system.Account; import com.iCo6.system.Account;
import com.iCo6.system.Accounts; import com.iCo6.system.Accounts;
import com.iCo6.system.Holdings; import com.iCo6.system.Holdings;
import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
/** /**
* iConomy 6 Implementation of Method * iConomy 6 Implementation of Method
* *
@@ -16,127 +17,177 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011 * @copyright (c) 2011
* @license AOL license <http://aol.nexua.org> * @license AOL license <http://aol.nexua.org>
*/ */
public class iCo6 implements Method { public class iCo6 implements Method
private iConomy iConomy; {
private iConomy iConomy;
public iConomy getPlugin() { public iConomy getPlugin()
return this.iConomy; {
} return this.iConomy;
}
public String getName() { public String getName()
return "iConomy"; {
} return "iConomy";
}
public String getVersion() { public String getVersion()
return "6"; {
} return "6";
}
public String format(double amount) { public int fractionalDigits()
return this.iConomy.format(amount); {
} return 2;
}
public boolean hasBanks() { public String format(double amount)
return false; {
} return com.iCo6.iConomy.format(amount);
}
public boolean hasBank(String bank) { public boolean hasBanks()
return false; {
} return false;
}
public boolean hasAccount(String name) { public boolean hasBank(String bank)
return (new Accounts()).exists(name); {
} return false;
}
public boolean hasBankAccount(String bank, String name) { public boolean hasAccount(String name)
return false; {
} return (new Accounts()).exists(name);
}
public MethodAccount getAccount(String name) { public boolean hasBankAccount(String bank, String name)
return new iCoAccount((new Accounts()).get(name)); {
} return false;
}
public MethodBankAccount getBankAccount(String bank, String name) { public MethodAccount getAccount(String name)
return null; {
} return new iCoAccount((new Accounts()).get(name));
}
public boolean isCompatible(Plugin plugin) { public MethodBankAccount getBankAccount(String bank, String name)
try { Class.forName("com.iCo6.IO"); } {
catch(Exception e) { return false; } 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) { public void setPlugin(Plugin plugin)
iConomy = (iConomy)plugin; {
} iConomy = (iConomy)plugin;
}
public class iCoAccount implements MethodAccount {
private Account account;
private Holdings holdings;
public iCoAccount(Account account) { public class iCoAccount implements MethodAccount
this.account = account; {
this.holdings = account.getHoldings(); private Account account;
} private Holdings holdings;
public Account getiCoAccount() { public iCoAccount(Account account)
return account; {
} this.account = account;
this.holdings = account.getHoldings();
}
public double balance() { public Account getiCoAccount()
return this.holdings.getBalance(); {
} return account;
}
public boolean set(double amount) { public double balance()
if(this.holdings == null) return false; {
this.holdings.setBalance(amount); return this.holdings.getBalance();
return true; }
}
public boolean add(double amount) { public boolean set(double amount)
if(this.holdings == null) return false; {
this.holdings.add(amount); if (this.holdings == null)
return true; {
} return false;
}
this.holdings.setBalance(amount);
return true;
}
public boolean subtract(double amount) { public boolean add(double amount)
if(this.holdings == null) return false; {
this.holdings.subtract(amount); if (this.holdings == null)
return true; {
} return false;
}
this.holdings.add(amount);
return true;
}
public boolean multiply(double amount) { public boolean subtract(double amount)
if(this.holdings == null) return false; {
this.holdings.multiply(amount); if (this.holdings == null)
return true; {
} return false;
}
this.holdings.subtract(amount);
return true;
}
public boolean divide(double amount) { public boolean multiply(double amount)
if(this.holdings == null) return false; {
this.holdings.divide(amount); if (this.holdings == null)
return true; {
} return false;
}
this.holdings.multiply(amount);
return true;
}
public boolean hasEnough(double amount) { public boolean divide(double amount)
return this.holdings.hasEnough(amount); {
} if (this.holdings == null)
{
return false;
}
this.holdings.divide(amount);
return true;
}
public boolean hasOver(double amount) { public boolean hasEnough(double amount)
return this.holdings.hasOver(amount); {
} return this.holdings.hasEnough(amount);
}
public boolean hasUnder(double amount) { public boolean hasOver(double amount)
return this.holdings.hasUnder(amount); {
} return this.holdings.hasOver(amount);
}
public boolean isNegative() { public boolean hasUnder(double amount)
return this.holdings.isNegative(); {
} return this.holdings.hasUnder(amount);
}
public boolean remove() { public boolean isNegative()
if(this.account == null) return false; {
this.account.remove(); return this.holdings.isNegative();
return true; }
}
} public boolean remove()
{
if (this.account == null)
{
return false;
}
this.account.remove();
return true;
}
}
} }

View File

@@ -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. # 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 spawn-protection: false
# Nether settings (switch between worlds with "/world nether" and "/world normal") # Nether settings
# Sets whether the nether system is enabled, what folder to save the world in, and whether portals should teleport players between worlds. # Sets wether you want to change the default behaviour of the nether portals.
nether: nether:
enabled: false
folder: nether
portals-enabled: false portals-enabled: false
generate-exit-portals: false generate-exit-portals: false
ratio: 16
# Mob limit on spawnmob # Mob limit on spawnmob
spawnmob-limit: 10 spawnmob-limit: 10
@@ -95,6 +92,7 @@ spawnmob-limit: 10
warn-on-smite: true warn-on-smite: true
# The message of the day, displayed on connect and by typing /motd. # The message of the day, displayed on connect and by typing /motd.
# Valid tags are: {PLAYER}, {IP}, {BALANCE}, {MAILS}, {WORLD}, {ONLINE}, {UNIQUE}, {PLAYERLIST}
motd: motd:
- '&cWelcome, {PLAYER}&c!' - '&cWelcome, {PLAYER}&c!'
- '&fType &c/help&f for a list of commands.' - '&fType &c/help&f for a list of commands.'
@@ -262,10 +260,16 @@ bed-sethome: false
# If no home is set send you to spawn when /home is used # If no home is set send you to spawn when /home is used
spawn-if-no-home: false spawn-if-no-home: false
# If users have essentials.sethome.multiple how many homes can they have # Allow players to have multiple homes.
# People with essentials.sethome.multiple.unlimited are not limited by this number # Define different amounts of multiple homes for different permissions, e.g. essentials.sethome.multiple.vip
multiple-homes: 5 # People with essentials.sethome.multiple.unlimited are not limited by these numbers.
sethome-multiple:
# essentials.sethome.multiple
default: 3
# essentials.sethome.multiple.vip
vip: 5
# essentials.sethome.multiple.staff
staff: 10
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
@@ -422,6 +426,9 @@ protect:
squid: false squid: false
zombie: false zombie: false
wolf: false wolf: false
cave_spider: false
enderman: false
silverfish: false
# Maximum height the creeper should explode. -1 allows them to explode everywhere. # 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. # Set prevent.creeper-explosion to true, if you want to disable creeper explosions.
@@ -485,7 +492,7 @@ protect:
use: true use: true
# Should we tell people they are not allowed to build # Should we tell people they are not allowed to build
warn-on-build-disallow: false warn-on-build-disallow: true
# Disable weather options # Disable weather options

View File

@@ -54,7 +54,7 @@ deleteJail = \u00a77Jail {0} has been removed.
deleteWarp = \u00a77Warp {0} has been removed. deleteWarp = \u00a77Warp {0} has been removed.
deniedAccessCommand = {0} was denied access to command. deniedAccessCommand = {0} was denied access to command.
dependancyDownloaded = [Essentials] Dependancy {0} downloaded successfully. 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. dependancyNotFound = [Essentials] A required dependancy was not found, downloading now.
depth = \u00a77You are at sea level. depth = \u00a77You are at sea level.
depthAboveSea = \u00a77You are {0} block(s) above sea level. depthAboveSea = \u00a77You are {0} block(s) above sea level.
@@ -171,7 +171,7 @@ mobsAvailable = \u00a77Mobs: {0}
mobSpawnError = Error while changing mob spawner. mobSpawnError = Error while changing mob spawner.
mobSpawnLimit = Mob quantity limited to server limit mobSpawnLimit = Mob quantity limited to server limit
mobSpawnTarget = Target block must be a mob spawner. 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} moneySentTo = \u00a7a{0} has been sent to {1}
moneyTaken = {0} taken from your bank account. moneyTaken = {0} taken from your bank account.
month = month month = month
@@ -265,7 +265,7 @@ requestAcceptedFrom = \u00a77{0} accepted your teleport request.
requestDenied = \u00a77Teleport request denied. requestDenied = \u00a77Teleport request denied.
requestDeniedFrom = \u00a77{0} denied your teleport request. requestDeniedFrom = \u00a77{0} denied your teleport request.
requestSent = \u00a77Request sent to {0}\u00a77. 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 second = second
seconds = seconds seconds = seconds
seenOffline = Player {0} is offline since {1} seenOffline = Player {0} is offline since {1}

View File

@@ -54,7 +54,7 @@ deleteJail = \u00a77Jail {0} has been removed.
deleteWarp = \u00a77Warp {0} has been removed. deleteWarp = \u00a77Warp {0} has been removed.
deniedAccessCommand = {0} was denied access to command. deniedAccessCommand = {0} was denied access to command.
dependancyDownloaded = [Essentials] Dependancy {0} downloaded successfully. 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. dependancyNotFound = [Essentials] A required dependancy was not found, downloading now.
depth = \u00a77You are at sea level. depth = \u00a77You are at sea level.
depthAboveSea = \u00a77You are {0} block(s) above 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. mobSpawnError = Error while changing mob spawner.
mobSpawnLimit = Mob quantity limited to server limit mobSpawnLimit = Mob quantity limited to server limit
mobSpawnTarget = Target block must be a mob spawner. 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} moneySentTo = \u00a7a{0} has been sent to {1}
moneyTaken = {0} taken from your bank account. moneyTaken = {0} taken from your bank account.
month = month month = month
@@ -264,7 +264,7 @@ requestAcceptedFrom = \u00a77{0} accepted your teleport request.
requestDenied = \u00a77Teleport request denied. requestDenied = \u00a77Teleport request denied.
requestDeniedFrom = \u00a77{0} denied your teleport request requestDeniedFrom = \u00a77{0} denied your teleport request
requestSent = \u00a77Request sent to {0}\u00a77. 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 second = second
seconds = seconds seconds = seconds
seenOffline = Player {0} is offline since {1} seenOffline = Player {0} is offline since {1}

View File

@@ -293,7 +293,7 @@ commands:
togglejail: togglejail:
description: Prevents a player from interacting with the world and teleports him/her to the the jail specified description: Prevents a player from interacting with the world and teleports him/her to the the jail specified
usage: /<command> [player] [jailname] <datediff> usage: /<command> [player] [jailname] <datediff>
aliases: [tjail,etogglejail] aliases: [tjail,unjail,eunjail,etogglejail]
top: top:
description: Teleport to the highest block at your current position. description: Teleport to the highest block at your current position.
usage: /<command> usage: /<command>

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials; package com.earth2me.essentials;
import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.ServerConfig;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -14,7 +15,9 @@ import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
@@ -43,6 +46,7 @@ public class FakeServer implements Server
return "1.0"; return "1.0";
} }
@Override
public Player[] getOnlinePlayers() public Player[] getOnlinePlayers()
{ {
return players.toArray(new Player[0]); return players.toArray(new Player[0]);
@@ -53,31 +57,37 @@ public class FakeServer implements Server
this.players = players; this.players = players;
} }
@Override
public int getMaxPlayers() public int getMaxPlayers()
{ {
return 100; return 100;
} }
@Override
public int getPort() public int getPort()
{ {
return 25565; return 25565;
} }
@Override
public String getIp() public String getIp()
{ {
return "127.0.0.1"; return "127.0.0.1";
} }
@Override
public String getServerName() public String getServerName()
{ {
return "Test Server"; return "Test Server";
} }
@Override
public String getServerId() public String getServerId()
{ {
return "Test Server"; return "Test Server";
} }
@Override
public int broadcastMessage(String string) public int broadcastMessage(String string)
{ {
int i = 0; int i = 0;
@@ -89,11 +99,19 @@ public class FakeServer implements Server
return i; return i;
} }
@Override
public String getUpdateFolder() public String getUpdateFolder()
{ {
return "update"; return "update";
} }
@Override
public File getUpdateFolderFile()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Player getPlayer(String string) public Player getPlayer(String string)
{ {
for (Player player : players) for (Player player : players)
@@ -106,6 +124,7 @@ public class FakeServer implements Server
return null; return null;
} }
@Override
public List<Player> matchPlayer(String string) public List<Player> matchPlayer(String string)
{ {
List<Player> matches = new ArrayList<Player>(); List<Player> matches = new ArrayList<Player>();
@@ -119,15 +138,17 @@ public class FakeServer implements Server
return matches; return matches;
} }
@Override
public PluginManager getPluginManager() public PluginManager getPluginManager()
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public BukkitScheduler getScheduler() public BukkitScheduler getScheduler()
{ {
return new BukkitScheduler() { return new BukkitScheduler()
{
@Override @Override
public int scheduleSyncDelayedTask(Plugin plugin, Runnable r, long l) public int scheduleSyncDelayedTask(Plugin plugin, Runnable r, long l)
{ {
@@ -215,16 +236,19 @@ public class FakeServer implements Server
}; };
} }
@Override
public ServicesManager getServicesManager() public ServicesManager getServicesManager()
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public List<World> getWorlds() public List<World> getWorlds()
{ {
return worlds; return worlds;
} }
@Override
public World createWorld(String string, Environment e) public World createWorld(String string, Environment e)
{ {
World w = new FakeWorld(string, e); World w = new FakeWorld(string, e);
@@ -232,6 +256,7 @@ public class FakeServer implements Server
return w; return w;
} }
@Override
public World createWorld(String string, Environment e, long l) public World createWorld(String string, Environment e, long l)
{ {
World w = new FakeWorld(string, e); World w = new FakeWorld(string, e);
@@ -239,45 +264,54 @@ public class FakeServer implements Server
return w; return w;
} }
@Override
public World getWorld(String string) public World getWorld(String string)
{ {
for (World world : worlds) for (World world : worlds)
{ {
if (world.getName().equalsIgnoreCase(string)) { if (world.getName().equalsIgnoreCase(string))
{
return world; return world;
} }
} }
return null; return null;
} }
@Override
public void reload() public void reload()
{ {
} }
@Override
public Logger getLogger() public Logger getLogger()
{ {
return Logger.getLogger("Minecraft"); return Logger.getLogger("Minecraft");
} }
@Override
public PluginCommand getPluginCommand(String string) public PluginCommand getPluginCommand(String string)
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public void savePlayers() public void savePlayers()
{ {
} }
@Override
public boolean dispatchCommand(CommandSender cs, String string) public boolean dispatchCommand(CommandSender cs, String string)
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public void configureDbConfig(ServerConfig sc) public void configureDbConfig(ServerConfig sc)
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public boolean addRecipe(Recipe recipe) public boolean addRecipe(Recipe recipe)
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
@@ -295,41 +329,55 @@ public class FakeServer implements Server
return player; return player;
} }
@Override
public World createWorld(String string, Environment e, ChunkGenerator cg) public World createWorld(String string, Environment e, ChunkGenerator cg)
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public World createWorld(String string, Environment e, long l, ChunkGenerator cg) public World createWorld(String string, Environment e, long l, ChunkGenerator cg)
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public World createWorld(WorldCreator creator)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean unloadWorld(String string, boolean bln) public boolean unloadWorld(String string, boolean bln)
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public boolean unloadWorld(World world, boolean bln) public boolean unloadWorld(World world, boolean bln)
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public Map<String, String[]> getCommandAliases() public Map<String, String[]> getCommandAliases()
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public int getSpawnRadius() public int getSpawnRadius()
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public void setSpawnRadius(int i) public void setSpawnRadius(int i)
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public boolean getOnlineMode() public boolean getOnlineMode()
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
@@ -340,6 +388,7 @@ public class FakeServer implements Server
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public World getWorld(UUID uuid) public World getWorld(UUID uuid)
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
@@ -454,7 +503,19 @@ public class FakeServer implements Server
} }
@Override @Override
public void setDefaultGameMode(GameMode gm) public void setDefaultGameMode(GameMode gamemode)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ConsoleCommandSender getConsoleSender()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set getOperators()
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }

View File

@@ -365,14 +365,6 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don't inherit."); sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don't inherit.");
return false; return false;
} }
if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player using groups with different heritage line.");
return false;
}
if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "The new group must be a higher rank.");
return false;
}
//PARECE OK //PARECE OK
auxUser.setGroup(auxGroup); auxUser.setGroup(auxGroup);

Binary file not shown.

Binary file not shown.