Skip to content
This repository was archived by the owner on Jan 30, 2021. It is now read-only.

Commit 8cbe046

Browse files
author
ByteExceptionM
committed
Changed Instance method 'JsonParser#parse' to static method 'JsonParser.parseString / JsonParser.parseReader', removed GlowStone Support and other small changes
1 parent f0fc86b commit 8cbe046

10 files changed

Lines changed: 51 additions & 144 deletions

File tree

reformcloud-addons/reformcloud-addons-cloudflare/src/main/java/systems/reformcloud/CloudFlareUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.google.gson.JsonArray;
88
import com.google.gson.JsonObject;
9+
import com.google.gson.JsonParser;
910
import eu.byteexception.requestbuilder.RequestBuilder;
1011
import eu.byteexception.requestbuilder.method.RequestMethod;
1112
import eu.byteexception.requestbuilder.result.RequestResult;
@@ -397,7 +398,7 @@ private JsonObject convertInputStreamToJson(InputStream inputStream) {
397398
);
398399
}
399400

400-
return ReformCloudLibraryService.PARSER.parse(stringBuilder.substring(0)).getAsJsonObject();
401+
return JsonParser.parseString(stringBuilder.substring(0)).getAsJsonObject();
401402
}
402403

403404
public static CloudFlareUtil getInstance() {

reformcloud-global/reformcloud-client/src/main/java/systems/reformcloud/serverprocess/startup/CloudServerStartupHandler.java

Lines changed: 24 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -250,28 +250,6 @@ public void bootstrap0() {
250250
FileUtils.copyAllFiles(Paths.get("reformcloud/default/servers"), path + StringUtil.EMPTY);
251251

252252
this.processStartupStage = ProcessStartupStage.PREPARING;
253-
if (this.serverStartupInfo.getServerGroup().getSpigotVersions()
254-
.equals(SpigotVersions.GLOWSTONE_1_7_9)
255-
|| this.serverStartupInfo.getServerGroup().getSpigotVersions()
256-
.equals(SpigotVersions.GLOWSTONE_1_8_9)
257-
|| this.serverStartupInfo.getServerGroup().getSpigotVersions()
258-
.equals(SpigotVersions.GLOWSTONE_1_9_4)
259-
|| this.serverStartupInfo.getServerGroup().getSpigotVersions()
260-
.equals(SpigotVersions.GLOWSTONE_1_10_2)
261-
|| this.serverStartupInfo.getServerGroup().getSpigotVersions()
262-
.equals(SpigotVersions.GLOWSTONE_1_11_2)
263-
|| this.serverStartupInfo.getServerGroup().getSpigotVersions()
264-
.equals(SpigotVersions.GLOWSTONE_1_12_2))
265-
{
266-
267-
if (!Files.exists(Paths.get(path + "/config"))) {
268-
FileUtils.createDirectory(Paths.get(path + "/config"));
269-
}
270-
if (!Files.exists(Paths.get(path + "/config/glowstone.yml"))) {
271-
FileUtils.copyCompiledFile("reformcloud/glowstone/glowstone.yml",
272-
path + "/config/glowstone.yml");
273-
}
274-
} else {
275253
if (!Files.exists(Paths.get(path + "/spigot.yml"))) {
276254
FileUtils
277255
.copyCompiledFile("reformcloud/spigot/spigot.yml", path + "/spigot.yml");
@@ -281,93 +259,36 @@ public void bootstrap0() {
281259
FileUtils.copyCompiledFile("reformcloud/default/server.properties",
282260
path + "/server.properties");
283261
}
284-
}
285262

286263
Properties properties = new Properties();
287-
if (this.serverStartupInfo.getServerGroup().getSpigotVersions()
288-
.equals(SpigotVersions.GLOWSTONE_1_7_9)
289-
|| this.serverStartupInfo.getServerGroup().getSpigotVersions()
290-
.equals(SpigotVersions.GLOWSTONE_1_8_9)
291-
|| this.serverStartupInfo.getServerGroup().getSpigotVersions()
292-
.equals(SpigotVersions.GLOWSTONE_1_9_4)
293-
|| this.serverStartupInfo.getServerGroup().getSpigotVersions()
294-
.equals(SpigotVersions.GLOWSTONE_1_10_2)
295-
|| this.serverStartupInfo.getServerGroup().getSpigotVersions()
296-
.equals(SpigotVersions.GLOWSTONE_1_11_2)
297-
|| this.serverStartupInfo.getServerGroup().getSpigotVersions()
298-
.equals(SpigotVersions.GLOWSTONE_1_12_2)) {
299-
try (InputStreamReader inputStreamReader = new InputStreamReader(
300-
Files.newInputStream(Paths.get(path + "/config/glowstone.yml")),
301-
StandardCharsets.UTF_8)) {
302-
net.md_5.config.Configuration configuration = ConfigurationProvider
303-
.getProvider(YamlConfiguration.class).load(inputStreamReader);
304-
net.md_5.config.Configuration section = configuration.getSection("server");
305-
306-
section.set("ip",
307-
ReformCloudClient.getInstance().getCloudConfiguration().getStartIP());
308-
section.set("port", port);
309-
section.set("name", this.serverStartupInfo.getName());
310-
section.set("max-players", this.serverStartupInfo.getServerGroup().getMaxPlayers());
311-
section.set("motd", this.serverStartupInfo.getServerGroup().getMotd());
312-
section.set("log-file", "logs/latest.log");
313-
314-
configuration.set("server", section);
315-
configuration.set("console.use-jline", false);
316-
configuration.set("advanced.proxy-support", true);
317-
try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
318-
Files.newOutputStream(Paths.get(path +
319-
"/config/glowstone.yml")), StandardCharsets.UTF_8)) {
320-
ConfigurationProvider.getProvider(YamlConfiguration.class)
321-
.save(configuration, outputStreamWriter);
322-
}
323-
} catch (final IOException ex) {
324-
StringUtil.printError(ReformCloudClient.getInstance().getColouredConsoleProvider(),
325-
"Error while reading glowstone config", ex);
326-
return;
327-
}
328-
} else {
329-
try (InputStreamReader inputStreamReader = new InputStreamReader(
330-
Files.newInputStream(Paths.get(path + "/server.properties")))) {
331-
properties.load(inputStreamReader);
332-
} catch (final IOException ex) {
333-
StringUtil
334-
.printError(ReformCloudLibraryServiceProvider.getInstance().getColouredConsoleProvider(),
335-
"Could not load server.properties", ex);
336-
return;
337-
}
264+
try (InputStreamReader inputStreamReader = new InputStreamReader(
265+
Files.newInputStream(Paths.get(path + "/server.properties")))) {
266+
properties.load(inputStreamReader);
267+
} catch (final IOException ex) {
268+
StringUtil
269+
.printError(ReformCloudLibraryServiceProvider.getInstance().getColouredConsoleProvider(),
270+
"Could not load server.properties", ex);
271+
return;
338272
}
339273

340-
if (!this.serverStartupInfo.getServerGroup().getSpigotVersions()
341-
.equals(SpigotVersions.GLOWSTONE_1_7_9)
342-
|| !this.serverStartupInfo.getServerGroup().getSpigotVersions()
343-
.equals(SpigotVersions.GLOWSTONE_1_8_9)
344-
|| !this.serverStartupInfo.getServerGroup().getSpigotVersions()
345-
.equals(SpigotVersions.GLOWSTONE_1_9_4)
346-
|| !this.serverStartupInfo.getServerGroup().getSpigotVersions()
347-
.equals(SpigotVersions.GLOWSTONE_1_10_2)
348-
|| !this.serverStartupInfo.getServerGroup().getSpigotVersions()
349-
.equals(SpigotVersions.GLOWSTONE_1_11_2)
350-
|| !this.serverStartupInfo.getServerGroup().getSpigotVersions()
351-
.equals(SpigotVersions.GLOWSTONE_1_12_2)) {
352-
if (DefaultPropertiesManager.available && DefaultPropertiesManager.getInstance().isPresent()) {
353-
DefaultPropertiesManager.getInstance()
354-
.fill(this.serverStartupInfo.getServerGroup().getName(), properties);
355-
}
274+
if (DefaultPropertiesManager.available && DefaultPropertiesManager.getInstance().isPresent()) {
275+
DefaultPropertiesManager.getInstance()
276+
.fill(this.serverStartupInfo.getServerGroup().getName(), properties);
277+
}
356278

357-
properties.setProperty("server-ip",
358-
ReformCloudClient.getInstance().getCloudConfiguration().getStartIP());
359-
properties.setProperty("server-port", port + StringUtil.EMPTY);
360-
properties.setProperty("server-name", serverStartupInfo.getName());
361-
properties.setProperty("motd", serverStartupInfo.getServerGroup().getMotd());
279+
properties.setProperty("server-ip",
280+
ReformCloudClient.getInstance().getCloudConfiguration().getStartIP());
281+
properties.setProperty("server-port", port + StringUtil.EMPTY);
282+
properties.setProperty("server-name", serverStartupInfo.getName());
283+
properties.setProperty("motd", serverStartupInfo.getServerGroup().getMotd());
362284

363-
try (OutputStream outputStream = Files
364-
.newOutputStream(Paths.get(path + "/server.properties"))) {
365-
properties.store(outputStream, "");
366-
} catch (final IOException ex) {
367-
StringUtil.printError(ReformCloudClient.getInstance().getColouredConsoleProvider(),
368-
"Cannot store server.properties", ex);
369-
return;
370-
}
285+
try (OutputStream outputStream = Files
286+
.newOutputStream(Paths.get(path + "/server.properties"))) {
287+
properties.store(outputStream, "");
288+
} catch (final IOException ex) {
289+
StringUtil.printError(ReformCloudClient.getInstance().getColouredConsoleProvider(),
290+
"Cannot store server.properties", ex);
291+
return;
371292
}
372293

373294
if (!Files.exists(Paths.get(path + "/spigot.jar"))) {

reformcloud-global/reformcloud-controller/src/main/java/systems/reformcloud/database/player/mongo/PlayerMongoDatabase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package systems.reformcloud.database.player.mongo;
66

77
import com.google.gson.JsonElement;
8+
import com.google.gson.JsonParser;
89
import com.mongodb.client.MongoCollection;
910
import com.mongodb.client.MongoDatabase;
1011
import com.mongodb.client.model.Filters;
@@ -243,7 +244,7 @@ private OfflinePlayer convert(String json) {
243244
private Configuration convertToConfig(String json) {
244245
JsonElement jsonElement = null;
245246
try {
246-
jsonElement = ReformCloudLibraryService.PARSER.parse(json);
247+
jsonElement = JsonParser.parseString(json);
247248
} catch (final Throwable throwable) {
248249
MongoDatabaseManager.handleError(throwable);
249250
}

reformcloud-library/src/main/java/systems/reformcloud/ReformCloudLibraryService.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ public final class ReformCloudLibraryService {
8989
.registerTypeAdapterFactory(TypeAdapters.newTypeHierarchyFactory(Configuration.class, new ConfigurationAdapter()))
9090
.disableHtmlEscaping().create();
9191

92-
/**
93-
* The cloud creates json parser instance
94-
*/
95-
public static final JsonParser PARSER = new JsonParser();
96-
9792
/**
9893
* Netty booleans
9994
*/

reformcloud-library/src/main/java/systems/reformcloud/configurations/Configuration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.google.gson.JsonElement;
88
import com.google.gson.JsonObject;
9+
import com.google.gson.JsonParser;
910
import com.google.gson.reflect.TypeToken;
1011
import systems.reformcloud.ReformCloudLibraryService;
1112
import systems.reformcloud.ReformCloudLibraryServiceProvider;
@@ -55,7 +56,7 @@ public Configuration(JsonObject jsonObject) {
5556
public Configuration(Reader reader) {
5657
JsonElement jsonElement;
5758
try {
58-
jsonElement = ReformCloudLibraryService.PARSER.parse(reader);
59+
jsonElement = JsonParser.parseReader(reader);
5960
} catch (final Throwable throwable) {
6061
StringUtil.printError(
6162
ReformCloudLibraryServiceProvider.getInstance().getColouredConsoleProvider(),
@@ -316,7 +317,7 @@ public static Configuration parse(File path) {
316317
StandardCharsets.UTF_8);
317318
BufferedReader bufferedReader = new BufferedReader(reader)) {
318319
return new Configuration(
319-
ReformCloudLibraryService.PARSER.parse(bufferedReader).getAsJsonObject());
320+
JsonParser.parseReader(bufferedReader).getAsJsonObject());
320321
} catch (final IOException ex) {
321322
StringUtil
322323
.printError(ReformCloudLibraryServiceProvider.getInstance().getColouredConsoleProvider(),
@@ -354,7 +355,7 @@ public static Configuration parse(String path) {
354355
* @return A new configuration which contains the content of the string
355356
*/
356357
public static Configuration fromString(String in) {
357-
return new Configuration(ReformCloudLibraryService.PARSER.parse(in).getAsJsonObject());
358+
return new Configuration(JsonParser.parseString(in).getAsJsonObject());
358359
}
359360

360361
/**

reformcloud-library/src/main/java/systems/reformcloud/logging/ColouredConsoleProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package systems.reformcloud.logging;
66

77
import com.google.gson.JsonObject;
8+
import com.google.gson.JsonParser;
89
import com.google.gson.stream.JsonReader;
910
import eu.byteexception.requestbuilder.RequestBuilder;
1011
import eu.byteexception.requestbuilder.method.RequestMethod;
@@ -421,7 +422,7 @@ public String uploadLog(String input) {
421422
JsonObject jsonObject;
422423
try (JsonReader jsonReader =
423424
new JsonReader(new InputStreamReader(requestResult.getStream(StreamType.DEFAULT)))) {
424-
jsonObject = ReformCloudLibraryService.PARSER.parse(jsonReader).getAsJsonObject();
425+
jsonObject = JsonParser.parseReader(jsonReader).getAsJsonObject();
425426
}
426427

427428
if (jsonObject == null) {

reformcloud-library/src/main/java/systems/reformcloud/meta/proxy/versions/ProxyVersions.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
public enum ProxyVersions implements Serializable {
1717
WATERFALL("Waterfall",
18-
"https://dl.reformcloud.systems/mcversions/proxies/waterfall.jar"),
18+
"https://papermc.io/ci/job/Waterfall/lastSuccessfulBuild/artifact/Waterfall-Proxy/bootstrap/target/Waterfall.jar"),
1919
HEXACORD("HexaCord",
20-
"https://dl.reformcloud.systems/mcversions/proxies/hexacord-1.7.10-1.14.x.jar"),
20+
"https://github.com/HexagonMC/BungeeCord/releases/download/v246/BungeeCord.jar"),
2121
BUNGEECORD("BungeeCord",
22-
"https://dl.reformcloud.systems/mcversions/proxies/bungeecord.jar"),
22+
"https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.ja"),
2323
VELOCITY("Velocity",
24-
"https://dl.reformcloud.systems/mcversions/proxies/velocity.jar"),
24+
"https://ci.velocitypowered.com/job/velocity/lastSuccessfulBuild/artifact/proxy/build/libs/velocity-proxy-1.0.4-SNAPSHOT-all.jar"),
2525
TRAVERTINE("Travertine",
26-
"https://dl.reformcloud.systems/mcversions/proxies/travertine.jar");
26+
"https://papermc.io/ci/job/Travertine/lastSuccessfulBuild/artifact/Travertine-Proxy/bootstrap/target/Travertine.jar");
2727

2828
private static Map<String, ProxyVersions> PROVIDERS = new ConcurrentHashMap<>();
2929

reformcloud-library/src/main/java/systems/reformcloud/meta/server/versions/SpigotVersions.java

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,40 +141,25 @@ public enum SpigotVersions implements Serializable {
141141
* TorchSpigot Versions
142142
*/
143143
TORCH_1_8_8("Torch 1.8.8", "1.8.8",
144-
"https://archive.mcmirror.io/Torch/Torch-1.8.8-R0.1.3-RC4.jar"),
144+
"https://dl.reformcloud.systems/mcversions/torch/Torch-1.8.8.jar"),
145145
TORCH_1_9_4("Torch 1.9.4", "1.9.4",
146-
"https://archive.mcmirror.io/Torch/Torch-1.9.4-R2.0-Light-RELEASE.jar"), // Will be changed later.
146+
"https://dl.reformcloud.systems/mcversions/torch/Torch-1.9.4.jar"),
147147
TORCH_1_11_2("Torch 1.11.2", "1.11.2",
148-
"https://archive.mcmirror.io/Torch/Torchpowered-latest.jar"),
148+
"https://dl.reformcloud.systems/mcversions/torch/Torch-1.11.2.jar"),
149149
/**
150150
* Hose Versions
151151
*/
152152
HOSE_1_8_8("Hose 1.8.8", "1.8.8",
153-
"https://archive.mcmirror.io/HOSE/hose-1.8.8.jar"),
153+
"https://dl.reformcloud.systems/mcversions/hose/hose-1.8.8.jar"),
154154
HOSE_1_9_4("Hose 1.9.4", "1.9.4",
155-
"https://archive.mcmirror.io/HOSE/hose-1.9.4.jar"), // Will be changeed later.
155+
"https://dl.reformcloud.systems/mcversions/hose/hose-1.9.4.jar"),
156156
HOSE_1_10_2("Hose 1.10.2", "1.10.2",
157-
"https://archive.mcmirror.io/HOSE/hose-1.10.2.jar"),
157+
"https://dl.reformcloud.systems/mcversions/hose/hose-1.10.2.jar"),
158158
/**
159159
* Akarin Versions
160160
*/
161161
AKARIN_1_12_2("Akarin 1.12.2", "1.12.2",
162-
"https://github.com/Akarin-project/Akarin/releases/download/1.12.2-R0.4.2/akarin-1.12.2.jar"), // Will bed changed later
163-
/**
164-
* GlowStone Versions
165-
*/
166-
GLOWSTONE_1_7_9("Glowstone 1.7.9", "1.7.9",
167-
"https://archive.mcmirror.io/GlowStone/glowstone-1.7.9-SNAPSHOT.jar"),
168-
GLOWSTONE_1_8_9("Glowstone 1.8.9", "1.8.9",
169-
"https://archive.mcmirror.io/GlowStone/glowstone-1.8.9-SNAPSHOT.jar"),
170-
GLOWSTONE_1_9_4("Glowstone 1.9.4", "1.9.4",
171-
"https://archive.mcmirror.io/GlowStone/glowstone-1.9.4-SNAPSHOT.jar"),
172-
GLOWSTONE_1_10_2("Glowstone 1.10.2", "1.10.2", // Will be changed later
173-
"https://archive.mcmirror.io/GlowStone/glowstone-1.10.2-SNAPSHOT.jar"),
174-
GLOWSTONE_1_11_2("Glowstone 1.11.2", "1.11.2",
175-
"https://archive.mcmirror.io/GlowStone/glowstone-1.11.2-SNAPSHOT.jar"),
176-
GLOWSTONE_1_12_2("Glowstone 1.12.2", "1.12.2",
177-
"https://github.com/GlowstoneMC/Glowstone/releases/download/2018.0.1/glowstone.jar");
162+
"https://github.com/Akarin-project/Akarin/releases/download/1.12.2-R0.4.2/akarin-1.12.2.jar");
178163

179164
private static final Map<String, SpigotVersions> PROVIDERS = new ConcurrentHashMap<>();
180165
public static final Deque<String> AVAILABLE_VERSIONS = new ConcurrentLinkedDeque<>();

reformcloud-library/src/main/java/systems/reformcloud/utility/uuid/UUIDConverter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.UUID;
1212
import java.util.regex.Pattern;
1313

14+
import com.google.gson.JsonParser;
1415
import eu.byteexception.requestbuilder.RequestBuilder;
1516
import eu.byteexception.requestbuilder.method.RequestMethod;
1617
import eu.byteexception.requestbuilder.result.RequestResult;
@@ -74,7 +75,7 @@ public static UUID getUUIDFromName(final String name) {
7475
.enableOutput()
7576
.fireAndForget();
7677

77-
final JsonObject jsonObject = ReformCloudLibraryService.PARSER.parse(requestResult.getResultAsString()).getAsJsonObject();
78+
final JsonObject jsonObject = JsonParser.parseString(requestResult.getResultAsString()).getAsJsonObject();
7879

7980
if (jsonObject.get("status").getAsString().equals("OK")) {
8081
final StringBuilder stringBuilder = new StringBuilder();
@@ -116,7 +117,7 @@ public static String getNameFromUUID(final UUID uuid) {
116117
.enableOutput()
117118
.fireAndForget();
118119

119-
final JsonObject jsonObject = ReformCloudLibraryService.PARSER.parse(requestResult.getResultAsString()).getAsJsonObject();
120+
final JsonObject jsonObject = JsonParser.parseString(requestResult.getResultAsString()).getAsJsonObject();
120121

121122
if (jsonObject.get("status").getAsString().equals("OK")) {
122123
final String name = jsonObject.get("name").getAsString();

reformcloud-library/src/main/java/systems/reformcloud/versioneering/VersionLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package systems.reformcloud.versioneering;
66

7+
import com.google.gson.JsonParser;
78
import com.google.gson.stream.JsonReader;
89
import eu.byteexception.requestbuilder.RequestBuilder;
910
import eu.byteexception.requestbuilder.result.RequestResult;
@@ -42,7 +43,7 @@ static String getNewestVersion() {
4243

4344
try (JsonReader jsonReader = new JsonReader(
4445
new InputStreamReader(requestResult.getStream(StreamType.DEFAULT), StandardCharsets.UTF_8))) {
45-
version = ReformCloudLibraryService.PARSER.parse(jsonReader).getAsJsonObject()
46+
version = JsonParser.parseReader(jsonReader).getAsJsonObject()
4647
.get("version").getAsString();
4748
}
4849

0 commit comments

Comments
 (0)