LevelChecker

invtype

Jan 16th, 2026
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. package net.swordie.ms.enums;
  2.  
  3. import net.swordie.ms.constants.ItemConstants;
  4.  
  5. import java.util.Arrays;
  6.  
  7. /**
  8. * Created on 11/23/2017.
  9. */
  10. public enum InvType {
  11. EQUIPPED(-1),
  12. EQUIP(1),
  13. CONSUME(2),
  14. ETC(4), // Turned around with INSTALL on purpose
  15. INSTALL(3),
  16. CASH(5),
  17. DEC(6)
  18. ;
  19.  
  20. private byte val;
  21.  
  22. InvType(int val) {
  23. this((byte) val);
  24. }
  25.  
  26. InvType(byte val) {
  27. this.val = val;
  28. }
  29.  
  30. public byte getVal() {
  31. return val;
  32. }
  33.  
  34. public static InvType getInvTypeByVal(int val) {
  35. return Arrays.stream(InvType.values()).filter(t -> t.getVal() == val).findFirst().orElse(null);
  36. }
  37.  
  38. public static InvType getInvTypeByString(String subMap) {
  39. subMap = subMap.toLowerCase();
  40. InvType res = null;
  41. switch(subMap) {
  42. case "cash":
  43. case "pet":
  44. res = CASH;
  45. break;
  46. case "consume":
  47. case "special":
  48. case "use":
  49. res = CONSUME;
  50. break;
  51. case "etc":
  52. res = ETC;
  53. break;
  54. case "install":
  55. case "setup":
  56. res = INSTALL;
  57. break;
  58. case "eqp":
  59. case "equip":
  60. res = EQUIP;
  61. break;
  62. case "dec":
  63. res = DEC;
  64. break;
  65. default:
  66. System.err.println("Unknown InvType string " + subMap);
  67. break;
  68. }
  69. return res;
  70. }
  71.  
  72. public boolean isStackable() {
  73. return this != EQUIP && this != EQUIPPED && this != DEC;
  74. }
  75.  
  76. public boolean isStackable(int itemId) {
  77. return isStackable() && !ItemConstants.isRechargable(itemId) && !ItemConstants.isPet(itemId) && !ItemConstants.isCashEffect(itemId);
  78. }
  79.  
  80. @Override
  81. public String toString() {
  82. switch (this) {
  83. case EQUIPPED:
  84. return "Equipped";
  85. case EQUIP:
  86. return "Equip";
  87. case CONSUME:
  88. return "Consume";
  89. case ETC:
  90. return "Etc";
  91. case INSTALL:
  92. return "Setup";
  93. case CASH:
  94. return "Cash";
  95. case DEC:
  96. return "Decoration";
  97. }
  98. return "Unknown";
  99. }
  100.  
  101. public boolean isEquipType() {
  102. return this == EQUIP || this == DEC;
  103. }
  104. }
  105.  
Advertisement
Add Comment
Please, Sign In to add comment