use of com.loohp.interactivechat.utils.PlayerUtils.ColorSettings in project InteractiveChat by LOOHP.
the class ClientSettingPacket method clientSettingsListener.
public static void clientSettingsListener() {
Bukkit.getPluginManager().registerEvents(new ClientSettingPacket(), InteractiveChat.plugin);
InteractiveChat.protocolManager.addPacketListener(new PacketAdapter(PacketAdapter.params().plugin(InteractiveChat.plugin).listenerPriority(ListenerPriority.MONITOR).types(PacketType.Play.Client.SETTINGS)) {
@Override
public void onPacketSending(PacketEvent event) {
// do nothing
}
@Override
public void onPacketReceiving(PacketEvent event) {
if (!event.getPacketType().equals(PacketType.Play.Client.SETTINGS)) {
return;
}
PacketContainer packet = event.getPacket();
Player player = event.getPlayer();
boolean colorSettings = packet.getBooleans().read(0);
ColorSettings originalColorSettings = getSettings(player);
if ((originalColorSettings.equals(ColorSettings.WAITING) || originalColorSettings.equals(ColorSettings.ON)) && !colorSettings) {
Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> player.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', ConfigManager.getConfig().getString("Messages.ColorsDisabled"))), 5);
}
if (originalColorSettings.equals(ColorSettings.OFF) && colorSettings) {
Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> player.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', ConfigManager.getConfig().getString("Messages.ColorsReEnabled"))), 5);
}
colorSettingsMap.put(player, colorSettings);
}
});
}
Aggregations