From 24d121643ee08e41997bbaf93d0d34be7f6f2570 Mon Sep 17 00:00:00 2001 From: Super_ Date: Wed, 8 Jan 2020 15:00:22 -0500 Subject: [PATCH] use ordinal over explicit ids --- .../me/totalfreedom/totalfreedommod/shop/ShopData.java | 6 +++--- .../me/totalfreedom/totalfreedommod/shop/ShopItem.java | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/shop/ShopData.java b/src/main/java/me/totalfreedom/totalfreedommod/shop/ShopData.java index e8f38839..11ee3dbe 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/shop/ShopData.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/shop/ShopData.java @@ -82,7 +82,7 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable public String giveItem(ShopItem item) { - String signature = String.valueOf(item.getId()); + String signature = String.valueOf(item.ordinal()); for (int i = 0; i < 7; i++) { signature += FUtil.getRandomCharacter(); @@ -96,7 +96,7 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable for (String i : items) { int id = Integer.valueOf(i.substring(0, 1)); - if (item.getId() == id) + if (item.ordinal() == id) { return true; } @@ -110,7 +110,7 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable for (String i : items) { int id = Integer.valueOf(i.substring(0, 1)); - if (item.getId() == id) + if (item.ordinal() == id) { signature = i; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/shop/ShopItem.java b/src/main/java/me/totalfreedom/totalfreedommod/shop/ShopItem.java index 9cf404f6..c1062e34 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/shop/ShopItem.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/shop/ShopItem.java @@ -6,7 +6,7 @@ import org.bukkit.Material; public enum ShopItem { - GRAPPLING_HOOK("Grappling Hook", Material.FISHING_ROD, 100, ChatColor.GREEN, 0); + GRAPPLING_HOOK("Grappling Hook", Material.FISHING_ROD, 100, ChatColor.GREEN); @Getter private final String name; @@ -16,16 +16,13 @@ public enum ShopItem private final int cost; @Getter private final ChatColor color; - @Getter - private final int id; - ShopItem(String name, Material material, int cost, ChatColor color, int id) + ShopItem(String name, Material material, int cost, ChatColor color) { this.name = name; this.material = material; this.cost = cost; this.color = color; - this.id = id; } public String getColoredName()