Search in sources :

Example 1 with WorldLoadEvent

use of org.bukkit.event.world.WorldLoadEvent in project NoCheatPlus by NoCheatPlus.

the class NoCheatPlus method getCoreListener.

/**
 * Quick solution to hide the listener methods, expect refactoring.
 * @return
 */
private Listener getCoreListener() {
    return new NCPListener() {

        @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerLogin(final PlayerLoginEvent event) {
            // (NORMAL to have chat checks come after this.)
            if (event.getResult() != Result.ALLOWED) {
                return;
            }
            final Player player = event.getPlayer();
            // TODO: Store by id + HashMapLOW.
            if (checkDenyLoginsNames(player.getName())) {
                if (DataManager.getPlayerData(player).hasPermission(Permissions.BYPASS_DENY_LOGIN, player)) {
                    return;
                }
                // TODO: Consider using the vanilla temporary ban feature instead (for an alternative?).
                // TODO: Display time for which the player is banned.
                event.setResult(Result.KICK_OTHER);
                // TODO: Some basic/language configuration object, possibly independent of checks.
                event.setKickMessage(ColorUtil.replaceColors(ConfigManager.getConfigFile(player.getWorld().getName()).getString(ConfPaths.STRINGS + ".msgtempdenylogin")));
            }
        }

        // Do update comment in NoCheatPlusAPI with changing.
        @EventHandler(priority = EventPriority.LOWEST)
        public void onPlayerJoinLowest(final PlayerJoinEvent event) {
            if (clearExemptionsOnJoin) {
                final Player player = event.getPlayer();
                NCPExemptionManager.unexempt(player);
            }
        }

        @EventHandler(priority = EventPriority.LOW)
        public void onPlayerJoinLow(final PlayerJoinEvent event) {
            // LOWEST is for DataMan and CombinedListener.
            onJoinLow(event.getPlayer());
        }

        @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
        public void onPlayerKick(final PlayerKickEvent event) {
            onLeave(event.getPlayer());
        }

        @EventHandler(priority = EventPriority.MONITOR)
        public void onPlayerQuit(final PlayerQuitEvent event) {
            onLeave(event.getPlayer());
        }

        @EventHandler(priority = EventPriority.MONITOR)
        public void onWorldLoad(final WorldLoadEvent event) {
            NoCheatPlus.this.onWorldLoad(event);
        }
    };
}
Also used : PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent) Player(org.bukkit.entity.Player) PlayerLoginEvent(org.bukkit.event.player.PlayerLoginEvent) PlayerQuitEvent(org.bukkit.event.player.PlayerQuitEvent) PlayerKickEvent(org.bukkit.event.player.PlayerKickEvent) WorldLoadEvent(org.bukkit.event.world.WorldLoadEvent) NCPListener(fr.neatmonster.nocheatplus.components.registry.feature.NCPListener)

Aggregations

NCPListener (fr.neatmonster.nocheatplus.components.registry.feature.NCPListener)1 Player (org.bukkit.entity.Player)1 PlayerJoinEvent (org.bukkit.event.player.PlayerJoinEvent)1 PlayerKickEvent (org.bukkit.event.player.PlayerKickEvent)1 PlayerLoginEvent (org.bukkit.event.player.PlayerLoginEvent)1 PlayerQuitEvent (org.bukkit.event.player.PlayerQuitEvent)1 WorldLoadEvent (org.bukkit.event.world.WorldLoadEvent)1