1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 23:13:48 +01:00

Update ConfigManager.java

This commit is contained in:
montlikadani 2018-10-08 16:46:52 +02:00 committed by GitHub
parent e764cdd436
commit fa0c45dc1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -551,10 +551,9 @@ public class ConfigManager {
ConfigurationSection guiSection = jobSection.getConfigurationSection("Gui"); ConfigurationSection guiSection = jobSection.getConfigurationSection("Gui");
if (guiSection.contains("Item") && guiSection.isString("Item")) { if (guiSection.contains("Item") && guiSection.isString("Item")) {
String item = guiSection.getString("Item"); String item = guiSection.getString("Item");
String type = null;
String subType = ""; String subType = "";
@SuppressWarnings("unused")
String meta = ""; String meta = "";
int id = 0;
if (item.contains("-")) { if (item.contains("-")) {
// uses subType // uses subType
@ -565,7 +564,8 @@ public class ConfigManager {
CMIMaterial material = CMIMaterial.get(item + (subType)); CMIMaterial material = CMIMaterial.get(item + (subType));
if (material == null) material = CMIMaterial.get(item.replace(" ", "_").toUpperCase()); if (material == null)
material = CMIMaterial.get(item.replace(" ", "_").toUpperCase());
if (material == null) { if (material == null) {
// try integer method // try integer method
@ -577,10 +577,8 @@ public class ConfigManager {
if (matId != null) { if (matId != null) {
material = CMIMaterial.get(matId); material = CMIMaterial.get(matId);
if (material != null) { if (material != null) {
Jobs.getPluginLogger() Jobs.getPluginLogger().warning("Job " + jobName + " is using GUI item ID: " + item + "!");
.warning("Job " + jobName + " is using GUI item ID: " + item + "!"); Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
Jobs.getPluginLogger()
.warning("Please use the Material name instead: " + material.toString() + "!");
} }
} }
} }
@ -591,39 +589,11 @@ public class ConfigManager {
for (String str4 : enchants) { for (String str4 : enchants) {
String[] enchantid = str4.split(":"); String[] enchantid = str4.split(":");
if ((GUIitem.getItemMeta() instanceof EnchantmentStorageMeta)) { if ((GUIitem.getItemMeta() instanceof EnchantmentStorageMeta)) {
EnchantmentStorageMeta enchantMeta = EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta();
(EnchantmentStorageMeta) GUIitem.getItemMeta(); enchantMeta.addStoredEnchant(Enchantment.getByName(enchantid[0]), Integer.parseInt(enchantid[1]), true);
enchantMeta.addStoredEnchant(
Enchantment.getByName(enchantid[0]), Integer.parseInt(enchantid[1]), true);
GUIitem.setItemMeta(enchantMeta); GUIitem.setItemMeta(enchantMeta);
} else { } else {
GUIitem.addUnsafeEnchantment( GUIitem.addUnsafeEnchantment(Enchantment.getByName(enchantid[0]), Integer.parseInt(enchantid[1]));
Enchantment.getByName(enchantid[0]), Integer.parseInt(enchantid[1]));
}
}
}
}
} else if (guiSection.contains("Id")
&& guiSection.contains("Data")
&& guiSection.isInt("Id")
&& guiSection.isInt("Data")) {
GUIitem =
CMIMaterial.get(guiSection.getInt("Id"), guiSection.getInt("Data")).newItemStack();
if (guiSection.contains("Enchantments")) {
List<String> enchants = guiSection.getStringList("Enchantments");
if (enchants.size() > 0) {
for (String str4 : enchants) {
String[] id = str4.split(":");
if ((GUIitem.getItemMeta() instanceof EnchantmentStorageMeta)) {
EnchantmentStorageMeta enchantMeta =
(EnchantmentStorageMeta) GUIitem.getItemMeta();
enchantMeta.addStoredEnchant(
Enchantment.getByName(id[0]), Integer.parseInt(id[1]), true);
GUIitem.setItemMeta(enchantMeta);
} else {
GUIitem.addUnsafeEnchantment(
Enchantment.getByName(id[0]), Integer.parseInt(id[1]));
}
} }
} }
} }
@ -637,14 +607,43 @@ public class ConfigManager {
skullMeta.setOwner(offPlayer.getName()); skullMeta.setOwner(offPlayer.getName());
} catch (Exception e) { } catch (Exception e) {
} }
} else skullMeta.setOwner(skullOwner); } else
skullMeta.setOwner(skullOwner);
GUIitem.setItemMeta(skullMeta); GUIitem.setItemMeta(skullMeta);
} else } else
Jobs.getPluginLogger() Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid Gui property. Please fix this if you want to use it!");
.warning( } else if (guiSection.contains("Id") && guiSection.contains("Data") && guiSection.isInt("Id") && guiSection.isInt("Data")) {
"Job " GUIitem = CMIMaterial.get(guiSection.getInt("Id"), guiSection.getInt("Data")).newItemStack();
+ jobKey if (guiSection.contains("Enchantments")) {
+ " has an invalid Gui property. Please fix this if you want to use it!"); List<String> enchants = guiSection.getStringList("Enchantments");
if (enchants.size() > 0) {
for (String str4 : enchants) {
String[] id = str4.split(":");
if ((GUIitem.getItemMeta() instanceof EnchantmentStorageMeta)) {
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta();
enchantMeta.addStoredEnchant(Enchantment.getByName(id[0]), Integer.parseInt(id[1]), true);
GUIitem.setItemMeta(enchantMeta);
} else {
GUIitem.addUnsafeEnchantment(Enchantment.getByName(id[0]), Integer.parseInt(id[1]));
}
}
}
} else if (guiSection.contains("CustomSkull")) {
String skullOwner = guiSection.getString("CustomSkull");
GUIitem = CMIMaterial.PLAYER_HEAD.newItemStack();
SkullMeta skullMeta = (SkullMeta) GUIitem.getItemMeta();
if (skullOwner.length() == 36) {
try {
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(UUID.fromString(skullOwner));
skullMeta.setOwner(offPlayer.getName());
} catch (Exception e) {
}
} else
skullMeta.setOwner(skullOwner);
GUIitem.setItemMeta(skullMeta);
} else
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid Gui property. Please fix this if you want to use it!");
}
} }
// Permissions // Permissions