mirror of
https://bitbucket.org/projectswg/lightspeed.git
synced 2026-01-16 23:04:40 -05:00
Added servers.csv for storing server list
This commit is contained in:
@@ -1,9 +1,3 @@
|
||||
CREATE TABLE IF NOT EXISTS servers (
|
||||
id TEXT PRIMARY KEY,
|
||||
directory TEXT,
|
||||
jvm_arguments TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS builds (
|
||||
id INTEGER PRIMARY KEY,
|
||||
time INTEGER,
|
||||
@@ -24,5 +18,3 @@ CREATE TABLE IF NOT EXISTS deployments (
|
||||
start_time INTEGER,
|
||||
end_time INTEGER
|
||||
);
|
||||
|
||||
PRAGMA user_version = 1;
|
||||
|
||||
2
data/servers.csv
Normal file
2
data/servers.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
name,directory,jvm_arguments
|
||||
NGE,/home/josh/devel/ProjectSWG/swg_workspace/Holocore,
|
||||
|
@@ -37,9 +37,7 @@ public interface BackendData {
|
||||
|
||||
ServerServerData getServer(String serverId);
|
||||
List<ServerServerData> getServerList();
|
||||
void insertServer(ServerServerData server);
|
||||
void insertBuild(ServerBuildData build);
|
||||
void insertDeployment(ServerDeploymentData deployment);
|
||||
void removeServer(String serverId);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,59 +25,73 @@
|
||||
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.post;
|
||||
package com.projectswg.common.data;
|
||||
|
||||
import me.joshlarson.json.JSONObject;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.projectswg.common.network.packets.PacketType;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
import com.projectswg.common.debug.Log;
|
||||
|
||||
public class PostCreateServerPacket extends PostPacket {
|
||||
public class CsvTable {
|
||||
|
||||
private static final String SERVER_ID = "server_id";
|
||||
private static final String DIRECTORY = "directory";
|
||||
private static final String JVM_ARGS = "jvm_arguments";
|
||||
private final File file;
|
||||
private final Map<String, Integer> columns;
|
||||
private final List<String[]> table;
|
||||
|
||||
public PostCreateServerPacket(JSONObject json) {
|
||||
super(json, PacketType.POST_CREATE_SERVER);
|
||||
public CsvTable(File file) {
|
||||
this.file = file;
|
||||
this.columns = new HashMap<>();
|
||||
this.table = new ArrayList<>();
|
||||
}
|
||||
|
||||
public PostCreateServerPacket(String serverId, String dir, String jvmArguments) {
|
||||
super(PacketType.POST_CREATE_SERVER);
|
||||
setServerId(serverId);
|
||||
setDirectory(dir);
|
||||
setJvmArguments(jvmArguments);
|
||||
public void read() throws IOException {
|
||||
columns.clear();
|
||||
table.clear();
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
readColumns(reader.readLine());
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
readRow(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SharedServerData getServer() {
|
||||
SharedServerData server = new SharedServerData(getServerId());
|
||||
server.setDirectory(getDirectory());
|
||||
server.setJvmArguments(getJvmArguments());
|
||||
return server;
|
||||
public String getRecord(int row, String column) {
|
||||
return getRecord(row, columns.get(column));
|
||||
}
|
||||
|
||||
public String getServerId() {
|
||||
return getJSON().getString(SERVER_ID);
|
||||
public String getRecord(int row, int column) {
|
||||
return table.get(row)[column];
|
||||
}
|
||||
|
||||
public String getDirectory() {
|
||||
return getJSON().getString(DIRECTORY);
|
||||
public int getRows() {
|
||||
return table.size();
|
||||
}
|
||||
|
||||
public String getJvmArguments() {
|
||||
return getJSON().getString(JVM_ARGS);
|
||||
public int getColumns() {
|
||||
return columns.size();
|
||||
}
|
||||
|
||||
public void setServerId(String serverId) {
|
||||
getJSON().put(SERVER_ID, serverId);
|
||||
private void readColumns(String line) {
|
||||
int i = 0;
|
||||
for (String col : line.split(",")) {
|
||||
columns.put(col, i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDirectory(String dir) {
|
||||
getJSON().put(DIRECTORY, dir);
|
||||
}
|
||||
|
||||
public void setJvmArguments(String jvmArguments) {
|
||||
getJSON().put(JVM_ARGS, jvmArguments);
|
||||
private void readRow(String line) {
|
||||
String [] row = line.split(",", columns.size());
|
||||
if (row.length != columns.size())
|
||||
Log.w("CSV Row does not contain enough columns! %s", Arrays.toString(row));
|
||||
table.add(row);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import com.projectswg.common.info.RelationalServerFactory;
|
||||
import com.projectswg.lightspeed.build.ServerBuildData;
|
||||
import com.projectswg.lightspeed.deployment.ServerDeploymentData;
|
||||
import com.projectswg.lightspeed.server.ServerServerData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData.DeploymentState;
|
||||
|
||||
public class HeavyweightBackendData implements BackendData {
|
||||
|
||||
@@ -47,16 +48,6 @@ public class HeavyweightBackendData implements BackendData {
|
||||
loadServers();
|
||||
}
|
||||
|
||||
public void insertServer(ServerServerData server) {
|
||||
synchronized (serverMap) {
|
||||
if (serverMap.put(server.getName(), server) != null)
|
||||
return;
|
||||
}
|
||||
try (ServerTable serverTable = new ServerTable()) {
|
||||
serverTable.insertServer(new SQLServerData(server));
|
||||
}
|
||||
}
|
||||
|
||||
public void insertBuild(ServerBuildData build) {
|
||||
try (BuildHistoryTable buildTable = new BuildHistoryTable()) {
|
||||
buildTable.insertBuildHistory(new SQLBuildData(build));
|
||||
@@ -69,15 +60,6 @@ public class HeavyweightBackendData implements BackendData {
|
||||
}
|
||||
}
|
||||
|
||||
public void removeServer(String serverId) {
|
||||
synchronized (serverMap) {
|
||||
serverMap.remove(serverId);
|
||||
}
|
||||
try (ServerTable serverTable = new ServerTable()) {
|
||||
serverTable.deleteServer(serverId);
|
||||
}
|
||||
}
|
||||
|
||||
public List<ServerServerData> getServerList() {
|
||||
List<ServerServerData> servers;
|
||||
synchronized (serverMap) {
|
||||
@@ -101,7 +83,7 @@ public class HeavyweightBackendData implements BackendData {
|
||||
private void loadServers() {
|
||||
synchronized (serverMap) {
|
||||
try (RelationalDatabase db = RelationalServerFactory.getServerDatabase("lightspeed.db")) {
|
||||
try (ServerTable serverTable = new ServerTable(db)) {
|
||||
try (ServerTable serverTable = new ServerTable()) {
|
||||
for (String serverId : serverTable.getServerStrings()) {
|
||||
ServerServerData server = createServerFromInfo(serverTable.getServerById(serverId));
|
||||
fetchBuildHistory(db, server);
|
||||
@@ -153,6 +135,7 @@ public class HeavyweightBackendData implements BackendData {
|
||||
ServerDeploymentData deployment = new ServerDeploymentData(info.getId(), server.getBuild(info.getBuildId()));
|
||||
deployment.setStartTime(info.getStartTime());
|
||||
deployment.setEndTime(info.getEndTime());
|
||||
deployment.setDeploymentState(DeploymentState.SHUTDOWN);
|
||||
return deployment;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ public class LightweightBackendData implements BackendData {
|
||||
return new ArrayList<>(serverMap.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertServer(ServerServerData server) {
|
||||
serverMap.put(server.getName(), server);
|
||||
}
|
||||
@@ -69,7 +68,6 @@ public class LightweightBackendData implements BackendData {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeServer(String serverId) {
|
||||
serverMap.remove(serverId);
|
||||
}
|
||||
|
||||
@@ -64,16 +64,6 @@ class SQLDeploymentData {
|
||||
this.endTime = 0;
|
||||
}
|
||||
|
||||
public JSONObject createJSON() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", id);
|
||||
json.put("server_id", serverId);
|
||||
json.put("build_id", buildId);
|
||||
json.put("start_time", TimeUtilities.getDateStringUtc(startTime));
|
||||
json.put("end_time", TimeUtilities.getDateStringUtc(endTime));
|
||||
return json;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -28,134 +28,44 @@
|
||||
package com.projectswg.common.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.projectswg.common.debug.Log;
|
||||
import com.projectswg.common.info.RelationalDatabase;
|
||||
import com.projectswg.common.info.RelationalServerFactory;
|
||||
|
||||
class ServerTable implements AutoCloseable {
|
||||
|
||||
private static final String INSERT_SERVER_SQL = "INSERT INTO servers (id, directory, jvm_arguments) VALUES (?, ?, ?)";
|
||||
private static final String DELETE_SERVER_SQL = "DELETE FROM servers WHERE id = ?";
|
||||
private static final String GET_SERVER_BY_DIR_SQL = "SELECT id, jvm_arguments FROM servers WHERE directory = ?";
|
||||
private static final String GET_SERVER_BY_ID_SQL = "SELECT directory, jvm_arguments FROM servers WHERE id = ?";
|
||||
private static final String GET_SERVERS_SQL = "SELECT id, directory, jvm_arguments FROM servers";
|
||||
|
||||
private final RelationalDatabase database;
|
||||
private final PreparedStatement insertServerStatement;
|
||||
private final PreparedStatement deleteServerStatement;
|
||||
private final PreparedStatement getServerByDirStatement;
|
||||
private final PreparedStatement getServerByIdStatement;
|
||||
private final PreparedStatement getServersStatement;
|
||||
private final CsvTable table;
|
||||
|
||||
public ServerTable() {
|
||||
this.database = RelationalServerFactory.getServerDatabase("lightspeed.db");
|
||||
this.insertServerStatement = database.prepareStatement(INSERT_SERVER_SQL);
|
||||
this.deleteServerStatement = database.prepareStatement(DELETE_SERVER_SQL);
|
||||
this.getServerByDirStatement = database.prepareStatement(GET_SERVER_BY_DIR_SQL);
|
||||
this.getServerByIdStatement = database.prepareStatement(GET_SERVER_BY_ID_SQL);
|
||||
this.getServersStatement = database.prepareStatement(GET_SERVERS_SQL);
|
||||
}
|
||||
|
||||
public ServerTable(RelationalDatabase db) {
|
||||
this.database = null;
|
||||
this.insertServerStatement = db.prepareStatement(INSERT_SERVER_SQL);
|
||||
this.deleteServerStatement = db.prepareStatement(DELETE_SERVER_SQL);
|
||||
this.getServerByDirStatement = db.prepareStatement(GET_SERVER_BY_DIR_SQL);
|
||||
this.getServerByIdStatement = db.prepareStatement(GET_SERVER_BY_ID_SQL);
|
||||
this.getServersStatement = db.prepareStatement(GET_SERVERS_SQL);
|
||||
this.table = new CsvTable(new File("data/servers.csv"));
|
||||
try {
|
||||
this.table.read();
|
||||
} catch (IOException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (database != null)
|
||||
database.close();
|
||||
safeClose(insertServerStatement);
|
||||
safeClose(deleteServerStatement);
|
||||
safeClose(getServerByDirStatement);
|
||||
safeClose(getServerByIdStatement);
|
||||
safeClose(getServersStatement);
|
||||
}
|
||||
|
||||
public boolean insertServer(SQLServerData server) {
|
||||
try {
|
||||
synchronized (insertServerStatement) {
|
||||
insertServerStatement.setString(1, server.getId());
|
||||
insertServerStatement.setString(2, server.getDir());
|
||||
insertServerStatement.setString(3, server.getJvmArgs());
|
||||
return insertServerStatement.executeUpdate() == 1;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean deleteServer(String serverId) {
|
||||
try {
|
||||
synchronized (deleteServerStatement) {
|
||||
deleteServerStatement.setString(1, serverId);
|
||||
return deleteServerStatement.executeUpdate() == 1;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public SQLServerData getServerByDirectory(File dir) {
|
||||
try {
|
||||
synchronized (getServerByDirStatement) {
|
||||
getServerByDirStatement.setString(1, dir.getAbsolutePath());
|
||||
ResultSet set = getServerByDirStatement.executeQuery();
|
||||
if (set.next())
|
||||
return new SQLServerData(set.getString("id"), dir.getAbsolutePath(), set.getString("jvm_arguments"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public SQLServerData getServerById(String id) {
|
||||
try {
|
||||
synchronized (getServerByIdStatement) {
|
||||
getServerByIdStatement.setString(1, id);
|
||||
ResultSet set = getServerByIdStatement.executeQuery();
|
||||
if (set.next())
|
||||
return new SQLServerData(id, set.getString("directory"), set.getString("jvm_arguments"));
|
||||
for (int i = 0; i < table.getRows(); i++) {
|
||||
if (table.getRecord(i, "name").equals(id)) {
|
||||
return new SQLServerData(id, table.getRecord(i, "directory"), table.getRecord(i, "jvm_arguments"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getServerStrings() {
|
||||
List<String> servers = new ArrayList<>();
|
||||
try {
|
||||
synchronized (getServersStatement) {
|
||||
ResultSet set = getServersStatement.executeQuery();
|
||||
while (set.next())
|
||||
servers.add(set.getString("id"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Log.e(e);
|
||||
for (int i = 0; i < table.getRows(); i++) {
|
||||
servers.add(table.getRecord(i, "name"));
|
||||
}
|
||||
return servers;
|
||||
}
|
||||
|
||||
private boolean safeClose(PreparedStatement statement) {
|
||||
try {
|
||||
statement.close();
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,13 +31,12 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.projectswg.common.data.BackendData;
|
||||
import com.projectswg.common.data.LightweightBackendData;
|
||||
|
||||
public class LightweightDataManager implements DataManager {
|
||||
|
||||
private final AtomicBoolean initialized;
|
||||
private final BackendData backendData;
|
||||
private final LightweightBackendData backendData;
|
||||
private final Map<ConfigFile, Config> configs;
|
||||
|
||||
public LightweightDataManager() {
|
||||
@@ -70,7 +69,7 @@ public class LightweightDataManager implements DataManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackendData getBackendData() {
|
||||
public LightweightBackendData getBackendData() {
|
||||
return backendData;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,8 +81,6 @@ public class Packet {
|
||||
case POST_DEPLOY: return new PostDeployPacket(json);
|
||||
case POST_STOP_BUILD: return new PostStopBuildPacket(json);
|
||||
case POST_STOP_DEPLOY: return new PostStopDeployPacket(json);
|
||||
case POST_CREATE_SERVER: return new PostCreateServerPacket(json);
|
||||
case POST_DELETE_SERVER: return new PostDeleteServerPacket(json);
|
||||
case POST_RESULT: return new PostResult(json);
|
||||
case REQUEST_SERVER_LIST: return new RequestServerListPacket(json);
|
||||
case REQUEST_BUILD_LIST: return new RequestBuildListPacket(json);
|
||||
|
||||
@@ -50,8 +50,6 @@ public enum PacketType {
|
||||
POST_BUILD,
|
||||
POST_DEPLOY,
|
||||
POST_STOP_BUILD,
|
||||
POST_STOP_DEPLOY,
|
||||
POST_CREATE_SERVER,
|
||||
POST_DELETE_SERVER
|
||||
POST_STOP_DEPLOY
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2015 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* -------------------------------------------------------------------------------- *
|
||||
* *
|
||||
* Holocore is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* Holocore is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***********************************************************************************/
|
||||
package com.projectswg.common.network.packets.post;
|
||||
|
||||
import me.joshlarson.json.JSONObject;
|
||||
|
||||
import com.projectswg.common.network.packets.PacketType;
|
||||
|
||||
public class PostDeleteServerPacket extends PostPacket {
|
||||
|
||||
private static final String SERVER_ID = "server_id";
|
||||
|
||||
public PostDeleteServerPacket(JSONObject json) {
|
||||
super(json, PacketType.POST_DELETE_SERVER);
|
||||
}
|
||||
|
||||
public PostDeleteServerPacket(String serverId) {
|
||||
super(PacketType.POST_DELETE_SERVER);
|
||||
setServerId(serverId);
|
||||
}
|
||||
|
||||
public String getServerId() {
|
||||
return getJSON().getString(SERVER_ID);
|
||||
}
|
||||
|
||||
public void setServerId(String serverId) {
|
||||
getJSON().put(SERVER_ID, serverId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import com.projectswg.common.network.packets.PacketType;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedBuildData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedServerData;
|
||||
import com.projectswg.lightspeed_frontend.data.SharedDeploymentData.DeploymentState;
|
||||
|
||||
public class ResponseDeploymentDetailedPacket extends ResponsePacket {
|
||||
|
||||
@@ -42,6 +43,7 @@ public class ResponseDeploymentDetailedPacket extends ResponsePacket {
|
||||
private static final String START_TIME = "start_time";
|
||||
private static final String END_TIME = "end_time";
|
||||
private static final String OUTPUT = "output";
|
||||
private static final String STATE = "state";
|
||||
|
||||
public ResponseDeploymentDetailedPacket(JSONObject json) {
|
||||
super(json, PacketType.RESPONSE_DEPLOYMENT_DETAILED);
|
||||
@@ -76,11 +78,16 @@ public class ResponseDeploymentDetailedPacket extends ResponsePacket {
|
||||
return getJSON().getString(OUTPUT);
|
||||
}
|
||||
|
||||
public DeploymentState getDeploymentState() {
|
||||
return DeploymentState.getState(getJSON().getString(STATE));
|
||||
}
|
||||
|
||||
public SharedDeploymentData getDeploymentData() {
|
||||
SharedDeploymentData deploymentData = new SharedDeploymentData(getDeploymentId(), new SharedBuildData(getBuildId(), new SharedServerData(getServerId())));
|
||||
deploymentData.setStartTime(getStartTime());
|
||||
deploymentData.setEndTime(getEndTime());
|
||||
deploymentData.setOutput(getOutput());
|
||||
deploymentData.setDeploymentState(getDeploymentState());
|
||||
return deploymentData;
|
||||
}
|
||||
|
||||
@@ -108,6 +115,10 @@ public class ResponseDeploymentDetailedPacket extends ResponsePacket {
|
||||
getJSON().put(OUTPUT, output);
|
||||
}
|
||||
|
||||
public void setDeploymentState(DeploymentState state) {
|
||||
getJSON().put(STATE, state.name());
|
||||
}
|
||||
|
||||
public void setDeploymentData(SharedDeploymentData deploymentData) {
|
||||
setServerId(deploymentData.getServer().getName());
|
||||
setBuildId(deploymentData.getBuild().getId());
|
||||
@@ -115,5 +126,6 @@ public class ResponseDeploymentDetailedPacket extends ResponsePacket {
|
||||
setStartTime(deploymentData.getStartTime());
|
||||
setEndTime(deploymentData.getEndTime());
|
||||
setOutput(deploymentData.getOutput());
|
||||
setDeploymentState(deploymentData.getDeploymentState());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,6 @@ import com.projectswg.common.debug.Log;
|
||||
import com.projectswg.common.intents.PrepareStarshipIntent;
|
||||
import com.projectswg.common.intents.RegisterHttpListenerIntent;
|
||||
import com.projectswg.common.network.packets.PacketType;
|
||||
import com.projectswg.common.network.packets.post.PostCreateServerPacket;
|
||||
import com.projectswg.common.network.packets.post.PostResult;
|
||||
import com.projectswg.common.network.packets.request.RequestServerDetailedPacket;
|
||||
import com.projectswg.common.network.packets.response.ResponseServerDetailedPacket;
|
||||
import com.projectswg.common.network.packets.response.ResponseServerListPacket;
|
||||
@@ -67,7 +65,6 @@ public class ServerService extends LightspeedService {
|
||||
for (ServerServerData server : servers) {
|
||||
server.setLastCommit("?");
|
||||
}
|
||||
new RegisterHttpListenerIntent(PacketType.POST_CREATE_SERVER, (type, params) -> onCreateServer(params)).broadcast();
|
||||
new RegisterHttpListenerIntent(PacketType.REQUEST_SERVER_LIST, (type, params) -> onRequestServerList(params)).broadcast();
|
||||
new RegisterHttpListenerIntent(PacketType.REQUEST_SERVER_DETAILED, (type, params) -> onRequestServerDetailed(params)).broadcast();
|
||||
return super.initialize();
|
||||
@@ -105,23 +102,6 @@ public class ServerService extends LightspeedService {
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject onCreateServer(JSONObject params) {
|
||||
PostCreateServerPacket create = new PostCreateServerPacket(params);
|
||||
synchronized (servers) {
|
||||
for (ServerServerData server : servers) {
|
||||
if (server.getName().equals(create.getServerId())) {
|
||||
return new PostResult(false).getJSON();
|
||||
}
|
||||
}
|
||||
ServerServerData server = new ServerServerData(create.getServerId());
|
||||
server.setDirectory(create.getDirectory());
|
||||
server.setJvmArguments(create.getJvmArguments());
|
||||
servers.add(server);
|
||||
getBackendData().insertServer(server);
|
||||
return new PostResult(true).getJSON();
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject onRequestServerList(JSONObject params) {
|
||||
synchronized (servers) {
|
||||
List<SharedServerData> serverList = new ArrayList<>(servers.size());
|
||||
|
||||
Reference in New Issue
Block a user