From bdca07f1cfd951b51116855cc1135466daf1e583 Mon Sep 17 00:00:00 2001 From: cnaude Date: Thu, 12 Jan 2017 18:25:46 -0700 Subject: [PATCH] Reduce kick event spamming. --- pom.xml | 7 +++ .../DeathMessagesPrimeListener.java | 53 +++++++++++++++++++ .../java/com/cnaude/purpleirc/PurpleIRC.java | 8 +++ 3 files changed, 68 insertions(+) create mode 100644 src/main/java/com/cnaude/purpleirc/GameListeners/DeathMessagesPrimeListener.java diff --git a/pom.xml b/pom.xml index 6a7bb8e..fa47508 100644 --- a/pom.xml +++ b/pom.xml @@ -344,6 +344,13 @@ DeathMessages 2.9.1-SNAPSHOT + + + + com.cnaude.deathmessagesprime + DeathMessagesPrime + 1.11.11 + diff --git a/src/main/java/com/cnaude/purpleirc/GameListeners/DeathMessagesPrimeListener.java b/src/main/java/com/cnaude/purpleirc/GameListeners/DeathMessagesPrimeListener.java new file mode 100644 index 0000000..bfc4acf --- /dev/null +++ b/src/main/java/com/cnaude/purpleirc/GameListeners/DeathMessagesPrimeListener.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2014 cnaude + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.cnaude.purpleirc.GameListeners; + +import com.cnaude.purpleirc.PurpleBot; +import com.cnaude.purpleirc.PurpleIRC; +import com.cnaude.purpleirc.TemplateName; +import net.memmove.bukkit.deathmsg.DeathMessageBroadcastEvent; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +/** + * + * @author Chris Naude + */ +public class DeathMessagesPrimeListener implements Listener { + + private final PurpleIRC plugin; + + /** + * + * @param plugin the PurpleIRC plugin + */ + public DeathMessagesPrimeListener(PurpleIRC plugin) { + this.plugin = plugin; + } + + /** + * + * @param event + */ + @EventHandler + public void onDeathMessageEvent(DeathMessageBroadcastEvent event) { + plugin.logDebug("onDeathMessageBroadcastEvent caught"); + for (PurpleBot ircBot : plugin.ircBots.values()) { + ircBot.gameDeath(event.getPlayer(), event.getMessage().getText(), TemplateName.DEATH_MESSAGES); + } + } +} diff --git a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java index 95815cb..e84ab65 100644 --- a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java +++ b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java @@ -20,6 +20,7 @@ import com.cnaude.purpleirc.Events.IRCMessageEvent; import com.cnaude.purpleirc.GameListeners.AdminChatListener; import com.cnaude.purpleirc.GameListeners.CleverNotchListener; import com.cnaude.purpleirc.GameListeners.DeathMessagesListener; +import com.cnaude.purpleirc.GameListeners.DeathMessagesPrimeListener; import com.cnaude.purpleirc.GameListeners.DynmapListener; import com.cnaude.purpleirc.GameListeners.EssentialsListener; import com.cnaude.purpleirc.GameListeners.GamePlayerChatListener; @@ -235,6 +236,7 @@ public class PurpleIRC extends JavaPlugin { final String PL_DYNMAP = "dynmap"; final String PL_SHORTIFY = "Shortify"; final String PL_DEATHMESSAGES = "DeathMessages"; + final String PL_DEATHMESSAGESPRIME = "DeathMessagesPrime"; final String PL_JOBS = "Jobs"; final String PL_COMMANDBOOK = "CommandBook"; final String PL_ADMINPRIVATECHAT = "AdminPrivateChat"; @@ -1681,6 +1683,12 @@ public class PurpleIRC extends JavaPlugin { } else { hookList.add(hookFormat(PL_DEATHMESSAGES, false)); } + if (isPluginEnabled(PL_DEATHMESSAGESPRIME)) { + hookList.add(hookFormat(PL_DEATHMESSAGESPRIME, true)); + getServer().getPluginManager().registerEvents(new DeathMessagesPrimeListener(this), this); + } else { + hookList.add(hookFormat(PL_DEATHMESSAGESPRIME, false)); + } if (isPluginEnabled(PL_SHORTIFY)) { String shortifyVersion = getServer().getPluginManager().getPlugin(PL_SHORTIFY).getDescription().getVersion(); if (shortifyVersion.startsWith("1.8")) {