From f4ced367cdd08c21f479a7d4c933b718700bb12c Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Sat, 26 Oct 2013 23:55:11 -0400 Subject: [PATCH] Add option to disable voice server --- common/mekanism/client/voice/VoiceClient.java | 3 +++ common/mekanism/common/CommonProxy.java | 1 + common/mekanism/common/Mekanism.java | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/common/mekanism/client/voice/VoiceClient.java b/common/mekanism/client/voice/VoiceClient.java index a7a3a265a..3bee035f4 100644 --- a/common/mekanism/client/voice/VoiceClient.java +++ b/common/mekanism/client/voice/VoiceClient.java @@ -4,6 +4,7 @@ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; +import java.net.ConnectException; import java.net.Socket; import javax.sound.sampled.AudioFormat; @@ -51,6 +52,8 @@ public class VoiceClient extends Thread (inputThread = new VoiceInput(this)).start(); System.out.println("[Mekanism] VoiceServer: Successfully connected to server."); + } catch(ConnectException e) { + System.err.println("[Mekanism] VoiceServer: Server's VoiceServer is disabled."); } catch(Exception e) { System.err.println("[Mekanism] VoiceServer: Error while starting client connection."); e.printStackTrace(); diff --git a/common/mekanism/common/CommonProxy.java b/common/mekanism/common/CommonProxy.java index aff11a768..773fb8d7d 100644 --- a/common/mekanism/common/CommonProxy.java +++ b/common/mekanism/common/CommonProxy.java @@ -149,6 +149,7 @@ public class CommonProxy Mekanism.controlCircuitOreDict = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ControlCircuitOreDict", true).getBoolean(true); Mekanism.logPackets = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "LogPackets", false).getBoolean(true); Mekanism.dynamicTankEasterEgg = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DynamicTankEasterEgg", false).getBoolean(true); + Mekanism.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", true).getBoolean(true); Mekanism.obsidianTNTDelay = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTDelay", 100).getInt(); Mekanism.obsidianTNTBlastRadius = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12).getInt(); Mekanism.UPDATE_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ClientUpdateDelay", 10).getInt(); diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index 499a67e75..023bc81ab 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -222,6 +222,7 @@ public class Mekanism public static boolean controlCircuitOreDict = true; public static boolean logPackets = false; public static boolean dynamicTankEasterEgg = false; + public static boolean voiceServerEnabled = true; public static int obsidianTNTBlastRadius = 12; public static int obsidianTNTDelay = 100; public static int UPDATE_DELAY = 10; @@ -1039,14 +1040,22 @@ public class Mekanism @EventHandler public void serverStarting(FMLServerStartingEvent event) { - voiceManager.start(); + if(voiceServerEnabled) + { + voiceManager.start(); + } + event.registerServerCommand(new CommandMekanism()); } @EventHandler public void serverStopping(FMLServerStoppingEvent event) { - voiceManager.stop(); + if(voiceServerEnabled) + { + voiceManager.stop(); + } + teleporters.clear(); dynamicInventories.clear(); } @@ -1106,7 +1115,10 @@ public class Mekanism MinecraftForge.EVENT_BUS.register(this); //Set up VoiceServerManager - voiceManager = new VoiceServerManager(); + if(voiceServerEnabled) + { + voiceManager = new VoiceServerManager(); + } //Register with TransmitterNetworkRegistry TransmitterNetworkRegistry.initiate();