Upload folder via GUI - src
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package dev.viper.eventengine.config;
|
||||
|
||||
import dev.viper.eventengine.EventEngine;
|
||||
import dev.viper.eventengine.util.ColorUtil;
|
||||
import dev.viper.eventengine.model.EventCategory;
|
||||
import dev.viper.eventengine.model.EventDefinition;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Liest den "event-overrides" Block aus config.yml und
|
||||
* überschreibt die Defaults eingebauter EventDefinitions.
|
||||
*/
|
||||
public class EventOverrideLoader {
|
||||
|
||||
private final EventEngine plugin;
|
||||
|
||||
public EventOverrideLoader(EventEngine plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void apply(EventDefinition def) {
|
||||
ConfigurationSection overrides = plugin.getConfigManager()
|
||||
.getMainConfig().getConfigurationSection("event-overrides");
|
||||
if (overrides == null) return;
|
||||
|
||||
ConfigurationSection sec = overrides.getConfigurationSection(def.getId());
|
||||
if (sec == null) return;
|
||||
|
||||
if (sec.contains("display-name")) def.setDisplayName(sec.getString("display-name"));
|
||||
if (sec.contains("description")) def.setDescription(sec.getString("description"));
|
||||
if (sec.contains("duration-seconds")) def.setDurationSeconds(sec.getInt("duration-seconds"));
|
||||
if (sec.contains("min-players")) def.setMinPlayers(sec.getInt("min-players"));
|
||||
if (sec.contains("max-players")) def.setMaxPlayers(sec.getInt("max-players"));
|
||||
if (sec.contains("announcement")) def.setAnnouncement(ColorUtil.color(sec.getString("announcement")));
|
||||
if (sec.contains("in-rotation")) def.setInRotation(sec.getBoolean("in-rotation"));
|
||||
if (sec.contains("weight")) def.setWeight(sec.getInt("weight"));
|
||||
if (sec.contains("start-commands")) def.setStartCommands(sec.getStringList("start-commands"));
|
||||
if (sec.contains("end-commands")) def.setEndCommands(sec.getStringList("end-commands"));
|
||||
if (sec.contains("rewards")) def.setRewards(sec.getStringList("rewards"));
|
||||
if (sec.contains("category")) {
|
||||
try { def.setCategory(EventCategory.valueOf(sec.getString("category").toUpperCase())); }
|
||||
catch (Exception ignored) {}
|
||||
}
|
||||
ConfigurationSection settings = sec.getConfigurationSection("settings");
|
||||
if (settings != null) {
|
||||
for (String key : settings.getKeys(false)) {
|
||||
def.setSetting(key, settings.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user