Commit 3f5e02df authored by Kenix Whisperwind's avatar Kenix Whisperwind

Server plugin handler and combat script loader are now non-stacic class members of Server

parent 7d9f6e30
......@@ -52,6 +52,8 @@ public final class Server implements Runnable {
private final PlayerDatabaseExecutor playerDataProcessor;
private final ServerConfiguration config;
private final ScheduledExecutorService scheduledExecutor;
private final PluginHandler pluginHandler;
private final CombatScriptLoader combatScriptLoader;
private final World world;
private DelayedEvent updateEvent;
......@@ -93,6 +95,8 @@ public final class Server implements Runnable {
name = getConfig().SERVER_NAME;
pluginHandler = new PluginHandler(this);
combatScriptLoader = new CombatScriptLoader(this);
constants = new Constants(this);
discordService = new DiscordService(this);
playerDataProcessor = new PlayerDatabaseExecutor(this);
......@@ -105,22 +109,13 @@ public final class Server implements Runnable {
public static void main(String[] args) throws IOException {
LOGGER.info("Launching Game Server...");
if (args.length == 0) {
LOGGER.info("Server Configuration file not provided. Loading from default.conf or local.conf.");
server = new Server("default.conf");
} else {
server = new Server(args[0]);
if (getServer().getConfig().DEBUG) {
LOGGER.info("Server Configuration file: " + args[0]);
LOGGER.info("\t Game Tick Cycle: {}", box(getServer().getConfig().GAME_TICK));
LOGGER.info("\t Client Version: {}", box(getServer().getConfig().CLIENT_VERSION));
LOGGER.info("\t Server type: " + (getServer().getConfig().MEMBER_WORLD ? "MEMBER" : "FREE" + " world."));
LOGGER.info("\t Combat Experience Rate: {}", box(getServer().getConfig().COMBAT_EXP_RATE));
LOGGER.info("\t Skilling Experience Rate: {}", box(getServer().getConfig().SKILLING_EXP_RATE));
LOGGER.info("\t Wilderness Experience Boost: {}", box(getServer().getConfig().WILDERNESS_BOOST));
LOGGER.info("\t Skull Experience Boost: {}", box(getServer().getConfig().SKULL_BOOST));
LOGGER.info("\t Double experience: " + (getServer().getConfig().IS_DOUBLE_EXP ? "Enabled" : "Disabled"));
LOGGER.info("\t View Distance: {}", box(getServer().getConfig().VIEW_DISTANCE));
for (int i = 0; i < args.length; i++) {
server = new Server(args[i]);
}
}
......@@ -145,14 +140,14 @@ public final class Server implements Runnable {
LOGGER.info("Loading game logging manager...");
GameLogging.load(this);
LOGGER.info("\t Logging Manager Completed");
LOGGER.info("\t Game Logging Manager Completed");
LOGGER.info("Loading Plugins...");
PluginHandler.getPluginHandler().initPlugins();
getPluginHandler().load();
LOGGER.info("\t Plugins Completed");
LOGGER.info("Loading Combat Scripts...");
CombatScriptLoader.init();
getCombatScriptLoader().load();
LOGGER.info("\t Combat Scripts Completed");
LOGGER.info("Loading World...");
......@@ -187,7 +182,7 @@ public final class Server implements Runnable {
bootstrap.childOption(ChannelOption.SO_RCVBUF, 10000);
bootstrap.childOption(ChannelOption.SO_SNDBUF, 10000);
try {
PluginHandler.getPluginHandler().handleAction("Startup", new Object[]{});
getPluginHandler().handleAction("Startup", new Object[]{});
serverChannel = bootstrap.bind(new InetSocketAddress(getServer().getConfig().SERVER_PORT)).sync();
LOGGER.info("Game world is now online on port {}!", box(getServer().getConfig().SERVER_PORT));
} catch (final InterruptedException e) {
......@@ -223,6 +218,7 @@ public final class Server implements Runnable {
}
public void kill() {
// TODO: Uninitialize server
stop();
LOGGER.fatal(getName() + " shutting down...");
System.exit(0);
......@@ -247,6 +243,7 @@ public final class Server implements Runnable {
// Doing the set in two stages here such that the whole tick has access to the same values for profiling information.
final long tickStart = System.currentTimeMillis();
System.out.println("Starting tick at: " + tickStart + ", lastClientUpdate: " + lastClientUpdate);
final long lastIncomingPacketsDuration = processIncomingPackets();
final long lastEventsDuration = runGameEvents();
final long lastGameStateDuration = runGameStateUpdate();
......@@ -514,4 +511,12 @@ public final class Server implements Runnable {
public String getName() {
return name;
}
public PluginHandler getPluginHandler() {
return pluginHandler;
}
public CombatScriptLoader getCombatScriptLoader() {
return combatScriptLoader;
}
}
package com.openrsc.server.event.rsc.impl;
import com.openrsc.server.Server;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.rsc.SingleTickEvent;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.model.entity.Mob;
import com.openrsc.server.model.entity.npc.Npc;
import com.openrsc.server.model.entity.player.Player;
......@@ -12,7 +12,6 @@ import com.openrsc.server.model.entity.update.Projectile;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.Functions;
import com.openrsc.server.plugins.PluginHandler;
/**
* @author n0m
......@@ -103,7 +102,7 @@ public class ProjectileEvent extends SingleTickEvent {
}
}
if (caster.isNpc()) {
if (PluginHandler.getPluginHandler().blockDefaultAction("PlayerKilledNpc",
if (caster.getWorld().getServer().getPluginHandler().blockDefaultAction("PlayerKilledNpc",
new Object[]{(Player) opponent, (Npc) caster})) {
return;
}
......@@ -155,7 +154,7 @@ public class ProjectileEvent extends SingleTickEvent {
if (opponent.isNpc() && caster.isPlayer()) {
Player playerCaster = (Player) caster;
Npc npcOpponent = (Npc) opponent;
if (PluginHandler.getPluginHandler().blockDefaultAction("PlayerKilledNpc",
if (caster.getWorld().getServer().getPluginHandler().blockDefaultAction("PlayerKilledNpc",
new Object[]{playerCaster, npcOpponent})) {
return;
}
......
package com.openrsc.server.event.rsc.impl;
import com.openrsc.server.Server;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.NpcId;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.rsc.GameTickEvent;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.NpcId;
import com.openrsc.server.model.PathValidation;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GroundItem;
......@@ -15,7 +15,6 @@ import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.model.entity.player.Prayers;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.PluginHandler;
import com.openrsc.server.util.rsc.DataConversions;
import com.openrsc.server.util.rsc.Formulae;
import com.openrsc.server.util.rsc.MessageType;
......@@ -130,7 +129,7 @@ public class RangeEvent extends GameTickEvent {
}
if (target.isNpc()) {
if (PluginHandler.getPluginHandler().blockDefaultAction("PlayerRangeNpc",
if (target.getWorld().getServer().getPluginHandler().blockDefaultAction("PlayerRangeNpc",
new Object[]{getOwner(), target})) {
getPlayerOwner().resetRange();
stop();
......
......@@ -13,7 +13,6 @@ import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.model.entity.player.Prayers;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.PluginHandler;
import com.openrsc.server.util.rsc.DataConversions;
import com.openrsc.server.util.rsc.Formulae;
......@@ -108,7 +107,7 @@ public class ThrowingEvent extends GameTickEvent {
}
if (target.isNpc()) {
if (PluginHandler.getPluginHandler().blockDefaultAction("PlayerRangeNpc",
if (target.getWorld().getServer().getPluginHandler().blockDefaultAction("PlayerRangeNpc",
new Object[]{getOwner(), target})) {
getPlayerOwner().resetRange();
stop();
......
package com.openrsc.server.event.rsc.impl.combat;
import com.openrsc.server.event.rsc.GameTickEvent;
import com.openrsc.server.event.rsc.impl.combat.scripts.CombatScriptLoader;
import com.openrsc.server.model.entity.npc.Npc;
import com.openrsc.server.model.entity.player.Player;
......@@ -13,7 +12,7 @@ public class AggroEvent extends GameTickEvent {
super(null, 0, "Aggro Event");
this.npc = npc;
this.player = player;
CombatScriptLoader.checkAndExecuteCombatAggroScript(npc, player);
player.getWorld().getServer().getCombatScriptLoader().checkAndExecuteCombatAggroScript(npc, player);
npc.setExecutedAggroScript(true);
}
......
package com.openrsc.server.event.rsc.impl.combat;
import com.openrsc.server.constants.Constants;
import com.openrsc.server.Server;
import com.openrsc.server.constants.Constants;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.rsc.GameTickEvent;
import com.openrsc.server.event.rsc.impl.combat.scripts.CombatScriptLoader;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.model.entity.Mob;
import com.openrsc.server.model.entity.npc.Npc;
import com.openrsc.server.model.entity.player.Player;
......@@ -16,7 +15,6 @@ import com.openrsc.server.model.states.CombatState;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.Functions;
import com.openrsc.server.plugins.PluginHandler;
import com.openrsc.server.util.rsc.DataConversions;
import com.openrsc.server.util.rsc.Formulae;
......@@ -34,7 +32,7 @@ public class CombatEvent extends GameTickEvent {
super(null, 0, "Combat Event");
this.attackerMob = attacker;
this.defenderMob = defender;
CombatScriptLoader.checkAndExecuteOnStartCombatScript(attacker, defender);
attacker.getWorld().getServer().getCombatScriptLoader().checkAndExecuteOnStartCombatScript(attacker, defender);
if (attacker.isNpc()) {
((Npc) attacker).setExecutedAggroScript(false);
} else if (defender.isNpc()) {
......@@ -44,7 +42,7 @@ public class CombatEvent extends GameTickEvent {
private static void onDeath(Mob killed, Mob killer) {
if (killer.isPlayer() && killed.isNpc()) {
if (PluginHandler.getPluginHandler().blockDefaultAction("PlayerKilledNpc",
if (killed.getWorld().getServer().getPluginHandler().blockDefaultAction("PlayerKilledNpc",
new Object[]{((Player) killer), ((Npc) killed)})) {
return;
}
......@@ -128,7 +126,7 @@ public class CombatEvent extends GameTickEvent {
Player targetPlayer = (Player) target;
if (targetPlayer.getPrayers().isPrayerActivated(Prayers.PARALYZE_MONSTER)) {
CombatScriptLoader.checkAndExecuteCombatScript(hitter, target);
hitter.getWorld().getServer().getCombatScriptLoader().checkAndExecuteCombatScript(hitter, target);
return;
}
}
......@@ -180,7 +178,7 @@ public class CombatEvent extends GameTickEvent {
if (target.getSkills().getLevel(3) > 0) {
if (!(target.isPlayer() && !((Player)target).getDuel().isDuelActive() && ((Player)target).checkRingOfLife(hitter)))
CombatScriptLoader.checkAndExecuteCombatScript(hitter, target);
target.getWorld().getServer().getCombatScriptLoader().checkAndExecuteCombatScript(hitter, target);
} else {
onDeath(target, hitter);
}
......
package com.openrsc.server.event.rsc.impl.combat.scripts;
import com.openrsc.server.Server;
import com.openrsc.server.model.entity.Mob;
import com.openrsc.server.model.entity.npc.Npc;
import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.plugins.PluginHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -21,14 +21,18 @@ public class CombatScriptLoader {
*/
private static final Logger LOGGER = LogManager.getLogger();
private static final Map<String, CombatScript> combatScripts = new HashMap<String, CombatScript>();
private final Map<String, CombatScript> combatScripts = new HashMap<String, CombatScript>();
private final Map<String, OnCombatStartScript> combatStartScripts = new HashMap<String, OnCombatStartScript>();
private final Map<String, CombatAggroScript> combatAggroScripts = new HashMap<String, CombatAggroScript>();
private static final Map<String, OnCombatStartScript> combatStartScripts = new HashMap<String, OnCombatStartScript>();
private static final Map<String, CombatAggroScript> combatAggroScripts = new HashMap<String, CombatAggroScript>();
private final Server server;
public CombatScriptLoader (Server server) {
this.server = server;
}
private static void loadCombatScripts() throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
for (Class<?> c : PluginHandler.loadClasses("com.openrsc.server.event.rsc.impl.combat.scripts.all")) {
private void loadCombatScripts() throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
for (Class<?> c : getServer().getPluginHandler().loadClasses("com.openrsc.server.event.rsc.impl.combat.scripts.all")) {
Object classInstance = c.getConstructor().newInstance();
if (classInstance instanceof CombatScript) {
CombatScript script = (CombatScript) classInstance;
......@@ -45,7 +49,7 @@ public class CombatScriptLoader {
}
}
public static void checkAndExecuteCombatScript(final Mob attacker, final Mob victim) {
public void checkAndExecuteCombatScript(final Mob attacker, final Mob victim) {
for (CombatScript script : combatScripts.values()) {
if (script.shouldExecute(attacker, victim)) {
script.executeScript(attacker, victim);
......@@ -53,7 +57,7 @@ public class CombatScriptLoader {
}
}
public static void checkAndExecuteOnStartCombatScript(final Mob attacker, final Mob victim) {
public void checkAndExecuteOnStartCombatScript(final Mob attacker, final Mob victim) {
try {
for (OnCombatStartScript script : combatStartScripts.values()) {
if (script.shouldExecute(attacker, victim)) {
......@@ -65,7 +69,7 @@ public class CombatScriptLoader {
}
}
public static void checkAndExecuteCombatAggroScript(final Npc npc, final Player player) {
public void checkAndExecuteCombatAggroScript(final Npc npc, final Player player) {
try {
for (CombatAggroScript script : combatAggroScripts.values()) {
if (script.shouldExecute(npc, player)) {
......@@ -77,7 +81,7 @@ public class CombatScriptLoader {
}
}
public static void init() {
public void load() {
try {
loadCombatScripts();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
......@@ -86,4 +90,8 @@ public class CombatScriptLoader {
LOGGER.catching(e);
}
}
public Server getServer() {
return server;
}
}
package com.openrsc.server.model.entity.npc;
import com.openrsc.server.constants.Constants;
import com.openrsc.server.Server;
import com.openrsc.server.constants.Constants;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.Quests;
import com.openrsc.server.constants.Skills;
......@@ -24,7 +24,6 @@ import com.openrsc.server.model.states.CombatState;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.Functions;
import com.openrsc.server.plugins.PluginHandler;
import com.openrsc.server.util.rsc.DataConversions;
import com.openrsc.server.util.rsc.Formulae;
import com.openrsc.server.util.rsc.GoldDrops;
......@@ -1125,7 +1124,7 @@ public class Npc extends Mob {
Server.getServer().getGameEventHandler().add(new ImmediateEvent("Init Talk Script") {
@Override
public void action() {
PluginHandler.getPluginHandler().blockDefaultAction("TalkToNpc", new Object[]{p, npc});
getWorld().getServer().getPluginHandler().blockDefaultAction("TalkToNpc", new Object[]{p, npc});
}
});
}
......@@ -1136,7 +1135,7 @@ public class Npc extends Mob {
Server.getServer().getGameEventHandler().add(new ImmediateEvent("Init Indirect Talk Script") {
@Override
public void action() {
PluginHandler.getPluginHandler().blockDefaultAction("IndirectTalkToNpc", new Object[]{p, npc});
getWorld().getServer().getPluginHandler().blockDefaultAction("IndirectTalkToNpc", new Object[]{p, npc});
}
});
}
......
......@@ -37,7 +37,6 @@ import com.openrsc.server.net.rsc.handlers.ItemDropHandler;
import com.openrsc.server.net.rsc.handlers.Ping;
import com.openrsc.server.net.rsc.handlers.WalkRequest;
import com.openrsc.server.plugins.Functions;
import com.openrsc.server.plugins.PluginHandler;
import com.openrsc.server.plugins.QuestInterface;
import com.openrsc.server.plugins.menu.Menu;
import com.openrsc.server.sql.GameLogging;
......@@ -1478,7 +1477,7 @@ public final class Player extends Mob {
activity += amount;
if (activity >= KITTEN_ACTIVITY_THRESHOLD) {
activity -= KITTEN_ACTIVITY_THRESHOLD;
PluginHandler.getPluginHandler().blockDefaultAction("CatGrowth", new Object[]{this});
getWorld().getServer().getPluginHandler().blockDefaultAction("CatGrowth", new Object[]{this});
}
}
}
......@@ -2163,7 +2162,7 @@ public final class Player extends Mob {
}
public void teleport(int x, int y, boolean bubble) {
if (bubble && PluginHandler.getPluginHandler().blockDefaultAction("Teleport", new Object[]{this})) {
if (bubble && getWorld().getServer().getPluginHandler().blockDefaultAction("Teleport", new Object[]{this})) {
return;
}
if (inCombat()) {
......
......@@ -10,7 +10,6 @@ import com.openrsc.server.net.ConnectionAttachment;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.PacketBuilder;
import com.openrsc.server.net.RSCConnectionHandler;
import com.openrsc.server.plugins.PluginHandler;
import com.openrsc.server.sql.DatabaseConnection;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.SecurityChangeLog;
......@@ -106,7 +105,7 @@ public class LoginPacketHandler {
loadedPlayer.setChangingAppearance(true);
}
PluginHandler.getPluginHandler().handleAction("PlayerLogin", new Object[]{loadedPlayer});
loadedPlayer.getWorld().getServer().getPluginHandler().handleAction("PlayerLogin", new Object[]{loadedPlayer});
ActionSender.sendLogin(loadedPlayer);
}
};
......
......@@ -13,7 +13,6 @@ import com.openrsc.server.model.world.World;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.OpcodeIn;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
public class AttackHandler implements PacketHandler {
/**
......@@ -98,13 +97,13 @@ public class AttackHandler implements PacketHandler {
return;
}
if (mob.isNpc()) {
if (PluginHandler.getPluginHandler().blockDefaultAction("PlayerAttackNpc",
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("PlayerAttackNpc",
new Object[]{player, (Npc) mob})) {
return;
}
}
if (mob.isPlayer()) {
if (PluginHandler.getPluginHandler().blockDefaultAction("PlayerAttack",
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("PlayerAttack",
new Object[]{player, mob})) {
return;
}
......
package com.openrsc.server.net.rsc.handlers;
import com.openrsc.server.Server;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.external.EntityHandler;
import com.openrsc.server.model.container.Bank;
import com.openrsc.server.model.container.Equipment;
import com.openrsc.server.model.container.Inventory;
......@@ -13,7 +13,6 @@ import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.net.rsc.OpcodeIn;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
import com.openrsc.server.util.rsc.DataConversions;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -66,7 +65,7 @@ public final class BankHandler implements PacketHandler {
return;
}
if (PluginHandler.getPluginHandler().blockDefaultAction("Withdraw",
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("Withdraw",
new Object[]{player, itemID, amount})) {
return;
}
......@@ -131,7 +130,7 @@ public final class BankHandler implements PacketHandler {
return;
}
if (PluginHandler.getPluginHandler().blockDefaultAction("Deposit",
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("Deposit",
new Object[]{player, itemID, amount})) {
return;
}
......@@ -153,11 +152,11 @@ public final class BankHandler implements PacketHandler {
Item depoItem = player.getEquipment().get(k);
if (depoItem == null)
continue;
if (PluginHandler.getPluginHandler().blockDefaultAction("Deposit",
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("Deposit",
new Object[]{player, depoItem.getID(), depoItem.getAmount()})) {
continue;
}
if (PluginHandler.getPluginHandler().blockDefaultAction(
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction(
"UnWield", new Object[]{player, depoItem}))
return;
player.getBank().unwieldItem(depoItem, false);
......@@ -200,7 +199,7 @@ public final class BankHandler implements PacketHandler {
boolean retval = true;
for (int k = player.getInventory().size() - 1; k >= 0; k--) {
Item depoItem = player.getInventory().get(k);
if (PluginHandler.getPluginHandler().blockDefaultAction("Deposit",
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("Deposit",
new Object[]{player, depoItem.getID(), depoItem.getAmount()})) {
continue;
}
......
......@@ -4,7 +4,6 @@ import com.openrsc.server.Server;
import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
public final class CommandHandler implements PacketHandler {
public void handlePacket(Packet p, Player player) throws Exception {
......@@ -20,7 +19,7 @@ public final class CommandHandler implements PacketHandler {
args = s.substring(firstSpace + 1).trim().split(" ");
}
PluginHandler.getPluginHandler().handleAction("Command",
player.getWorld().getServer().getPluginHandler().handleAction("Command",
new Object[]{cmd.toLowerCase(), args, player});
}
}
......
......@@ -10,7 +10,6 @@ import com.openrsc.server.model.world.World;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.OpcodeIn;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
public class GameObjectAction implements PacketHandler {
/**
......@@ -47,7 +46,7 @@ public class GameObjectAction implements PacketHandler {
String command = (click == 0 ? def.getCommand1() : def
.getCommand2()).toLowerCase();
player.face(object.getX(), object.getY());
if (PluginHandler.getPluginHandler().blockDefaultAction(
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction(
"ObjectAction",
new Object[]{object, command, player})) {
......
......@@ -11,7 +11,6 @@ import com.openrsc.server.model.world.World;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.OpcodeIn;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
public class GameObjectWallAction implements PacketHandler {
/**
......@@ -46,7 +45,7 @@ public class GameObjectWallAction implements PacketHandler {
return;
}
if (PluginHandler.getPluginHandler().blockDefaultAction(
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction(
"WallObjectAction",
new Object[]{object, click, player})) {
return;
......
......@@ -9,7 +9,6 @@ import com.openrsc.server.model.states.Action;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
public class GroundItemTake implements PacketHandler {
/**
......@@ -72,7 +71,7 @@ public class GroundItemTake implements PacketHandler {
player.resetAll();
if (PluginHandler.getPluginHandler().blockDefaultAction("Pickup", new Object[]{player, item})) {
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("Pickup", new Object[]{player, item})) {
return;
}
......
......@@ -11,7 +11,6 @@ import com.openrsc.server.model.world.World;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
public class ItemActionHandler implements PacketHandler {
/**
......@@ -69,7 +68,7 @@ public class ItemActionHandler implements PacketHandler {
player.resetAll();
if (PluginHandler.getPluginHandler().blockDefaultAction("InvAction",
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("InvAction",
new Object[]{item, player, item.getDef().getCommand()[commandIndex]})) {
return;
}
......
......@@ -10,7 +10,6 @@ import com.openrsc.server.model.world.World;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.GenericLog;
import com.openrsc.server.util.rsc.DataConversions;
......@@ -103,7 +102,7 @@ public final class ItemDropHandler implements PacketHandler {
player.setStatus(Action.IDLE);
return;
}
if (PluginHandler.getPluginHandler().blockDefaultAction("Drop", new Object[]{player, item})) {
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("Drop", new Object[]{player, item})) {
return;
}
......@@ -167,7 +166,7 @@ public final class ItemDropHandler implements PacketHandler {
return;
}
ActionSender.sendSound(getOwner(), "dropobject");
if (PluginHandler.getPluginHandler().blockDefaultAction("Drop", new Object[]{player, item})) {
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("Drop", new Object[]{player, item})) {
stop();
player.setStatus(Action.IDLE);
return;
......
......@@ -11,7 +11,6 @@ import com.openrsc.server.model.states.Action;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
public class ItemUseOnGroundItem implements PacketHandler {
/**
......@@ -76,7 +75,7 @@ public class ItemUseOnGroundItem implements PacketHandler {
return;
}
if (PluginHandler.getPluginHandler()
if (player.getWorld().getServer().getPluginHandler()
.blockDefaultAction("InvUseOnGroundItem",
new Object[]{myItem, item, player})) {
return;
......
......@@ -7,7 +7,6 @@ import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
public final class ItemUseOnItem implements PacketHandler {
/**
......@@ -51,7 +50,7 @@ public final class ItemUseOnItem implements PacketHandler {
// GenericLog(player.getUsername() + " used item " + item1 + " on item "
// + item2 + " at " + player.getLocation()));
if (PluginHandler.getPluginHandler().blockDefaultAction("InvUseOnItem",
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction("InvUseOnItem",
new Object[]{player, item1, item2})) {
return;
}
......
......@@ -10,7 +10,6 @@ import com.openrsc.server.model.states.Action;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
public class ItemUseOnNpc implements PacketHandler {
/**
......@@ -50,7 +49,7 @@ public class ItemUseOnNpc implements PacketHandler {
}
player.resetAll();
player.face(affectedNpc);
if (PluginHandler.getPluginHandler().blockDefaultAction(
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction(
"InvUseOnNpc",
new Object[]{player, affectedNpc, item}))
return;
......
......@@ -12,7 +12,6 @@ import com.openrsc.server.model.world.World;
import com.openrsc.server.net.Packet;
import com.openrsc.server.net.rsc.OpcodeIn;
import com.openrsc.server.net.rsc.PacketHandler;
import com.openrsc.server.plugins.PluginHandler;
public class ItemUseOnObject implements PacketHandler {
/**
......@@ -41,7 +40,7 @@ public class ItemUseOnObject implements PacketHandler {
player.message(player.MEMBER_MESSAGE);
return;
}
if (PluginHandler.getPluginHandler().blockDefaultAction(
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction(
"InvUseOnWallObject",
new Object[]{object, item, player}))
return;
......@@ -55,7 +54,7 @@ public class ItemUseOnObject implements PacketHandler {
if ((object.getID() == 226 || object.getID() == 232) && player.withinRange(object, 2)) {
player.resetPath();
player.resetAll();
if (PluginHandler.getPluginHandler().blockDefaultAction(
if (player.getWorld().getServer().getPluginHandler().blockDefaultAction(
"InvUseOnObject", new Object[]{object, item, player}))
return;
}
......@@ -78,7 +77,7 @@ public class ItemUseOnObject implements PacketHandler {
return;
}
if (PluginHandler.getPluginHandler()