Add map templates, multi-config system, &#rrggbb colors

- MapTemplate: Save/load structures via Bukkit Structure API (.nbt files)
- TemplateManager: Manage templates and presets
- MapBuilder: Build/clear map with generators, hooks, pallets, etc.
- SetupCommand: /dbdsetup wand/save/load/set/build for map editing
- MessagesConfig: All messages with &#rrggbb color support via MiniMessage
- SkillCheckConfig: Skill check colors, zones, rotation settings
- Update GameConfig with color codes
- ConfigManager: Load/save all 4 config files
- Update plugin.yml with dbdsetup command
- Add methods to Generator for template integration
This commit is contained in:
loki5512344 2026-05-31 21:05:25 +02:00
parent 362b791774
commit 2a2b9f4b5b
10 changed files with 951 additions and 1 deletions

View file

@ -0,0 +1,119 @@
package dev.loki.map;
import dev.loki.mdbd;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import java.io.File;
import java.io.FilenameFilter;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
public class TemplateManager {
private final mdbd plugin;
private final File templatesFolder;
private final Map<String, MapTemplate> templates;
private final Map<String, PresetMap> presets;
public TemplateManager(mdbd plugin) {
this.plugin = plugin;
this.templatesFolder = new File(plugin.getDataFolder(), "templates");
this.templates = new HashMap<>();
this.presets = new HashMap<>();
if (!templatesFolder.exists()) {
templatesFolder.mkdirs();
}
}
public void loadAllTemplates() {
templates.clear();
File[] files = templatesFolder.listFiles((dir, name) -> name.endsWith(".nbt"));
if (files == null) return;
for (File file : files) {
String name = file.getName().replace(".nbt", "");
MapTemplate template = new MapTemplate(name);
if (template.loadFromFile(file)) {
templates.put(name, template);
plugin.getLogger().info("Loaded template: " + name);
}
}
}
public MapTemplate getTemplate(String name) {
return templates.get(name);
}
public boolean hasTemplate(String name) {
return templates.containsKey(name);
}
public void saveTemplate(String name, Location corner1, Location corner2) {
MapTemplate template = new MapTemplate(name);
template.saveArea(corner1, corner2);
File file = new File(templatesFolder, name + ".nbt");
template.saveToFile(file);
templates.put(name, template);
plugin.getLogger().info("Saved template: " + name);
}
public Map<String, MapTemplate> getAllTemplates() {
return new HashMap<>(templates);
}
public void registerPreset(String name, PresetMap preset) {
presets.put(name, preset);
}
public PresetMap getPreset(String name) {
return presets.get(name);
}
public void loadDefaultPresets() {
// Generator presets (3x3x3 structure)
presets.put("generator_default", new PresetMap("generator_default",
"generator", new Location(null, 1, 0, 1)));
// Hook preset (2x3x2)
presets.put("hook_default", new PresetMap("hook_default",
"hook", new Location(null, 1, 0, 1)));
// Pallet preset (3x2x1)
presets.put("pallet_default", new PresetMap("pallet_default",
"pallet", new Location(null, 1, 0, 0)));
// Chest preset (1x1x1)
presets.put("chest_default", new PresetMap("chest_default",
"chest", new Location(null, 0, 0, 0)));
// Totem preset (1x2x1)
presets.put("totem_default", new PresetMap("totem_default",
"totem", new Location(null, 0, 0, 0)));
// Hatch preset (2x1x2)
presets.put("hatch_default", new PresetMap("hatch_default",
"hatch", new Location(null, 1, 0, 1)));
}
public boolean placeObject(String templateName, Location location) {
MapTemplate template = templates.get(templateName);
if (template == null || !template.isLoaded()) return false;
template.place(location, false);
return true;
}
public boolean placeObject(String templateName, Location location,
org.bukkit.block.structure.StructureRotation rotation) {
MapTemplate template = templates.get(templateName);
if (template == null || !template.isLoaded()) return false;
template.placeWithRotation(location, rotation,
org.bukkit.block.structure.Mirror.NONE);
return true;
}
public record PresetMap(String name, String templateName, Location offset) {}
}