From e71a4f0ba7d91b1e9481017449c19b9a97989eee Mon Sep 17 00:00:00 2001
From: Zak Ford <zak.j.ford@gmail.com>
Date: Fri, 6 Apr 2012 08:21:47 -0400
Subject: [PATCH 3/3] Added console-only bridges

---
 .../uircbridge/BridgeManager.java                  |   14 +++++++++++---
 .../uircbridge/EventListener.java                  |    2 +-
 .../ultimateminecraft/uircbridge/UIRCBridge.java   |   19 +++++++++++++++----
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/src/net/ultimateminecraft/uircbridge/BridgeManager.java b/src/net/ultimateminecraft/uircbridge/BridgeManager.java
index cedb54d..e35415b 100644
--- a/src/net/ultimateminecraft/uircbridge/BridgeManager.java
+++ b/src/net/ultimateminecraft/uircbridge/BridgeManager.java
@@ -7,10 +7,14 @@ import com.dthielke.herochat.Channel;
 
 public class BridgeManager {
 
-	public static Set<Bridge> bridges = new HashSet<Bridge>();
+	private static Set<Bridge> bridges = new HashSet<Bridge>();
+	private static Set<Bridge> consoleBridges = new HashSet<Bridge>();
 	
-	public static void add(String IRCChannel, String GameChannel) {
-		bridges.add(new Bridge(IRCChannel, GameChannel));
+	public static void add(String IRCChannel, String GameChannel, boolean isConsole) {
+	    Bridge b = new Bridge(IRCChannel, GameChannel);
+		bridges.add(b);
+		if (isConsole)
+		    consoleBridges.add(b);
 	}
 	
 	public static Set<Bridge> getBridges(Channel channel) {
@@ -32,4 +36,8 @@ public class BridgeManager {
 		}
 		return ret;
 	}
+	
+	public static Set<Bridge> getConsoleBridges() {
+	    return consoleBridges;
+	}
 }
diff --git a/src/net/ultimateminecraft/uircbridge/EventListener.java b/src/net/ultimateminecraft/uircbridge/EventListener.java
index eb4d60f..ef8f7df 100644
--- a/src/net/ultimateminecraft/uircbridge/EventListener.java
+++ b/src/net/ultimateminecraft/uircbridge/EventListener.java
@@ -17,7 +17,7 @@ public class EventListener implements Listener {
 		if (event.getCommand().startsWith("say")) {
 			String message = event.getCommand().substring(4);
 			// broadcast
-			for (Bridge b : BridgeManager.bridges) {
+			for (Bridge b : BridgeManager.getConsoleBridges()) {
 				b.endPoint.messageOut(message, "Server", b.craftIRCTag, b.GameChannel.getName(), b.GameChannel.getNick());
 			}
 		}
diff --git a/src/net/ultimateminecraft/uircbridge/UIRCBridge.java b/src/net/ultimateminecraft/uircbridge/UIRCBridge.java
index 5665dc7..8def960 100644
--- a/src/net/ultimateminecraft/uircbridge/UIRCBridge.java
+++ b/src/net/ultimateminecraft/uircbridge/UIRCBridge.java
@@ -1,6 +1,9 @@
 package net.ultimateminecraft.uircbridge;
 
 import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.bukkit.plugin.java.JavaPlugin;
 
@@ -27,13 +30,20 @@ public class UIRCBridge extends JavaPlugin {
 		if ((new File(getDataFolder(), "config.yml").exists())) {
 			getLogger().info("Parsing config file");
 
-			java.util.Set<String> bridges = null;
+			Set<String> bridges = null;
+            Set<String> consoleBridges = null;
+            if (getConfig().contains("uIRCBridge.consolebridge")) {
+                consoleBridges = new HashSet<String>(getConfig().getStringList("uIRCBridge.consolebridge"));
+            }
 			if (getConfig().contains("uIRCBridge.bridges")) {
 				bridges = getConfig().getConfigurationSection("uIRCBridge.bridges").getKeys(false);
 				if (bridges != null) {
-					//if (getConfig().getConfigurationSection("uIRCBridge.bridges").getKeys(false).size() > 0) {
 					for (String bridge: bridges) {
-						BridgeManager.add(bridge, getConfig().getString("uIRCBridge.bridges." + bridge));
+					    boolean isConsole = false;
+					    if (consoleBridges != null && consoleBridges.contains(bridge))
+					        isConsole = true;
+					    
+						BridgeManager.add(bridge, getConfig().getString("uIRCBridge.bridges." + bridge), isConsole);
 						getLogger().info(bridge + " added.");
 					}
 					return;
@@ -43,7 +53,8 @@ public class UIRCBridge extends JavaPlugin {
 
 		getLogger().info("Creating new config file");
 		getConfig().set("uIRCBridge.bridges.CraftIRC-Tag-1", "HeroChat-Channel-1");
-		getConfig().set("uIRCBridge.bridges.CraftIRC-Tag-2", "HeroChat-Channel-2");
+        getConfig().set("uIRCBridge.bridges.CraftIRC-Tag-2", "HeroChat-Channel-2");
+        getConfig().set("uIRCBridge.consolebridge", Arrays.asList("CraftIRC-Tag-1", "CraftIRC-Tag-2"));
 		saveConfig();
 
 	}
-- 
1.7.8.msysgit.0

