blob: aa1592d31f240c2fb141d61010c958ac9071d009 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
package de.torui.coflsky;
import java.net.URI;
import java.net.URISyntaxException;
import de.torui.coflsky.websocket.WSClient;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class EventRegistry{
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void PlayerLoggedIn(PlayerLoggedInEvent plie) {
System.out.println("COFLSKY initialized");
if(plie.player.getEntityWorld().isRemote) {
//is a server
/*ServerData sd = Minecraft.getMinecraft().getCurrentServerData();
if(sd != null) {
System.out.println("ServerIP:= " + sd.serverIP);
} else {
System.out.println("Could not get serverdata");
}
*/
if(CoflSky.WS == null) {
try {
String uuid = Minecraft.getMinecraft().thePlayer.getPersistentID().toString();
//String uuid = Minecraft.getMinecraft().thePlayer.getUUID(null)
CoflSky.WS = new WSClient(new URI("wss://sky-commands.coflnet.com/modsocket?uuid=" + uuid));
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thread t = new Thread(CoflSky.WS);
}
} else {
System.out.println("World is not remote");
}
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void PlayerLoggedOut(PlayerLoggedOutEvent ploe) {
System.out.println("COFLSKY disabled");
if(CoflSky.WS != null) {
try {
CoflSky.WS.closeBlocking();
CoflSky.WS = null;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
|