use of fr.neatmonster.nocheatplus.components.registry.feature.NCPListener 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);
}
};
}
Aggregations