simple fix
This commit is contained in:
parent
07af2596d8
commit
bf8681a385
2 changed files with 10 additions and 12 deletions
|
@ -94,14 +94,14 @@ public class CustomItemEvents implements Listener {
|
||||||
|
|
||||||
ItemStack weapon = player.getInventory().getItemInMainHand();
|
ItemStack weapon = player.getInventory().getItemInMainHand();
|
||||||
ItemMeta weaponMeta = weapon.getItemMeta();
|
ItemMeta weaponMeta = weapon.getItemMeta();
|
||||||
PersistentDataContainer container = weaponMeta.getPersistentDataContainer();
|
if (weaponMeta != null) {
|
||||||
if (container != null) {
|
PersistentDataContainer container = weaponMeta.getPersistentDataContainer();
|
||||||
NamespacedKey ammocount = CustomItemManager.keys.get("Snow Gun.ammo");
|
NamespacedKey ammoKey = CustomItemManager.keys.get(name + ".ammo");
|
||||||
int ammo = container.get(ammocount, PersistentDataType.INTEGER);
|
int ammo = container.get(ammoKey, PersistentDataType.INTEGER);
|
||||||
container.set(ammocount, PersistentDataType.INTEGER, ammo - 1);
|
container.set(ammoKey, PersistentDataType.INTEGER, ammo - 1);
|
||||||
int maxload = container.get(CustomItemManager.keys.get("Snow Gun.maxload"), PersistentDataType.INTEGER);
|
int max = container.get(CustomItemManager.keys.get(name + ".maxload"), PersistentDataType.INTEGER);
|
||||||
weapon.setItemMeta(weaponMeta);
|
weapon.setItemMeta(weaponMeta);
|
||||||
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&6AK-47 ( " + (ammo - 1) + "/ " + maxload + " )")));
|
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&6AK-47 ( " + (ammo - 1) + "/ " + max + " )")));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,7 @@ public class CustomItemManager {
|
||||||
CustomItemManager.main = main;
|
CustomItemManager.main = main;
|
||||||
main.getConfig().options().copyDefaults();
|
main.getConfig().options().copyDefaults();
|
||||||
main.saveDefaultConfig();
|
main.saveDefaultConfig();
|
||||||
if(!main.getDataFolder().exists()) {
|
if(!main.getDataFolder().exists()) main.getDataFolder().mkdir();
|
||||||
main.getDataFolder().mkdir();
|
|
||||||
}
|
|
||||||
createDirectoryInPluginFolder("ItemData");
|
createDirectoryInPluginFolder("ItemData");
|
||||||
createFilesFromConfig(main.getConfig());
|
createFilesFromConfig(main.getConfig());
|
||||||
register();
|
register();
|
||||||
|
@ -116,12 +114,12 @@ public class CustomItemManager {
|
||||||
if (property.equals("ammo")) {
|
if (property.equals("ammo")) {
|
||||||
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
|
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
|
||||||
NamespacedKey key1 = new NamespacedKey(main, "ammo");
|
NamespacedKey key1 = new NamespacedKey(main, "ammo");
|
||||||
keys.put(fileConfig.getString("name") + "." + property, key1);
|
keys.put(Rarity.getRarity(fileConfig.getString("rarity")).getColor() + fileConfig.getString("name") + "." + property, key1);
|
||||||
container.set(key1, PersistentDataType.INTEGER, fileConfig.getInt(key));
|
container.set(key1, PersistentDataType.INTEGER, fileConfig.getInt(key));
|
||||||
} else if (property.equals("maxload")) {
|
} else if (property.equals("maxload")) {
|
||||||
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
|
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
|
||||||
NamespacedKey key2 = new NamespacedKey(main, "maxload");
|
NamespacedKey key2 = new NamespacedKey(main, "maxload");
|
||||||
keys.put(fileConfig.getString("name") + "." + property, key2);
|
keys.put(Rarity.getRarity(fileConfig.getString("rarity")).getColor() + fileConfig.getString("name") + "." + property, key2);
|
||||||
container.set(key2, PersistentDataType.INTEGER, fileConfig.getInt(key));
|
container.set(key2, PersistentDataType.INTEGER, fileConfig.getInt(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue