mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-29 04:18:07 +01:00
Fixing GUI icons for new ItemStack deserializator
This commit is contained in:
parent
70303080b6
commit
16a59470fc
@ -1170,8 +1170,10 @@ public class ConfigManager {
|
||||
};
|
||||
|
||||
CMIItemStack item = CMIItemStack.deserialize(guiSection.getString("ItemStack"), ahead);
|
||||
if (!ahead.isAsyncHead() && item != null && item.getCMIType().isNone())
|
||||
|
||||
if (!ahead.isAsyncHead() && item != null && !item.getCMIType().isNone()) {
|
||||
gItem.setGuiItem(item.getItemStack());
|
||||
}
|
||||
|
||||
} else if (guiSection.isString("Item")) {
|
||||
String item = guiSection.getString("Item");
|
||||
@ -1212,45 +1214,49 @@ public class ConfigManager {
|
||||
CMIMessages.consoleMessage("&5Update " + jobConfigName + " jobs gui item section to use `ItemStack` instead of `Item` sections format. More information inside _EXAMPLE job file");
|
||||
informedGUI = true;
|
||||
}
|
||||
|
||||
gItem.setGuiItem(guiItem);
|
||||
} else if (guiSection.isInt("Id") && guiSection.isInt("Data")) {
|
||||
guiItem = CMIMaterial.get(guiSection.getInt("Id"), guiSection.getInt("Data")).newItemStack();
|
||||
guiItem = CMIMaterial.get(guiSection.getInt("Id"), guiSection.getInt("Data")).newItemStack();
|
||||
gItem.setGuiItem(guiItem);
|
||||
CMIMessages.consoleMessage("Update " + jobConfigName + " jobs gui item section to use `Item` instead of `Id` and `Data` sections");
|
||||
} else
|
||||
log.warning("Job " + jobConfigName + " has an invalid (" + guiSection.getString("Item") + ") Gui property. Please fix this if you want to use it!");
|
||||
|
||||
for (String str4 : guiSection.getStringList("Enchantments")) {
|
||||
String[] id = str4.split(":", 2);
|
||||
if (guiSection.isList("Enchantments")) {
|
||||
for (String str4 : guiSection.getStringList("Enchantments")) {
|
||||
String[] id = str4.split(":", 2);
|
||||
|
||||
if (id.length < 2)
|
||||
continue;
|
||||
if (id.length < 2)
|
||||
continue;
|
||||
|
||||
Enchantment enchant = CMIEnchantment.getEnchantment(id[0]);
|
||||
if (enchant == null)
|
||||
continue;
|
||||
Enchantment enchant = CMIEnchantment.getEnchantment(id[0]);
|
||||
if (enchant == null)
|
||||
continue;
|
||||
|
||||
int level = 1;
|
||||
try {
|
||||
level = Integer.parseInt(id[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
int level = 1;
|
||||
try {
|
||||
level = Integer.parseInt(id[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
}
|
||||
|
||||
if (guiItem.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) guiItem.getItemMeta();
|
||||
enchantMeta.addStoredEnchant(enchant, level, true);
|
||||
guiItem.setItemMeta(enchantMeta);
|
||||
} else
|
||||
guiItem.addUnsafeEnchantment(enchant, level);
|
||||
}
|
||||
|
||||
if (guiItem.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) guiItem.getItemMeta();
|
||||
enchantMeta.addStoredEnchant(enchant, level, true);
|
||||
guiItem.setItemMeta(enchantMeta);
|
||||
} else
|
||||
guiItem.addUnsafeEnchantment(enchant, level);
|
||||
gItem.setGuiItem(guiItem);
|
||||
}
|
||||
|
||||
String customSkull = guiSection.getString("CustomSkull", "");
|
||||
if (!customSkull.isEmpty()) {
|
||||
guiItem = Util.getSkull(customSkull);
|
||||
gItem.setGuiItem(Util.getSkull(customSkull));
|
||||
}
|
||||
gItem.setGuiSlot(guiSection.getInt("slot", -1));
|
||||
}
|
||||
|
||||
gItem.setGuiItem(guiItem);
|
||||
|
||||
job.setGuiItem(gItem);
|
||||
|
||||
// Permissions
|
||||
@ -1554,10 +1560,10 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
for (String key : typeSection.getKeys(false)) {
|
||||
|
||||
|
||||
if (key.equalsIgnoreCase("materials"))
|
||||
continue;
|
||||
|
||||
|
||||
ConfigurationSection section = typeSection.getConfigurationSection(key);
|
||||
if (section == null) {
|
||||
continue;
|
||||
|
@ -28,37 +28,38 @@ public class DatabaseSaveThread extends Thread {
|
||||
private int sleep;
|
||||
|
||||
public DatabaseSaveThread(int duration) {
|
||||
super("Jobs-DatabaseSaveTask");
|
||||
this.sleep = duration * 60000;
|
||||
super("Jobs-DatabaseSaveTask");
|
||||
this.sleep = duration * 60000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
CMIMessages.consoleMessage("&eStarted database save task.");
|
||||
CMIMessages.consoleMessage("&eStarted database save task.");
|
||||
|
||||
while (running) {
|
||||
try {
|
||||
sleep(sleep);
|
||||
} catch (InterruptedException e) {
|
||||
this.running = false;
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
Jobs.getPlayerManager().saveAll();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
CMIMessages.consoleMessage("&c[Jobs] Exception in DatabaseSaveTask, stopping auto save!");
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
while (running) {
|
||||
try {
|
||||
sleep(sleep);
|
||||
} catch (InterruptedException e) {
|
||||
this.running = false;
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
if (running)
|
||||
Jobs.getPlayerManager().saveAll();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
CMIMessages.consoleMessage("&c[Jobs] Exception in DatabaseSaveTask, stopping auto save!");
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
CMIMessages.consoleMessage("&eDatabase save task shutdown!");
|
||||
CMIMessages.consoleMessage("&eDatabase save task shutdown!");
|
||||
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
this.running = false;
|
||||
interrupt();
|
||||
this.running = false;
|
||||
interrupt();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user