summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java1
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java40
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/UserData.java29
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandhome.java24
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandlist.java22
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java4
-rw-r--r--Essentials/src/config.yml10
-rw-r--r--Essentials/src/messages.properties4
-rw-r--r--Essentials/src/messages_da.properties4
-rw-r--r--Essentials/src/messages_de.properties4
-rw-r--r--Essentials/src/messages_en.properties4
-rw-r--r--Essentials/src/messages_es.properties4
-rw-r--r--Essentials/src/messages_fr.properties4
-rw-r--r--Essentials/src/messages_nl.properties4
-rw-r--r--Essentials/test/com/earth2me/essentials/UserTest.java22
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java29
18 files changed, 112 insertions, 105 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index 7c728b0b4..5ede55fc5 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -178,7 +178,6 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_LOGIN, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, this);
- pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_EGG_THROW, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this);
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index c6cbfe232..f92f9d808 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -231,12 +231,12 @@ public class EssentialsPlayerListener extends PlayerListener
private void updateCompass(final User user)
{
- try
- {
- user.setCompassTarget(user.getHome(user.getLocation()));
+ Location loc = user.getHome(user.getLocation());
+ if (loc == null) {
+ loc = user.getBedSpawnLocation();
}
- catch (Exception ex)
- {
+ if (loc != null) {
+ user.setCompassTarget(loc);
}
}
@@ -256,32 +256,6 @@ public class EssentialsPlayerListener extends PlayerListener
}
@Override
- public void onPlayerInteract(final PlayerInteractEvent event)
- {
- if (event.isCancelled())
- {
- return;
- }
- if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
- {
- return;
- }
-
- if (ess.getSettings().getBedSetsHome() && event.getClickedBlock().getType() == Material.BED_BLOCK)
- {
- try
- {
- final User user = ess.getUser(event.getPlayer());
- user.setHome();
- user.sendMessage(_("homeSetToBed"));
- }
- catch (Throwable ex)
- {
- }
- }
- }
-
- @Override
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -387,7 +361,7 @@ public class EssentialsPlayerListener extends PlayerListener
}
@Override
- public void onPlayerChangedWorld(PlayerChangedWorldEvent event)
+ public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
{
if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName())) {
User user = ess.getUser(event.getPlayer());
@@ -395,5 +369,5 @@ public class EssentialsPlayerListener extends PlayerListener
user.sendMessage(_("noGodWorldWarning"));
}
}
- }
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index 7891190dc..e7ce92a55 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -21,8 +21,6 @@ public interface ISettings extends IConf
long getBackupInterval();
- boolean getBedSetsHome();
-
String getChatFormat(String group);
int getChatRadius();
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index 47a102326..ab5b0a364 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -37,12 +37,6 @@ public class Settings implements ISettings
}
@Override
- public boolean getBedSetsHome()
- {
- return config.getBoolean("bed-sethome", false);
- }
-
- @Override
public List<String> getMultipleHomes()
{
return config.getKeys("sethome-multiple");
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java
index d9dad769d..9df1b0342 100644
--- a/Essentials/src/com/earth2me/essentials/UserData.java
+++ b/Essentials/src/com/earth2me/essentials/UserData.java
@@ -130,27 +130,32 @@ public abstract class UserData extends PlayerExtension implements IConf
return loc;
}
- public Location getHome(Location world) throws Exception
+ public Location getHome(final Location world)
{
- Location loc;
- for (String home : getHomes())
+ try
{
- loc = config.getLocation("homes." + home, getServer());
- if (world.getWorld() == loc.getWorld())
+ Location loc;
+ for (String home : getHomes())
{
- return loc;
- }
+ loc = config.getLocation("homes." + home, getServer());
+ if (world.getWorld() == loc.getWorld())
+ {
+ return loc;
+ }
+ }
+ loc = config.getLocation("homes." + getHomes().get(0), getServer());
+ return loc;
+ }
+ catch (Exception ex)
+ {
+ return null;
}
- loc = config.getLocation("homes." + getHomes().get(0), getServer());
- return loc;
}
public List<String> getHomes()
{
- List<String> list = new ArrayList(homes.keySet());
- return list;
-
+ return new ArrayList(homes.keySet());
}
public void setHome(String name, Location loc)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
index 5478ab986..090cebd4c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
@@ -6,6 +6,7 @@ import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
import java.util.Locale;
+import org.bukkit.Location;
import org.bukkit.Server;
@@ -42,14 +43,32 @@ public class Commandhome extends EssentialsCommand
}
try
{
+ if ("bed".equalsIgnoreCase(homeName)) {
+ final Location bed = player.getBedSpawnLocation();
+ if (bed != null)
+ {
+ user.getTeleport().teleport(bed, charge);
+ }
+ }
user.getTeleport().home(player, homeName.toLowerCase(Locale.ENGLISH), charge);
}
catch (NotEnoughArgumentsException e)
{
final List<String> homes = player.getHomes();
- if (homes.isEmpty() && player.equals(user) && ess.getSettings().spawnIfNoHome())
+ if (homes.isEmpty() && player.equals(user))
{
- user.getTeleport().respawn(ess.getSpawn(), charge);
+ final Location loc = player.getBedSpawnLocation();
+ if (loc == null)
+ {
+ if (ess.getSettings().spawnIfNoHome())
+ {
+ user.getTeleport().respawn(ess.getSpawn(), charge);
+ }
+ }
+ else
+ {
+ user.getTeleport().teleport(loc, charge);
+ }
}
else if (homes.isEmpty())
{
@@ -61,6 +80,7 @@ public class Commandhome extends EssentialsCommand
}
else
{
+ homes.add("bed");
user.sendMessage(_("homes", Util.joinList(homes)));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
index 549f6efac..92833a66c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
@@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.*;
-import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -39,16 +38,15 @@ public class Commandlist extends EssentialsCommand
playerHidden++;
}
}
- //TODO: move these to messages file
- final StringBuilder online = new StringBuilder();
- online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden);
+
+ String online;
if (showhidden && playerHidden > 0)
{
- online.append(ChatColor.GRAY).append("/").append(playerHidden);
+ online = _("listAmountHidden", server.getOnlinePlayers().length - playerHidden, playerHidden, server.getMaxPlayers());
+ } else {
+ online = _("listAmount",server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
}
- online.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
- online.append(ChatColor.BLUE).append(" players online.");
- sender.sendMessage(online.toString());
+ sender.sendMessage(online);
if (ess.getSettings().getSortListByGroups())
{
@@ -90,11 +88,11 @@ public class Commandlist extends EssentialsCommand
}
if (user.isAfk())
{
- groupString.append("§7[AFK]§f");
+ groupString.append(_("listAfkTag"));
}
if (user.isHidden())
{
- groupString.append("§7[HIDDEN]§f");
+ groupString.append(_("listHiddenTag"));
}
groupString.append(user.getDisplayName());
groupString.append("§f");
@@ -131,11 +129,11 @@ public class Commandlist extends EssentialsCommand
}
if (user.isAfk())
{
- onlineUsers.append("§7[AFK]§f");
+ onlineUsers.append(_("listAfkTag"));
}
if (user.isHidden())
{
- onlineUsers.append("§7[HIDDEN]§f");
+ onlineUsers.append(_("listHiddenTag"));
}
onlineUsers.append(user.getDisplayName());
onlineUsers.append("§f");
diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
index 63717fcae..6b9d17b26 100644
--- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
+++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
@@ -47,6 +47,10 @@ public abstract class EssentialsCommand implements IEssentialsCommand
{
throw new NotEnoughArgumentsException();
}
+ if (args[pos].isEmpty())
+ {
+ throw new NoSuchFieldException(_("playerNotFound"));
+ }
final User user = ess.getUser(args[pos]);
if (user != null)
{
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml
index cf39007e3..a68630f67 100644
--- a/Essentials/src/config.yml
+++ b/Essentials/src/config.yml
@@ -236,15 +236,11 @@ no-god-in-worlds:
# +------------------------------------------------------+ #
############################################################
-# When users die, should they respawn at their homes, instead of the spawnpoint?
+# When users die, should they respawn at their first home, instead of the spawnpoint or bed?
respawn-at-home: false
-# When a user interacts with a bed, should their home be set to that location?
-# If you enable this and remove default user access to the /sethome command, you can make beds the only way for players to set their home location.
-bed-sethome: false
-
-# If no home is set send you to spawn when /home is used
-spawn-if-no-home: false
+# If no home is set send you to bed or spawn when /home is used
+spawn-if-no-home: true
# Allow players to have multiple homes.
# Define different amounts of multiple homes for different permissions, e.g. essentials.sethome.multiple.vip
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index fdbe917df..e0a23002b 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -153,6 +153,10 @@ kitTimed=\u00a7cYou can''t use that kit again for another {0}.
kits=\u00a77Kits: {0}
lightningSmited=\u00a77You have just been smited
lightningUse=\u00a77Smiting {0}
+listAfkTag = \u00a77[AFK]\u00a7f
+listAmount = \u00a79There are \u00a7c{0}\u00a79 out of maximum \u00a7c{1}\u00a79 players online.
+listAmountHidden = \u00a79There are \u00a7c{0}\u00a77/{1}\u00a79 out of maximum \u00a7c{2}\u00a79 players online.
+listHiddenTag = \u00a77[HIDDEN]\u00a7f
loadWarpError=Failed to load warp {0}
loadinfo=Loaded {0} build {1} by: {2}
localFormat=Local: <{0}> {1}
diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties
index dd2ee3b97..53bf399f3 100644
--- a/Essentials/src/messages_da.properties
+++ b/Essentials/src/messages_da.properties
@@ -153,6 +153,10 @@ kitTimed=\u00a7cDu kan ikke den pakke igen f\u00f8r om {0}.
kits=\u00a77Pakker: {0}
lightningSmited=\u00a77Du er blevet sl\u00e5et
lightningUse=\u00a77Sl\u00e5r {0}
+listAfkTag = \u00a77[AFK]\u00a7f
+listAmount = \u00a79There are \u00a7c{0}\u00a79 out of maximum \u00a7c{1}\u00a79 players online.
+listAmountHidden = \u00a79There are \u00a7c{0}\u00a77/{1}\u00a79 out of maximum \u00a7c{2}\u00a79 players online.
+listHiddenTag = \u00a77[HIDDEN]\u00a7f
loadWarpError=Kunne ikke indl\u00e6se warp {0}
loadinfo=Indl\u00e6ste {0} byg {1} af {2}
localFormat=Lokal: <{0}> {1}
diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties
index d14141507..e0bd6dca7 100644
--- a/Essentials/src/messages_de.properties
+++ b/Essentials/src/messages_de.properties
@@ -153,6 +153,10 @@ kitTimed=\u00a7cDu kannst diese Ausr\u00fcstung nicht innerhalb von {0} anforder
kits=\u00a77Ausr\u00fcstungen: {0}
lightningSmited=\u00a77Du wurdest gepeinigt.
lightningUse=\u00a77Peinige {0}
+listAfkTag = \u00a77[Inaktiv]\u00a7f
+listAmount = \u00a79Es sind \u00a7c{0}\u00a79 von maximal \u00a7c{1}\u00a79 Spielern online.
+listAmountHidden = \u00a79Es sind \u00a7c{0}\u00a77/{1}\u00a79 von maximal \u00a7c{2}\u00a79 Spielern online.
+listHiddenTag = \u00a77[Versteckt]\u00a7f
loadWarpError=Fehler beim Laden von Warp-Punkt {0}
loadinfo=Plugin {0} Version {1} geladen, erstellt von {2}, \u00fcbersetzt von snowleo
localFormat=Lokal: <{0}> {1}
diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties
index 8843cf194..e89004bf7 100644
--- a/Essentials/src/messages_en.properties
+++ b/Essentials/src/messages_en.properties
@@ -153,6 +153,10 @@ kitTimed=\u00a7cYou can''t use that kit again for another {0}.
kits=\u00a77Kits: {0}
lightningSmited=\u00a77You have just been smited
lightningUse=\u00a77Smiting {0}
+listAfkTag = \u00a77[AFK]\u00a7f
+listAmount = \u00a79There are \u00a7c{0}\u00a79 out of maximum \u00a7c{1}\u00a79 players online.
+listAmountHidden = \u00a79There are \u00a7c{0}\u00a77/{1}\u00a79 out of maximum \u00a7c{2}\u00a79 players online.
+listHiddenTag = \u00a77[HIDDEN]\u00a7f
loadWarpError=Failed to load warp {0}
loadinfo=Loaded {0} build {1} by: {2}
localFormat=Local: <{0}> {1}
diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties
index 95fda63ac..ffa0af2ce 100644
--- a/Essentials/src/messages_es.properties
+++ b/Essentials/src/messages_es.properties
@@ -153,6 +153,10 @@ kitTimed=\u00a7c No puedes usar ese kit de nuevo para otro{0}.
kits=\u00a77Kits: {0}
lightningSmited=\u00a77Acabas de ser golpeado
lightningUse=\u00a77Golpeando a {0}
+listAfkTag = \u00a77[AFK]\u00a7f
+listAmount = \u00a79There are \u00a7c{0}\u00a79 out of maximum \u00a7c{1}\u00a79 players online.
+listAmountHidden = \u00a79There are \u00a7c{0}\u00a77/{1}\u00a79 out of maximum \u00a7c{2}\u00a79 players online.
+listHiddenTag = \u00a77[HIDDEN]\u00a7f
loadWarpError=Error al cargar el tenetransporte {0}
loadinfo=Cargado {0}, construido {1} por: {2}
localFormat=Local: <{0}> {1}
diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties
index f64968250..1d3cddea0 100644
--- a/Essentials/src/messages_fr.properties
+++ b/Essentials/src/messages_fr.properties
@@ -153,6 +153,10 @@ kitTimed=\u00a7cVous ne pouvez pas utiliser ce kit pendant encore {0}.
kits=\u00a77Kits:{0}
lightningSmited=\u00a77Vous venez d''\u00eatre foudroy\u00e9
lightningUse=\u00a77{0} a \u00e9t\u00e9 foudroy\u00e9
+listAfkTag = \u00a77[AFK]\u00a7f
+listAmount = \u00a79There are \u00a7c{0}\u00a79 out of maximum \u00a7c{1}\u00a79 players online.
+listAmountHidden = \u00a79There are \u00a7c{0}\u00a77/{1}\u00a79 out of maximum \u00a7c{2}\u00a79 players online.
+listHiddenTag = \u00a77[HIDDEN]\u00a7f
loadWarpError=\u00c9chec du chargement du warp {0}
loadinfo={0} version {1} par {2} a \u00e9t\u00e9 charg\u00e9
localFormat=Local:<{0}> {1}
diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties
index 5907a1047..ea0cf99d8 100644
--- a/Essentials/src/messages_nl.properties
+++ b/Essentials/src/messages_nl.properties
@@ -153,6 +153,10 @@ kitTimed=\u00a7cJe kan die kit pas weer gebruiken over {0}.
kits=\u00a77Kits: {0}
lightningSmited=\u00a77Je bent zojuist verbrand
lightningUse=\u00a77Brand {0}
+listAfkTag = \u00a77[AFK]\u00a7f
+listAmount = \u00a79There are \u00a7c{0}\u00a79 out of maximum \u00a7c{1}\u00a79 players online.
+listAmountHidden = \u00a79There are \u00a7c{0}\u00a77/{1}\u00a79 out of maximum \u00a7c{2}\u00a79 players online.
+listHiddenTag = \u00a77[HIDDEN]\u00a7f
loadWarpError=Fout bij het laden van warp {0}
loadinfo=Build {1} geladen {0} van {2}
localFormat=Local: <{0}> {1}
diff --git a/Essentials/test/com/earth2me/essentials/UserTest.java b/Essentials/test/com/earth2me/essentials/UserTest.java
index 35244ac90..ef9ab515d 100644
--- a/Essentials/test/com/earth2me/essentials/UserTest.java
+++ b/Essentials/test/com/earth2me/essentials/UserTest.java
@@ -54,21 +54,15 @@ public class UserTest extends TestCase
user.setHome();
OfflinePlayer base2 = server.createPlayer(base1.getName(), ess);
User user2 = ess.getUser(base2);
- try
- {
- Location home = user2.getHome(loc);
- assertEquals(loc.getWorld().getName(), home.getWorld().getName());
- assertEquals(loc.getX(), home.getX());
- assertEquals(loc.getY(), home.getY());
- assertEquals(loc.getZ(), home.getZ());
- assertEquals(loc.getYaw(), home.getYaw());
- assertEquals(loc.getPitch(), home.getPitch());
- }
- catch (Exception ex)
- {
- fail("Exception");
- }
+ Location home = user2.getHome(loc);
+ assertNotNull(home);
+ assertEquals(loc.getWorld().getName(), home.getWorld().getName());
+ assertEquals(loc.getX(), home.getX());
+ assertEquals(loc.getY(), home.getY());
+ assertEquals(loc.getZ(), home.getZ());
+ assertEquals(loc.getYaw(), home.getYaw());
+ assertEquals(loc.getPitch(), home.getPitch());
}
public void testMoney()
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
index a5d1efba9..57b842c82 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
@@ -15,8 +15,9 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
{
private final transient IEssentials ess;
- public EssentialsSpawnPlayerListener(IEssentials ess)
+ public EssentialsSpawnPlayerListener(final IEssentials ess)
{
+ super();
this.ess = ess;
}
@@ -25,28 +26,24 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
{
final User user = ess.getUser(event.getPlayer());
- try
+ if (ess.getSettings().getRespawnAtHome())
{
- if (ess.getSettings().getRespawnAtHome())
+ Location home = user.getHome(user.getLocation());
+ if (home == null)
+ {
+ home = user.getBedSpawnLocation();
+ }
+ if (home != null)
{
- Location home = user.getHome(user.getLocation());
- if (home == null)
- {
- throw new Exception();
- }
event.setRespawnLocation(home);
return;
}
}
- catch (Throwable ex)
+ final Location spawn = ess.getSpawn().getSpawn(user.getGroup());
+ if (spawn != null)
{
+ event.setRespawnLocation(spawn);
}
- Location spawn = ess.getSpawn().getSpawn(user.getGroup());
- if (spawn == null)
- {
- return;
- }
- event.setRespawnLocation(spawn);
}
@Override
@@ -54,7 +51,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
{
final User user = ess.getUser(event.getPlayer());
- if (!user.isNew())
+ if (!user.isNew() || user.getBedSpawnLocation() != null)
{
return;
}