Work on server

This commit is contained in:
Aidan C. Brady 2013-10-13 23:40:28 -04:00
parent fbedc1915f
commit 17fdc03e9f

View file

@ -6,16 +6,25 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;
import net.minecraft.entity.player.EntityPlayerMP;
import cpw.mods.fml.common.FMLCommonHandler;
public class VoiceConnection
{
public Socket socket;
public EntityPlayerMP entityPlayer;
public boolean open = true;
public DataInputStream input;
public DataOutputStream output;
public VoiceConnection(Socket s)
{
socket = s;
start();
}
public void start()
@ -24,16 +33,53 @@ public class VoiceConnection
input = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
new Thread(new Runnable()
for(Object obj : FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList)
{
@Override
public void run()
if(obj instanceof EntityPlayerMP)
{
EntityPlayerMP playerMP = (EntityPlayerMP)obj;
String playerIP = playerMP.getPlayerIP();
if(playerIP.equals("127.0.0.1"))
{
entityPlayer = playerMP;
break;
}
else if(playerIP.equals(socket.getInetAddress().getHostAddress()))
{
entityPlayer = playerMP;
break;
}
}
}
} catch(Exception e) {
open = false;
}
//Main client listen thread
new Thread(new Runnable()
{
@Override
public void run()
{
try {
while(open)
{
}
} catch(Exception e) {
open = false;
}
if(!open)
{
try {
input.close();
output.close();
socket.close();
} catch(Exception e) {}
}
}).start();
} catch(Exception e) {}
}
}).start();
}
}