Removed dead config files and entries
Added option for bungeecord return server
This commit is contained in:
parent
a00c1f174c
commit
4aa5c1e5ae
src/main/java/eu/mhsl/craftattack/worldmuseum
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"start_world": "world",
|
|
||||||
"bungeecord": false
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
package eu.mhsl.craftattack.worldmuseum.inventory;
|
package eu.mhsl.craftattack.worldmuseum.inventory;
|
||||||
|
|
||||||
import eu.mhsl.craftattack.worldmuseum.util.BunggeCordComunicator;
|
import eu.mhsl.craftattack.worldmuseum.util.BunggeCordComunicator;
|
||||||
|
import eu.mhsl.craftattack.worldmuseum.util.Config;
|
||||||
import eu.mhsl.craftattack.worldmuseum.util.MuseumPlayer;
|
import eu.mhsl.craftattack.worldmuseum.util.MuseumPlayer;
|
||||||
import eu.mhsl.craftattack.worldmuseum.worlds.World;
|
import eu.mhsl.craftattack.worldmuseum.worlds.World;
|
||||||
import eu.mhsl.craftattack.worldmuseum.worlds.WorldManager;
|
import eu.mhsl.craftattack.worldmuseum.worlds.WorldManager;
|
||||||
@ -49,7 +50,7 @@ public class WorldSelector extends Inventory {
|
|||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
player.startLoading();
|
player.startLoading();
|
||||||
|
|
||||||
BunggeCordComunicator.connect(player, "server");
|
BunggeCordComunicator.connect(player, Config.getInstance().getBungeeReturnServerName());
|
||||||
|
|
||||||
MinecraftServer.getSchedulerManager().scheduleTask(() -> {
|
MinecraftServer.getSchedulerManager().scheduleTask(() -> {
|
||||||
if(player.isOnline()) player.kick("Timeout beim Serverwechsel. Bitte joine dem Server erneut!");
|
if(player.isOnline()) player.kick("Timeout beim Serverwechsel. Bitte joine dem Server erneut!");
|
||||||
|
@ -2,8 +2,6 @@ package eu.mhsl.craftattack.worldmuseum.util;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import eu.mhsl.craftattack.worldmuseum.worlds.World;
|
|
||||||
import eu.mhsl.craftattack.worldmuseum.worlds.WorldManager;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@ -11,35 +9,31 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private static Config instance;
|
private static Config instance;
|
||||||
private World start_world;
|
|
||||||
private boolean bungeecordEnabled = false;
|
private boolean bungeecordEnabled = false;
|
||||||
|
private String bungeeReturnServerName;
|
||||||
public static Config getInstance() {
|
public static Config getInstance() {
|
||||||
if (instance == null) instance = new Config();
|
if (instance == null) instance = new Config();
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
public void loadConfig() {
|
public void loadConfig() {
|
||||||
checkConfig();
|
createDefaultIfNotExists();
|
||||||
try {
|
try {
|
||||||
JsonObject config = (JsonObject) JsonParser.parseReader(new FileReader("config.json"));
|
JsonObject config = (JsonObject) JsonParser.parseReader(new FileReader("config.json"));
|
||||||
for (World w : WorldManager.getInstance().getWorlds()) {
|
|
||||||
if (!w.getName().equals(config.get("start_world").getAsString())) continue;
|
|
||||||
this.start_world = w;
|
|
||||||
}
|
|
||||||
this.bungeecordEnabled = config.get("bungeecord").getAsBoolean();
|
this.bungeecordEnabled = config.get("bungeecord").getAsBoolean();
|
||||||
|
this.bungeeReturnServerName = config.get("bc-return-servername").getAsString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkConfig() {
|
private void createDefaultIfNotExists() {
|
||||||
try {
|
try {
|
||||||
File checkfile = new File("./config.json");
|
File checkfile = new File("./config.json");
|
||||||
if (checkfile.createNewFile()) {
|
if (checkfile.createNewFile()) {
|
||||||
FileWriter fileWriter = new FileWriter("config.json");
|
FileWriter fileWriter = new FileWriter("config.json");
|
||||||
String default_config = """
|
String default_config = """
|
||||||
{
|
{
|
||||||
"start_world": "world",
|
"bc-return-servername": "server",
|
||||||
"bungeecord": false
|
"bungeecord": false
|
||||||
}""";
|
}""";
|
||||||
fileWriter.write(default_config);
|
fileWriter.write(default_config);
|
||||||
@ -50,11 +44,11 @@ public class Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public World getStart_world() {
|
|
||||||
return start_world;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBungeecordEnabled() {
|
public boolean isBungeecordEnabled() {
|
||||||
return bungeecordEnabled;
|
return bungeecordEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBungeeReturnServerName() {
|
||||||
|
return bungeeReturnServerName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"enabled": false,
|
|
||||||
"name": "DEFAULT_NAME",
|
|
||||||
"material": "GRASS_BLOCK",
|
|
||||||
"spawn": {
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
"z": 0
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"RANDOM_TAG"
|
|
||||||
]
|
|
||||||
}
|
|
Reference in New Issue
Block a user