mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2025-01-05 18:37:48 +01:00
World gamerules etc. are now only updated on world load
This commit is contained in:
parent
e97c827ddc
commit
42c43c41b6
@ -127,6 +127,8 @@ public class WorldSystem extends JavaPlugin {
|
||||
20 * PluginConfig.getGCPeriod());
|
||||
}
|
||||
|
||||
|
||||
/* TODO better check this only on worldInitEvent
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
|
||||
for (World w : Bukkit.getWorlds()) {
|
||||
SystemWorld sw = SystemWorld.getSystemWorld(w.getName());
|
||||
@ -134,7 +136,7 @@ public class WorldSystem extends JavaPlugin {
|
||||
SettingsConfig.editWorld(w);
|
||||
|
||||
}
|
||||
}, 20, 20 * 10);
|
||||
}, 20, 20 * 10);*/
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
|
||||
for (World w : Bukkit.getWorlds()) {
|
||||
|
@ -3,6 +3,7 @@ package de.butzlabben.world.command;
|
||||
import de.butzlabben.world.command.commands.WSCommands;
|
||||
import de.butzlabben.world.command.commands.WorldAdministrateCommand;
|
||||
import de.butzlabben.world.command.commands.WorldSettingsCommands;
|
||||
import de.butzlabben.world.util.Worldutils;
|
||||
import de.butzlabben.world.wrapper.WorldTemplateProvider;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -77,8 +78,9 @@ public class CommandRegistry implements CommandExecutor {
|
||||
return settings.fireCommand(sender, command, label, args);
|
||||
case "reload":
|
||||
if(!sender.isOp()){
|
||||
sender.sendMessage("Reloaded Templates!");
|
||||
sender.sendMessage("Reloading Settings!");
|
||||
WorldTemplateProvider.getInstance().reload();
|
||||
Worldutils.reloadWorldSettings();
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
|
@ -17,6 +17,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
//maybe just merge this config with the WorldConfig
|
||||
public class SettingsConfig {
|
||||
|
||||
private static final HashMap<String, Long> borderSizes = new HashMap<>();
|
||||
@ -27,6 +28,8 @@ public class SettingsConfig {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
// TODO rebuild this, as it's inperformant and not very beautiful code..
|
||||
// only load once, and then reload the things from the disk on command
|
||||
public static void editWorld(World w) {
|
||||
YamlConfiguration cfg = getConfig();
|
||||
|
||||
|
@ -1,25 +1,22 @@
|
||||
package de.butzlabben.world.listener;
|
||||
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import de.butzlabben.world.config.SettingsConfig;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
public class WorldInitSkipSpawn implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void worldInit(WorldInitEvent e) {
|
||||
World world = e.getWorld();
|
||||
SystemWorld sw = SystemWorld.getSystemWorld(world.getName());
|
||||
if(sw == null)
|
||||
return;
|
||||
|
||||
SettingsConfig.editWorld(world);
|
||||
e.getWorld().setKeepSpawnInMemory(false);
|
||||
}
|
||||
|
||||
|
18
src/main/java/de/butzlabben/world/util/Worldutils.java
Normal file
18
src/main/java/de/butzlabben/world/util/Worldutils.java
Normal file
@ -0,0 +1,18 @@
|
||||
package de.butzlabben.world.util;
|
||||
|
||||
import de.butzlabben.world.config.SettingsConfig;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class Worldutils {
|
||||
|
||||
public static void reloadWorldSettings(){
|
||||
for (World w : Bukkit.getWorlds()) {
|
||||
SystemWorld sw = SystemWorld.getSystemWorld(w.getName());
|
||||
if (sw != null && sw.isLoaded())
|
||||
SettingsConfig.editWorld(w);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user