mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-08-29 13:20:32 +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.TerraWorld;
|
||||||
import com.dfsek.terra.config.base.PluginConfig;
|
import com.dfsek.terra.config.base.PluginConfig;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
|
import com.dfsek.terra.registry.ConfigRegistry;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.polydev.gaea.command.Command;
|
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) {
|
public boolean execute(@NotNull CommandSender sender, org.bukkit.command.@NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
PluginConfig.load(getMain());
|
PluginConfig.load(getMain());
|
||||||
LangUtil.load(PluginConfig.getLanguage(), getMain()); // Load language.
|
LangUtil.load(PluginConfig.getLanguage(), getMain()); // Load language.
|
||||||
|
ConfigRegistry.loadAll(getMain());
|
||||||
TerraWorld.invalidate();
|
TerraWorld.invalidate();
|
||||||
LangUtil.send("command.reload", sender);
|
LangUtil.send("command.reload", sender);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.dfsek.terra.registry;
|
package com.dfsek.terra.registry;
|
||||||
|
|
||||||
import com.dfsek.tectonic.exception.ConfigException;
|
import com.dfsek.tectonic.exception.ConfigException;
|
||||||
import com.dfsek.terra.Terra;
|
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public class ConfigRegistry extends TerraRegistry<ConfigPack> {
|
|||||||
add(pack.getTemplate().getID(), pack);
|
add(pack.getTemplate().getID(), pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAll(Terra main) {
|
public static void loadAll(JavaPlugin main) {
|
||||||
File packsFolder = new File(main.getDataFolder(), "packs");
|
File packsFolder = new File(main.getDataFolder(), "packs");
|
||||||
for(File dir : packsFolder.listFiles(File::isDirectory)) {
|
for(File dir : packsFolder.listFiles(File::isDirectory)) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -62,4 +62,11 @@ public abstract class TerraRegistry<T> implements TypeLoader<T> {
|
|||||||
public Set<T> entries() {
|
public Set<T> entries() {
|
||||||
return new HashSet<>(objects.values());
|
return new HashSet<>(objects.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears all entries from the registry.
|
||||||
|
*/
|
||||||
|
public void clear() {
|
||||||
|
objects.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user