From 9d5d1c57ace83dbe49eb6541dd2301371b47f4f2 Mon Sep 17 00:00:00 2001 From: MatthewBishop <55411296+MatthewBishop@users.noreply.github.com> Date: Sun, 5 Feb 2023 20:06:37 -0500 Subject: [PATCH] Emergency Fix (#587) --- .../main/java/com/rs2/game/items/DeprecatedItems.java | 2 ++ .../src/main/java/com/rs2/game/items/ItemData.java | 6 ++++++ .../java/org/apollo/cache/def/ItemDefinition.java | 11 ++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/2006Scape Server/src/main/java/com/rs2/game/items/DeprecatedItems.java b/2006Scape Server/src/main/java/com/rs2/game/items/DeprecatedItems.java index ecee7816..af63a5b7 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/items/DeprecatedItems.java +++ b/2006Scape Server/src/main/java/com/rs2/game/items/DeprecatedItems.java @@ -39,6 +39,8 @@ public class DeprecatedItems { */ @java.lang.Deprecated 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) return "Unarmed"; return org.apollo.cache.def.ItemDefinition.lookup(id).getName(); diff --git a/2006Scape Server/src/main/java/com/rs2/game/items/ItemData.java b/2006Scape Server/src/main/java/com/rs2/game/items/ItemData.java index 1d016d4e..b2a73e7d 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/items/ItemData.java +++ b/2006Scape Server/src/main/java/com/rs2/game/items/ItemData.java @@ -149,6 +149,8 @@ public class ItemData { "sallet", "Facemask", "Bearhead"}; public static boolean isFullBody(int itemId) { + if(itemId == -1) + return false; String weapon = ItemDefinition.lookup(itemId).getName(); if (weapon == null) { return false; @@ -162,6 +164,8 @@ public class ItemData { } public static boolean isFullHelm(int itemId) { + if(itemId == -1) + return false; String weapon = ItemDefinition.lookup(itemId).getName(); if (weapon == null) { return false; @@ -175,6 +179,8 @@ public class ItemData { } public static boolean isFullMask(int itemId) { + if(itemId == -1) + return false; String weapon = ItemDefinition.lookup(itemId).getName(); if (weapon == null) { return false; diff --git a/2006Scape Server/src/main/java/org/apollo/cache/def/ItemDefinition.java b/2006Scape Server/src/main/java/org/apollo/cache/def/ItemDefinition.java index 9c678f1d..b20b38ae 100644 --- a/2006Scape Server/src/main/java/org/apollo/cache/def/ItemDefinition.java +++ b/2006Scape Server/src/main/java/org/apollo/cache/def/ItemDefinition.java @@ -78,6 +78,12 @@ public final class ItemDefinition { 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. * @@ -86,7 +92,10 @@ public final class ItemDefinition { * @throws IndexOutOfBoundsException If the id is out of bounds. */ 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]; }