-
Notifications
You must be signed in to change notification settings - Fork 1
Rework item aliases #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d1ac60a
968c8ba
5e46c49
b680997
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,13 +12,11 @@ | |
| import org.bukkit.inventory.meta.Damageable; | ||
| import org.bukkit.inventory.meta.ItemMeta; | ||
| import org.royaldev.royalcommands.RUtils; | ||
| import org.royaldev.royalcommands.RoyalCommands; | ||
| import org.royaldev.royalcommands.shaded.com.sk89q.util.config.ConfigurationNode; | ||
| import org.royaldev.royalcommands.wrappers.player.RPlayer; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * A class representing a kit. | ||
| */ | ||
|
|
@@ -68,11 +66,11 @@ private Enchantment getEnchantment(final ConfigurationNode enchantment) { | |
| * @param item Node representing an ItemStack | ||
| * @return ItemStack of null | ||
| */ | ||
| // TODO Handle invalid item names better | ||
| private ItemStack getItemStack(final ConfigurationNode item) { | ||
| final ItemStack is = RoyalCommands.inm.getItemStackFromAlias(item.getString("type")); | ||
| final Damageable imd = (Damageable) is.getItemMeta(); | ||
| final ItemStack is = RUtils.getItem(item.getString("type"), item.getInt("amount", 1)); | ||
| if (is == null) return null; | ||
| is.setAmount(item.getInt("amount", 1)); | ||
| final Damageable imd = (Damageable) is.getItemMeta(); | ||
| imd.setDamage(item.getShort("damage", (short) 0)); | ||
|
Comment on lines
+73
to
74
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two lines could probably be removed, as it's just setting |
||
| final ItemMeta im = is.getItemMeta(); | ||
| im.setDisplayName(RUtils.colorize(item.getString("name"))); | ||
|
|
@@ -92,7 +90,9 @@ private List<ItemStack> getItemStacks(final List<ConfigurationNode> items) { | |
| final List<ItemStack> itemStacks = new ArrayList<>(); | ||
| for (final ConfigurationNode item : items) { | ||
| final ItemStack is = this.getItemStack(item); | ||
| if (is == null) continue; | ||
| if (is == null) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I agree this change is probably something we want to move towards, this shouldn't be done as part of this PR and should be part of a bigger code cleanup commit that can then be ignored using Git's ignore refs. |
||
| continue; | ||
| } | ||
| itemStacks.add(is); | ||
| } | ||
| return itemStacks; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #"DIAMOND_SWORD","stabby_knife" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these imports needed?