2026-04-02 20:48:21 +00:00
|
|
|
package com.alttd.easter.config;
|
|
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2026-04-03 23:08:30 +00:00
|
|
|
import org.bukkit.Location;
|
|
|
|
|
import org.bukkit.World;
|
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
2026-04-02 20:48:21 +00:00
|
|
|
|
|
|
|
|
import java.io.File;
|
2026-04-03 23:08:30 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
2026-04-02 20:48:21 +00:00
|
|
|
|
|
|
|
|
@Slf4j public class Config extends AbstractConfig{
|
|
|
|
|
|
|
|
|
|
static Config config;
|
|
|
|
|
|
|
|
|
|
Config() {
|
|
|
|
|
super(
|
|
|
|
|
new File(File.separator
|
|
|
|
|
+ "mnt" + File.separator
|
|
|
|
|
+ "configs" + File.separator
|
|
|
|
|
+ "Easter"),
|
|
|
|
|
"config.yml");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void reload() {
|
|
|
|
|
log.info("Reloading config");
|
|
|
|
|
config = new Config();
|
|
|
|
|
config.readConfig(Config.class, null);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-03 23:08:30 +00:00
|
|
|
public static class EGGS {
|
|
|
|
|
private static final String prefix = "eggs.";
|
|
|
|
|
public static double SPAWN_CHANCE = 0.02; // ~2 per night per player
|
2026-04-02 20:48:21 +00:00
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
private static void load() {
|
2026-04-03 23:08:30 +00:00
|
|
|
SPAWN_CHANCE = config.getDouble(prefix, "spawn-chance", SPAWN_CHANCE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class RABBIT {
|
|
|
|
|
private static final String prefix = "rabbit.";
|
|
|
|
|
public static String WORLD = "world";
|
|
|
|
|
public static double X = 0, Y = 64, Z = 0;
|
|
|
|
|
public static float YAW = 0, PITCH = 0;
|
|
|
|
|
public static double INTERACT_RADIUS = 2.5;
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
private static void load() {
|
|
|
|
|
WORLD = config.getString(prefix, "world", WORLD);
|
|
|
|
|
X = config.getDouble(prefix, "x", X);
|
|
|
|
|
Y = config.getDouble(prefix, "y", Y);
|
|
|
|
|
Z = config.getDouble(prefix, "z", Z);
|
|
|
|
|
YAW = (float) config.getDouble(prefix, "yaw", YAW);
|
|
|
|
|
PITCH = (float) config.getDouble(prefix, "pitch", PITCH);
|
|
|
|
|
INTERACT_RADIUS = config.getDouble(prefix, "interact-radius", INTERACT_RADIUS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Location getLocation(org.bukkit.Server server) {
|
|
|
|
|
World world = server.getWorld(WORLD);
|
|
|
|
|
if (world == null) return null;
|
|
|
|
|
return new Location(world, X, Y, Z, YAW, PITCH);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class PRIZES {
|
|
|
|
|
private static final String prefix = "prizes.";
|
|
|
|
|
public static List<ItemStack> LIST = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
private static void load() {
|
|
|
|
|
List<?> raw = config.yaml.getList(prefix + "list");
|
|
|
|
|
LIST = new ArrayList<>();
|
|
|
|
|
if (raw != null) {
|
|
|
|
|
for (Object o : raw) {
|
|
|
|
|
if (o instanceof ItemStack item) LIST.add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// ensure path exists
|
|
|
|
|
config.yaml.addDefault(prefix + "list", LIST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void addPrize(ItemStack item) {
|
|
|
|
|
LIST.add(item);
|
|
|
|
|
config.set(prefix, "list", LIST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ItemStack getRandomPrize() {
|
|
|
|
|
if (LIST.isEmpty()) return null;
|
|
|
|
|
return LIST.get((int) (Math.random() * LIST.size())).clone();
|
2026-04-02 20:48:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|