@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerQuit(final PlayerQuitEvent e) { Player player = e.getPlayer(); SCPlayer scPlayer = getSCPlayer(player.getUniqueId()); e.setQuitMessage(null); if (scPlayer.isCombatTagged()) { player.setHealth(0); scPlayer.removeCombatTag(); broadcast( new FancyMessage(scPlayer.getTag()) .tooltip(scPlayer.getHoverText()) .then(" §5has logged off while in combat!")); } if (rankManager.getRank(player.getUniqueId()).getId() >= Rank.MOD.getId()) staff( new FancyMessage("§9[STAFF] ") .then(scPlayer.getTag()) .tooltip(scPlayer.getHoverText()) .then(" §edisconnected.")); removeSCPlayer(player.getUniqueId()); }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJoin(final PlayerJoinEvent e) { Player player = e.getPlayer(); addSCPlayer(player.getUniqueId()); SCPlayer scPlayer = getSCPlayer(player.getUniqueId()); if (rankManager.getRank(player.getUniqueId()).getId() >= Rank.MOD.getId()) staff( new FancyMessage("§9[STAFF] ") .then(scPlayer.getTag()) .tooltip(scPlayer.getHoverText()) .then(" §econnected.")); e.setJoinMessage(null); }
@EventHandler(priority = EventPriority.LOW) public void onPlayerChat(final AsyncPlayerChatEvent e) { List<Punishment> punishments = punishmentManager.getPunishments(e.getPlayer().getUniqueId()); for (Punishment punishment : punishments) { if (punishment.getType().equals(PunishmentType.MUTE)) { if (!punishment.hasExpired()) { e.getPlayer().sendMessage("§cYou are permanently muted."); e.setCancelled(true); return; } } if (punishment.getType().equals(PunishmentType.TEMPMUTE)) { if (!punishment.hasExpired()) { e.getPlayer() .sendMessage( "§cYou are temporarily muted until §3" + punishment.getEndTimestamp() + " §c."); e.setCancelled(true); return; } } } e.setCancelled(true); Player player = e.getPlayer(); SCPlayer scPlayer = getSCPlayer(player.getUniqueId()); if (player.isOp()) e.setMessage(e.getMessage().replace('&', ChatColor.COLOR_CHAR)); FancyMessage message = new FancyMessage(" §7- ") .then(scPlayer.getTag()) .tooltip(scPlayer.getHoverText()) .then("§8: §7" + e.getMessage()); for (final Player other : e.getRecipients()) { if (other.getWorld() != player.getWorld()) continue; if (other.getLocation().distanceSquared(player.getLocation()) <= 900) message.send(other); } }