Commit b941a6f8 authored by Kenix Whisperwind's avatar Kenix Whisperwind

EntityHandler is now a non-static class member of Server.

parent 1b2aac41
......@@ -312,7 +312,7 @@ public final class Admins implements CommandListener {
HashMap<String, Integer> hmap = new HashMap<>();
ItemDropDef[] drops = Objects.requireNonNull(EntityHandler.getNpcDef(npcID)).getDrops();
ItemDropDef[] drops = Objects.requireNonNull(player.getWorld().getServer().getEntityHandler().getNpcDef(npcID)).getDrops();
for (ItemDropDef drop : drops) {
dropID = drop.getID();
if (dropID == -1) continue;
......@@ -331,7 +331,7 @@ public final class Admins implements CommandListener {
for (int h : herbs)
hmap.put("herb " + h, 0);
} else {
ItemDefinition def = EntityHandler.getItemDef(dropID);
ItemDefinition def = player.getWorld().getServer().getEntityHandler().getItemDef(dropID);
hmap.put(def.getName().toLowerCase() + " " + dropID, 0);
}
}
......@@ -367,7 +367,7 @@ public final class Admins implements CommandListener {
dropID = Formulae.calculateGemDrop(player);
else if (dropID == 165)
dropID = Formulae.calculateHerbDrop();
ItemDefinition def = EntityHandler.getItemDef(dropID);
ItemDefinition def = player.getWorld().getServer().getEntityHandler().getItemDef(dropID);
try {
hmap.put(def.getName().toLowerCase() + " " + dropID, hmap.get(def.getName().toLowerCase() + " " + dropID) + 1);
} catch (NullPointerException n) {
......@@ -450,7 +450,7 @@ public final class Admins implements CommandListener {
return;
}
if (EntityHandler.getItemDef(id) == null) {
if (player.getWorld().getServer().getEntityHandler().getItemDef(id) == null) {
player.message(messagePrefix + "Invalid item id");
return;
}
......@@ -467,7 +467,7 @@ public final class Admins implements CommandListener {
+ item.getId() + "','" + item.getX() + "','" + item.getY() + "','" + item.getAmount()
+ "','" + item.getRespawnTime() + "')");
World.getWorld().registerItem(new GroundItem(player.getWorld(), item));
player.message(messagePrefix + "Added ground item to database: " + EntityHandler.getItemDef(item.getId()).getName() + " with item ID " + item.getId() + " at " + itemLocation);
player.message(messagePrefix + "Added ground item to database: " + player.getWorld().getServer().getEntityHandler().getItemDef(item.getId()).getName() + " with item ID " + item.getId() + " at " + itemLocation);
} else if (cmd.equalsIgnoreCase("rgi") || cmd.equalsIgnoreCase("rgitem") || cmd.equalsIgnoreCase("rgrounditem") || cmd.equalsIgnoreCase("removegi") || cmd.equalsIgnoreCase("removegitem") || cmd.equalsIgnoreCase("removegrounditem")) {
if (args.length == 1) {
player.message(badSyntaxPrefix + cmd.toUpperCase() + " (x) (y)");
......@@ -570,7 +570,7 @@ public final class Admins implements CommandListener {
return;
}
if (EntityHandler.getItemDef(id) == null) {
if (player.getWorld().getServer().getEntityHandler().getItemDef(id) == null) {
player.message(messagePrefix + "Invalid item id");
return;
}
......@@ -594,11 +594,11 @@ public final class Admins implements CommandListener {
return;
}
if (EntityHandler.getItemDef(id).isStackable()) {
if (player.getWorld().getServer().getEntityHandler().getItemDef(id).isStackable()) {
player.getInventory().add(new Item(id, amount));
} else {
for (int i = 0; i < amount; i++) {
if (!EntityHandler.getItemDef(id).isStackable()) {
if (!player.getWorld().getServer().getEntityHandler().getItemDef(id).isStackable()) {
if (amount > 30) { // Prevents too many un-stackable items from being spawned and crashing clients in the local area.
player.message(messagePrefix + "Invalid amount specified. Please spawn 30 or less of that item.");
return;
......@@ -608,9 +608,9 @@ public final class Admins implements CommandListener {
}
}
player.message(messagePrefix + "You have spawned " + amount + " " + EntityHandler.getItemDef(id).getName() + " to " + p.getUsername());
player.message(messagePrefix + "You have spawned " + amount + " " + player.getWorld().getServer().getEntityHandler().getItemDef(id).getName() + " to " + p.getUsername());
if (p.getUsernameHash() != player.getUsernameHash()) {
p.message(messagePrefix + "A staff member has given you " + amount + " " + EntityHandler.getItemDef(id).getName());
p.message(messagePrefix + "A staff member has given you " + amount + " " + player.getWorld().getServer().getEntityHandler().getItemDef(id).getName());
}
} else if (cmd.equalsIgnoreCase("bankitem") || cmd.equalsIgnoreCase("bitem") || cmd.equalsIgnoreCase("addbank")) {
if (args.length < 1) {
......@@ -626,7 +626,7 @@ public final class Admins implements CommandListener {
return;
}
if (EntityHandler.getItemDef(id) == null) {
if (player.getWorld().getServer().getEntityHandler().getItemDef(id) == null) {
player.message(messagePrefix + "Invalid item id");
return;
}
......@@ -652,9 +652,9 @@ public final class Admins implements CommandListener {
p.getBank().add(new Item(id, amount));
player.message(messagePrefix + "You have spawned to bank " + amount + " " + EntityHandler.getItemDef(id).getName() + " to " + p.getUsername());
player.message(messagePrefix + "You have spawned to bank " + amount + " " + player.getWorld().getServer().getEntityHandler().getItemDef(id).getName() + " to " + p.getUsername());
if (p.getUsernameHash() != player.getUsernameHash()) {
p.message(messagePrefix + "A staff member has added to your bank " + amount + " " + EntityHandler.getItemDef(id).getName());
p.message(messagePrefix + "A staff member has added to your bank " + amount + " " + player.getWorld().getServer().getEntityHandler().getItemDef(id).getName());
}
} else if (cmd.equals("fillbank")) {
for (int i = 0; i < 1289; i++) {
......@@ -929,7 +929,7 @@ public final class Admins implements CommandListener {
try {
int id = Integer.parseInt(args[0]);
int amount = Integer.parseInt(args[1]);
ItemDefinition itemDef = EntityHandler.getItemDef(id);
ItemDefinition itemDef = player.getWorld().getServer().getEntityHandler().getItemDef(id);
if (itemDef != null) {
int x = 0;
int y = 0;
......@@ -1021,14 +1021,14 @@ public final class Admins implements CommandListener {
int id = Integer.parseInt(args[0]);
int amount = Integer.parseInt(args[1]);
int duration = args.length >= 3 ? Integer.parseInt(args[2]) : 10;
NPCDef npcDef = EntityHandler.getNpcDef(id);
NPCDef npcDef = player.getWorld().getServer().getEntityHandler().getNpcDef(id);
if (npcDef == null) {
player.message(messagePrefix + "Invalid ID");
return;
}
if (EntityHandler.getNpcDef(id) != null) {
if (player.getWorld().getServer().getEntityHandler().getNpcDef(id) != null) {
int x = 0;
int y = 0;
int baseX = player.getX();
......@@ -1234,8 +1234,8 @@ public final class Admins implements CommandListener {
itemID = Integer.parseInt(args[2]);
itemAmt = args.length >= 4 ? Integer.parseInt(args[3]) : 1;
duration = args.length >= 5 ? Integer.parseInt(args[4]) : 10;
itemDef = EntityHandler.getItemDef(itemID);
npcDef = EntityHandler.getNpcDef(npcID);
itemDef = player.getWorld().getServer().getEntityHandler().getItemDef(itemID);
npcDef = player.getWorld().getServer().getEntityHandler().getNpcDef(npcID);
} catch (NumberFormatException e) {
player.message(badSyntaxPrefix + cmd.toUpperCase() + " [npc_id] [npc_amount] [item_id] (item_amount) (duration)");
return;
......@@ -1869,7 +1869,7 @@ public final class Admins implements CommandListener {
time = 10;
}
if (EntityHandler.getNpcDef(id) == null) {
if (player.getWorld().getServer().getEntityHandler().getNpcDef(id) == null) {
player.message(messagePrefix + "Invalid spawn npc id");
return;
}
......@@ -1886,8 +1886,7 @@ public final class Admins implements CommandListener {
}
});
player.message(messagePrefix + "You have spawned " + EntityHandler.getNpcDef(id).getName() + ", radius: " + radius + " for " + time + " minutes");
player.message(messagePrefix + "You have spawned " + player.getWorld().getServer().getEntityHandler().getNpcDef(id).getName() + ", radius: " + radius + " for " + time + " minutes");
}
}
}
package com.openrsc.server.plugins.commands;
import com.openrsc.server.Server;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.model.Point;
import com.openrsc.server.model.entity.GameObject;
import com.openrsc.server.model.entity.npc.Npc;
......@@ -77,7 +76,7 @@ public final class Development implements CommandListener {
Point npcLoc = new Point(x,y);
final Npc n = new Npc(player.getWorld(), id, x, y, x - radius, x + radius, y - radius, y + radius);
if (EntityHandler.getNpcDef(id) == null) {
if (player.getWorld().getServer().getEntityHandler().getNpcDef(id) == null) {
player.message(messagePrefix + "Invalid npc id");
return;
}
......@@ -219,7 +218,7 @@ public final class Development implements CommandListener {
return;
}
if (EntityHandler.getGameObjectDef(id) == null) {
if (player.getWorld().getServer().getEntityHandler().getGameObjectDef(id) == null) {
player.message(messagePrefix + "Invalid object id");
return;
}
......
......@@ -4,7 +4,6 @@ import com.openrsc.server.Server;
import com.openrsc.server.content.clan.ClanInvite;
import com.openrsc.server.content.party.PartyPlayer;
import com.openrsc.server.content.party.PartyRank;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.model.entity.player.Group;
import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.model.snapshot.Chatlog;
......@@ -395,7 +394,7 @@ public final class RegularPlayer implements CommandListener {
while (result.next()) {
int npcID = result.getInt("npcID");
int killCount = result.getInt("killCount");
kills.append("NPC: ").append(EntityHandler.getNpcDef(npcID).getName()).append(" - Kill Count: ").append(killCount).append("%");
kills.append("NPC: ").append(player.getWorld().getServer().getEntityHandler().getNpcDef(npcID).getName()).append(" - Kill Count: ").append(killCount).append("%");
}
result.close();
ActionSender.sendBox(player, kills.toString(), true);
......
package com.openrsc.server.plugins.commands;
import com.openrsc.server.Server;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.external.ItemDropDef;
import com.openrsc.server.external.NPCDef;
import com.openrsc.server.model.Point;
......@@ -231,11 +230,11 @@ public final class SuperModerator implements CommandListener {
try {
PreparedStatement statement = DatabaseConnection.getDatabase().prepareStatement(
"SELECT * FROM `" + Server.getServer().getConfig().MYSQL_TABLE_PREFIX + "npcdrops` WHERE npcdef_id = ?");
for (int i = 0; i < EntityHandler.npcs.size(); i++) {
for (int i = 0; i < player.getWorld().getServer().getEntityHandler().npcs.size(); i++) {
statement.setInt(1, i);
ResultSet dropResult = statement.executeQuery();
NPCDef def = EntityHandler.getNpcDef(i);
NPCDef def = player.getWorld().getServer().getEntityHandler().getNpcDef(i);
def.drops = null;
ArrayList<ItemDropDef> drops = new ArrayList<>();
while (dropResult.next()) {
......
package com.openrsc.server.plugins.defaults;
import com.openrsc.server.Server;
import com.openrsc.server.event.ShortEvent;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.NpcId;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.ShortEvent;
import com.openrsc.server.model.TelePoint;
import com.openrsc.server.model.entity.GameObject;
import com.openrsc.server.model.entity.npc.Npc;
......@@ -60,7 +59,7 @@ public class Ladders {
player.message("You go up the stairs");
return;
}
TelePoint telePoint = EntityHandler.getObjectTelePoint(obj
TelePoint telePoint = player.getWorld().getServer().getEntityHandler().getObjectTelePoint(obj
.getLocation(), command);
if (telePoint != null) {
player.teleport(telePoint.getX(), telePoint.getY(), false);
......
package com.openrsc.server.plugins.itemactions;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.external.ItemDefinition;
import com.openrsc.server.Server;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.external.ItemDefinition;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.plugins.listeners.action.InvUseOnItemListener;
......@@ -66,8 +66,8 @@ public class InvItemPoisoning implements InvUseOnItemListener, InvUseOnItemExecu
private Item getPoisonedItem(String name) {
String poisonedVersion = "Poisoned " + name;
String poisonedVersion2 = "Poison " + name;
for (int i = 0; i < EntityHandler.items.length; i++) {
ItemDefinition def = EntityHandler.getItemDef(i);
for (int i = 0; i < Server.getServer().getEntityHandler().items.length; i++) {
ItemDefinition def = Server.getServer().getEntityHandler().getItemDef(i);
if (def.getName().equalsIgnoreCase(poisonedVersion) || def.getName().equalsIgnoreCase(poisonedVersion2)) {
return new Item(i);
}
......
package com.openrsc.server.plugins.minigames.fishingtrawler;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GameObject;
import com.openrsc.server.model.entity.player.Player;
......@@ -102,15 +101,15 @@ public class TrawlerCatch implements ObjectActionListener, ObjectActionExecutive
if (randomJunkItem == ItemId.BROKEN_GLASS_DIGSITE_LVL_2.id() || randomJunkItem == ItemId.BUTTONS.id()
|| randomJunkItem == ItemId.DAMAGED_ARMOUR_1.id() || randomJunkItem == ItemId.DAMAGED_ARMOUR_2.id()
|| randomJunkItem == ItemId.CERAMIC_REMAINS.id()) {
message(p, 1200, "..some " + EntityHandler.getItemDef(randomJunkItem).getName());
message(p, 1200, "..some " + p.getWorld().getServer().getEntityHandler().getItemDef(randomJunkItem).getName());
}
// Old boot
else if (randomJunkItem == ItemId.OLD_BOOT.id()) {
message(p, 1200, "..an " + EntityHandler.getItemDef(randomJunkItem).getName());
message(p, 1200, "..an " + p.getWorld().getServer().getEntityHandler().getItemDef(randomJunkItem).getName());
}
// broken arrow, broken staff, Rusty sword, vase
else {
message(p, 1200, "..a " + EntityHandler.getItemDef(randomJunkItem).getName());
message(p, 1200, "..a " + p.getWorld().getServer().getEntityHandler().getItemDef(randomJunkItem).getName());
}
addItem(p, randomJunkItem, 1);
p.incExp(Skills.FISHING, 5, false);
......
package com.openrsc.server.plugins.misc;
import com.openrsc.server.Server;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.external.SpellDef;
import com.openrsc.server.model.container.Item;
......@@ -21,7 +20,7 @@ public class EnchantDragonstoneRing implements PlayerMageItemListener, PlayerMag
@Override
public void onPlayerMageItem(Player p, Integer itemID, Integer spellID) {
SpellDef spellDef = EntityHandler.getSpellDef(spellID.intValue());
SpellDef spellDef = p.getWorld().getServer().getEntityHandler().getSpellDef(spellID.intValue());
if (spellDef == null)
return;
......
package com.openrsc.server.plugins.npcs;
import com.openrsc.server.Server;
import com.openrsc.server.external.CerterDef;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.constants.NpcId;
import com.openrsc.server.external.CerterDef;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.npc.Npc;
import com.openrsc.server.model.entity.player.Player;
......@@ -30,7 +29,7 @@ public class Certer implements TalkToNpcListener, TalkToNpcExecutiveListener {
return;
}
final CerterDef certerDef = EntityHandler.getCerterDef(n.getID());
final CerterDef certerDef = p.getWorld().getServer().getEntityHandler().getCerterDef(n.getID());
if (certerDef == null) {
return;
}
......@@ -186,7 +185,7 @@ public class Certer implements TalkToNpcListener, TalkToNpcExecutiveListener {
if (p.getBank().remove(itemID, itemAmount) > -1) {
p.message("You exchange the " + certerDef.getType() + ", "
+ itemAmount + " "
+ EntityHandler.getItemDef(itemID).getName()
+ p.getWorld().getServer().getEntityHandler().getItemDef(itemID).getName()
+ " is taken from your bank");
p.getInventory().add(new Item(certID, certAmount));
}
......
......@@ -6,7 +6,6 @@ import com.openrsc.server.constants.NpcId;
import com.openrsc.server.constants.Quests;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.SingleEvent;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.model.Point;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GameObject;
......@@ -949,7 +948,7 @@ public class LegendsQuestGameObjects implements ObjectActionListener, ObjectActi
p.getInventory().replace(ItemId.BLESSED_GOLDEN_BOWL.id(), ItemId.BLESSED_GOLDEN_BOWL_WITH_PURE_WATER.id());
message(p, 1300, "The water seems to bubble and sparkle as if alive.");
} else {
message(p, 1300, "You put some water in the " + EntityHandler.getItemDef(emptyID).getName().toLowerCase() + ".");
message(p, 1300, "You put some water in the " + p.getWorld().getServer().getEntityHandler().getItemDef(emptyID).getName().toLowerCase() + ".");
p.getInventory().replace(emptyID, refilledID);
}
removeItem(p, ItemId.CUT_REED_PLANT.id(), 1);
......
package com.openrsc.server.plugins.skills;
import com.openrsc.server.Server;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.MiniEvent;
import com.openrsc.server.event.SingleEvent;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.external.ItemCraftingDef;
import com.openrsc.server.external.ItemGemDef;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.model.MenuOptionListener;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GameObject;
import com.openrsc.server.model.entity.player.Player;
......@@ -105,7 +104,7 @@ public class Crafting implements InvUseOnItemListener,
}
final int craftType = option;
if (owner.getInventory().countId(moulds[craftType]) < 1) {
owner.message("You need a " + EntityHandler.getItemDef(moulds[craftType]).getName() + " to make a " + reply);
owner.message("You need a " + owner.getWorld().getServer().getEntityHandler().getItemDef(moulds[craftType]).getName() + " to make a " + reply);
return;
}
owner.message("What type of " + reply + " would you like to make?");
......@@ -133,7 +132,7 @@ public class Crafting implements InvUseOnItemListener,
interrupt();
return;
}
ItemCraftingDef def = EntityHandler.getCraftingDef((option * 3) + craftType);
ItemCraftingDef def = owner.getWorld().getServer().getEntityHandler().getCraftingDef((option * 3) + craftType);
if (def == null) {
owner.message("Nothing interesting happens");
interrupt();
......@@ -201,7 +200,7 @@ public class Crafting implements InvUseOnItemListener,
ItemId.UNSTRUNG_UNHOLY_SYMBOL_OF_ZAMORAK.id()
};
if (owner.getInventory().countId(moulds[option]) < 1) {
owner.message("You need a " + EntityHandler.getItemDef(moulds[option]).getName() + " to make a " + reply + "!");
owner.message("You need a " + owner.getWorld().getServer().getEntityHandler().getItemDef(moulds[option]).getName() + " to make a " + reply + "!");
return;
}
......@@ -450,7 +449,7 @@ public class Crafting implements InvUseOnItemListener,
}
private boolean doCutGem(Player player, final Item chisel, final Item gem) {
final ItemGemDef gemDef = EntityHandler.getItemGemDef(gem.getID());
final ItemGemDef gemDef = player.getWorld().getServer().getEntityHandler().getItemGemDef(gem.getID());
if (gemDef == null) {
return false;
}
......@@ -732,8 +731,8 @@ public class Crafting implements InvUseOnItemListener,
@Override
public boolean blockInvUseOnItem(Player player, Item item1, Item item2) {
ItemGemDef gemDef = EntityHandler.getItemGemDef(item1.getID());
ItemGemDef gemDef2 = EntityHandler.getItemGemDef(item2.getID());
ItemGemDef gemDef = player.getWorld().getServer().getEntityHandler().getItemGemDef(item1.getID());
ItemGemDef gemDef2 = player.getWorld().getServer().getEntityHandler().getItemGemDef(item2.getID());
if (item1.getID() == ItemId.CHISEL.id() && (gemDef != null || gemDef2 != null)) {
return true;
} else if (item2.getID() == ItemId.CHISEL.id() && (gemDef != null || gemDef2 != null)) {
......
package com.openrsc.server.plugins.skills;
import com.openrsc.server.Server;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.SingleEvent;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.external.FiremakingDef;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GameObject;
import com.openrsc.server.model.entity.GroundItem;
......@@ -60,7 +59,7 @@ public class Firemaking implements InvUseOnGroundItemListener, InvUseOnGroundIte
}
private void handleFiremaking(final GroundItem gItem, Player player) {
final FiremakingDef def = EntityHandler.getFiremakingDef(gItem.getID());
final FiremakingDef def = player.getWorld().getServer().getEntityHandler().getFiremakingDef(gItem.getID());
if (def == null) {
player.message("Nothing interesting happens.");
return;
......@@ -113,7 +112,7 @@ public class Firemaking implements InvUseOnGroundItemListener, InvUseOnGroundIte
}
private void handleCustomFiremaking(final GroundItem gItem, Player player) {
final FiremakingDef def = EntityHandler.getFiremakingDef(gItem.getID());
final FiremakingDef def = player.getWorld().getServer().getEntityHandler().getFiremakingDef(gItem.getID());
if (def == null) {
player.message("Nothing interesting happens");
......
package com.openrsc.server.plugins.skills;
import com.openrsc.server.Server;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.external.ObjectFishDef;
import com.openrsc.server.external.ObjectFishingDef;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GameObject;
import com.openrsc.server.model.entity.player.Player;
......@@ -50,7 +49,7 @@ public class Fishing implements ObjectActionListener, ObjectActionExecutiveListe
private void handleFishing(final GameObject object, Player owner, final int click, final String command) {
final ObjectFishingDef def = EntityHandler.getObjectFishingDef(object.getID(), click);
final ObjectFishingDef def = owner.getWorld().getServer().getEntityHandler().getObjectFishingDef(object.getID(), click);
if (owner.isBusy()) {
return;
......@@ -76,7 +75,7 @@ public class Fishing implements ObjectActionListener, ObjectActionExecutiveListe
owner.playerServerMessage(MessageType.QUEST, "You need at least level " + def.getReqLevel() + " "
+ fishingRequirementString(object, command) + " "
+ (!command.contains("cage") ? "these fish"
: EntityHandler.getItemDef(def.getFishDefs()[0].getId()).getName().toLowerCase()
: owner.getWorld().getServer().getEntityHandler().getItemDef(def.getFishDefs()[0].getId()).getName().toLowerCase()
.substring(4) + "s"));
return;
}
......@@ -84,13 +83,13 @@ public class Fishing implements ObjectActionListener, ObjectActionExecutiveListe
if (owner.getInventory().countId(netId) <= 0) {
owner.playerServerMessage(MessageType.QUEST,
"You need a "
+ EntityHandler
+ owner.getWorld().getServer().getEntityHandler()
.getItemDef(
netId)
.getName().toLowerCase()
+ " to " + (command.equals("lure") || command.equals("bait") ? command : def.getBaitId() > 0 ? "bait" : "catch") + " "
+ (!command.contains("cage") ? "these fish"
: EntityHandler.getItemDef(def.getFishDefs()[0].getId()).getName().toLowerCase()
: owner.getWorld().getServer().getEntityHandler().getItemDef(def.getFishDefs()[0].getId()).getName().toLowerCase()
.substring(4) + "s"));
return;
}
......@@ -98,7 +97,7 @@ public class Fishing implements ObjectActionListener, ObjectActionExecutiveListe
if (baitId >= 0) {
if (owner.getInventory().countId(baitId) <= 0) {
owner.playerServerMessage(MessageType.QUEST,
"You don't have any " + EntityHandler.getItemDef(baitId).getName().toLowerCase() + " left");
"You don't have any " + owner.getWorld().getServer().getEntityHandler().getItemDef(baitId).getName().toLowerCase() + " left");
return;
}
}
......@@ -111,7 +110,7 @@ public class Fishing implements ObjectActionListener, ObjectActionExecutiveListe
final int baitId = def.getBaitId();
if (baitId >= 0) {
if (owner.getInventory().countId(baitId) <= 0) {
owner.playerServerMessage(MessageType.QUEST, "You don't have any " + EntityHandler.getItemDef(baitId).getName().toLowerCase()
owner.playerServerMessage(MessageType.QUEST, "You don't have any " + owner.getWorld().getServer().getEntityHandler().getItemDef(baitId).getName().toLowerCase()
+ " left");
interrupt();
return;
......
......@@ -70,7 +70,7 @@ public class Fletching implements InvUseOnItemExecutiveListener {
ItemDartTipDef tipDef = null;
if (item.getID() == com.openrsc.server.constants.ItemId.ARROW_SHAFTS.id()) {
itemID = com.openrsc.server.constants.ItemId.HEADLESS_ARROWS.id();
} else if ((tipDef = EntityHandler.getItemDartTipDef(item.getID())) != null) {
} else if ((tipDef = player.getWorld().getServer().getEntityHandler().getItemDartTipDef(item.getID())) != null) {
itemID = tipDef.getDartID(); // Dart ID
experience = (int) (tipDef.getExp());
} else {
......@@ -110,7 +110,7 @@ public class Fletching implements InvUseOnItemExecutiveListener {
player.sendMemberErrorMessage();
return true;
}
final ItemArrowHeadDef headDef = EntityHandler
final ItemArrowHeadDef headDef = player.getWorld().getServer().getEntityHandler()
.getItemArrowHeadDef(arrowHeads.getID());
if (headDef == null) {
return false;
......@@ -163,7 +163,7 @@ public class Fletching implements InvUseOnItemExecutiveListener {
player.sendMemberErrorMessage();
return true;
}
final ItemBowStringDef stringDef = EntityHandler
final ItemBowStringDef stringDef = player.getWorld().getServer().getEntityHandler()
.getItemBowStringDef(bow.getID());
if (stringDef == null) {
return false;
......@@ -208,7 +208,7 @@ public class Fletching implements InvUseOnItemExecutiveListener {
player.sendMemberErrorMessage();
return true;
}
final ItemLogCutDef cutDef = EntityHandler.getItemLogCutDef(log.getID());
final ItemLogCutDef cutDef = player.getWorld().getServer().getEntityHandler().getItemLogCutDef(log.getID());
if (cutDef == null) {
return false;
}
......
package com.openrsc.server.plugins.skills;
import com.openrsc.server.Server;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.external.ObjectMiningDef;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GameObject;
......@@ -41,7 +39,7 @@ public class GemMining implements ObjectActionListener,
if (!p.withinRange(obj, 1)) {
return;
}
final ObjectMiningDef def = EntityHandler.getObjectMiningDef(obj.getID());
final ObjectMiningDef def = p.getWorld().getServer().getEntityHandler().getObjectMiningDef(obj.getID());
final int axeId = getAxe(p);
int retrytimes;
final int mineLvl = p.getSkills().getLevel(com.openrsc.server.constants.Skills.MINING);
......
......@@ -5,7 +5,6 @@ import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Quests;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.external.ItemHerbDef;
import com.openrsc.server.external.ItemHerbSecond;
import com.openrsc.server.external.ItemUnIdentHerbDef;
......@@ -73,10 +72,10 @@ public class Herblaw implements InvActionListener, InvUseOnItemListener,
@Override
public void onInvUseOnItem(Player player, Item item, Item usedWith) {
ItemHerbSecond secondDef = null;
if ((secondDef = EntityHandler.getItemHerbSecond(item.getID(), usedWith
if ((secondDef = player.getWorld().getServer().getEntityHandler().getItemHerbSecond(item.getID(), usedWith
.getID())) != null) {
doHerbSecond(player, item, usedWith, secondDef, false);
} else if ((secondDef = EntityHandler.getItemHerbSecond(usedWith
} else if ((secondDef = player.getWorld().getServer().getEntityHandler().getItemHerbSecond(usedWith
.getID(), item.getID())) != null) {
doHerbSecond(player, usedWith, item, secondDef, true);
} else if (item.getID() == com.openrsc.server.constants.ItemId.PESTLE_AND_MORTAR.id()) {
......@@ -202,8 +201,8 @@ public class Herblaw implements InvActionListener, InvUseOnItemListener,
}
public boolean blockInvUseOnItem(Player p, Item item, Item usedWith) {
if ((EntityHandler.getItemHerbSecond(item.getID(), usedWith.getID())) != null
|| (EntityHandler.getItemHerbSecond(usedWith.getID(), item
if ((p.getWorld().getServer().getEntityHandler().getItemHerbSecond(item.getID(), usedWith.getID())) != null
|| (p.getWorld().getServer().getEntityHandler().getItemHerbSecond(usedWith.getID(), item
.getID())) != null) {
return true;
} else if (item.getID() == com.openrsc.server.constants.ItemId.PESTLE_AND_MORTAR.id() || usedWith.getID() == com.openrsc.server.constants.ItemId.PESTLE_AND_MORTAR.id()) {
......@@ -277,7 +276,7 @@ public class Herblaw implements InvActionListener, InvUseOnItemListener,
player.getInventory().add(new Item(com.openrsc.server.constants.ItemId.SNAKES_WEED_SOLUTION.id(), 1));
return false;
}
final ItemHerbDef herbDef = EntityHandler.getItemHerbDef(herb.getID());
final ItemHerbDef herbDef = player.getWorld().getServer().getEntityHandler().getItemHerbDef(herb.getID());
if (herbDef == null) {
return false;
}
......
......@@ -5,7 +5,6 @@ import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Quests;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.external.ObjectMiningDef;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GameObject;
......@@ -117,7 +116,7 @@ public final class Mining implements ObjectActionListener,
return;
}
final ObjectMiningDef def = EntityHandler.getObjectMiningDef(object.getID());
final ObjectMiningDef def = owner.getWorld().getServer().getEntityHandler().getObjectMiningDef(object.getID());
final int axeId = getAxe(owner);
int retrytimes = -1;
final int mineLvl = owner.getSkills().getLevel(com.openrsc.server.constants.Skills.MINING);
......
......@@ -4,7 +4,6 @@ import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Quests;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.external.ObjectRunecraftingDef;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GameObject;
......@@ -20,7 +19,7 @@ public class Runecrafting implements ObjectActionListener, ObjectActionExecutive
@Override
public boolean blockObjectAction(GameObject obj, String command, Player player) {
final ObjectRunecraftingDef def = EntityHandler.getObjectRunecraftingDef(obj.getID());
final ObjectRunecraftingDef def = player.getWorld().getServer().getEntityHandler().getObjectRunecraftingDef(obj.getID());