mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-26 10:37:46 +01:00
Add issue #221 - permission check event
This commit is contained in:
parent
120a4dc401
commit
cf4846baa9
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
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.event.ServerConnectEvent;
|
||||||
import net.md_5.bungee.api.scoreboard.Scoreboard;
|
import net.md_5.bungee.api.scoreboard.Scoreboard;
|
||||||
import net.md_5.bungee.netty.HandlerBoss;
|
import net.md_5.bungee.netty.HandlerBoss;
|
||||||
@ -249,7 +250,7 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
@Synchronized("permMutex")
|
@Synchronized("permMutex")
|
||||||
public boolean hasPermission(String permission)
|
public boolean hasPermission(String permission)
|
||||||
{
|
{
|
||||||
return permissions.contains( permission );
|
return bungee.getPluginManager().callEvent( new PermissionCheckEvent( this, permissions.contains( permission ) ) ).hasPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user