summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2011-12-01 15:15:45 +0000
committerKHobbits <rob@khobbits.co.uk>2011-12-01 15:15:45 +0000
commitb0377498f72814cb78e1ffd0286ffd4a92333f50 (patch)
tree00180217195c9bbc58fd48deb112f5b10ba26b8f
parent00d44873ca4bb810add4d49aa5e5b6d4545c727a (diff)
downloadEssentials-b0377498f72814cb78e1ffd0286ffd4a92333f50.tar
Essentials-b0377498f72814cb78e1ffd0286ffd4a92333f50.tar.gz
Essentials-b0377498f72814cb78e1ffd0286ffd4a92333f50.tar.lz
Essentials-b0377498f72814cb78e1ffd0286ffd4a92333f50.tar.xz
Essentials-b0377498f72814cb78e1ffd0286ffd4a92333f50.zip
Better distance checking.
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandnear.java20
-rw-r--r--Essentials/src/messages.properties2
-rw-r--r--Essentials/src/messages_da.properties2
-rw-r--r--Essentials/src/messages_de.properties2
-rw-r--r--Essentials/src/messages_en.properties2
-rw-r--r--Essentials/src/messages_es.properties2
-rw-r--r--Essentials/src/messages_fr.properties2
-rw-r--r--Essentials/src/messages_nl.properties2
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java37
9 files changed, 32 insertions, 39 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnear.java b/Essentials/src/com/earth2me/essentials/commands/Commandnear.java
index 4df3598da..cfb8d671b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnear.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnear.java
@@ -16,7 +16,6 @@ public class Commandnear extends EssentialsCommand
super("near");
}
- //Todo Translate
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
@@ -34,26 +33,23 @@ public class Commandnear extends EssentialsCommand
user.sendMessage(_("nearbyPlayers", getLocal(server, user, radius)));
}
- private String getLocal(final Server server, final User user, final long radius)
+ private String getLocal(final Server server, final User user, long radius)
{
final Location loc = user.getLocation();
- final World world = loc.getWorld();
- final int x = loc.getBlockX();
- final int y = loc.getBlockY();
- final int z = loc.getBlockZ();
+ final World world = loc.getWorld();
final StringBuilder output = new StringBuilder();
+ radius *= radius;
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User player = ess.getUser(onlinePlayer);
if (!player.equals(user) && !player.isHidden())
{
- final Location l = player.getLocation();
- final int dx = x - l.getBlockX();
- final int dy = y - l.getBlockY();
- final int dz = z - l.getBlockZ();
- final long delta = dx * dx + dy * dy + dz * dz;
- if (delta > radius || world != l.getWorld())
+ final Location playerLoc = player.getLocation();
+ if (playerLoc.getWorld() != world) { continue; }
+
+ final double delta = playerLoc.distanceSquared(loc);
+ if (delta > radius)
{
if (output.length() > 0)
{
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index 2c1b754ec..5d1efdf65 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -221,7 +221,7 @@ noMailSendPerm=\u00a7cYou do not have the \u00a7fessentials.mail.send\u00a7c per
noMotd=\u00a7cThere is no message of the day.
noNewMail=\u00a77You have no new mail.
noPendingRequest=You do not have a pending request.
-noPermToSpawnMob=\u00a7cYou don't have permission to spawn this mob.
+noPermToSpawnMob=\u00a7cYou don''t have permission to spawn this mob.
noPlacePermission=\u00a7cYou do not have permission to place a block near that sign.
noPowerTools=You have no power tools assigned.
noRules=\u00a7cThere are no rules specified yet.
diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties
index 16e57fbf0..c5d9dc411 100644
--- a/Essentials/src/messages_da.properties
+++ b/Essentials/src/messages_da.properties
@@ -221,7 +221,7 @@ noMailSendPerm=\u00a7cDu har ikke \u00a7fessentials.mail.send\u00a7c tilladelsen
noMotd=\u00a7cDer er ikke nogen besked for dagen.
noNewMail=\u00a77Du har ingen ny post.
noPendingRequest=Du har ikke en ventende anmodning.
-noPermToSpawnMob=\u00a7cYou don't have permission to spawn this mob.
+noPermToSpawnMob=\u00a7cYou don''t have permission to spawn this mob.
noPlacePermission=\u00a7cYou do not have permission to place a block near that sign.
noPowerTools= You have no power tools assigned.
noRules=\u00a7cDer er ingen regler fastsat endnu.
diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties
index 0865a4b37..75510937f 100644
--- a/Essentials/src/messages_de.properties
+++ b/Essentials/src/messages_de.properties
@@ -221,7 +221,7 @@ noMailSendPerm=\u00a7cDu hast die Rechte \u00a7fessentials.mail.send\u00a7c nich
noMotd=\u00a7cEs existiert keine Willkommensnachricht.
noNewMail=\u00a77Du hast keine Nachrichten.
noPendingRequest=Du hast keine Teleportierungsanfragen.
-noPermToSpawnMob=\u00a7cYou don't have permission to spawn this mob.
+noPermToSpawnMob=\u00a7cYou don''t have permission to spawn this mob.
noPlacePermission=\u00a7cDu hast keine Rechte, einen Block in der N\u00e4he des Schildes zu platzieren.
noPowerTools=Du hast keine Powertools zugewiesen.
noRules=\u00a7cEs wurden keine Regeln definiert.
diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties
index 373aa6129..28e7bd99f 100644
--- a/Essentials/src/messages_en.properties
+++ b/Essentials/src/messages_en.properties
@@ -221,7 +221,7 @@ noMailSendPerm=\u00a7cYou do not have the \u00a7fessentials.mail.send\u00a7c per
noMotd=\u00a7cThere is no message of the day.
noNewMail=\u00a77You have no new mail.
noPendingRequest=You do not have a pending request.
-noPermToSpawnMob=\u00a7cYou don't have permission to spawn this mob.
+noPermToSpawnMob=\u00a7cYou don''t have permission to spawn this mob.
noPlacePermission=\u00a7cYou do not have permission to place a block near that sign.
noPowerTools=You have no power tools assigned.
noRules=\u00a7cThere are no rules specified yet.
diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties
index 3955f9f2a..b4fc3afb9 100644
--- a/Essentials/src/messages_es.properties
+++ b/Essentials/src/messages_es.properties
@@ -221,7 +221,7 @@ noMailSendPerm=\u00a7cNo tienes el permiso de \u00a7fessentials.mail.send\u00a7c
noMotd=\u00a7cNo hay ningun mensaje del dia.
noNewMail=\u00a77No tienes ningun correo nuevo.
noPendingRequest=No tienes ninguna peticion pendiente.
-noPermToSpawnMob=\u00a7cYou don't have permission to spawn this mob.
+noPermToSpawnMob=\u00a7cYou don''t have permission to spawn this mob.
noPlacePermission=\u00a7cNo tienes permiso para situar ese bloque en ese lugar.
noPowerTools=You have no power tools assigned.
noRules=\u00a7cNo hay reglas especificadas todavia.
diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties
index a25da6368..ef72f4f8b 100644
--- a/Essentials/src/messages_fr.properties
+++ b/Essentials/src/messages_fr.properties
@@ -221,7 +221,7 @@ noMailSendPerm=\u00a7cVous n''avez pas la permission \u00a7fessentials.mail.send
noMotd=\u00a7cIl n''y a pas de message su jour.
noNewMail=\u00a77Vous n''avez pas de courrier.
noPendingRequest=Vous n''avez pas de requ\u00eate non lue.
-noPermToSpawnMob=\u00a7cYou don't have permission to spawn this mob.
+noPermToSpawnMob=\u00a7cYou don''t have permission to spawn this mob.
noPlacePermission=\u00a7cVous n''avez pas la permission de placer un bloc pr\u00c3\u00a8 de cette pancarte.
noPowerTools=Vous n''avez pas d''outil automatique associ\u00e9.
noRules=\u00a7cIl n''y a pas encore de r\u00c3\u00a8gles d\u00e9finies.
diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties
index ab5a93928..c101cc0be 100644
--- a/Essentials/src/messages_nl.properties
+++ b/Essentials/src/messages_nl.properties
@@ -221,7 +221,7 @@ noMailSendPerm=\u00a7cJe hebt de \u00a7fessentials.mail.send\u00a7c toestemming
noMotd=\u00a7cEr is geen bericht van de dag.
noNewMail=\u00a77Je hebt geen nieuwe berichten.
noPendingRequest=Je hebt geen aanvragen.
-noPermToSpawnMob=\u00a7cYou don't have permission to spawn this mob.
+noPermToSpawnMob=\u00a7cYou don''t have permission to spawn this mob.
noPlacePermission=\u00a7cJe hebt geen toestemming om een blok naast die sign te plaatsen.
noPowerTools=You have no power tools assigned.
noRules=\u00a7cEr zijn nog geen regels gegeven.
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
index 305e13e8a..2d6e1ae4e 100644
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
@@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerListener;
-
+//TODO: Translate the local/spy tags
public abstract class EssentialsChatPlayer extends PlayerListener
{
protected transient IEssentials ess;
@@ -112,34 +112,31 @@ public abstract class EssentialsChatPlayer extends PlayerListener
logger.info(_("localFormat", sender.getName(), event.getMessage()));
final Location loc = sender.getLocation();
final World world = loc.getWorld();
- final int x = loc.getBlockX();
- final int y = loc.getBlockY();
- final int z = loc.getBlockZ();
- for (Player p : server.getOnlinePlayers())
+
+ for (Player onlinePlayer : server.getOnlinePlayers())
{
String type = "[L]";
- final User u = ess.getUser(p);
+ final User user = ess.getUser(onlinePlayer);
//TODO: remove reference to op
- if (u.isIgnoredPlayer(sender.getName()) && !sender.isOp())
+ if (user.isIgnoredPlayer(sender.getName()) && !sender.isOp())
{
continue;
}
- if (!u.equals(sender))
- {
- final Location l = u.getLocation();
- final int dx = x - l.getBlockX();
- final int dy = y - l.getBlockY();
- final int dz = z - l.getBlockZ();
- final long delta = dx * dx + dy * dy + dz * dz;
- if (delta > radius || world != l.getWorld())
+ if (!user.equals(sender))
+ {
+ final Location playerLoc = user.getLocation();
+ if (playerLoc.getWorld() != world) { continue; }
+ final double delta = playerLoc.distanceSquared(loc);
+
+ if (delta > radius)
{
- if (!u.isAuthorized("essentials.chat.spy"))
+ if (user.isAuthorized("essentials.chat.spy"))
{
- continue;
+ type = type.concat("[Spy]");
}
else
{
- type = type.concat("[Spy]");
+ continue;
}
}
}
@@ -147,9 +144,9 @@ public abstract class EssentialsChatPlayer extends PlayerListener
String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage());
for (IEssentialsChatListener listener : listeners.values())
{
- message = listener.modifyMessage(event, p, message);
+ message = listener.modifyMessage(event, onlinePlayer, message);
}
- u.sendMessage(message);
+ user.sendMessage(message);
}
}
}