Merge branch 'master' of github.com:khobbits/Essentials

This commit is contained in:
okamosy 2011-08-23 19:48:09 +01:00
commit c374f474ed
23 changed files with 445 additions and 174 deletions

View File

@ -155,10 +155,6 @@ public final class DescParseTickFormat
int hours = 0;
int minutes = 0;
if (desc.endsWith("pm"))
{
hours += 12;
}
desc = desc.toLowerCase().replaceAll("[^0-9]", "");
@ -189,6 +185,16 @@ public final class DescParseTickFormat
{
throw new NumberFormatException();
}
if (desc.endsWith("pm") && hours != 12)
{
hours += 12;
}
if (desc.endsWith("am") && hours == 12)
{
hours -= 12;
}
return hoursMinutesToTicks(hours, minutes);
}

View File

@ -209,10 +209,10 @@ public class Essentials extends JavaPlugin implements IEssentials
final EssentialsTimer timer = new EssentialsTimer(this);
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50);
Economy.setEss(this);
if (enableErrorLogging)
if (getSettings().isUpdateEnabled())
{
updateTimer = new EssentialsUpdateTimer(this);
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 50, 50 * 60 * (this.getDescription().getVersion().startsWith("Dev") ? 60 : 360));
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60, 20 * 3600 * 6);
}
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
}

View File

@ -68,7 +68,12 @@ public class EssentialsConf extends Configuration
}
}
}
super.load();
try {
super.load();
} catch(RuntimeException e) {
logger.log(Level.INFO, "File: " + configFile.toString());
throw e;
}
if (this.root == null)
{
this.root = new HashMap<String, Object>();

View File

@ -4,65 +4,81 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.entity.Player;
class EssentialsUpdateTimer implements Runnable
{
private URL url;
private final Essentials ess;
private static final Logger logger = Logger.getLogger("Minecraft");
public EssentialsUpdateTimer(Essentials ess)
private transient URL url;
private final transient IEssentials ess;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient Pattern pattern = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*");
public EssentialsUpdateTimer(final IEssentials ess)
{
this.ess = ess;
try
{
url = new URL("http://127.0.0.1:8080/check");
url = new URL("http://essentialsupdate.appspot.com/check");
}
catch (MalformedURLException ex)
{
logger.log(Level.SEVERE, "Invalid url!", ex);
LOGGER.log(Level.SEVERE, "Invalid url!", ex);
}
}
@Override
public void run()
{
try
{
StringBuilder sb = new StringBuilder();
sb.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(),"UTF-8"));
sb.append("&b=").append(URLEncoder.encode(ess.getServer().getVersion(),"UTF-8"));
sb.append("&jv=").append(URLEncoder.encode(System.getProperty("java.version"),"UTF-8"));
sb.append("&l=").append(URLEncoder.encode(Util.getCurrentLocale().toString(),"UTF-8"));
sb.append("&on=").append(URLEncoder.encode(System.getProperty("os.name"),"UTF-8"));
sb.append("&ov=").append(URLEncoder.encode(System.getProperty("os.version"),"UTF-8"));
for (BigInteger bigInteger : ess.getErrors().keySet())
final StringBuilder builder = new StringBuilder();
String bukkitVersion = ess.getServer().getVersion();
final Matcher versionMatch = pattern.matcher(bukkitVersion);
if (versionMatch.matches())
{
sb.append("&e[]=").append(bigInteger.toString(36));
bukkitVersion = versionMatch.group(4);
}
URLConnection conn = url.openConnection();
builder.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(), "UTF-8"));
builder.append("&b=").append(URLEncoder.encode(bukkitVersion, "UTF-8"));
final URLConnection conn = url.openConnection();
conn.setConnectTimeout(10000);
conn.setDoOutput(true);
conn.connect();
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(sb.toString());
wr.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String ret = br.readLine();
wr.close();
br.close();
logger.log(Level.INFO, ret);
final OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(builder.toString());
writer.flush();
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
final String ret = reader.readLine();
writer.close();
reader.close();
if (!ret.isEmpty() && !ret.equalsIgnoreCase("OK"))
{
LOGGER.log(Level.INFO, "Essentials Update-Check: " + ret);
if (ret.startsWith("New Version"))
{
for (Player player : ess.getServer().getOnlinePlayers())
{
final User user = ess.getUser(player);
if (user.isAuthorized("essentials.admin.notices.update"))
{
user.sendMessage(ret);
}
}
}
}
}
catch (IOException ex)
{
logger.log(Level.SEVERE, "Failed to open connection", ex);
LOGGER.log(Level.SEVERE, "Failed to open connection", ex);
}
}
}
}

View File

@ -252,6 +252,79 @@ public class EssentialsUpgrade
doneFile.save();
}
private void updateUsersHomesFormat()
{
if (doneFile.getBoolean("updateUsersHomesFormat", false))
{
return;
}
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
{
return;
}
final File[] userFiles = userdataFolder.listFiles();
for (File file : userFiles)
{
if (!file.isFile() || !file.getName().endsWith(".yml"))
{
continue;
}
final EssentialsConf config = new EssentialsConf(file);
try
{
config.load();
if (config.hasProperty("home") && config.hasProperty("home.default"))
{
@SuppressWarnings("unchecked")
final String defworld = (String)config.getProperty("home.default");
final Location defloc = config.getLocation("home.worlds." + defworld, ess.getServer());
;
config.setProperty("homes.home", defloc);
List<String> worlds = config.getKeys("home.worlds");
Location loc;
String worldName;
if (worlds == null)
{
continue;
}
for (String world : worlds)
{
if (defworld.equalsIgnoreCase(world))
{
continue;
}
loc = config.getLocation("home.worlds." + world, ess.getServer());
if (loc == null)
{
continue;
}
worldName = loc.getWorld().getName().toLowerCase();
if (worldName != null && !worldName.isEmpty())
{
config.setProperty("homes." + worldName, loc);
}
}
config.removeProperty("home");
config.save();
}
}
catch (RuntimeException ex)
{
LOGGER.log(Level.INFO, "File: " + file.toString());
throw ex;
}
}
doneFile.setProperty("updateUsersHomesFormat", true);
doneFile.save();
}
private void moveUsersDataToUserdataFolder()
{
final File usersFile = new File(ess.getDataFolder(), "users.yml");
@ -287,12 +360,12 @@ public class EssentialsUpgrade
}
if (world != null)
{
user.setHome(new Location(world,
((Number)vals.get(0)).doubleValue(),
((Number)vals.get(1)).doubleValue(),
((Number)vals.get(2)).doubleValue(),
((Number)vals.get(3)).floatValue(),
((Number)vals.get(4)).floatValue()), true);
user.setHome("home", new Location(world,
((Number)vals.get(0)).doubleValue(),
((Number)vals.get(1)).doubleValue(),
((Number)vals.get(2)).doubleValue(),
((Number)vals.get(3)).floatValue(),
((Number)vals.get(4)).floatValue()));
}
}
}
@ -513,5 +586,6 @@ public class EssentialsUpgrade
moveUsersDataToUserdataFolder();
convertWarps();
updateUsersPowerToolsFormat();
updateUsersHomesFormat();
}
}

View File

@ -72,6 +72,8 @@ public interface ISettings extends IConf
boolean getReclaimSetting();
boolean getRespawnAtHome();
int getMultipleHomes();
boolean getSortListByGroups();
@ -129,7 +131,9 @@ public interface ISettings extends IConf
boolean isPlayerCommand(String string);
public boolean useBukkitPermissions();
boolean useBukkitPermissions();
public boolean addPrefixSuffix();
boolean addPrefixSuffix();
boolean isUpdateEnabled();
}

View File

@ -22,7 +22,7 @@ public interface IUser
boolean isAuthorized(String node);
boolean isAuthorized(IEssentialsCommand cmd);
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
void setLastTeleportTimestamp(long time);
@ -45,7 +45,9 @@ public interface IUser
void setLastLocation();
Location getHome(Location location);
Location getHome(String name);
Location getHome(Location loc);
String getName();

View File

@ -30,6 +30,12 @@ public class Settings implements ISettings
{
return config.getBoolean("respawn-at-home", false);
}
@Override
public int getMultipleHomes()
{
return config.getInt("multiple-homes", 5);
}
@Override
public boolean getBedSetsHome()
@ -473,4 +479,10 @@ public class Settings implements ISettings
{
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
}
@Override
public boolean isUpdateEnabled()
{
return config.getBoolean("update-check", true);
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Logger;
@ -10,6 +11,8 @@ import org.bukkit.entity.Entity;
public class Teleport implements Runnable
{
private static final double MOVE_CONSTANT = 0.3;
private static class Target
{
private final Location location;
@ -57,9 +60,9 @@ public class Teleport implements Runnable
this.started = System.currentTimeMillis();
this.delay = delay;
this.health = user.getHealth();
this.initX = Math.round(user.getLocation().getX()*MOVE_CONSTANT);
this.initY = Math.round(user.getLocation().getY()*MOVE_CONSTANT);
this.initZ = Math.round(user.getLocation().getZ()*MOVE_CONSTANT);
this.initX = Math.round(user.getLocation().getX() * MOVE_CONSTANT);
this.initY = Math.round(user.getLocation().getY() * MOVE_CONSTANT);
this.initZ = Math.round(user.getLocation().getZ() * MOVE_CONSTANT);
this.teleportTarget = target;
this.chargeFor = chargeFor;
}
@ -72,9 +75,9 @@ public class Teleport implements Runnable
cancel();
return;
}
if (Math.round(user.getLocation().getX()*MOVE_CONSTANT) != initX
|| Math.round(user.getLocation().getY()*MOVE_CONSTANT) != initY
|| Math.round(user.getLocation().getZ()*MOVE_CONSTANT) != initZ
if (Math.round(user.getLocation().getX() * MOVE_CONSTANT) != initX
|| Math.round(user.getLocation().getY() * MOVE_CONSTANT) != initY
|| Math.round(user.getLocation().getZ() * MOVE_CONSTANT) != initZ
|| user.getHealth() < health)
{ // user moved, cancel teleport
cancel(true);
@ -92,7 +95,7 @@ public class Teleport implements Runnable
user.sendMessage(Util.i18n("teleportationCommencing"));
try
{
now(teleportTarget);
if (chargeFor != null)
{
@ -229,7 +232,7 @@ public class Teleport implements Runnable
cooldown(false);
now(new Target(loc));
}
public void now(Location loc, Trade chargeFor) throws Exception
{
cooldown(false);
@ -256,14 +259,9 @@ public class Teleport implements Runnable
back(null);
}
public void home(Trade chargeFor) throws Exception
public void home(IUser user, String home, Trade chargeFor) throws Exception
{
home(user, chargeFor);
}
public void home(IUser user, Trade chargeFor) throws Exception
{
Location loc = user.getHome(this.user.getLocation());
final Location loc = user.getHome(home);
if (loc == null)
{
if (ess.getSettings().spawnIfNoHome())
@ -272,7 +270,7 @@ public class Teleport implements Runnable
}
else
{
throw new Exception(user == this.user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
throw new NotEnoughArgumentsException();
}
}
teleport(new Target(loc), chargeFor);

View File

@ -1,11 +1,13 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import com.earth2me.essentials.register.payment.Method;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -20,44 +22,44 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private final Teleport teleport;
private long lastActivity;
private boolean hidden = false;
User(Player base, IEssentials ess)
{
super(base, ess);
teleport = new Teleport(this, ess);
}
User update(Player base)
{
setBase(base);
return this;
}
public boolean isAuthorized(IEssentialsCommand cmd)
{
return isAuthorized(cmd, "essentials.");
}
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
{
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
}
public boolean isAuthorized(String node)
{
if (isOp())
{
return true;
}
if (isJailed())
{
return false;
}
return ess.getPermissionsHandler().hasPermission(this, node);
}
public void healCooldown() throws Exception
{
Calendar now = new GregorianCalendar();
@ -75,12 +77,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
setLastHealTimestamp(now.getTimeInMillis());
}
public void giveMoney(double value)
{
giveMoney(value, null);
}
public void giveMoney(double value, CommandSender initiator)
{
if (value == 0)
@ -94,7 +96,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
}
}
public void payUser(User reciever, double value) throws Exception
{
if (value == 0)
@ -113,12 +115,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
}
}
public void takeMoney(double value)
{
takeMoney(value, null);
}
public void takeMoney(double value, CommandSender initiator)
{
if (value == 0)
@ -132,43 +134,43 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
}
}
public boolean canAfford(double cost)
{
double mon = getMoney();
return mon >= cost || isAuthorized("essentials.eco.loan");
}
public void dispose()
{
this.base = new OfflinePlayer(getName(), ess);
}
public boolean getJustPortaled()
{
return justPortaled;
}
public void setJustPortaled(boolean value)
{
justPortaled = value;
}
public void setReplyTo(CommandSender user)
{
replyTo = user;
}
public CommandSender getReplyTo()
{
return replyTo;
}
public int compareTo(User t)
{
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
}
@Override
public boolean equals(Object o)
{
@ -177,51 +179,56 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return false;
}
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
}
@Override
public int hashCode()
{
return ChatColor.stripColor(this.getDisplayName()).hashCode();
}
public Boolean canSpawnItem(int itemId)
{
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
}
public Location getHome()
{
return getHome(getHomes().get(0));
}
public void setHome()
{
setHome(getLocation(), true);
setHome("home", getLocation());
}
public void setHome(boolean defaultHome)
public void setHome(String name)
{
setHome(getLocation(), defaultHome);
setHome(name, getLocation());
}
public void setLastLocation()
{
setLastLocation(getLocation());
}
public void requestTeleport(User player, boolean here)
{
teleportRequester = player;
teleportRequestHere = here;
}
public User getTeleportRequest()
{
return teleportRequester;
}
public boolean isTeleportRequestHere()
{
return teleportRequestHere;
}
public String getNick()
{
final StringBuilder nickname = new StringBuilder();
@ -245,12 +252,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
}
}
if (ess.getSettings().addPrefixSuffix())
{
final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
final String suffix = ess.getPermissionsHandler().getSuffix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
nickname.insert(0, prefix);
nickname.append(suffix);
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
@ -258,25 +265,25 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
nickname.append("§f");
}
}
return nickname.toString();
}
public Teleport getTeleport()
{
return teleport;
}
public long getLastActivity()
{
return lastActivity;
}
public void setLastActivity(long timestamp)
{
lastActivity = timestamp;
}
@Override
public double getMoney()
{
@ -298,7 +305,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
return super.getMoney();
}
@Override
public void setMoney(double value)
{
@ -320,14 +327,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
super.setMoney(value);
}
@Override
public void setAfk(boolean set)
{
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
super.setAfk(set);
}
@Override
public boolean toggleAfk()
{
@ -335,17 +342,17 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
return now;
}
public boolean isHidden()
{
return hidden;
}
public void setHidden(boolean hidden)
{
this.hidden = hidden;
}
public void checkJailTimeout(final long currentTime)
{
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
@ -363,7 +370,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
}
}
public void checkMuteTimeout(final long currentTime)
{
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
@ -373,7 +380,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setMuted(false);
}
}
public void checkBanTimeout(final long currentTime)
{
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && ess.getBans().isNameBanned(getName()))

View File

@ -1,15 +1,14 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -36,7 +35,8 @@ public abstract class UserData extends PlayerExtension implements IConf
config.load();
money = _getMoney();
unlimited = _getUnlimited();
powertools = getPowertools();
powertools = _getPowertools();
homes = _getHomes();
lastLocation = _getLastLocation();
lastTeleportTimestamp = _getLastTeleportTimestamp();
lastHealTimestamp = _getLastHealTimestamp();
@ -89,6 +89,88 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("money", value);
config.save();
}
private Map<String, Object> homes;
private Map<String, Object> _getHomes()
{
Object o = config.getProperty("homes");
if (o instanceof Map)
{
return (Map<String, Object>)o;
}
else
{
return new HashMap<String, Object>();
}
}
public Location getHome(String name)
{
Location loc = config.getLocation("homes." + name, getServer());
if (loc == null)
{
try
{
loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer());
}
catch (IndexOutOfBoundsException e)
{
return null;
}
catch (NumberFormatException e)
{
return null;
}
}
return loc;
}
public Location getHome(Location world)
{
Location loc;
for (String home : getHomes())
{
loc = config.getLocation("homes." + home, getServer());
if (world.getWorld() == loc.getWorld())
{
return loc;
}
}
loc = config.getLocation("homes." + getHomes().get(0), getServer());
return loc;
}
public List<String> getHomes()
{
List<String> list = new ArrayList(homes.keySet());
return list;
}
public void setHome(String name, Location loc)
{
homes.put(name, loc);
config.setProperty("homes." + name, loc);
config.save();
}
public void delHome(String name) throws Exception
{
if (getHome(name) != null)
{
homes.remove(name);
config.removeProperty("homes." + name);
config.save();
}
else {
//TODO: move this message to messages file
throw new Exception("Home "+name+" doesn't exist");
}
}
public boolean hasHome()
{
@ -99,40 +181,6 @@ public abstract class UserData extends PlayerExtension implements IConf
return false;
}
public Location getHome(Location location)
{
if (!hasHome())
{
return null;
}
World world = location.getWorld();
String worldHome = "home.worlds." + world.getName().toLowerCase();
if (!config.hasProperty(worldHome))
{
String defaultWorld = config.getString("home.default");
worldHome = "home.worlds." + defaultWorld;
}
Location loc = config.getLocation(worldHome, getServer());
return loc;
}
public void setHome(Location loc, boolean b)
{
String worldName = loc.getWorld().getName().toLowerCase();
if (worldName == null || worldName.isEmpty())
{
logger.log(Level.WARNING, Util.i18n("emptyWorldName"));
return;
}
if (b || !config.hasProperty("home.default"))
{
config.setProperty("home.default", worldName);
}
config.setProperty("home.worlds." + worldName, loc);
config.save();
}
public String getNickname()
{
return config.getString("nickname");
@ -176,10 +224,10 @@ public abstract class UserData extends PlayerExtension implements IConf
private Map<Integer, Object> powertools;
@SuppressWarnings("unchecked")
private Map<Integer, Object> getPowertools()
private Map<Integer, Object> _getPowertools()
{
Object o = config.getProperty("powertools");
if (o instanceof Map)
{
return (Map<Integer, Object>)o;

View File

@ -0,0 +1,42 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.Util;
public class Commanddelhome extends EssentialsCommand
{
public Commanddelhome()
{
super("delhome");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
User user;
String name;
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
else if (args.length < 2)
{
user = ess.getUser(sender);
if (user == null)
{
throw new NotEnoughArgumentsException();
}
name = args[0];
}
else
{
user = getPlayer(server, args, 0);
name = args[1];
}
user.delHome(name.toLowerCase());
sender.sendMessage(Util.format("deleteHome", name));
}
}

View File

@ -4,6 +4,7 @@ import com.earth2me.essentials.Trade;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
public class Commandhome extends EssentialsCommand
@ -18,24 +19,44 @@ public class Commandhome extends EssentialsCommand
{
Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
if(args.length > 0 && user.isAuthorized("essentials.home.others"))
User u = user;
String homeName = "";
String[] nameParts;
if (args.length > 0)
{
User u;
try
nameParts = args[0].split(":");
if (nameParts[0].length() == args[0].length())
{
u = getPlayer(server, args, 0);
homeName = nameParts[0];
}
catch(NoSuchFieldException ex)
else
{
u = ess.getOfflineUser(args[0]);
u = getPlayer(server, nameParts[0].split(" "), 0, true);
if (nameParts.length > 1)
{
homeName = nameParts[1];
}
}
}
try
{
user.getTeleport().home(u, homeName.toLowerCase(), charge);
}
catch (NotEnoughArgumentsException e)
{
List<String> homes = u.getHomes();
if (homes.isEmpty())
{
throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
}
else if ((homes.size() == 1) && u == user)
{
user.getTeleport().home(u, homes.get(0), charge);
}
else
{
user.sendMessage(Util.format("homes", homes.toString()));
}
if (u == null)
{
throw new Exception(Util.i18n("playerNotFound"));
}
user.getTeleport().home(u, charge);
return;
}
user.getTeleport().home(charge);
}
}

View File

@ -19,14 +19,26 @@ public class Commandsethome extends EssentialsCommand
{
if (args.length < 2)
{
user.setHome(args[0].equalsIgnoreCase("default"));
if (user.isAuthorized("essentials.sethome.multiple"))
{
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getMultipleHomes())
|| (user.getHomes().contains(args[0].toLowerCase())))
{
user.setHome(args[0].toLowerCase());
}
else
{
throw new Exception(Util.format("maxHomes", ess.getSettings().getMultipleHomes()));
}
}
}
else
{
if (user.isAuthorized("essentials.sethome.others"))
{
User usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
if(usersHome == null)
if (usersHome == null)
{
usersHome = ess.getOfflineUser(args[0]);
}
@ -34,13 +46,13 @@ public class Commandsethome extends EssentialsCommand
{
throw new Exception(Util.i18n("playerNotFound"));
}
usersHome.setHome(user.getLocation(), args[1].equalsIgnoreCase("default"));
usersHome.setHome(args[1].toLowerCase(), user.getLocation());
}
}
}
else
{
user.setHome(false);
user.setHome();
}
charge(user);
user.sendMessage(Util.i18n("homeSet"));

View File

@ -21,6 +21,7 @@ public class EssentialsSign
{
private static final Set<Material> EMPTY_SET = new HashSet<Material>();
protected transient final String signName;
//TODO: Add these settings to messages
private static final String FORMAT_SUCCESS = "§1[%s]";
private static final String FORMAT_TEMPLATE = "[%s]";
private static final String FORMAT_FAIL = "§4[%s]";

View File

@ -230,6 +230,9 @@ remove-god-on-disconnect: false
# This only works if no other permission plugins are installed
use-bukkit-permissions: false
# Check for updates
update-check: true
############################################################
# +------------------------------------------------------+ #
# | EssentialsHome | #
@ -246,6 +249,10 @@ bed-sethome: false
#if no home is set send you to spawn when /home is used
spawn-if-no-home: false
# If users have essentials.sethome.multiple how many homes can they have
# People with essentials.sethome.multiple.unlimited are not limited by this number
multiple-homes: 5
############################################################
# +------------------------------------------------------+ #

View File

@ -48,6 +48,7 @@ day = day
days = days
defaultBanReason = The Ban Hammer has spoken!
deleteFileError = Could not delete file: {0}
deleteHome = \u00a77Home {0} has been removed.
deleteJail = \u00a77Jail {0} has been removed.
deleteWarp = \u00a77Warp {0} has been removed.
deniedAccessCommand = {0} was denied access to command.
@ -63,7 +64,6 @@ disabled = disabled
dontMoveMessage = \u00a77Teleportation will commence in {0}. Don''t move.
downloadingGeoIp = Downloading GeoIP database ... this might take a while (country: 0.6 MB, city: 20MB)
duplicatedUserdata = Duplicated userdata: {0} and {1}
emptyWorldName = Set Home: World name is null or empty.
enableUnlimited = \u00a77Giving unlimited amount of {0} to {1}.
enabled = enabled
errorCallingCommand = Error calling command /{0}
@ -96,6 +96,7 @@ helpConsole = To view help from the console, type ?.
helpOp = \u00a7c[HelpOp]\u00a7f \u00a77{0}:\u00a7f {1}
helpPages = Page \u00a7c{0}\u00a7f of \u00a7c{1}\u00a7f:
holeInFloor = Hole in floor
homes = Homes: {0}
homeSet = \u00a77Home set.
homeSetToBed = \u00a77Your home is now set to this bed.
hour = hour
@ -154,6 +155,7 @@ mailSent = \u00a77Mail sent!
markMailAsRead = \u00a7cTo mark your mail as read, type /mail clear
markedAsAway = \u00a77You are now marked as away.
markedAsNotAway = \u00a77You are no longer marked as away.
maxHomes=You cannot set more than {0} homes.
mayNotJail = \u00a7cYou may not jail that person
me = me
minute = minute

View File

@ -48,6 +48,7 @@ day = dag
days = dage
defaultBanReason = Ban hammeren har talt!
deleteFileError = Kunne ikke slette fil: {0}
deleteHome = \u00a77Home {0} has been removed.
deleteJail = \u00a77F\u00e6ngsel {0} er fjernet.
deleteWarp = \u00a77Warp {0} er fjernet.
deniedAccessCommand = {0} var n\u00e6gtet adgang til kommando.
@ -63,7 +64,6 @@ disabled = deaktiveret
dontMoveMessage = \u00a77Teleportering vil begynde om {0}. Bev\u00e6g dig ikke.
downloadingGeoIp = Downloader GeoIP database ... det her kan tage et stykke tid (land: 0.6 MB, by: 20MB)
duplicatedUserdata = Duplikerede userdata: {0} og {1}
emptyWorldName = S\u00e6t Hjem: World navn er null eller tom.
enableUnlimited = \u00a77Giver ubegr\u00e6nset m\u00e6ngde af {0} til {1}.
enabled = aktiveret
errorCallingCommand = Fejl ved opkald af kommando /{0}
@ -96,6 +96,7 @@ helpConsole = For at se hj\u00e6lp fra konsolen, skriv ?.
helpOp = \u00a7c[HelpOp]\u00a7f \u00a77{0}:\u00a7f {1}
helpPages = Side \u00a7c{0}\u00a7f af \u00a7c{1}\u00a7f:
holeInFloor = Hul i gulv
homes = Homes: {0}
homeSet = \u00a77Hjem sat.
homeSetToBed = \u00a77Dit hjem er nu sat til denne seng.
hour = time
@ -154,6 +155,7 @@ mailSent = \u00a77Post sendt!
markMailAsRead = \u00a7cTo marker din post som l\u00e6st, skriv /post ryd
markedAsAway = \u00a77Du er nu markeret som v\u00e6k.
markedAsNotAway = \u00a77Du er ikke l\u00e6ngere markeret som v\u00e6k.
maxHomes=You cannot set more than {0} homes.
mayNotJail = \u00a7cDu m\u00e5 ikke f\u00e6ngsle den person
me = mig
minute = minut

View File

@ -48,6 +48,7 @@ day = Tag
days = Tage
defaultBanReason = Der Bann-Hammer hat gesprochen!
deleteFileError = Konnte Datei nicht l\u00f6schen: {0}
deleteHome = \u00a77Home {0} has been removed.
deleteJail = \u00a77Gef\u00e4ngnis {0} wurde gel\u00f6scht.
deleteWarp = \u00a77Warp-Punkt {0} wurde gel\u00f6scht.
deniedAccessCommand = {0} hat keinen Zugriff auf diesen Befehl.
@ -63,7 +64,6 @@ disabled = deaktiviert
dontMoveMessage = \u00a77Teleportvorgang startet in {0}. Beweg dich nicht.
downloadingGeoIp = Lade GeoIP-Datenbank ... dies kann etwas dauern (country: 0.6 MB, city: 20MB)
duplicatedUserdata = Doppelte Datei in userdata: {0} und {1}
emptyWorldName = /sethome: Weltname ist null oder leer.
enableUnlimited = \u00a77Gebe {1} unendliche Mengen von {0}.
enabled = aktiviert
errorCallingCommand = Fehler beim Aufrufen des Befehls /{0}
@ -96,6 +96,7 @@ helpConsole = Um die Hilfe der Konsole zu sehen, schreibe ?.
helpOp = \u00a7c[Hilfe]\u00a7f \u00a77{0}:\u00a7f {1}
helpPages = Seite \u00a7c{0}\u00a7f von \u00a7c{1}\u00a7f:
holeInFloor = Loch im Boden
homes = Homes: {0}
homeSet = \u00a77Zuhause gesetzt.
homeSetToBed = \u00a77Dein Zuhause ist nun an diesem Bett.
hour = Stunde
@ -154,6 +155,7 @@ mailSent = \u00a77Nachricht gesendet!
markMailAsRead = \u00a7cUm deine Nachrichten zu l\u00f6schen, schreibe /mail clear
markedAsAway = \u00a77Du wirst als abwesend angezeigt.
markedAsNotAway = \u00a77Du wirst nicht mehr als abwesend angezeigt.
maxHomes=You cannot set more than {0} homes.
mayNotJail = \u00a7cDu kannst diese Person nicht einsperren.
me = mir
minute = Minute

View File

@ -48,6 +48,7 @@ day = day
days = days
defaultBanReason = The Ban Hammer has spoken!
deleteFileError = Could not delete file: {0}
deleteHome = \u00a77Home {0} has been removed.
deleteJail = \u00a77Jail {0} has been removed.
deleteWarp = \u00a77Warp {0} has been removed.
deniedAccessCommand = {0} was denied access to command.
@ -63,7 +64,6 @@ disabled = disabled
dontMoveMessage = \u00a77Teleportation will commence in {0}. Don''t move.
downloadingGeoIp = Downloading GeoIP database ... this might take a while (country: 0.6 MB, city: 20MB)
duplicatedUserdata = Duplicated userdata: {0} and {1}
emptyWorldName = Set Home: World name is null or empty.
enableUnlimited = \u00a77Giving unlimited amount of {0} to {1}.
enabled = enabled
errorCallingCommand = Error calling command /{0}
@ -96,6 +96,7 @@ helpConsole = To view help from the console, type ?.
helpOp = \u00a7c[HelpOp]\u00a7f \u00a77{0}:\u00a7f {1}
helpPages = Page \u00a7c{0}\u00a7f of \u00a7c{1}\u00a7f:
holeInFloor = Hole in floor
homes = Homes: {0}
homeSet = \u00a77Home set.
homeSetToBed = \u00a77Your home is now set to this bed.
hour = hour
@ -154,6 +155,7 @@ mailSent = \u00a77Mail sent!
markMailAsRead = \u00a7cTo mark your mail as read, type /mail clear
markedAsAway = \u00a77You are now marked as away.
markedAsNotAway = \u00a77You are no longer marked as away.
maxHomes=You cannot set more than {0} homes.
mayNotJail = \u00a7cYou may not jail that person
me = me
minute = minute

View File

@ -48,6 +48,7 @@ day = jour
days = jours
defaultBanReason = Le marteau du ban a frapp\u00e9!
deleteFileError = Le fichier n''a pas pu \u00eatre supprim\u00e9: {0}
deleteHome = \u00a77Home {0} has been removed.
deleteJail = \u00a77La prison {0} a \u00e9t\u00e9 supprim\u00e9e.
deleteWarp = \u00a77Warp {0} supprim\u00e9.
deniedAccessCommand = L''acc\u00e8s \u00e0 la commande a \u00e9t\u00e9 refus\u00e9 pour {0}.
@ -63,7 +64,6 @@ disabled = d\u00e9sactiv\u00e9
dontMoveMessage = \u00a77La t\u00e9l\u00e9portation commence dans {0}. Ne bougez pas.
downloadingGeoIp = T\u00e9l\u00e9chargement de la base de donn\u00e9es GeoIP ... cela peut prendre un moment (campagne : 0.6 Mo, ville : 20Mo)
duplicatedUserdata = Donn\u00e9e utilisateur dupliqu\u00e9e: {0} et {1}
emptyWorldName = Set Home: Le nom du monte est nul ou vide.
enableUnlimited = \u00a77Donner un nombre illimit\u00e9 de {0} \u00e0 {1}.
enabled = activ\u00e9
errorCallingCommand = Erreur en appelant la commande /{0}
@ -96,6 +96,7 @@ helpConsole = Pour voir l''aide tapez ?
helpOp = \u00a7c[Aide Admin]\u00a7f \u00a77{0}:\u00a7f {1}
helpPages = Page \u00a7c{0}\u00a7f sur \u00a7c{1}\u00a7f.
holeInFloor = Trou dans le Sol.
homes = Homes: {0}
homeSet = \u00a77Home d\u00e9fini.
homeSetToBed = \u00a77Votre home est d\u00e9sormais d\u00e9fini sur ce lit.
hour = heure
@ -154,6 +155,7 @@ mailSent = \u00a77Courrier envoy\u00e9 !
markMailAsRead = \u00a7cPour marquer votre courrier en tant que lu, entrez /mail clear
markedAsAway = \u00a77Vous \u00eates d\u00e9sormais AFK.
markedAsNotAway = \u00a77Vous n''\u00eates d\u00e9sormais plus AFK.
maxHomes=You cannot set more than {0} homes.
mayNotJail = \u00a7cVous ne pouvez pas emprisonner cette personne.
me = moi
minute = minute

View File

@ -48,6 +48,7 @@ day = dag
days = dagen
defaultBanReason = De Ban Hamer heeft gesproken!
deleteFileError = Het bestand kon niet verwijderd worden: {0}
deleteHome = \u00a77Home {0} has been removed.
deleteJail = \u00a77Gevangenis {0} is verwijderd.
deleteWarp = \u00a77Warp {0} is verwijderd.
deniedAccessCommand = {0} was de toegang verboden tot het commando.
@ -63,7 +64,6 @@ disabled = uitgeschakeld
dontMoveMessage = \u00a77Beginnen met teleporteren in {0}. Niet bewegen.
downloadingGeoIp = Bezig met downloaden van GeoIP database ... Dit kan een tijdje duren (country: 0.6 MB, city: 20MB)
duplicatedUserdata = Dubbele userdata: {0} en {1}.
emptyWorldName = Set Home: Naam van wereld is leeg.
enableUnlimited = \u00a77Oneindig aantal {0} aan {1} gegeven.
enabled = ingeschakeld
errorCallingCommand = Fout bij het aanroepen van de opdracht /{0}
@ -96,6 +96,7 @@ helpConsole = type ? om de consolehelp weer te geven.
helpOp = \u00a7c[HelpOp]\u00a7f \u00a77{0}:\u00a7f {1}
helpPages = Pagina \u00a7c{0}\u00a7f van de \u00a7c{1}\u00a7f:
holeInFloor = Gat in de vloer
homes = Homes: {0}
homeSet = \u00a77Home ingesteld.
homeSetToBed = \u00a77Je home is is nu verplaatst naar dit bed.
hour = uur
@ -154,6 +155,7 @@ mailSent = \u00a77Bericht verzonden!
markMailAsRead = \u00a7cType /mail clear, om je berichten als gelezen te markeren
markedAsAway = \u00a77Je staat nu als afwezig gemeld.
markedAsNotAway = \u00a77Je staat niet meer als afwezig gemeld.
maxHomes=You cannot set more than {0} homes.
mayNotJail = \u00a7cJe mag die speler niet in de gevangenis zetten.
me = me
minute = minuut

View File

@ -59,6 +59,10 @@ commands:
description: Describes your current bearing.
usage: /<command>
aliases: [ecompass]
delhome:
description: Removes a home
usage: /<command> [player] <name>
aliases: [edelhome,remhome,rmhome,eremhome,ermhome]
deljail:
description: Removes a jail
usage: /<command> [jailname]
@ -223,9 +227,9 @@ commands:
usage: /<command>
aliases: [rel,ereloadall,ereload,erel]
repair:
description: Repairs the item in hand, or all items in the current inventory.
description: Repairs the durability of all or one item.
usage: /<command> [hand|all]
aliases: [fix]
aliases: [fix,erepair,efix]
rules:
description: Views the server rules.
usage: /<command>