live reloading

This commit is contained in:
dfsek
2020-11-27 15:53:52 -07:00
parent af6ba33921
commit 4b7b0ee7e9
3 changed files with 11 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ package com.dfsek.terra.command;
import com.dfsek.terra.TerraWorld;
import com.dfsek.terra.config.base.PluginConfig;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.registry.ConfigRegistry;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.polydev.gaea.command.Command;
@@ -30,6 +31,7 @@ public class ReloadCommand extends Command implements DebugCommand {
public boolean execute(@NotNull CommandSender sender, org.bukkit.command.@NotNull Command command, @NotNull String label, @NotNull String[] args) {
PluginConfig.load(getMain());
LangUtil.load(PluginConfig.getLanguage(), getMain()); // Load language.
ConfigRegistry.loadAll(getMain());
TerraWorld.invalidate();
LangUtil.send("command.reload", sender);
return true;

View File

@@ -1,8 +1,8 @@
package com.dfsek.terra.registry;
import com.dfsek.tectonic.exception.ConfigException;
import com.dfsek.terra.Terra;
import com.dfsek.terra.config.base.ConfigPack;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
@@ -26,7 +26,7 @@ public class ConfigRegistry extends TerraRegistry<ConfigPack> {
add(pack.getTemplate().getID(), pack);
}
public static void loadAll(Terra main) {
public static void loadAll(JavaPlugin main) {
File packsFolder = new File(main.getDataFolder(), "packs");
for(File dir : packsFolder.listFiles(File::isDirectory)) {
try {

View File

@@ -62,4 +62,11 @@ public abstract class TerraRegistry<T> implements TypeLoader<T> {
public Set<T> entries() {
return new HashSet<>(objects.values());
}
/**
* Clears all entries from the registry.
*/
public void clear() {
objects.clear();
}
}