summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-01-01 22:00:53 +0000
committerKHobbits <rob@khobbits.co.uk>2013-01-01 22:00:53 +0000
commitc6dd921f0c91006e360067abf6fe349da031eca4 (patch)
tree3b280fa09cc00a5156f757039b540a1e008fdfec
parent63e622374d778a8f14e8b73fa3b38a53aea1eb55 (diff)
downloadEssentials-c6dd921f0c91006e360067abf6fe349da031eca4.tar
Essentials-c6dd921f0c91006e360067abf6fe349da031eca4.tar.gz
Essentials-c6dd921f0c91006e360067abf6fe349da031eca4.tar.lz
Essentials-c6dd921f0c91006e360067abf6fe349da031eca4.tar.xz
Essentials-c6dd921f0c91006e360067abf6fe349da031eca4.zip
New permission: essentials.fly.safelogin - Players with this command will automatically switch to fly mode if they login whilst floating in the air.
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index 6946bf4ae..9b4585112 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -15,6 +15,7 @@ import java.util.logging.Logger;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
+import org.bukkit.World;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -238,6 +239,24 @@ public class EssentialsPlayerListener implements Listener
user.sendMessage(_("youHaveNewMail", mail.size()));
}
}
+ if (user.isAuthorized("essentials.fly.safelogin"))
+ {
+ final World world = user.getLocation().getWorld();
+ final int x = user.getLocation().getBlockX();
+ int y = user.getLocation().getBlockY();
+ final int z = user.getLocation().getBlockZ();
+ while (Util.isBlockUnsafe(world, x, y, z) && y > -1)
+ {
+ y--;
+ }
+
+ if (user.getLocation().getBlockY() - y > 1 || y < 0)
+ {
+ user.setAllowFlight(true);
+ user.setFlying(true);
+ user.sendMessage(_("flyMode", _("enabled"), user.getDisplayName()));
+ }
+ }
}
// Makes the compass item ingame always point to the first essentials home. #EasterEgg