Emergency Fix (#587)

This commit is contained in:
MatthewBishop
2023-02-05 20:06:37 -05:00
committed by GitHub
parent 5db6da334d
commit 9d5d1c57ac
3 changed files with 18 additions and 1 deletions
@@ -39,6 +39,8 @@ public class DeprecatedItems {
*/ */
@java.lang.Deprecated @java.lang.Deprecated
public static String getItemName(int id) { public static String getItemName(int id) {
if(id == -1)
return "Unarmed";
if(org.apollo.cache.def.ItemDefinition.lookup(id) == null || org.apollo.cache.def.ItemDefinition.lookup(id).getName() == null) if(org.apollo.cache.def.ItemDefinition.lookup(id) == null || org.apollo.cache.def.ItemDefinition.lookup(id).getName() == null)
return "Unarmed"; return "Unarmed";
return org.apollo.cache.def.ItemDefinition.lookup(id).getName(); return org.apollo.cache.def.ItemDefinition.lookup(id).getName();
@@ -149,6 +149,8 @@ public class ItemData {
"sallet", "Facemask", "Bearhead"}; "sallet", "Facemask", "Bearhead"};
public static boolean isFullBody(int itemId) { public static boolean isFullBody(int itemId) {
if(itemId == -1)
return false;
String weapon = ItemDefinition.lookup(itemId).getName(); String weapon = ItemDefinition.lookup(itemId).getName();
if (weapon == null) { if (weapon == null) {
return false; return false;
@@ -162,6 +164,8 @@ public class ItemData {
} }
public static boolean isFullHelm(int itemId) { public static boolean isFullHelm(int itemId) {
if(itemId == -1)
return false;
String weapon = ItemDefinition.lookup(itemId).getName(); String weapon = ItemDefinition.lookup(itemId).getName();
if (weapon == null) { if (weapon == null) {
return false; return false;
@@ -175,6 +179,8 @@ public class ItemData {
} }
public static boolean isFullMask(int itemId) { public static boolean isFullMask(int itemId) {
if(itemId == -1)
return false;
String weapon = ItemDefinition.lookup(itemId).getName(); String weapon = ItemDefinition.lookup(itemId).getName();
if (weapon == null) { if (weapon == null) {
return false; return false;
@@ -78,6 +78,12 @@ public final class ItemDefinition {
return entry; return entry;
} }
private static ItemDefinition NULL_DEF = new ItemDefinition(-1);
static {
NULL_DEF.setName("");
NULL_DEF.setDescription("");
}
/** /**
* Gets the item definition for the specified id. * Gets the item definition for the specified id.
* *
@@ -86,7 +92,10 @@ public final class ItemDefinition {
* @throws IndexOutOfBoundsException If the id is out of bounds. * @throws IndexOutOfBoundsException If the id is out of bounds.
*/ */
public static ItemDefinition lookup(int id) { public static ItemDefinition lookup(int id) {
Preconditions.checkElementIndex(id, definitions.length, "Id out of bounds."); // Preconditions.checkElementIndex(id, definitions.length, "Id out of bounds.");
if(id < 0 || id > definitions.length) {
return NULL_DEF;
}
return definitions[id]; return definitions[id];
} }