Skip to content

Commit

Permalink
Fix for loading plot world as default world
Browse files Browse the repository at this point in the history
  • Loading branch information
tim03we committed Aug 11, 2022
1 parent 79efe44 commit d2466c0
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>tim03we.futureplots</groupId>
<artifactId>FuturePlots</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.0.3.2-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>tim03we.futureplots</groupId>
<artifactId>FuturePlots</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.0.3.2-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/tim03we/futureplots/FuturePlots.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public void onLoad() {
providerClass.put("mysql", MySQLProvider.class);
providerClass.put("sqlite", SQLiteProvider.class);
registerGenerator();

File folder = new File(FuturePlots.getInstance().getDataFolder() + "/worlds/");
for(File file : folder.listFiles()) {
Settings.levels.add(file.getName().replace(".yml", ""));
}
loadWorldsSettings();
}

@Override
Expand Down Expand Up @@ -200,11 +206,16 @@ private void registerGenerator() {

private void loadWorlds() {
for (String world : Settings.levels) {
new PlotSettings(world);
getServer().loadLevel(world);
}
}

private void loadWorldsSettings() {
for (String world : Settings.levels) {
new PlotSettings(world);
}
}

public void generateLevel(String levelName) {
Settings.levels.add(levelName);
new PlotSettings(levelName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import cn.nukkit.level.generator.Generator;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
import cn.nukkit.utils.Config;
import tim03we.futureplots.utils.PlotSettings;
import tim03we.futureplots.utils.Settings;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -65,6 +67,9 @@ public PlotGenerator(Map<String, Object> options) {
groundHeight = PlotSettings.getGroundHeight(levelName);
} catch (ArrayIndexOutOfBoundsException | NullPointerException | NumberFormatException e) {
Server.getInstance().getLogger().critical("Your world configuration " + options.get("preset") + ".yml is incorrect, check it or the server will not start properly. An example of the config, if it does not match your previous one, can be found at \"https://github.com/tim03we/FuturePlots/wiki/World-Config-Example\".");
if(Settings.debug) {
e.printStackTrace();
}
Server.getInstance().shutdown();
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/tim03we/futureplots/utils/PlotSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class PlotSettings {
private String levelName;

public PlotSettings(String levelName) {
Server.getInstance().getLogger().info("Setting up " + levelName + "..");
this.levelName = levelName;
Config config = new Config(FuturePlots.getInstance().getDataFolder() + "/worlds/" + levelName + ".yml", Config.YAML);

Expand Down Expand Up @@ -108,7 +109,7 @@ public PlotSettings(String levelName) {
config.save();
}

private Config getConfig() {
public Config getConfig() {
return new Config(FuturePlots.getInstance().getDataFolder() + "/worlds/" + levelName + ".yml", Config.YAML);
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/tim03we/futureplots/utils/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ public class Settings {
public static void init() {
Config config = FuturePlots.getInstance().getConfig();
File folder = new File(FuturePlots.getInstance().getDataFolder() + "/worlds/");
for(File file : folder.listFiles()) {

/*for(File file : folder.listFiles()) { // See onLoad()
levels.add(file.getName().replace(".yml", ""));
}
}*/
wallBlockClaimed = config.getString("default-settings.wall.claimed");
wallBlockUnClaimed = config.getString("default-settings.wall.unclaimed");
roadBlock = config.getString("default-settings.roadBlock");
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/nukkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: FuturePlots
main: tim03we.futureplots.FuturePlots
api: 1.0.9
author: tim03we
version: 2.0.3-SNAPSHOT
version: 2.0.3.2-SNAPSHOT
description: A NukkitX based plot plugin
softdepend:
- EconomyAPI
Expand Down
4 changes: 2 additions & 2 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Tue Aug 09 21:24:48 CEST 2022
version=2.0.3-SNAPSHOT
#Thu Aug 11 22:08:17 CEST 2022
version=2.0.3.2-SNAPSHOT
groupId=tim03we.futureplots
artifactId=FuturePlots

0 comments on commit d2466c0

Please sign in to comment.