mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-05 07:16:10 +00:00
live reloading
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user