New permission: essentials.sleepingignored

This commit is contained in:
snowleo 2011-07-15 20:13:52 +02:00
parent cecb9867d9
commit ae7275c7ad
2 changed files with 42 additions and 38 deletions

View File

@ -268,6 +268,9 @@ public class EssentialsPlayerListener extends PlayerListener
user.setDisplayName(user.getNick());
user.setAfk(false);
if (user.isAuthorized("essentials.sleepingignored")) {
user.setSleepingIgnored(true);
}
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
{

View File

@ -19,44 +19,44 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private boolean teleportRequestHere;
private final Teleport teleport;
private long lastActivity;
User(Player base, IEssentials ess)
{
super(base, ess);
teleport = new Teleport(this, ess);
}
User update(Player base)
{
setBase(base);
return this;
}
public boolean isAuthorized(IEssentialsCommand cmd)
{
return isAuthorized(cmd, "essentials.");
}
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
{
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
}
public boolean isAuthorized(String node)
{
if (isOp())
{
return true;
}
if (isJailed())
{
return false;
}
return ess.getPermissionsHandler().hasPermission(this, node);
}
public void healCooldown() throws Exception
{
Calendar now = new GregorianCalendar();
@ -74,7 +74,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
setLastHealTimestamp(now.getTimeInMillis());
}
public void giveMoney(double value)
{
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())));
}
}
public void payUser(User reciever, double value) throws Exception
{
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()));
}
}
public void takeMoney(double value)
{
takeMoney(value, null);
}
public void takeMoney(double value, CommandSender initiator)
{
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())));
}
}
public boolean canAfford(double cost)
{
double mon = getMoney();
return mon >= cost || isAuthorized("essentials.eco.loan");
}
public void dispose()
{
this.base = new OfflinePlayer(getName());
}
public boolean getJustPortaled()
{
return justPortaled;
}
public void setJustPortaled(boolean value)
{
justPortaled = value;
}
public void setReplyTo(CommandSender user)
{
replyTo = user;
}
public CommandSender getReplyTo()
{
return replyTo;
}
public int compareTo(User t)
{
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
}
@Override
public boolean equals(Object o)
{
@ -175,51 +176,51 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return false;
}
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
}
@Override
public int hashCode()
{
return ChatColor.stripColor(this.getDisplayName()).hashCode();
}
public Boolean canSpawnItem(int itemId)
{
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
}
public void setHome()
{
setHome(getLocation(), true);
}
public void setHome(boolean defaultHome)
{
setHome(getLocation(), defaultHome);
}
public void setLastLocation()
{
setLastLocation(getLocation());
}
public void requestTeleport(User player, boolean here)
{
teleportRequester = player;
teleportRequestHere = here;
}
public User getTeleportRequest()
{
return teleportRequester;
}
public boolean isTeleportRequestHere()
{
return teleportRequestHere;
}
public String getNick()
{
String nickname = getNickname();
@ -243,22 +244,22 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
return nickname;
}
public Teleport getTeleport()
{
return teleport;
}
public long getLastActivity()
{
return lastActivity;
}
public void setLastActivity(long timestamp)
{
lastActivity = timestamp;
}
@Override
public double getMoney()
{
@ -280,7 +281,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
return super.getMoney();
}
@Override
public void setMoney(double value)
{
@ -302,19 +303,19 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
super.setMoney(value);
}
@Override
public void setAfk(boolean set)
{
this.setSleepingIgnored(set);
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
super.setAfk(set);
}
@Override
public boolean toggleAfk()
{
boolean now = super.toggleAfk();
this.setSleepingIgnored(now);
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
return now;
}
}