-
Notifications
You must be signed in to change notification settings - Fork 23
/
SubServerController.java
355 lines (301 loc) · 8.44 KB
/
SubServerController.java
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
package net.ME1312.SubServers.Bungee.Host;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import java.util.*;
/**
* API-Safe SubServer Layout Class
*/
public abstract class SubServerController {
private final SubServerContainer control;
/**
* Creates a SubServer
*
* @param host Host
* @param name Server Name
* @param port Port Number
* @param motd Server MOTD
* @param restricted Players will need a permission to join if true
* @throws InvalidServerException
*/
public SubServerController(Host host, String name, int port, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
control = new SubServerContainer(host, name, port, motd, hidden, restricted) {
@Override
public boolean start() {
return SubServerController.this.start();
}
@Override
public boolean start(UUID player) {
return SubServerController.this.start(player);
}
@Override
public boolean stop() {
return SubServerController.this.stop();
}
@Override
public boolean stop(UUID player) {
return SubServerController.this.stop(player);
}
@Override
public boolean terminate() {
return SubServerController.this.terminate();
}
@Override
public boolean terminate(UUID player) {
return SubServerController.this.terminate(player);
}
@Override
public boolean command(String command) {
return SubServerController.this.command(command);
}
@Override
public boolean command(UUID player, String command) {
return SubServerController.this.command(player, command);
}
@Override
public int edit(ObjectMap<String> edit) {
return SubServerController.this.edit(edit);
}
@Override
public int edit(UUID player, ObjectMap<String> edit) {
return SubServerController.this.edit(player, edit);
}
@Override
public void waitFor() throws InterruptedException {
SubServerController.this.waitFor();
}
@Override
public boolean isRunning() {
return SubServerController.this.isRunning();
}
@Override
public Host getHost() {
return SubServerController.this.getHost();
}
@Override
public boolean isEnabled() {
return SubServerController.this.isEnabled();
}
@Override
public void setEnabled(boolean value) {
SubServerController.this.setEnabled(value);
}
@Override
public boolean isLogging() {
return SubServerController.this.isLogging();
}
@Override
public void setLogging(boolean value) {
SubServerController.this.setLogging(value);
}
@Override
public SubLogger getLogger() {
return SubServerController.this.getLogger();
}
@Override
public LinkedList<LoggedCommand> getCommandHistory() {
return SubServerController.this.getCommandHistory();
}
@Override
public String getPath() {
return SubServerController.this.getPath();
}
@Override
public String getExecutable() {
return SubServerController.this.getExecutable();
}
@Override
public String getStopCommand() {
return SubServerController.this.getStopCommand();
}
@Override
public void setStopCommand(String value) {
SubServerController.this.setStopCommand(value);
}
@Override
public StopAction getStopAction() {
return SubServerController.this.getStopAction();
}
@Override
public void setStopAction(StopAction action) {
SubServerController.this.setStopAction(action);
}
};
}
/**
* Get the SubServer that is being controlled
*
* @return SubServer
*/
public SubServer get() {
return control;
}
/**
* Starts the Server
*
* @param player Player who Started
* @return Success Status
*/
public abstract boolean start(UUID player);
/**
* Starts the Server
*
* @return Success Status
*/
public boolean start() {
return start(null);
}
/**
* Stops the Server
*
* @param player Player who Stopped
* @return Success Status
*/
public abstract boolean stop(UUID player);
/**
* Stops the Server
*
* @return Success Status
*/
public boolean stop() {
return stop(null);
}
/**
* Terminates the Server
*
* @param player Player who Terminated
* @return Success Status
*/
public abstract boolean terminate(UUID player);
/**
* Terminates the Server
*
* @return Success Status
*/
public boolean terminate() {
return terminate(null);
}
/**
* Commands the Server
*
* @param player Player who Commanded
* @param command Command to Send
* @return Success Status
*/
public abstract boolean command(UUID player, String command);
/**
* Commands the Server
*
* @param command Command to Send
* @return Success Status
*/
public boolean command(String command) {
return command(null, command);
}
/**
* Edits the Server
*
* @param player Player Editing
* @param edit Edits
* @return Success Status
*/
public int edit(UUID player, ObjectMap<String> edit) {
return -1;
}
/**
* Edits the Server
*
* @param edit Edits
* @return Success Status
*/
public int edit(ObjectMap<String> edit) {
return -1;
}
/**
* Waits for the Server to Stop
*
* @throws InterruptedException
*/
public abstract void waitFor() throws InterruptedException;
/**
* If the Server is Running
*
* @return Running Status
*/
public abstract boolean isRunning();
/**
* Grabs the Host of the Server
*
* @return The Host
*/
public abstract Host getHost();
/**
* If the Server is Enabled
*
* @return Enabled Status
*/
public abstract boolean isEnabled();
/**
* Set if the Server is Enabled
*
* @param value Value
*/
public abstract void setEnabled(boolean value);
/**
* If the Server is Logging
*
* @return Logging Status
*/
public abstract boolean isLogging();
/**
* Set if the Server is Logging
*
* @param value Value
*/
public abstract void setLogging(boolean value);
/**
* Get Process Logger
*/
public abstract SubLogger getLogger();
/**
* Gets all the commands that were sent to this Server successfully
*
* @return Command History
*/
public abstract LinkedList<SubServer.LoggedCommand> getCommandHistory();
/**
* Get the Server Directory Path
*
* @return Server Directory Path
*/
public abstract String getPath();
/**
* Get the Server's Executable String
*
* @return Executable String
*/
public abstract String getExecutable();
/**
* Grab the Command to Stop the Server
*
* @return Stop Command
*/
public abstract String getStopCommand();
/**
* Set the Command that Stops the Server
*
* @param value Value
*/
public abstract void setStopCommand(String value);
/**
* Get the action the Server will take when it stops
*
* @return Stop Action
*/
public abstract SubServer.StopAction getStopAction();
/**
* Set the action the Server will take when it stops
*
* @param action Stop Action
*/
public abstract void setStopAction(SubServer.StopAction action);
}