mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2025-01-22 15:31:25 +01:00
Major refactoring of Herochat code.
This commit is contained in:
parent
7794d2898d
commit
91920953c6
6
pom.xml
6
pom.xml
@ -223,6 +223,12 @@
|
||||
<artifactId>Herochat</artifactId>
|
||||
<version>5.6.5</version>
|
||||
</dependency>
|
||||
<!-- Herochat Premium
|
||||
<dependency>
|
||||
<groupId>com.cnaude.herochat</groupId>
|
||||
<artifactId>HerochatPremium</artifactId>
|
||||
<version>6.0.0</version>
|
||||
</dependency> -->
|
||||
|
||||
<!-- VentureChat -->
|
||||
<dependency>
|
||||
|
@ -18,6 +18,7 @@ package com.cnaude.purpleirc.GameListeners;
|
||||
|
||||
import com.cnaude.purpleirc.PurpleBot;
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import com.cnaude.purpleirc.TemplateName;
|
||||
import com.dthielke.herochat.Channel;
|
||||
import com.dthielke.herochat.ChannelChatEvent;
|
||||
import com.dthielke.herochat.Chatter;
|
||||
@ -73,13 +74,85 @@ public class HeroChatListener implements Listener {
|
||||
for (PurpleBot ircBot : plugin.ircBots.values()) {
|
||||
if (plugin.heroChatEmoteFormat.equals(event.getFormat())) {
|
||||
plugin.logDebug("HC Emote: TRUE");
|
||||
ircBot.heroAction(chatter, chatColor, event.getMessage());
|
||||
heroAction(ircBot, chatter, chatColor, event.getMessage());
|
||||
} else {
|
||||
plugin.logDebug("HC Emote: FALSE");
|
||||
ircBot.heroChat(chatter, chatColor, event.getMessage());
|
||||
heroChat(ircBot, chatter, chatColor, event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from HeroChat listener
|
||||
*
|
||||
* @param ircBot
|
||||
* @param chatter
|
||||
* @param chatColor
|
||||
* @param message
|
||||
*/
|
||||
public void heroChat(PurpleBot ircBot, Chatter chatter, ChatColor chatColor, String message) {
|
||||
if (!ircBot.isConnected()) {
|
||||
return;
|
||||
}
|
||||
Player player = chatter.getPlayer();
|
||||
if (ircBot.floodChecker.isSpam(player)) {
|
||||
ircBot.sendFloodWarning(player);
|
||||
return;
|
||||
}
|
||||
for (String channelName : ircBot.botChannels) {
|
||||
if (ircBot.isPlayerInValidWorld(player, channelName)) {
|
||||
String hChannel = chatter.getActiveChannel().getName();
|
||||
String hNick = chatter.getActiveChannel().getNick();
|
||||
String hColor = chatColor.toString();
|
||||
plugin.logDebug("HC Channel: " + hChannel);
|
||||
if (ircBot.isMessageEnabled(channelName, "hero-" + hChannel + "-chat")
|
||||
|| ircBot.isMessageEnabled(channelName, TemplateName.HERO_CHAT)) {
|
||||
ircBot.asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.chatHeroTokenizer(player, message, hColor, hChannel,
|
||||
hNick, plugin.getHeroChatTemplate(ircBot.botNick, hChannel)));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is in \""
|
||||
+ hChannel + "\" but hero-" + hChannel + "-chat is disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ircBot
|
||||
* @param chatter
|
||||
* @param chatColor
|
||||
* @param message
|
||||
*/
|
||||
public void heroAction(PurpleBot ircBot, Chatter chatter, ChatColor chatColor, String message) {
|
||||
if (!ircBot.isConnected()) {
|
||||
return;
|
||||
}
|
||||
Player player = chatter.getPlayer();
|
||||
if (ircBot.floodChecker.isSpam(player)) {
|
||||
ircBot.sendFloodWarning(player);
|
||||
return;
|
||||
}
|
||||
for (String channelName : ircBot.botChannels) {
|
||||
if (!ircBot.isPlayerInValidWorld(player, channelName)) {
|
||||
continue;
|
||||
}
|
||||
String hChannel = chatter.getActiveChannel().getName();
|
||||
String hNick = chatter.getActiveChannel().getNick();
|
||||
String hColor = chatColor.toString();
|
||||
plugin.logDebug("HC Channel: " + hChannel);
|
||||
if (ircBot.isMessageEnabled(channelName, "hero-" + hChannel + "-action")
|
||||
|| ircBot.isMessageEnabled(channelName, "hero-action")) {
|
||||
ircBot.asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.chatHeroTokenizer(player, message, hColor, hChannel,
|
||||
hNick, plugin.getHeroActionTemplate(ircBot.botNick, hChannel)));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is in \""
|
||||
+ hChannel + "\" but hero-" + hChannel + "-action is disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
63
src/main/java/com/cnaude/purpleirc/Hooks/HerochatHook.java
Normal file
63
src/main/java/com/cnaude/purpleirc/Hooks/HerochatHook.java
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.Hooks;
|
||||
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import com.dthielke.herochat.ChannelManager;
|
||||
import com.dthielke.herochat.Herochat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cnaude
|
||||
*/
|
||||
public class HerochatHook {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin the PurpleIRC plugin
|
||||
*/
|
||||
public HerochatHook(PurpleIRC plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void sendHeroMessage(String heroChannel, String message) {
|
||||
getChannelManager().getChannel(heroChannel).sendRawMessage(message);
|
||||
}
|
||||
|
||||
public String getHeroNick(String channel) {
|
||||
return getChannelManager().getChannel(channel).getNick();
|
||||
}
|
||||
|
||||
public String getHeroColor(String channel) {
|
||||
return getChannelManager().getChannel(channel).getColor().toString();
|
||||
}
|
||||
|
||||
public boolean isValidChannel(String channel) {
|
||||
return getChannelManager().hasChannel(channel);
|
||||
}
|
||||
|
||||
public String getChannelName(String channel) {
|
||||
return getChannelManager().getChannel(channel).getName();
|
||||
}
|
||||
|
||||
private ChannelManager getChannelManager() {
|
||||
return Herochat.getChannelManager();
|
||||
}
|
||||
|
||||
}
|
@ -39,8 +39,6 @@ import static com.cnaude.purpleirc.IRCMessage.Type.CTCP;
|
||||
import static com.cnaude.purpleirc.IRCMessage.Type.MESSAGE;
|
||||
import static com.cnaude.purpleirc.IRCMessage.Type.NOTICE;
|
||||
import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap;
|
||||
import com.dthielke.herochat.Herochat;
|
||||
import com.dthielke.herochat.Chatter;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
@ -164,7 +162,7 @@ public final class PurpleBot {
|
||||
public CaseInsensitiveMap<Boolean> enableMessageFiltering;
|
||||
public CaseInsensitiveMap<String> channelPrefix;
|
||||
private final CaseInsensitiveMap<Boolean> shortify;
|
||||
public CaseInsensitiveMap<String> heroChannel;
|
||||
public CaseInsensitiveMap<String> heroChannelMap;
|
||||
public CaseInsensitiveMap<String> ventureChatChannel;
|
||||
public CaseInsensitiveMap<String> townyChannel;
|
||||
public CaseInsensitiveMap<String> discordChannel;
|
||||
@ -253,7 +251,7 @@ public final class PurpleBot {
|
||||
this.opsList = new CaseInsensitiveMap<>();
|
||||
this.banList = new CaseInsensitiveMap<>();
|
||||
this.voicesList = new CaseInsensitiveMap<>();
|
||||
this.heroChannel = new CaseInsensitiveMap<>();
|
||||
this.heroChannelMap = new CaseInsensitiveMap<>();
|
||||
this.ventureChatChannel = new CaseInsensitiveMap<>();
|
||||
this.townyChannel = new CaseInsensitiveMap<>();
|
||||
this.discordChannel = new CaseInsensitiveMap<>();
|
||||
@ -975,8 +973,8 @@ public final class PurpleBot {
|
||||
channelTopicChanserv.put(channelName, config.getBoolean("channels." + enChannelName + ".topic-chanserv", false));
|
||||
plugin.logDebug(" Topic Chanserv Mode => " + channelTopicChanserv.get(channelName).toString());
|
||||
|
||||
heroChannel.put(channelName, config.getString("channels." + enChannelName + ".hero-channel", "admin"));
|
||||
plugin.logDebug(" HeroChannel => " + heroChannel.get(channelName));
|
||||
heroChannelMap.put(channelName, config.getString("channels." + enChannelName + ".hero-channel", "admin"));
|
||||
plugin.logDebug(" HeroChannel => " + heroChannelMap.get(channelName));
|
||||
|
||||
ventureChatChannel.put(channelName, config.getString("channels." + enChannelName + ".venture-channel", "global"));
|
||||
plugin.logDebug(" VentureChatChannel => " + ventureChatChannel.get(channelName));
|
||||
@ -1373,70 +1371,6 @@ public final class PurpleBot {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from HeroChat listener
|
||||
*
|
||||
* @param chatter
|
||||
* @param chatColor
|
||||
* @param message
|
||||
*/
|
||||
public void heroChat(Chatter chatter, ChatColor chatColor, String message) {
|
||||
if (!this.isConnected()) {
|
||||
return;
|
||||
}
|
||||
Player player = chatter.getPlayer();
|
||||
if (floodChecker.isSpam(player)) {
|
||||
sendFloodWarning(player);
|
||||
return;
|
||||
}
|
||||
for (String channelName : botChannels) {
|
||||
if (isPlayerInValidWorld(player, channelName)) {
|
||||
String hChannel = chatter.getActiveChannel().getName();
|
||||
String hNick = chatter.getActiveChannel().getNick();
|
||||
String hColor = chatColor.toString();
|
||||
plugin.logDebug("HC Channel: " + hChannel);
|
||||
if (isMessageEnabled(channelName, "hero-" + hChannel + "-chat")
|
||||
|| isMessageEnabled(channelName, TemplateName.HERO_CHAT)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.chatHeroTokenizer(player, message, hColor, hChannel,
|
||||
hNick, plugin.getHeroChatTemplate(botNick, hChannel)));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is in \""
|
||||
+ hChannel + "\" but hero-" + hChannel + "-chat is disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void heroAction(Chatter chatter, ChatColor chatColor, String message) {
|
||||
if (!this.isConnected()) {
|
||||
return;
|
||||
}
|
||||
Player player = chatter.getPlayer();
|
||||
if (floodChecker.isSpam(player)) {
|
||||
sendFloodWarning(player);
|
||||
return;
|
||||
}
|
||||
for (String channelName : botChannels) {
|
||||
if (!isPlayerInValidWorld(player, channelName)) {
|
||||
continue;
|
||||
}
|
||||
String hChannel = chatter.getActiveChannel().getName();
|
||||
String hNick = chatter.getActiveChannel().getNick();
|
||||
String hColor = chatColor.toString();
|
||||
plugin.logDebug("HC Channel: " + hChannel);
|
||||
if (isMessageEnabled(channelName, "hero-" + hChannel + "-action")
|
||||
|| isMessageEnabled(channelName, "hero-action")) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.chatHeroTokenizer(player, message, hColor, hChannel,
|
||||
hNick, plugin.getHeroActionTemplate(botNick, hChannel)));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is in \""
|
||||
+ hChannel + "\" but hero-" + hChannel + "-action is disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from TitanChat listener
|
||||
*
|
||||
@ -2941,16 +2875,16 @@ public final class PurpleBot {
|
||||
Send messages to Herochat if enabled
|
||||
*/
|
||||
if (isMessageEnabled(channelName, TemplateName.IRC_HERO_CHAT)) {
|
||||
String hChannel = heroChannel.get(channelName);
|
||||
String hChannel = heroChannelMap.get(channelName);
|
||||
String tmpl = plugin.getIrcHeroChatTemplate(botNick, hChannel);
|
||||
plugin.logDebug("broadcastChat [HC]: " + hChannel + ": " + tmpl);
|
||||
String rawHCMessage = filterMessage(
|
||||
plugin.tokenizer.ircChatToHeroChatTokenizer(this, user, channel, tmpl, message, Herochat.getChannelManager(), hChannel), channelName);
|
||||
plugin.tokenizer.ircChatToHeroChatTokenizer(this, user, channel, tmpl, message, hChannel), channelName);
|
||||
if (!rawHCMessage.isEmpty()) {
|
||||
if (Herochat.getChannelManager().getChannel(hChannel) == null) {
|
||||
if (!plugin.herochatHook.isValidChannel(hChannel)) {
|
||||
plugin.logError("Herochat channel is invalid: " + hChannel);
|
||||
} else {
|
||||
Herochat.getChannelManager().getChannel(hChannel).sendRawMessage(rawHCMessage);
|
||||
plugin.herochatHook.sendHeroMessage(hChannel, rawHCMessage);
|
||||
messageSent = true;
|
||||
if (logIrcToHeroChat.containsKey(channelName)) {
|
||||
if (logIrcToHeroChat.get(channelName)) {
|
||||
@ -3070,17 +3004,14 @@ public final class PurpleBot {
|
||||
msg = message.split(" ", 2)[1];
|
||||
if (enabledMessages.get(channelName).contains(TemplateName.IRC_HERO_CHAT)) {
|
||||
plugin.logDebug("Checking if " + hChannel + " is a valid hero channel...");
|
||||
if (Herochat.getChannelManager().hasChannel(hChannel)) {
|
||||
hChannel = Herochat.getChannelManager().getChannel(hChannel).getName();
|
||||
if (plugin.herochatHook.isValidChannel(hChannel)) {
|
||||
hChannel = plugin.herochatHook.getChannelName(hChannel);
|
||||
String template = plugin.getIrcHeroChatTemplate(botNick, hChannel);
|
||||
plugin.logDebug("T: " + template);
|
||||
String t = plugin.tokenizer.ircChatToHeroChatTokenizer(this, user,
|
||||
channel, template, msg,
|
||||
Herochat.getChannelManager(), hChannel);
|
||||
String t = plugin.tokenizer.ircChatToHeroChatTokenizer(this, user, channel, template, msg, hChannel);
|
||||
plugin.logDebug("Sending message to" + hChannel + ":" + t);
|
||||
Herochat.getChannelManager().getChannel(hChannel)
|
||||
.sendRawMessage(t);
|
||||
plugin.logDebug("Channel format: " + Herochat.getChannelManager().getChannel(hChannel).getFormat());
|
||||
plugin.herochatHook.sendHeroMessage(hChannel, t);
|
||||
//plugin.logDebug("Channel format: " + Herochat.getChannelManager().getChannel(hChannel).getFormat());
|
||||
// Let the sender know the message was sent
|
||||
String responseTemplate = plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_HCHAT_RESPONSE);
|
||||
if (!responseTemplate.isEmpty()) {
|
||||
@ -3223,13 +3154,13 @@ public final class PurpleBot {
|
||||
Send IRC action messages to HeroChat if enabled
|
||||
*/
|
||||
if (isMessageEnabled(channelName, TemplateName.IRC_HERO_ACTION)) {
|
||||
String hChannel = heroChannel.get(channelName);
|
||||
String hChannel = heroChannelMap.get(channelName);
|
||||
String tmpl = plugin.getIrcHeroActionTemplate(botNick, hChannel);
|
||||
plugin.logDebug("broadcastChat [HA]: " + hChannel + ": " + tmpl);
|
||||
String rawHCMessage = filterMessage(
|
||||
plugin.tokenizer.ircChatToHeroChatTokenizer(this, user, channel, tmpl, message, Herochat.getChannelManager(), hChannel), channelName);
|
||||
plugin.tokenizer.ircChatToHeroChatTokenizer(this, user, channel, tmpl, message, hChannel), channelName);
|
||||
if (!rawHCMessage.isEmpty()) {
|
||||
Herochat.getChannelManager().getChannel(hChannel).sendRawMessage(rawHCMessage);
|
||||
plugin.herochatHook.sendHeroMessage(hChannel, rawHCMessage);
|
||||
if (logIrcToHeroChat.containsKey(channelName)) {
|
||||
if (logIrcToHeroChat.get(channelName)) {
|
||||
plugin.getServer().getConsoleSender().sendMessage(rawHCMessage);
|
||||
@ -3303,16 +3234,10 @@ public final class PurpleBot {
|
||||
}
|
||||
|
||||
if (isMessageEnabled(channelName, TemplateName.IRC_HERO_KICK)) {
|
||||
Herochat.getChannelManager().getChannel(heroChannel.get(channelName))
|
||||
.sendRawMessage(plugin.tokenizer
|
||||
.ircKickToHeroChatTokenizer(this,
|
||||
recipient, kicker,
|
||||
reason, channel,
|
||||
plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_HERO_KICK),
|
||||
Herochat.getChannelManager(),
|
||||
heroChannel.get(channelName)
|
||||
)
|
||||
);
|
||||
String hChannel = heroChannelMap.get(channelName);
|
||||
String template = plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_HERO_KICK);
|
||||
String message = plugin.tokenizer.ircKickToHeroChatTokenizer(this, recipient, kicker, reason, channel, template, hChannel);
|
||||
plugin.herochatHook.sendHeroMessage(hChannel, message);
|
||||
}
|
||||
|
||||
// Broadcast kick message to VentureChat
|
||||
@ -3391,13 +3316,11 @@ public final class PurpleBot {
|
||||
}
|
||||
|
||||
// Broadcast join message to HeroChat
|
||||
if (isMessageEnabled(channel, TemplateName.IRC_HERO_JOIN)) {
|
||||
Herochat.getChannelManager().getChannel(heroChannel.get(channel.getName()))
|
||||
.sendRawMessage(plugin.tokenizer.ircChatToHeroChatTokenizer(
|
||||
this, user, channel, plugin.getMessageTemplate(
|
||||
botNick, channelName, TemplateName.IRC_HERO_JOIN),
|
||||
Herochat.getChannelManager(),
|
||||
heroChannel.get(channel.getName())));
|
||||
if (isMessageEnabled(channel, TemplateName.IRC_HERO_JOIN) && plugin.herochatHook != null) {
|
||||
String hChannel = heroChannelMap.get(channelName);
|
||||
String template = plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_HERO_JOIN);
|
||||
String message = plugin.tokenizer.ircChatToHeroChatTokenizer(this, user, channel, template, hChannel);
|
||||
plugin.herochatHook.sendHeroMessage(heroChannelMap.get(channelName), message);
|
||||
}
|
||||
|
||||
// Broadcast join message to VentureChat
|
||||
@ -3432,12 +3355,10 @@ public final class PurpleBot {
|
||||
}
|
||||
|
||||
if (isMessageEnabled(channel, TemplateName.IRC_HERO_PART)) {
|
||||
Herochat.getChannelManager().getChannel(heroChannel.get(channel.getName()))
|
||||
.sendRawMessage(plugin.tokenizer.ircChatToHeroChatTokenizer(
|
||||
this, user, channel, plugin.getMessageTemplate(
|
||||
botNick, channelName, TemplateName.IRC_HERO_PART),
|
||||
Herochat.getChannelManager(),
|
||||
heroChannel.get(channel.getName())));
|
||||
String hChannel = heroChannelMap.get(channel.getName());
|
||||
String template = plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_HERO_PART);
|
||||
String message = plugin.tokenizer.ircChatToHeroChatTokenizer(this, user, channel, template,hChannel);
|
||||
plugin.herochatHook.sendHeroMessage(hChannel, message);
|
||||
}
|
||||
|
||||
// Broadcast part message to VentureChat
|
||||
@ -3471,12 +3392,9 @@ public final class PurpleBot {
|
||||
}
|
||||
|
||||
if (isMessageEnabled(channel, TemplateName.IRC_HERO_QUIT)) {
|
||||
Herochat.getChannelManager().getChannel(heroChannel.get(channel.getName()))
|
||||
.sendRawMessage(plugin.tokenizer.ircChatToHeroChatTokenizer(
|
||||
this, user, channel, plugin.getMessageTemplate(
|
||||
botNick, channelName, TemplateName.IRC_HERO_QUIT),
|
||||
Herochat.getChannelManager(),
|
||||
heroChannel.get(channel.getName())));
|
||||
String template = plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_HERO_QUIT);
|
||||
String message = plugin.tokenizer.ircChatToHeroChatTokenizer(this, user, channel, template, heroChannelMap.get(channel.getName()));
|
||||
plugin.herochatHook.sendHeroMessage(heroChannelMap.get(channel.getName()), message);
|
||||
}
|
||||
|
||||
// Broadcast part message to VentureChat
|
||||
@ -3515,11 +3433,10 @@ public final class PurpleBot {
|
||||
}
|
||||
|
||||
if (isMessageEnabled(channel, TemplateName.IRC_HERO_TOPIC)) {
|
||||
Herochat.getChannelManager().getChannel(heroChannel.get(channel.getName()))
|
||||
.sendRawMessage(plugin.tokenizer.ircChatToHeroChatTokenizer(
|
||||
this, user, channel, plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_HERO_TOPIC), topic,
|
||||
Herochat.getChannelManager(),
|
||||
heroChannel.get(channel.getName())));
|
||||
String hChannel = heroChannelMap.get(channel.getName());
|
||||
String template = plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_HERO_TOPIC);
|
||||
String message = plugin.tokenizer.ircChatToHeroChatTokenizer(this, user, channel, template, topic,hChannel);
|
||||
plugin.herochatHook.sendHeroMessage(hChannel, message);
|
||||
}
|
||||
|
||||
// Broadcast topic message to VentureChat
|
||||
|
@ -54,6 +54,7 @@ import com.cnaude.purpleirc.Hooks.DynmapHook;
|
||||
import com.cnaude.purpleirc.Hooks.EssentialsHook;
|
||||
import com.cnaude.purpleirc.Hooks.FactionChatHook;
|
||||
import com.cnaude.purpleirc.Hooks.GriefPreventionHook;
|
||||
import com.cnaude.purpleirc.Hooks.HerochatHook;
|
||||
import com.cnaude.purpleirc.Hooks.JobsHook;
|
||||
import com.cnaude.purpleirc.Hooks.McMMOChatHook;
|
||||
import com.cnaude.purpleirc.Hooks.PlaceholderApiHook;
|
||||
@ -224,6 +225,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
public VaultHook vaultHelpers;
|
||||
public VanishHook vanishHook;
|
||||
public SuperVanishHook superVanishHook;
|
||||
public HerochatHook herochatHook;
|
||||
private YamlConfiguration heroConfig;
|
||||
private final File cacheFile;
|
||||
private final File uuidCacheFile;
|
||||
@ -1560,6 +1562,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
if (isPluginEnabled(PL_HEROCHAT)) {
|
||||
hookList.add(hookFormat(PL_HEROCHAT, true));
|
||||
getServer().getPluginManager().registerEvents(new HeroChatListener(this), this);
|
||||
herochatHook = new HerochatHook(this);
|
||||
heroConfig = new YamlConfiguration();
|
||||
heroConfigFile = new File(getServer().getPluginManager()
|
||||
.getPlugin(PL_HEROCHAT).getDataFolder(), "config.yml");
|
||||
|
@ -20,7 +20,6 @@ import com.cnaude.purpleirc.PlayerList;
|
||||
import com.cnaude.purpleirc.PurpleBot;
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import com.cnaude.purpleirc.TemplateName;
|
||||
import com.dthielke.herochat.ChannelManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.nyancraft.reportrts.data.Ticket;
|
||||
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
||||
@ -166,11 +165,10 @@ public class ChatTokenizer {
|
||||
* @param user
|
||||
* @param channel
|
||||
* @param template
|
||||
* @param channelManager
|
||||
* @param hChannel
|
||||
* @param heroChannel
|
||||
* @return
|
||||
*/
|
||||
public String ircChatToHeroChatTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template, ChannelManager channelManager, String hChannel) {
|
||||
public String ircChatToHeroChatTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template, String heroChannel) {
|
||||
String ircNick = user.getNick();
|
||||
String tmpl;
|
||||
Player player = this.getPlayer(ircNick);
|
||||
@ -181,9 +179,9 @@ public class ChatTokenizer {
|
||||
tmpl = playerTokenizer(ircNick, template);
|
||||
}
|
||||
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(tmpl, user, ircBot)
|
||||
.replace("%HEROCHANNEL%", hChannel)
|
||||
.replace("%HERONICK%", channelManager.getChannel(hChannel).getNick())
|
||||
.replace("%HEROCOLOR%", channelManager.getChannel(hChannel).getColor().toString())
|
||||
.replace("%HEROCHANNEL%", heroChannel)
|
||||
.replace("%HERONICK%", plugin.herochatHook.getHeroNick(heroChannel))
|
||||
.replace("%HEROCOLOR%", plugin.herochatHook.getHeroColor(heroChannel))
|
||||
.replace("%NICKPREFIX%", ircBot.getNickPrefix(user, channel))
|
||||
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
||||
.replace("%CHANNEL%", channel.getName()));
|
||||
@ -274,16 +272,16 @@ public class ChatTokenizer {
|
||||
* @param hChannel
|
||||
* @return
|
||||
*/
|
||||
public String ircChatToHeroChatTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template, String message, ChannelManager channelManager, String hChannel) {
|
||||
public String ircChatToHeroChatTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template, String message, String hChannel) {
|
||||
String ircNick = user.getNick();
|
||||
String heroNick = "";
|
||||
String heroColor = "";
|
||||
String tmpl;
|
||||
if (channelManager.getChannel(hChannel) == null) {
|
||||
if (!plugin.herochatHook.isValidChannel(hChannel)) {
|
||||
plugin.logError("Herochat channel is invalid: " + hChannel);
|
||||
} else {
|
||||
heroNick = channelManager.getChannel(hChannel).getNick();
|
||||
heroColor = channelManager.getChannel(hChannel).getColor().toString();
|
||||
heroNick = plugin.herochatHook.getHeroNick(hChannel);
|
||||
heroColor = plugin.herochatHook.getHeroColor(hChannel);
|
||||
}
|
||||
Player player = this.getPlayer(ircNick);
|
||||
if (player != null) {
|
||||
@ -414,15 +412,14 @@ public class ChatTokenizer {
|
||||
* @param reason
|
||||
* @param channel
|
||||
* @param template
|
||||
* @param channelManager
|
||||
* @param hChannel
|
||||
* @return
|
||||
*/
|
||||
public String ircKickToHeroChatTokenizer(PurpleBot ircBot, User recipient, User kicker, String reason, org.pircbotx.Channel channel, String template, ChannelManager channelManager, String hChannel) {
|
||||
public String ircKickToHeroChatTokenizer(PurpleBot ircBot, User recipient, User kicker, String reason, org.pircbotx.Channel channel, String template, String hChannel) {
|
||||
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(template, recipient, kicker, ircBot)
|
||||
.replace("%HEROCHANNEL%", hChannel)
|
||||
.replace("%HERONICK%", channelManager.getChannel(hChannel).getNick())
|
||||
.replace("%HEROCOLOR%", channelManager.getChannel(hChannel).getColor().toString())
|
||||
.replace("%HERONICK%", plugin.herochatHook.getHeroNick(hChannel))
|
||||
.replace("%HEROCOLOR%", plugin.herochatHook.getHeroColor(hChannel))
|
||||
.replace("%NICKPREFIX%", ircBot.getNickPrefix(kicker, channel))
|
||||
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
||||
.replace("%REASON%", reason)
|
||||
|
Loading…
Reference in New Issue
Block a user