Add issue #221 - permission check event

This commit is contained in:
md_5 2013-03-24 16:29:45 +11:00
parent 120a4dc401
commit cf4846baa9
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,36 @@
package net.md_5.bungee.api.event;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Event;
/**
* Called when the permission of a CommandSender is checked.
*/
@Data
@AllArgsConstructor
@ToString(callSuper = false)
@EqualsAndHashCode(callSuper = false)
public class PermissionCheckEvent extends Event
{
/**
* The command sender being checked for a permission.
*/
private final CommandSender sender;
/**
* The outcome of this permission check.
*/
@Getter(AccessLevel.NONE)
private boolean hasPermission;
public boolean hasPermission()
{
return hasPermission;
}
}

View File

@ -23,6 +23,7 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PermissionCheckEvent;
import net.md_5.bungee.api.event.ServerConnectEvent;
import net.md_5.bungee.api.scoreboard.Scoreboard;
import net.md_5.bungee.netty.HandlerBoss;
@ -249,7 +250,7 @@ public final class UserConnection implements ProxiedPlayer
@Synchronized("permMutex")
public boolean hasPermission(String permission)
{
return permissions.contains( permission );
return bungee.getPluginManager().callEvent( new PermissionCheckEvent( this, permissions.contains( permission ) ) ).hasPermission();
}
@Override