14
14
public class BungeeSocket {
15
15
16
16
// Here sits the lovely MGLib server waiting for requests from our Lobby slaves >:D
17
+ // Socket server moved to lobby, dis our slave now :(
17
18
18
19
// We're gonna send simple strings like: sign:<minigame>:<arena>:<state>:<players>/<amxplayers>
19
20
20
- PluginInstance pli ;
21
-
22
- public ArrayList <Socket > clients = new ArrayList <Socket >();
23
-
24
- public BungeeSocket (PluginInstance pli ) {
25
- this .pli = pli ;
26
- }
27
-
28
- public String signUpdateString (Arena a ) {
21
+ public static String signUpdateString (PluginInstance pli , Arena a ) {
29
22
if (a == null ) {
30
23
return "sign:" + pli .getPlugin ().getName () + ":null:JOIN:0:0" ;
31
24
}
32
25
return "sign:" + pli .getPlugin ().getName () + ":" + a .getInternalName () + ":" + a .getArenaState ().toString () + ":" + a .getAllPlayers ().size () + ":" + a .getMaxPlayers ();
33
26
}
34
27
35
- /*
36
- * public void sendSingUpdate(String arenaname) { for (Socket s : clients) { try { PrintWriter out = new PrintWriter(s.getOutputStream(), true);
37
- * out.println(signUpdateString(pli.getArenaByName(arenaname))); } catch (Exception e) { e.printStackTrace(); } } }
38
- */
28
+ static ArrayList <Integer > portsUp = new ArrayList <Integer >();
29
+ static boolean init = false ;
30
+ static boolean initializing = false ;
39
31
40
- ArrayList <Integer > portsUp = new ArrayList <Integer >();
41
- boolean init = false ;
42
- boolean initializing = false ;
43
-
44
- public void sendSignUpdate (final Arena a ) {
32
+ public static void sendSignUpdate (final PluginInstance pli , final Arena a ) {
45
33
try {
46
34
System .out .println ("" + init );
47
35
if (init ) {
48
36
for (int i : portsUp ) {
49
37
ArenaLogger .debug ("Sending to port " + i );
50
38
Socket socket = new Socket ("127.0.0.1" , i );
51
39
PrintWriter out = new PrintWriter (socket .getOutputStream (), true );
52
- out .println (signUpdateString (a ));
40
+ out .println (signUpdateString (pli , a ));
53
41
socket .close ();
54
42
}
55
43
return ;
56
44
}
57
45
// Of course we'll have lags at the first sign update as we check through 20 ports
58
46
if (!initializing ) {
47
+ initializing = true ;
59
48
new Thread (new Runnable () {
60
49
public void run () {
61
50
for (int i = 13380 ; i < 13400 ; i ++) {
@@ -66,7 +55,7 @@ public void run() {
66
55
portsUp .add (i );
67
56
}
68
57
PrintWriter out = new PrintWriter (socket .getOutputStream (), true );
69
- out .println (signUpdateString (a ));
58
+ out .println (signUpdateString (pli , a ));
70
59
socket .close ();
71
60
} catch (Exception e ) {
72
61
ArenaLogger .debug ("Could not connect to port " + i );
@@ -75,7 +64,6 @@ public void run() {
75
64
init = true ;
76
65
}
77
66
}).start ();
78
- initializing = true ;
79
67
}
80
68
} catch (Exception e ) {
81
69
e .printStackTrace ();
0 commit comments