Initial commit
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
package com.alttd.config;
|
||||
|
||||
import com.alttd.objects.LoadedVillagers;
|
||||
import com.alttd.objects.VillagerType;
|
||||
import com.alttd.util.Logger;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VillagerConfig extends AbstractConfig {
|
||||
|
||||
static VillagerConfig config;
|
||||
static int version;
|
||||
|
||||
public VillagerConfig() {
|
||||
super("villagerConfig.yml");
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
config = new VillagerConfig();
|
||||
|
||||
version = config.getInt("config-version", 1);
|
||||
config.set("config-version", 1);
|
||||
|
||||
config.readConfig(VillagerConfig.class, null);
|
||||
}
|
||||
|
||||
private static void loadVillagers() {
|
||||
LoadedVillagers.clearLoadedVillagers();
|
||||
config.getConfigurationSection("").getKeys(false).forEach(key -> {
|
||||
VillagerType villagerType = VillagerType.getVillagerType(config.getString(key, ""));
|
||||
if (villagerType != null)
|
||||
LoadedVillagers.addLoadedVillager(UUID.fromString(key), villagerType);
|
||||
else
|
||||
Logger.warning("Invalid config entry %.", key);
|
||||
});
|
||||
}
|
||||
|
||||
public static void removeVillager(UUID uuid) {
|
||||
config.set(uuid.toString(), null);
|
||||
}
|
||||
|
||||
public static void addVillager(UUID uuid, VillagerType villagerType) {
|
||||
config.set(uuid.toString(), villagerType.getName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.alttd.config;
|
||||
|
||||
import com.alttd.VillagerUI;
|
||||
import com.alttd.objects.Price;
|
||||
import com.alttd.util.Logger;
|
||||
import com.alttd.util.Utilities;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
public class WorthConfig extends AbstractConfig {
|
||||
static WorthConfig config;
|
||||
static int version;
|
||||
|
||||
public WorthConfig() {
|
||||
super(new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "VillagerShopUI"), "worth.yml");
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
config = new WorthConfig();
|
||||
|
||||
version = config.getInt("config-version", 1);
|
||||
config.set("config-version", 1);
|
||||
|
||||
config.readConfig(WorthConfig.class, null);
|
||||
}
|
||||
|
||||
public static Object2ObjectOpenHashMap<Material, Price> prices = new Object2ObjectOpenHashMap<>();
|
||||
private static void loadWorth() { //TODO test after removing points
|
||||
prices.clear();
|
||||
ConfigurationSection worth = config.getConfigurationSection("worth");
|
||||
if (worth == null) {
|
||||
Logger.severe("No worth in worth.yml! Stopping VillagerUI.");
|
||||
VillagerUI.getInstance().getServer().getPluginManager().disablePlugin(VillagerUI.getInstance());
|
||||
return;
|
||||
}
|
||||
Set<String> materials = worth.getKeys(false);
|
||||
for (String key : materials) {
|
||||
if (key == null) {
|
||||
Logger.severe("Null key in worth.yml?");
|
||||
continue;
|
||||
}
|
||||
prices.put(Material.getMaterial(key), new Price(Utilities.round(worth.getDouble(key), 2)));
|
||||
}
|
||||
}
|
||||
|
||||
public static int POINT_MOD = 4;
|
||||
private static void loadOtherStuff() {
|
||||
POINT_MOD = config.getInt("point-mod", POINT_MOD);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user