summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java15
-rw-r--r--Essentials/src/com/earth2me/essentials/Teleport.java173
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandheal.java21
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtphere.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/SignKit.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/SignWarp.java2
-rw-r--r--Essentials/src/items.csv1
-rw-r--r--EssentialsGroupManager/src/Changelog.txt3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java12
-rw-r--r--EssentialsGroupManager/src/users.yml6
11 files changed, 162 insertions, 78 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java
index 8dbd02a38..0077d988c 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java
@@ -7,6 +7,7 @@ import java.util.logging.Logger;
import org.bukkit.Material;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -46,7 +47,7 @@ public class EssentialsEntityListener implements Listener
{
event.setCancelled(true);
}
-
+
if (attacker.isGodModeEnabled() && !attacker.isAuthorized("essentials.god.pvp"))
{
event.setCancelled(true);
@@ -161,4 +162,16 @@ public class EssentialsEntityListener implements Listener
event.setCancelled(true);
}
}
+
+ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
+ public void onPotionSplashEvent(final PotionSplashEvent event)
+ {
+ for (LivingEntity entity : event.getAffectedEntities())
+ {
+ if (entity instanceof Player && ess.getUser(entity).isGodModeEnabled())
+ {
+ event.setIntensity(entity, 0d);
+ }
+ }
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java
index c6106ad24..6a666a199 100644
--- a/Essentials/src/com/earth2me/essentials/Teleport.java
+++ b/Essentials/src/com/earth2me/essentials/Teleport.java
@@ -37,13 +37,14 @@ public class Teleport implements Runnable, ITeleport
{
if (this.name != null)
{
-
+
return ess.getServer().getPlayerExact(name).getLocation();
}
return location;
}
}
private IUser user;
+ private IUser teleportUser;
private int teleTimer = -1;
private long started; // time this task was initiated
private long delay; // how long to delay the teleport
@@ -62,12 +63,18 @@ public class Teleport implements Runnable, ITeleport
private void initTimer(long delay, Target target, Trade chargeFor, TeleportCause cause)
{
+ initTimer(delay, user, target, chargeFor, cause);
+ }
+
+ private void initTimer(long delay, IUser teleportUser, Target target, Trade chargeFor, TeleportCause cause)
+ {
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.health = teleportUser.getHealth();
+ this.initX = Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT);
+ this.initY = Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT);
+ this.initZ = Math.round(teleportUser.getLocation().getZ() * MOVE_CONSTANT);
+ this.teleportUser = teleportUser;
this.teleportTarget = target;
this.chargeFor = chargeFor;
this.cause = cause;
@@ -79,31 +86,38 @@ public class Teleport implements Runnable, ITeleport
if (user == null || !user.isOnline() || user.getLocation() == null)
{
- cancel();
+ cancel(false);
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
- || user.getHealth() < health)
- { // user moved, cancel teleport
- cancel(true);
+ if (teleportUser == null || !teleportUser.isOnline() || teleportUser.getLocation() == null)
+ {
+ cancel(false);
return;
}
- health = user.getHealth(); // in case user healed, then later gets injured
-
+ if (!user.isAuthorized("essentials.teleport.timer.move")
+ && (Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT) != initX
+ || Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT) != initY
+ || Math.round(teleportUser.getLocation().getZ() * MOVE_CONSTANT) != initZ
+ || teleportUser.getHealth() < health))
+ {
+ // user moved, cancel teleport
+ cancel(true);
+ return;
+ }
+ health = teleportUser.getHealth(); // in case user healed, then later gets injured
long now = System.currentTimeMillis();
if (now > started + delay)
{
try
{
cooldown(false);
- user.sendMessage(_("teleportationCommencing"));
+ teleportUser.sendMessage(_("teleportationCommencing"));
try
{
- now(teleportTarget, cause);
+ teleportUser.getTeleport().now(teleportTarget, cause);
+ cancel(false);
if (chargeFor != null)
{
chargeFor.charge(user);
@@ -117,6 +131,10 @@ public class Teleport implements Runnable, ITeleport
catch (Exception ex)
{
user.sendMessage(_("cooldownWithMessage", ex.getMessage()));
+ if (user != teleportUser)
+ {
+ teleportUser.sendMessage(_("cooldownWithMessage", ex.getMessage()));
+ }
}
}
}
@@ -127,22 +145,6 @@ public class Teleport implements Runnable, ITeleport
this.ess = ess;
}
- public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
- {
- final Player player = user.getBase();
- final Location bed = player.getBedSpawnLocation();
- final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, bed == null ? player.getWorld().getSpawnLocation() : bed, bed != null);
- ess.getServer().getPluginManager().callEvent(pre);
- teleport(new Target(pre.getRespawnLocation()), chargeFor, cause);
- }
-
- public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
- {
- Location loc = ess.getWarps().getWarp(warp);
- teleport(new Target(loc), chargeFor, cause);
- user.sendMessage(_("warpingTo", warp));
- }
-
public void cooldown(boolean check) throws Exception
{
final Calendar time = new GregorianCalendar();
@@ -181,6 +183,7 @@ public class Teleport implements Runnable, ITeleport
}
}
+ //If we need to cancel a pending teleport call this method
public void cancel(boolean notifyUser)
{
if (teleTimer == -1)
@@ -193,6 +196,10 @@ public class Teleport implements Runnable, ITeleport
if (notifyUser)
{
user.sendMessage(_("pendingTeleportCancelled"));
+ if (teleportUser != user)
+ {
+ teleportUser.sendMessage(_("pendingTeleportCancelled"));
+ }
}
}
finally
@@ -201,16 +208,40 @@ public class Teleport implements Runnable, ITeleport
}
}
- public void cancel()
+ //The now function is used when you want to skip tp delay when teleporting someone to a location or player.
+ public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
+ {
+ if (cooldown)
+ {
+ cooldown(false);
+ }
+ now(new Target(loc), cause);
+ }
+
+ public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
+ {
+ if (cooldown)
+ {
+ cooldown(false);
+ }
+ now(new Target(entity), cause);
+ }
+
+ private void now(Target target, TeleportCause cause) throws Exception
{
cancel(false);
+ user.setLastLocation();
+ user.getBase().teleport(Util.getSafeDestination(target.getLocation()), cause);
}
+ //The teleport function is used when you want to normally teleport someone to a location or player.
+ //This method is nolonger used internally and will be removed.
+ @Deprecated
public void teleport(Location loc, Trade chargeFor) throws Exception
{
- teleport(new Target(loc), chargeFor, TeleportCause.PLUGIN);
+ teleport(loc, chargeFor, TeleportCause.PLUGIN);
}
-
+
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{
teleport(new Target(loc), chargeFor, cause);
@@ -241,58 +272,82 @@ public class Teleport implements Runnable, ITeleport
return;
}
- cancel();
- Calendar c = new GregorianCalendar();
- c.add(Calendar.SECOND, (int)delay);
- c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
- user.sendMessage(_("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
+ cancel(false);
+ warnUser(user);
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
}
- private void now(Target target, TeleportCause cause) throws Exception
+ //The teleportToMe function is a wrapper used to handle teleporting players to them, like /tphere
+ public void teleportToMe(User otherUser, Trade chargeFor, TeleportCause cause) throws Exception
{
- cancel();
- user.setLastLocation();
- user.getBase().teleport(Util.getSafeDestination(target.getLocation()), cause);
- }
+ Target target = new Target(user);
- public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
- {
- if (cooldown)
+ double delay = ess.getSettings().getTeleportDelay();
+
+ if (chargeFor != null)
+ {
+ chargeFor.isAffordableFor(user);
+ }
+ cooldown(true);
+ if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
{
cooldown(false);
+ otherUser.getTeleport().now(target, cause);
+ if (chargeFor != null)
+ {
+ chargeFor.charge(user);
+ }
+ return;
}
- now(new Target(loc), cause);
+
+ cancel(false);
+ warnUser(otherUser);
+ initTimer((long)(delay * 1000.0), otherUser, target, chargeFor, cause);
+
+ teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
}
- public void now(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
+ private void warnUser(final IUser user)
{
- cooldown(false);
- chargeFor.charge(user);
- now(new Target(loc), cause);
+ Calendar c = new GregorianCalendar();
+ c.add(Calendar.SECOND, (int)delay);
+ c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
+ user.sendMessage(_("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
}
- public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
+ //The respawn function is a wrapper used to handle tp fallback, on /jail and /home
+ public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
{
- if (cooldown)
- {
- cooldown(false);
- }
- now(new Target(entity), cause);
+ final Player player = user.getBase();
+ final Location bed = player.getBedSpawnLocation();
+ final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, bed == null ? player.getWorld().getSpawnLocation() : bed, bed != null);
+ ess.getServer().getPluginManager().callEvent(pre);
+ teleport(new Target(pre.getRespawnLocation()), chargeFor, cause);
+ }
+
+ //The warp function is a wrapper used to teleport a player to a /warp
+ public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
+ {
+ Location loc = ess.getWarps().getWarp(warp);
+ teleport(new Target(loc), chargeFor, cause);
+ user.sendMessage(_("warpingTo", warp));
}
+ //The back function is a wrapper used to teleport a player /back to their previous location.
public void back(Trade chargeFor) throws Exception
{
teleport(new Target(user.getLastLocation()), chargeFor, TeleportCause.COMMAND);
}
+ //This function is used to throw a user back after a jail sentence
public void back() throws Exception
{
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
}
+ //This function handles teleporting to /home
public void home(Location loc, Trade chargeFor) throws Exception
{
teleport(new Target(loc), chargeFor, TeleportCause.COMMAND);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
index 82678c96e..224e782de 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
@@ -6,6 +6,8 @@ import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
public class Commandheal extends EssentialsCommand
@@ -33,9 +35,7 @@ public class Commandheal extends EssentialsCommand
{
user.healCooldown();
}
- user.setHealth(20);
- user.setFoodLevel(20);
- user.sendMessage(_("heal"));
+ healPlayer(user);
}
@Override
@@ -63,10 +63,19 @@ public class Commandheal extends EssentialsCommand
{
continue;
}
- p.setHealth(20);
- p.setFoodLevel(20);
- p.sendMessage(_("heal"));
+ healPlayer(p);
sender.sendMessage(_("healOther", p.getDisplayName()));
}
}
+
+ private void healPlayer(final Player p)
+ {
+ p.setHealth(20);
+ p.setFoodLevel(20);
+ p.sendMessage(_("heal"));
+ for (PotionEffect effect : p.getActivePotionEffects())
+ {
+ p.removePotionEffect(effect.getType());
+ }
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
index 86f88f884..865492921 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
@@ -65,12 +65,13 @@ public class Commandtpaccept extends EssentialsCommand
if (user.isTpRequestHere())
{
- user.getTeleport().teleport(target, charge, TeleportCause.COMMAND);
+ target.getTeleport().teleportToMe(user, charge, TeleportCause.COMMAND);
}
else
{
target.getTeleport().teleport(user, charge, TeleportCause.COMMAND);
}
user.requestTeleport(null, false);
+ throw new NoChargeException();
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
index 641290575..76041ca6c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
@@ -27,7 +27,7 @@ public class Commandtphere extends EssentialsCommand
{
throw new Exception(_("noPerm", "essentials.worlds." + user.getWorld().getName()));
}
- player.getTeleport().teleport(user, new Trade(this.getName(), ess), TeleportCause.COMMAND);
+ user.getTeleport().teleportToMe(player, new Trade(this.getName(), ess), TeleportCause.COMMAND);
user.sendMessage(_("teleporting"));
player.sendMessage(_("teleporting"));
throw new NoChargeException();
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignKit.java b/Essentials/src/com/earth2me/essentials/signs/SignKit.java
index aee1d7dea..1c3528a18 100644
--- a/Essentials/src/com/earth2me/essentials/signs/SignKit.java
+++ b/Essentials/src/com/earth2me/essentials/signs/SignKit.java
@@ -51,7 +51,7 @@ public class SignKit extends EssentialsSign
final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH).trim();
final String group = sign.getLine(2);
if ((!group.isEmpty() && ("§2Everyone".equals(group) || player.inGroup(group)))
- || (group.isEmpty() && (player.isAuthorized("essentials.kit." + kitName))))
+ || (group.isEmpty() && (player.isAuthorized("essentials.kits." + kitName))))
{
final Trade charge = getTrade(sign, 3, ess);
charge.isAffordableFor(player);
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignWarp.java b/Essentials/src/com/earth2me/essentials/signs/SignWarp.java
index 8f470bc6b..eb81ea4e1 100644
--- a/Essentials/src/com/earth2me/essentials/signs/SignWarp.java
+++ b/Essentials/src/com/earth2me/essentials/signs/SignWarp.java
@@ -53,7 +53,7 @@ public class SignWarp extends EssentialsSign
if ((!group.isEmpty()
&& ("§2Everyone".equals(group)
|| player.inGroup(group)))
- || (group.isEmpty() && (!ess.getSettings().getPerWarpPermission() || player.isAuthorized("essentials.warp." + warpName))))
+ || (group.isEmpty() && (!ess.getSettings().getPerWarpPermission() || player.isAuthorized("essentials.warps." + warpName))))
{
final Trade charge = getTrade(sign, 3, ess);
try
diff --git a/Essentials/src/items.csv b/Essentials/src/items.csv
index 0e66d61e2..a3d6ca91b 100644
--- a/Essentials/src/items.csv
+++ b/Essentials/src/items.csv
@@ -1587,6 +1587,7 @@ tdoor,96,0
doort,96,0
trapd,96,0
dtrap,96,0
+monsteregg,97,0
silverfish,97,0
monsteregg,97,0
monstereggsmoothstone,97,0
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index a877078d8..0c9b13a47 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -199,4 +199,5 @@ v 2.0:
- Include the GM version when logging errors.
- Fix Synchronization on adding subgroups (thanks snowleo).
- Remove info node support from GlobalGroups. It should not have them as GlobalGroups are only permission collections.
- - Change order of data in Users.yml to [name, Group, SubGroup, Permissions, Info nodes]. \ No newline at end of file
+ - Change order of data in Users.yml to [name, Group, SubGroup, Permissions, Info nodes].
+ - Add alphabetically sorted user lists. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
index 9790efa2a..a4b346154 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
@@ -15,8 +15,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.anjocaido.groupmanager.GroupManager;
@@ -1018,17 +1020,19 @@ public class WorldDataHolder {
public static void writeUsers(WorldDataHolder ph, File usersFile) {
Map<String, Object> root = new HashMap<String, Object>();
-
- Map<String, Object> usersMap = new HashMap<String, Object>();
+ LinkedHashMap<String, Object> usersMap = new LinkedHashMap<String, Object>();
+
root.put("users", usersMap);
synchronized (ph.getUsers()) {
- for (String userKey : ph.getUsers().keySet()) {
+
+ // A sorted list of users.
+ for (String userKey : new TreeSet<String>(ph.getUsers().keySet())) {
User user = ph.getUsers().get(userKey);
if ((user.getGroup() == null || user.getGroup().equals(ph.getDefaultGroup())) && user.getPermissionList().isEmpty() && user.getVariables().isEmpty() && user.isSubGroupsEmpty()) {
continue;
}
- Map<String, Object> aUserMap = new HashMap<String, Object>();
+ LinkedHashMap<String, Object> aUserMap = new LinkedHashMap<String, Object>();
usersMap.put(user.getName(), aUserMap);
// GROUP NODE
diff --git a/EssentialsGroupManager/src/users.yml b/EssentialsGroupManager/src/users.yml
index 72a7b652f..19496ad84 100644
--- a/EssentialsGroupManager/src/users.yml
+++ b/EssentialsGroupManager/src/users.yml
@@ -1,15 +1,15 @@
# "For a more advanced configuration example utilizing the advanced features of GroupManager, see http://pastebin.com/a8ZA0j5G"
users:
snowleo:
+ group: Builder
subgroups: []
permissions: []
- group: Builder
KHobbits:
+ group: Moderator
subgroups: []
permissions: []
- group: Moderator
ElgarL:
+ group: Moderator
subgroups: []
permissions: []
- group: Moderator