Update OreBroadcast hook for v1.3.

This commit is contained in:
cnaude 2016-12-16 14:53:10 -07:00
parent 08a802a348
commit 15177269dc
5 changed files with 37 additions and 11 deletions

View File

@ -258,7 +258,7 @@
<dependency>
<groupId>com.cnaude.orebroadcast</groupId>
<artifactId>OreBroadcast</artifactId>
<version>1.2.3</version>
<version>1.3</version>
</dependency>
<!-- RedditStream -->

View File

@ -16,7 +16,7 @@
*/
package com.cnaude.purpleirc.GameListeners;
import be.bendem.orebroadcast.OreBroadcastEvent;
import be.bendem.bukkit.orebroadcast.OreBroadcastEvent;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
@ -46,7 +46,7 @@ public class OreBroadcastListener implements Listener {
public void onOreBroadcastEvent(OreBroadcastEvent event) {
plugin.logDebug("onOreBroadcastEvent caught");
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameOreBroadcast(event.getPlayer(), event.getMessage());
ircBot.gameOreBroadcast(event.getSource(), event.getBlockMined(), event.getVein());
}
}
}

View File

@ -17,7 +17,6 @@
package com.cnaude.purpleirc;
import com.cnaude.purpleirc.Events.VentureChatEvent;
import com.cnaude.purpleirc.GameListeners.UltimateChatListener;
import com.cnaude.purpleirc.IRCListeners.ActionListener;
import com.cnaude.purpleirc.IRCListeners.AwayListener;
import com.cnaude.purpleirc.IRCListeners.ConnectListener;
@ -59,6 +58,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
@ -69,6 +69,7 @@ import me.botsko.prism.events.BlockStateChange;
import org.bukkit.Achievement;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
@ -1721,18 +1722,16 @@ public final class PurpleBot {
/**
*
* @param player
* @param message
* @param block
* @param vein
*/
public void gameOreBroadcast(Player player, String message) {
public void gameOreBroadcast(Player player, Block block, Set<Block> vein) {
if (!this.isConnected()) {
return;
}
for (String channelName : botChannels) {
if (isMessageEnabled(channelName, TemplateName.ORE_BROADCAST)) {
asyncIRCMessage(channelName, plugin.tokenizer
.gameChatToIRCTokenizer(player, plugin
.getMessageTemplate(botNick, channelName, TemplateName.ORE_BROADCAST),
ChatColor.translateAlternateColorCodes('&', message)));
asyncIRCMessage(channelName, plugin.tokenizer.oreBroadcastTokenizer(player, botNick, block, vein));
}
}
}

View File

@ -24,9 +24,11 @@ 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;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.pircbotx.User;
@ -1168,4 +1170,29 @@ public class ChatTokenizer {
}
return s;
}
/**
* OreBroadcast to IRC
*
* @param player
* @param botNick
* @param block
* @param vein
* @return
*/
public String oreBroadcastTokenizer(Player player, String botNick, Block block, Set<Block> vein) {
String template = plugin.getMessageTemplate(botNick, "", TemplateName.ORE_BROADCAST);
String blockName = block.getType().name();
String veinSize = String.valueOf(vein.size());
String plural = "";
if (vein.isEmpty() || vein.size() > 1) {
plural = "s";
}
return plugin.colorConverter.gameColorsToIrc(
playerTokenizer(player, template)
.replace("%ORE%", blockName)
.replace("%PLURAL%", plural)
.replace("%COUNT%", veinSize)
);
}
}

View File

@ -223,7 +223,7 @@ message-format:
# IRC to dynmap action nick template
irc-dynmap-action-nick: '[IRC] ***%NICK%'
# OreBroadcast message
ore-broadcast: '[OreBroadcast] %MESSAGE%'
ore-broadcast: '[OreBroadcast] &l%NAME%&c has found &6&l%COUNT%&c block%PLURAL% of [&l&k%ORE%&c]'
# Jobs seperator
jobs-separator: ', '
# Message format per hero channel. From IRC to game.