hey guys i need a hand and some input on how to change this. Where it's looking for LEATHER_LEGGINGS in the config i need it to look for a Lore That is defined in the config and not the Material. So if the item has the lore lets say ("exa") the plugin respond to that and not the Material Main.java Code:java private void loadArmor() {ConfigurationSection section = getConfig().getConfigurationSection("armor");for(String s : section.getKeys(false)){ConfigurationSection sub = section.getConfigurationSection(s);World w = (s.equals("default")) ? null : getServer().getWorld(s);System.out.println("[" + getDescription().getName() + "] Loading armor modifications for world " + ((w == null) ? "default" : w.getName()));for(String str : sub.getKeys(false)){try{int i;try{i = Integer.parseInt(str);} catch (NumberFormatException ex){i = Material.getMaterial(str).getId();}armorHook.modifyArmorValue(i, sub.getInt(str));} catch (Exception ex){ex.printStackTrace();System.out.println("[" + getDescription().getName() + "] Configuration node armor." + s + "." + str + " is causing an issue.");}}}System.out.println("[" + getDescription().getName() + "] Successfully loaded armor modifications!");} Config.yml Code:java armor:default:LEATHER_LEGGINGS: 6 how it should be want it to look for the lore ("exa") Config.yml Code:java armor:default:exa : 6 And thanks in-advance alot of you guys helped me on my other post in the last following weeks
Uhm, take the ItemStack, do something like this: Code: ItemMeta data = i.getItemMeta(); ArrayList<String> desc = new ArrayList<String>(); Desc.add("lore here"); Data.setLore(arrowDesc); i.setItemMeta(data); and then simply: Code: i.getItemMeta().hasLore() Code: i.getItemMeta().getLore() returns a List of Strings, that you can check/edit freely.
Autocorrect on my iPhone >_> EDIT: However it's complete bullshit that you can't use capital letters, sure not AT THE START of the word, but after it doesn't really matter and helps readability.
thanks CreeperShift thats not really what im looking for , wanting to alter this code to work as stated above not sure all of it can be seen on a iphone hehe
What do you want me to rewrite it for you lol? If it's your own code you can easily rewrite it with the second part of what I said, just check for lore instead, it's not that hard. On the list (or array, I forgot what it was) you can easily check .contains("bla bla") noraver Your post isn't really structured very well nor is the grammar very readable so let me just ask you if this is correct: You are trying to identify an item by it's lore, because obviously using the name can be changed via an anvil. Correct? Further, you are trying to get a value from your lore and applying bonuses to according to lore? Yes? No? If so, you might want to look at this (ignore it if you are not actually trying to do this ) This is from one of my plugins, which checks the item for lore, then scans through it if it contains a int. Code: if (damager instanceof Player){ ItemStack i = ((Player)damager).getItemInHand(); if(i.hasItemMeta() == true){ List<String> lore = i.getItemMeta().getLore(); String damage = "damage"; String looree = lore.toString(); if (looree.toLowerCase().contains(damage)){ Scanner s = new Scanner(looree).useDelimiter("[^0-9]+"); int damagevalue = s.nextInt(); event.setDamage(damagevalue); } EDIT by Moderator: merged posts, please use the edit button instead of double posting.
CreeperShift nope never asked for anyone to rewrite it, also it's not my code i'm trying to adapt it to my plugin that's in development, NBT is still new to me and how they have it, why i asked kind of pointers on where to look and what i may need to edit not asking for whole thing.
no im not trying to get any bonuses or apply anything i just wish to change so where it's looking for LEATHER_LEGGINGS it checks for a lore instead
Then I don't understand why my example is not what you are looking for. It does exactly what you just said. It checks for lore! Code: //You need an itemstack, lets call it i! if(i.hasItemMeta() == true){ //check if i has any meta, if it has lore it also has metadata, meaning it wont give us a nullpointer when we try to call it on an item without lore List<String> lore = i.getItemMeta().getLore(); //this creates a list of strings with ANY LORE the item may contain Alternatively you could also just convert it to a string, makes it easier for searching: String lore = i.getItemMeta().getLore().toString(); now you can easily do if (lore.toLowerCase().contains("any lore you might have added"){ //do something in here } It's really easy, this is basically how you check if an item has lore and WHICH lore. You should be able to include that in your plugin easily.
It's stylistic. Camel-case seems to be the norm for Java, anyway. It's for quicker readability when you need to be more descriptive with your variables.
I hope you're talking about the iPhone, sorry if you misinterpreted what I said, I meant that you shouldn't start variables with a capital for the sake that it's what classes start with