cn.nukkit.event.player.PlayerKickEvent Java Examples
The following examples show how to use
cn.nukkit.event.player.PlayerKickEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerOnlineListener.java From Plan with GNU Lesser General Public License v3.0 | 6 votes |
/** * PlayerKickEvent Listener. * <p> * Adds processing information to the ProcessingQueue. * After KickEvent, the QuitEvent is automatically called. * * @param event Fired event */ @EventHandler(priority = EventPriority.MONITOR) public void onPlayerKick(PlayerKickEvent event) { try { if (!status.areKicksCounted() || event.isCancelled()) { return; } UUID uuid = event.getPlayer().getUniqueId(); if (NukkitAFKListener.AFK_TRACKER.isAfk(uuid)) { return; } dbSystem.getDatabase().executeTransaction(new KickStoreTransaction(uuid)); } catch (Exception e) { errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build()); } }
Example #2
Source File: BanCommand.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length == 0) { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } String name = args[0]; String reason = ""; for (int i = 1; i < args.length; i++) { reason += args[i] + " "; } if (reason.length() > 0) { reason = reason.substring(0, reason.length() - 1); } sender.getServer().getNameBans().addBan(name, reason, null, sender.getName()); Player player = sender.getServer().getPlayerExact(name); if (player != null) { player.kick(PlayerKickEvent.Reason.NAME_BANNED, !reason.isEmpty() ? "Banned by admin. Reason: " + reason : "Banned by admin"); } Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.ban.success", player != null ? player.getName() : name)); return true; }
Example #3
Source File: BanIpCommand.java From Jupiter with GNU General Public License v3.0 | 5 votes |
private void processIPBan(String ip, CommandSender sender, String reason) { sender.getServer().getIPBans().addBan(ip, reason, null, sender.getName()); for (Player player : new ArrayList<>(sender.getServer().getOnlinePlayers().values())) { if (player.getAddress().equals(ip)) { player.kick(PlayerKickEvent.Reason.IP_BANNED, !reason.isEmpty() ? reason : "IP banned"); } } sender.getServer().getNetwork().blockAddress(ip, -1); }
Example #4
Source File: KickCommand.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length == 0) { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } String name = args[0]; String reason = ""; for (int i = 1; i < args.length; i++) { reason += args[i] + " "; } if (reason.length() > 0) { reason = reason.substring(0, reason.length() - 1); } Player player = sender.getServer().getPlayer(name); if (player != null) { player.kick(PlayerKickEvent.Reason.KICKED_BY_ADMIN, reason); if (reason.length() >= 1) { Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success.reason", new String[]{player.getName(), reason}) ); } else { Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success", player.getName())); } } else { sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound")); } return true; }
Example #5
Source File: BanCommand.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length == 0) { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } String name = args[0]; String reason = ""; for (int i = 1; i < args.length; i++) { reason += args[i] + " "; } if (reason.length() > 0) { reason = reason.substring(0, reason.length() - 1); } sender.getServer().getNameBans().addBan(name, reason, null, sender.getName()); Player player = sender.getServer().getPlayerExact(name); if (player != null) { player.kick(PlayerKickEvent.Reason.NAME_BANNED, !reason.isEmpty() ? "Banned by admin. Reason: " + reason : "Banned by admin"); } Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.ban.success", player != null ? player.getName() : name)); return true; }
Example #6
Source File: BanIpCommand.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void processIPBan(String ip, CommandSender sender, String reason) { sender.getServer().getIPBans().addBan(ip, reason, null, sender.getName()); for (Player player : new ArrayList<>(sender.getServer().getOnlinePlayers().values())) { if (player.getAddress().equals(ip)) { player.kick(PlayerKickEvent.Reason.IP_BANNED, !reason.isEmpty() ? reason : "IP banned"); } } sender.getServer().getNetwork().blockAddress(ip, -1); }
Example #7
Source File: KickCommand.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length == 0) { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } String name = args[0]; String reason = ""; for (int i = 1; i < args.length; i++) { reason += args[i] + " "; } if (reason.length() > 0) { reason = reason.substring(0, reason.length() - 1); } Player player = sender.getServer().getPlayer(name); if (player != null) { player.kick(PlayerKickEvent.Reason.KICKED_BY_ADMIN, reason); if (reason.length() >= 1) { Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success.reason", player.getName(), reason) ); } else { Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success", player.getName())); } } else { sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound")); } return true; }
Example #8
Source File: BanCommand.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length == 0) { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } String name = args[0]; String reason = ""; for (int i = 1; i < args.length; i++) { reason += args[i] + " "; } if (reason.length() > 0) { reason = reason.substring(0, reason.length() - 1); } sender.getServer().getNameBans().addBan(name, reason, null, sender.getName()); Player player = sender.getServer().getPlayerExact(name); if (player != null) { player.kick(PlayerKickEvent.Reason.NAME_BANNED, !reason.isEmpty() ? "Banned by admin. Reason: " + reason : "Banned by admin"); } Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.ban.success", player != null ? player.getName() : name)); return true; }
Example #9
Source File: BanIpCommand.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void processIPBan(String ip, CommandSender sender, String reason) { sender.getServer().getIPBans().addBan(ip, reason, null, sender.getName()); for (Player player : new ArrayList<>(sender.getServer().getOnlinePlayers().values())) { if (player.getAddress().equals(ip)) { player.kick(PlayerKickEvent.Reason.IP_BANNED, !reason.isEmpty() ? reason : "IP banned"); } } sender.getServer().getNetwork().blockAddress(ip, -1); }
Example #10
Source File: KickCommand.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (args.length == 0) { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } String name = args[0]; String reason = ""; for (int i = 1; i < args.length; i++) { reason += args[i] + " "; } if (reason.length() > 0) { reason = reason.substring(0, reason.length() - 1); } Player player = sender.getServer().getPlayer(name); if (player != null) { player.kick(PlayerKickEvent.Reason.KICKED_BY_ADMIN, reason); if (reason.length() >= 1) { Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success.reason", new String[]{player.getName(), reason}) ); } else { Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success", player.getName())); } } else { sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound")); } return true; }