2016-12-24 05:55:17 +01:00
|
|
|
package net.ME1312.SubServers.Bungee.Host;
|
2016-12-05 04:21:04 +01:00
|
|
|
|
2019-04-18 16:02:09 +02:00
|
|
|
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
|
|
|
import net.ME1312.Galaxi.Library.Util;
|
2016-12-05 04:21:04 +01:00
|
|
|
|
2021-12-01 10:50:25 +01:00
|
|
|
import java.io.File;
|
2017-07-21 22:45:41 +02:00
|
|
|
import java.util.*;
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
2017-08-27 20:37:25 +02:00
|
|
|
* SubServer Interface
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
public interface SubServer extends Server {
|
2018-08-30 03:55:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SubServer Stop Action Class
|
|
|
|
*/
|
|
|
|
enum StopAction {
|
|
|
|
NONE,
|
|
|
|
RESTART,
|
|
|
|
REMOVE_SERVER,
|
2019-04-18 16:02:09 +02:00
|
|
|
RECYCLE_SERVER,
|
2018-08-30 03:55:59 +02:00
|
|
|
DELETE_SERVER;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return super.toString().substring(0, 1).toUpperCase()+super.toString().substring(1).toLowerCase().replace('_', ' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
|
|
|
* Command Storage Class
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
class LoggedCommand {
|
2017-01-21 17:49:37 +01:00
|
|
|
private Date date;
|
|
|
|
private UUID sender;
|
|
|
|
private String command;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a Command
|
|
|
|
*
|
|
|
|
* @param command Command
|
|
|
|
*/
|
|
|
|
public LoggedCommand(String command) {
|
2021-10-24 06:14:07 +02:00
|
|
|
Util.nullpo(command);
|
2017-01-21 17:49:37 +01:00
|
|
|
this.date = Calendar.getInstance().getTime();
|
|
|
|
this.sender = null;
|
|
|
|
this.command = command;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a Command
|
|
|
|
*
|
|
|
|
* @param sender Command Sender (null for CONSOLE)
|
|
|
|
* @param command Command
|
|
|
|
*/
|
|
|
|
public LoggedCommand(UUID sender, String command) {
|
2021-10-24 06:14:07 +02:00
|
|
|
Util.nullpo(command);
|
2017-01-21 17:49:37 +01:00
|
|
|
this.date = Calendar.getInstance().getTime();
|
|
|
|
this.sender = sender;
|
|
|
|
this.command = command;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a Command
|
|
|
|
*
|
|
|
|
* @param date Date
|
|
|
|
* @param sender Command Sender (null for CONSOLE)
|
|
|
|
* @param command Command
|
|
|
|
*/
|
|
|
|
public LoggedCommand(Date date, UUID sender, String command) {
|
2021-10-24 06:14:07 +02:00
|
|
|
Util.nullpo(date, command);
|
2017-01-30 21:22:36 +01:00
|
|
|
this.date = date;
|
2017-01-21 17:49:37 +01:00
|
|
|
this.sender = sender;
|
|
|
|
this.command = command;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the date this command was logged
|
|
|
|
*
|
|
|
|
* @return Date
|
|
|
|
*/
|
|
|
|
public Date getDate() {
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the command sender
|
|
|
|
*
|
|
|
|
* @return Command Sender (null if CONSOLE)
|
|
|
|
*/
|
|
|
|
public UUID getSender() {
|
|
|
|
return sender;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the command
|
|
|
|
*
|
|
|
|
* @return Command
|
|
|
|
*/
|
|
|
|
public String getCommand() {
|
|
|
|
return command;
|
|
|
|
}
|
|
|
|
}
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts the Server
|
|
|
|
*
|
|
|
|
* @param player Player who Started
|
2016-12-19 01:38:02 +01:00
|
|
|
* @return Success Status
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
boolean start(UUID player);
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts the Server
|
2016-12-19 01:38:02 +01:00
|
|
|
*
|
|
|
|
* @return Success Status
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2021-12-01 10:50:25 +01:00
|
|
|
default boolean start() {
|
|
|
|
return start(null);
|
|
|
|
}
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stops the Server
|
|
|
|
*
|
|
|
|
* @param player Player who Stopped
|
2016-12-19 01:38:02 +01:00
|
|
|
* @return Success Status
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
boolean stop(UUID player);
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stops the Server
|
2016-12-19 01:38:02 +01:00
|
|
|
*
|
|
|
|
* @return Success Status
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2021-12-01 10:50:25 +01:00
|
|
|
default boolean stop() {
|
|
|
|
return stop(null);
|
|
|
|
}
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Terminates the Server
|
|
|
|
*
|
|
|
|
* @param player Player who Terminated
|
2016-12-19 01:38:02 +01:00
|
|
|
* @return Success Status
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
boolean terminate(UUID player);
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Terminates the Server
|
2016-12-19 01:38:02 +01:00
|
|
|
*
|
|
|
|
* @return Success Status
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2021-12-01 10:50:25 +01:00
|
|
|
default boolean terminate() {
|
|
|
|
return terminate(null);
|
|
|
|
}
|
2016-12-05 04:21:04 +01:00
|
|
|
|
2017-04-24 18:28:16 +02:00
|
|
|
/**
|
|
|
|
* Edits the Server
|
|
|
|
*
|
|
|
|
* @param player Player Editing
|
|
|
|
* @param edit Edits
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
2019-04-18 16:02:09 +02:00
|
|
|
default int edit(UUID player, ObjectMap<String> edit) {
|
2018-08-30 03:55:59 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2017-04-24 18:28:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Edits the Server
|
|
|
|
*
|
|
|
|
* @param edit Edits
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
2019-04-18 16:02:09 +02:00
|
|
|
default int edit(ObjectMap<String> edit) {
|
2019-05-09 22:17:15 +02:00
|
|
|
return edit(null, edit);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edits the Server (& Saves Changes)
|
|
|
|
*
|
|
|
|
* @param player Player Editing
|
|
|
|
* @param edit Edits
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
|
|
|
default int permaEdit(UUID player, ObjectMap<String> edit) {
|
2018-08-30 03:55:59 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2017-04-24 18:28:16 +02:00
|
|
|
|
2019-05-09 22:17:15 +02:00
|
|
|
/**
|
|
|
|
* Edits the Server (& Saves Changes)
|
|
|
|
*
|
|
|
|
* @param edit Edits
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
|
|
|
default int permaEdit(ObjectMap<String> edit) {
|
|
|
|
return permaEdit(null, edit);
|
|
|
|
}
|
|
|
|
|
2016-12-05 04:21:04 +01:00
|
|
|
/**
|
|
|
|
* Waits for the Server to Stop
|
|
|
|
*
|
|
|
|
* @throws InterruptedException
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
void waitFor() throws InterruptedException;
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the Server is Running
|
|
|
|
*
|
|
|
|
* @return Running Status
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
boolean isRunning();
|
2016-12-05 04:21:04 +01:00
|
|
|
|
2020-07-05 04:39:59 +02:00
|
|
|
/**
|
|
|
|
* If the Server is Online<br>
|
|
|
|
* <b>This method can only be true when a SubData connection is made!</b>
|
|
|
|
*
|
|
|
|
* @return Online Status
|
|
|
|
*/
|
|
|
|
boolean isOnline();
|
|
|
|
|
2016-12-05 04:21:04 +01:00
|
|
|
/**
|
|
|
|
* Grabs the Host of the Server
|
|
|
|
*
|
|
|
|
* @return The Host
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
Host getHost();
|
2016-12-05 04:21:04 +01:00
|
|
|
|
2019-06-17 05:13:48 +02:00
|
|
|
/**
|
|
|
|
* Grabs the Template this Server was created from
|
|
|
|
*
|
|
|
|
* @return The Template
|
|
|
|
*/
|
|
|
|
SubCreator.ServerTemplate getTemplate();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Template this Server was created from
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
|
|
|
void setTemplate(SubCreator.ServerTemplate value);
|
|
|
|
|
2020-06-20 03:00:50 +02:00
|
|
|
/**
|
|
|
|
* Sets the Template this Server was created from
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
|
|
|
void setTemplate(String value);
|
|
|
|
|
2019-06-17 05:13:48 +02:00
|
|
|
/**
|
|
|
|
* Is this Host Available?
|
|
|
|
*
|
|
|
|
* @return Availability Status
|
|
|
|
*/
|
|
|
|
boolean isAvailable();
|
|
|
|
|
2016-12-05 04:21:04 +01:00
|
|
|
/**
|
|
|
|
* If the Server is Enabled
|
|
|
|
*
|
|
|
|
* @return Enabled Status
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
boolean isEnabled();
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set if the Server is Enabled
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
void setEnabled(boolean value);
|
2016-12-05 04:21:04 +01:00
|
|
|
|
2017-12-07 23:51:06 +01:00
|
|
|
/**
|
|
|
|
* If the Server is accepting requests to edit()
|
|
|
|
*
|
2019-05-09 22:17:15 +02:00
|
|
|
* @see #permaEdit(ObjectMap<String>)
|
|
|
|
* @see #permaEdit(UUID, ObjectMap<String>)
|
2017-12-07 23:51:06 +01:00
|
|
|
* @return Edit Status
|
|
|
|
*/
|
2018-08-30 03:55:59 +02:00
|
|
|
default boolean isEditable() {
|
2019-05-09 22:17:15 +02:00
|
|
|
return permaEdit(new ObjectMap<String>()) >= 0;
|
2018-08-30 03:55:59 +02:00
|
|
|
}
|
2017-12-07 23:51:06 +01:00
|
|
|
|
2016-12-05 04:21:04 +01:00
|
|
|
/**
|
|
|
|
* If the Server is Logging
|
|
|
|
*
|
|
|
|
* @return Logging Status
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
boolean isLogging();
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set if the Server is Logging
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
void setLogging(boolean value);
|
2016-12-05 04:21:04 +01:00
|
|
|
|
2017-01-09 20:37:57 +01:00
|
|
|
/**
|
|
|
|
* Get Process Logger
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
SubLogger getLogger();
|
2017-01-01 20:34:46 +01:00
|
|
|
|
2017-01-21 17:49:37 +01:00
|
|
|
/**
|
2017-07-21 22:45:41 +02:00
|
|
|
* Gets all the commands that were sent to this Server successfully
|
2017-01-21 17:49:37 +01:00
|
|
|
*
|
|
|
|
* @return Command History
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
LinkedList<LoggedCommand> getCommandHistory();
|
2017-01-21 17:49:37 +01:00
|
|
|
|
2017-01-01 20:34:46 +01:00
|
|
|
/**
|
2017-04-24 18:28:16 +02:00
|
|
|
* Get the Server Directory Path
|
|
|
|
*
|
|
|
|
* @return Server Directory Path
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
String getPath();
|
2017-04-24 18:28:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Full Server Directory Path
|
|
|
|
*
|
|
|
|
* @return Full Server Directory Path
|
|
|
|
*/
|
2021-12-01 10:50:25 +01:00
|
|
|
default String getFullPath() {
|
|
|
|
return new File(getHost().getPath(), getPath()).getPath();
|
|
|
|
}
|
2017-04-24 18:28:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Server's Executable String
|
2017-01-01 20:34:46 +01:00
|
|
|
*
|
2017-04-24 18:28:16 +02:00
|
|
|
* @return Executable String
|
2017-01-01 20:34:46 +01:00
|
|
|
*/
|
2019-01-04 22:51:58 +01:00
|
|
|
String getExecutable();
|
2017-01-01 20:34:46 +01:00
|
|
|
|
2016-12-05 04:21:04 +01:00
|
|
|
/**
|
|
|
|
* Grab the Command to Stop the Server
|
|
|
|
*
|
|
|
|
* @return Stop Command
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
String getStopCommand();
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the Command that Stops the Server
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
void setStopCommand(String value);
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
2018-08-30 03:55:59 +02:00
|
|
|
* Get the action the Server will take when it stops
|
2016-12-05 04:21:04 +01:00
|
|
|
*
|
2018-08-30 03:55:59 +02:00
|
|
|
* @return Stop Action
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2018-08-30 03:55:59 +02:00
|
|
|
StopAction getStopAction();
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
2018-08-30 03:55:59 +02:00
|
|
|
* Set the action the Server will take when it stops
|
2016-12-05 04:21:04 +01:00
|
|
|
*
|
2018-08-30 03:55:59 +02:00
|
|
|
* @param action Stop Action
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2018-08-30 03:55:59 +02:00
|
|
|
void setStopAction(StopAction action);
|
2016-12-05 04:21:04 +01:00
|
|
|
|
2017-07-21 22:45:41 +02:00
|
|
|
/**
|
|
|
|
* Toggles compatibility with other Servers
|
|
|
|
*
|
|
|
|
* @param server SubServers to toggle
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
void toggleCompatibility(SubServer... server);
|
2017-07-21 22:45:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a Server is compatible
|
|
|
|
*
|
|
|
|
* @param server Server to check
|
|
|
|
* @return Compatible Status
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
boolean isCompatible(SubServer server);
|
2017-07-21 22:45:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get all listed incompatibilities for this Server
|
|
|
|
*
|
|
|
|
* @return Incompatibility List
|
|
|
|
*/
|
2018-08-30 03:55:59 +02:00
|
|
|
List<SubServer> getIncompatibilities();
|
2017-07-21 22:45:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get incompatibility issues this server currently has
|
|
|
|
*
|
|
|
|
* @return Current Incompatibility List
|
|
|
|
*/
|
2017-08-27 20:37:25 +02:00
|
|
|
List<SubServer> getCurrentIncompatibilities();
|
2016-12-05 04:21:04 +01:00
|
|
|
}
|