Skip to content

Commit 406f1b5

Browse files
committed
Finished update 2.4.40; ready for release
1 parent 5672bba commit 406f1b5

24 files changed

Lines changed: 139 additions & 204 deletions

build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
val plugingroup = "de.cycodly"
2-
val pluginname = "WorldSystemUpdated"
2+
val pluginname = "WorldSystem"
33
val pluginauthors = "[Butzlabben, Trainerlord, Cycodly]"
4-
val pluginversion = "2.4.40-dev"
4+
val pluginversion = "2.4.40"
55
val plugindescription = "Worldsystem - Let players create thier own worlds"
66
val pluginapiversion = "1.16"
77
val pluginminecraft = "1.21.4"
@@ -30,6 +30,7 @@ repositories {
3030
mavenCentral()
3131
maven("https://jitpack.io")
3232
maven("https://repo.extendedclip.com/releases/")
33+
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
3334
maven("https://maven.enginehub.org/repo/")
3435
maven("https://repo.codemc.io/repository/maven-public/")
3536
}

src/main/java/de/cycodly/worldsystem/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# Oh, hello fellow viewer ... or programmer?
22
Here you can find different program modules.
3+
4+
Always use this to send a (debug) message to the console:
5+
```java
6+
WorldSystem.logger().log(Level.INFO,"Debug message");
7+
```
38

49
---
510

611
- [WorldSystem.java](WorldSystem.java) represents the Main file. Here the plugin get's the start and stop information.
712
- [WorldCheckerRunnable.java](WorldCheckerRunnable.java) Checks if the world folder is in good condition
8-
- [GCRunnable.java](GCRunnable.java) Adds a Thread to run different things
13+
- [GCRunnable.java](GCRunnable.java) Adds a Thread to run different processes
914
- [wrapper](wrapper)
1015
- [AsyncCreatorAdapter.java](wrapper/AsyncCreatorAdapter.java) Option to load the minecraft worlds async
1116
- [GeneratorSettings.java](wrapper/GeneratorSettings.java)

src/main/java/de/cycodly/worldsystem/WorldSystem.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.bukkit.plugin.java.JavaPlugin;
1313
import org.bukkit.scheduler.BukkitRunnable;
1414
import org.bstats.bukkit.Metrics;
15+
import org.bstats.charts.SingleLineChart;
1516

1617
import de.cycodly.worldsystem.commands.CommandRegistry;
1718
import de.cycodly.worldsystem.config.DependenceConfig;
@@ -54,29 +55,29 @@ public static void createConfigs() {
5455
// Create directories
5556
File sources = new File(folder + "/worldsources");
5657
File languages = new File(folder + "/languages");
57-
58+
5859
if (!sources.exists()) {
5960
sources.mkdirs();
6061
}
6162
if (!languages.exists()) {
6263
languages.mkdirs();
63-
}
64-
64+
}
6565
// Create files
6666
File guiYML = new File(folder, "gui.yml");
6767
File configYML = new File(folder, "config.yml");
6868
File dependenceYML = new File(folder, "dependence.yml");
69-
String[] langYML = { "en", "de", "hu", "nl", "pl", "es", "ru", "fi", "ja", "zh", "fr", PluginConfig.getLanguage() };
7069

70+
//Important: initialize config builders first before usage (or "FILE" will be null)
7171
PluginConfig.checkConfig(configYML);
7272
GuiConfig.checkConfig(guiYML);
7373
SettingsConfig.checkConfig();
7474
YamlConfiguration confg = YamlConfiguration.loadConfiguration(configYML);
7575

76+
String[] langYML = { "en", "de", "hu", "nl", "pl", "es", "ru", "fi", "ja", "zh", "fr", PluginConfig.getLanguage() };
7677
for (String lang : langYML) {
7778
MessageConfig.checkConfig(new File(languages, lang + ".yml"));
7879
}
79-
80+
8081
if (!dependenceYML.exists()) {
8182
try {
8283
dependenceYML.createNewFile();
@@ -149,7 +150,7 @@ public void onEnable() {
149150

150151
// System.setProperty("bstats.relocatecheck", "false");
151152
Metrics metrics = new Metrics(this, BSTATS_ID);
152-
// metrics.addCustomChart(new SingleLineChart("worlds", DependenceConfig::getHighestID));
153+
metrics.addCustomChart(new SingleLineChart("worlds", DependenceConfig::getHighestID));
153154

154155
if (Bukkit.getPluginManager().getPlugin("Chunky") != null && PluginConfig.loadWorldsASync()) {
155156

src/main/java/de/cycodly/worldsystem/commands/WSCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public boolean mainCommand(CommandSender sender, Command command, String label,
2828

2929
String prefix = PluginConfig.getPrefix();
3030
cs.sendMessage(
31-
prefix + "WorldSystem by CrazyCloudCraft v" + WorldSystem.getInstance().getDescription().getVersion());
32-
cs.sendMessage(prefix + "Contributors: Jubeki, montlikadani, jstoeckm2, Butzlabben");
31+
prefix + "WorldSystemUpdated v" + WorldSystem.getInstance().getDescription().getVersion());
32+
cs.sendMessage(prefix + "Authors: Cycodly, Trainerlord, Butzlabben");
3333
List<String> cmdHelp = MessageConfig.getCommandHelp();
3434
cmdHelp.forEach(s -> cs.sendMessage("§6" + s)); //(prefix + s));
3535
// cs.sendMessage(prefix + "==============");

src/main/java/de/cycodly/worldsystem/commands/WorldSettingsCommands.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,18 @@ public boolean setHomeCommand(CommandSender sender, Command command, String labe
136136
return false;
137137
}
138138

139-
WorldConfig config = WorldConfig.getWorldConfig(p.getWorld().getName());
140-
Location playerLocation = p.getLocation();
141-
config.home = new Location(
142-
playerLocation.getWorld(),
143-
playerLocation.getX(),
144-
playerLocation.getY(),
145-
playerLocation.getZ(),
146-
playerLocation.getYaw(),
147-
playerLocation.getPitch());
148-
WorldSystem.logger().log(Level.INFO, "installed");
149139
try {
150-
if (config.home == playerLocation) {
151-
WorldSystem.logger().log(Level.INFO, "registered");
140+
WorldConfig config = WorldConfig.getWorldConfig(p.getWorld().getName());
141+
Location playerLocation = p.getLocation();
142+
143+
// Save the home location
144+
config.home = playerLocation;
145+
146+
// Log the result
147+
if (config.home != null && config.home.equals(playerLocation)) {
148+
WorldSystem.logger().log(Level.INFO, "Home location registered successfully");
152149
} else {
153-
WorldSystem.logger().log(Level.INFO, "registered incorrectly");
150+
WorldSystem.logger().log(Level.INFO, "Home location registration failed");
154151
}
155152
config.save();
156153
p.sendMessage(MessageConfig.getHomeSet());

src/main/java/de/cycodly/worldsystem/config/GuiConfig.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,26 @@
2424

2525
public class GuiConfig {
2626

27-
private static File file;
27+
private static File FILE;
2828

2929
private GuiConfig() {
3030
}
3131

3232
public static void checkConfig(File f) {
33-
file = f;
34-
if (!file.exists()) {
33+
FILE = f;
34+
if (!FILE.exists()) {
3535
try {
3636
// Create parent directories if they don't exist
37-
if (!file.getParentFile().exists()) {
38-
file.getParentFile().mkdirs();
37+
if (!FILE.getParentFile().exists()) {
38+
FILE.getParentFile().mkdirs();
3939
}
4040
// Try to get the config from resources
4141
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource("gui.yml");
4242
if (in != null) {
43-
Files.copy(in, file.toPath());
43+
Files.copy(in, FILE.toPath());
4444
in.close();
4545
} else {
46-
WorldSystem.logger().log(Level.WARNING,
47-
"Could not find gui.yml in resources, creating default config");
46+
WorldSystem.logger().log(Level.WARNING, "Could not find gui.yml in resources, creating default config");
4847
// Create default GUI config
4948
YamlConfiguration config = new YamlConfiguration();
5049
config.set("options.enabled.material", "LIME_DYE");
@@ -58,7 +57,7 @@ public static void checkConfig(File f) {
5857
config.set("options.fill.material", "BLACK_STAINED_GLASS_PANE");
5958
config.set("options.fill.display", " ");
6059
config.set("options.players.playerhead.material", "PLAYER_HEAD");
61-
config.save(file);
60+
config.save(FILE);
6261
}
6362

6463
} catch (IOException e) {
@@ -80,7 +79,7 @@ public static void checkConfig(File f) {
8079
public static YamlConfiguration getConfig() {
8180
try {
8281
return YamlConfiguration
83-
.loadConfiguration(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
82+
.loadConfiguration(new InputStreamReader(new FileInputStream(FILE), StandardCharsets.UTF_8));
8483
} catch (FileNotFoundException e) {
8584
e.printStackTrace();
8685
}

src/main/java/de/cycodly/worldsystem/config/MessageConfig.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public class MessageConfig {
2323

2424
private static final List<String> defaultCmdHelp = new ArrayList<>(20);
25-
private static File file;
25+
private static File FILE;
2626

2727
static {
2828
defaultCmdHelp.add("/ws get §8- §7Will give you a World");
@@ -43,24 +43,24 @@ public class MessageConfig {
4343
private MessageConfig() {}
4444

4545
public static void checkConfig(File f) {
46-
file = f;
47-
if (!file.exists()) {
46+
FILE = f;
47+
if (!FILE.exists()) {
4848
try {
4949
// Create parent directories if they don't exist
50-
if (!file.getParentFile().exists()) {
51-
file.getParentFile().mkdirs();
50+
if (!FILE.getParentFile().exists()) {
51+
FILE.getParentFile().mkdirs();
5252
}
5353
// Try to get the language file from resources
5454
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource("languages/" + f.getName());
5555

5656
if (in != null) {
57-
Files.copy(in, file.toPath());
57+
Files.copy(in, FILE.toPath());
5858
in.close();
5959
} else {
6060
// If specific language file not found, try to use custom_messages template
6161
in = JavaPlugin.getPlugin(WorldSystem.class).getResource("custom_messages.yml");
6262
if (in != null) {
63-
Files.copy(in, file.toPath());
63+
Files.copy(in, FILE.toPath());
6464
in.close();
6565
} else {
6666
// Create default messages if no resource found
@@ -98,7 +98,7 @@ public static void checkConfig(File f) {
9898
config.set("request.confirm", "&cPlease confirm reset of your world: %command");
9999

100100
// Save the config
101-
config.save(file);
101+
config.save(FILE);
102102
}
103103
}
104104
} catch (IOException e) {
@@ -109,7 +109,7 @@ public static void checkConfig(File f) {
109109

110110
private static YamlConfiguration getConfig() {
111111
try {
112-
return YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
112+
return YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(FILE), StandardCharsets.UTF_8));
113113
} catch (FileNotFoundException e) {
114114
e.printStackTrace();
115115
}

src/main/java/de/cycodly/worldsystem/config/PluginConfig.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
public class PluginConfig {
2929

30-
private final static GameMode[] GAME_MODES = new GameMode[]{GameMode.SURVIVAL, GameMode.CREATIVE, GameMode.ADVENTURE, GameMode.SPECTATOR};
30+
private final static GameMode[] GAME_MODES = new GameMode[] {GameMode.SURVIVAL, GameMode.CREATIVE, GameMode.ADVENTURE, GameMode.SPECTATOR};
3131
private static File FILE;
3232

3333
private PluginConfig() {}
@@ -37,8 +37,8 @@ public static void checkConfig(File f) {
3737
if (FILE.exists()) {
3838
YamlConfiguration cfg = getConfig();
3939
if (!(cfg.isString("worldfolder") && cfg.isInt("unloadingtime")
40-
&& cfg.isBoolean("survival") && cfg.isString("language") && cfg.isString("prefix")
41-
&& cfg.isInt("request_expires") && cfg.isBoolean("need_confirm")
40+
&& cfg.isBoolean("survival") && cfg.isString("language") && cfg.isString("prefix") && cfg.isString("cmd_prefix")
41+
&& cfg.isInt("request_expires")
4242
&& cfg.isBoolean("contact_authserver") && cfg.isBoolean("spawn_teleportation")
4343
&& cfg.isInt("delete_after") && cfg.isBoolean("worldtemplates.multi_choose")
4444
&& cfg.isString("worldtemplates.default") && cfg.isBoolean("load_worlds_async") &&
@@ -73,7 +73,7 @@ public static void checkConfig(File f) {
7373
+ new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss").format(new Date()) + ".yml").toPath(),
7474
StandardCopyOption.REPLACE_EXISTING);
7575
Files.delete(FILE.toPath());
76-
WorldSystem.logger().log(Level.SEVERE,"[WorldSystem] Config is broken, creating a new one!");
76+
WorldSystem.logger().log(Level.SEVERE,"Config is broken, creating a new one!");
7777
checkConfig(f);
7878
} catch (IOException e) {
7979
e.printStackTrace();
@@ -87,18 +87,17 @@ public static void checkConfig(File f) {
8787
}
8888
// Try to get the config from resources
8989
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource("config.yml");
90-
if (in != null) {
91-
// Copy from resources
92-
Files.copy(in, FILE.toPath());
93-
in.close();
94-
} else {
90+
// Copy from resources
91+
Files.copy(in, FILE.toPath());
92+
in.close();
93+
if (in == null) {
9594
// Create a new config with default values if resource not found
9695
YamlConfiguration config = new YamlConfiguration();
9796
config.set("prefix", "&8[&3WorldSystem&8] &6");
98-
config.set("command_prefix", "realms");
97+
config.set("cmd_prefix", "ws");
9998
config.set("worldfolder", "plugins/WorldSystem/Worlds");
10099
config.set("language", "en");
101-
config.set("need_confirm", true);
100+
//config.set("need_confirm", true);
102101
config.set("contact_authserver", true);
103102
config.set("spawn.gamemode", 2);
104103
config.set("spawn.spawnpoint.use_last_location", false);
@@ -146,14 +145,13 @@ public static void checkConfig(File f) {
146145

147146
// Should fix #2
148147
if (getSpawn(null).getWorld() == null) {
149-
Bukkit.getConsoleSender().sendMessage(getPrefix() + "§cA lobby/hub spawn is missing. If this is not the first launch, add a spawn in config.yml");
148+
WorldSystem.logger().log(Level.SEVERE,"A lobby/hub spawn is missing. If this is not the first launch, add a spawn in config.yml");
150149
}
151150
}
152151

153152
public static YamlConfiguration getConfig() {
154153
try {
155-
return YamlConfiguration
156-
.loadConfiguration(new InputStreamReader(new FileInputStream(FILE), StandardCharsets.UTF_8));
154+
return YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(FILE), StandardCharsets.UTF_8));
157155
} catch (FileNotFoundException e) {
158156
e.printStackTrace();
159157
}

src/main/java/de/cycodly/worldsystem/config/SettingsConfig.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
public class SettingsConfig {
3030

3131
private static final HashMap<String, Long> BORDER_SIZES = new HashMap<>();
32-
33-
private static File file;
32+
private static File FILE;
3433

3534
private SettingsConfig() {
3635
}
@@ -169,27 +168,27 @@ public static void editWorld(World w) {
169168
private static YamlConfiguration getConfig() {
170169
try {
171170
return YamlConfiguration
172-
.loadConfiguration(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
171+
.loadConfiguration(new InputStreamReader(new FileInputStream(FILE), StandardCharsets.UTF_8));
173172
} catch (FileNotFoundException e) {
174173
e.printStackTrace();
175174
}
176175
return null;
177176
}
178177

179178
public static void checkConfig() {
180-
File file = new File(WorldSystem.getInstance().getDataFolder(), "settings.yml");
181-
SettingsConfig.file = file;
182-
if (!file.exists()) {
179+
File FILE = new File(WorldSystem.getInstance().getDataFolder(), "settings.yml");
180+
SettingsConfig.FILE = FILE;
181+
if (!FILE.exists()) {
183182
try {
184183
// Create parent directories if they don't exist
185-
if (!file.getParentFile().exists()) {
186-
file.getParentFile().mkdirs();
184+
if (!FILE.getParentFile().exists()) {
185+
FILE.getParentFile().mkdirs();
187186
}
188187

189188
// Try to get the config from resources
190189
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource("settings.yml");
191190
if (in != null) {
192-
Files.copy(in, file.toPath());
191+
Files.copy(in, FILE.toPath());
193192
in.close();
194193
} else {
195194
// Create default settings if resource not found
@@ -237,7 +236,7 @@ public static void checkConfig() {
237236
// Commands to execute when getting a world
238237
config.set("commands_on_get", new ArrayList<String>());
239238

240-
config.save(file);
239+
config.save(FILE);
241240
}
242241
} catch (IOException e) {
243242
WorldSystem.logger().log(Level.SEVERE, "Wasn't able to create settings.yml", e);

src/main/java/de/cycodly/worldsystem/util/VersionUtil.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,19 @@ public static int getVersion() {
4242

4343
// Iterate over the map to find a match
4444
for (Map.Entry<String, Integer> entry : VERSION_MAP.entrySet()) {
45-
if (detectedVersion.contains(entry.getKey())) {
45+
if (detectedVersion.startsWith(entry.getKey())) {
4646
version = entry.getValue();
4747
break;
4848
}
4949
}
5050

5151
// Handle unknown version
5252
if (version == 0) {
53-
WorldSystem.logger().log(Level.SEVERE, "[WorldSystem] Unknown version: " + detectedVersion);
54-
WorldSystem.logger().log(Level.SEVERE, "[WorldSystem] Defaulting to version 1.12.2");
53+
WorldSystem.logger().log(Level.SEVERE, "Unknown version: " + detectedVersion);
54+
WorldSystem.logger().log(Level.SEVERE, "Defaulting to version 1.12.2");
5555
version = 12;
56+
} else {
57+
WorldSystem.logger().log(Level.INFO, "Version "+ version +" detected: " + detectedVersion);
5658
}
5759
}
5860
return version;

0 commit comments

Comments
 (0)