Add IRCMessageEvent

Minor bug fix in mcmmo hook.
This commit is contained in:
cnaude 2015-12-05 10:58:16 -07:00
parent 07361bc6e8
commit b27ecc59db
4 changed files with 81 additions and 4 deletions

View File

@ -27,7 +27,7 @@ import org.bukkit.event.HandlerList;
*/
public class IRCCommandEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private static final HandlerList HANDLERS = new HandlerList();
private final IRCCommand ircCommand;
/**
@ -52,7 +52,7 @@ public class IRCCommandEvent extends Event {
*/
@Override
public HandlerList getHandlers() {
return handlers;
return HANDLERS;
}
/**
@ -60,6 +60,6 @@ public class IRCCommandEvent extends Event {
* @return
*/
public static HandlerList getHandlerList() {
return handlers;
return HANDLERS;
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.Events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
*
* @author Chris Naude Event listener for plugins that want to catch irc message events
* from PurpleIRC
*/
public class IRCMessageEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
private final String message;
private final String permission;
/**
*
* @param message
* @param permission
*/
public IRCMessageEvent(String message, String permission) {
this.message = message;
this.permission = permission;
}
/**
*
* @return
*/
public String getMessage() {
return this.message;
}
/**
*
* @return
*/
public String getPermission() {
return this.permission;
}
/**
*
* @return
*/
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
/**
*
* @return
*/
public static HandlerList getHandlerList() {
return HANDLERS;
}
}

View File

@ -48,7 +48,7 @@ public class McMMOChatHook {
plugin.logDebug("[mcMMOChatHook:sendAdminMessage]: " + message);
String chatPrefix = Config.getInstance().getAdminChatPrefix();
message = LocaleLoader.formatString(chatPrefix, sender) + " " + message;
plugin.getServer().broadcast(message, "mcmmo.chat.adminchat");
plugin.broadcastToGame(message, "mcmmo.chat.adminchat");
}
}

View File

@ -16,6 +16,7 @@
*/
package com.cnaude.purpleirc;
import com.cnaude.purpleirc.Events.IRCMessageEvent;
import com.cnaude.purpleirc.GameListeners.AdminChatListener;
import com.cnaude.purpleirc.GameListeners.CleverNotchListener;
import com.cnaude.purpleirc.GameListeners.DeathMessagesListener;
@ -1659,6 +1660,7 @@ public class PurpleIRC extends JavaPlugin {
}
public void broadcastToGame(final String message, final String permission) {
getServer().getPluginManager().callEvent(new IRCMessageEvent(message, permission));
if (broadcastChatToConsole) {
logDebug("Broadcast All [" + permission + "]: " + message);
getServer().broadcast(message, permission);