use ordinal over explicit ids

This commit is contained in:
Super_ 2020-01-08 15:00:22 -05:00
parent 035acbfa19
commit 24d121643e
2 changed files with 5 additions and 8 deletions

View file

@ -82,7 +82,7 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
public String giveItem(ShopItem item) public String giveItem(ShopItem item)
{ {
String signature = String.valueOf(item.getId()); String signature = String.valueOf(item.ordinal());
for (int i = 0; i < 7; i++) for (int i = 0; i < 7; i++)
{ {
signature += FUtil.getRandomCharacter(); signature += FUtil.getRandomCharacter();
@ -96,7 +96,7 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
for (String i : items) for (String i : items)
{ {
int id = Integer.valueOf(i.substring(0, 1)); int id = Integer.valueOf(i.substring(0, 1));
if (item.getId() == id) if (item.ordinal() == id)
{ {
return true; return true;
} }
@ -110,7 +110,7 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
for (String i : items) for (String i : items)
{ {
int id = Integer.valueOf(i.substring(0, 1)); int id = Integer.valueOf(i.substring(0, 1));
if (item.getId() == id) if (item.ordinal() == id)
{ {
signature = i; signature = i;
} }

View file

@ -6,7 +6,7 @@ import org.bukkit.Material;
public enum ShopItem 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 @Getter
private final String name; private final String name;
@ -16,16 +16,13 @@ public enum ShopItem
private final int cost; private final int cost;
@Getter @Getter
private final ChatColor color; 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.name = name;
this.material = material; this.material = material;
this.cost = cost; this.cost = cost;
this.color = color; this.color = color;
this.id = id;
} }
public String getColoredName() public String getColoredName()