mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 10:04:51 +02:00
New permission: essentials.fly.safelogin - Players with this command automatically switch to fly mode if they login whilst floating in the air.
c6dd921f0c
This commit is contained in:
@@ -11,6 +11,7 @@ import java.util.regex.Pattern;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -328,6 +329,25 @@ public class EssentialsPlayerListener implements Listener
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
if(Permissions.FLY_SAFELOGIN.isAuthorized(user))
|
||||
{
|
||||
final Location loc = user.getPlayer().getLocation();
|
||||
final World world = loc.getWorld();
|
||||
final int x = loc.getBlockX();
|
||||
int y = loc.getBlockY();
|
||||
final int z = loc.getBlockZ();
|
||||
while(LocationUtil.isBlockUnsafe(world, x, y, z) && y > -1)
|
||||
{
|
||||
y--;
|
||||
}
|
||||
|
||||
if(loc.getBlockY() - y > 1 || y < 0)
|
||||
{
|
||||
user.getPlayer().setAllowFlight(true);
|
||||
user.getPlayer().setFlying(true);
|
||||
user.sendMessage(_("flyMode", _("enabled"), user.getPlayer().getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -592,7 +612,7 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH)
|
||||
{
|
||||
final IUser user = userMap.getUser((Player)event.getWhoClicked());
|
||||
final IUser user = userMap.getUser((Player) event.getWhoClicked());
|
||||
if (user.isRecipeSee())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
@@ -39,6 +39,7 @@ public enum Permissions implements IPermission
|
||||
FEED_OTHERS,
|
||||
FLY_EXEMPT,
|
||||
FLY_OTHERS,
|
||||
FLY_SAFELOGIN,
|
||||
GAMEMODE_EXEMPT,
|
||||
GAMEMODE_OTHERS,
|
||||
GEOIP_HIDE(PermissionDefault.FALSE),
|
||||
|
Reference in New Issue
Block a user