Last active
February 22, 2017 15:30
-
-
Save leonardosnt/ea205f7e4f1bfaf841af639985054761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ItemStack dummy = new ItemStack(Material.AIR); | |
Iterable<String> split = Splitter.on(',').trimResults().omitEmptyStrings().split("276:2, 10, §3Sei la, DAMAGE_ALL:5, FIRE_ASPECT:2"); | |
Spliterator<String> it = split.spliterator(); | |
/* Id e data */ | |
it.tryAdvance(raw -> { | |
String[] rawSpl = raw.split(":"); // 0 = id, 1 = data | |
dummy.setTypeId(Integer.parseInt(rawSpl[0])); | |
dummy.getData().setData(Byte.parseByte(rawSpl[1])); | |
}); | |
ItemMeta dummyMeta = dummy.getItemMeta(); | |
/* Quantidade */ | |
it.tryAdvance(amt -> dummy.setAmount(Integer.valueOf(amt))); | |
/* DisplayName */ | |
it.tryAdvance(dummyMeta::setDisplayName); | |
/* Enchantments */ | |
it.forEachRemaining(rawEnch -> { | |
String[] rawSpl = rawEnch.split(":"); | |
dummy.addEnchantment(Enchantment.getByName(rawSpl[0]), | |
Short.parseShort(rawSpl[1])); | |
}); | |
dummy.setItemMeta(dummyMeta); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment