Add NTheEndAgain hooks.

This commit is contained in:
cnaude 2015-11-26 14:50:02 -07:00
parent f78a833bff
commit ecd89e7e25
6 changed files with 97 additions and 3 deletions

View File

@ -119,6 +119,14 @@
<version>18.0</version>
</dependency>
<!-- NTheEndAgain -->
<dependency>
<groupId>com.cnaude.nplugins</groupId>
<artifactId>ntheendagain</artifactId>
<version>0.6.10-SNAPSHOT</version>
<type>jar</type>
</dependency>
<!-- Essentials -->
<dependency>
<groupId>com.cnaude.essentials</groupId>

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 fr.ribesg.bukkit.ntheendagain.event.RegenEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
*
* @author Chris Naude
*/
public class NTheEndAgainListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin the PurpleIRC plugin
*/
public NTheEndAgainListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler
public void onRegenEvent(RegenEvent event) {
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.nTheEndNotify(event.getMessages(), ircBot.botNick, "ntheendagain-" + event.getType());
}
}
}

View File

@ -1437,6 +1437,23 @@ public final class PurpleBot {
}
}
public void nTheEndNotify(String messages[], String botNick, String messageType) {
if (!this.isConnected()) {
return;
}
for (String message : messages) {
for (String channelName : botChannels) {
if (isMessageEnabled(channelName, messageType)) {
asyncIRCMessage(
channelName,
plugin.tokenizer.gameChatToIRCTokenizer(
plugin.getMsgTemplate(botNick, channelName, messageType),
message));
}
}
}
}
/**
*
* @param channelName

View File

@ -32,6 +32,7 @@ import com.cnaude.purpleirc.GameListeners.GamePlayerQuitListener;
import com.cnaude.purpleirc.GameListeners.GameServerCommandListener;
import com.cnaude.purpleirc.GameListeners.HeroChatListener;
import com.cnaude.purpleirc.GameListeners.McMMOChatListener;
import com.cnaude.purpleirc.GameListeners.NTheEndAgainListener;
import com.cnaude.purpleirc.GameListeners.OreBroadcastListener;
import com.cnaude.purpleirc.GameListeners.PrismListener;
import com.cnaude.purpleirc.GameListeners.RedditStreamListener;
@ -202,6 +203,7 @@ public class PurpleIRC extends JavaPlugin {
final String PL_ESSENTIALS = "Essentials";
final String PL_REPORTRTS = "ReportRTS";
final String PL_NTHE_END_AGAIN = "NTheEndAgain";
final String PL_SUPERVANISH = "SuperVanish";
final String PL_VANISHNOPACKET = "VanishNoPacket";
final String PL_OREBROADCAST = "OreBroadcast";
@ -1614,6 +1616,12 @@ public class PurpleIRC extends JavaPlugin {
} else {
hookList.add(hookFormat(PL_REPORTRTS, false));
}
if (isPluginEnabled(PL_NTHE_END_AGAIN)) {
hookList.add(hookFormat(PL_NTHE_END_AGAIN, true));
getServer().getPluginManager().registerEvents(new NTheEndAgainListener(this), this);
} else {
hookList.add(hookFormat(PL_NTHE_END_AGAIN, false));
}
if (isPluginEnabled(PL_ESSENTIALS)) {
hookList.add(hookFormat(PL_ESSENTIALS, true));
getServer().getPluginManager().registerEvents(new EssentialsListener(this), this);

View File

@ -143,4 +143,8 @@ public class TemplateName {
public final static String CROSS_CHAT = "cross-chat";
public final static String NTHE_END_AGAIN_HARD = "ntheendagain-hard";
public final static String NTHE_END_AGAIN_SOFT = "ntheendagain-soft";
public final static String NTHE_END_AGAIN_CRYSTAL = "ntheendagain-crystal";
}

View File

@ -219,6 +219,10 @@ message-format:
prism-custom: '[PrismCustom] [Player: %NAME%] [Action: %ACTION%] [Message: %MESSAGE%] [Plugin: %PLUGIN%]'
# RedditStream
reddit-messages: '[R] %MESSAGE%'
# NTheEndAgain
ntheendagain-hard: '[NTheEndAgain] %MESSAGE%'
ntheendagain-soft: '[NTheEndAgain] %MESSAGE%'
ntheendagain-crystal: '[NTheEndAgain] %MESSAGE%'
# Defaults below take effect when user joins IRC and matching player is offline
default-player-suffix: ''
default-player-prefix: ''