mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-08 11:41:28 +01:00
Fix for loading worlds.
This commit is contained in:
parent
d48b3fd4ee
commit
0d4441e233
@ -150,78 +150,81 @@ public class UltimateKits extends JavaPlugin {
|
|||||||
* Load configuration files into memory.
|
* Load configuration files into memory.
|
||||||
*/
|
*/
|
||||||
private void loadFromFile() {
|
private void loadFromFile() {
|
||||||
|
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||||
|
|
||||||
//Empty kits from manager.
|
//Empty kits from manager.
|
||||||
kitManager.clearKits();
|
kitManager.clearKits();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Register kit into KitManager from Configuration.
|
* Register kit into KitManager from Configuration.
|
||||||
*/
|
*/
|
||||||
for (String kitName : kitFile.getConfig().getConfigurationSection("Kits").getKeys(false)) {
|
for (String kitName : kitFile.getConfig().getConfigurationSection("Kits").getKeys(false)) {
|
||||||
try {
|
try {
|
||||||
int delay = kitFile.getConfig().getInt("Kits." + kitName + ".delay");
|
int delay = kitFile.getConfig().getInt("Kits." + kitName + ".delay");
|
||||||
String title = kitFile.getConfig().getString("Kits." + kitName + ".title");
|
String title = kitFile.getConfig().getString("Kits." + kitName + ".title");
|
||||||
String link = kitFile.getConfig().getString("Kits." + kitName + ".link");
|
String link = kitFile.getConfig().getString("Kits." + kitName + ".link");
|
||||||
Material material = kitFile.getConfig().contains("Kits." + kitName + ".displayItem") ? Material.valueOf(kitFile.getConfig().getString("Kits." + kitName + ".displayItem")) : null;
|
Material material = kitFile.getConfig().contains("Kits." + kitName + ".displayItem") ? Material.valueOf(kitFile.getConfig().getString("Kits." + kitName + ".displayItem")) : null;
|
||||||
boolean hidden = kitFile.getConfig().getBoolean("Kits." + kitName + ".hidden");
|
boolean hidden = kitFile.getConfig().getBoolean("Kits." + kitName + ".hidden");
|
||||||
double price = kitFile.getConfig().getDouble("Kits." + kitName + ".price");
|
double price = kitFile.getConfig().getDouble("Kits." + kitName + ".price");
|
||||||
List<String> strContents = kitFile.getConfig().getStringList("Kits." + kitName + ".items");
|
List<String> strContents = kitFile.getConfig().getStringList("Kits." + kitName + ".items");
|
||||||
String kitAnimation = kitFile.getConfig().getString("Kits." + kitName + ".animation", KitAnimation.NONE.name());
|
String kitAnimation = kitFile.getConfig().getString("Kits." + kitName + ".animation", KitAnimation.NONE.name());
|
||||||
|
|
||||||
List<KitItem> contents = new ArrayList<>();
|
List<KitItem> contents = new ArrayList<>();
|
||||||
|
|
||||||
for (String string : strContents) {
|
for (String string : strContents) {
|
||||||
contents.add(new KitItem(string));
|
contents.add(new KitItem(string));
|
||||||
|
}
|
||||||
|
|
||||||
|
Kit kit = new Kit(kitName, title, link, price, material, delay, hidden, contents, KitAnimation.valueOf(kitAnimation));
|
||||||
|
kitManager.addKit(kit);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
console.sendMessage(Methods.formatText("&cYour kit &4" + kitName + " &cis setup incorrectly."));
|
||||||
|
Debugger.runReport(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Kit kit = new Kit(kitName, title, link, price, material, delay, hidden, contents, KitAnimation.valueOf(kitAnimation));
|
|
||||||
kitManager.addKit(kit);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
console.sendMessage(Methods.formatText("&cYour kit &4" + kitName + " &cis setup incorrectly."));
|
|
||||||
Debugger.runReport(ex);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Register kit locations into KitManager from Configuration.
|
* Register kit locations into KitManager from Configuration.
|
||||||
*/
|
*/
|
||||||
if (dataFile.getConfig().contains("BlockData")) {
|
if (dataFile.getConfig().contains("BlockData")) {
|
||||||
for (String key : dataFile.getConfig().getConfigurationSection("BlockData").getKeys(false)) {
|
for (String key : dataFile.getConfig().getConfigurationSection("BlockData").getKeys(false)) {
|
||||||
Location location = Methods.unserializeLocation(key);
|
Location location = Methods.unserializeLocation(key);
|
||||||
Kit kit = kitManager.getKit(dataFile.getConfig().getString("BlockData." + key + ".kit"));
|
Kit kit = kitManager.getKit(dataFile.getConfig().getString("BlockData." + key + ".kit"));
|
||||||
KitType type = KitType.valueOf(dataFile.getConfig().getString("BlockData." + key + ".type", "PREVIEW"));
|
KitType type = KitType.valueOf(dataFile.getConfig().getString("BlockData." + key + ".type", "PREVIEW"));
|
||||||
boolean holograms = dataFile.getConfig().getBoolean("BlockData." + key + ".holograms");
|
boolean holograms = dataFile.getConfig().getBoolean("BlockData." + key + ".holograms");
|
||||||
boolean displayItems = dataFile.getConfig().getBoolean("BlockData." + key + ".displayItems");
|
boolean displayItems = dataFile.getConfig().getBoolean("BlockData." + key + ".displayItems");
|
||||||
boolean particles = dataFile.getConfig().getBoolean("BlockData." + key + ".particles");
|
boolean particles = dataFile.getConfig().getBoolean("BlockData." + key + ".particles");
|
||||||
boolean itemOverride = dataFile.getConfig().getBoolean("BlockData." + key + ".itemOverride");
|
boolean itemOverride = dataFile.getConfig().getBoolean("BlockData." + key + ".itemOverride");
|
||||||
|
|
||||||
if (kit == null) dataFile.getConfig().set("BlockData." + key, null);
|
if (kit == null) dataFile.getConfig().set("BlockData." + key, null);
|
||||||
else kitManager.addKitToLocation(kit, location, type, holograms, particles, displayItems, itemOverride);
|
else
|
||||||
|
kitManager.addKitToLocation(kit, location, type, holograms, particles, displayItems, itemOverride);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//Apply default keys.
|
//Apply default keys.
|
||||||
checkKeyDefaults();
|
checkKeyDefaults();
|
||||||
|
|
||||||
//Empty keys from manager.
|
//Empty keys from manager.
|
||||||
keyManager.clear();
|
keyManager.clear();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Register keys into KitManager from Configuration.
|
* Register keys into KitManager from Configuration.
|
||||||
*/
|
*/
|
||||||
if (keyFile.getConfig().contains("Keys")) {
|
if (keyFile.getConfig().contains("Keys")) {
|
||||||
for (String keyName : keyFile.getConfig().getConfigurationSection("Keys").getKeys(false)) {
|
for (String keyName : keyFile.getConfig().getConfigurationSection("Keys").getKeys(false)) {
|
||||||
int amt = keyFile.getConfig().getInt("Keys." + keyName + ".Item Amount");
|
int amt = keyFile.getConfig().getInt("Keys." + keyName + ".Item Amount");
|
||||||
int kitAmount = keyFile.getConfig().getInt("Keys." + keyName + ".Amount of kit received");
|
int kitAmount = keyFile.getConfig().getInt("Keys." + keyName + ".Amount of kit received");
|
||||||
|
|
||||||
Key key = new Key(keyName, amt, kitAmount);
|
Key key = new Key(keyName, amt, kitAmount);
|
||||||
keyManager.addKey(key);
|
keyManager.addKey(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (hologram != null)
|
if (hologram != null)
|
||||||
hologram.loadHolograms();
|
hologram.loadHolograms();
|
||||||
|
|
||||||
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerVersion getServerVersion() {
|
public ServerVersion getServerVersion() {
|
||||||
|
Loading…
Reference in New Issue
Block a user