mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-26 11:07:55 +01:00
New permission: essentials.sleepingignored
This commit is contained in:
parent
cecb9867d9
commit
ae7275c7ad
@ -268,6 +268,9 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
|
|
||||||
user.setDisplayName(user.getNick());
|
user.setDisplayName(user.getNick());
|
||||||
user.setAfk(false);
|
user.setAfk(false);
|
||||||
|
if (user.isAuthorized("essentials.sleepingignored")) {
|
||||||
|
user.setSleepingIgnored(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||||
{
|
{
|
||||||
|
@ -19,44 +19,44 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
private boolean teleportRequestHere;
|
private boolean teleportRequestHere;
|
||||||
private final Teleport teleport;
|
private final Teleport teleport;
|
||||||
private long lastActivity;
|
private long lastActivity;
|
||||||
|
|
||||||
User(Player base, IEssentials ess)
|
User(Player base, IEssentials ess)
|
||||||
{
|
{
|
||||||
super(base, ess);
|
super(base, ess);
|
||||||
teleport = new Teleport(this, ess);
|
teleport = new Teleport(this, ess);
|
||||||
}
|
}
|
||||||
|
|
||||||
User update(Player base)
|
User update(Player base)
|
||||||
{
|
{
|
||||||
setBase(base);
|
setBase(base);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(IEssentialsCommand cmd)
|
public boolean isAuthorized(IEssentialsCommand cmd)
|
||||||
{
|
{
|
||||||
return isAuthorized(cmd, "essentials.");
|
return isAuthorized(cmd, "essentials.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
|
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
|
||||||
{
|
{
|
||||||
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(String node)
|
public boolean isAuthorized(String node)
|
||||||
{
|
{
|
||||||
if (isOp())
|
if (isOp())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isJailed())
|
if (isJailed())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ess.getPermissionsHandler().hasPermission(this, node);
|
return ess.getPermissionsHandler().hasPermission(this, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void healCooldown() throws Exception
|
public void healCooldown() throws Exception
|
||||||
{
|
{
|
||||||
Calendar now = new GregorianCalendar();
|
Calendar now = new GregorianCalendar();
|
||||||
@ -74,7 +74,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
}
|
}
|
||||||
setLastHealTimestamp(now.getTimeInMillis());
|
setLastHealTimestamp(now.getTimeInMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void giveMoney(double value)
|
public void giveMoney(double value)
|
||||||
{
|
{
|
||||||
giveMoney(value, null);
|
giveMoney(value, null);
|
||||||
@ -93,7 +93,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value), this.getDisplayName())));
|
initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value), this.getDisplayName())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void payUser(User reciever, double value) throws Exception
|
public void payUser(User reciever, double value) throws Exception
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -112,11 +112,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value), getDisplayName()));
|
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value), getDisplayName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void takeMoney(double value)
|
public void takeMoney(double value)
|
||||||
{
|
{
|
||||||
takeMoney(value, null);
|
takeMoney(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void takeMoney(double value, CommandSender initiator)
|
public void takeMoney(double value, CommandSender initiator)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
@ -130,43 +131,43 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value), this.getDisplayName())));
|
initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value), this.getDisplayName())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canAfford(double cost)
|
public boolean canAfford(double cost)
|
||||||
{
|
{
|
||||||
double mon = getMoney();
|
double mon = getMoney();
|
||||||
return mon >= cost || isAuthorized("essentials.eco.loan");
|
return mon >= cost || isAuthorized("essentials.eco.loan");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
this.base = new OfflinePlayer(getName());
|
this.base = new OfflinePlayer(getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getJustPortaled()
|
public boolean getJustPortaled()
|
||||||
{
|
{
|
||||||
return justPortaled;
|
return justPortaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJustPortaled(boolean value)
|
public void setJustPortaled(boolean value)
|
||||||
{
|
{
|
||||||
justPortaled = value;
|
justPortaled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReplyTo(CommandSender user)
|
public void setReplyTo(CommandSender user)
|
||||||
{
|
{
|
||||||
replyTo = user;
|
replyTo = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandSender getReplyTo()
|
public CommandSender getReplyTo()
|
||||||
{
|
{
|
||||||
return replyTo;
|
return replyTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(User t)
|
public int compareTo(User t)
|
||||||
{
|
{
|
||||||
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
|
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o)
|
public boolean equals(Object o)
|
||||||
{
|
{
|
||||||
@ -175,51 +176,51 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
|
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return ChatColor.stripColor(this.getDisplayName()).hashCode();
|
return ChatColor.stripColor(this.getDisplayName()).hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean canSpawnItem(int itemId)
|
public Boolean canSpawnItem(int itemId)
|
||||||
{
|
{
|
||||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHome()
|
public void setHome()
|
||||||
{
|
{
|
||||||
setHome(getLocation(), true);
|
setHome(getLocation(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHome(boolean defaultHome)
|
public void setHome(boolean defaultHome)
|
||||||
{
|
{
|
||||||
setHome(getLocation(), defaultHome);
|
setHome(getLocation(), defaultHome);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastLocation()
|
public void setLastLocation()
|
||||||
{
|
{
|
||||||
setLastLocation(getLocation());
|
setLastLocation(getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestTeleport(User player, boolean here)
|
public void requestTeleport(User player, boolean here)
|
||||||
{
|
{
|
||||||
teleportRequester = player;
|
teleportRequester = player;
|
||||||
teleportRequestHere = here;
|
teleportRequestHere = here;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getTeleportRequest()
|
public User getTeleportRequest()
|
||||||
{
|
{
|
||||||
return teleportRequester;
|
return teleportRequester;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTeleportRequestHere()
|
public boolean isTeleportRequestHere()
|
||||||
{
|
{
|
||||||
return teleportRequestHere;
|
return teleportRequestHere;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNick()
|
public String getNick()
|
||||||
{
|
{
|
||||||
String nickname = getNickname();
|
String nickname = getNickname();
|
||||||
@ -243,22 +244,22 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
}
|
}
|
||||||
return nickname;
|
return nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Teleport getTeleport()
|
public Teleport getTeleport()
|
||||||
{
|
{
|
||||||
return teleport;
|
return teleport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLastActivity()
|
public long getLastActivity()
|
||||||
{
|
{
|
||||||
return lastActivity;
|
return lastActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastActivity(long timestamp)
|
public void setLastActivity(long timestamp)
|
||||||
{
|
{
|
||||||
lastActivity = timestamp;
|
lastActivity = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMoney()
|
public double getMoney()
|
||||||
{
|
{
|
||||||
@ -280,7 +281,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
}
|
}
|
||||||
return super.getMoney();
|
return super.getMoney();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMoney(double value)
|
public void setMoney(double value)
|
||||||
{
|
{
|
||||||
@ -302,19 +303,19 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
}
|
}
|
||||||
super.setMoney(value);
|
super.setMoney(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAfk(boolean set)
|
public void setAfk(boolean set)
|
||||||
{
|
{
|
||||||
this.setSleepingIgnored(set);
|
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||||
super.setAfk(set);
|
super.setAfk(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean toggleAfk()
|
public boolean toggleAfk()
|
||||||
{
|
{
|
||||||
boolean now = super.toggleAfk();
|
boolean now = super.toggleAfk();
|
||||||
this.setSleepingIgnored(now);
|
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user