Reduce kick event spamming.

This commit is contained in:
cnaude 2017-01-12 18:25:46 -07:00
parent 19f72d8927
commit bdca07f1cf
3 changed files with 68 additions and 0 deletions

View File

@ -344,6 +344,13 @@
<artifactId>DeathMessages</artifactId>
<version>2.9.1-SNAPSHOT</version>
</dependency>
<!-- DeathMessages -->
<dependency>
<groupId>com.cnaude.deathmessagesprime</groupId>
<artifactId>DeathMessagesPrime</artifactId>
<version>1.11.11</version>
</dependency>
<!-- Shortify -->
<dependency>

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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);
}
}
}

View File

@ -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")) {