diff --git a/api/src/main/java/net/md_5/bungee/api/event/PermissionCheckEvent.java b/api/src/main/java/net/md_5/bungee/api/event/PermissionCheckEvent.java new file mode 100644 index 000000000..9c3830787 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/event/PermissionCheckEvent.java @@ -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; + } +} diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index dd11d967a..7cbd91bd9 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -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