Search in sources :

Example 1 with PermissionsChangedEvent

use of net.minecraftforge.event.entity.player.PermissionsChangedEvent in project MinecraftForge by MinecraftForge.

the class ForgeEventFactory method onPermissionChanged.

public static boolean onPermissionChanged(GameProfile gameProfile, int newLevel, PlayerList playerList) {
    int oldLevel = playerList.getServer().getProfilePermissions(gameProfile);
    ServerPlayer player = playerList.getPlayer(gameProfile.getId());
    if (newLevel != oldLevel && player != null) {
        return MinecraftForge.EVENT_BUS.post(new PermissionsChangedEvent(player, newLevel, oldLevel));
    }
    return false;
}
Also used : PermissionsChangedEvent(net.minecraftforge.event.entity.player.PermissionsChangedEvent) ServerPlayer(net.minecraft.server.level.ServerPlayer)

Aggregations

ServerPlayer (net.minecraft.server.level.ServerPlayer)1 PermissionsChangedEvent (net.minecraftforge.event.entity.player.PermissionsChangedEvent)1