Using base instead of our wrapped player for permission check.

This commit is contained in:
snowleo 2011-08-31 12:51:59 +02:00
parent 057c9cb3f5
commit d3dd4980a4
2 changed files with 15 additions and 8 deletions

View File

@ -17,7 +17,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private transient User teleportRequester; private transient User teleportRequester;
private transient boolean teleportRequestHere; private transient boolean teleportRequestHere;
private transient final Teleport teleport; private transient final Teleport teleport;
private transient long lastOnlineActivity ; private transient long lastOnlineActivity;
private transient long lastActivity = System.currentTimeMillis(); private transient long lastActivity = System.currentTimeMillis();
private boolean hidden = false; private boolean hidden = false;
private transient boolean godStateBeforeAfk; private transient boolean godStateBeforeAfk;
@ -50,6 +50,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override @Override
public boolean isAuthorized(final String node) public boolean isAuthorized(final String node)
{ {
if (base instanceof OfflinePlayer)
{
return false;
}
if (isOp()) if (isOp())
{ {
return true; return true;
@ -60,7 +65,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return false; return false;
} }
return ess.getPermissionsHandler().hasPermission(this, node); return ess.getPermissionsHandler().hasPermission(base, node);
} }
public void healCooldown() throws Exception public void healCooldown() throws Exception
@ -264,8 +269,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
if (ess.getSettings().addPrefixSuffix()) if (ess.getSettings().addPrefixSuffix())
{ {
final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName()); final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
final String suffix = ess.getPermissionsHandler().getSuffix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName()); final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
nickname.insert(0, prefix); nickname.insert(0, prefix);
nickname.append(suffix); nickname.append(suffix);
@ -341,11 +346,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public void setAfk(final boolean set) public void setAfk(final boolean set)
{ {
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set); this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers()) { if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers())
{
godStateBeforeAfk = isGodModeEnabled(); godStateBeforeAfk = isGodModeEnabled();
setGodModeEnabled(true); setGodModeEnabled(true);
} }
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers()) { if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers())
{
setGodModeEnabled(godStateBeforeAfk); setGodModeEnabled(godStateBeforeAfk);
} }
super.setAfk(set); super.setAfk(set);
@ -423,7 +430,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis() if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis()
&& !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt")) && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
{ {
final String kickReason = Util.format("autoAfkKickReason", autoafkkick/60.0); final String kickReason = Util.format("autoAfkKickReason", autoafkkick / 60.0);
kickPlayer(kickReason); kickPlayer(kickReason);

View File

@ -44,7 +44,7 @@ public class Permissions2Handler implements IPermissionsHandler
@Override @Override
public boolean hasPermission(final Player base, final String node) public boolean hasPermission(final Player base, final String node)
{ {
return permissionHandler.permission(base, node); return permissionHandler.permission(base.getWorld().getName(), base.getName(), node);
} }
@Override @Override