Don't launch VoiceClient unless VoiceServerEnabled is set to true

This commit is contained in:
Aidan C. Brady 2013-10-28 07:16:22 -04:00
parent 2fb13e1f3d
commit d8a4ecb986

View file

@ -31,30 +31,39 @@ public class ClientConnectionHandler implements IConnectionHandler
@Override @Override
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager)
{
if(Mekanism.voiceServerEnabled)
{ {
try { try {
voiceClient = new VoiceClient(server, 36123); voiceClient = new VoiceClient(server, 36123);
voiceClient.run(); voiceClient.run();
} catch(Exception e) {} } catch(Exception e) {}
} }
}
@Override @Override
public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager)
{
if(Mekanism.voiceServerEnabled)
{ {
try { try {
voiceClient = new VoiceClient(InetAddress.getLocalHost().getHostAddress(), 36123); voiceClient = new VoiceClient(InetAddress.getLocalHost().getHostAddress(), 36123);
voiceClient.run(); voiceClient.run();
} catch(Exception e) {} } catch(Exception e) {}
} }
}
@Override @Override
public void connectionClosed(INetworkManager manager) public void connectionClosed(INetworkManager manager)
{
if(Mekanism.voiceServerEnabled)
{ {
if(voiceClient != null) if(voiceClient != null)
{ {
voiceClient.disconnect(); voiceClient.disconnect();
voiceClient = null; voiceClient = null;
} }
}
Mekanism.proxy.unloadSoundHandler(); Mekanism.proxy.unloadSoundHandler();
} }