summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-07-15 20:13:52 +0200
committersnowleo <schneeleo@gmail.com>2011-07-15 20:13:52 +0200
commitae7275c7ad4de45c2cf2b0903f1a27724d0f2c25 (patch)
tree8d55a0f62ffe84f7304b12384d89a12299064cd3
parentcecb9867d949dcfe208b58bdff0123581b13f137 (diff)
downloadEssentials-ae7275c7ad4de45c2cf2b0903f1a27724d0f2c25.tar
Essentials-ae7275c7ad4de45c2cf2b0903f1a27724d0f2c25.tar.gz
Essentials-ae7275c7ad4de45c2cf2b0903f1a27724d0f2c25.tar.lz
Essentials-ae7275c7ad4de45c2cf2b0903f1a27724d0f2c25.tar.xz
Essentials-ae7275c7ad4de45c2cf2b0903f1a27724d0f2c25.zip
New permission: essentials.sleepingignored
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java77
2 files changed, 42 insertions, 38 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index 022b9f031..64ff9ae7b 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -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"))
{
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
index 2c6e998b3..4de4d2f7f 100644
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ b/Essentials/src/com/earth2me/essentials/User.java
@@ -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;
}
}