diff --git a/Server/src/main/java/core/game/content/activity/duel/DuelSession.java b/Server/src/main/java/core/game/content/activity/duel/DuelSession.java index 1897ad460..107707542 100644 --- a/Server/src/main/java/core/game/content/activity/duel/DuelSession.java +++ b/Server/src/main/java/core/game/content/activity/duel/DuelSession.java @@ -1,6 +1,6 @@ package core.game.content.activity.duel; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.CloseEvent; import core.game.component.Component; import core.game.component.ComponentDefinition; @@ -569,7 +569,7 @@ public final class DuelSession extends ComponentPlugin { amount = c.getAmount(c.get(slot)); break; case 234: - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { c.withdraw(slot, (int) value); return Unit.INSTANCE; }); @@ -686,7 +686,7 @@ public final class DuelSession extends ComponentPlugin { c1.offer(slot, player.getInventory().getAmount(player.getInventory().get(slot).getId())); break; case 234: - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { c1.offer(slot, (int) value); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/content/activity/guild/WizardGuildPlugin.java b/Server/src/main/java/core/game/content/activity/guild/WizardGuildPlugin.java index 132a399c3..27edf9020 100644 --- a/Server/src/main/java/core/game/content/activity/guild/WizardGuildPlugin.java +++ b/Server/src/main/java/core/game/content/activity/guild/WizardGuildPlugin.java @@ -1,6 +1,6 @@ package core.game.content.activity.guild; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.NPCDefinition; import core.cache.def.impl.SceneryDefinition; import core.game.content.dialogue.DialoguePlugin; @@ -61,7 +61,7 @@ public final class WizardGuildPlugin extends OptionHandler { switch (id) { case 1600: case 1601: - if (ContentAPI.getDynLevel(player, Skills.MAGIC) < 66) { + if (getDynLevel(player, Skills.MAGIC) < 66) { player.getDialogueInterpreter().sendDialogue("You need a Magic level of at least 66 to enter."); return true; } diff --git a/Server/src/main/java/core/game/content/activity/partyroom/PartyRoomPlugin.java b/Server/src/main/java/core/game/content/activity/partyroom/PartyRoomPlugin.java index 4c03b75e8..436a2b511 100644 --- a/Server/src/main/java/core/game/content/activity/partyroom/PartyRoomPlugin.java +++ b/Server/src/main/java/core/game/content/activity/partyroom/PartyRoomPlugin.java @@ -5,7 +5,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.SceneryDefinition; import core.game.component.Component; import core.game.component.ComponentDefinition; @@ -316,7 +316,7 @@ public final class PartyRoomPlugin extends OptionHandler { viewer.getContainer().addItem(slot, ammount); break; case 234: - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { viewer.getContainer().addItem(slot, (int) value); return Unit.INSTANCE; }); @@ -347,7 +347,7 @@ public final class PartyRoomPlugin extends OptionHandler { viewer.getContainer().takeItem(slot, ammount); break; case 234: - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { viewer.getContainer().takeItem(slot, (int) value); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidOptionHandler.java b/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidOptionHandler.java index 28788cf5b..b947a2abe 100644 --- a/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidOptionHandler.java +++ b/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidOptionHandler.java @@ -1,6 +1,6 @@ package core.game.content.activity.pyramidplunder; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.NPCDefinition; import core.cache.def.impl.SceneryDefinition; import core.game.content.global.action.ClimbActionHandler; @@ -84,7 +84,7 @@ public final class PyramidOptionHandler extends OptionHandler { if(entrance == currentEntrance && willBePushed){ player.lock(); player.animate(new Animation(7299)); - ContentAPI.submitWorldPulse(new Pulse(4, player){ + submitWorldPulse(new Pulse(4, player){ @Override public boolean pulse() { player.unlock(); diff --git a/Server/src/main/java/core/game/content/consumable/Consumable.java b/Server/src/main/java/core/game/content/consumable/Consumable.java index a3e82ff3f..3de3c3733 100644 --- a/Server/src/main/java/core/game/content/consumable/Consumable.java +++ b/Server/src/main/java/core/game/content/consumable/Consumable.java @@ -1,7 +1,7 @@ package core.game.content.consumable; import api.Container; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.node.entity.player.Player; import core.game.node.item.Item; import core.game.world.update.flag.context.Animation; @@ -50,11 +50,11 @@ public abstract class Consumable implements Plugin { final int nextItemId = getNextItemId(item.getId()); if(item.getAmount() > 1){ - ContentAPI.removeItem(player, item.getId(), Container.INVENTORY); - } else ContentAPI.removeItem(player, item, Container.INVENTORY); + removeItem(player, item.getId(), Container.INVENTORY); + } else removeItem(player, item, Container.INVENTORY); if (nextItemId != -1) { - ContentAPI.addItem(player, nextItemId, 1); + addItem(player, nextItemId, 1); } final int initialLifePoints = player.getSkills().getLifepoints(); Consumables.getConsumableById(item.getId()).effect.activate(player); diff --git a/Server/src/main/java/core/game/content/dialogue/DialoguePlugin.java b/Server/src/main/java/core/game/content/dialogue/DialoguePlugin.java index b814afc94..01a683016 100644 --- a/Server/src/main/java/core/game/content/dialogue/DialoguePlugin.java +++ b/Server/src/main/java/core/game/content/dialogue/DialoguePlugin.java @@ -11,6 +11,7 @@ import rs09.game.content.dialogue.DialogueFile; import java.util.ArrayList; +import static api.DialUtilsKt.splitLines; import static rs09.tools.DialogueConstKt.DIALOGUE_INITIAL_OPTIONS_HANDLE; import static rs09.tools.DialogueConstKt.START_DIALOGUE; @@ -318,7 +319,7 @@ public abstract class DialoguePlugin implements Plugin { * @param msg the message for the NPC to say */ public Component npcl(FacialExpression expr, String msg){ - return npc(expr, api.DialUtils.splitLines(msg)); + return npc(expr, splitLines(msg)); } /** @@ -327,7 +328,7 @@ public abstract class DialoguePlugin implements Plugin { * @param msg the message for the player to say */ public Component playerl(FacialExpression expr, String msg){ - return player(expr, api.DialUtils.splitLines(msg)); + return player(expr, splitLines(msg)); } } \ No newline at end of file diff --git a/Server/src/main/java/core/game/content/dialogue/DrezelMonumentDialogue.java b/Server/src/main/java/core/game/content/dialogue/DrezelMonumentDialogue.java index aeb536891..ac0f82ab7 100644 --- a/Server/src/main/java/core/game/content/dialogue/DrezelMonumentDialogue.java +++ b/Server/src/main/java/core/game/content/dialogue/DrezelMonumentDialogue.java @@ -1,6 +1,6 @@ package core.game.content.dialogue; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.node.entity.npc.NPC; import core.game.node.entity.player.Player; import core.game.node.entity.player.link.quest.Quest; @@ -83,7 +83,7 @@ public final class DrezelMonumentDialogue extends DialoguePlugin { interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Greetings again adventurer, How go your travels in", "Morytania? Is it as evil as I have heard?"); stage = 420; } else if (quest.getStage(player) < 100){ - ContentAPI.openDialogue(player, new NSDrezelDialogue(), npc); + openDialogue(player, new NSDrezelDialogue(), npc); } else { npcl(FacialExpression.NEUTRAL, "I heard you finished your quest with Filliman! Great work!"); stage = END_DIALOGUE; diff --git a/Server/src/main/java/core/game/content/dialogue/EnchantTiaraDialogue.java b/Server/src/main/java/core/game/content/dialogue/EnchantTiaraDialogue.java index 5c47866f5..ce7f30796 100644 --- a/Server/src/main/java/core/game/content/dialogue/EnchantTiaraDialogue.java +++ b/Server/src/main/java/core/game/content/dialogue/EnchantTiaraDialogue.java @@ -1,6 +1,6 @@ package core.game.content.dialogue; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.plugin.Initializable; import core.game.node.entity.skill.runecrafting.Altar; import core.game.node.entity.skill.runecrafting.EnchantTiaraPulse; @@ -76,7 +76,7 @@ public final class EnchantTiaraDialogue extends DialoguePlugin { amt = 5; break; case 4: - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { player.getPulseManager().run(new EnchantTiaraPulse(player, event.getUsedItem(), Talisman.forItem(event.getUsedItem()).getTiara(), (int) value)); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/content/dialogue/LeatherCraftDialogue.java b/Server/src/main/java/core/game/content/dialogue/LeatherCraftDialogue.java index b1974676b..c299ab36e 100644 --- a/Server/src/main/java/core/game/content/dialogue/LeatherCraftDialogue.java +++ b/Server/src/main/java/core/game/content/dialogue/LeatherCraftDialogue.java @@ -1,6 +1,6 @@ package core.game.content.dialogue; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.ItemDefinition; import core.game.component.Component; import kotlin.Unit; @@ -111,7 +111,7 @@ public final class LeatherCraftDialogue extends DialoguePlugin { amt = 5; break; case 3: - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { player.getPulseManager().run(new HardCraftPulse(player, null, (int) value)); return Unit.INSTANCE; }); @@ -205,7 +205,7 @@ public final class LeatherCraftDialogue extends DialoguePlugin { if (hidee == null) { return false; } - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { player.getPulseManager().run(new DragonCraftPulse(player, null, hidee, (int) value)); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/content/dialogue/RugMerchantDialogue.java b/Server/src/main/java/core/game/content/dialogue/RugMerchantDialogue.java index aa4ced91b..2c2e096e1 100644 --- a/Server/src/main/java/core/game/content/dialogue/RugMerchantDialogue.java +++ b/Server/src/main/java/core/game/content/dialogue/RugMerchantDialogue.java @@ -1,7 +1,7 @@ package core.game.content.dialogue; import api.Container; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.NPCDefinition; import core.game.container.impl.EquipmentContainer; import core.plugin.Initializable; @@ -288,8 +288,8 @@ public final class RugMerchantDialogue extends DialoguePlugin { player.getEquipment().replace(new Item(Items.MAGIC_CARPET_5614),EquipmentContainer.SLOT_WEAPON); player.getPacketDispatch().sendInterfaceConfig(548,69,true); - ContentAPI.registerLogoutListener(player, "magic-carpet", (pl) -> { - ContentAPI.removeItem(pl, Items.MAGIC_CARPET_5614, Container.EQUIPMENT); + registerLogoutListener(player, "magic-carpet", (pl) -> { + removeItem(pl, Items.MAGIC_CARPET_5614, Container.EQUIPMENT); return Unit.INSTANCE; }); @@ -333,7 +333,7 @@ public final class RugMerchantDialogue extends DialoguePlugin { player.animate(new Animation(-1)); player.getConfigManager().set(499, 0); - ContentAPI.clearLogoutListener(player, "magic-carpet"); + clearLogoutListener(player, "magic-carpet"); break; case 902: diff --git a/Server/src/main/java/core/game/content/dialogue/SkillDialoguePlugin.java b/Server/src/main/java/core/game/content/dialogue/SkillDialoguePlugin.java index 4b6d4ff2b..97663cd88 100644 --- a/Server/src/main/java/core/game/content/dialogue/SkillDialoguePlugin.java +++ b/Server/src/main/java/core/game/content/dialogue/SkillDialoguePlugin.java @@ -1,6 +1,6 @@ package core.game.content.dialogue; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.node.entity.player.Player; import core.game.node.entity.player.link.RunScript; import core.plugin.Initializable; @@ -58,7 +58,7 @@ public class SkillDialoguePlugin extends DialoguePlugin { if (amount != -1) { handler.create(amount, index); } else { - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { handler.create((int) value, index); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/content/global/shop/Shop.kt b/Server/src/main/java/core/game/content/global/shop/Shop.kt index dac28ee95..7a0784f94 100644 --- a/Server/src/main/java/core/game/content/global/shop/Shop.kt +++ b/Server/src/main/java/core/game/content/global/shop/Shop.kt @@ -1,7 +1,7 @@ package core.game.content.global.shop import rs09.game.world.World.ticks -import api.ContentAPI.amountInInventory +import api.* import rs09.game.system.SystemLogger.logInfo import core.game.node.entity.player.link.diary.DiaryType import core.cache.def.impl.ItemDefinition diff --git a/Server/src/main/java/core/game/content/quest/members/rovingelves/IsafdarZone.java b/Server/src/main/java/core/game/content/quest/members/rovingelves/IsafdarZone.java index 8923f07e2..83e2d0b98 100644 --- a/Server/src/main/java/core/game/content/quest/members/rovingelves/IsafdarZone.java +++ b/Server/src/main/java/core/game/content/quest/members/rovingelves/IsafdarZone.java @@ -1,6 +1,6 @@ package core.game.content.quest.members.rovingelves; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.node.entity.Entity; import core.game.node.entity.combat.ImpactHandler; import core.game.node.entity.player.Player; @@ -56,15 +56,15 @@ public final class IsafdarZone extends MapZone implements Plugin { if (e instanceof Player) { Player player = (Player) e; if(LEAF_TRAPS.contains(player.getLocation())){ - ContentAPI.sendMessage(player,LEAF_FAIL_MSG); - ContentAPI.impact(player,1, ImpactHandler.HitsplatType.NORMAL); + sendMessage(player,LEAF_FAIL_MSG); + impact(player,1, ImpactHandler.HitsplatType.NORMAL); player.teleport(LEAF_TRAP_PIT); } else if(STICK_TRAPS.contains(player.getLocation())) { - ContentAPI.sendMessage(player,STICK_FAIL_MSG); - ContentAPI.impact(player,1, ImpactHandler.HitsplatType.NORMAL); + sendMessage(player,STICK_FAIL_MSG); + impact(player,1, ImpactHandler.HitsplatType.NORMAL); } else if (WIRE_TRAPS.contains(player.getLocation())){ - ContentAPI.sendMessage(player,WIRE_FAIL_MSG); - ContentAPI.impact(player,1, ImpactHandler.HitsplatType.NORMAL); + sendMessage(player,WIRE_FAIL_MSG); + impact(player,1, ImpactHandler.HitsplatType.NORMAL); } } } diff --git a/Server/src/main/java/core/game/content/quest/members/rovingelves/RovingElvesObstacles.java b/Server/src/main/java/core/game/content/quest/members/rovingelves/RovingElvesObstacles.java index 92d572443..ecb2495f4 100644 --- a/Server/src/main/java/core/game/content/quest/members/rovingelves/RovingElvesObstacles.java +++ b/Server/src/main/java/core/game/content/quest/members/rovingelves/RovingElvesObstacles.java @@ -1,6 +1,6 @@ package core.game.content.quest.members.rovingelves; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.SceneryDefinition; import core.game.node.entity.skill.agility.AgilityHandler; import core.game.interaction.OptionHandler; @@ -200,7 +200,7 @@ public final class RovingElvesObstacles extends OptionHandler { break; case 3927: player.teleport(LEAF_TRAP_CLIMB); - ContentAPI.sendMessage(player,LEAF_LADDER_MSG); + sendMessage(player,LEAF_LADDER_MSG); break; } diff --git a/Server/src/main/java/core/game/content/zone/phasmatys/PhasmatysZone.java b/Server/src/main/java/core/game/content/zone/phasmatys/PhasmatysZone.java index 4a448c8e7..8f38faae3 100644 --- a/Server/src/main/java/core/game/content/zone/phasmatys/PhasmatysZone.java +++ b/Server/src/main/java/core/game/content/zone/phasmatys/PhasmatysZone.java @@ -1,6 +1,6 @@ package core.game.content.zone.phasmatys; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.content.global.Bones; import core.game.content.global.action.ClimbActionHandler; import core.game.interaction.Option; @@ -76,16 +76,16 @@ public final class PhasmatysZone extends MapZone implements Plugin { return true; case 5267: player.animate(Animation.create(536)); - ContentAPI.sendMessage(player, "The trapdoor opens..."); + sendMessage(player, "The trapdoor opens..."); SceneryBuilder.replace((Scenery) target, ((Scenery) target).transform(5268)); return true; case 5268: if (option.getName().equals("Close")) { player.animate(Animation.create(535)); - ContentAPI.sendMessage(player, "You close the trapdoor."); + sendMessage(player, "You close the trapdoor."); SceneryBuilder.replace((Scenery) target, ((Scenery) target).transform(5267)); } else { - ContentAPI.sendMessage(player, "You climb down through the trapdoor..."); + sendMessage(player, "You climb down through the trapdoor..."); player.getProperties().setTeleportLocation(Location.create(3669, 9888, 3)); } return true; diff --git a/Server/src/main/java/core/game/interaction/city/EdgevilleNodePlugin.java b/Server/src/main/java/core/game/interaction/city/EdgevilleNodePlugin.java index 532c83e23..a0578afed 100644 --- a/Server/src/main/java/core/game/interaction/city/EdgevilleNodePlugin.java +++ b/Server/src/main/java/core/game/interaction/city/EdgevilleNodePlugin.java @@ -1,6 +1,6 @@ package core.game.interaction.city; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.SceneryDefinition; import core.game.component.Component; import core.game.content.global.action.ClimbActionHandler; @@ -50,7 +50,7 @@ public final class EdgevilleNodePlugin extends OptionHandler { case 9262: case 9261: case 30806: - ContentAPI.sendMessage(player, "There doesn't seem to be any seeds on this rosebush."); + sendMessage(player, "There doesn't seem to be any seeds on this rosebush."); break; case 12265: ClimbActionHandler.climb(player, null, Location.create(3078, 3493, 0)); @@ -65,17 +65,17 @@ public final class EdgevilleNodePlugin extends OptionHandler { case 26933: // Edgeville Dungeon trapdoor (when closed) if (option.equalsIgnoreCase("open")) { player.animate(Animation.create(536)); - ContentAPI.sendMessage(player, "The trapdoor opens..."); + sendMessage(player, "The trapdoor opens..."); SceneryBuilder.replace(node.asScenery(), node.asScenery().transform(26934), 500); } break; case 26934: // Edgeville Dungeon trapdoor (when open) if (option.equalsIgnoreCase("close")) { player.animate(Animation.create(535)); - ContentAPI.sendMessage(player, "You close the trapdoor."); + sendMessage(player, "You close the trapdoor."); SceneryBuilder.replace(node.asScenery(), node.asScenery().transform(26933)); } else if (option.equalsIgnoreCase("climb-down")) { - ContentAPI.sendMessage(player, "You climb down through the trapdoor..."); + sendMessage(player, "You climb down through the trapdoor..."); ClimbActionHandler.climbLadder(player, (Scenery) node, option); } break; diff --git a/Server/src/main/java/core/game/interaction/city/WizardTowerPlugin.java b/Server/src/main/java/core/game/interaction/city/WizardTowerPlugin.java index a3f3f47f0..ad48e6a21 100644 --- a/Server/src/main/java/core/game/interaction/city/WizardTowerPlugin.java +++ b/Server/src/main/java/core/game/interaction/city/WizardTowerPlugin.java @@ -1,6 +1,6 @@ package core.game.interaction.city; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.NPCDefinition; import core.cache.def.impl.SceneryDefinition; import core.game.component.Component; @@ -687,7 +687,7 @@ public final class WizardTowerPlugin extends OptionHandler { } final int amount = getAmt(buttonId); if (amount == -1) {// rscript. - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { make(bark, (int) value); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/interaction/city/lumbridge/CowFieldSign.java b/Server/src/main/java/core/game/interaction/city/lumbridge/CowFieldSign.java index 38ee9713f..3c476b757 100644 --- a/Server/src/main/java/core/game/interaction/city/lumbridge/CowFieldSign.java +++ b/Server/src/main/java/core/game/interaction/city/lumbridge/CowFieldSign.java @@ -1,6 +1,8 @@ package core.game.interaction.city.lumbridge; -import api.ContentAPI; +import static api.ContentAPIKt.*; + +import api.ContentAPIKt; import core.cache.def.impl.SceneryDefinition; import core.game.content.dialogue.DialoguePlugin; import core.game.interaction.OptionHandler; @@ -44,9 +46,9 @@ public class CowFieldSign extends OptionHandler { public boolean open(Object... args){ int dailyCowDeaths = GlobalStats.getDailyCowDeaths(); if(dailyCowDeaths > 0) { - ContentAPI.sendDialogue(player, "Local cowherders have reported that " + dailyCowDeaths + " cows have been slain in this field today by passing adventurers. Farmers throughout the land fear this may be an epidemic."); + ContentAPIKt.sendDialogue(player,"Local cowherders have reported that " + dailyCowDeaths + " cows have been slain in this field today by passing adventurers. Farmers throughout the land fear this may be an epidemic."); } else { - ContentAPI.sendDialogue(player, "The Lumbridge cow population has been thriving today, without a single cow death to worry about!" ); + ContentAPIKt.sendDialogue(player,"The Lumbridge cow population has been thriving today, without a single cow death to worry about!" ); } return true; } diff --git a/Server/src/main/java/core/game/interaction/inter/ClanInterfacePlugin.java b/Server/src/main/java/core/game/interaction/inter/ClanInterfacePlugin.java index 609d052e4..dbe961776 100644 --- a/Server/src/main/java/core/game/interaction/inter/ClanInterfacePlugin.java +++ b/Server/src/main/java/core/game/interaction/inter/ClanInterfacePlugin.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -89,9 +89,9 @@ public final class ClanInterfacePlugin extends ComponentPlugin { MSPacketRepository.sendClanRename(player, ""); break; default: - ContentAPI.sendInputDialogue(player, false, "Enter clan prefix:", (value) -> { + sendInputDialogue(player, false, "Enter clan prefix:", (value) -> { String name = StringUtils.formatDisplayName((String) value); - ContentAPI.setInterfaceText(player, name, 590, 22); + setInterfaceText(player, name, 590, 22); MSPacketRepository.sendClanRename(player, name); clan.setName(name); return Unit.INSTANCE; diff --git a/Server/src/main/java/core/game/interaction/inter/GlassInterface.java b/Server/src/main/java/core/game/interaction/inter/GlassInterface.java index 7d5beec10..663beab2d 100644 --- a/Server/src/main/java/core/game/interaction/inter/GlassInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/GlassInterface.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -74,7 +74,7 @@ public final class GlassInterface extends ComponentPlugin { real = p.getInventory().getAmount(MOLTEN_GLASS); break; case 211: - ContentAPI.sendInputDialogue(p, true, "Enter the amount:", (value) -> { + sendInputDialogue(p, true, "Enter the amount:", (value) -> { make(p, def, (int) value); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/interaction/inter/GliderInterface.java b/Server/src/main/java/core/game/interaction/inter/GliderInterface.java index 16653f84b..c67df24f8 100644 --- a/Server/src/main/java/core/game/interaction/inter/GliderInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/GliderInterface.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -31,7 +31,7 @@ public final class GliderInterface extends ComponentPlugin { if (glider == null) { return true; } - ContentAPI.submitWorldPulse(new GliderPulse(1, player, glider)); + submitWorldPulse(new GliderPulse(1, player, glider)); return true; } } diff --git a/Server/src/main/java/core/game/interaction/inter/GrandExchangeInterface.java b/Server/src/main/java/core/game/interaction/inter/GrandExchangeInterface.java index 2cb7fccc7..e00ea34f3 100644 --- a/Server/src/main/java/core/game/interaction/inter/GrandExchangeInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/GrandExchangeInterface.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.CS2Mapping; import core.cache.def.impl.ItemDefinition; import core.game.component.Component; @@ -334,7 +334,7 @@ public class GrandExchangeInterface extends ComponentPlugin { setOfferAmount(player, offer, amount + 1000); return true; case 170: // value x - ContentAPI.sendInputDialogue(player, false, "Enter the amount:", (value) -> { + sendInputDialogue(player, false, "Enter the amount:", (value) -> { if (player.getInterfaceManager().getChatbox().getId() == 389) { player.getPlayerGrandExchange().openSearch(); } @@ -372,7 +372,7 @@ public class GrandExchangeInterface extends ComponentPlugin { player.getPacketDispatch().sendMessage("Please select an offer first."); return true; } - ContentAPI.sendInputDialogue(player, false, "Enter the amount:", (value) -> { + sendInputDialogue(player, false, "Enter the amount:", (value) -> { if (player.getInterfaceManager().getChatbox().getId() == 389) { player.getPlayerGrandExchange().openSearch(); } diff --git a/Server/src/main/java/core/game/interaction/inter/JewelleryInterface.java b/Server/src/main/java/core/game/interaction/inter/JewelleryInterface.java index 781e54e9c..f5ed32ce1 100644 --- a/Server/src/main/java/core/game/interaction/inter/JewelleryInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/JewelleryInterface.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.ItemDefinition; import core.game.component.Component; import core.game.component.ComponentDefinition; @@ -180,7 +180,7 @@ public final class JewelleryInterface extends ComponentPlugin { break; case 199: final JewelleryItem d = data; - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { JewelleryCrafting.make(player, d, (int) value); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/interaction/inter/LeatherCraftInterface.java b/Server/src/main/java/core/game/interaction/inter/LeatherCraftInterface.java index b6f78bc15..d265a0ac9 100644 --- a/Server/src/main/java/core/game/interaction/inter/LeatherCraftInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/LeatherCraftInterface.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -45,8 +45,8 @@ public final class LeatherCraftInterface extends ComponentPlugin { amount = player.getInventory().getAmount(new Item(LeatherCrafting.LEATHER)); break; case 199: - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { - ContentAPI.submitIndividualPulse(player, new SoftCraftPulse(player, new Item(LeatherCrafting.LEATHER), soft, (int) value)); + sendInputDialogue(player, true, "Enter the amount:", (value) -> { + submitIndividualPulse(player, new SoftCraftPulse(player, new Item(LeatherCrafting.LEATHER), soft, (int) value)); return Unit.INSTANCE; }); return true; diff --git a/Server/src/main/java/core/game/interaction/inter/SawmillPlankInterface.java b/Server/src/main/java/core/game/interaction/inter/SawmillPlankInterface.java index 688053d6d..e5e3b3784 100644 --- a/Server/src/main/java/core/game/interaction/inter/SawmillPlankInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/SawmillPlankInterface.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -66,7 +66,7 @@ public class SawmillPlankInterface extends ComponentPlugin { } if (amount == 69) { final Plank plankk = plank; - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { create(player, plankk, (int) value); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/interaction/inter/ShoppingPlugin.java b/Server/src/main/java/core/game/interaction/inter/ShoppingPlugin.java index 298c44972..56c2c0c6b 100644 --- a/Server/src/main/java/core/game/interaction/inter/ShoppingPlugin.java +++ b/Server/src/main/java/core/game/interaction/inter/ShoppingPlugin.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; diff --git a/Server/src/main/java/core/game/interaction/inter/SmeltingInterface.java b/Server/src/main/java/core/game/interaction/inter/SmeltingInterface.java index 609c12d75..be454ed7d 100644 --- a/Server/src/main/java/core/game/interaction/inter/SmeltingInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/SmeltingInterface.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -32,8 +32,8 @@ public class SmeltingInterface extends ComponentPlugin { } if (barType.getAmount() == -1) { player.getInterfaceManager().closeChatbox(); - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { - ContentAPI.submitIndividualPulse(player, new SmeltingPulse(player, null, barType.getBar(), (int) value)); + sendInputDialogue(player, true, "Enter the amount:", (value) -> { + submitIndividualPulse(player, new SmeltingPulse(player, null, barType.getBar(), (int) value)); return Unit.INSTANCE; }); } else { diff --git a/Server/src/main/java/core/game/interaction/inter/SmithingInterface.java b/Server/src/main/java/core/game/interaction/inter/SmithingInterface.java index de7f8d5cc..d1064874e 100644 --- a/Server/src/main/java/core/game/interaction/inter/SmithingInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/SmithingInterface.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -38,7 +38,7 @@ public class SmithingInterface extends ComponentPlugin { p.getGameAttributes().setAttribute("smith-bar", bar); p.getGameAttributes().setAttribute("smith-item", item); if (amount == -1) { - ContentAPI.sendInputDialogue(p, true, "Enter the amount:", (value) -> { + sendInputDialogue(p, true, "Enter the amount:", (value) -> { p.getPulseManager().run(new SmithingPulse(p, new Item((int) p.getGameAttributes().getAttribute("smith-item"), (int) value), (Bars) p.getGameAttributes().getAttribute("smith-bar"), (int) value)); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/interaction/inter/SpinningInterface.java b/Server/src/main/java/core/game/interaction/inter/SpinningInterface.java index a8a58c472..4c29853b7 100644 --- a/Server/src/main/java/core/game/interaction/inter/SpinningInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/SpinningInterface.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.ItemDefinition; import core.game.component.Component; import core.game.component.ComponentDefinition; @@ -45,8 +45,8 @@ public class SpinningInterface extends ComponentPlugin { amt = p.getInventory().getAmount(new Item(spin.getNeed())); break; case 199: - ContentAPI.sendInputDialogue(p, true, "Enter the amount:", (value) -> { - ContentAPI.submitIndividualPulse(p, new SpinningPulse(p, new Item(spin.getNeed(), 1), (int) value, spin)); + sendInputDialogue(p, true, "Enter the amount:", (value) -> { + submitIndividualPulse(p, new SpinningPulse(p, new Item(spin.getNeed(), 1), (int) value, spin)); return Unit.INSTANCE; }); break; diff --git a/Server/src/main/java/core/game/interaction/inter/TanningInterface.java b/Server/src/main/java/core/game/interaction/inter/TanningInterface.java index fcb912e96..5c1952984 100644 --- a/Server/src/main/java/core/game/interaction/inter/TanningInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/TanningInterface.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -75,7 +75,7 @@ public class TanningInterface extends ComponentPlugin { case 124: amount = 10; case 199: - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { TanningProduct.tan(player, (int) value, deff); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/interaction/inter/TradeInterfacePlugin.java b/Server/src/main/java/core/game/interaction/inter/TradeInterfacePlugin.java index 88fb909be..4537fb0fa 100644 --- a/Server/src/main/java/core/game/interaction/inter/TradeInterfacePlugin.java +++ b/Server/src/main/java/core/game/interaction/inter/TradeInterfacePlugin.java @@ -1,6 +1,6 @@ package core.game.interaction.inter; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -68,7 +68,7 @@ public final class TradeInterfacePlugin extends ComponentPlugin { module.getContainer().withdraw(slot, module.getContainer().getAmount(module.getContainer().get(slot))); break; case 234: - ContentAPI.sendInputDialogue(player, false, "Enter the amount:", (value) -> { + sendInputDialogue(player, false, "Enter the amount:", (value) -> { String s = value.toString(); s = s.replace("k","000"); s = s.replace("K","000"); @@ -102,7 +102,7 @@ public final class TradeInterfacePlugin extends ComponentPlugin { module.getContainer().offer(slot, player.getInventory().getAmount(player.getInventory().get(slot))); break; case 234: - ContentAPI.sendInputDialogue(player, false, "Enter the amount:", (value) -> { + sendInputDialogue(player, false, "Enter the amount:", (value) -> { String s = value.toString(); s = s.replace("k","000"); s = s.replace("K","000"); diff --git a/Server/src/main/java/core/game/interaction/item/CasketPlugin.java b/Server/src/main/java/core/game/interaction/item/CasketPlugin.java index 2c8f9cbf8..a5888d9cd 100644 --- a/Server/src/main/java/core/game/interaction/item/CasketPlugin.java +++ b/Server/src/main/java/core/game/interaction/item/CasketPlugin.java @@ -3,7 +3,7 @@ package core.game.interaction.item; import java.util.ArrayList; import java.util.List; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.ItemDefinition; import core.game.interaction.OptionHandler; import core.game.node.Node; @@ -51,7 +51,7 @@ public final class CasketPlugin extends OptionHandler { final Item reward = table.roll().get(0); player.getInventory().remove((Item) node); player.getDialogueInterpreter().sendItemMessage(reward, "You open the casket. Inside you find " + (reward.getAmount() > 1 ? "some" : (StringUtils.isPlusN(reward.getName()) ? "an" : "a")) + " " + reward.getName().toLowerCase() + "."); - ContentAPI.addItemOrDrop(player, reward.getId(), reward.getAmount()); + addItemOrDrop(player, reward.getId(), reward.getAmount()); return true; } diff --git a/Server/src/main/java/core/game/interaction/item/ExplorersRingPlugin.kt b/Server/src/main/java/core/game/interaction/item/ExplorersRingPlugin.kt index 46ab2b00e..6e1d6d91c 100644 --- a/Server/src/main/java/core/game/interaction/item/ExplorersRingPlugin.kt +++ b/Server/src/main/java/core/game/interaction/item/ExplorersRingPlugin.kt @@ -1,6 +1,6 @@ package core.game.interaction.item -import api.ContentAPI +import api.* import core.Util import core.cache.def.impl.ItemDefinition import core.plugin.Initializable @@ -36,28 +36,28 @@ class ExplorersRingPlugin : InteractionListener() { on(RINGS, ITEM, "run-replenish"){player, node -> val charges = getStoreFile().getInt(player.username.toLowerCase() + ":run") if (charges >= getRingLevel(node.id)) { - ContentAPI.sendMessage(player,"You have used all the charges you can for one day.") + sendMessage(player,"You have used all the charges you can for one day.") return@on true } player.settings.updateRunEnergy(-50.0) getStoreFile()[player.username.toLowerCase() + ":run"] = charges + 1 - ContentAPI.sendMessage(player,"You feel refreshed as the ring revitalises you and a charge is used up.") - ContentAPI.visualize(player, 9988, 1733) + sendMessage(player,"You feel refreshed as the ring revitalises you and a charge is used up.") + visualize(player, 9988, 1733) return@on true } on(RINGS, ITEM, "low-alchemy"){player, _ -> - if (!ContentAPI.hasLevelStat(player, Skills.MAGIC, 21)) { - ContentAPI.sendMessage(player,"You need a Magic level of 21 in order to do that.") + if (!hasLevelStat(player, Skills.MAGIC, 21)) { + sendMessage(player,"You need a Magic level of 21 in order to do that.") return@on true } if(getStoreFile().getBoolean(player.username.toLowerCase() + ":alchs")){ - ContentAPI.sendMessage(player, "You have claimed all the charges you can for one day.") + sendMessage(player, "You have claimed all the charges you can for one day.") return@on true } - ContentAPI.sendMessage(player,"You grant yourself with 30 free low alchemy charges.") // todo this implementation is not correct, see https://www.youtube.com/watch?v=UbUIF2Kw_Dw + sendMessage(player,"You grant yourself with 30 free low alchemy charges.") // todo this implementation is not correct, see https://www.youtube.com/watch?v=UbUIF2Kw_Dw getStoreFile()[player.username.toLowerCase() + ":alchs"] = true @@ -71,7 +71,7 @@ class ExplorersRingPlugin : InteractionListener() { on(RINGS, ITEM, "operate", "rub"){player, node -> if(getRingLevel(node.id) < 3){ - ContentAPI.sendMessage(player, "This item can not be operated.") + sendMessage(player, "This item can not be operated.") return@on true } @@ -81,7 +81,7 @@ class ExplorersRingPlugin : InteractionListener() { } fun teleport(player: Player){ - ContentAPI.teleport(player, CABBAGE_PORT, TeleportType.CABBAGE) + teleport(player, CABBAGE_PORT, TeleportType.CABBAGE) } fun getRingLevel(id: Int): Int{ diff --git a/Server/src/main/java/core/game/interaction/item/SilverSicklePlugin.java b/Server/src/main/java/core/game/interaction/item/SilverSicklePlugin.java index 632db87a3..0d6a95478 100644 --- a/Server/src/main/java/core/game/interaction/item/SilverSicklePlugin.java +++ b/Server/src/main/java/core/game/interaction/item/SilverSicklePlugin.java @@ -1,6 +1,6 @@ package core.game.interaction.item; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.ItemDefinition; import core.game.interaction.OptionHandler; import core.game.node.Node; @@ -32,7 +32,7 @@ public final class SilverSicklePlugin extends OptionHandler { player.getPacketDispatch().sendAnimation(9021); NSUtils.castBloom(player); } else { - ContentAPI.sendDialogue(player, "You must complete Nature Spirit to use this."); + sendDialogue(player, "You must complete Nature Spirit to use this."); } return true; } diff --git a/Server/src/main/java/core/game/interaction/item/toys/ChocatriceCape.java b/Server/src/main/java/core/game/interaction/item/toys/ChocatriceCape.java deleted file mode 100644 index 3a7fed3bc..000000000 --- a/Server/src/main/java/core/game/interaction/item/toys/ChocatriceCape.java +++ /dev/null @@ -1,26 +0,0 @@ -package core.game.interaction.item.toys; - -import core.cache.def.impl.ItemDefinition; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.player.Player; -import core.game.world.update.flag.context.Animation; -import core.game.world.update.flag.context.Graphics; -import core.plugin.Initializable; -import core.plugin.Plugin; - -@Initializable -public class ChocatriceCape extends OptionHandler { - @Override - public Plugin newInstance(Object arg) throws Throwable { - ItemDefinition.forId(12634).getHandlers().put("option:operate",this); - return this; - } - - @Override - public boolean handle(Player player, Node node, String option) { - player.getLocks().lockInteractions(2); - player.getAnimator().animate(new Animation(8903),new Graphics(1566)); - return true; - } -} diff --git a/Server/src/main/java/core/game/interaction/item/toys/DiangoReclaimInterface.java b/Server/src/main/java/core/game/interaction/item/toys/DiangoReclaimInterface.java index 17325e390..159a14220 100644 --- a/Server/src/main/java/core/game/interaction/item/toys/DiangoReclaimInterface.java +++ b/Server/src/main/java/core/game/interaction/item/toys/DiangoReclaimInterface.java @@ -1,6 +1,5 @@ package core.game.interaction.item.toys; -import api.ContentAPI; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -10,12 +9,17 @@ import core.game.node.item.Item; import core.plugin.Initializable; import core.plugin.Plugin; import core.game.content.holiday.easter.BasketofEggsEvent; +import org.rs09.consts.Items; +import rs09.game.interaction.item.ToyListeners; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; +import static api.ContentAPIKt.inEquipment; +import static api.ContentAPIKt.inInventory; + /** * Handles diango's item reclaiming interface @@ -25,14 +29,13 @@ import java.util.Objects; public class DiangoReclaimInterface extends ComponentPlugin { private static final int COMPONENT_ID = 468; public static final List ITEMS = new ArrayList<>(20); - public static final Item[] HOLIDAY_ITEMS = {YoyoPlugin.YOYO, ReindeerHatPlugin.ReindeerHat, BasketofEggsEvent.RUBBER_CHICKEN,ZombieHeadPlugin.ZOMBIE_HEAD, new Item(6857), new Item(6856), new Item(6858), new Item(6859), new Item(6860), new Item(6861), new Item(6862), new Item(6863), new Item(9920), new Item(9921),new Item(9922), new Item(9923), new Item(9924), new Item(9925), new Item(11019), new Item(11020), new Item(11021), new Item(11022), new Item(11789), new Item(11949), new Item(12634), new Item(14076), new Item(14077), new Item(14081),new Item(14595), new Item(14602), new Item(14603), new Item(14605), new Item(14654)}; + public static final Item[] HOLIDAY_ITEMS = {new Item(Items.YO_YO_4079), new Item(Items.REINDEER_HAT_10507), BasketofEggsEvent.RUBBER_CHICKEN,new Item(Items.ZOMBIE_HEAD_6722), new Item(6857), new Item(6856), new Item(6858), new Item(6859), new Item(6860), new Item(6861), new Item(6862), new Item(6863), new Item(9920), new Item(9921),new Item(9922), new Item(9923), new Item(9924), new Item(9925), new Item(11019), new Item(11020), new Item(11021), new Item(11022), new Item(11789), new Item(11949), new Item(12634), new Item(14076), new Item(14077), new Item(14081),new Item(14595), new Item(14602), new Item(14603), new Item(14605), new Item(14654), new Item(Items.RED_MARIONETTE_6867), new Item(Items.GREEN_MARIONETTE_6866), new Item(Items.BLUE_MARIONETTE_6865)}; //initialize the plugin, add lists of items to the ITEMS list... @Override public Plugin newInstance(Object arg) throws Throwable { ComponentDefinition.put(COMPONENT_ID,this); ITEMS.addAll(Arrays.asList(HOLIDAY_ITEMS)); - ITEMS.addAll(MarionettePlugin.MARIONETTES); return this; } @@ -47,7 +50,7 @@ public class DiangoReclaimInterface extends ComponentPlugin { Item[] reclaimables = ITEMS.stream().filter(Objects::nonNull) .filter(item -> !player.getEquipment().containsItem(item) && !player.getInventory().containsItem(item) && !player.getBank().containsItem(item) && (item.getId() != 14654 - || (!(ContentAPI.inInventory(player, 14655, 1) || ContentAPI.inEquipment(player, 14656, 1)) && player.getAttribute("sotr:purchased",false)) + || (!(inInventory(player, 14655, 1) || inEquipment(player, 14656, 1)) && player.getAttribute("sotr:purchased",false)) )) .toArray(Item[]::new); diff --git a/Server/src/main/java/core/game/interaction/item/toys/MarionettePlugin.java b/Server/src/main/java/core/game/interaction/item/toys/MarionettePlugin.java deleted file mode 100644 index 33dbe0917..000000000 --- a/Server/src/main/java/core/game/interaction/item/toys/MarionettePlugin.java +++ /dev/null @@ -1,71 +0,0 @@ -package core.game.interaction.item.toys; - -import core.cache.def.impl.ItemDefinition; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; -import core.game.world.update.flag.context.Animation; -import core.game.world.update.flag.context.Graphics; -import core.plugin.Initializable; -import core.plugin.Plugin; - -import java.util.Arrays; -import java.util.List; - -@Initializable -public class MarionettePlugin extends OptionHandler { - public final static List MARIONETTES = Arrays.asList(new Item(6865), new Item(6866), new Item(6867)); - private final Animation JUMP = new Animation(3003); - private final Animation WALK = new Animation(3004); - private final Animation BOW = new Animation(3005); - private final Animation DANCE = new Animation(3006); - private final int[][] GFX = new int[][] {{507,508,509,510}, {511,512,513,514}, {515,516,517,518}}; - - @Override - public Plugin newInstance(Object arg) throws Throwable { - for(Item item : MARIONETTES) { - ItemDefinition def = item.getDefinition(); - def.getHandlers().put("option:jump",this); - def.getHandlers().put("option:walk",this); - def.getHandlers().put("option:bow",this); - def.getHandlers().put("option:dance",this); - } - return this; - } - - @Override - public boolean handle(Player player, Node node, String option) { - int index = 0; - switch(node.getId()){ - case 6865: - index = 1; - break; - case 6866: - index = 2; - break; - case 6867: - index = 0; - break; - } - switch(option){ - case "jump": - player.getLocks().lockInteractions(2); - player.getAnimator().animate(JUMP, new Graphics(GFX[index][0])); - break; - case "walk": - player.getLocks().lockInteractions(2); - player.getAnimator().animate(WALK, new Graphics(GFX[index][1])); - break; - case "bow": - player.getLocks().lockInteractions(2); - player.getAnimator().animate(BOW, new Graphics(GFX[index][2])); - break; - case "dance": - player.getLocks().lockInteractions(2); - player.getAnimator().animate(DANCE, new Graphics(GFX[index][3])); - break; - } - return false; - } -} diff --git a/Server/src/main/java/core/game/interaction/item/toys/ReindeerHatPlugin.java b/Server/src/main/java/core/game/interaction/item/toys/ReindeerHatPlugin.java deleted file mode 100644 index 530a414e9..000000000 --- a/Server/src/main/java/core/game/interaction/item/toys/ReindeerHatPlugin.java +++ /dev/null @@ -1,27 +0,0 @@ -package core.game.interaction.item.toys; - -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; -import core.game.world.update.flag.context.Animation; -import core.plugin.Initializable; -import core.plugin.Plugin; - -@Initializable -public class ReindeerHatPlugin extends OptionHandler { - public final static Item ReindeerHat = new Item(10507); - - @Override - public Plugin newInstance(Object arg) throws Throwable { - ReindeerHat.getDefinition().getHandlers().put("option:operate",this); - return null; - } - - @Override - public boolean handle(Player player, Node node, String option) { - player.getLocks().lockInteractions(2); - player.getAnimator().animate(new Animation(5059)); - return true; - } -} diff --git a/Server/src/main/java/core/game/interaction/item/toys/SnowGlobePlugin.java b/Server/src/main/java/core/game/interaction/item/toys/SnowGlobePlugin.java index 22e5454b7..92185eccb 100644 --- a/Server/src/main/java/core/game/interaction/item/toys/SnowGlobePlugin.java +++ b/Server/src/main/java/core/game/interaction/item/toys/SnowGlobePlugin.java @@ -17,9 +17,6 @@ import rs09.plugin.PluginManager; @Initializable public class SnowGlobePlugin extends OptionHandler { - - private final Animation SHAKE = new Animation(7535);//Initial Shake - private final Animation HOLDFACE = new Animation(7536);//Immediately after shake, player holds the snow globe to face private static final Component INTERFACE = new Component(659);//After HOLDFACE this interface is displayed, player either clicks 'continue' for inv of snowballs, or 'close' for no snowballs private final Animation DOWNFAST = new Animation(7537);//Used when player hit 'close' on the interface private final Animation DOWNSLOW = new Animation(7538);//Used when the player hit 'continue' on the interface @@ -29,28 +26,11 @@ public class SnowGlobePlugin extends OptionHandler { @Override public Plugin newInstance(Object arg) throws Throwable { PluginManager.definePlugin(new SnowGlobeInterface()); - ItemDefinition.forId(11949).getHandlers().put("option:shake",this); return this; } @Override public boolean handle(Player player, Node node, String option) { - player.getLocks().lockInteractions(2); - player.getAnimator().animate(SHAKE); - player.getPulseManager().run(new Pulse(3) { - @Override - public boolean pulse() { - player.getAnimator().animate(HOLDFACE); - player.getPulseManager().run(new Pulse(1){ - @Override - public boolean pulse(){ - player.getInterfaceManager().open(INTERFACE); - return true; - } - }); - return true; - } - }); return true; } diff --git a/Server/src/main/java/core/game/interaction/item/toys/YoyoPlugin.java b/Server/src/main/java/core/game/interaction/item/toys/YoyoPlugin.java deleted file mode 100644 index 249ea9fc4..000000000 --- a/Server/src/main/java/core/game/interaction/item/toys/YoyoPlugin.java +++ /dev/null @@ -1,53 +0,0 @@ -package core.game.interaction.item.toys; - -import core.cache.def.impl.ItemDefinition; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; -import core.game.world.update.flag.context.Animation; -import core.plugin.Initializable; -import core.plugin.Plugin; - -@Initializable -public class YoyoPlugin extends OptionHandler { - final static Animation PLAY = new Animation(1457); - final static Animation LOOP = new Animation(1458); - final static Animation WALK = new Animation(1459); - final static Animation CRAZY = new Animation(1460); - final static Item YOYO = new Item(4079); - - @Override - public Plugin newInstance(Object arg) throws Throwable { - ItemDefinition def = ItemDefinition.forId(YOYO.getId()); - def.getHandlers().put("option:play",this); - def.getHandlers().put("option:loop",this); - def.getHandlers().put("option:walk",this); - def.getHandlers().put("option:crazy",this); - return this; - } - - @Override - public boolean handle(Player player, Node node, String option) { - - switch(option){ - case "play": - player.getLocks().lockInteractions(2); - player.getAnimator().animate(PLAY); - break; - case "loop": - player.getLocks().lockInteractions(2); - player.getAnimator().animate(LOOP); - break; - case "walk": - player.getLocks().lockInteractions(2); - player.getAnimator().animate(WALK); - break; - case "crazy": - player.getLocks().lockInteractions(2); - player.getAnimator().animate(CRAZY); - break; - } - return true; - } -} diff --git a/Server/src/main/java/core/game/interaction/item/toys/ZombieHeadPlugin.java b/Server/src/main/java/core/game/interaction/item/toys/ZombieHeadPlugin.java deleted file mode 100644 index d5176feb0..000000000 --- a/Server/src/main/java/core/game/interaction/item/toys/ZombieHeadPlugin.java +++ /dev/null @@ -1,44 +0,0 @@ -package core.game.interaction.item.toys; - -import core.cache.def.impl.ItemDefinition; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; -import core.game.world.update.flag.context.Animation; -import core.plugin.Initializable; -import core.plugin.Plugin; - -@Initializable -public class ZombieHeadPlugin extends OptionHandler { - static final Item ZOMBIE_HEAD = new Item(6722); - static final Animation TALK_AT = new Animation(2840); - static final Animation DISPLAY = new Animation(2844); - @Override - public Plugin newInstance(Object arg) throws Throwable { - ItemDefinition def = ItemDefinition.forId(ZOMBIE_HEAD.getId()); - def.getHandlers().put("option:talk-at",this); - def.getHandlers().put("option:display",this); - def.getHandlers().put("option:question",this); - return this; - } - - @Override - public boolean handle(Player player, Node node, String option) { - switch(option){ - case "talk-at": - player.getLocks().lockInteractions(2); - player.getAnimator().animate(TALK_AT); - player.sendChat("Alas!"); - break; - case "display": - player.getLocks().lockInteractions(2); - player.getAnimator().animate(DISPLAY); - player.sendChat("MWAHHAHAHAHAHAHA"); - break; - case "question": - //player.getDialogueInterpreter().open() - } - return true; - } -} diff --git a/Server/src/main/java/core/game/interaction/item/withitem/FruitCuttingPlugin.java b/Server/src/main/java/core/game/interaction/item/withitem/FruitCuttingPlugin.java index 51f27f988..6b0fc2829 100644 --- a/Server/src/main/java/core/game/interaction/item/withitem/FruitCuttingPlugin.java +++ b/Server/src/main/java/core/game/interaction/item/withitem/FruitCuttingPlugin.java @@ -1,6 +1,6 @@ package core.game.interaction.item.withitem; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.plugin.Initializable; import kotlin.Unit; @@ -222,7 +222,7 @@ public final class FruitCuttingPlugin extends UseWithHandler { amount = 5; break; case 4: - ContentAPI.sendInputDialogue(player, false, "Enter the amount:", (value) -> { + sendInputDialogue(player, false, "Enter the amount:", (value) -> { String s = value.toString(); s = s.replace("k","000"); s = s.replace("K","000"); diff --git a/Server/src/main/java/core/game/interaction/item/withitem/PoisonWeaponPlugin.java b/Server/src/main/java/core/game/interaction/item/withitem/PoisonWeaponPlugin.java index 03c8203ff..2a88511af 100644 --- a/Server/src/main/java/core/game/interaction/item/withitem/PoisonWeaponPlugin.java +++ b/Server/src/main/java/core/game/interaction/item/withitem/PoisonWeaponPlugin.java @@ -1,6 +1,6 @@ package core.game.interaction.item.withitem; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.interaction.NodeUsageEvent; import core.game.interaction.UseWithHandler; import core.game.node.entity.player.Player; @@ -299,8 +299,8 @@ public class PoisonWeaponPlugin extends UseWithHandler { } int amt = Math.min(weaponItem.getAmount(), 5); player.getInventory().remove(new Item(weaponItem.getId(), amt)); - ContentAPI.addItemOrDrop(player, product, amt); - ContentAPI.addItemOrDrop(player, Items.VIAL_229, 1); + addItemOrDrop(player, product, amt); + addItemOrDrop(player, Items.VIAL_229, 1); player.getPacketDispatch().sendMessage("You poison the " + weaponItem.getName().toLowerCase() + "."); } diff --git a/Server/src/main/java/core/game/interaction/item/withobject/WaterSourcePlugin.java b/Server/src/main/java/core/game/interaction/item/withobject/WaterSourcePlugin.java index 11867b09c..09670bfcb 100644 --- a/Server/src/main/java/core/game/interaction/item/withobject/WaterSourcePlugin.java +++ b/Server/src/main/java/core/game/interaction/item/withobject/WaterSourcePlugin.java @@ -1,6 +1,6 @@ package core.game.interaction.item.withobject; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.plugin.Initializable; import org.rs09.consts.Items; import core.game.interaction.NodeUsageEvent; @@ -41,7 +41,7 @@ public final class WaterSourcePlugin extends UseWithHandler { @Override public Plugin newInstance(Object arg) throws Throwable { for (int i : OBJECTS) { - if(ContentAPI.sceneryDefinition(i).getName().toLowerCase().contains("well")){ + if(sceneryDefinition(i).getName().toLowerCase().contains("well")){ continue; } addHandler(i, OBJECT_TYPE, this); diff --git a/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt b/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt index 8a2930716..b1a67f4c6 100644 --- a/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt +++ b/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt @@ -1,6 +1,6 @@ package core.game.interaction.npc -import api.ContentAPI +import api.* import core.cache.def.impl.NPCDefinition import core.game.component.Component import core.plugin.Initializable @@ -27,16 +27,16 @@ class NPCTradePlugin : InteractionListener() { return@on true } if (npc.id == 7601) { - ContentAPI.openInterface(player, 732) + openInterface(player, 732) return@on true } return@on npc.openShop(player) } on(NPCs.SIEGFRIED_ERKLE_933, NPC, "trade"){player, node -> - val points = ContentAPI.getQP(player) + val points = getQP(player) if(points < 40){ - ContentAPI.sendNPCDialogue(player, NPCs.SIEGFRIED_ERKLE_933, "I'm sorry, adventurer, but you need 40 quest points to buy from me.") + sendNPCDialogue(player, NPCs.SIEGFRIED_ERKLE_933, "I'm sorry, adventurer, but you need 40 quest points to buy from me.") return@on true } node.asNpc().openShop(player) diff --git a/Server/src/main/java/core/game/interaction/npc/ZaffPlugin.kt b/Server/src/main/java/core/game/interaction/npc/ZaffPlugin.kt index 01693be2f..c398b6ce7 100644 --- a/Server/src/main/java/core/game/interaction/npc/ZaffPlugin.kt +++ b/Server/src/main/java/core/game/interaction/npc/ZaffPlugin.kt @@ -1,7 +1,7 @@ package core.game.interaction.npc import api.Container -import api.ContentAPI +import api.* import api.InputType import core.cache.def.impl.NPCDefinition import core.plugin.Initializable @@ -311,7 +311,7 @@ class ZaffPlugin : OptionHandler() { 1001 -> when(buttonId){ 1 -> { end() - ContentAPI.openDialogue(player, 9679, npc) + openDialogue(player, 9679, npc) } 2 -> { end() @@ -393,13 +393,13 @@ class ZaffPlugin : OptionHandler() { ) stage = 1 } - 1 -> end().also { ContentAPI.sendInputDialogue(player, InputType.NUMERIC, "Enter an amount:"){ value -> + 1 -> end().also { sendInputDialogue(player, InputType.NUMERIC, "Enter an amount:"){ value -> ammount = getStoreFile().getInt(player.username.toLowerCase()) var amt = value as Int if(amt > maxStaffs - ammount) amt = maxStaffs - ammount val coinage = amt * 8000 - if(!ContentAPI.inInventory(player, Items.COINS_995, coinage)){ - ContentAPI.sendDialogue(player, "You can't afford that many.") + if(!inInventory(player, Items.COINS_995, coinage)){ + sendDialogue(player, "You can't afford that many.") return@sendInputDialogue } @@ -407,8 +407,8 @@ class ZaffPlugin : OptionHandler() { return@sendInputDialogue } - if(ContentAPI.removeItem(player, Item(Items.COINS_995, coinage), Container.INVENTORY)){ - ContentAPI.addItem(player, Items.BATTLESTAFF_1392, amt) + if(removeItem(player, Item(Items.COINS_995, coinage), Container.INVENTORY)){ + addItem(player, Items.BATTLESTAFF_1392, amt) ZaffPlugin.getStoreFile()[player.username.toLowerCase()] = amt + ammount } } } diff --git a/Server/src/main/java/core/game/interaction/object/BankingPlugin.java b/Server/src/main/java/core/game/interaction/object/BankingPlugin.java index d129d418f..00d65a7a6 100644 --- a/Server/src/main/java/core/game/interaction/object/BankingPlugin.java +++ b/Server/src/main/java/core/game/interaction/object/BankingPlugin.java @@ -1,6 +1,6 @@ package core.game.interaction.object; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.NPCDefinition; import core.cache.def.impl.SceneryDefinition; import core.game.component.CloseEvent; @@ -372,7 +372,7 @@ public final class BankingPlugin extends OptionHandler { amount = p.getBank().getLastAmountX(); break; case 234: - ContentAPI.sendInputDialogue(p, false, "Enter the amount:", (value) -> { + sendInputDialogue(p, false, "Enter the amount:", (value) -> { String s = value.toString(); s = s.replace("k","000"); s = s.replace("K","000"); @@ -452,7 +452,7 @@ public final class BankingPlugin extends OptionHandler { p.getBank().addItem(slot, p.getBank().getLastAmountX()); break; case 234: - ContentAPI.sendInputDialogue(p, false, "Enter the amount:", (value) -> { + sendInputDialogue(p, false, "Enter the amount:", (value) -> { String s = value.toString(); s = s.replace("k","000"); s = s.replace("K","000"); @@ -522,7 +522,7 @@ public final class BankingPlugin extends OptionHandler { }); return true; case 234: - ContentAPI.sendInputDialogue(p, false, "Enter the amount:", (value) -> { + sendInputDialogue(p, false, "Enter the amount:", (value) -> { String s = value.toString(); s = s.replace("k","000"); s = s.replace("K","000"); diff --git a/Server/src/main/java/core/game/node/entity/combat/spell/CurseSpells.java b/Server/src/main/java/core/game/node/entity/combat/spell/CurseSpells.java index 4356c7853..7adb3e2d8 100644 --- a/Server/src/main/java/core/game/node/entity/combat/spell/CurseSpells.java +++ b/Server/src/main/java/core/game/node/entity/combat/spell/CurseSpells.java @@ -1,6 +1,6 @@ package core.game.node.entity.combat.spell; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.node.entity.skill.Skills; import core.game.node.entity.skill.magic.Runes; import core.game.node.entity.Entity; diff --git a/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java b/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java index 9f6177596..339e9ca3a 100644 --- a/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java +++ b/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java @@ -1,6 +1,6 @@ package core.game.node.entity.npc.drop; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.NPCDefinition; import core.game.content.global.Bones; import core.game.ge.GrandExchangeDatabase; @@ -113,7 +113,7 @@ public final class NPCDropTables { } return; } - ContentAPI.announceIfRare(player, item); + announceIfRare(player, item); if(item.getId() == 6199 && player instanceof Player){ player.sendMessage("A mystery box has fallen on the ground."); } diff --git a/Server/src/main/java/core/game/node/entity/player/Player.java b/Server/src/main/java/core/game/node/entity/player/Player.java index 78fc93e46..87dd1591e 100644 --- a/Server/src/main/java/core/game/node/entity/player/Player.java +++ b/Server/src/main/java/core/game/node/entity/player/Player.java @@ -1,6 +1,5 @@ package core.game.node.entity.player; -import api.ContentAPI; import core.game.component.Component; import core.game.container.Container; import core.game.container.impl.BankContainer; @@ -94,6 +93,7 @@ import rs09.tools.TickUtilsKt; import java.util.*; +import static api.ContentAPIKt.*; import static rs09.game.node.entity.player.info.stats.StatAttributeKeysKt.STATS_BASE; import static rs09.game.node.entity.player.info.stats.StatAttributeKeysKt.STATS_DEATHS; import static rs09.tools.stringtools.GlobalsKt.colorize; @@ -801,11 +801,11 @@ public class Player extends Entity { } else { return false; } - boolean legs = ContentAPI.inEquipment(this, Items.VOID_KNIGHT_ROBE_8840, 1); - boolean top = ContentAPI.inEquipment(this, Items.VOID_KNIGHT_TOP_8839, 1) - || ContentAPI.inEquipment(this, Items.VOID_KNIGHT_TOP_10611, 1); - boolean gloves = ContentAPI.inEquipment(this, Items.VOID_KNIGHT_GLOVES_8842, 1); - return ContentAPI.inEquipment(this, helm, 1) && legs && top && gloves; + boolean legs = inEquipment(this, Items.VOID_KNIGHT_ROBE_8840, 1); + boolean top = inEquipment(this, Items.VOID_KNIGHT_TOP_8839, 1) + || inEquipment(this, Items.VOID_KNIGHT_TOP_10611, 1); + boolean gloves = inEquipment(this, Items.VOID_KNIGHT_GLOVES_8842, 1); + return inEquipment(this, helm, 1) && legs && top && gloves; } /** diff --git a/Server/src/main/java/core/game/node/entity/player/link/request/trade/TradeContainer.java b/Server/src/main/java/core/game/node/entity/player/link/request/trade/TradeContainer.java index c9fa341e1..aa3419eb7 100644 --- a/Server/src/main/java/core/game/node/entity/player/link/request/trade/TradeContainer.java +++ b/Server/src/main/java/core/game/node/entity/player/link/request/trade/TradeContainer.java @@ -1,6 +1,6 @@ package core.game.node.entity.player.link.request.trade; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.ItemDefinition; import core.game.container.*; import core.game.node.entity.player.Player; @@ -167,7 +167,7 @@ public final class TradeContainer extends Container { return false; } if ((playerIsBot || targetIsBot) && (playerIP.equals(targetIP) || playerMac.equals(targetMac) || playerHost.equals(targetHost))){ - ContentAPI.sendMessage(player, colorize("%RYou can not trade items with your own bot accounts.")); + sendMessage(player, colorize("%RYou can not trade items with your own bot accounts.")); return false; } if (item.getName().equals("Coins") && item.getId() != 995) { diff --git a/Server/src/main/java/core/game/node/entity/skill/agility/AgilityHandler.java b/Server/src/main/java/core/game/node/entity/skill/agility/AgilityHandler.java index c8a8c0b90..e7b35b0df 100644 --- a/Server/src/main/java/core/game/node/entity/skill/agility/AgilityHandler.java +++ b/Server/src/main/java/core/game/node/entity/skill/agility/AgilityHandler.java @@ -1,6 +1,6 @@ package core.game.node.entity.skill.agility; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.node.entity.player.link.TeleportManager; import core.game.node.entity.skill.Skills; import core.game.interaction.MovementPulse; @@ -102,21 +102,21 @@ public final class AgilityHandler { */ public static void fail(final Player player, int delay, final Location dest, Animation anim, final int hit, final String message) { if (anim != null) { - ContentAPI.animate(player, anim, true); - ContentAPI.submitWorldPulse(new Pulse(ContentAPI.animationDuration(anim), player) { + animate(player, anim, true); + submitWorldPulse(new Pulse(animationDuration(anim), player) { boolean dmg = false; @Override public boolean pulse() { - ContentAPI.teleport(player, dest, TeleportManager.TeleportType.INSTANT); - ContentAPI.animate(player, Animation.RESET, true); + teleport(player, dest, TeleportManager.TeleportType.INSTANT); + animate(player, Animation.RESET, true); if (!dmg) { if (hit > 0) { player.getImpactHandler().setDisabledTicks(0); - ContentAPI.impact(player, hit, HitsplatType.NORMAL); + impact(player, hit, HitsplatType.NORMAL); } if (message != null) { - ContentAPI.sendMessage(player, message); + sendMessage(player, message); } dmg = true; } diff --git a/Server/src/main/java/core/game/node/entity/skill/construction/PortalOptionPlugin.java b/Server/src/main/java/core/game/node/entity/skill/construction/PortalOptionPlugin.java index 7dd543a29..02cb759ab 100644 --- a/Server/src/main/java/core/game/node/entity/skill/construction/PortalOptionPlugin.java +++ b/Server/src/main/java/core/game/node/entity/skill/construction/PortalOptionPlugin.java @@ -1,7 +1,7 @@ package core.game.node.entity.skill.construction; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.SceneryDefinition; import core.game.content.dialogue.DialogueInterpreter; import core.game.content.dialogue.DialoguePlugin; @@ -121,10 +121,10 @@ public final class PortalOptionPlugin extends OptionHandler { case 3: if(player.getIronmanManager().isIronman()){ end(); - ContentAPI.sendMessage(player, "You can't do that as an ironman."); + sendMessage(player, "You can't do that as an ironman."); return true; } - ContentAPI.sendInputDialogue(player, false, "Enter friend's name:", (value) -> { + sendInputDialogue(player, false, "Enter friend's name:", (value) -> { Player p = Repository.getPlayerByName((String) value); if (p == null || !p.isActive()) { player.getPacketDispatch().sendMessage("This player is not online."); diff --git a/Server/src/main/java/core/game/node/entity/skill/construction/decoration/chapel/BoneOfferPlugin.java b/Server/src/main/java/core/game/node/entity/skill/construction/decoration/chapel/BoneOfferPlugin.java index 3a8ee87aa..a8e822d09 100644 --- a/Server/src/main/java/core/game/node/entity/skill/construction/decoration/chapel/BoneOfferPlugin.java +++ b/Server/src/main/java/core/game/node/entity/skill/construction/decoration/chapel/BoneOfferPlugin.java @@ -1,7 +1,7 @@ package core.game.node.entity.skill.construction.decoration.chapel; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.SceneryDefinition; import core.game.content.global.Bones; import core.game.node.entity.skill.Skills; @@ -89,7 +89,7 @@ public class BoneOfferPlugin extends UseWithHandler { Location gfxLoc = player.getLocation().transform(player.getDirection(), 1); - ContentAPI.submitIndividualPulse(player, new Pulse(1) { + submitIndividualPulse(player, new Pulse(1) { int counter = 0; @Override diff --git a/Server/src/main/java/core/game/node/entity/skill/herblore/HerbCleanPlugin.java b/Server/src/main/java/core/game/node/entity/skill/herblore/HerbCleanPlugin.java index beb9505f2..884c5b421 100644 --- a/Server/src/main/java/core/game/node/entity/skill/herblore/HerbCleanPlugin.java +++ b/Server/src/main/java/core/game/node/entity/skill/herblore/HerbCleanPlugin.java @@ -1,7 +1,7 @@ package core.game.node.entity.skill.herblore; import api.Container; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.ItemDefinition; import core.game.interaction.OptionHandler; import core.game.node.Node; @@ -39,9 +39,9 @@ public final class HerbCleanPlugin extends OptionHandler { return true; } double exp = herb.getExperience(); - if (ContentAPI.removeItem(player, node.asItem(), Container.INVENTORY)){ + if (removeItem(player, node.asItem(), Container.INVENTORY)){ player.getSkills().addExperience(Skills.HERBLORE, exp, true); - ContentAPI.addItem(player, herb.getProduct().getId(), 1); + addItem(player, herb.getProduct().getId(), 1); player.getAudioManager().send(SFX_IDS[RandomFunction.random(SFX_IDS.length)], 1); player.getPacketDispatch().sendMessage("You clean the dirt from the " + herb.getProduct().getName().toLowerCase().replace("clean", "").trim() + " leaf."); } diff --git a/Server/src/main/java/core/game/node/entity/skill/slayer/SlayerEquipmentFlags.kt b/Server/src/main/java/core/game/node/entity/skill/slayer/SlayerEquipmentFlags.kt index d925e3d1f..55bfbc788 100644 --- a/Server/src/main/java/core/game/node/entity/skill/slayer/SlayerEquipmentFlags.kt +++ b/Server/src/main/java/core/game/node/entity/skill/slayer/SlayerEquipmentFlags.kt @@ -1,6 +1,6 @@ package core.game.node.entity.skill.slayer -import api.ContentAPI +import api.* import api.EquipmentSlot import core.game.node.entity.player.Player import org.rs09.consts.Items @@ -18,16 +18,16 @@ object SlayerEquipmentFlags { @JvmStatic fun updateFlags(player: Player){ var flags = 0 - if(SkillcapePerks.isActive(SkillcapePerks.TRICKS_OF_THE_TRADE,player) && ContentAPI.getAttribute(player, "cape_perks:tott:helmet-stored", false)) flags = 0x3F + if(SkillcapePerks.isActive(SkillcapePerks.TRICKS_OF_THE_TRADE,player) && getAttribute(player, "cape_perks:tott:helmet-stored", false)) flags = 0x3F else if(hasItem(player, Items.SLAYER_HELMET_13263)) flags = 0x1F else if(hasItem(player, Items.NOSE_PEG_4168)) flags = 1 else if(hasItem(player, Items.EARMUFFS_4166)) flags = flags or (1 shl 1) else if(hasItem(player, Items.FACE_MASK_4164)) flags = flags or (1 shl 2) - else if((ContentAPI.getItemFromEquipment(player, EquipmentSlot.HAT)?.id ?: 0) in blackMasks) flags = flags or (1 shl 3) + else if((getItemFromEquipment(player, EquipmentSlot.HAT)?.id ?: 0) in blackMasks) flags = flags or (1 shl 3) else if(hasItem(player, Items.SPINY_HELMET_4551)) flags = flags or (1 shl 4) - if((ContentAPI.getItemFromEquipment(player, EquipmentSlot.AMULET)?.id ?: 0) == Items.WITCHWOOD_ICON_8923) flags = flags or (1 shl 7) - if((ContentAPI.getItemFromEquipment(player, EquipmentSlot.SHIELD)?.id ?: 0) == Items.MIRROR_SHIELD_4156) flags = flags or (1 shl 8) + if((getItemFromEquipment(player, EquipmentSlot.AMULET)?.id ?: 0) == Items.WITCHWOOD_ICON_8923) flags = flags or (1 shl 7) + if((getItemFromEquipment(player, EquipmentSlot.SHIELD)?.id ?: 0) == Items.MIRROR_SHIELD_4156) flags = flags or (1 shl 8) player.slayer.flags.equipmentFlags = flags } @@ -77,7 +77,7 @@ object SlayerEquipmentFlags { } private fun hasItem(player: Player, id: Int): Boolean{ - return (ContentAPI.getItemFromEquipment(player, EquipmentSlot.HAT)?.id ?: 0) == id + return (getItemFromEquipment(player, EquipmentSlot.HAT)?.id ?: 0) == id } fun isSlayerEq(item: Int): Boolean{ diff --git a/Server/src/main/java/core/game/node/entity/skill/slayer/dungeon/AncientCavern.java b/Server/src/main/java/core/game/node/entity/skill/slayer/dungeon/AncientCavern.java index 49528d09d..627ed96c9 100644 --- a/Server/src/main/java/core/game/node/entity/skill/slayer/dungeon/AncientCavern.java +++ b/Server/src/main/java/core/game/node/entity/skill/slayer/dungeon/AncientCavern.java @@ -1,6 +1,6 @@ package core.game.node.entity.skill.slayer.dungeon; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.SceneryDefinition; import core.game.component.CloseEvent; import core.game.component.Component; @@ -68,7 +68,7 @@ public final class AncientCavern extends MapZone implements Plugin { @Override public boolean handle(final Player player, Node node, String option) { - ContentAPI.lock(player, 30); + lock(player, 30); AgilityHandler.forceWalk(player, -1, player.getLocation(), player.getLocation().transform(0, -6, 0), Animation.create(6723), 10, 0.0, null); World.getPulser().submit(new Pulse(1, player) { int count; @@ -87,7 +87,7 @@ public final class AncientCavern extends MapZone implements Plugin { player.getPacketDispatch().sendMessages("You dive into the swirling maelstorm of the whirlpool.", "You are swirled beneath the water, the darkness and pressure are overwhelming.", "Mystical forces guide you into a cavern below the whirlpool."); break; case 8: - ContentAPI.unlock(player); + unlock(player); return true; } return false; diff --git a/Server/src/main/java/core/game/node/entity/skill/smithing/smelting/SmeltingPulse.java b/Server/src/main/java/core/game/node/entity/skill/smithing/smelting/SmeltingPulse.java index d1ec780c4..9f1facbcf 100644 --- a/Server/src/main/java/core/game/node/entity/skill/smithing/smelting/SmeltingPulse.java +++ b/Server/src/main/java/core/game/node/entity/skill/smithing/smelting/SmeltingPulse.java @@ -1,6 +1,6 @@ package core.game.node.entity.skill.smithing.smelting; -import api.ContentAPI; +import static api.ContentAPIKt.*; import api.EquipmentSlot; import core.game.container.impl.EquipmentContainer; import org.rs09.consts.Items; @@ -189,13 +189,13 @@ public class SmeltingPulse extends SkillPulse { public boolean success(Player player) { if (bar == Bar.IRON && !superHeat) { if (hasForgingRing(player)) { - Item ring = ContentAPI.getItemFromEquipment(player, EquipmentSlot.RING); + Item ring = getItemFromEquipment(player, EquipmentSlot.RING); if(ring != null){ - if(ContentAPI.getCharge(ring) == 1000) ContentAPI.setCharge(ring, 140); - ContentAPI.adjustCharge(ring, -1); - if(ContentAPI.getCharge(ring) == 0){ + if(getCharge(ring) == 1000) setCharge(ring, 140); + adjustCharge(ring, -1); + if(getCharge(ring) == 0){ player.getEquipment().remove(ring); - ContentAPI.sendMessage(player, "Your ring of forging uses up its last charge and disintegrates."); + sendMessage(player, "Your ring of forging uses up its last charge and disintegrates."); } } return true; diff --git a/Server/src/main/java/core/game/node/entity/skill/summoning/SummoningCreationPlugin.java b/Server/src/main/java/core/game/node/entity/skill/summoning/SummoningCreationPlugin.java index 182fbc9ac..2d76cc417 100644 --- a/Server/src/main/java/core/game/node/entity/skill/summoning/SummoningCreationPlugin.java +++ b/Server/src/main/java/core/game/node/entity/skill/summoning/SummoningCreationPlugin.java @@ -1,6 +1,6 @@ package core.game.node.entity.skill.summoning; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.cache.def.impl.ItemDefinition; import core.game.component.Component; import core.game.component.ComponentDefinition; @@ -49,7 +49,7 @@ public final class SummoningCreationPlugin extends ComponentPlugin { SummoningCreator.create(player, getItemAmount(opcode), component.getId() == 669 ? SummoningPouch.forSlot(slot > 50 ? slot -1 : slot) : SummoningScroll.forId(slot > 50 ? slot -1 : slot)); break; case 234: - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { SummoningCreator.create(player, (int) value, component.getId() == 669 ? SummoningPouch.forSlot(slot > 50 ? slot -1 : slot) : SummoningScroll.forId(slot > 50 ? slot -1 : slot)); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/game/node/entity/skill/summoning/familiar/BurdenInterfacePlugin.java b/Server/src/main/java/core/game/node/entity/skill/summoning/familiar/BurdenInterfacePlugin.java index 1863d441a..ebfbbbcb9 100644 --- a/Server/src/main/java/core/game/node/entity/skill/summoning/familiar/BurdenInterfacePlugin.java +++ b/Server/src/main/java/core/game/node/entity/skill/summoning/familiar/BurdenInterfacePlugin.java @@ -1,6 +1,6 @@ package core.game.node.entity.skill.summoning.familiar; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -56,7 +56,7 @@ public final class BurdenInterfacePlugin extends ComponentPlugin { beast.transfer(item, container.getAmount(item), withdraw); return true; case 234: - ContentAPI.sendInputDialogue(player, true, "Enter the amount:", (value) -> { + sendInputDialogue(player, true, "Enter the amount:", (value) -> { beast.transfer(item, (int) value, withdraw); return Unit.INSTANCE; }); diff --git a/Server/src/main/java/core/net/packet/in/RunScriptPacketHandler.java b/Server/src/main/java/core/net/packet/in/RunScriptPacketHandler.java index 6cc2f3e2f..515c2af4e 100644 --- a/Server/src/main/java/core/net/packet/in/RunScriptPacketHandler.java +++ b/Server/src/main/java/core/net/packet/in/RunScriptPacketHandler.java @@ -1,6 +1,6 @@ package core.net.packet.in; -import api.ContentAPI; +import static api.ContentAPIKt.*; import core.game.node.entity.player.Player; import core.game.node.entity.player.link.RunScript; import core.net.packet.IncomingPacket; @@ -33,7 +33,7 @@ public class RunScriptPacketHandler implements IncomingPacket { try { script.invoke(value); } catch (NumberFormatException nfe){ - ContentAPI.sendDialogue(player, "That number's a bit large, don't you think?"); + sendDialogue(player, "That number's a bit large, don't you think?"); } player.removeAttribute("runscript"); } diff --git a/Server/src/main/kotlin/api/ContentAPI.kt b/Server/src/main/kotlin/api/ContentAPI.kt index 90bc7b679..1a23aefe0 100644 --- a/Server/src/main/kotlin/api/ContentAPI.kt +++ b/Server/src/main/kotlin/api/ContentAPI.kt @@ -42,1226 +42,1236 @@ import rs09.game.world.World import rs09.game.world.World.Pulser import rs09.game.world.repository.Repository -object ContentAPI { - /** - * Gets a skilling tool which the player has the level to use and is in their inventory. - * @param player the player to get the tool for - * @param pickaxe whether or not we are trying to get a pickaxe. - * @return the tool which meets the requirements or null if none. - */ - @JvmStatic - fun getTool(player: Player, pickaxe: Boolean): SkillingTool? { - return if(pickaxe) SkillingTool.getPickaxe(player) else SkillingTool.getHatchet(player) +/** + * Gets a skilling tool which the player has the level to use and is in their inventory. + * @param player the player to get the tool for + * @param pickaxe whether or not we are trying to get a pickaxe. + * @return the tool which meets the requirements or null if none. + */ + +fun getTool(player: Player, pickaxe: Boolean): SkillingTool? { + return if(pickaxe) SkillingTool.getPickaxe(player) else SkillingTool.getHatchet(player) +} + +/** + * Check if a player has a given level (buffable/debuffable) + * @param player the player to check the stat for + * @param skill the Skill to check. There is an enum for this called Skills. Example: Skills.STRENGTH + * @param level the level to check against + * @return true if the check succeeds, false otherwise + */ + +fun hasLevelDyn(player: Player, skill: Int, level: Int): Boolean { + return player.skills.getLevel(skill) >= level +} + +/** + * Check if a player's static skill level meets a certain value + * @param player the player to check the stat for + * @param skill the Skill to check. There is an enum for this called Skills. Example: Skills.STRENGTH + * @param level the level to check against + * @return true if the check succeeds, false otherwise + */ + +fun hasLevelStat(player: Player, skill: Int, level: Int): Boolean { + return player.skills.getStaticLevel(skill) >= level +} + +/** + * Check if an item exists in a player's inventory + * @param player the player whose inventory to check + * @param item the ID of the item to check for + * @param amount the amount to check for + * @return true if the player has >= the given item in the given amount, false otherwise. + */ + +fun inInventory(player: Player, item: Int, amount: Int = 1): Boolean { + return player.inventory.contains(item, amount) +} + +/** + * Check the amount of a given item in the player's inventory + * @param player the player whose inventory to check + * @param id the ID of the item to check for the amount of + * @return the amount of the given ID in the player's inventory + */ + +fun amountInInventory(player: Player, id: Int): Int{ + return player.inventory.getAmount(id) +} + +/** + * Check the amount of a given item in the player's bank + * @param player the player to check + * @param id the ID of the item to check for + * @return the amount of the ID in the player's bank. + */ + +fun amountInBank(player: Player, id: Int): Int{ + return player.bank.getAmount(id) +} + +/** + * Check the amount of a given item in the player's equipment slots + * @param player the player to check + * @param id the ID of the item to check for + * @return the amount of the ID in the player's equipment. + */ + +fun amountInEquipment(player: Player, id: Int): Int{ + return player.equipment.getAmount(id) +} + +/** + * Remove an item from a player's inventory + * @param player the player whose inventory to remove the item from + * @param item the ID or Item object to remove from the player's inventory + * @param container the Container to remove the items from. An enum exists for this in the api package called Container. Ex: api.Container.BANK + */ + +fun removeItem(player: Player, item: T, container: Container): Boolean { + item ?: return false + val it = when (item) { + is Item -> item + is Int -> Item(item) + else -> throw IllegalStateException("Invalid value passed for item") } - /** - * Check if a player has a given level (buffable/debuffable) - * @param player the player to check the stat for - * @param skill the Skill to check. There is an enum for this called Skills. Example: Skills.STRENGTH - * @param level the level to check against - * @return true if the check succeeds, false otherwise - */ - @JvmStatic - fun hasLevelDyn(player: Player, skill: Int, level: Int): Boolean { - return player.skills.getLevel(skill) >= level + return when(container){ + Container.INVENTORY -> player.inventory.remove(it) + Container.BANK -> player.bank.remove(it) + Container.EQUIPMENT -> player.equipment.remove(it) } +} - /** - * Check if a player's static skill level meets a certain value - * @param player the player to check the stat for - * @param skill the Skill to check. There is an enum for this called Skills. Example: Skills.STRENGTH - * @param level the level to check against - * @return true if the check succeeds, false otherwise - */ - @JvmStatic - fun hasLevelStat(player: Player, skill: Int, level: Int): Boolean { - return player.skills.getStaticLevel(skill) >= level - } +/** + * Add an item to a player's inventory + * @param player the player whose inventory to add an item to + * @param id the ID of the item to add + * @param amount the amount of the item to add, defaults to 1 + * @return true if the item exists in the given amount in the player's inventory + */ - /** - * Check if an item exists in a player's inventory - * @param player the player whose inventory to check - * @param item the ID of the item to check for - * @param amount the amount to check for - * @return true if the player has >= the given item in the given amount, false otherwise. - */ - @JvmStatic - fun inInventory(player: Player, item: Int, amount: Int = 1): Boolean { - return player.inventory.contains(item, amount) - } +fun addItem(player: Player, id: Int, amount: Int = 1): Boolean{ + return player.inventory.add(Item(id,amount)) +} - /** - * Check the amount of a given item in the player's inventory - * @param player the player whose inventory to check - * @param id the ID of the item to check for the amount of - * @return the amount of the given ID in the player's inventory - */ - @JvmStatic - fun amountInInventory(player: Player, id: Int): Int{ - return player.inventory.getAmount(id) - } +/** + * Add an item with a variable quantity or drop it if a player does not have enough space + * @param player the player whose inventory to add to + * @param id the ID of the item to add to the player's inventory + * @param amount the amount of the ID to add to the player's inventory, defaults to 1 + */ - /** - * Check the amount of a given item in the player's bank - * @param player the player to check - * @param id the ID of the item to check for - * @return the amount of the ID in the player's bank. - */ - @JvmStatic - fun amountInBank(player: Player, id: Int): Int{ - return player.bank.getAmount(id) - } +fun addItemOrDrop(player: Player, id: Int, amount: Int = 1){ + val item = Item(id, amount) + if(!player.inventory.add(item)) GroundItemManager.create(item,player) +} - /** - * Check the amount of a given item in the player's equipment slots - * @param player the player to check - * @param id the ID of the item to check for - * @return the amount of the ID in the player's equipment. - */ - @JvmStatic - fun amountInEquipment(player: Player, id: Int): Int{ - return player.equipment.getAmount(id) - } +/** + * Clears an NPC with the "poof" smoke graphics commonly seen with random event NPCs. + * @param npc the NPC object to initialize + */ - /** - * Remove an item from a player's inventory - * @param player the player whose inventory to remove the item from - * @param item the ID or Item object to remove from the player's inventory - * @param container the Container to remove the items from. An enum exists for this in the api package called Container. Ex: api.Container.BANK - */ - @JvmStatic - fun removeItem(player: Player, item: T, container: Container): Boolean { - item ?: return false - val it = when (item) { - is Item -> item - is Int -> Item(item) - else -> throw IllegalStateException("Invalid value passed for item") - } - - return when(container){ - Container.INVENTORY -> player.inventory.remove(it) - Container.BANK -> player.bank.remove(it) - Container.EQUIPMENT -> player.equipment.remove(it) - } - } - - /** - * Add an item to a player's inventory - * @param player the player whose inventory to add an item to - * @param id the ID of the item to add - * @param amount the amount of the item to add, defaults to 1 - * @return true if the item exists in the given amount in the player's inventory - */ - @JvmStatic - fun addItem(player: Player, id: Int, amount: Int = 1): Boolean{ - return player.inventory.add(Item(id,amount)) - } - - /** - * Add an item with a variable quantity or drop it if a player does not have enough space - * @param player the player whose inventory to add to - * @param id the ID of the item to add to the player's inventory - * @param amount the amount of the ID to add to the player's inventory, defaults to 1 - */ - @JvmStatic - fun addItemOrDrop(player: Player, id: Int, amount: Int = 1){ - val item = Item(id, amount) - if(!player.inventory.add(item)) GroundItemManager.create(item,player) - } - - /** - * Clears an NPC with the "poof" smoke graphics commonly seen with random event NPCs. - * @param npc the NPC object to initialize - */ - @JvmStatic - fun poofClear(npc: NPC){ - submitWorldPulse(object : Pulse(){ - var counter = 0 - override fun pulse(): Boolean { - when(counter++){ - 2 -> { - npc.isInvisible = true; Graphics.send(Graphics(86), npc.location) - } - 3 -> npc.clear().also { return true } +fun poofClear(npc: NPC){ + submitWorldPulse(object : Pulse(){ + var counter = 0 + override fun pulse(): Boolean { + when(counter++){ + 2 -> { + npc.isInvisible = true; Graphics.send(Graphics(86), npc.location) } - return false + 3 -> npc.clear().also { return true } } - }) - } - - /** - * Check if an item exists in a player's bank - * @param player the player whose bank to check - * @param item the ID of the item to check for - * @param amount the amount to check for, defaults to 1 - * @return true if the item exists in the given amount in the player's bank - */ - @JvmStatic - fun inBank(player: Player, item: Int, amount: Int = 1): Boolean { - return player.bank.contains(item, amount) - } - - /** - * Check if an item exists in a player's equipment - * @param player the player whose equipment to check - * @param item the ID of the item to check for - * @param amount the amount to check for, defaults to 1 - * @return true if the item exists in the given amount in the player's equipment - */ - @JvmStatic - fun inEquipment(player: Player, item: Int, amount: Int = 1): Boolean { - return player.equipment.contains(item, amount) - } - - /** - * Get number of free slots in a player's inventory - * @param player the player to check - * @return the number of free slots in the player's inventory - */ - @JvmStatic - fun freeSlots(player: Player): Int { - return player.inventory.freeSlots() - } - - /** - * Get an animation by ID. - * @param id the ID of the animation to use - * @return an Animation object with the given ID. - */ - @JvmStatic - fun getAnimation(id: Int): Animation { - return Animation(id) - } - - /** - * Get an animation by ID with priority - * @param id the ID of the animation to get - * @param priority the Animator.Priority enum instance to represent the desired priority - * @return an Animation object with the given ID and priority - */ - @JvmStatic - fun getAnimationWithPriority(id: Int, priority: Animator.Priority): Animation { - return Animation(id, Animator.Priority.values()[priority.ordinal]) - } - - /** - * Reset a player's animator - * @param player the player whose animator to reset - */ - @JvmStatic - fun resetAnimator(player: Player) { - player.animator.animate(Animation(-1, Animator.Priority.VERY_HIGH)) - } - - /** - * Get the number of ticks an animation lasts - * @param animation the Animation object to check the duration of - * @return the number of ticks the given animation lasts for - */ - @JvmStatic - fun animationDuration(animation: Animation): Int { - return animation.definition.durationTicks - } - - /** - * Give a player some amount of experience in a specific skill - * @param player the player to award XP to - * @param skill the Skill ID to reward XP for. There is a Skills enum you can use for this. Example: Skills.STRENGTH - * @param amount the amount, including decimal place, of experience to award - */ - @JvmStatic - fun rewardXP(player: Player, skill: Int, amount: Double) { - player.skills.addExperience(skill, amount) - } - - /** - * Replace an object with the given revert timer - * @param toReplace the GameObject instance we are replacing - * @param with the ID of the GameObject we wish to replace toReplace with - * @param for_ticks the number of ticks the object should be replaced for. Use -1 for permanent. - * @param loc the location to move the new object to if necessary. Defaults to null. - */ - @JvmStatic - fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int, loc: Location? = null) { - val newLoc = when(loc){ - null -> toReplace.location - else -> loc + return false } - if (for_ticks == -1) { - SceneryBuilder.replace(toReplace, toReplace.transform(with,toReplace.rotation,newLoc)) - } else { - SceneryBuilder.replace(toReplace, toReplace.transform(with,toReplace.rotation, newLoc), for_ticks) + }) +} + +/** + * Check if an item exists in a player's bank + * @param player the player whose bank to check + * @param item the ID of the item to check for + * @param amount the amount to check for, defaults to 1 + * @return true if the item exists in the given amount in the player's bank + */ + +fun inBank(player: Player, item: Int, amount: Int = 1): Boolean { + return player.bank.contains(item, amount) +} + +/** + * Check if an item exists in a player's equipment + * @param player the player whose equipment to check + * @param item the ID of the item to check for + * @param amount the amount to check for, defaults to 1 + * @return true if the item exists in the given amount in the player's equipment + */ + +fun inEquipment(player: Player, item: Int, amount: Int = 1): Boolean { + return player.equipment.contains(item, amount) +} + +/** + * Get number of free slots in a player's inventory + * @param player the player to check + * @return the number of free slots in the player's inventory + */ + +fun freeSlots(player: Player): Int { + return player.inventory.freeSlots() +} + +/** + * Get an animation by ID. + * @param id the ID of the animation to use + * @return an Animation object with the given ID. + */ + +fun getAnimation(id: Int): Animation { + return Animation(id) +} + +/** + * Get an animation by ID with priority + * @param id the ID of the animation to get + * @param priority the Animator.Priority enum instance to represent the desired priority + * @return an Animation object with the given ID and priority + */ + +fun getAnimationWithPriority(id: Int, priority: Animator.Priority): Animation { + return Animation(id, Animator.Priority.values()[priority.ordinal]) +} + +/** + * Reset a player's animator + * @param player the player whose animator to reset + */ + +fun resetAnimator(player: Player) { + player.animator.animate(Animation(-1, Animator.Priority.VERY_HIGH)) +} + +/** + * Get the number of ticks an animation lasts + * @param animation the Animation object to check the duration of + * @return the number of ticks the given animation lasts for + */ + +fun animationDuration(animation: Animation): Int { + return animation.definition.durationTicks +} + +/** + * Give a player some amount of experience in a specific skill + * @param player the player to award XP to + * @param skill the Skill ID to reward XP for. There is a Skills enum you can use for this. Example: Skills.STRENGTH + * @param amount the amount, including decimal place, of experience to award + */ + +fun rewardXP(player: Player, skill: Int, amount: Double) { + player.skills.addExperience(skill, amount) +} + +/** + * Replace an object with the given revert timer + * @param toReplace the GameObject instance we are replacing + * @param with the ID of the GameObject we wish to replace toReplace with + * @param for_ticks the number of ticks the object should be replaced for. Use -1 for permanent. + * @param loc the location to move the new object to if necessary. Defaults to null. + */ + +fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int, loc: Location? = null) { + val newLoc = when(loc){ + null -> toReplace.location + else -> loc + } + if (for_ticks == -1) { + SceneryBuilder.replace(toReplace, toReplace.transform(with,toReplace.rotation,newLoc)) + } else { + SceneryBuilder.replace(toReplace, toReplace.transform(with,toReplace.rotation, newLoc), for_ticks) + } + toReplace.isActive = false +} + +/** + * Replace an object with the given revert timer with the given rotation + * @param toReplace the GameObject instance we are replacing + * @param with the ID of the GameObject we wish to replace toReplace with + * @param for_ticks the number of ticks the object should be replaced for. Use -1 for permanent. + * @Param rotation the Direction of the rotation it should use. Direction.NORTH, Direction.SOUTH, etc + * @param loc the location to move the new object to if necessary. Defaults to null. + */ + +fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int, rotation: Direction, loc: Location? = null){ + val newLoc = when(loc){ + null -> toReplace.location + else -> loc + } + val rot = when(rotation){ + Direction.NORTH_WEST -> 0 + Direction.NORTH -> 1 + Direction.NORTH_EAST -> 2 + Direction.EAST -> 4 + Direction.SOUTH_EAST -> 7 + Direction.SOUTH -> 6 + Direction.SOUTH_WEST -> 5 + Direction.WEST -> 3 + } + if (for_ticks == -1) { + SceneryBuilder.replace(toReplace, toReplace.transform(with,rot, newLoc)) + } else { + SceneryBuilder.replace(toReplace, toReplace.transform(with,rot,newLoc), for_ticks) + } + toReplace.isActive = false +} + +/** + * Gets the name of an item. + * @param id the ID of the item to get the name of + * @return the name of the item + */ + +fun getItemName(id: Int): String { + return ItemDefinition.forId(id).name +} + +/** + * Removes a ground item + * @param node the GroundItem object to remove + */ + +fun removeGroundItem(node: GroundItem) { + GroundItemManager.destroy(node) +} + +/** + * Checks if a ground item is valid/still exists/should exist + * @param node the GroundItem object to check the validity of + * @return true if the node is valid, false otherwise + */ + +fun isValidGroundItem(node: GroundItem): Boolean { + return GroundItemManager.getItems().contains(node) +} + +/** + * Checks if a player has space for an item + * @param player the player whose inventory to check + * @param item the Item to check against + * @return true if the player's inventory has space for the item + */ + +fun hasSpaceFor(player: Player, item: Item): Boolean { + return player.inventory.hasSpaceFor(item) +} + +/** + * Get the number of ticks passed since server startup + */ + +fun getWorldTicks(): Int { + return World.ticks +} + +/** + * Gets an Audio object with specified id, volume, etc + */ + +fun getAudio(id: Int, volume: Int = 10, delay: Int = 1): Audio { + return Audio(id, volume, delay) +} + +/** + * Impact an enemy with the given amount of damage and the given hitsplat type + * @param entity the entity to damage + * @param amount the amount of damage to deal + * @param type the type of hit splat to use, ImpactHandler.HitsplatType is an enum containing these options. + */ + +fun impact(entity: Entity, amount: Int, type: ImpactHandler.HitsplatType) { + entity.impactHandler.manualHit(entity, amount, type) +} + +/** + * Get an item's definition + * @param id the ID of the item to get the definition of + * @return the ItemDefinition for the given ID. + */ + +fun itemDefinition(id: Int): ItemDefinition { + return ItemDefinition.forId(id) +} + +/** + * Send an object animation + */ + +fun animateScenery(player: Player, obj: Scenery, animationId: Int, global: Boolean = false) { + player.packetDispatch.sendSceneryAnimation(obj, getAnimation(animationId), global) +} + +/** + * Send an object animation independent of a player + */ + +fun animateScenery(obj: Scenery, animationId: Int){ + val animation = Animation(animationId) + animation.setObject(obj) + getRegionChunk(obj.location).flag(AnimateObjectUpdateFlag(animation)) +} + +/** + * Produce a ground item owned by the player + */ + +fun produceGroundItem(player: Player, item: Int) { + GroundItemManager.create(Item(item), player) +} + +/** + * Spawns a projectile + */ + +fun spawnProjectile(source: Entity, dest: Entity, projectileId: Int) { + Projectile.create(source, dest, projectileId).send() +} + +/** + * Spawns a projectile with more advanced parameters + * @param source the initial Location of the projectile + * @param dest the final Location of the projectile + * @param projectile the ID of the gfx used for the projectile + * @param startHeight the height the projectile spawns at + * @param endHeight the height the projectile ends at + * @param delay the delay before the projectile spawns + * @param speed the speed the projectile travels at + * @param angle the angle the projectile travels at + */ + +fun spawnProjectile(source: Location, dest: Location, projectile: Int, startHeight: Int, endHeight: Int, delay: Int, speed: Int, angle: Int){ + Projectile.create(source, dest, projectile, startHeight, endHeight, delay, speed, angle, source.getDistance(dest).toInt()).send() +} + +/** + * Causes the given entity to face the given toFace + * @param entity the entity you wish to face something + * @param toFace the thing to face + * @param duration how long you wish to face the thing for + */ + +fun face(entity: Entity, toFace: Node, duration: Int = -1) { + if (duration == -1) { + when (toFace) { + is Location -> entity.faceLocation(toFace) + is Entity -> entity.face(toFace) } - toReplace.isActive = false - } - - /** - * Replace an object with the given revert timer with the given rotation - * @param toReplace the GameObject instance we are replacing - * @param with the ID of the GameObject we wish to replace toReplace with - * @param for_ticks the number of ticks the object should be replaced for. Use -1 for permanent. - * @Param rotation the Direction of the rotation it should use. Direction.NORTH, Direction.SOUTH, etc - * @param loc the location to move the new object to if necessary. Defaults to null. - */ - @JvmStatic - fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int, rotation: Direction, loc: Location? = null){ - val newLoc = when(loc){ - null -> toReplace.location - else -> loc - } - val rot = when(rotation){ - Direction.NORTH_WEST -> 0 - Direction.NORTH -> 1 - Direction.NORTH_EAST -> 2 - Direction.EAST -> 4 - Direction.SOUTH_EAST -> 7 - Direction.SOUTH -> 6 - Direction.SOUTH_WEST -> 5 - Direction.WEST -> 3 - } - if (for_ticks == -1) { - SceneryBuilder.replace(toReplace, toReplace.transform(with,rot, newLoc)) - } else { - SceneryBuilder.replace(toReplace, toReplace.transform(with,rot,newLoc), for_ticks) - } - toReplace.isActive = false - } - - /** - * Gets the name of an item. - * @param id the ID of the item to get the name of - * @return the name of the item - */ - @JvmStatic - fun getItemName(id: Int): String { - return ItemDefinition.forId(id).name - } - - /** - * Removes a ground item - * @param node the GroundItem object to remove - */ - @JvmStatic - fun removeGroundItem(node: GroundItem) { - GroundItemManager.destroy(node) - } - - /** - * Checks if a ground item is valid/still exists/should exist - * @param node the GroundItem object to check the validity of - * @return true if the node is valid, false otherwise - */ - @JvmStatic - fun isValidGroundItem(node: GroundItem): Boolean { - return GroundItemManager.getItems().contains(node) - } - - /** - * Checks if a player has space for an item - * @param player the player whose inventory to check - * @param item the Item to check against - * @return true if the player's inventory has space for the item - */ - @JvmStatic - fun hasSpaceFor(player: Player, item: Item): Boolean { - return player.inventory.hasSpaceFor(item) - } - - /** - * Get the number of ticks passed since server startup - */ - @JvmStatic - fun getWorldTicks(): Int { - return World.ticks - } - - /** - * Gets an Audio object with specified id, volume, etc - */ - @JvmStatic - fun getAudio(id: Int, volume: Int = 10, delay: Int = 1): Audio { - return Audio(id, volume, delay) - } - - /** - * Impact an enemy with the given amount of damage and the given hitsplat type - * @param entity the entity to damage - * @param amount the amount of damage to deal - * @param type the type of hit splat to use, ImpactHandler.HitsplatType is an enum containing these options. - */ - @JvmStatic - fun impact(entity: Entity, amount: Int, type: ImpactHandler.HitsplatType) { - entity.impactHandler.manualHit(entity, amount, type) - } - - /** - * Get an item's definition - * @param id the ID of the item to get the definition of - * @return the ItemDefinition for the given ID. - */ - @JvmStatic - fun itemDefinition(id: Int): ItemDefinition { - return ItemDefinition.forId(id) - } - - /** - * Send an object animation - */ - @JvmStatic - fun animateScenery(player: Player, obj: Scenery, animationId: Int, global: Boolean = false) { - player.packetDispatch.sendSceneryAnimation(obj, getAnimation(animationId), global) - } - - /** - * Send an object animation independent of a player - */ - @JvmStatic - fun animateScenery(obj: Scenery, animationId: Int){ - val animation = Animation(animationId) - animation.setObject(obj) - getRegionChunk(obj.location).flag(AnimateObjectUpdateFlag(animation)) - } - - /** - * Produce a ground item owned by the player - */ - @JvmStatic - fun produceGroundItem(player: Player, item: Int) { - GroundItemManager.create(Item(item), player) - } - - /** - * Spawns a projectile - */ - @JvmStatic - fun spawnProjectile(source: Entity, dest: Entity, projectileId: Int) { - Projectile.create(source, dest, projectileId).send() - } - - /** - * Spawns a projectile with more advanced parameters - * @param source the initial Location of the projectile - * @param dest the final Location of the projectile - * @param projectile the ID of the gfx used for the projectile - * @param startHeight the height the projectile spawns at - * @param endHeight the height the projectile ends at - * @param delay the delay before the projectile spawns - * @param speed the speed the projectile travels at - * @param angle the angle the projectile travels at - */ - @JvmStatic - fun spawnProjectile(source: Location, dest: Location, projectile: Int, startHeight: Int, endHeight: Int, delay: Int, speed: Int, angle: Int){ - Projectile.create(source, dest, projectile, startHeight, endHeight, delay, speed, angle, source.getDistance(dest).toInt()).send() - } - - /** - * Causes the given entity to face the given toFace - * @param entity the entity you wish to face something - * @param toFace the thing to face - * @param duration how long you wish to face the thing for - */ - @JvmStatic - fun face(entity: Entity, toFace: Node, duration: Int = -1) { - if (duration == -1) { - when (toFace) { - is Location -> entity.faceLocation(toFace) - is Entity -> entity.face(toFace) - } - } else { - when (toFace) { - is Location -> entity.faceTemporary(toFace.asNpc(), duration) - else -> entity.faceTemporary(toFace as Entity, duration) - } - } - } - - /** - * Opens the given interface for the given player - * @param player the player to open the interface for - * @param id the ID of the interface to open - */ - @JvmStatic - fun openInterface(player: Player, id: Int) { - player.interfaceManager.open(Component(id)) - } - - /** - * Opens the given interface as an overlay for the given player - * @param player the player to open the interface for - * @param id the ID of the interface to open - */ - @JvmStatic - fun openOverlay(player: Player, id: Int){ - player.interfaceManager.openOverlay(Component(id)) - } - - /** - * Closes any open overlays for the given player - * @param player the player to close for - */ - @JvmStatic - fun closeOverlay(player: Player){ - player.interfaceManager.closeOverlay() - } - - /** - * Runs the given Emote for the given Entity - * @param entity the entity to run the emote on - * @param emote the Emotes enum entry to run - */ - @JvmStatic - fun emote(entity: Entity, emote: Emotes) { - entity.animate(emote.animation) - } - - /** - * Sends a message to the given player. - * @param player the player to send the message to. - */ - @JvmStatic - fun sendMessage(player: Player, message: String) { - player.sendMessage(message) - } - - /** - * Forces an above-head chat message for the given entity - * @param entity the entity to send the chat for - * @param message the message to display - */ - @JvmStatic - fun sendChat(entity: Entity, message: String) { - entity.sendChat(message) - } - - /** - * Sends a message to a player's dialogue box - * @param player the player to send the dialogue to - * @param message the message to send, lines are split automatically. - */ - @JvmStatic - fun sendDialogue(player: Player, message: String) { - player.dialogueInterpreter.sendDialogue(*DialUtils.splitLines(message)) - } - - /** - * Plays an animation on the entity - * @param entity the entity to animate - * @param anim the animation to play, can be an ID or an Animation object. - * @param forced whether or not to force the animation (usually not necessary) - */ - @JvmStatic - fun animate(entity: Entity, anim: T, forced: Boolean = false) { - val animation = when(anim){ - is Int -> Animation(anim) - is Animation -> anim - else -> throw IllegalStateException("Invalid value passed for anim") - } - - if (forced) { - entity.animator.forceAnimation(animation) - } else { - entity.animator.animate(animation) - } - } - - /** - * Plays the given Audio for the given Entity - * @param player the player to play the audio for - * @param audio the Audio to play - * @param global if other nearby entities should be able to hear it - */ - @JvmStatic - fun playAudio(player: Player, audio: Audio, global: Boolean = false) { - player.audioManager.send(audio, global) - } - - /** - * Opens a dialogue with the given dialogue key or dialogue file, depending which is passed. - * @param player the player to open the dialogue for - * @param dialogue either the dialogue key or an instance of a DialogueFile - * @param args various args to pass to the opened dialogue - */ - @JvmStatic - fun openDialogue(player: Player, dialogue: Any, vararg args: Any) { - player.dialogueInterpreter.close() - when (dialogue) { - is Int -> player.dialogueInterpreter.open(dialogue, *args) - is DialogueFile -> player.dialogueInterpreter.open(dialogue, *args) - else -> SystemLogger.logErr("Invalid object type passed to openDialogue() -> ${dialogue.javaClass.simpleName}") - } - } - - /** - * Gets an NPC with the given ID from the repository. - * @param id the ID of the NPC to locate - * @returns an NPC instance matching the ID if it finds one, null otherwise - */ - @JvmStatic - fun findNPC(id: Int): NPC? { - return Repository.findNPC(id) - } - - /** - * Gets the spawned scenery from the world map using the given coordinates - * @param x the X coordinate to use - * @param y the Y coordinate to use - * @param z the Z coordinate to use - */ - @JvmStatic - fun getScenery(x: Int, y: Int, z: Int): Scenery?{ - return RegionManager.getObject(z,x,y) - } - - /** - * Gets the spawned scenery from the world map using the given Location object. - * @param loc the Location object to use. - */ - @JvmStatic - fun getScenery(loc: Location): Scenery?{ - return RegionManager.getObject(loc) - } - - /** - * Gets an NPC within render distance of the refLoc that matches the given ID - * @param refLoc the Location to find the closes NPC to - * @param id the ID of the NPC to locate - * @returns an NPC instance matching the ID if it finds one, null otherwise - */ - @JvmStatic - fun findNPC(refLoc: Location, id: Int): NPC? { - return Repository.npcs.firstOrNull { it.id == id && it.location.withinDistance(refLoc) } - } - - /** - * Gets an NPC with the given ID in the same general area as the given Entity - * @param entity the entity to search around - * @param id the ID of the NPC to locate - * @returns an NPC matching the given ID or null if none is found - */ - @JvmStatic - fun findLocalNPC(entity: Entity, id: Int): NPC? { - return RegionManager.getLocalNpcs(entity).firstOrNull { it.id == id } - } - - /** - * Gets a list of nearby NPCs that match the given IDs. - * @param entity the entity to check around - * @param ids the IDs of the NPCs to look for - */ - @JvmStatic - fun findLocalNPCs(entity: Entity, ids: IntArray): List{ - return RegionManager.getLocalNpcs(entity).filter { it.id in ids }.toList() - } - - /** - * Gets a list of nearby NPCs that match the given IDs. - * @param entity the entity to check around - * @param ids the IDs of the NPCs to look for - * @param distance The maximum distance to the entity. - */ - @JvmStatic - fun findLocalNPCs(entity: Entity, ids: IntArray, distance: Int): List{ - return RegionManager.getLocalNpcs(entity, distance).filter { it.id in ids }.toList() - } - - /** - * Gets the value of an attribute key from the Entity's attributes store - * @param entity the entity to get the attribute from - * @param attribute the attribute key to use - * @param default the default value to return if the attribute does not exist - */ - @JvmStatic - fun getAttribute(entity: Entity, attribute: String, default: T): T { - return entity.getAttribute(attribute, default) - } - - /** - * Sets an attribute key to the given value in an Entity's attribute store - * @param entity the entity to set the attribute for - * @param attribute the attribute key to use - * @param value the value to set the attribute to - */ - @JvmStatic - fun setAttribute(entity: Entity, attribute: String, value: T) { - entity.setAttribute(attribute, value) - } - - /** - * Locks the given entity for the given number of ticks - * @param entity the entity to lock - * @param duration the number of ticks to lock for - */ - @JvmStatic - fun lock(entity: Entity, duration: Int) { - entity.lock(duration) - } - - /** - * Locks specifically an entity's interactions, allowing movement still - * @param entity the entity to lock - * @param duration the duration in ticks to lock for - */ - @JvmStatic - fun lockInteractions(entity: Entity, duration: Int) { - entity.locks.lockInteractions(duration) - } - - /** - * Unlocks the given entity - * @param entity the entity to unlock - */ - @JvmStatic - fun unlock(entity: Entity) { - entity.unlock() - } - - /** - * Transforms an NPC for the given number of ticks - * @param npc the NPC object to transform - * @param transformTo the ID of the NPC to turn into - * @param restoreTicks the number of ticks until the NPC returns to normal - */ - @JvmStatic - fun transformNpc(npc: NPC, transformTo: Int, restoreTicks: Int){ - npc.transform(transformTo) - Pulser.submit(object : Pulse(restoreTicks){ - override fun pulse(): Boolean { - npc.reTransform() - return true - } - }) - } - - /** - * Produces a Location object using the given x,y,z values - */ - @JvmStatic - fun location(x: Int, y: Int, z: Int): Location{ - return Location.create(x,y,z) - } - - /** - * AHeals the given entity for the given number of hitpoints - */ - @JvmStatic - fun heal(entity: Entity, amount: Int){ - entity.skills.heal(amount) - } - - /** - * Sets the given varbit for the given player - * @param player the player to set the varbit for - * @param varpIndex the index of the VARP that contains the desired varbit. - * @param offset the offset of the desired varbit inside the varp. - * @param value the value to set the varbit to - */ - @JvmStatic - fun setVarbit(player: Player, varpIndex: Int, offset: Int, value: Int){ - player.varpManager.get(varpIndex).setVarbit(offset,value).send(player) - } - - /** - * Clears all bits for a given varp index - * @param player the player to clear for - * @param varpIndex the index of the varp to clear - */ - @JvmStatic - fun clearVarp(player: Player, varpIndex: Int){ - player.varpManager.get(varpIndex).clear() - } - - /** - * Gets the value of all bits collected together from a given varp - * @param player the player to get the varp for - * @param varpIndex the index of the varp to calculate the value of - * @return the value of the varp - */ - @JvmStatic - fun getVarpValue(player: Player, varpIndex: Int): Int{ - return player.varpManager.get(varpIndex).getValue() - } - - /** - * Gets the value of a specific varbit - * @param player the player to get the value for - * @param varpIndex the index of th varp containinig the desired varbit - * @param offset the offset of the varbit inside the varp - * @return the value of the given varbit - */ - @JvmStatic - fun getVarbitValue(player: Player, varpIndex: Int, offset: Int): Int { - return player.varpManager.get(varpIndex).getVarbitValue(offset) - } - - /** - * Force an entity to walk to a given destination. - * @param entity the entity to forcewalk - * @param dest the Location object to walk to - * @param type the type of pathfinder to use. "smart" for the SMART pathfinder, "clip" for the noclip pathfinder, anything else for DUMB. - */ - @JvmStatic - fun forceWalk(entity: Entity, dest: Location, type: String){ - if(type == "clip"){ - ForceMovement(entity, dest, 10, 10).run() - return - } - val pathfinder = when(type){ - "smart" -> Pathfinder.SMART - else -> Pathfinder.DUMB - } - val path = Pathfinder.find(entity, dest, true, pathfinder) - path.walk(entity) - } - - /** - * Interrupts a given entity's walking queue - * @param entity the entity to interrupt - */ - @JvmStatic - fun stopWalk(entity: Entity){ - entity.walkingQueue.reset() - } - - /** - * Gets the item in the given equipment slot for the given player - * @param player the player whose equipment to pull from - * @param slot the Equipment slot to use, EquipmentSlot enum contains the options. - * @return the Item in the given slot, or null if none. - */ - @JvmStatic - fun getItemFromEquipment(player: Player, slot: EquipmentSlot): Item? { - return player.equipment.get(slot.ordinal) - } - - /** - * Adjusts the charge for the given node. - * @param node the node to adjust the charge of - * @param amount the amount to adjust by - */ - @JvmStatic - fun adjustCharge(node: Node, amount: Int){ - when(node){ - is Item -> node.charge += amount - is Scenery -> node.charge += amount - else -> SystemLogger.logErr("Attempt to adjust the charge of invalid type: ${node.javaClass.simpleName}") - } - } - - /** - * Get the current charge of the given node - * @param node the node whose charge to check - * @return amount of charges the node has, or -1 if the node does not accept charges. - */ - @JvmStatic - fun getCharge(node: Node): Int{ - when(node){ - is Item -> return node.charge - is Scenery -> return node.charge - else -> SystemLogger.logErr("Attempt to get charge of invalid type: ${node.javaClass.simpleName}").also { return -1 } - } - } - - /** - * Set the charge of the given node to the given amount. - * @param node the node to set the charge for - * @param charge the amount to set the node's charge to (default is 1000) - */ - @JvmStatic - fun setCharge(node: Node, charge: Int){ - when(node){ - is Item -> node.charge = charge - is Scenery -> node.charge = charge - else -> SystemLogger.logErr("Attempt to set the charge of invalid type: ${node.javaClass.simpleName}") - } - } - - /** - * Gets the used option in the context of an interaction. - * @param player the player to get the used option for. - * @return the option the player used - */ - @JvmStatic - fun getUsedOption(player: Player): String { - return player.getAttribute("interact:option","INVALID") - } - - /** - * Used to play both an Animation and Graphics object simultaneously. - * @param entity the entity to perform this on - * @param anim the Animation object to use, can also be an ID. - * @param gfx the Graphics object to use, can also be an ID. - */ - @JvmStatic - fun visualize(entity: Entity, anim: A, gfx: G){ - val animation = when(anim){ - is Int -> Animation(anim) - is Animation -> anim - else -> throw IllegalStateException("Invalid parameter passed for animation.") - } - - val graphics = when(gfx){ - is Int -> Graphics(gfx) - is Graphics -> gfx - else -> throw IllegalStateException("Invalid parameter passed for graphics.") - } - - entity.visualize(animation,graphics) - } - - /** - * Used to submit a pulse to the GameWorld's Pulser. - * @param pulse the Pulse object to submit - */ - @JvmStatic - fun submitWorldPulse(pulse: Pulse){ - World.Pulser.submit(pulse) - } - - /** - * Teleports or "instantly moves" an entity to a given Location object. - * @param entity the entity to move - * @param loc the Location object to move them to - * @param type the teleport type to use (defaults to instant). An enum exists as TeleportManager.TeleportType. - */ - @JvmStatic - fun teleport(entity: Entity, loc: Location, type: TeleportManager.TeleportType = TeleportManager.TeleportType.INSTANT){ - if(type == TeleportManager.TeleportType.INSTANT) entity.properties.teleportLocation = loc - else entity.teleporter.send(loc,type) - } - - /** - * Sets the dynamic or "temporary" (restores) level of a skill. - * @param entity the entity to set the level for - * @param skill the Skill to set. A Skills enum exists that can be used. Ex: Skills.STRENGTH - * @param level the level to set the skill to - */ - @JvmStatic - fun setTempLevel(entity: Entity, skill: Int, level: Int){ - entity.skills.setLevel(skill, level) - } - - /** - * Gets the static (unchanging/max) level of an entity's skill - * @param entity the entity to get the level for - * @param skill the Skill to get the level of. A Skills enum exists that can be used. Ex: Skills.STRENGTH - * @return the static level of the skill - */ - @JvmStatic - fun getStatLevel(entity: Entity, skill: Int): Int { - return entity.skills.getStaticLevel(skill) - } - - /** - * Gets the dynamic (boostable/debuffable/restoring) level of an entity's skill - * @param entity the entity to get the level for - * @param skill the Skill to get the level of. A Skills enum exists that can be used. Ex: Skills.STRENGTH - * @return the dynamic level of the skill - */ - @JvmStatic - fun getDynLevel(entity: Entity, skill: Int): Int { - return entity.skills.getLevel(skill) - } - - /** - * Adjusts (buffs/debuffs) the given Skill by the amount given. - * @param entity the entity to adjust the skill for - * @param skill the Skill to adjust. A Skills enum exists that can be used. Ex: Skills.STRENGTH - * @param amount the amount to adjust the skill by. Ex-Buff: 5, Ex-Debuff: -5 - */ - @JvmStatic - fun adjustLevel(entity: Entity, skill: Int, amount: Int){ - entity.skills.setLevel(skill, entity.skills.getStaticLevel(skill) + amount) - } - - /** - * Remove all of a given item from the given container - * @param player the player to remove the item from - * @param item the item to remove. Can be an Item object or an ID. - * @param container the Container to remove the item from. An enum exists for this called Container. Ex: Container.BANK - */ - @JvmStatic - fun removeAll(player: Player, item: T, container: Container){ - val it = when(item){ - is Item -> item.id - is Int -> item - else -> throw IllegalStateException("Invalid value passed as item") - } - - when(container){ - Container.EQUIPMENT -> player.equipment.remove(Item(it, amountInEquipment(player, it))) - Container.BANK -> player.bank.remove(Item(it, amountInBank(player, it))) - Container.INVENTORY -> player.inventory.remove(Item(it, amountInInventory(player, it))) - } - } - - /** - * Sends a string to a specific interface child - * @param player the player to send the packet to - * @param string the string to send to the child - * @param iface the ID of the interface to use - * @param child the index of the child to send the string to - */ - @JvmStatic - fun setInterfaceText(player: Player, string: String, iface: Int, child: Int){ - player.packetDispatch.sendString(string,iface,child) - } - - /** - * Closes any open (non-chat) interfaces for the player - * @param player the player to close the interface for - */ - @JvmStatic - fun closeInterface(player: Player){ - player.interfaceManager.close() - } - - /** - * Closes any opened tab interfaces for the player - * @param player the player to close the tab for - */ - @JvmStatic - fun closeTabInterface(player: Player){ - player.interfaceManager.closeSingleTab() - } - - /** - * Sends a dialogue that uses the player's chathead. - * @param player the player to send the dialogue to - * @param msg the message to send. - * @param expr the FacialExpression to use. An enum exists for these called FacialExpression. Defaults to FacialExpression.FRIENDLY - */ - @JvmStatic - fun sendPlayerDialogue(player: Player, msg: String, expr: FacialExpression = FacialExpression.FRIENDLY){ - player.dialogueInterpreter.sendDialogues(player, expr, *DialUtils.splitLines(msg)) - } - - /** - * Sends a player model to a specific interface child - * @param player the player to send the packet to and whose model to use - * @param iface the ID of the interface to send it to - * @param child the index of the child on the interface to send the model to - */ - @JvmStatic - fun sendPlayerOnInterface(player: Player, iface: Int, child: Int){ - player.packetDispatch.sendPlayerOnInterface(iface,child) - } - - /** - * Sends a dialogue that uses the player's chathead. - * @param player the player to send the dialogue to - * @param npc the ID of the NPC to use for the chathead - * @param msg the message to send. - * @param expr the FacialExpression to use. An enum exists for these called FacialExpression. Defaults to FacialExpression.FRIENDLY - */ - @JvmStatic - fun sendNPCDialogue(player: Player, npc: Int, msg: String, expr: FacialExpression = FacialExpression.FRIENDLY){ - player.dialogueInterpreter.sendDialogues(npc, expr, *DialUtils.splitLines(msg)) - } - - /** - * Sends an animation to a specific interface child - * @param player the player to send the packet to - * @param anim the ID of the animation to send to the interface - * @param iface the ID of the interface to send the animation to - * @param child the index of the child on the interface to send the model to - */ - @JvmStatic - fun sendAnimationOnInterface(player: Player, anim: Int, iface: Int, child: Int){ - player.packetDispatch.sendAnimationInterface(anim,iface,child) - } - - /** - * Register a logout listener to a player. Logout listeners are methods that run when a player logs out. - * @param player the player to register the listener for - * @param handler the method to run when the listener is invoked (when the player logs out) - */ - @JvmStatic - fun registerLogoutListener(player: Player, key: String, handler: (p: Player) -> Unit){ - player.logoutListeners[key] = handler - } - - /** - * Removes a logout listener based on the key from a player - * @param player the player to remove the logout listner from - * @param key the key of the logout listener to remove. - */ - @JvmStatic - fun clearLogoutListener(player: Player, key: String){ - player.logoutListeners.remove(key) - } - - /** - * Sends an item to a specific child on an interface - * @param player the player to send the packet to - * @param iface the ID of the interface to send the item onto - * @Param child the index of the child on the interface to send the item onto - * @param item the ID of the item to send - * @param amount the amount of the item to send - defaults to 1 - */ - @JvmStatic - fun sendItemOnInterface(player: Player, iface: Int, child: Int, item: Int, amount: Int = 1){ - player.packetDispatch.sendItemOnInterface(item,amount,iface,child) - } - - /** - * Sends a dialogue box with a single item and some text - * @param player the player to send it to - * @param item the ID of the item to show - * @param message the text to display - */ - @JvmStatic - fun sendItemDialogue(player: Player, item: Int, message: String){ - player.dialogueInterpreter.sendItemMessage(item, *DialUtils.splitLines(message)) - } - - /** - * Sends a dialogue box with two items and some text - * @param player the player to send it to - * @param item1 the ID of the first item to show - * @param item2 the ID of the second item to show - * @param message the text to display - */ - @JvmStatic - fun sendDoubleItemDialogue(player: Player, item1: Int, item2: Int, message: String){ - player.dialogueInterpreter.sendDoubleItemMessage(item1, item2, message) - } - - /** - * Send an input dialogue to retrieve a specified value from the player - * @param player the player to send the input dialogue to - * @param numeric whether or not the input is numeric - * @param prompt what to prompt the player - * @param handler the method that handles the value gained from the input dialogue - */ - @JvmStatic - fun sendInputDialogue(player: Player, numeric: Boolean, prompt: String, handler: (value: Any) -> Unit){ - if(numeric) sendInputDialogue(player, InputType.NUMERIC, prompt, handler) - else sendInputDialogue(player, InputType.STRING_SHORT, prompt, handler) - } - - /** - * Send input dialogues based on type. Some dialogues are special and can't be covered by the other sendInputDialogue method - * @param player the player to send the input dialogue to - * @param type the input type to send - an enum is available for this called InputType - * @param prompt what to prompt the player - * @param handler the method that handles the value from the input dialogue - */ - @JvmStatic - fun sendInputDialogue(player: Player, type: InputType, prompt: String, handler: (value: Any) -> Unit){ - when(type){ - InputType.NUMERIC, InputType.STRING_SHORT -> player.dialogueInterpreter.sendInput(type != InputType.NUMERIC, prompt) - InputType.STRING_LONG -> player.dialogueInterpreter.sendLongInput(prompt) - InputType.MESSAGE -> player.dialogueInterpreter.sendMessageInput(prompt) - } - player.setAttribute("runscript", handler) - } - - /** - * Forces an NPC to "flee" from a player or other entity - * @param entity the entity to make flee - * @param from the entity to flee from - */ - @JvmStatic - fun flee(entity: Entity, from: Entity){ - lock(entity, 5) - face(entity, from, 5) - - val diffX = entity.location.x - from.location.x - val diffY = entity.location.y - from.location.y - - forceWalk(entity, entity.location.transform(diffX,diffY,0), "DUMB") - } - - /** - * Submits an individual or "weak" pulse to a specific entity's pulse manager. Pulses submitted this way can be overridden by other pulses. - * @param entity the entity to submit the pulse to - * @param pulse the pulse to submit - */ - @JvmStatic - fun submitIndividualPulse(entity: Entity, pulse: Pulse){ - entity.pulseManager.run(pulse) - } - - /** - * Gets the number of QP a player has - * @param player the player to get the QP for - * @return the number of QP the player has - */ - @JvmStatic - fun getQP(player: Player): Int{ - return player.questRepository.points - } - - /** - * Gets a scenery definition from the given ID - * @param id the ID of the scenery to get the definition for. - * @return the scenery definition - */ - @JvmStatic - fun sceneryDefinition(id: Int): SceneryDefinition{ - return SceneryDefinition.forId(id) - } - - /** - * Register a map zone - * @param zone the zone to register - * @param borders the ZoneBorders that compose the zone - */ - @JvmStatic - fun registerMapZone(zone: MapZone, borders: ZoneBorders){ - ZoneBuilder.configure(zone) - zone.register(borders) - } - - /** - * Animates a component of an interface. - * @param player the player to animate the interface for. - * @param iface the ID of the interface to animate. - * @param child the child on the interface to animate. - * @param anim the ID of the animation to use. - */ - @JvmStatic - fun animateInterface(player: Player, iface: Int, child: Int, anim: Int){ - player.packetDispatch.sendAnimationInterface(anim,iface,child) - } - - /** - * Adds a climb destination to the ladder handler. - * @param ladderLoc the location of the ladder/stairs object you want to climb. - * @param dest the destination for the climb. - */ - @JvmStatic - fun addClimbDest(ladderLoc: Location, dest: Location){ - SpecialLadders.add(ladderLoc,dest) - } - - /** - * Sends a news announcement in game chat. - * @param message the message to announce - */ - @JvmStatic - fun sendNews(message: String){ - Repository.sendNews(message, 12, "CC6600") - } - - /** - * Sends a given Graphics object, or graphics ID, to the given location. - * @param gfx the Graphics object, or the Integer ID of the graphics, to send. Either works. - * @param location the location to send it to - */ - @JvmStatic - fun sendGraphics(gfx: G, location: Location){ - when(gfx){ - is Int -> Graphics.send(Graphics(gfx),location) - is Graphics -> Graphics.send(gfx, location) - } - } - - @JvmStatic - fun announceIfRare(player: Player, item: Item) { - if (item.definition.getConfiguration(ItemConfigParser.RARE_ITEM, false)) { - ContentAPI.sendNews("${player.username} has just received: ${item.amount} x ${item.name}."); - GlobalKillCounter.incrementRareDrop(player, item); + } else { + when (toFace) { + is Location -> entity.faceTemporary(toFace.asNpc(), duration) + else -> entity.faceTemporary(toFace as Entity, duration) } } } + +/** + * Opens the given interface for the given player + * @param player the player to open the interface for + * @param id the ID of the interface to open + */ + +fun openInterface(player: Player, id: Int) { + player.interfaceManager.open(Component(id)) +} + +/** + * Opens the given interface as an overlay for the given player + * @param player the player to open the interface for + * @param id the ID of the interface to open + */ + +fun openOverlay(player: Player, id: Int){ + player.interfaceManager.openOverlay(Component(id)) +} + +/** + * Closes any open overlays for the given player + * @param player the player to close for + */ + +fun closeOverlay(player: Player){ + player.interfaceManager.closeOverlay() +} + +/** + * Runs the given Emote for the given Entity + * @param entity the entity to run the emote on + * @param emote the Emotes enum entry to run + */ + +fun emote(entity: Entity, emote: Emotes) { + entity.animate(emote.animation) +} + +/** + * Sends a message to the given player. + * @param player the player to send the message to. + */ + +fun sendMessage(player: Player, message: String) { + player.sendMessage(message) +} + +/** + * Forces an above-head chat message for the given entity + * @param entity the entity to send the chat for + * @param message the message to display + */ + +fun sendChat(entity: Entity, message: String) { + entity.sendChat(message) +} + +/** + * Sends a message to a player's dialogue box + * @param player the player to send the dialogue to + * @param message the message to send, lines are split automatically. + */ + +fun sendDialogue(player: Player, message: String) { + player.dialogueInterpreter.sendDialogue(*splitLines(message)) +} + +/** + * Plays an animation on the entity + * @param entity the entity to animate + * @param anim the animation to play, can be an ID or an Animation object. + * @param forced whether or not to force the animation (usually not necessary) + */ + +fun animate(entity: Entity, anim: T, forced: Boolean = false) { + val animation = when(anim){ + is Int -> Animation(anim) + is Animation -> anim + else -> throw IllegalStateException("Invalid value passed for anim") + } + + if (forced) { + entity.animator.forceAnimation(animation) + } else { + entity.animator.animate(animation) + } +} + +/** + * Plays the given Audio for the given Entity + * @param player the player to play the audio for + * @param audio the Audio to play + * @param global if other nearby entities should be able to hear it + */ + +fun playAudio(player: Player, audio: Audio, global: Boolean = false) { + player.audioManager.send(audio, global) +} + +/** + * Opens a dialogue with the given dialogue key or dialogue file, depending which is passed. + * @param player the player to open the dialogue for + * @param dialogue either the dialogue key or an instance of a DialogueFile + * @param args various args to pass to the opened dialogue + */ + +fun openDialogue(player: Player, dialogue: Any, vararg args: Any) { + player.dialogueInterpreter.close() + when (dialogue) { + is Int -> player.dialogueInterpreter.open(dialogue, *args) + is DialogueFile -> player.dialogueInterpreter.open(dialogue, *args) + else -> SystemLogger.logErr("Invalid object type passed to openDialogue() -> ${dialogue.javaClass.simpleName}") + } +} + +/** + * Gets an NPC with the given ID from the repository. + * @param id the ID of the NPC to locate + * @returns an NPC instance matching the ID if it finds one, null otherwise + */ + +fun findNPC(id: Int): NPC? { + return Repository.findNPC(id) +} + +/** + * Gets the spawned scenery from the world map using the given coordinates + * @param x the X coordinate to use + * @param y the Y coordinate to use + * @param z the Z coordinate to use + */ + +fun getScenery(x: Int, y: Int, z: Int): Scenery?{ + return RegionManager.getObject(z,x,y) +} + +/** + * Gets the spawned scenery from the world map using the given Location object. + * @param loc the Location object to use. + */ + +fun getScenery(loc: Location): Scenery?{ + return RegionManager.getObject(loc) +} + +/** + * Gets an NPC within render distance of the refLoc that matches the given ID + * @param refLoc the Location to find the closes NPC to + * @param id the ID of the NPC to locate + * @returns an NPC instance matching the ID if it finds one, null otherwise + */ + +fun findNPC(refLoc: Location, id: Int): NPC? { + return Repository.npcs.firstOrNull { it.id == id && it.location.withinDistance(refLoc) } +} + +/** + * Gets an NPC with the given ID in the same general area as the given Entity + * @param entity the entity to search around + * @param id the ID of the NPC to locate + * @returns an NPC matching the given ID or null if none is found + */ + +fun findLocalNPC(entity: Entity, id: Int): NPC? { + return RegionManager.getLocalNpcs(entity).firstOrNull { it.id == id } +} + +/** + * Gets a list of nearby NPCs that match the given IDs. + * @param entity the entity to check around + * @param ids the IDs of the NPCs to look for + */ + +fun findLocalNPCs(entity: Entity, ids: IntArray): List{ + return RegionManager.getLocalNpcs(entity).filter { it.id in ids }.toList() +} + +/** + * Gets a list of nearby NPCs that match the given IDs. + * @param entity the entity to check around + * @param ids the IDs of the NPCs to look for + * @param distance The maximum distance to the entity. + */ + +fun findLocalNPCs(entity: Entity, ids: IntArray, distance: Int): List{ + return RegionManager.getLocalNpcs(entity, distance).filter { it.id in ids }.toList() +} + +/** + * Gets the value of an attribute key from the Entity's attributes store + * @param entity the entity to get the attribute from + * @param attribute the attribute key to use + * @param default the default value to return if the attribute does not exist + */ + +fun getAttribute(entity: Entity, attribute: String, default: T): T { + return entity.getAttribute(attribute, default) +} + +/** + * Sets an attribute key to the given value in an Entity's attribute store + * @param entity the entity to set the attribute for + * @param attribute the attribute key to use + * @param value the value to set the attribute to + */ + +fun setAttribute(entity: Entity, attribute: String, value: T) { + entity.setAttribute(attribute, value) +} + +/** + * Locks the given entity for the given number of ticks + * @param entity the entity to lock + * @param duration the number of ticks to lock for + */ + +fun lock(entity: Entity, duration: Int) { + entity.lock(duration) +} + +/** + * Locks specifically an entity's interactions, allowing movement still + * @param entity the entity to lock + * @param duration the duration in ticks to lock for + */ + +fun lockInteractions(entity: Entity, duration: Int) { + entity.locks.lockInteractions(duration) +} + +/** + * Unlocks the given entity + * @param entity the entity to unlock + */ + +fun unlock(entity: Entity) { + entity.unlock() +} + +/** + * Transforms an NPC for the given number of ticks + * @param npc the NPC object to transform + * @param transformTo the ID of the NPC to turn into + * @param restoreTicks the number of ticks until the NPC returns to normal + */ + +fun transformNpc(npc: NPC, transformTo: Int, restoreTicks: Int){ + npc.transform(transformTo) + Pulser.submit(object : Pulse(restoreTicks){ + override fun pulse(): Boolean { + npc.reTransform() + return true + } + }) +} + +/** + * Produces a Location object using the given x,y,z values + */ + +fun location(x: Int, y: Int, z: Int): Location{ + return Location.create(x,y,z) +} + +/** + * AHeals the given entity for the given number of hitpoints + */ + +fun heal(entity: Entity, amount: Int){ + entity.skills.heal(amount) +} + +/** + * Sets the given varbit for the given player + * @param player the player to set the varbit for + * @param varpIndex the index of the VARP that contains the desired varbit. + * @param offset the offset of the desired varbit inside the varp. + * @param value the value to set the varbit to + */ + +fun setVarbit(player: Player, varpIndex: Int, offset: Int, value: Int){ + player.varpManager.get(varpIndex).setVarbit(offset,value).send(player) +} + +/** + * Clears all bits for a given varp index + * @param player the player to clear for + * @param varpIndex the index of the varp to clear + */ + +fun clearVarp(player: Player, varpIndex: Int){ + player.varpManager.get(varpIndex).clear() +} + +/** + * Gets the value of all bits collected together from a given varp + * @param player the player to get the varp for + * @param varpIndex the index of the varp to calculate the value of + * @return the value of the varp + */ + +fun getVarpValue(player: Player, varpIndex: Int): Int{ + return player.varpManager.get(varpIndex).getValue() +} + +/** + * Gets the value of a specific varbit + * @param player the player to get the value for + * @param varpIndex the index of th varp containinig the desired varbit + * @param offset the offset of the varbit inside the varp + * @return the value of the given varbit + */ + +fun getVarbitValue(player: Player, varpIndex: Int, offset: Int): Int { + return player.varpManager.get(varpIndex).getVarbitValue(offset) +} + +/** + * Force an entity to walk to a given destination. + * @param entity the entity to forcewalk + * @param dest the Location object to walk to + * @param type the type of pathfinder to use. "smart" for the SMART pathfinder, "clip" for the noclip pathfinder, anything else for DUMB. + */ + +fun forceWalk(entity: Entity, dest: Location, type: String){ + if(type == "clip"){ + ForceMovement(entity, dest, 10, 10).run() + return + } + val pathfinder = when(type){ + "smart" -> Pathfinder.SMART + else -> Pathfinder.DUMB + } + val path = Pathfinder.find(entity, dest, true, pathfinder) + path.walk(entity) +} + +/** + * Interrupts a given entity's walking queue + * @param entity the entity to interrupt + */ + +fun stopWalk(entity: Entity){ + entity.walkingQueue.reset() +} + +/** + * Gets the item in the given equipment slot for the given player + * @param player the player whose equipment to pull from + * @param slot the Equipment slot to use, EquipmentSlot enum contains the options. + * @return the Item in the given slot, or null if none. + */ + +fun getItemFromEquipment(player: Player, slot: EquipmentSlot): Item? { + return player.equipment.get(slot.ordinal) +} + +/** + * Adjusts the charge for the given node. + * @param node the node to adjust the charge of + * @param amount the amount to adjust by + */ + +fun adjustCharge(node: Node, amount: Int){ + when(node){ + is Item -> node.charge += amount + is Scenery -> node.charge += amount + else -> SystemLogger.logErr("Attempt to adjust the charge of invalid type: ${node.javaClass.simpleName}") + } +} + +/** + * Get the current charge of the given node + * @param node the node whose charge to check + * @return amount of charges the node has, or -1 if the node does not accept charges. + */ + +fun getCharge(node: Node): Int{ + when(node){ + is Item -> return node.charge + is Scenery -> return node.charge + else -> SystemLogger.logErr("Attempt to get charge of invalid type: ${node.javaClass.simpleName}").also { return -1 } + } +} + +/** + * Set the charge of the given node to the given amount. + * @param node the node to set the charge for + * @param charge the amount to set the node's charge to (default is 1000) + */ + +fun setCharge(node: Node, charge: Int){ + when(node){ + is Item -> node.charge = charge + is Scenery -> node.charge = charge + else -> SystemLogger.logErr("Attempt to set the charge of invalid type: ${node.javaClass.simpleName}") + } +} + +/** + * Gets the used option in the context of an interaction. + * @param player the player to get the used option for. + * @return the option the player used + */ + +fun getUsedOption(player: Player): String { + return player.getAttribute("interact:option","INVALID") +} + +/** + * Used to play both an Animation and Graphics object simultaneously. + * @param entity the entity to perform this on + * @param anim the Animation object to use, can also be an ID. + * @param gfx the Graphics object to use, can also be an ID. + */ + +fun visualize(entity: Entity, anim: A, gfx: G){ + val animation = when(anim){ + is Int -> Animation(anim) + is Animation -> anim + else -> throw IllegalStateException("Invalid parameter passed for animation.") + } + + val graphics = when(gfx){ + is Int -> Graphics(gfx) + is Graphics -> gfx + else -> throw IllegalStateException("Invalid parameter passed for graphics.") + } + + entity.visualize(animation,graphics) +} + +/** + * Used to submit a pulse to the GameWorld's Pulser. + * @param pulse the Pulse object to submit + */ + +fun submitWorldPulse(pulse: Pulse){ + World.Pulser.submit(pulse) +} + +/** + * Teleports or "instantly moves" an entity to a given Location object. + * @param entity the entity to move + * @param loc the Location object to move them to + * @param type the teleport type to use (defaults to instant). An enum exists as TeleportManager.TeleportType. + */ + +fun teleport(entity: Entity, loc: Location, type: TeleportManager.TeleportType = TeleportManager.TeleportType.INSTANT){ + if(type == TeleportManager.TeleportType.INSTANT) entity.properties.teleportLocation = loc + else entity.teleporter.send(loc,type) +} + +/** + * Sets the dynamic or "temporary" (restores) level of a skill. + * @param entity the entity to set the level for + * @param skill the Skill to set. A Skills enum exists that can be used. Ex: Skills.STRENGTH + * @param level the level to set the skill to + */ + +fun setTempLevel(entity: Entity, skill: Int, level: Int){ + entity.skills.setLevel(skill, level) +} + +/** + * Gets the static (unchanging/max) level of an entity's skill + * @param entity the entity to get the level for + * @param skill the Skill to get the level of. A Skills enum exists that can be used. Ex: Skills.STRENGTH + * @return the static level of the skill + */ + +fun getStatLevel(entity: Entity, skill: Int): Int { + return entity.skills.getStaticLevel(skill) +} + +/** + * Gets the dynamic (boostable/debuffable/restoring) level of an entity's skill + * @param entity the entity to get the level for + * @param skill the Skill to get the level of. A Skills enum exists that can be used. Ex: Skills.STRENGTH + * @return the dynamic level of the skill + */ + +fun getDynLevel(entity: Entity, skill: Int): Int { + return entity.skills.getLevel(skill) +} + +/** + * Adjusts (buffs/debuffs) the given Skill by the amount given. + * @param entity the entity to adjust the skill for + * @param skill the Skill to adjust. A Skills enum exists that can be used. Ex: Skills.STRENGTH + * @param amount the amount to adjust the skill by. Ex-Buff: 5, Ex-Debuff: -5 + */ + +fun adjustLevel(entity: Entity, skill: Int, amount: Int){ + entity.skills.setLevel(skill, entity.skills.getStaticLevel(skill) + amount) +} + +/** + * Remove all of a given item from the given container + * @param player the player to remove the item from + * @param item the item to remove. Can be an Item object or an ID. + * @param container the Container to remove the item from. An enum exists for this called Container. Ex: Container.BANK + */ + +fun removeAll(player: Player, item: T, container: Container){ + val it = when(item){ + is Item -> item.id + is Int -> item + else -> throw IllegalStateException("Invalid value passed as item") + } + + when(container){ + Container.EQUIPMENT -> player.equipment.remove(Item(it, amountInEquipment(player, it))) + Container.BANK -> player.bank.remove(Item(it, amountInBank(player, it))) + Container.INVENTORY -> player.inventory.remove(Item(it, amountInInventory(player, it))) + } +} + +/** + * Sends a string to a specific interface child + * @param player the player to send the packet to + * @param string the string to send to the child + * @param iface the ID of the interface to use + * @param child the index of the child to send the string to + */ + +fun setInterfaceText(player: Player, string: String, iface: Int, child: Int){ + player.packetDispatch.sendString(string,iface,child) +} + +/** + * Closes any open (non-chat) interfaces for the player + * @param player the player to close the interface for + */ + +fun closeInterface(player: Player){ + player.interfaceManager.close() +} + +/** + * Closes any opened tab interfaces for the player + * @param player the player to close the tab for + */ + +fun closeTabInterface(player: Player){ + player.interfaceManager.closeSingleTab() +} + +/** + * Sends a dialogue that uses the player's chathead. + * @param player the player to send the dialogue to + * @param msg the message to send. + * @param expr the FacialExpression to use. An enum exists for these called FacialExpression. Defaults to FacialExpression.FRIENDLY + */ + +fun sendPlayerDialogue(player: Player, msg: String, expr: FacialExpression = FacialExpression.FRIENDLY){ + player.dialogueInterpreter.sendDialogues(player, expr, *splitLines(msg)) +} + +/** + * Sends a player model to a specific interface child + * @param player the player to send the packet to and whose model to use + * @param iface the ID of the interface to send it to + * @param child the index of the child on the interface to send the model to + */ + +fun sendPlayerOnInterface(player: Player, iface: Int, child: Int){ + player.packetDispatch.sendPlayerOnInterface(iface,child) +} + +/** + * Sends a dialogue that uses the player's chathead. + * @param player the player to send the dialogue to + * @param npc the ID of the NPC to use for the chathead + * @param msg the message to send. + * @param expr the FacialExpression to use. An enum exists for these called FacialExpression. Defaults to FacialExpression.FRIENDLY + */ + +fun sendNPCDialogue(player: Player, npc: Int, msg: String, expr: FacialExpression = FacialExpression.FRIENDLY){ + player.dialogueInterpreter.sendDialogues(npc, expr, *splitLines(msg)) +} + +/** + * Sends an animation to a specific interface child + * @param player the player to send the packet to + * @param anim the ID of the animation to send to the interface + * @param iface the ID of the interface to send the animation to + * @param child the index of the child on the interface to send the model to + */ + +fun sendAnimationOnInterface(player: Player, anim: Int, iface: Int, child: Int){ + player.packetDispatch.sendAnimationInterface(anim,iface,child) +} + +/** + * Register a logout listener to a player. Logout listeners are methods that run when a player logs out. + * @param player the player to register the listener for + * @param handler the method to run when the listener is invoked (when the player logs out) + */ + +fun registerLogoutListener(player: Player, key: String, handler: (p: Player) -> Unit){ + player.logoutListeners[key] = handler +} + +/** + * Removes a logout listener based on the key from a player + * @param player the player to remove the logout listner from + * @param key the key of the logout listener to remove. + */ + +fun clearLogoutListener(player: Player, key: String){ + player.logoutListeners.remove(key) +} + +/** + * Sends an item to a specific child on an interface + * @param player the player to send the packet to + * @param iface the ID of the interface to send the item onto + * @Param child the index of the child on the interface to send the item onto + * @param item the ID of the item to send + * @param amount the amount of the item to send - defaults to 1 + */ + +fun sendItemOnInterface(player: Player, iface: Int, child: Int, item: Int, amount: Int = 1){ + player.packetDispatch.sendItemOnInterface(item,amount,iface,child) +} + +/** + * Sends a dialogue box with a single item and some text + * @param player the player to send it to + * @param item the ID of the item to show + * @param message the text to display + */ + +fun sendItemDialogue(player: Player, item: Int, message: String){ + player.dialogueInterpreter.sendItemMessage(item, *splitLines(message)) +} + +/** + * Sends a dialogue box with two items and some text + * @param player the player to send it to + * @param item1 the ID of the first item to show + * @param item2 the ID of the second item to show + * @param message the text to display + */ + +fun sendDoubleItemDialogue(player: Player, item1: Int, item2: Int, message: String){ + player.dialogueInterpreter.sendDoubleItemMessage(item1, item2, message) +} + +/** + * Send an input dialogue to retrieve a specified value from the player + * @param player the player to send the input dialogue to + * @param numeric whether or not the input is numeric + * @param prompt what to prompt the player + * @param handler the method that handles the value gained from the input dialogue + */ + +fun sendInputDialogue(player: Player, numeric: Boolean, prompt: String, handler: (value: Any) -> Unit){ + if(numeric) sendInputDialogue(player, InputType.NUMERIC, prompt, handler) + else sendInputDialogue(player, InputType.STRING_SHORT, prompt, handler) +} + +/** + * Send input dialogues based on type. Some dialogues are special and can't be covered by the other sendInputDialogue method + * @param player the player to send the input dialogue to + * @param type the input type to send - an enum is available for this called InputType + * @param prompt what to prompt the player + * @param handler the method that handles the value from the input dialogue + */ + +fun sendInputDialogue(player: Player, type: InputType, prompt: String, handler: (value: Any) -> Unit){ + when(type){ + InputType.NUMERIC, InputType.STRING_SHORT -> player.dialogueInterpreter.sendInput(type != InputType.NUMERIC, prompt) + InputType.STRING_LONG -> player.dialogueInterpreter.sendLongInput(prompt) + InputType.MESSAGE -> player.dialogueInterpreter.sendMessageInput(prompt) + } + player.setAttribute("runscript", handler) +} + +/** + * Forces an NPC to "flee" from a player or other entity + * @param entity the entity to make flee + * @param from the entity to flee from + */ + +fun flee(entity: Entity, from: Entity){ + lock(entity, 5) + face(entity, from, 5) + + val diffX = entity.location.x - from.location.x + val diffY = entity.location.y - from.location.y + + forceWalk(entity, entity.location.transform(diffX,diffY,0), "DUMB") +} + +/** + * Submits an individual or "weak" pulse to a specific entity's pulse manager. Pulses submitted this way can be overridden by other pulses. + * @param entity the entity to submit the pulse to + * @param pulse the pulse to submit + */ + +fun submitIndividualPulse(entity: Entity, pulse: Pulse){ + entity.pulseManager.run(pulse) +} + +/** + * Similar to submitIndividualPulse, but for non-repeating tasks, with a cleaner syntax. + */ + +fun runTask(entity: Entity, delay: Int = 0, task: () -> Unit){ + entity.pulseManager.run(object : Pulse(delay) { + override fun pulse(): Boolean { + task.invoke() + return true + } + }) +} + +/** + * Gets the number of QP a player has + * @param player the player to get the QP for + * @return the number of QP the player has + */ + +fun getQP(player: Player): Int{ + return player.questRepository.points +} + +/** + * Gets a scenery definition from the given ID + * @param id the ID of the scenery to get the definition for. + * @return the scenery definition + */ + +fun sceneryDefinition(id: Int): SceneryDefinition{ + return SceneryDefinition.forId(id) +} + +/** + * Register a map zone + * @param zone the zone to register + * @param borders the ZoneBorders that compose the zone + */ + +fun registerMapZone(zone: MapZone, borders: ZoneBorders){ + ZoneBuilder.configure(zone) + zone.register(borders) +} + +/** + * Animates a component of an interface. + * @param player the player to animate the interface for. + * @param iface the ID of the interface to animate. + * @param child the child on the interface to animate. + * @param anim the ID of the animation to use. + */ +fun animateInterface(player: Player, iface: Int, child: Int, anim: Int){ + player.packetDispatch.sendAnimationInterface(anim,iface,child) +} + +/** + * Adds a climb destination to the ladder handler. + * @param ladderLoc the location of the ladder/stairs object you want to climb. + * @param dest the destination for the climb. + */ + +fun addClimbDest(ladderLoc: Location, dest: Location){ + SpecialLadders.add(ladderLoc,dest) +} + +/** + * Sends a news announcement in game chat. + * @param message the message to announce + */ + +fun sendNews(message: String){ + Repository.sendNews(message, 12, "CC6600") +} + +/** + * Sends a given Graphics object, or graphics ID, to the given location. + * @param gfx the Graphics object, or the Integer ID of the graphics, to send. Either works. + * @param location the location to send it to + */ + +fun sendGraphics(gfx: G, location: Location){ + when(gfx){ + is Int -> Graphics.send(Graphics(gfx),location) + is Graphics -> Graphics.send(gfx, location) + } +} + + +fun announceIfRare(player: Player, item: Item) { + if (item.definition.getConfiguration(ItemConfigParser.RARE_ITEM, false)) { + sendNews("${player.username} has just received: ${item.amount} x ${item.name}."); + GlobalKillCounter.incrementRareDrop(player, item); + } +} diff --git a/Server/src/main/kotlin/api/DialUtils.kt b/Server/src/main/kotlin/api/DialUtils.kt index a0db709e3..e2c6dfda8 100644 --- a/Server/src/main/kotlin/api/DialUtils.kt +++ b/Server/src/main/kotlin/api/DialUtils.kt @@ -3,52 +3,48 @@ import rs09.game.system.SystemLogger import java.util.* import kotlin.system.exitProcess -object DialUtils { +//Number of chars per line. Line is split at the nearest whole word that doesn't exceed this length. This should remain constant once a perfect value is found +const val LINE_SIZE = 52.0 - //Number of chars per line. Line is split at the nearest whole word that doesn't exceed this length. This should remain constant once a perfect value is found - const val LINE_SIZE = 52.0 +/** + * Automatically split a single continuous string into multiple comma-separated lines. + * Should this not work out for any reason, you should fallback to standard npc and player methods for dialogue. + */ +fun splitLines(message: String): Array{ + val chars = message.split("").toTypedArray().size.toDouble() + val words = message.split(" ").toTypedArray() + val lines = Math.ceil(chars / LINE_SIZE).toInt() - @JvmStatic - /** - * Automatically split a single continuous string into multiple comma-separated lines. - * Should this not work out for any reason, you should fallback to standard npc and player methods for dialogue. - */ - fun splitLines(message: String): Array{ - val chars = message.split("").toTypedArray().size.toDouble() - val words = message.split(" ").toTypedArray() - val lines = Math.ceil(chars / LINE_SIZE).toInt() - - if(lines > 4){ - SystemLogger.logErr("INVALID NUM LINES. NUM CHARS: $chars") - } - - val messages = ArrayList() - - var index = 0 - - for (msg in 0 until lines) { - var length = 0 - val line = StringBuilder() - while (length <= LINE_SIZE && !(index == words.size)) { - var currentWord = "" - try { - currentWord = words[index] + if (length + words[index].length + 1 <= LINE_SIZE) " " else "" - } catch (e: Exception){ - SystemLogger.logWarn("INDEX: $index WORDSIZE: ${words.size}") - for(word in words.indices){ - SystemLogger.logErr("Word $word: ${words[word]}") - } - exitProcess(0) - } - length += currentWord.length - if (length <= LINE_SIZE) { - line.append(currentWord) - ++index - } - } - messages.add(line.toString()) - } - - return messages.toTypedArray() + if(lines > 4){ + SystemLogger.logErr("INVALID NUM LINES. NUM CHARS: $chars") } + + val messages = ArrayList() + + var index = 0 + + for (msg in 0 until lines) { + var length = 0 + val line = StringBuilder() + while (length <= LINE_SIZE && !(index == words.size)) { + var currentWord = "" + try { + currentWord = words[index] + if (length + words[index].length + 1 <= LINE_SIZE) " " else "" + } catch (e: Exception){ + SystemLogger.logWarn("INDEX: $index WORDSIZE: ${words.size}") + for(word in words.indices){ + SystemLogger.logErr("Word $word: ${words[word]}") + } + exitProcess(0) + } + length += currentWord.length + if (length <= LINE_SIZE) { + line.append(currentWord) + ++index + } + } + messages.add(line.toString()) + } + + return messages.toTypedArray() } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt b/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt index b2f7fbaba..08c00b671 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt @@ -1,6 +1,6 @@ package rs09.game.ai.general -import api.ContentAPI +import api.* import core.cache.def.impl.ItemDefinition import core.game.component.Component import core.game.content.consumable.Consumable @@ -704,7 +704,7 @@ class ScriptAPI(private val bot: Player) { */ fun checkPriceOverrides(id: Int): Int?{ return when(id){ - else -> ContentAPI.itemDefinition(id).getConfiguration(ItemConfigParser.GE_PRICE) + else -> itemDefinition(id).getConfiguration(ItemConfigParser.GE_PRICE) } } diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt index 2f86bb669..55924b6ce 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt @@ -12,7 +12,7 @@ import rs09.game.ai.general.ScriptAPI import rs09.game.ai.skillingbot.SkillingBotAssembler import rs09.game.interaction.InteractionListener import rs09.game.interaction.InteractionListeners -import api.ContentAPI +import api.* @PlayerCompatible @ScriptName("Falador Coal Miner") @@ -58,7 +58,7 @@ class CoalMiner : Script() { val rock = scriptAPI.getNearestNode("rocks",true) rock?.let { InteractionListeners.run(rock.id, InteractionListener.SCENERY,"mine",bot,rock) } } - overlay!!.setAmount(ContentAPI.amountInInventory(bot, Items.COAL_453) + coalAmount) + overlay!!.setAmount(amountInInventory(bot, Items.COAL_453) + coalAmount) } State.TO_BANK -> { diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/GnomeAgility.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/GnomeAgility.kt index de32ecbaf..991430dd8 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/GnomeAgility.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/GnomeAgility.kt @@ -1,6 +1,6 @@ package rs09.game.ai.general.scriptrepository -import api.ContentAPI +import api.* import core.game.world.map.zone.ZoneBorders import rs09.game.ai.general.ScriptAPI import rs09.game.ai.skillingbot.SkillingBotAssembler diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/GnomeBowstring.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/GnomeBowstring.kt index e264ec422..a44190a3f 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/GnomeBowstring.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/GnomeBowstring.kt @@ -1,6 +1,6 @@ package rs09.game.ai.general.scriptrepository -import api.ContentAPI +import api.* import core.game.interaction.DestinationFlag import core.game.interaction.MovementPulse import core.game.node.entity.skill.crafting.spinning.SpinningItem @@ -131,7 +131,7 @@ class GnomeBowstring : Script() { } }) } - if(ContentAPI.freeSlots(bot) > 27){ + if(freeSlots(bot) > 27){ bLadderSwitch = true state = State.RETURN_TO_FLAX } diff --git a/Server/src/main/kotlin/rs09/game/content/activity/barrows/RewardChest.kt b/Server/src/main/kotlin/rs09/game/content/activity/barrows/RewardChest.kt index 7e6d25d31..186fa0b5d 100644 --- a/Server/src/main/kotlin/rs09/game/content/activity/barrows/RewardChest.kt +++ b/Server/src/main/kotlin/rs09/game/content/activity/barrows/RewardChest.kt @@ -1,6 +1,6 @@ package rs09.game.content.activity.barrows -import api.ContentAPI +import api.* import core.game.component.Component import core.game.container.access.InterfaceContainer import core.game.content.global.BossKillCounter @@ -94,7 +94,7 @@ object RewardChest { player.interfaceManager.open(Component(Components.TRAIL_REWARD_364)) BossKillCounter.addtoBarrowsCount(player) for(item in rewards){ - ContentAPI.announceIfRare(player, item); + announceIfRare(player, item); if(!player.inventory.add(item)){ GroundItemManager.create(item,player) } diff --git a/Server/src/main/kotlin/rs09/game/content/activity/vinesweeper/Vinesweeper.kt b/Server/src/main/kotlin/rs09/game/content/activity/vinesweeper/Vinesweeper.kt index 70dbe2f77..01d7af1ce 100644 --- a/Server/src/main/kotlin/rs09/game/content/activity/vinesweeper/Vinesweeper.kt +++ b/Server/src/main/kotlin/rs09/game/content/activity/vinesweeper/Vinesweeper.kt @@ -1,4 +1,4 @@ -import api.ContentAPI +import api.* import core.game.component.Component import core.game.node.entity.Entity import core.game.node.entity.impl.Projectile @@ -68,14 +68,14 @@ data class SeedDestination(val player: Player, val loc: Location, val alive: Boo var SEED_LOCS: HashSet = HashSet() fun isSeed(loc: Location): Boolean { - val scenery = ContentAPI.getScenery(loc) + val scenery = getScenery(loc) return scenery != null && SEED_LOCS.contains(scenery.location) } fun populateSeeds() { while(SEED_LOCS.size < MAX_SEEDS) { val loc = VINESWEEPER_BORDERS.getRandomLoc() - val scenery = ContentAPI.getScenery(loc) + val scenery = getScenery(loc) if(scenery != null && HOLES.contains(scenery.id)) { SEED_LOCS.add(loc) } @@ -83,14 +83,14 @@ fun populateSeeds() { } fun isHole(loc: Location): Boolean { - val scenery = ContentAPI.getScenery(loc) + val scenery = getScenery(loc) return scenery != null && HOLES.contains(scenery.id) } fun scheduleNPCs(player: Player, loc: Location, alive: Boolean, rabbit: Boolean) { val dest = SeedDestination(player, loc, alive) val ids = if(rabbit) { intArrayOf(RABBIT, *FARMERS) } else { FARMERS } - for(npc in ContentAPI.findLocalNPCs(player, ids, 30)) { + for(npc in findLocalNPCs(player, ids, 30)) { if(npc is VinesweeperNPC) { npc.seedDestinations.add(dest) npc.resetWalk() @@ -138,7 +138,7 @@ class VinesweeperListener : InteractionListener() { sendUpdatedPoints(player) player.sendMessage("Oh dear! It looks like you dug up a potato seed by mistake."); scheduleNPCs(player, loc, false, false) - val scenery = ContentAPI.getScenery(loc) + val scenery = getScenery(loc) if(scenery != null) { SceneryBuilder.replace(scenery, scenery.transform(DEAD_PLANT_OBJ)) } @@ -153,7 +153,7 @@ class VinesweeperListener : InteractionListener() { } } } - val scenery = ContentAPI.getScenery(loc) + val scenery = getScenery(loc) if(scenery != null) { SceneryBuilder.replace(scenery, scenery.transform(NUMBERS[count])) } @@ -174,7 +174,7 @@ class VinesweeperListener : InteractionListener() { on(PORTAL, SCENERY, "enter") { player, _ -> val x = player.getAttribute("vinesweeper:return-tele:x", 3052) val y = player.getAttribute("vinesweeper:return-tele:y", 3304) - ContentAPI.teleport(player, Location(x, y)) + teleport(player, Location(x, y)) return@on true } on(SIGNS, SCENERY, "read") { player, node -> @@ -219,14 +219,14 @@ class VinesweeperListener : InteractionListener() { "You are certain there is no seed planted here." } } - ContentAPI.sendDialogue(player, msg) + sendDialogue(player, msg) return true } }) return@on true } on(MRS_WINKIN, NPC, "talk-to") { player, npc -> - ContentAPI.openDialogue(player, WinkinDialogue(), npc) + openDialogue(player, WinkinDialogue(), npc) return@on true } on(MRS_WINKIN, NPC, "trade") { player, _ -> @@ -236,7 +236,7 @@ class VinesweeperListener : InteractionListener() { on(MRS_WINKIN, NPC, "buy flags") { player, npc -> val dialogue = WinkinDialogue() dialogue.stage = 20 - ContentAPI.openDialogue(player, dialogue, npc) + openDialogue(player, dialogue, npc) return@on true } on(RABBIT, NPC, "feed") { player, node -> @@ -263,19 +263,19 @@ class VinesweeperListener : InteractionListener() { } on(FARMER_BLINKIN, NPC, "talk-to") { player, npc -> //player.interfaceManager.open(Component(TUTORIAL)) - ContentAPI.openDialogue(player, BlinkinDialogue(), npc) + openDialogue(player, BlinkinDialogue(), npc) return@on true } on(FARMER_BLINKIN, NPC, "buy-flags") { player, npc -> val dialogue = BlinkinDialogue() dialogue.stage = 21 - ContentAPI.openDialogue(player, dialogue, npc) + openDialogue(player, dialogue, npc) return@on true } on(FARMER_BLINKIN, NPC, "buy-roots") { player, npc -> val dialogue = BlinkinDialogue() dialogue.stage = 40 - ContentAPI.openDialogue(player, dialogue, npc) + openDialogue(player, dialogue, npc) return@on true } } @@ -306,13 +306,13 @@ class VinesweeperNPC : AbstractNPC { override fun handleTickActions() { val dest = seedDestinations.find({sd -> sd.loc == location}) if(dest != null) { - for(npc in ContentAPI.findLocalNPCs(this, intArrayOf(RABBIT, *FARMERS), 30)) { + for(npc in findLocalNPCs(this, intArrayOf(RABBIT, *FARMERS), 30)) { if(npc is VinesweeperNPC) { npc.seedDestinations.remove(dest) npc.resetWalk() } } - val scenery = ContentAPI.getScenery(dest.loc) + val scenery = getScenery(dest.loc) if(scenery != null) { if(id == RABBIT) { val replacement = if(SEED_LOCS.contains(dest.loc)) { DEAD_PLANT_OBJ } else { HOLES[0] } @@ -389,7 +389,7 @@ class VinesweeperNPC : AbstractNPC { fun farmerClear(dest: SeedDestination) { for(dx in -FARMER_CLEAR_RADIUS..FARMER_CLEAR_RADIUS) { for(dy in -FARMER_CLEAR_RADIUS..FARMER_CLEAR_RADIUS) { - val toClear = ContentAPI.getScenery(dest.loc.transform(dx, dy, 0)) + val toClear = getScenery(dest.loc.transform(dx, dy, 0)) if(toClear != null && intArrayOf(DEAD_PLANT_OBJ, *NUMBERS).contains(toClear.id)) { SceneryBuilder.replace(toClear, toClear.transform(HOLES[0])) } @@ -508,7 +508,7 @@ class VinesweeperRewards : InterfaceListener() { override fun defineListeners() { onOpen(IFACE) { _, _ -> /*for((buttonID, reward) in REWARDS) { - ContentAPI.sendItemOnInterface(player, IFACE, buttonID, reward.itemID, 5) + sendItemOnInterface(player, IFACE, buttonID, reward.itemID, 5) }*/ //player.packetDispatch.sendRunScript(2003, "") return@onOpen true diff --git a/Server/src/main/kotlin/rs09/game/content/activity/vinesweeper/VinesweeperDialogues.kt b/Server/src/main/kotlin/rs09/game/content/activity/vinesweeper/VinesweeperDialogues.kt index b9125059a..f6a89460f 100644 --- a/Server/src/main/kotlin/rs09/game/content/activity/vinesweeper/VinesweeperDialogues.kt +++ b/Server/src/main/kotlin/rs09/game/content/activity/vinesweeper/VinesweeperDialogues.kt @@ -1,4 +1,4 @@ -import api.ContentAPI +import api.* import core.game.component.Component import core.game.node.entity.player.Player import core.game.node.item.GroundItemManager @@ -140,7 +140,7 @@ class BlinkinDialogue : FarmerDialogue() { npcl("Sorry, ya can't afford that many. Come back when yer feeling a bit richer if ya like!") stage = END_DIALOGUE } - //ContentAPI.openDialogue(player!!, this, npc as Any) + //openDialogue(player!!, this, npc as Any) } player!!.dialogueInterpreter.sendInput(false, "Enter the amount:") } diff --git a/Server/src/main/kotlin/rs09/game/content/ame/RandomEventNPC.kt b/Server/src/main/kotlin/rs09/game/content/ame/RandomEventNPC.kt index 432af842a..a28bdb501 100644 --- a/Server/src/main/kotlin/rs09/game/content/ame/RandomEventNPC.kt +++ b/Server/src/main/kotlin/rs09/game/content/ame/RandomEventNPC.kt @@ -1,6 +1,6 @@ package rs09.game.content.ame -import api.ContentAPI +import api.* import core.game.interaction.MovementPulse import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player @@ -35,7 +35,7 @@ abstract class RandomEventNPC(id: Int) : NPC(id) { open fun terminate(){ player.antiMacroHandler.event = null if(initialized){ - ContentAPI.poofClear(this) + poofClear(this) } } diff --git a/Server/src/main/kotlin/rs09/game/content/ame/events/certer/CerterDialogue.kt b/Server/src/main/kotlin/rs09/game/content/ame/events/certer/CerterDialogue.kt index b29c231f8..cc6dc2251 100644 --- a/Server/src/main/kotlin/rs09/game/content/ame/events/certer/CerterDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/ame/events/certer/CerterDialogue.kt @@ -1,6 +1,6 @@ package rs09.game.content.ame.events.certer -import api.ContentAPI +import api.* import core.game.component.Component import core.game.node.item.GroundItemManager import rs09.game.content.dialogue.DialogueFile @@ -23,7 +23,7 @@ class CerterDialogue(val initial: Boolean) : DialogueFile() { 0 -> if(!isCorrect) npc("Sorry, I don't think so.").also { stage = END_DIALOGUE; player!!.antiMacroHandler.event?.terminate() } else npc("Oh yes! That's right.").also { stage++ } 1 -> { npc("Please, take this as a thanks.") - player!!.antiMacroHandler.event?.loot!!.roll().forEach { ContentAPI.addItemOrDrop(player!!, it.id, it.amount) } + player!!.antiMacroHandler.event?.loot!!.roll().forEach { addItemOrDrop(player!!, it.id, it.amount) } player!!.antiMacroHandler.event?.terminate() stage = END_DIALOGUE } diff --git a/Server/src/main/kotlin/rs09/game/content/ame/events/drilldemon/DrillDemonUtils.kt b/Server/src/main/kotlin/rs09/game/content/ame/events/drilldemon/DrillDemonUtils.kt index bc44624fe..9dd099e8d 100644 --- a/Server/src/main/kotlin/rs09/game/content/ame/events/drilldemon/DrillDemonUtils.kt +++ b/Server/src/main/kotlin/rs09/game/content/ame/events/drilldemon/DrillDemonUtils.kt @@ -1,6 +1,6 @@ package rs09.game.content.ame.events.drilldemon -import api.ContentAPI +import api.* import core.game.content.dialogue.FacialExpression import core.game.node.entity.player.Player import core.game.node.item.GroundItemManager @@ -29,8 +29,8 @@ object DrillDemonUtils { player.packetDispatch.sendInterfaceConfig(548, 69, true) player.packetDispatch.sendInterfaceConfig(746, 12, true) - ContentAPI.registerLogoutListener(player, "drilldemon"){p -> - ContentAPI.teleport(p, player.getAttribute(DD_KEY_RETURN_LOC, p.location)) + registerLogoutListener(player, "drilldemon"){p -> + teleport(p, player.getAttribute(DD_KEY_RETURN_LOC, p.location)) } changeSignsAndAssignTask(player) @@ -78,7 +78,7 @@ object DrillDemonUtils { } fun cleanup(player: Player){ - ContentAPI.clearLogoutListener(player, "drilldemon") + clearLogoutListener(player, "drilldemon") player.properties.teleportLocation = player.getAttribute(DD_KEY_RETURN_LOC) player.removeAttribute(DD_KEY_NPC) player.removeAttribute(DD_KEY_RETURN_LOC) diff --git a/Server/src/main/kotlin/rs09/game/content/ame/events/genie/GenieDialogue.kt b/Server/src/main/kotlin/rs09/game/content/ame/events/genie/GenieDialogue.kt index 891502027..60e6a1d30 100644 --- a/Server/src/main/kotlin/rs09/game/content/ame/events/genie/GenieDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/ame/events/genie/GenieDialogue.kt @@ -1,6 +1,6 @@ package rs09.game.content.ame.events.genie -import api.ContentAPI +import api.* import core.game.content.dialogue.FacialExpression import core.cache.def.impl.ItemDefinition import core.game.component.Component @@ -14,7 +14,7 @@ class GenieDialogue : DialogueFile() { override fun handle(componentID: Int, buttonID: Int) { val assigned = player!!.getAttribute("genie:item",0) npcl(FacialExpression.NEUTRAL, "Ah, so you are there, ${player!!.name.capitalize()}. I'm so glad you summoned me. Please take this lamp and make your wish.") - ContentAPI.addItemOrDrop(player!!, assigned) + addItemOrDrop(player!!, assigned) player!!.antiMacroHandler.event?.terminate() stage = END_DIALOGUE } diff --git a/Server/src/main/kotlin/rs09/game/content/ame/events/supriseexam/SurpriseExamUtils.kt b/Server/src/main/kotlin/rs09/game/content/ame/events/supriseexam/SurpriseExamUtils.kt index e0416df21..a9a512f4c 100644 --- a/Server/src/main/kotlin/rs09/game/content/ame/events/supriseexam/SurpriseExamUtils.kt +++ b/Server/src/main/kotlin/rs09/game/content/ame/events/supriseexam/SurpriseExamUtils.kt @@ -1,6 +1,6 @@ package rs09.game.content.ame.events.supriseexam -import api.ContentAPI +import api.* import core.game.node.entity.player.Player import core.game.node.item.GroundItemManager import core.game.node.item.Item @@ -30,8 +30,8 @@ object SurpriseExamUtils { fun teleport(player: Player){ player.setAttribute(SE_KEY_LOC,player.location) - ContentAPI.registerLogoutListener(player, SE_LOGOUT_KEY){p -> - ContentAPI.teleport(p, p.getAttribute(SE_KEY_LOC, p.location)) + registerLogoutListener(player, SE_LOGOUT_KEY){p -> + teleport(p, p.getAttribute(SE_KEY_LOC, p.location)) } player.properties.teleportLocation = Location.create(1886, 5025, 0) @@ -39,7 +39,7 @@ object SurpriseExamUtils { fun cleanup(player: Player){ player.properties.teleportLocation = player.getAttribute(SE_KEY_LOC,null) - ContentAPI.clearLogoutListener(player, SE_LOGOUT_KEY) + clearLogoutListener(player, SE_LOGOUT_KEY) player.removeAttribute(SE_KEY_LOC) player.removeAttribute(SE_KEY_INDEX) player.removeAttribute(SE_KEY_CORRECT) diff --git a/Server/src/main/kotlin/rs09/game/content/dialogue/CaptainCainDialogue.kt b/Server/src/main/kotlin/rs09/game/content/dialogue/CaptainCainDialogue.kt index f5de9b1fd..2d3e4ca82 100644 --- a/Server/src/main/kotlin/rs09/game/content/dialogue/CaptainCainDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/dialogue/CaptainCainDialogue.kt @@ -1,6 +1,6 @@ package rs09.game.content.dialogue -import api.ContentAPI +import api.* import core.game.content.dialogue.DialoguePlugin import core.game.content.dialogue.FacialExpression import core.game.node.entity.player.Player @@ -41,7 +41,7 @@ class CaptainCainDialogue(player: Player? = null) : DialoguePlugin(player) { 10 -> npcl(FacialExpression.FRIENDLY, "Alright, then, that'll be 7,500,000 gold please.").also { stage++ } 11 -> options("Here you go!","Nevermind.").also { stage++ } 12 -> when(buttonId){ - 1 -> if(ContentAPI.inInventory(player, 995, 7500000)) + 1 -> if(inInventory(player, 995, 7500000)) playerl(FacialExpression.FRIENDLY, "Here you go!").also { stage = 20 } else playerl(FacialExpression.HALF_GUILTY, "Actually, I don't have that much.").also { stage = END_DIALOGUE } @@ -51,8 +51,8 @@ class CaptainCainDialogue(player: Player? = null) : DialoguePlugin(player) { 20 -> { npcl(FacialExpression.FRIENDLY, "Thank you much, kind sir. And here's your torso.") - if(ContentAPI.removeItem(player, Item(995,7500000), api.Container.INVENTORY)) { - ContentAPI.addItem(player, Items.FIGHTER_TORSO_10551, 1) + if(removeItem(player, Item(995,7500000), api.Container.INVENTORY)) { + addItem(player, Items.FIGHTER_TORSO_10551, 1) } stage = END_DIALOGUE } diff --git a/Server/src/main/kotlin/rs09/game/content/dialogue/DialogueFile.kt b/Server/src/main/kotlin/rs09/game/content/dialogue/DialogueFile.kt index 50dda5aed..974f1295f 100644 --- a/Server/src/main/kotlin/rs09/game/content/dialogue/DialogueFile.kt +++ b/Server/src/main/kotlin/rs09/game/content/dialogue/DialogueFile.kt @@ -1,6 +1,6 @@ package rs09.game.content.dialogue -import api.DialUtils.splitLines +import api.splitLines import core.game.component.Component import core.game.content.dialogue.DialogueInterpreter import core.game.content.dialogue.DialoguePlugin diff --git a/Server/src/main/kotlin/rs09/game/content/dialogue/region/dungeon/taverley/VelrakDialogue.kt b/Server/src/main/kotlin/rs09/game/content/dialogue/region/dungeon/taverley/VelrakDialogue.kt index 319cd2089..519b105ff 100644 --- a/Server/src/main/kotlin/rs09/game/content/dialogue/region/dungeon/taverley/VelrakDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/dialogue/region/dungeon/taverley/VelrakDialogue.kt @@ -1,7 +1,7 @@ package rs09.game.content.dialogue.region.dungeon.taverley import api.Container -import api.ContentAPI +import api.* import core.game.content.dialogue.DialoguePlugin import core.game.content.dialogue.FacialExpression import core.game.node.entity.player.Player @@ -17,11 +17,11 @@ class VelrakDialogue(player: Player? = null) : DialoguePlugin(player) { } override fun open(vararg args: Any?): Boolean { - if(ContentAPI.inInventory(player, Items.DUSTY_KEY_1590)){ + if(inInventory(player, Items.DUSTY_KEY_1590)){ playerl(FacialExpression.HALF_THINKING, "Are you still here?").also { stage = 100 } } else { npcl(FacialExpression.FRIENDLY, "Thank you for rescuing me! It isn't very comfy in this cell.") - ContentAPI.removeItem(player, Items.JAIL_KEY_1591, Container.INVENTORY) + removeItem(player, Items.JAIL_KEY_1591, Container.INVENTORY) } return true } @@ -42,7 +42,7 @@ class VelrakDialogue(player: Player? = null) : DialoguePlugin(player) { 2 -> playerl(FacialExpression.NEUTRAL, "No, it's too dangerous for me too.").also { stage = 15 } } - 14 -> ContentAPI.sendItemDialogue(player, Items.DUSTY_KEY_1590, "Velrak reaches somewhere mysterious and passes you a key.").also { ContentAPI.addItem(player, Items.DUSTY_KEY_1590, 1); stage = END_DIALOGUE } + 14 -> sendItemDialogue(player, Items.DUSTY_KEY_1590, "Velrak reaches somewhere mysterious and passes you a key.").also { addItem(player, Items.DUSTY_KEY_1590, 1); stage = END_DIALOGUE } 15 -> npcl(FacialExpression.FRIENDLY, "I don't blame you!").also { stage = END_DIALOGUE } diff --git a/Server/src/main/kotlin/rs09/game/content/dialogue/region/jatizso/LeftieRightieDialogue.kt b/Server/src/main/kotlin/rs09/game/content/dialogue/region/jatizso/LeftieRightieDialogue.kt index 27d961b7b..03cc179b4 100644 --- a/Server/src/main/kotlin/rs09/game/content/dialogue/region/jatizso/LeftieRightieDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/dialogue/region/jatizso/LeftieRightieDialogue.kt @@ -1,6 +1,6 @@ package rs09.game.content.dialogue.region.jatizso -import api.DialUtils +import api.* import core.game.content.dialogue.FacialExpression import core.game.node.entity.npc.NPC import org.rs09.consts.NPCs @@ -27,6 +27,6 @@ class LeftieRightieDialogue() : DialogueFile() { } fun npc2(messages: String){ - sendNormalDialogue(leftie, FacialExpression.NEUTRAL, *DialUtils.splitLines(messages)) + sendNormalDialogue(leftie, FacialExpression.NEUTRAL, *splitLines(messages)) } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/christmas/GiftRollPlugin.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/christmas/GiftRollPlugin.kt index 884f6c3f8..8d6257e76 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/christmas/GiftRollPlugin.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/christmas/GiftRollPlugin.kt @@ -1,7 +1,7 @@ package rs09.game.content.global.worldevents.holiday.christmas import api.Container -import api.ContentAPI +import api.* import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills import core.plugin.Initializable @@ -30,8 +30,8 @@ class GiftRollPlugin : XPGainPlugin() { if(System.currentTimeMillis() > cooldown && numDaily < 10 && RandomFunction.roll(15).also { player.debug("Rolling gift: $it") } && amount > 20) { incrementDailyGifts(player) - ContentAPI.addItemOrDrop(player, Items.MYSTERY_BOX_6199) - ContentAPI.sendMessage(player, colorize("%RMerry Christmas! %GYou randomly receive a mystery box while training ${Skills.SKILL_NAME[skill]}!")) + addItemOrDrop(player, Items.MYSTERY_BOX_6199) + sendMessage(player, colorize("%RMerry Christmas! %GYou randomly receive a mystery box while training ${Skills.SKILL_NAME[skill]}!")) } } @@ -63,9 +63,9 @@ class XMASMboxHandler : InteractionListener() { on(MBOX, ITEM, "open"){player, used -> val item = MBOX_LOOT.roll().first() - if(ContentAPI.removeItem(player, used, Container.INVENTORY)) { - ContentAPI.sendDialogue(player, "You open the gift and find ${item.amount} ${item.name}!") - ContentAPI.addItemOrDrop(player, item.id, item.amount) + if(removeItem(player, used, Container.INVENTORY)) { + sendDialogue(player, "You open the gift and find ${item.amount} ${item.name}!") + addItemOrDrop(player, item.id, item.amount) } return@on true } diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/halloween/GrimDialogue.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/halloween/GrimDialogue.kt index 85a718be2..7d1993751 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/halloween/GrimDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/halloween/GrimDialogue.kt @@ -1,6 +1,6 @@ package rs09.game.content.global.worldevents.holiday.halloween -import api.ContentAPI +import api.* import core.game.content.dialogue.DialoguePlugin import core.game.content.dialogue.FacialExpression import core.game.node.entity.combat.ImpactHandler @@ -179,7 +179,7 @@ class GrimDialogue(player: Player? = null) : DialoguePlugin(player){ fun buyStaff(player: Player){ player.setAttribute("/save:sotr:purchased", true) removeCandies(player, 40) - ContentAPI.addItem(player, 14654, 1) + addItem(player, 14654, 1) stage = 104 handleRewardShop(player, -1) } diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/halloween/TrickOrTreatHandler.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/halloween/TrickOrTreatHandler.kt index ba7df3b7f..00071e328 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/halloween/TrickOrTreatHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/holiday/halloween/TrickOrTreatHandler.kt @@ -1,6 +1,6 @@ package rs09.game.content.global.worldevents.holiday.halloween -import api.ContentAPI +import api.* import core.game.component.Component import core.game.content.dialogue.FacialExpression import core.game.node.entity.npc.NPC @@ -26,12 +26,12 @@ class TrickOrTreatHandler : InteractionListener() { val hasDoneMe = getTrickOrTreatedNPCs(player).contains(node.name.toLowerCase()) if(hasDone5){ - ContentAPI.sendNPCDialogue(player, node.id, "My informants tell me you've already collected candy from 5 people today.", FacialExpression.FRIENDLY) + sendNPCDialogue(player, node.id, "My informants tell me you've already collected candy from 5 people today.", FacialExpression.FRIENDLY) return@on true } if(hasDoneMe){ - ContentAPI.sendNPCDialogue(player, node.id, "You've already asked me today! Don't get greedy, now.", FacialExpression.ANNOYED) + sendNPCDialogue(player, node.id, "You've already asked me today! Don't get greedy, now.", FacialExpression.ANNOYED) return@on true } @@ -42,7 +42,7 @@ class TrickOrTreatHandler : InteractionListener() { 1 -> npcl(FacialExpression.FRIENDLY, "Very well, then, here you are my friend.").also { stage++ } 2 -> { player.dialogueInterpreter.sendItemMessage(14084, "They hand you a nicely-wrapped candy.") - ContentAPI.addItemOrDrop(player, 14084, 1) + addItemOrDrop(player, 14084, 1) registerNpc(player, npc!!) incrementDailyToT(player) stage = END_DIALOGUE diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/LarryHandler.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/LarryHandler.kt index 641a7591b..c55998200 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/LarryHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/LarryHandler.kt @@ -1,6 +1,6 @@ package rs09.game.content.global.worldevents.penguinhns -import api.ContentAPI +import api.* import core.game.component.Component import core.game.content.dialogue.DialoguePlugin import core.game.content.dialogue.FacialExpression @@ -75,7 +75,7 @@ class LarryHandler(player: Player? = null) : DialoguePlugin(player){ return } - val level = ContentAPI.getStatLevel(player, skill) + val level = getStatLevel(player, skill) System.out.println("Level: $level") val expGained = points?.toDouble()?.times((level * 25)) System.out.print("exp: $expGained") diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStarMiningPulse.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStarMiningPulse.kt index dcb3a35fc..adcd4a19f 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStarMiningPulse.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStarMiningPulse.kt @@ -1,6 +1,6 @@ package rs09.game.content.global.worldevents.shootingstar -import api.ContentAPI +import api.* import core.game.content.global.worldevents.shootingstar.ScoreboardManager import core.game.node.scenery.Scenery import core.game.node.entity.player.Player @@ -101,7 +101,7 @@ class ShootingStarMiningPulse(player: Player?, node: Scenery?, val star: Shootin if (ShootingStarOptionHandler.getStarDust(player) < 200) { player.inventory.add(Item(ShootingStarOptionHandler.STAR_DUST, 1)) } - if(!ContentAPI.inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && !ContentAPI.inBank(player, Items.ANCIENT_BLUEPRINT_14651)){ + if(!inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && !inBank(player, Items.ANCIENT_BLUEPRINT_14651)){ rollBlueprint(player) } return false @@ -121,9 +121,9 @@ class ShootingStarMiningPulse(player: Player?, node: Scenery?, val star: Shootin } if(RandomFunction.roll(chance)){ - ContentAPI.addItemOrDrop(player, Items.ANCIENT_BLUEPRINT_14651, 1) - ContentAPI.sendMessage(player, colorize("%RWhile mining the star you find an ancient-looking blueprint.")) - ContentAPI.sendNews("${player.username} found an Ancient Blueprint while mining a shooting star!") + addItemOrDrop(player, Items.ANCIENT_BLUEPRINT_14651, 1) + sendMessage(player, colorize("%RWhile mining the star you find an ancient-looking blueprint.")) + sendNews("${player.username} found an Ancient Blueprint while mining a shooting star!") } } diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/StarSpriteDialogue.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/StarSpriteDialogue.kt index 8789c8cbe..99242a3b8 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/StarSpriteDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/StarSpriteDialogue.kt @@ -1,7 +1,7 @@ package rs09.game.content.global.worldevents.shootingstar import api.Container -import api.ContentAPI +import api.* import core.game.content.dialogue.DialoguePlugin import core.game.content.dialogue.FacialExpression import core.game.node.entity.npc.NPC @@ -64,10 +64,10 @@ class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) { override fun open(vararg args: Any): Boolean { npc = args[0] as NPC - if (ContentAPI.inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && !ContentAPI.getAttribute(player, "star-ring:bp-shown", false)) { + if (inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && !getAttribute(player, "star-ring:bp-shown", false)) { npcl(FacialExpression.NEUTRAL, "I see you got ahold of a blueprint of those silly old rings we used to make.") stage = 1000 - } else if (ContentAPI.inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && ContentAPI.getAttribute(player, "star-ring:bp-shown", false)) { + } else if (inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && getAttribute(player, "star-ring:bp-shown", false)) { playerl(FacialExpression.HALF_ASKING, "So about those rings...") stage = 2000 } else if (getStoreFile().getBoolean(player.username.toLowerCase()) || !player.getInventory().contains(ShootingStarOptionHandler.STAR_DUST, 1)) { @@ -184,7 +184,7 @@ class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) { } 41 -> end() 50 -> { - val wearingRing = ContentAPI.inEquipment(player, Items.RING_OF_THE_STAR_SPRITE_14652) + val wearingRing = inEquipment(player, Items.RING_OF_THE_STAR_SPRITE_14652) val dust = if (player.getInventory().getAmount(ShootingStarOptionHandler.STAR_DUST) > 200) 200 else player.getInventory().getAmount(ShootingStarOptionHandler.STAR_DUST) if (player.getInventory().remove(Item(ShootingStarOptionHandler.STAR_DUST, dust))) { val cosmicRunes = (Math.ceil(0.76 * dust) * AMPLIFIER).toInt() @@ -214,10 +214,10 @@ class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) { } } - if(!ContentAPI.inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && !ContentAPI.inBank(player, Items.ANCIENT_BLUEPRINT_14651) && RandomFunction.roll(500)){ - ContentAPI.addItemOrDrop(player, Items.ANCIENT_BLUEPRINT_14651, 1) - ContentAPI.sendMessage(player, colorize("%RThe Star Sprite dropped what looks like some ancient piece of paper and you pick it up.")) - ContentAPI.sendNews("${player.username} found an Ancient Blueprint while mining a shooting star!") + if(!inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && !inBank(player, Items.ANCIENT_BLUEPRINT_14651) && RandomFunction.roll(500)){ + addItemOrDrop(player, Items.ANCIENT_BLUEPRINT_14651, 1) + sendMessage(player, colorize("%RThe Star Sprite dropped what looks like some ancient piece of paper and you pick it up.")) + sendNews("${player.username} found an Ancient Blueprint while mining a shooting star!") } stage = 52 } @@ -235,19 +235,19 @@ class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) { 1008 -> npcl(FacialExpression.NEUTRAL, "Yes, it seems we need a ring mould, a silver bar, a cut dragonstone and 200 stardust. Oh, and make sure to bring this blueprint with you.").also { stage++ } 1009 -> playerl(FacialExpression.FRIENDLY, "Thanks, I'll get right on it!").also { stage++ } 1010 -> playerl(FacialExpression.ASKING, "So just to make sure I've got it right, I need a ring mould, a silver bar, a cut dragonstone and 200 stardust, as well as this blueprint?").also { stage++ } - 1011 -> npcl(FacialExpression.NEUTRAL, "Yeah, you've got it, human. Any of my kin should be able to do this for you.").also { stage++; ContentAPI.setAttribute(player, "/save:star-ring:bp-shown", true) } + 1011 -> npcl(FacialExpression.NEUTRAL, "Yeah, you've got it, human. Any of my kin should be able to do this for you.").also { stage++; setAttribute(player, "/save:star-ring:bp-shown", true) } 1012 -> playerl(FacialExpression.FRIENDLY, "Thanks!").also { stage = END_DIALOGUE } 2000 -> npcl(FacialExpression.NEUTRAL, "Yes, did you bring the components to make it, human?").also { stage++ } - 2001 -> if(ContentAPI.inInventory(player, Items.DRAGONSTONE_1615,1) && ContentAPI.inInventory(player, Items.RING_MOULD_1592, 1) && ContentAPI.inInventory(player, Items.STARDUST_13727, 200) && ContentAPI.inInventory(player, Items.SILVER_BAR_2355, 1)){ + 2001 -> if(inInventory(player, Items.DRAGONSTONE_1615,1) && inInventory(player, Items.RING_MOULD_1592, 1) && inInventory(player, Items.STARDUST_13727, 200) && inInventory(player, Items.SILVER_BAR_2355, 1)){ playerl(FacialExpression.FRIENDLY, "Yes, I have them right here, friend.").also { stage++ } } else { playerl(FacialExpression.HALF_GUILTY, "I'm afraid not, what did I need again?").also { stage = 2100 } } 2002 -> npcl(FacialExpression.NEUTRAL, "Excellent, give me just a moment here...").also { stage++ } 2003 -> sendDialogue("You watch as the Star Sprite casts some strange spell.").also { stage++ } - 2004 -> if(ContentAPI.removeItem(player, Items.SILVER_BAR_2355, Container.INVENTORY) && ContentAPI.removeItem(player, Items.DRAGONSTONE_1615, Container.INVENTORY) && ContentAPI.removeItem(player, Item(Items.STARDUST_13727, 200), Container.INVENTORY)){ - ContentAPI.addItem(player, Items.RING_OF_THE_STAR_SPRITE_14652) + 2004 -> if(removeItem(player, Items.SILVER_BAR_2355, Container.INVENTORY) && removeItem(player, Items.DRAGONSTONE_1615, Container.INVENTORY) && removeItem(player, Item(Items.STARDUST_13727, 200), Container.INVENTORY)){ + addItem(player, Items.RING_OF_THE_STAR_SPRITE_14652) player.dialogueInterpreter.sendItemMessage(Items.RING_OF_THE_STAR_SPRITE_14652, "The Star Sprite hands you a strange ring.").also { stage++ } } else end() 2005 -> npcl(FacialExpression.NEUTRAL, "There you go, I hope you enjoy it!").also { stage++ } @@ -266,13 +266,13 @@ class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) { if(RandomFunction.roll(3)){ val state = player.states["shooting-star"] as? ShootingStarState ?: return state.ticksLeft += secondsToTicks(TimeUnit.MINUTES.toSeconds(5).toInt()) - ContentAPI.sendMessage(player, colorize("%RYour ring shines dimly as if imbued with energy.")) + sendMessage(player, colorize("%RYour ring shines dimly as if imbued with energy.")) } else if(RandomFunction.roll(5)){ - ContentAPI.addItem(player, bonusId, bonusBaseAmt) - ContentAPI.sendMessage(player, colorize("%RYour ring shines brightly as if surging with energy and then fades out.")) + addItem(player, bonusId, bonusBaseAmt) + sendMessage(player, colorize("%RYour ring shines brightly as if surging with energy and then fades out.")) } else if(RandomFunction.roll(25)){ getStoreFile()[player.username.toLowerCase()] = false //flag daily as uncompleted - ContentAPI.sendMessage(player, colorize("%RYour ring vibrates briefly as if surging with power, and then stops.")) + sendMessage(player, colorize("%RYour ring vibrates briefly as if surging with power, and then stops.")) } } diff --git a/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt b/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt index 22e638436..e31193293 100644 --- a/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt +++ b/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt @@ -2,7 +2,7 @@ package rs09.game.content.jobs import GatheringJobs import SlayingJob -import api.ContentAPI +import api.* import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player import core.game.node.entity.player.link.diary.DiaryType @@ -64,7 +64,7 @@ class WorkForInteractionListener : InteractionListener() { var jobId = 0 if(JobManager.getStoreFile().getInt(player.username.toLowerCase()) == 3){ - ContentAPI.sendNPCDialogue(player, node.id,"You've hit your limit for the day. Come back tomorrow!") + sendNPCDialogue(player, node.id,"You've hit your limit for the day. Come back tomorrow!") return@on true } diff --git a/Server/src/main/kotlin/rs09/game/content/quest/free/dragonslayer/DSEquipListeners.kt b/Server/src/main/kotlin/rs09/game/content/quest/free/dragonslayer/DSEquipListeners.kt index 89e5896fb..78cd02f23 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/free/dragonslayer/DSEquipListeners.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/free/dragonslayer/DSEquipListeners.kt @@ -1,6 +1,6 @@ package rs09.game.content.quest.free.dragonslayer -import api.ContentAPI +import api.* import org.rs09.consts.Items import rs09.game.interaction.InteractionListener @@ -28,7 +28,7 @@ class DSEquipListeners : InteractionListener() { for(id in restrictedItems){ onEquip(id){ player, _ -> if(!player.questRepository.isComplete("Dragon Slayer")){ - ContentAPI.sendMessage(player, "You must have completed Dragon Slayer to equip this.") + sendMessage(player, "You must have completed Dragon Slayer to equip this.") return@onEquip false } return@onEquip true diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/FillimanTarlockNPC.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/FillimanTarlockNPC.kt index 6e6cc1475..ce9e4716c 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/FillimanTarlockNPC.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/FillimanTarlockNPC.kt @@ -1,6 +1,6 @@ package rs09.game.content.quest.members.naturespirit -import api.ContentAPI +import api.* import core.game.node.entity.npc.AbstractNPC import core.game.world.map.Location import core.plugin.Initializable @@ -23,7 +23,7 @@ class FillimanTarlockNPC : AbstractNPC { override fun handleTickActions() { super.handleTickActions() - if(spawnedTicks++ > 100) ContentAPI.poofClear(this) + if(spawnedTicks++ > 100) poofClear(this) } override fun getIds(): IntArray { diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSDrezelDialogue.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSDrezelDialogue.kt index 26a0872a3..98ac12013 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSDrezelDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSDrezelDialogue.kt @@ -1,6 +1,6 @@ package rs09.game.content.quest.members.naturespirit -import api.ContentAPI +import api.* import core.game.content.dialogue.FacialExpression import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player @@ -48,10 +48,10 @@ class NSDrezelDialogue : DialogueFile() { 20 -> npcl(FacialExpression.NEUTRAL, "That's great! Many Thanks! Now then, please be aware of the Ghasts, you cannot attack them, only Filliman knew how to take them on.").also { stage++ } 21 -> npcl(FacialExpression.NEUTRAL, "Just run from them if you can. If you start to get lost, try to make your way back to the temple.").also { stage++ } 22 -> { - ContentAPI.sendDoubleItemDialogue(player!!, Items.MEAT_PIE_2327, Items.APPLE_PIE_2323, "The cleric hands you some food.") + sendDoubleItemDialogue(player!!, Items.MEAT_PIE_2327, Items.APPLE_PIE_2323, "The cleric hands you some food.") if(questStage == 0){ - repeat(3) { ContentAPI.addItemOrDrop(player!!, Items.MEAT_PIE_2327, 1) } - repeat(3) { ContentAPI.addItemOrDrop(player!!, Items.APPLE_PIE_2323, 1) } + repeat(3) { addItemOrDrop(player!!, Items.MEAT_PIE_2327, 1) } + repeat(3) { addItemOrDrop(player!!, Items.APPLE_PIE_2323, 1) } player!!.questRepository.getQuest("Nature Spirit").setStage(player!!, 5) } stage++ @@ -80,7 +80,7 @@ class NSDrezelDialogue : DialogueFile() { 4 -> { end() player!!.lock(); - ContentAPI.submitIndividualPulse(player!!, BlessingPulse(npc!!, player!!)) + submitIndividualPulse(player!!, BlessingPulse(npc!!, player!!)) } } } @@ -105,9 +105,9 @@ private class BlessingPulse(val drezel: NPC, val player: Player) : Pulse(){ override fun pulse(): Boolean { when(ticks){ - 0 -> ContentAPI.animate(drezel, 1162).also { ContentAPI.spawnProjectile(drezel, player, 268); ContentAPI.playAudio(player, Audio(2674)) } - 2 -> ContentAPI.visualize(player, Animation(645), Graphics(267, 100)) - 4 -> ContentAPI.unlock(player).also { player.questRepository.getQuest("Nature Spirit").setStage(player, 40); return true } + 0 -> animate(drezel, 1162).also { spawnProjectile(drezel, player, 268); playAudio(player, Audio(2674)) } + 2 -> visualize(player, Animation(645), Graphics(267, 100)) + 4 -> unlock(player).also { player.questRepository.getQuest("Nature Spirit").setStage(player, 40); return true } } ticks++ return false @@ -115,6 +115,6 @@ private class BlessingPulse(val drezel: NPC, val player: Player) : Pulse(){ override fun stop() { super.stop() - ContentAPI.openDialogue(player, NSDrezelDialogue(), drezel) + openDialogue(player, NSDrezelDialogue(), drezel) } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSListeners.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSListeners.kt index 70e619568..2f132f764 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSListeners.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSListeners.kt @@ -1,8 +1,7 @@ package rs09.game.content.quest.members.naturespirit import api.Container -import api.ContentAPI -import api.DialUtils +import api.* import core.game.content.dialogue.FacialExpression import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player @@ -46,15 +45,15 @@ class NSListeners : InteractionListener() { override fun defineListeners() { on(GROTTO_TREE, SCENERY, "look-at"){player, _ -> - ContentAPI.sendMessage(player, "It looks like a tree on a large rock with roots trailing down to the ground.") + sendMessage(player, "It looks like a tree on a large rock with roots trailing down to the ground.") return@on true } on(GROTTO_TREE, SCENERY, "search"){player, _ -> - if(!ContentAPI.getAttribute(player, GROTTO_SEARCHED, false) || !(ContentAPI.inInventory(player, JOURNAL) || ContentAPI.inBank(player, JOURNAL))){ - ContentAPI.sendItemDialogue(player, JOURNAL, "You search the strange rock. You find a knot and inside of it you discover a small tome. The words on the front are a bit vague, but you can make out the words 'Tarlock' and 'journal'.") - ContentAPI.addItemOrDrop(player, JOURNAL, 1) - ContentAPI.setAttribute(player, GROTTO_SEARCHED, true) + if(!getAttribute(player, GROTTO_SEARCHED, false) || !(inInventory(player, JOURNAL) || inBank(player, JOURNAL))){ + sendItemDialogue(player, JOURNAL, "You search the strange rock. You find a knot and inside of it you discover a small tome. The words on the front are a bit vague, but you can make out the words 'Tarlock' and 'journal'.") + addItemOrDrop(player, JOURNAL, 1) + setAttribute(player, GROTTO_SEARCHED, true) return@on true } return@on false @@ -76,7 +75,7 @@ class NSListeners : InteractionListener() { on(GROTTO_ALTAR, SCENERY,"search"){player, node -> val stage = player.questRepository.getStage("Nature Spirit") if(stage == 55){ - ContentAPI.openDialogue(player, FillimanCompletionDialogue(), NPC(NPCs.FILLIMAN_TARLOCK_1050)) + openDialogue(player, FillimanCompletionDialogue(), NPC(NPCs.FILLIMAN_TARLOCK_1050)) return@on true } @@ -84,17 +83,17 @@ class NSListeners : InteractionListener() { } on(NATURE_STONE, SCENERY, "search"){player, _ -> - ContentAPI.sendDialogue(player, "You search the stone and find that it has some sort of nature symbol scratched into it.") + sendDialogue(player, "You search the stone and find that it has some sort of nature symbol scratched into it.") return@on true } on(FAITH_STONE, SCENERY, "search"){player, _ -> - ContentAPI.sendDialogue(player, "You search the stone and find that it has some sort of faith symbol scratched into it.") + sendDialogue(player, "You search the stone and find that it has some sort of faith symbol scratched into it.") return@on true } on(FREELY_GIVEN_STONE, SCENERY, "search"){player, _ -> - ContentAPI.sendDialogue(player, "You search the stone and find it has some sort of spirit symbol scratched into it.") + sendDialogue(player, "You search the stone and find it has some sort of spirit symbol scratched into it.") return@on true } @@ -102,7 +101,7 @@ class NSListeners : InteractionListener() { if(player.questRepository.isComplete("Nature Spirit") && player.questRepository.isComplete("Wolf Whistle")) ShopParser.openUid(player, 241) else - ContentAPI.sendDialogue(player, "You can't do that yet.") + sendDialogue(player, "You can't do that yet.") return@on true } @@ -120,19 +119,19 @@ class NSListeners : InteractionListener() { } on(MIRROR, GROUNDITEM, "take"){player, node -> - if(ContentAPI.getAttribute(player, MIRROR_TAKEN, false) && (ContentAPI.inInventory(player, MIRROR) || ContentAPI.inBank(player, MIRROR))){ - ContentAPI.sendDialogue(player, "I don't need another one of these.") + if(getAttribute(player, MIRROR_TAKEN, false) && (inInventory(player, MIRROR) || inBank(player, MIRROR))){ + sendDialogue(player, "I don't need another one of these.") return@on true } - ContentAPI.setAttribute(player, MIRROR_TAKEN, true) + setAttribute(player, MIRROR_TAKEN, true) PickupHandler.take(player, node as GroundItem) return@on true } on(SPELLCARD, ITEM, "cast"){player, node -> if(NSUtils.castBloom(player)){ - ContentAPI.removeItem(player, node.asItem(), Container.INVENTORY) - ContentAPI.addItem(player, Items.A_USED_SPELL_2969) + removeItem(player, node.asItem(), Container.INVENTORY) + addItem(player, Items.A_USED_SPELL_2969) } return@on true } @@ -140,26 +139,26 @@ class NSListeners : InteractionListener() { on(intArrayOf(DRUID_POUCH, DRUID_POUCH_EMPTY), ITEM, "fill"){player, node -> if(player.questRepository.getStage("Nature Spirit") >= 75) { - if (ContentAPI.amountInInventory(player, Items.MORT_MYRE_FUNGUS_2970) >= 3) { + if (amountInInventory(player, Items.MORT_MYRE_FUNGUS_2970) >= 3) { if (node.id != Items.DRUID_POUCH_2958) { - ContentAPI.removeItem(player, node, Container.INVENTORY) + removeItem(player, node, Container.INVENTORY) } - ContentAPI.removeItem(player, Item(Items.MORT_MYRE_FUNGUS_2970, 3), Container.INVENTORY) - ContentAPI.addItem(player, Items.DRUID_POUCH_2958, 3) + removeItem(player, Item(Items.MORT_MYRE_FUNGUS_2970, 3), Container.INVENTORY) + addItem(player, Items.DRUID_POUCH_2958, 3) } else { - ContentAPI.sendDialogue(player, "You need 3 fungus before you can do that.") + sendDialogue(player, "You need 3 fungus before you can do that.") } } else { - ContentAPI.sendDialogue(player, "I don't know how to use that yet.") + sendDialogue(player, "I don't know how to use that yet.") } return@on true } onUseWith(SCENERY, Items.SILVER_SICKLE_2961, NATURE_ALTAR){player, used, with -> - ContentAPI.sendItemDialogue(player, Items.SILVER_SICKLEB_2963, "You dump the sickle into the waters.") - if(ContentAPI.removeItem(player, Items.SILVER_SICKLE_2961, Container.INVENTORY)){ - ContentAPI.addItem(player, Items.SILVER_SICKLEB_2963, 1) + sendItemDialogue(player, Items.SILVER_SICKLEB_2963, "You dump the sickle into the waters.") + if(removeItem(player, Items.SILVER_SICKLE_2961, Container.INVENTORY)){ + addItem(player, Items.SILVER_SICKLEB_2963, 1) } return@onUseWith true } @@ -172,22 +171,22 @@ class NSListeners : InteractionListener() { when (used.id) { USED_SPELLCARD -> { if (with.id == FREELY_GIVEN_STONE) { - if(ContentAPI.removeItem(player, used, Container.INVENTORY)){ - ContentAPI.sendNPCDialogue(player, NPCs.FILLIMAN_TARLOCK_1050, "Aha, yes, that seems right well done!") - ContentAPI.sendMessage(player, "The stone seems to absorb the used spell scroll.") + if(removeItem(player, used, Container.INVENTORY)){ + sendNPCDialogue(player, NPCs.FILLIMAN_TARLOCK_1050, "Aha, yes, that seems right well done!") + sendMessage(player, "The stone seems to absorb the used spell scroll.") NSUtils.flagCardPlaced(player) } - } else ContentAPI.sendMessage(player, "You try to put the item on the stone, but it just moves off.") + } else sendMessage(player, "You try to put the item on the stone, but it just moves off.") } FUNGUS -> { if (with.id == NATURE_STONE) { - if(ContentAPI.removeItem(player, used, Container.INVENTORY)){ - ContentAPI.sendNPCDialogue(player, NPCs.FILLIMAN_TARLOCK_1050, "Aha, yes, that seems right well done!") - ContentAPI.sendMessage(player, "The stone seems to absorb the used fungus.") + if(removeItem(player, used, Container.INVENTORY)){ + sendNPCDialogue(player, NPCs.FILLIMAN_TARLOCK_1050, "Aha, yes, that seems right well done!") + sendMessage(player, "The stone seems to absorb the used fungus.") NSUtils.flagFungusPlaced(player) } - } else ContentAPI.sendMessage(player, "You try to put the item on the stone, but it just moves off.") + } else sendMessage(player, "You try to put the item on the stone, but it just moves off.") } } return@onUseWith true @@ -198,8 +197,8 @@ class NSListeners : InteractionListener() { class NSJournalDialogue : DialogueFile() { override fun handle(componentID: Int, buttonID: Int) { when(stage){ - 0 -> dialogue(*DialUtils.splitLines("Most of the writing is pretty uninteresting, but something inside refers to a nature spirit. The requirements for which are,")).also { stage++ } - 1 -> dialogue(*DialUtils.splitLines("'Something from nature', 'something with faith' and 'something of the spirit-to-become freely given'. It's all pretty vague.")).also { stage = END_DIALOGUE } + 0 -> dialogue(*splitLines("Most of the writing is pretty uninteresting, but something inside refers to a nature spirit. The requirements for which are,")).also { stage++ } + 1 -> dialogue(*splitLines("'Something from nature', 'something with faith' and 'something of the spirit-to-become freely given'. It's all pretty vague.")).also { stage = END_DIALOGUE } } } } @@ -211,8 +210,8 @@ class FillimanCompletionDialogue : DialogueFile() { 1 -> npcl(FacialExpression.NEUTRAL, "I must complete the transformation now. Just stand there and watch the show, apparently it's quite good!").also { stage++ } 2 -> { end() - ContentAPI.lock(player!!, 10) - ContentAPI.submitWorldPulse(CompleteSpellPulse(player!!)) + lock(player!!, 10) + submitWorldPulse(CompleteSpellPulse(player!!)) } } } @@ -224,10 +223,10 @@ class CompleteSpellPulse(val player: Player) : Pulse(2){ val dest = Location.create(3441, 9738, 0) override fun pulse(): Boolean { when(counter++){ - 0 -> repeat(6) { ContentAPI.spawnProjectile(locations[it], dest, 268, 0, 1000, 0, 40, 20) } + 0 -> repeat(6) { spawnProjectile(locations[it], dest, 268, 0, 1000, 0, 40, 20) } 1 -> player.questRepository.getQuest("Nature Spirit").setStage(player, 60) 2 -> player.teleport(player.location.transform(0,0,1)) - 3 -> ContentAPI.openDialogue(player, NPCs.NATURE_SPIRIT_1051, ContentAPI.findLocalNPC(player, NPCs.NATURE_SPIRIT_1051) as NPC).also { ContentAPI.unlock(player); return true } + 3 -> openDialogue(player, NPCs.NATURE_SPIRIT_1051, findLocalNPC(player, NPCs.NATURE_SPIRIT_1051) as NPC).also { unlock(player); return true } } return false } diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSTarlockDialogue.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSTarlockDialogue.kt index 31f0b8260..069e5d2d0 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSTarlockDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSTarlockDialogue.kt @@ -1,8 +1,7 @@ package rs09.game.content.quest.members.naturespirit import api.Container -import api.ContentAPI -import api.DialUtils +import api.* import core.game.content.dialogue.DialoguePlugin import core.game.content.dialogue.FacialExpression import core.game.node.entity.npc.NPC @@ -29,7 +28,7 @@ class NSTarlockDialogue(player: Player? = null) : DialoguePlugin(player) { val quest = player.questRepository.getQuest("Nature Spirit") questStage = quest.getStage(player) - if(questStage > 10 && !ContentAPI.inEquipment(player, Items.GHOSTSPEAK_AMULET_552)){ + if(questStage > 10 && !inEquipment(player, Items.GHOSTSPEAK_AMULET_552)){ npcl(FacialExpression.HALF_GUILTY, "OooOOOOOOoooOoOOoOOOo") setQuest(15) return false @@ -42,7 +41,7 @@ class NSTarlockDialogue(player: Player? = null) : DialoguePlugin(player) { 30 -> npcl(FacialExpression.HALF_GUILTY, "Thanks for the journal, I've been reading it. It looks like I came to a violent and bitter end but that's not really important. I just have to figure out what I am going to do now?").also { stage = 14 } 35 -> npcl(FacialExpression.NEUTRAL, "Hello there, have you been blessed yet?").also { stage = 60 } 45 -> { - if(ContentAPI.inInventory(player, Items.MORT_MYRE_FUNGUS_2970)){ + if(inInventory(player, Items.MORT_MYRE_FUNGUS_2970)){ npcl(FacialExpression.NEUTRAL, "Did you manage to get something from nature?").also { stage = 80 } } else { playerl( @@ -59,7 +58,7 @@ class NSTarlockDialogue(player: Player? = null) : DialoguePlugin(player) { override fun handle(interfaceId: Int, buttonId: Int): Boolean { when(stage){ - 0 -> if(ContentAPI.inInventory(player, Items.MIRROR_2966)){ + 0 -> if(inInventory(player, Items.MIRROR_2966)){ sendDialogue("You use the mirror on the spirit","of the dead Filliman Tarlock.").also { stage++ } } else { playerl(FacialExpression.NEUTRAL, "Yes, I do think you're dead and I'll prove it somehow.").also { stage = 1002 } @@ -71,9 +70,9 @@ class NSTarlockDialogue(player: Player? = null) : DialoguePlugin(player) { 4 -> playerl(FacialExpression.NEUTRAL, "That's because you're dead! Dead as a door nail... Deader in fact... You bear a remarkable resemblance to wormbait! Err... No offence...").also { stage++ } 5 -> npcl(FacialExpression.HALF_GUILTY, "I think you might be right my friend, though I still feel very much alive. It is strange how I still come to be here and yet I've not turned into a Ghast.").also { stage++ } 6 -> npcl(FacialExpression.HALF_GUILTY, " It must be a sign... Yes a sign... I must try to find out what it means. Now, where did I put my journal?").also { stage++ } - 7 -> if(!ContentAPI.inInventory(player, Items.JOURNAL_2967)){ + 7 -> if(!inInventory(player, Items.JOURNAL_2967)){ playerl(FacialExpression.NEUTRAL, "Where did you put it?").also { stage++; setQuest(25) } - } else sendDialogue("You give the journal to Filliman Tarlock").also { ContentAPI.removeItem(player, Items.JOURNAL_2967, Container.INVENTORY); stage = 10; setQuest(30) } + } else sendDialogue("You give the journal to Filliman Tarlock").also { removeItem(player, Items.JOURNAL_2967, Container.INVENTORY); stage = 10; setQuest(30) } //no journal 8 -> npcl(FacialExpression.HALF_GUILTY, "Well, if I knew that, I wouldn't still be looking for it. However, I do remember something about a knot? Perhaps I was meant to tie a knot or something?").also { stage = END_DIALOGUE } @@ -107,7 +106,7 @@ class NSTarlockDialogue(player: Player? = null) : DialoguePlugin(player) { 52 -> npcl(FacialExpression.HALF_GUILTY, "Well, the book says, that I need, and I quote:- 'Something with faith', 'something from nature' and the 'spirit-to-become' freely given'. Hmm, I know how to get something from nature.").also { stage++ } 53 -> playerl(FacialExpression.NEUTRAL, "Well, that does seem a bit vague.").also { stage++ } 54 -> npcl(FacialExpression.HALF_GUILTY, "Hmm, it does and I could understand if you didn't want to help. However, if you could perhaps at least get the item from nature, that would be a start. Perhaps we can figure out the rest as we go along.").also { stage++ } - 55 -> sendDialogue(*DialUtils.splitLines("The druid produces a small sheet of papyrus with some writing on it.")).also { ContentAPI.addItemOrDrop(player, Items.DRUIDIC_SPELL_2968); setQuest(35); stage++ } + 55 -> sendDialogue(*splitLines("The druid produces a small sheet of papyrus with some writing on it.")).also { addItemOrDrop(player, Items.DRUIDIC_SPELL_2968); setQuest(35); stage++ } 56 -> npcl(FacialExpression.NEUTRAL, "This spell needs to be cast in the swamp after you have been blessed. I'm afraid you'll need to go to the temple to the North and ask a member of the clergy to bless you.").also { stage++ } 57 -> playerl(FacialExpression.NEUTRAL, "Blessed, what does that do?").also { stage++ } 58 -> npcl(FacialExpression.NEUTRAL, "It is required if you're to cast this druid spell. Once you've cast the spell, you should find something from nature. Bring it back to me and then we'll try to figure out the other things we need.").also { stage = END_DIALOGUE } @@ -115,20 +114,20 @@ class NSTarlockDialogue(player: Player? = null) : DialoguePlugin(player) { //have you been blessed yet 60 -> playerl(FacialExpression.NEUTRAL, "No, not yet.").also { stage++ } 61 -> npcl(FacialExpression.NEUTRAL, "Well, hurry up!").also { stage++ } - 62 -> if(ContentAPI.inInventory(player, Items.DRUIDIC_SPELL_2968) || ContentAPI.inBank(player, Items.DRUIDIC_SPELL_2968)) end() + 62 -> if(inInventory(player, Items.DRUIDIC_SPELL_2968) || inBank(player, Items.DRUIDIC_SPELL_2968)) end() else playerl(FacialExpression.NEUTRAL, "Could I have another bloom scroll please?").also { stage++ } 63 -> npcl(FacialExpression.NEUTRAL, "Sure, but please look after this one.").also { stage++ } - 64 -> sendDialogue("The spirit of Filliman Tarlock gives you another bloom spell.").also { ContentAPI.addItemOrDrop(player, Items.DRUIDIC_SPELL_2968); stage = END_DIALOGUE } + 64 -> sendDialogue("The spirit of Filliman Tarlock gives you another bloom spell.").also { addItemOrDrop(player, Items.DRUIDIC_SPELL_2968); stage = END_DIALOGUE } //I've been blessed 70 -> npcl(FacialExpression.NEUTRAL, "Well, you need to bring 'something from nature', 'something with faith' and 'something of the spirit-to- become freely given.'").also { stage++ } 71 -> playerl(FacialExpression.NEUTRAL, "Yeah, but what does that mean?").also { stage++ } 72 -> npcl(FacialExpression.NEUTRAL, "Hmm, it is a conundrum, however, if you use that spell I gave you, you should be able to get from nature. Once you have that, we may be puzzle the rest out.").also { stage++ } - 73 -> if(!ContentAPI.inInventory(player, Items.DRUIDIC_SPELL_2968) && !ContentAPI.inBank(player, Items.DRUIDIC_SPELL_2968)){ + 73 -> if(!inInventory(player, Items.DRUIDIC_SPELL_2968) && !inBank(player, Items.DRUIDIC_SPELL_2968)){ playerl(FacialExpression.NEUTRAL, "Could I have another bloom scroll please?").also { stage++ } } else end() 74 -> npcl(FacialExpression.NEUTRAL, "Sure, but please look after this one.").also { stage++ } - 75 -> sendDialogue("The spirit of Filliman Tarlock gives you","another bloom spell.").also { ContentAPI.addItem(player, Items.DRUIDIC_SPELL_2968); stage = END_DIALOGUE } + 75 -> sendDialogue("The spirit of Filliman Tarlock gives you","another bloom spell.").also { addItem(player, Items.DRUIDIC_SPELL_2968); stage = END_DIALOGUE } //has fungus 80 -> sendDialogue("You show the fungus to Filliman.").also { stage++ } @@ -161,22 +160,22 @@ class NSTarlockDialogue(player: Player? = null) : DialoguePlugin(player) { 120 -> npcl(FacialExpression.NEUTRAL, "Oh really.. Have you placed all the items on the stones? Ok, well, let's try!").also { stage++ } 121 -> sendDialogue("~ The druid attempts to cast a spell. ~").also { stage++ } 122 -> { - ContentAPI.animate(npc, 812) + animate(npc, 812) if(NSUtils.hasPlacedCard(player) && NSUtils.hasPlacedFungus(player) && NSUtils.onStone(player)){ end() player.lock() val locations = arrayOf(Location.create(3439, 3336, 0), Location.create(3441, 3336, 0), Location.create(3440, 3335, 0)) - repeat(3) {i -> ContentAPI.spawnProjectile(locations[i], Location.create(3440, 3336, 0), 268, 0, 35, 0, 100, 20) } - ContentAPI.submitIndividualPulse(player, object : Pulse(4){ + repeat(3) {i -> spawnProjectile(locations[i], Location.create(3440, 3336, 0), 268, 0, 35, 0, 100, 20) } + submitIndividualPulse(player, object : Pulse(4){ override fun pulse(): Boolean { - ContentAPI.sendNPCDialogue(player, npc.originalId, "Aha, everything seems to be in place! You can come through now into the grotto for the final section of my transformation.") + sendNPCDialogue(player, npc.originalId, "Aha, everything seems to be in place! You can come through now into the grotto for the final section of my transformation.") setQuest(55) - ContentAPI.unlock(player) + unlock(player) return true } override fun stop() { - ContentAPI.visualize(npc, -1, Graphics(266, 80)) + visualize(npc, -1, Graphics(266, 80)) super.stop() } }) @@ -187,17 +186,17 @@ class NSTarlockDialogue(player: Player? = null) : DialoguePlugin(player) { stage = END_DIALOGUE } - 130 -> if(ContentAPI.inInventory(player, Items.DRUIDIC_SPELL_2968) || ContentAPI.inBank(player, Items.DRUIDIC_SPELL_2968)){ + 130 -> if(inInventory(player, Items.DRUIDIC_SPELL_2968) || inBank(player, Items.DRUIDIC_SPELL_2968)){ npcl(FacialExpression.NEUTRAL, "No, you've already got one!").also { stage = END_DIALOGUE } } else { npcl(FacialExpression.NEUTRAL, "Sure, but look after this one.") - ContentAPI.addItem(player, Items.DRUIDIC_SPELL_2968) + addItem(player, Items.DRUIDIC_SPELL_2968) stage = END_DIALOGUE } //Initial dialogue 1000 -> playerl(FacialExpression.HALF_ASKING, "Hello?").also { stage++ } - 1001 -> if(ContentAPI.inEquipment(player, Items.GHOSTSPEAK_AMULET_552)){ + 1001 -> if(inEquipment(player, Items.GHOSTSPEAK_AMULET_552)){ npcl(FacialExpression.EXTREMELY_SHOCKED, "Oh, I understand you! At last, someone who doesn't just mumble. I understand what you're saying!").also { stage++ } } else npcl(FacialExpression.HALF_GUILTY, "OooOOoOOoOOOOo.") diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSUtils.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSUtils.kt index c301909bd..752b70d18 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSUtils.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NSUtils.kt @@ -1,7 +1,7 @@ package rs09.game.content.quest.members.naturespirit import api.Container -import api.ContentAPI +import api.* import core.game.node.Node import core.game.node.scenery.Scenery import core.game.node.scenery.SceneryBuilder @@ -19,19 +19,19 @@ import rs09.game.node.entity.npc.other.MortMyreGhastNPC object NSUtils { fun flagFungusPlaced(player: Player) { - ContentAPI.setAttribute(player, "/save:ns:fungus_placed", true) + setAttribute(player, "/save:ns:fungus_placed", true) } fun flagCardPlaced(player: Player){ - ContentAPI.setAttribute(player, "/save:ns:card_placed", true) + setAttribute(player, "/save:ns:card_placed", true) } fun hasPlacedFungus(player: Player): Boolean { - return ContentAPI.getAttribute(player, "ns:fungus_placed", false) + return getAttribute(player, "ns:fungus_placed", false) } fun hasPlacedCard(player: Player): Boolean { - return ContentAPI.getAttribute(player, "ns:card_placed", false) + return getAttribute(player, "ns:card_placed", false) } fun onStone(player: Player): Boolean { @@ -39,11 +39,11 @@ object NSUtils { } fun getGhastKC(player: Player): Int { - return ContentAPI.getAttribute(player,"ns:ghasts_killed", 0) as Int + return getAttribute(player,"ns:ghasts_killed", 0) as Int } fun incrementGhastKC(player: Player){ - ContentAPI.setAttribute(player, "/save:ns:ghasts_killed", getGhastKC(player) + 1) + setAttribute(player, "/save:ns:ghasts_killed", getGhastKC(player) + 1) val msg = when(getGhastKC(player)) { 1 -> "That's one down, two more to go." 2 -> "Two down, only one more to go." @@ -52,25 +52,25 @@ object NSUtils { } if(!msg.isEmpty()){ - ContentAPI.sendMessage(player, msg) + sendMessage(player, msg) } } fun activatePouch(player: Player, attacker: MortMyreGhastNPC): Boolean { var shouldAddEmptyPouch = false - val pouchAmt = ContentAPI.amountInInventory(player, Items.DRUID_POUCH_2958) + val pouchAmt = amountInInventory(player, Items.DRUID_POUCH_2958) if(pouchAmt == 1) shouldAddEmptyPouch = true - if(pouchAmt > 0 && ContentAPI.removeItem(player, Items.DRUID_POUCH_2958, Container.INVENTORY)){ + if(pouchAmt > 0 && removeItem(player, Items.DRUID_POUCH_2958, Container.INVENTORY)){ if(shouldAddEmptyPouch){ - ContentAPI.addItem(player, Items.DRUID_POUCH_2957) + addItem(player, Items.DRUID_POUCH_2957) } - ContentAPI.spawnProjectile(player, attacker, 268) - ContentAPI.submitWorldPulse(object : Pulse(){ + spawnProjectile(player, attacker, 268) + submitWorldPulse(object : Pulse(){ var ticks = 0 override fun pulse(): Boolean { when(ticks++){ - 2 -> ContentAPI.visualize(attacker, -1, Graphics(269, 125)) - 3 -> attacker.transform(attacker.id + 1).also { attacker.attack(player); attacker.setAttribute("woke", ContentAPI.getWorldTicks()); return true } + 2 -> visualize(attacker, -1, Graphics(269, 125)) + 3 -> attacker.transform(attacker.id + 1).also { attacker.attack(player); attacker.setAttribute("woke", getWorldTicks()); return true } } return false } diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NatureSpiritDialogue.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NatureSpiritDialogue.kt index 052b699d5..233a07999 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NatureSpiritDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NatureSpiritDialogue.kt @@ -1,7 +1,7 @@ package rs09.game.content.quest.members.naturespirit import api.Container -import api.ContentAPI +import api.* import core.game.content.dialogue.DialoguePlugin import core.game.content.dialogue.FacialExpression import core.game.node.entity.npc.NPC @@ -57,7 +57,7 @@ class NatureSpiritDialogue(player: Player? = null) : DialoguePlugin(player){ 30 -> npcl(FacialExpression.NEUTRAL, "My blessings will entice nature to bloom in Mort Myre! And then with nature's harvest you can fill a druids pouch and release the Ghasts from their torment.").also { stage = 2 } //this dude kinda weird //have you brought me a sickle yet bro - 100 -> if(ContentAPI.inInventory(player, Items.SILVER_SICKLE_2961)){ + 100 -> if(inInventory(player, Items.SILVER_SICKLE_2961)){ playerl(FacialExpression.FRIENDLY, "Yes, here it is. What are you going to do with it?").also { stage = 110 } } else { playerl(FacialExpression.NEUTRAL, "No sorry, not yet!").also { stage++ } @@ -76,11 +76,11 @@ class NatureSpiritDialogue(player: Player? = null) : DialoguePlugin(player){ /** * Here we go uoooh */ - 112 -> end().also { ContentAPI.lock(player, 10); ContentAPI.submitWorldPulse(SickleBlessPulse(player, npc)) } + 112 -> end().also { lock(player, 10); submitWorldPulse(SickleBlessPulse(player, npc)) } //go kill some ghasts bro 200 -> npcl(FacialExpression.NEUTRAL, "Go forth into Mort Myre and slay three Ghasts. You'll be releasing their souls from Mort Myre.").also { stage++ } - 201 -> ContentAPI.sendItemDialogue(player, Items.DRUID_POUCH_2957, "The nature spirit gives you an empty pouch.").also { stage++; setQuest(75) } + 201 -> sendItemDialogue(player, Items.DRUID_POUCH_2957, "The nature spirit gives you an empty pouch.").also { stage++; setQuest(75) } 202 -> npcl(FacialExpression.NEUTRAL, "You'll need this in order to collect together nature's bounty. It will bind the Ghast to you until you flee or it is defeated.").also { stage = END_DIALOGUE } //Have you killed the ghasts yet bro @@ -135,21 +135,21 @@ class NatureSpiritDialogue(player: Player? = null) : DialoguePlugin(player){ override fun pulse(): Boolean { when(ticks++){ - 0 -> ContentAPI.animate(spirit, 812) + 0 -> animate(spirit, 812) 1 -> repeat(4) { val loc = locs.random() locs.remove(loc) - ContentAPI.spawnProjectile(loc, player.location, 268, 0, 400, 0, 125, 180) - ContentAPI.animate(player, 9021) + spawnProjectile(loc, player.location, 268, 0, 400, 0, 125, 180) + animate(player, 9021) } 4 -> { - if(ContentAPI.removeItem(player, Items.SILVER_SICKLE_2961, Container.INVENTORY)){ - ContentAPI.addItem(player, Items.SILVER_SICKLEB_2963) - ContentAPI.unlock(player) + if(removeItem(player, Items.SILVER_SICKLE_2961, Container.INVENTORY)){ + addItem(player, Items.SILVER_SICKLEB_2963) + unlock(player) player.questRepository.getQuest("Nature Spirit").setStage(player, 70) - ContentAPI.openDialogue(player, NPCs.NATURE_SPIRIT_1051, ContentAPI.findLocalNPC(player, NPCs.NATURE_SPIRIT_1051) as NPC) - ContentAPI.sendMessage(player, "Your sickle has been blessed! You can bless a new sickle by dipping it into the grotto waters.") + openDialogue(player, NPCs.NATURE_SPIRIT_1051, findLocalNPC(player, NPCs.NATURE_SPIRIT_1051) as NPC) + sendMessage(player, "Your sickle has been blessed! You can bless a new sickle by dipping it into the grotto waters.") } } 6 -> return true diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NatureSpiritQuest.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NatureSpiritQuest.kt index 05ac35cbc..b1ce94fa5 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NatureSpiritQuest.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/naturespirit/NatureSpiritQuest.kt @@ -1,6 +1,6 @@ package rs09.game.content.quest.members.naturespirit -import api.ContentAPI +import api.* import core.game.node.entity.player.Player import core.game.node.entity.player.link.quest.Quest import core.game.node.entity.skill.Skills @@ -114,9 +114,9 @@ class NatureSpiritQuest : Quest("Nature Spirit", 95, 94, 2, 307, 0, 1, 110 ) { drawReward(player, "3,000 Crafting XP",ln++) drawReward(player, "2,000 Hitpoints XP", ln++) drawReward(player, "2,000 Defence XP", ln++) - ContentAPI.rewardXP(player, Skills.CRAFTING, 3000.0) - ContentAPI.rewardXP(player, Skills.HITPOINTS, 2000.0) - ContentAPI.rewardXP(player, Skills.DEFENCE, 2000.0) + rewardXP(player, Skills.CRAFTING, 3000.0) + rewardXP(player, Skills.HITPOINTS, 2000.0) + rewardXP(player, Skills.DEFENCE, 2000.0) NSUtils.cleanupAttributes(player) } } diff --git a/Server/src/main/kotlin/rs09/game/content/zone/AlKharidStairsPlugin.kt b/Server/src/main/kotlin/rs09/game/content/zone/AlKharidStairsPlugin.kt index 4c7525f09..483168725 100644 --- a/Server/src/main/kotlin/rs09/game/content/zone/AlKharidStairsPlugin.kt +++ b/Server/src/main/kotlin/rs09/game/content/zone/AlKharidStairsPlugin.kt @@ -1,6 +1,6 @@ package rs09.game.content.zone; -import api.ContentAPI +import api.* import core.cache.def.impl.SceneryDefinition import core.game.content.global.action.DoorActionHandler import core.game.interaction.OptionHandler @@ -28,7 +28,7 @@ class AlKharidStairsPlugin : OptionHandler() { node ?: return false option ?: return false if(node.location == zekeDoorOpened.location || node.location == craftingDoorOpened.location){ - ContentAPI.sendMessage(player,"This door appears to be stuck open.") + sendMessage(player,"This door appears to be stuck open.") } else{ DoorActionHandler.handleDoor(player,node.asScenery()) } diff --git a/Server/src/main/kotlin/rs09/game/content/zone/FarmingPatchZone.kt b/Server/src/main/kotlin/rs09/game/content/zone/FarmingPatchZone.kt index 68145204b..9d97fc2fb 100644 --- a/Server/src/main/kotlin/rs09/game/content/zone/FarmingPatchZone.kt +++ b/Server/src/main/kotlin/rs09/game/content/zone/FarmingPatchZone.kt @@ -1,6 +1,6 @@ package rs09.game.content.zone -import api.ContentAPI +import api.* import core.game.content.dialogue.FacialExpression import core.game.node.entity.Entity import core.game.node.entity.npc.NPC @@ -26,7 +26,7 @@ class FarmingPatchZone : MapZone("farming patch", true), Plugin { registerRegion(12083) registerRegion(10548) register(ZoneBorders(3594,3521,3608,3532)) - ContentAPI.submitWorldPulse(zonePulse) + submitWorldPulse(zonePulse) } override fun newInstance(arg: Any?): Plugin { @@ -39,7 +39,7 @@ class FarmingPatchZone : MapZone("farming patch", true), Plugin { } override fun enter(e: Entity?): Boolean { - if(e is Player && playersInZone[e] == null && ContentAPI.getStatLevel(e, Skills.FARMING) <= 15) { + if(e is Player && playersInZone[e] == null && getStatLevel(e, Skills.FARMING) <= 15) { playersInZone[e] = 0 } return super.enter(e) @@ -61,14 +61,14 @@ class FarmingPatchZone : MapZone("farming patch", true), Plugin { npc.init() npc.moveStep() npc.face(player) - ContentAPI.openDialogue(player, SpiritDialogue(true), npc) + openDialogue(player, SpiritDialogue(true), npc) } else if (ticks == secondsToTicks(TimeUnit.MINUTES.toSeconds(10).toInt())){ val npc = NPC(NPCs.GITHAN_7122) npc.location = player.location npc.init() npc.moveStep() npc.face(player) - ContentAPI.openDialogue(player, SpiritDialogue(false), npc) + openDialogue(player, SpiritDialogue(false), npc) playersInZone.remove(player) } @@ -91,7 +91,7 @@ class FarmingPatchZone : MapZone("farming patch", true), Plugin { override fun end(){ super.end() - ContentAPI.poofClear(npc ?: return) + poofClear(npc ?: return) } } diff --git a/Server/src/main/kotlin/rs09/game/content/zone/phasmatys/bonegrinder/BoneGrinderListener.kt b/Server/src/main/kotlin/rs09/game/content/zone/phasmatys/bonegrinder/BoneGrinderListener.kt index b4f8ff8d3..39029ffe7 100644 --- a/Server/src/main/kotlin/rs09/game/content/zone/phasmatys/bonegrinder/BoneGrinderListener.kt +++ b/Server/src/main/kotlin/rs09/game/content/zone/phasmatys/bonegrinder/BoneGrinderListener.kt @@ -1,7 +1,7 @@ package rs09.game.content.zone.phasmatys.bonegrinder import api.Container -import api.ContentAPI +import api.* import core.game.content.global.Bones import core.game.node.entity.player.Player import core.game.node.item.Item @@ -71,15 +71,15 @@ class BoneGrinderListener : InteractionListener() { fun handleFill(player: Player): Boolean{ val bone = getBone(player) if(bone == null){ - ContentAPI.sendMessage(player,"You have no bones to grind.") + sendMessage(player,"You have no bones to grind.") return true } - if(ContentAPI.getAttribute(player,BONE_HOPPER_KEY,false)){ - ContentAPI.sendMessage(player,"You already have some bones in the hopper.") + if(getAttribute(player,BONE_HOPPER_KEY,false)){ + sendMessage(player,"You already have some bones in the hopper.") return true } - if(ContentAPI.getAttribute(player,BONE_BIN_KEY,false)){ - ContentAPI.sendMessage(player,"You already have some bonemeal that needs to be collected.") + if(getAttribute(player,BONE_BIN_KEY,false)){ + sendMessage(player,"You already have some bonemeal that needs to be collected.") return true } @@ -88,14 +88,14 @@ class BoneGrinderListener : InteractionListener() { override fun pulse(): Boolean { when(stage++){ 0 -> { - ContentAPI.lock(player, FILL_ANIM.duration) - ContentAPI.animate(player,FILL_ANIM) + lock(player, FILL_ANIM.duration) + animate(player,FILL_ANIM) } FILL_ANIM.duration -> { - ContentAPI.sendMessage(player,"You fill the hopper with bones.") - ContentAPI.removeItem(player,Item(bone.itemId),Container.INVENTORY) - ContentAPI.setAttribute(player,LOADED_BONE_KEY,bone.ordinal) - ContentAPI.setAttribute(player,BONE_HOPPER_KEY,true) + sendMessage(player,"You fill the hopper with bones.") + removeItem(player,Item(bone.itemId),Container.INVENTORY) + setAttribute(player,LOADED_BONE_KEY,bone.ordinal) + setAttribute(player,BONE_HOPPER_KEY,true) return true } } @@ -103,15 +103,15 @@ class BoneGrinderListener : InteractionListener() { } } - if(ContentAPI.inInventory(player,bone.itemId)){ + if(inInventory(player,bone.itemId)){ player.pulseManager.run(object : Pulse(){ var stage = 0 override fun pulse(): Boolean { when(stage++){ 0 -> Pulser.submit(fillPulse).also { delay = FILL_ANIM.duration + 1} 1 -> { - ContentAPI.stopWalk(player) - ContentAPI.forceWalk(player,Location(3659,3524),"smart") + stopWalk(player) + forceWalk(player,Location(3659,3524),"smart") delay = 2 } 2 -> { @@ -119,12 +119,12 @@ class BoneGrinderListener : InteractionListener() { delay = WIND_ANIM.duration + 1 } 3 -> { - ContentAPI.stopWalk(player) - ContentAPI.forceWalk(player,Location(3658,3524),"smart") + stopWalk(player) + forceWalk(player,Location(3658,3524),"smart") delay = 2 } 4 -> { - if(!ContentAPI.inInventory(player,Items.EMPTY_POT_1931,1)){ + if(!inInventory(player,Items.EMPTY_POT_1931,1)){ return handleEmpty(player) } else { handleEmpty(player) @@ -132,12 +132,12 @@ class BoneGrinderListener : InteractionListener() { } } 5 -> { - ContentAPI.stopWalk(player) - ContentAPI.forceWalk(player,Location(3660,3524),"smart") + stopWalk(player) + forceWalk(player,Location(3660,3524),"smart") delay = 4 } 6 -> { - ContentAPI.face(player,Location(3660,3526)) + face(player,Location(3660,3526)) handleFill(player) return true } @@ -152,13 +152,13 @@ class BoneGrinderListener : InteractionListener() { } fun handleWind(player: Player): Boolean{ - if(!ContentAPI.getAttribute(player,BONE_HOPPER_KEY,false)){ - ContentAPI.sendMessage(player,"You have no bones loaded to grind.") + if(!getAttribute(player,BONE_HOPPER_KEY,false)){ + sendMessage(player,"You have no bones loaded to grind.") return true } - if(ContentAPI.getAttribute(player,BONE_BIN_KEY,false)){ - ContentAPI.sendMessage(player,"You already have some bonemeal which you need to collect.") + if(getAttribute(player,BONE_BIN_KEY,false)){ + sendMessage(player,"You already have some bonemeal which you need to collect.") return true } @@ -167,15 +167,15 @@ class BoneGrinderListener : InteractionListener() { override fun pulse(): Boolean { when(stage++){ 0 -> { - ContentAPI.face(player,Location(3659, 3526, 1)) - ContentAPI.lock(player,WIND_ANIM.duration) - ContentAPI.animate(player,WIND_ANIM) - ContentAPI.sendMessage(player,"You wind the handle.") + face(player,Location(3659, 3526, 1)) + lock(player,WIND_ANIM.duration) + animate(player,WIND_ANIM) + sendMessage(player,"You wind the handle.") } WIND_ANIM.duration -> { - ContentAPI.sendMessage(player,"The bonemeal falls into the bin.") - ContentAPI.setAttribute(player,BONE_HOPPER_KEY,false) - ContentAPI.setAttribute(player,BONE_BIN_KEY,true) + sendMessage(player,"The bonemeal falls into the bin.") + setAttribute(player,BONE_HOPPER_KEY,false) + setAttribute(player,BONE_BIN_KEY,true) return true } } @@ -186,36 +186,36 @@ class BoneGrinderListener : InteractionListener() { } private fun handleStatus(player: Player): Boolean{ - val bonesLoaded = ContentAPI.getAttribute(player,BONE_HOPPER_KEY,false) - val boneMealReady = ContentAPI.getAttribute(player,BONE_BIN_KEY,false) + val bonesLoaded = getAttribute(player,BONE_HOPPER_KEY,false) + val boneMealReady = getAttribute(player,BONE_BIN_KEY,false) - if(bonesLoaded) ContentAPI.sendMessage(player,"There are bones waiting in the hopper.") - if(boneMealReady) ContentAPI.sendMessage(player,"There is bonemeal waiting in the bin to be collected.") + if(bonesLoaded) sendMessage(player,"There are bones waiting in the hopper.") + if(boneMealReady) sendMessage(player,"There is bonemeal waiting in the bin to be collected.") if(!bonesLoaded && !boneMealReady){ - ContentAPI.sendMessage(player,"There is nothing loaded into the machine.") + sendMessage(player,"There is nothing loaded into the machine.") } return true } fun handleEmpty(player: Player): Boolean{ - if(!ContentAPI.getAttribute(player,BONE_BIN_KEY,false)){ - ContentAPI.sendMessage(player,"You have no bonemeal to collect.") + if(!getAttribute(player,BONE_BIN_KEY,false)){ + sendMessage(player,"You have no bonemeal to collect.") return true } - if(ContentAPI.getAttribute(player,BONE_HOPPER_KEY,false) && !ContentAPI.getAttribute(player,BONE_BIN_KEY,false)){ - ContentAPI.sendMessage(player,"You need to wind the wheel to grind the bones.") + if(getAttribute(player,BONE_HOPPER_KEY,false) && !getAttribute(player,BONE_BIN_KEY,false)){ + sendMessage(player,"You need to wind the wheel to grind the bones.") return true } - if(!ContentAPI.inInventory(player,Items.EMPTY_POT_1931,1)){ - ContentAPI.sendMessage(player,"You don't have any pots to take the bonemeal with.") + if(!inInventory(player,Items.EMPTY_POT_1931,1)){ + sendMessage(player,"You don't have any pots to take the bonemeal with.") return true } - val bone = Bones.values()[ContentAPI.getAttribute(player,LOADED_BONE_KEY,-1)] + val bone = Bones.values()[getAttribute(player,LOADED_BONE_KEY,-1)] Pulser.submit(object : Pulse(){ @@ -223,16 +223,16 @@ class BoneGrinderListener : InteractionListener() { override fun pulse(): Boolean { when(stage++){ 0 -> { - ContentAPI.face(player,Location(3658, 3525, 1)) - ContentAPI.lock(player, SCOOP_ANIM.duration) - ContentAPI.animate(player,SCOOP_ANIM) + face(player,Location(3658, 3525, 1)) + lock(player, SCOOP_ANIM.duration) + animate(player,SCOOP_ANIM) } SCOOP_ANIM.duration -> { - if(ContentAPI.removeItem(player,Item(Items.EMPTY_POT_1931),Container.INVENTORY)){ - ContentAPI.addItem(player,bone.boneMeal.id) - ContentAPI.setAttribute(player,BONE_BIN_KEY,false) - ContentAPI.setAttribute(player,BONE_HOPPER_KEY,false) - ContentAPI.setAttribute(player,LOADED_BONE_KEY,-1) + if(removeItem(player,Item(Items.EMPTY_POT_1931),Container.INVENTORY)){ + addItem(player,bone.boneMeal.id) + setAttribute(player,BONE_BIN_KEY,false) + setAttribute(player,BONE_HOPPER_KEY,false) + setAttribute(player,LOADED_BONE_KEY,-1) } return true } @@ -245,7 +245,7 @@ class BoneGrinderListener : InteractionListener() { fun getBone(player: Player): Bones? { for(bone in Bones.values()){ - if(ContentAPI.inInventory(player,bone.itemId)) return bone + if(inInventory(player,bone.itemId)) return bone } return null } diff --git a/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt b/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt index bb6e364a6..e5375eac5 100644 --- a/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt +++ b/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt @@ -1,6 +1,6 @@ package rs09.game.ge -import api.ContentAPI +import api.* import rs09.ServerConstants import core.cache.def.impl.ItemDefinition import core.game.content.eco.EcoStatus @@ -510,7 +510,7 @@ object OfferManager { } private fun getItemDefPrice(itemID: Int): Int { - return max(ContentAPI.itemDefinition(itemID).getConfiguration(ItemConfigParser.GE_PRICE) ?: 0, ContentAPI.itemDefinition(itemID).value) + return max(itemDefinition(itemID).getConfiguration(ItemConfigParser.GE_PRICE) ?: 0, itemDefinition(itemID).value) } @JvmStatic diff --git a/Server/src/main/kotlin/rs09/game/ge/PlayerGrandExchange.kt b/Server/src/main/kotlin/rs09/game/ge/PlayerGrandExchange.kt index a2c31eeb3..25f262023 100644 --- a/Server/src/main/kotlin/rs09/game/ge/PlayerGrandExchange.kt +++ b/Server/src/main/kotlin/rs09/game/ge/PlayerGrandExchange.kt @@ -1,6 +1,6 @@ package rs09.game.ge -import api.ContentAPI +import api.* import core.cache.def.impl.ItemDefinition import core.game.component.CloseEvent import core.game.component.Component @@ -318,7 +318,7 @@ class PlayerGrandExchange(private val player: Player) { temporaryOffer!!.itemID = itemId temporaryOffer!!.sell = false var itemDb = GrandExchangeDatabase.getDatabase()[itemId] - if (itemDb == null || !ContentAPI.itemDefinition(itemId).isTradeable) { + if (itemDb == null || !itemDefinition(itemId).isTradeable) { player.packetDispatch.sendMessage("This item has been blacklisted from the Grand Exchange.") return } diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/CreditShopInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/CreditShopInterface.kt index 6a7e82d4c..781c5c87c 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/CreditShopInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/CreditShopInterface.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.inter -import api.ContentAPI +import api.* import core.game.node.entity.player.Player import core.game.node.item.Item import org.rs09.consts.Components @@ -17,7 +17,7 @@ class CreditShopInterface : InterfaceListener() { val item = getItem(buttonID) if(opcode == 155){ - ContentAPI.sendDialogue(player, "This item costs ${item.price} credits.") + sendDialogue(player, "This item costs ${item.price} credits.") return@on true } @@ -59,19 +59,19 @@ class CreditShopInterface : InterfaceListener() { } fun sendCredits(player: Player){ - ContentAPI.setInterfaceText(player, "You have ${player.details.credits} credits to spend.", CREDIT_SHOP, TEXT_CHILD) + setInterfaceText(player, "You have ${player.details.credits} credits to spend.", CREDIT_SHOP, TEXT_CHILD) } fun attemptPurchase(player: Player, item: Int, price: Int){ if(player.details.credits < price){ - ContentAPI.sendDialogue(player, "You don't have enough credits for that.") + sendDialogue(player, "You don't have enough credits for that.") return } if(player.inventory.add(Item(item))){ player.details.credits -= price } else { - ContentAPI.sendDialogue(player, "You don't have enough inventory space for that.") + sendDialogue(player, "You don't have enough inventory space for that.") } sendCredits(player) } diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/ExperienceInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/ExperienceInterface.kt index 666b376f1..b8e4e1215 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/ExperienceInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/ExperienceInterface.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.inter -import api.ContentAPI +import api.* import core.game.component.Component import core.game.component.ComponentDefinition import core.game.component.ComponentPlugin @@ -41,8 +41,8 @@ class ExperienceInterface() : ComponentPlugin() { if(caller is Plugin<*>) caller.handleSelectionCallback(confirmedSkill, player) else (caller as (Int,Player) -> Unit).invoke(confirmedSkill,player) - ContentAPI.playAudio(player, SOUND) - ContentAPI.closeInterface(player) + playAudio(player, SOUND) + closeInterface(player) } } else { val skill = when (button) { diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt index a8ab9cb88..246729a4f 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.inter -import api.ContentAPI +import api.* import core.game.component.Component import core.game.content.dialogue.FacialExpression import core.game.node.entity.player.Player @@ -37,13 +37,13 @@ class FairyRingInterface : InterfaceListener(){ } onClose(RINGS){player, _ -> - ContentAPI.closeTabInterface(player) + closeTabInterface(player) player.removeAttribute("fr:ring1") player.removeAttribute("fr:ring2") player.removeAttribute("fr:ring3") - ContentAPI.clearVarp(player, 816) - ContentAPI.setVarbit(player, 816, 0, 0) - ContentAPI.closeTabInterface(player) + clearVarp(player, 816) + setVarbit(player, 816, 0, 0) + closeTabInterface(player) return@onClose true } @@ -76,7 +76,7 @@ class FairyRingInterface : InterfaceListener(){ toSet = !toSet player.setAttribute("fr:sortorder",toSet) if(toSet) { - ContentAPI.setVarbit(player, 816, 0, ring1index) + setVarbit(player, 816, 0, ring1index) player.setAttribute("fr:ring2",0) player.setAttribute("fr:ring3",0) } @@ -110,7 +110,7 @@ class FairyRingInterface : InterfaceListener(){ val ring: FairyRing? = FairyRing.valueOf(code.toUpperCase()) var tile = ring?.tile if(ring == FairyRing.CIP){ - ContentAPI.sendDialogue(player, "The ring seems to reject you.") + sendDialogue(player, "The ring seems to reject you.") } if (ring == null || tile == null) { val center = Location(2412, 4434, 0) @@ -124,7 +124,7 @@ class FairyRingInterface : InterfaceListener(){ } World.Pulser.submit(object : Pulse(4, player) { override fun pulse(): Boolean { - ContentAPI.sendPlayerDialogue(player, "Wow, fairy magic sure is useful, I hardly moved at all!", FacialExpression.AMAZED) + sendPlayerDialogue(player, "Wow, fairy magic sure is useful, I hardly moved at all!", FacialExpression.AMAZED) return true } }) @@ -133,8 +133,8 @@ class FairyRingInterface : InterfaceListener(){ player.savedData.globalData.setTravelLog(ring.ordinal) } } - ContentAPI.closeInterface(player) - ContentAPI.teleport(player, tile!!, TeleportManager.TeleportType.FAIRY_RING) + closeInterface(player) + teleport(player, tile!!, TeleportManager.TeleportType.FAIRY_RING) } } @@ -192,7 +192,7 @@ enum class FairyRing(val tile: Location?, val tip: String = "", val childId: Int if (ring.childId == -1) { continue } - ContentAPI.setInterfaceText(player, "
${ring.tip}", 735, ring.childId) + setInterfaceText(player, "
${ring.tip}", 735, ring.childId) } } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/FurClothingInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/FurClothingInterface.kt index 26ad97c93..4c89fe4ae 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/FurClothingInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/FurClothingInterface.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.inter -import api.ContentAPI +import api.* import core.game.component.Component import core.game.component.ComponentDefinition import core.game.component.ComponentPlugin @@ -97,8 +97,8 @@ class FurClothingInterface : ComponentPlugin(){ val checkedFurs = arrayListOf() for(CLOTHING in FUR_CLOTHING.values()){ if(checkedFurs.contains(CLOTHING.textContent)) continue - if(ContentAPI.inInventory(player, CLOTHING.requiredFur.id, CLOTHING.requiredFur.amount)){ - ContentAPI.setInterfaceText(player, colorize("%G${CLOTHING.textContent}"), FUR_CLOTHING_COMPONENT_ID, CLOTHING.textChildID) + if(inInventory(player, CLOTHING.requiredFur.id, CLOTHING.requiredFur.amount)){ + setInterfaceText(player, colorize("%G${CLOTHING.textContent}"), FUR_CLOTHING_COMPONENT_ID, CLOTHING.textChildID) checkedFurs.add(CLOTHING.textContent) } } @@ -144,7 +144,7 @@ class FurClothingInterface : ComponentPlugin(){ } private fun value(player: Player, clothing: FUR_CLOTHING){ - ContentAPI.sendMessage(player,"${clothing.product.name} requires ${clothing.requiredFur.amount} ${clothing.requiredFur.name.toLowerCase()} and costs ${clothing.price} coins.") + sendMessage(player,"${clothing.product.name} requires ${clothing.requiredFur.amount} ${clothing.requiredFur.name.toLowerCase()} and costs ${clothing.price} coins.") } private fun buy(player: Player, clothing: FUR_CLOTHING, amount: Int){ @@ -152,19 +152,19 @@ class FurClothingInterface : ComponentPlugin(){ val amtFurRequired = clothing.requiredFur.amount * amount val requiredFur = Item(clothing.requiredFur.id,amtFurRequired) - if(!ContentAPI.inInventory(player, requiredFur.id, requiredFur.amount)){ - ContentAPI.sendDialogue(player, "You don't have enough fur for that.") + if(!inInventory(player, requiredFur.id, requiredFur.amount)){ + sendDialogue(player, "You don't have enough fur for that.") return } - if(!ContentAPI.inInventory(player, coins.id, coins.amount)){ - ContentAPI.sendDialogue(player,"You can't afford that.") + if(!inInventory(player, coins.id, coins.amount)){ + sendDialogue(player,"You can't afford that.") return } - ContentAPI.removeItem(player, requiredFur, api.Container.INVENTORY) - ContentAPI.removeItem(player, coins, api.Container.INVENTORY) - ContentAPI.addItem(player, clothing.product.id, amount) + removeItem(player, requiredFur, api.Container.INVENTORY) + removeItem(player, coins, api.Container.INVENTORY) + addItem(player, clothing.product.id, amount) } override fun newInstance(arg: Any?): Plugin { diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/HairDresserInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/HairDresserInterface.kt index edd15a528..ed7abf8a9 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/HairDresserInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/HairDresserInterface.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.inter -import api.ContentAPI +import api.* import core.game.component.Component import core.game.component.ComponentDefinition import core.game.component.ComponentPlugin @@ -142,9 +142,9 @@ class HairDresserInterface : ComponentPlugin(){ HAIRDRESSER_MALE_COMPONENT_ID -> 61 else -> 0 } - ContentAPI.sendPlayerOnInterface(player, usedInterface, player_model_child) - ContentAPI.sendPlayerOnInterface(player, usedInterface, player_head_child) - ContentAPI.sendAnimationOnInterface(player, FacialExpression.HAPPY.animationId, usedInterface, player_head_child) + sendPlayerOnInterface(player, usedInterface, player_model_child) + sendPlayerOnInterface(player, usedInterface, player_head_child) + sendAnimationOnInterface(player, FacialExpression.HAPPY.animationId, usedInterface, player_head_child) player.toggleWardrobe(true) component?.setCloseEvent{pl,_ -> diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/MainGameInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/MainGameInterface.kt index 8558a1813..7bd711643 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/MainGameInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/MainGameInterface.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.inter -import api.ContentAPI +import api.* import core.game.component.CloseEvent import core.game.component.Component import core.game.content.quest.tutorials.tutorialisland.TutorialSession @@ -33,12 +33,12 @@ class MainGameInterface : InterfaceListener() { on(TOPLEVEL_FS){player, _, _, buttonID, _, _ -> when (buttonID) { - 12 -> ContentAPI.setInterfaceText(player, + 12 -> setInterfaceText(player, "When you have finished playing " + settings!!.name + ", always use the button below to logout safely. ", 182, 0 ) - 49 -> ContentAPI.setInterfaceText(player, + 49 -> setInterfaceText(player, "Friends List - " + settings!!.name + " " + settings!!.worldId, 550, 3 diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/SilverInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/SilverInterface.kt index dd86e0f0b..3e398929a 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/SilverInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/SilverInterface.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.inter -import api.ContentAPI +import api.* import core.game.node.entity.player.Player import core.game.node.entity.player.link.diary.DiaryType import core.game.node.entity.skill.Skills @@ -14,49 +14,49 @@ import rs09.game.interaction.InterfaceListener class SilverInterface : InterfaceListener() { val IFACE = Components.CRAFTING_SILVER_CASTING_438 - val ANIM = ContentAPI.getAnimation(899) + val ANIM = getAnimation(899) override fun defineListeners() { onOpen(IFACE){player, _ -> - ContentAPI.sendItemOnInterface(player, IFACE, 17, 1718) - ContentAPI.sendItemOnInterface(player, IFACE, 24, 1724) - ContentAPI.sendItemOnInterface(player, IFACE, 31, 2961) - ContentAPI.sendItemOnInterface(player, IFACE, 38, 4201) - ContentAPI.sendItemOnInterface(player, IFACE, 45, 5525) - ContentAPI.sendItemOnInterface(player, IFACE, 53, 7637) - ContentAPI.sendItemOnInterface(player, IFACE, 60, 6748) - ContentAPI.sendItemOnInterface(player, IFACE, 67, 9382) - ContentAPI.sendItemOnInterface(player, IFACE, 74, 13154) + sendItemOnInterface(player, IFACE, 17, 1718) + sendItemOnInterface(player, IFACE, 24, 1724) + sendItemOnInterface(player, IFACE, 31, 2961) + sendItemOnInterface(player, IFACE, 38, 4201) + sendItemOnInterface(player, IFACE, 45, 5525) + sendItemOnInterface(player, IFACE, 53, 7637) + sendItemOnInterface(player, IFACE, 60, 6748) + sendItemOnInterface(player, IFACE, 67, 9382) + sendItemOnInterface(player, IFACE, 74, 13154) return@onOpen true } on(IFACE){player, _, opcode, buttonID, _, _ -> val product = SilverProduct.forId(buttonID) ?: return@on true - if(!ContentAPI.inInventory(player, product.needed)){ - ContentAPI.sendMessage(player, "You need a ${ContentAPI.itemDefinition(product.needed).name.toLowerCase()} to make this item.") + if(!inInventory(player, product.needed)){ + sendMessage(player, "You need a ${itemDefinition(product.needed).name.toLowerCase()} to make this item.") return@on true } if(product == SilverProduct.SILVTHRIL_ROD || product == SilverProduct.SILVTHRIL_CHAIN){ - ContentAPI.sendMessage(player, "You can't do that yet.") + sendMessage(player, "You can't do that yet.") return@on true } - if(!ContentAPI.hasLevelDyn(player, Skills.CRAFTING, product.level)){ - ContentAPI.sendMessage(player, "You need a Crafting level of ${product.level} to make this.") + if(!hasLevelDyn(player, Skills.CRAFTING, product.level)){ + sendMessage(player, "You need a Crafting level of ${product.level} to make this.") return@on true } val amt = when(opcode){ 155 -> 1 196 -> 5 - 124 -> ContentAPI.amountInInventory(player, Items.SILVER_BAR_2355) + 124 -> amountInInventory(player, Items.SILVER_BAR_2355) 199 -> -1 //Make X else -> return@on true } - if(amt == -1) ContentAPI.sendInputDialogue(player, true, "Enter the amount:"){value -> + if(amt == -1) sendInputDialogue(player, true, "Enter the amount:"){value -> make(player,product,value as Int) } else make(player, product, amt) return@on true @@ -65,18 +65,18 @@ class SilverInterface : InterfaceListener() { fun make(player: Player, product: SilverProduct, amount: Int){ var amt = amount - ContentAPI.closeInterface(player) - ContentAPI.submitWorldPulse(object : Pulse(){ + closeInterface(player) + submitWorldPulse(object : Pulse(){ override fun pulse(): Boolean { if(amt < 1) return true - if(!ContentAPI.inInventory(player, product.needed) || !ContentAPI.inInventory(player, Items.SILVER_BAR_2355)) return true; - ContentAPI.animate(player, ANIM) + if(!inInventory(player, product.needed) || !inInventory(player, Items.SILVER_BAR_2355)) return true; + animate(player, ANIM) - if(ContentAPI.removeItem(player, Items.SILVER_BAR_2355, api.Container.INVENTORY)){ - ContentAPI.addItem(player, product.product, if(product == SilverProduct.SILVER_BOLTS) 10 else 1) - ContentAPI.rewardXP(player, Skills.CRAFTING, product.exp) + if(removeItem(player, Items.SILVER_BAR_2355, api.Container.INVENTORY)){ + addItem(player, product.product, if(product == SilverProduct.SILVER_BOLTS) 10 else 1) + rewardXP(player, Skills.CRAFTING, product.exp) - if(product == SilverProduct.UNBLESSED && player.location.withinDistance(ContentAPI.location(3226,3254,0))){ + if(product == SilverProduct.UNBLESSED && player.location.withinDistance(location(3226,3254,0))){ player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 2, 8) } delay = 3 @@ -93,7 +93,7 @@ class SilverBarUseWith : InteractionListener() { val FURNACES = intArrayOf(2966, 3044, 3294, 4304, 6189, 11009, 11010, 11666, 12100, 12809, 18497, 18525, 18526, 21879, 22721, 26814, 28433, 28434, 30021, 30510, 36956, 37651) override fun defineListeners() { onUseWith(SCENERY, Items.SILVER_BAR_2355, *FURNACES){ player, _, _ -> - ContentAPI.openInterface(player, Components.CRAFTING_SILVER_CASTING_438) + openInterface(player, Components.CRAFTING_SILVER_CASTING_438) return@onUseWith true } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/BraceletOfClayPlugin.kt b/Server/src/main/kotlin/rs09/game/interaction/item/BraceletOfClayPlugin.kt index ab0107422..35d3c3ed1 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/BraceletOfClayPlugin.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/BraceletOfClayPlugin.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.item -import api.ContentAPI +import api.* import rs09.game.interaction.InteractionListener /** @@ -14,8 +14,8 @@ class BraceletOfClayPlugin : InteractionListener() { override fun defineListeners() { on(BRACELET,ITEM,"operate"){player,node -> - var charge = ContentAPI.getCharge(node) - if (charge > 28) ContentAPI.setCharge(node, 28).also { charge = 28 } + var charge = getCharge(node) + if (charge > 28) setCharge(node, 28).also { charge = 28 } player.sendMessage("You have $charge uses left.") return@on true } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/CulChestItems.kt b/Server/src/main/kotlin/rs09/game/interaction/item/CulChestItems.kt index 3d9a4efc4..042674d99 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/CulChestItems.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/CulChestItems.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.item -import api.ContentAPI +import api.* import core.game.node.Node import core.game.node.entity.player.Player import core.game.node.item.GroundItemManager @@ -43,14 +43,14 @@ class CulChestItems: InteractionListener() { } fun alchemize(player: Player, node: Node): Boolean{ - val amount = ContentAPI.amountInInventory(player, node.id) + ContentAPI.amountInEquipment(player, node.id) - val coins = amount * ContentAPI.itemDefinition(node.id).value + val amount = amountInInventory(player, node.id) + amountInEquipment(player, node.id) + val coins = amount * itemDefinition(node.id).value - ContentAPI.removeAll(player, node.id, api.Container.INVENTORY) - ContentAPI.removeItem(player, node.id, api.Container.EQUIPMENT) - ContentAPI.addItemOrDrop(player, 995, coins) + removeAll(player, node.id, api.Container.INVENTORY) + removeItem(player, node.id, api.Container.EQUIPMENT) + addItemOrDrop(player, 995, coins) - ContentAPI.sendDialogue(player, "The item instantly alchemized itself!") + sendDialogue(player, "The item instantly alchemized itself!") return false //tell equip handler not to equip the gloves at all if they still even exist lel } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/GodBookListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/item/GodBookListeners.kt index 7e2b75ae0..a92ae4090 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/GodBookListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/GodBookListeners.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.item -import api.ContentAPI +import api.* import core.game.node.entity.player.Player import core.game.system.task.Pulse import core.game.world.update.flag.context.Animation @@ -17,17 +17,17 @@ class GodBookListeners : InteractionListener() { override fun defineListeners() { on(GB_SARADOMIN, ITEM, "preach"){player, _ -> - ContentAPI.openDialogue(player, HOLY_DIALOGUE(BOOK.SARA)) + openDialogue(player, HOLY_DIALOGUE(BOOK.SARA)) return@on true } on(GB_ZAMORAK, ITEM, "preach"){ player, _ -> - ContentAPI.openDialogue(player, HOLY_DIALOGUE(BOOK.ZAM)) + openDialogue(player, HOLY_DIALOGUE(BOOK.ZAM)) return@on true } on(GB_GUTHIX, ITEM, "preach"){ player, _ -> - ContentAPI.openDialogue(player, HOLY_DIALOGUE(BOOK.GUTHIX)) + openDialogue(player, HOLY_DIALOGUE(BOOK.GUTHIX)) return@on true } } @@ -112,18 +112,18 @@ class GodBookListeners : InteractionListener() { BOOK.GUTHIX -> PREACH_GUTH_AMEN } - val lastTick = ContentAPI.animationDuration(animation) + val lastTick = animationDuration(animation) - ContentAPI.lock(player, 100) - ContentAPI.animate(player, animation) + lock(player, 100) + animate(player, animation) - ContentAPI.submitIndividualPulse(player, object : Pulse() { + submitIndividualPulse(player, object : Pulse() { var counter = 0 override fun pulse(): Boolean { when(counter++){ - 0 -> ContentAPI.sendChat(player, message) - lastTick - 1 -> if(preach) ContentAPI.sendChat(player, preachText) - lastTick -> ContentAPI.unlock(player).also { return true } + 0 -> sendChat(player, message) + lastTick - 1 -> if(preach) sendChat(player, preachText) + lastTick -> unlock(player).also { return true } } return false } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/GrandSeedPodHandler.kt b/Server/src/main/kotlin/rs09/game/interaction/item/GrandSeedPodHandler.kt index 1488de6f4..a950f3a05 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/GrandSeedPodHandler.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/GrandSeedPodHandler.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.item -import api.ContentAPI +import api.* import core.game.content.global.travel.glider.GliderPulse import core.game.content.global.travel.glider.Gliders import core.game.node.entity.player.Player @@ -25,12 +25,12 @@ class GrandSeedPodHandler : InteractionListener() { override fun defineListeners() { on(Items.GRAND_SEED_POD_9469, ITEM, "squash", "launch"){player, _ -> - when(ContentAPI.getUsedOption(player)){ - "launch" -> ContentAPI.submitWorldPulse(LaunchPulse(player)) - "squash" -> ContentAPI.submitWorldPulse(SquashPulse(player)) + when(getUsedOption(player)){ + "launch" -> submitWorldPulse(LaunchPulse(player)) + "squash" -> submitWorldPulse(SquashPulse(player)) } - ContentAPI.removeItem(player, Items.GRAND_SEED_POD_9469, api.Container.INVENTORY) - ContentAPI.lock(player, 50) + removeItem(player, Items.GRAND_SEED_POD_9469, api.Container.INVENTORY) + lock(player, 50) return@on true } } @@ -39,9 +39,9 @@ class GrandSeedPodHandler : InteractionListener() { var counter = 0 override fun pulse(): Boolean { when(counter++){ - 1 -> ContentAPI.visualize(player, LAUNCH_ANIMATION, LAUNCH_GRAPHICS) - 3 -> ContentAPI.rewardXP(player, Skills.FARMING, 100.0) - 4 -> ContentAPI.submitWorldPulse(GliderPulse(2,player,Gliders.TA_QUIR_PRIW)).also { return true } + 1 -> visualize(player, LAUNCH_ANIMATION, LAUNCH_GRAPHICS) + 3 -> rewardXP(player, Skills.FARMING, 100.0) + 4 -> submitWorldPulse(GliderPulse(2,player,Gliders.TA_QUIR_PRIW)).also { return true } } return false } @@ -51,12 +51,12 @@ class GrandSeedPodHandler : InteractionListener() { var counter = 0 override fun pulse(): Boolean { when(counter++){ - 1 -> ContentAPI.visualize(player, SQUASH_ANIM_BEGIN, SQUASH_GRAPHICS_BEGIN) - 4 -> ContentAPI.animate(player, 1241, true) - 5 -> ContentAPI.teleport(player, Location.create(2464, 3494, 0)) - 6 -> ContentAPI.visualize(player, anim = 1241, gfx = SQUASH_GRAPHICS_END) - 8 -> ContentAPI.animate(player, SQUASH_ANIM_END, true).also { ContentAPI.adjustLevel(player, Skills.FARMING, -5) } - 9 -> ContentAPI.unlock(player).also { return true } + 1 -> visualize(player, SQUASH_ANIM_BEGIN, SQUASH_GRAPHICS_BEGIN) + 4 -> animate(player, 1241, true) + 5 -> teleport(player, Location.create(2464, 3494, 0)) + 6 -> visualize(player, anim = 1241, gfx = SQUASH_GRAPHICS_END) + 8 -> animate(player, SQUASH_ANIM_END, true).also { adjustLevel(player, Skills.FARMING, -5) } + 9 -> unlock(player).also { return true } } return false } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/ImplingJarListener.kt b/Server/src/main/kotlin/rs09/game/interaction/item/ImplingJarListener.kt index d9ba9e9e6..c8099c25b 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/ImplingJarListener.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/ImplingJarListener.kt @@ -1,7 +1,7 @@ package rs09.game.interaction.item import api.Container -import api.ContentAPI +import api.* import core.game.content.ttrail.ClueScrollPlugin import org.rs09.consts.Items import rs09.game.content.global.WeightBasedTable @@ -19,9 +19,9 @@ class ImplingJarListener : InteractionListener() { val loot = ImplingLoot.forId(jar.id)?.roll()?.first() ?: return@on false - if(ContentAPI.removeItem(player, jar, Container.INVENTORY)) { - ContentAPI.addItemOrDrop(player, loot.id, loot.amount) - ContentAPI.addItemOrDrop(player, Items.IMPLING_JAR_11260, 1) + if(removeItem(player, jar, Container.INVENTORY)) { + addItemOrDrop(player, loot.id, loot.amount) + addItemOrDrop(player, Items.IMPLING_JAR_11260, 1) } return@on true diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/LegendsCapeLock.kt b/Server/src/main/kotlin/rs09/game/interaction/item/LegendsCapeLock.kt index f4c4a86f8..d4f0d5cf7 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/LegendsCapeLock.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/LegendsCapeLock.kt @@ -1,14 +1,14 @@ package rs09.game.interaction.item -import api.ContentAPI +import api.* import org.rs09.consts.Items import rs09.game.interaction.InteractionListener class LegendsCapeLock : InteractionListener() { override fun defineListeners() { onEquip(Items.CAPE_OF_LEGENDS_1052){player, node -> - val points = ContentAPI.getQP(player) - if(points < 40) ContentAPI.sendDialogue(player, "You need 40 QP to equip that.") + val points = getQP(player) + if(points < 40) sendDialogue(player, "You need 40 QP to equip that.") return@onEquip points >= 40 } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/StaffOfTheRaven.kt b/Server/src/main/kotlin/rs09/game/interaction/item/StaffOfTheRaven.kt index f2364cb20..397da4e1a 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/StaffOfTheRaven.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/StaffOfTheRaven.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.item -import api.ContentAPI +import api.* import core.game.node.entity.player.Player import core.game.node.item.Item import core.game.world.update.flag.context.Graphics @@ -19,7 +19,7 @@ class StaffOfTheRaven : InteractionListener() { val hasRecolorA = player.getAttribute("sotr:recolor1", false) val hasRecolorB = player.getAttribute("sotr:recolor2", false) val isBase = node.id == 14654 - val isOperate = ContentAPI.getUsedOption(player) == "operate" + val isOperate = getUsedOption(player) == "operate" if(!hasUnlocked){ //Remove the item if the player has not purchased it. Just in case. diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/StarRingListener.kt b/Server/src/main/kotlin/rs09/game/interaction/item/StarRingListener.kt index 6f56800e6..fa0de99b8 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/StarRingListener.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/StarRingListener.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.item -import api.ContentAPI +import api.* import core.game.node.entity.player.Player import core.game.node.entity.player.link.TeleportManager import core.game.node.entity.skill.Skills @@ -24,22 +24,22 @@ class StarRingListener : InteractionListener(){ on(RING, ITEM, "rub", "operate"){player, node -> val star = WorldEvents.get("shooting-stars") as? ShootingStarEvent - if(star == null) ContentAPI.sendDialogue(player, "There is currently no active star.").also { return@on true } + if(star == null) sendDialogue(player, "There is currently no active star.").also { return@on true } if(getStoreFile().getBoolean(player.username.toLowerCase())){ - ContentAPI.sendDialogue(player, "The ring is still recharging.") + sendDialogue(player, "The ring is still recharging.") return@on true } val condition: (Player) -> Boolean = when(star?.star!!.location.toLowerCase()){ "canifis bank" -> { p -> p.questRepository.isComplete("Priest in Peril")} - "crafting guild" -> {p -> ContentAPI.hasLevelStat(p, Skills.CRAFTING, 40) } + "crafting guild" -> {p -> hasLevelStat(p, Skills.CRAFTING, 40) } "south crandor mining site" -> {p -> p.questRepository.isComplete("Dragon Slayer")} else -> {_ -> true} } if(!condition.invoke(player) || player.skullManager.isWilderness){ - ContentAPI.sendDialogue(player, "Magical forces prevent your teleportation.") + sendDialogue(player, "Magical forces prevent your teleportation.") return@on true } @@ -52,7 +52,7 @@ class StarRingListener : InteractionListener(){ else -> false } - ContentAPI.openDialogue(player, RingDialogue(shouldWarn, star.star)) + openDialogue(player, RingDialogue(shouldWarn, star.star)) return@on true } @@ -81,7 +81,7 @@ class StarRingListener : InteractionListener(){ } fun teleport(player: Player, star: ShootingStar){ - ContentAPI.teleport(player, star.crash_locations[star.location]!!.transform(0, -1, 0), TeleportManager.TeleportType.MINIGAME) + teleport(player, star.crash_locations[star.location]!!.transform(0, -1, 0), TeleportManager.TeleportType.MINIGAME) getStoreFile()[player.username.toLowerCase()] = true } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/ToyListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/item/ToyListeners.kt new file mode 100644 index 000000000..e1d364e99 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/ToyListeners.kt @@ -0,0 +1,101 @@ +package rs09.game.interaction.item + +import api.* +import core.game.world.update.flag.context.Animation +import core.game.world.update.flag.context.Graphics +import org.rs09.consts.Items +import rs09.game.interaction.InteractionListener + +class ToyListeners : InteractionListener() { + companion object { + val MARIONETTES = intArrayOf(Items.RED_MARIONETTE_6867, Items.GREEN_MARIONETTE_6866, Items.BLUE_MARIONETTE_6865) + private val MARIONETTE_JUMP = Animation(3003) + private val MARIONETTE_WALK = Animation(3004) + private val MARIONETTE_BOW = Animation(3005) + private val MARIONETTE_DANCE = Animation(3006) + private val MARIONETTE_GFX = arrayOf(intArrayOf(507, 508, 509, 510), intArrayOf(511, 512, 513, 514), intArrayOf(515, 516, 517, 518)) + private val SNOWGLOBE_SHAKE = Animation(7535) //Initial Shake + private val SNOWGLOBE_HOLDFACE = Animation(7536) //Immediately after shake, player holds the snow globe to face + private val SNOWGLOBE_INTERFACE = 659 //After HOLDFACE this interface is displayed, player either clicks 'continue' for inv of snowballs, or 'close' for no snowballs + private val SNOWGLOBE_DOWNFAST = Animation(7537) //Used when player hit 'close' on the interface + private val SNOWGLOBE_DOWNSLOW = Animation(7538) //Used when the player hit 'continue' on the interface + private val SNOWGLOBE_STOMP = Animation(7528) //When player hits continue this animation plays + private val SNOWGLOBE_SNOW = Graphics(1284) //When Animation STOMP is playing this gfx also plays + val YOYO_PLAY = Animation(1457) + val YOYO_LOOP = Animation(1458) + val YOYO_WALK = Animation(1459) + val YOYO_CRAZY = Animation(1460) + val ZOMBIE_HEAD_TALK_AT = Animation(2840) + val ZOMBIE_HEAD_DISPLAY = Animation(2844) + } + + override fun defineListeners() { + on(Items.CHOCATRICE_CAPE_12634, ITEM, "operate"){player, _ -> + lockInteractions(player, 2) + visualize(player, 8903, 1566) + return@on true + } + + on(MARIONETTES, ITEM, "jump", "walk", "bow", "dance") {player, marionette -> + val index = MARIONETTES.indexOf(marionette.id) + + lockInteractions(player, 2) + when(getUsedOption(player)) { + "jump" -> visualize(player, MARIONETTE_JUMP, MARIONETTE_GFX[index][0]) + "walk" -> visualize(player, MARIONETTE_WALK, MARIONETTE_GFX[index][1]) + "bow" -> visualize(player, MARIONETTE_BOW, MARIONETTE_GFX[index][2]) + "dance" -> visualize(player, MARIONETTE_DANCE, MARIONETTE_GFX[index][3]) + } + return@on true + } + + on(Items.REINDEER_HAT_10507, ITEM, "operate"){player, _ -> + lockInteractions(player, 2) + animate(player, 5059) + return@on true + } + + on(Items.SNOW_GLOBE_11949, ITEM, "shake") {player, _ -> + lockInteractions(player, 2) + animate(player, SNOWGLOBE_SHAKE) + runTask(player, 3) { + animate(player, SNOWGLOBE_HOLDFACE) + runTask(player){ + openInterface(player, SNOWGLOBE_INTERFACE) + } + } + return@on true + } + + on(Items.YO_YO_4079, ITEM, "play", "loop", "walk", "crazy"){player, _ -> + val option = getUsedOption(player) + + lockInteractions(player, 2) + when(option) { + "play" -> animate(player, YOYO_PLAY) + "loop" -> animate(player, YOYO_LOOP) + "walk" -> animate(player, YOYO_WALK) + "crazy" -> animate(player, YOYO_CRAZY) + } + return@on true + } + + on(Items.ZOMBIE_HEAD_6722, ITEM, "talk-at", "display", "question"){player, _ -> + val option = getUsedOption(player) + + lockInteractions(player, 2) + when(option) { + "talk-at" -> { + animate(player, ZOMBIE_HEAD_TALK_AT) + sendChat(player, "Alas!") + } + + "display" -> { + animate(player, ZOMBIE_HEAD_DISPLAY) + sendChat(player, "MWAHAHAHAHAHAHAH") + } + } + return@on true + } + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withitem/HaySackOnSpear.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/HaySackOnSpear.kt index 331f80cd3..ef31ceb08 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/withitem/HaySackOnSpear.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/HaySackOnSpear.kt @@ -1,7 +1,7 @@ package rs09.game.interaction.item.withitem import api.Container -import api.ContentAPI +import api.* import org.rs09.consts.Items import rs09.game.interaction.InteractionListener @@ -11,10 +11,10 @@ class HaySackOnSpear : InteractionListener() { override fun defineListeners() { onUseWith(ITEM, HAYSACK, SPEAR){ player, used, _ -> - if(ContentAPI.removeItem(player, used.asItem(), Container.INVENTORY)){ - ContentAPI.addItem(player, Items.HAY_SACK_6058, 1) - ContentAPI.sendMessage(player, "You stab the hay sack with a bronze spear") - ContentAPI.removeItem(player, SPEAR, Container.INVENTORY) + if(removeItem(player, used.asItem(), Container.INVENTORY)){ + addItem(player, Items.HAY_SACK_6058, 1) + sendMessage(player, "You stab the hay sack with a bronze spear") + removeItem(player, SPEAR, Container.INVENTORY) } return@onUseWith true } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withitem/TOTTHelmOnCape.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/TOTTHelmOnCape.kt index 1eff3699f..7693542a5 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/withitem/TOTTHelmOnCape.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/TOTTHelmOnCape.kt @@ -1,8 +1,7 @@ package rs09.game.interaction.item.withitem import api.Container -import api.ContentAPI -import api.DialUtils +import api.* import org.rs09.consts.Items import rs09.game.content.dialogue.DialogueFile import rs09.game.interaction.InteractionListener @@ -11,21 +10,21 @@ import rs09.tools.END_DIALOGUE class TOTTHelmOnCape : InteractionListener() { override fun defineListeners() { onUseWith(ITEM, Items.SLAYER_HELMET_13263, Items.SLAYER_CAPE_9786, Items.SLAYER_CAPET_9787){ player, used, with -> - val alreadyHasHelm = ContentAPI.getAttribute(player, "cape_perks:tott:helmet-stored", false) + val alreadyHasHelm = getAttribute(player, "cape_perks:tott:helmet-stored", false) if(alreadyHasHelm){ - ContentAPI.sendDialogue(player, "You've already stored the components of a helmet in this cape.") + sendDialogue(player, "You've already stored the components of a helmet in this cape.") } else { - ContentAPI.openDialogue(player, object : DialogueFile(){ + openDialogue(player, object : DialogueFile(){ override fun handle(componentID: Int, buttonID: Int) { when(stage){ 0 -> dialogue("This will destroy your helmet permanently.").also { stage++ } 1 -> interpreter!!.sendOptions("Continue?", "Yes", "No").also { stage++ } 2 -> when(buttonID){ 1 -> { - if(ContentAPI.removeItem(player, Items.SLAYER_HELMET_13263, Container.INVENTORY)) { - dialogue(*DialUtils.splitLines("You disassemble the helmet and place the components into their respective pockets on your cape.")) - ContentAPI.setAttribute(player, "/save:cape_perks:tott:helmet-stored", true) + if(removeItem(player, Items.SLAYER_HELMET_13263, Container.INVENTORY)) { + dialogue(*splitLines("You disassemble the helmet and place the components into their respective pockets on your cape.")) + setAttribute(player, "/save:cape_perks:tott:helmet-stored", true) stage = END_DIALOGUE } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withitem/WatermelonOnSack.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/WatermelonOnSack.kt index be5dca0d7..859a8509b 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/withitem/WatermelonOnSack.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/WatermelonOnSack.kt @@ -1,7 +1,7 @@ package rs09.game.interaction.item.withitem import api.Container -import api.ContentAPI +import api.* import core.game.node.entity.skill.Skills import org.rs09.consts.Items import rs09.game.interaction.InteractionListener @@ -12,14 +12,14 @@ class WatermelonOnSack : InteractionListener() { override fun defineListeners() { onUseWith(ITEM, SACK, WATERMELON){player, used, _ -> - if(ContentAPI.getStatLevel(player, Skills.FARMING) >= 23){ - ContentAPI.removeItem(player,SACK, Container.INVENTORY) - ContentAPI.removeItem(player,WATERMELON,Container.INVENTORY) - ContentAPI.addItem(player, Items.SCARECROW_6059) - ContentAPI.rewardXP(player, Skills.FARMING, 25.0) - ContentAPI.sendMessage(player, "You stab the watermelon on top of the spear, finishing your scarecrow") + if(getStatLevel(player, Skills.FARMING) >= 23){ + removeItem(player,SACK, Container.INVENTORY) + removeItem(player,WATERMELON,Container.INVENTORY) + addItem(player, Items.SCARECROW_6059) + rewardXP(player, Skills.FARMING, 25.0) + sendMessage(player, "You stab the watermelon on top of the spear, finishing your scarecrow") }else{ - ContentAPI.sendMessage(player, "Your Farming level is not high enough to do this") + sendMessage(player, "Your Farming level is not high enough to do this") } return@onUseWith true } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/CatOnArdougneCivilian.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/CatOnArdougneCivilian.kt index f6480f30b..181d91f14 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/CatOnArdougneCivilian.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/CatOnArdougneCivilian.kt @@ -1,7 +1,7 @@ package rs09.game.interaction.item.withnpc import api.Container -import api.ContentAPI +import api.* import org.rs09.consts.Items import org.rs09.consts.NPCs import rs09.game.interaction.InteractionListener @@ -45,10 +45,10 @@ class CatOnArdougneCivilian: InteractionListener() { override fun defineListeners() { onUseWith(NPC,cats,*civilians){player, used, _ -> - ContentAPI.sendItemDialogue(player,Items.DEATH_RUNE_560,"You hand over the cat.
You are given 100 Death Runes.") + sendItemDialogue(player,Items.DEATH_RUNE_560,"You hand over the cat.
You are given 100 Death Runes.") player.familiarManager.removeDetails(used.id) - ContentAPI.removeItem(player,used,Container.INVENTORY) - ContentAPI.addItem(player,Items.DEATH_RUNE_560,100) + removeItem(player,used,Container.INVENTORY) + addItem(player,Items.DEATH_RUNE_560,100) return@onUseWith true; } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/AxeOnTree.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/AxeOnTree.kt index 9cec2668d..e0ed9c070 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/AxeOnTree.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/AxeOnTree.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.item.withobject -import api.ContentAPI +import api.* import core.game.node.entity.skill.gather.SkillingTool import core.game.node.entity.skill.gather.woodcutting.WoodcuttingNode import core.game.node.entity.skill.gather.woodcutting.WoodcuttingSkillPulse @@ -14,7 +14,7 @@ class AxeOnTree : InteractionListener(){ override fun defineListeners() { onUseWith(SCENERY, axes, *trees){player, _, with -> - ContentAPI.submitIndividualPulse(player, WoodcuttingSkillPulse(player, with.asScenery())) + submitIndividualPulse(player, WoodcuttingSkillPulse(player, with.asScenery())) return@onUseWith true } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/FishEasterEgg.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/FishEasterEgg.kt index 7646b98a5..6d90ae74a 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/FishEasterEgg.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/FishEasterEgg.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.item.withobject -import api.ContentAPI +import api.* import core.game.node.entity.skill.gather.woodcutting.WoodcuttingNode import org.rs09.consts.Items import rs09.game.interaction.InteractionListener @@ -13,12 +13,12 @@ class FishEasterEgg : InteractionListener() { override fun defineListeners() { onUseWith(SCENERY, fish, *TREE_IDs){player, _, _ -> - ContentAPI.sendMessage(player, "This is not the mightiest tree in the forest.") + sendMessage(player, "This is not the mightiest tree in the forest.") return@onUseWith true } onUseWith(SCENERY, fish, *doors){player, _, _ -> - ContentAPI.sendMessage(player, "It can't be done!") + sendMessage(player, "It can't be done!") return@onUseWith true } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/HatStand.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/HatStand.kt index 72603cd32..1e0a7f12f 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/HatStand.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/HatStand.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.item.withobject -import api.ContentAPI +import api.* import api.EquipmentSlot import core.cache.def.impl.ItemDefinition import rs09.game.interaction.InteractionListener @@ -13,7 +13,7 @@ class HatStand : InteractionListener() { override fun defineListeners() { onUseWith(SCENERY, hats, hat_stand){player, used, with -> - ContentAPI.sendDialogue(player, "It'd probably fall off if I tried to do that.") + sendDialogue(player, "It'd probably fall off if I tried to do that.") return@onUseWith true } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/SackOnHay.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/SackOnHay.kt index 0de84caa7..b716ef9a8 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/withobject/SackOnHay.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withobject/SackOnHay.kt @@ -1,7 +1,7 @@ package rs09.game.interaction.item.withobject import api.Container -import api.ContentAPI +import api.* import org.rs09.consts.Items import rs09.game.interaction.InteractionListener @@ -11,9 +11,9 @@ class SackOnHay : InteractionListener() { override fun defineListeners() { onUseWith(SCENERY, SACK, *HAY){player, used, _ -> - if(ContentAPI.removeItem(player, used.asItem(), Container.INVENTORY)){ - ContentAPI.addItem(player, Items.HAY_SACK_6057, 1) - ContentAPI.sendMessage(player, "You fill the sack with hay.") + if(removeItem(player, used.asItem(), Container.INVENTORY)){ + addItem(player, Items.HAY_SACK_6057, 1) + sendMessage(player, "You fill the sack with hay.") } return@onUseWith true } diff --git a/Server/src/main/kotlin/rs09/game/interaction/npc/BogrogPouchSwapper.kt b/Server/src/main/kotlin/rs09/game/interaction/npc/BogrogPouchSwapper.kt index f2824b973..b707d0910 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/npc/BogrogPouchSwapper.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/npc/BogrogPouchSwapper.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.npc -import api.ContentAPI +import api.* import core.game.component.Component import core.game.node.entity.player.Player import core.game.node.entity.player.link.RunScript @@ -39,7 +39,7 @@ object BogrogPouchSwapper { OP_SWAP_5 -> swap(player, 5, player.inventory.get(slot).id) OP_SWAP_10 -> swap(player,10,player.inventory.get(slot).id) OP_SWAP_X -> true.also{ - ContentAPI.sendInputDialogue(player, true, "Enter the amount:"){value -> + sendInputDialogue(player, true, "Enter the amount:"){value -> swap(player, value as Int, player.inventory.get(slot).id) } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/object/DemonTauntHandler.kt b/Server/src/main/kotlin/rs09/game/interaction/object/DemonTauntHandler.kt index 0c763906c..8af5f7612 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/object/DemonTauntHandler.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/object/DemonTauntHandler.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.`object` -import api.ContentAPI +import api.* import core.game.node.entity.player.link.diary.DiaryType import core.game.node.entity.player.link.emote.Emotes import org.rs09.consts.NPCs @@ -15,11 +15,11 @@ class DemonTauntHandler : InteractionListener(){ override fun defineListeners() { on(BARS,SCENERY,"taunt-through"){ player, _ -> - ContentAPI.sendMessage(player, "You taunt the demon, making it growl.") - val demon = ContentAPI.findLocalNPC(player, NPCs.LESSER_DEMON_82) ?: return@on true - ContentAPI.sendChat(demon, "Graaagh!") - ContentAPI.face(demon, player, 3) - ContentAPI.emote(player, Emotes.RASPBERRY) + sendMessage(player, "You taunt the demon, making it growl.") + val demon = findLocalNPC(player, NPCs.LESSER_DEMON_82) ?: return@on true + sendChat(demon, "Graaagh!") + face(demon, player, 3) + emote(player, Emotes.RASPBERRY) player.achievementDiaryManager.finishTask(player, DiaryType.LUMBRIDGE, 1, 13) return@on true } diff --git a/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt b/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt index 0c3cf23a4..f7d897de4 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.`object` -import api.ContentAPI +import api.* import core.game.interaction.Option import core.game.node.Node import core.game.node.entity.Entity @@ -21,18 +21,18 @@ class VarrockGuardSignpost : InteractionListener() { } } - ContentAPI.registerMapZone(zone, ZoneBorders(3225,3445,3198,3471)) - ContentAPI.registerMapZone(zone, ZoneBorders(3222,3375,3199,3387)) - ContentAPI.registerMapZone(zone, ZoneBorders(3180,3420,3165,3435)) - ContentAPI.registerMapZone(zone, ZoneBorders(3280,3422,3266,3435)) + registerMapZone(zone, ZoneBorders(3225,3445,3198,3471)) + registerMapZone(zone, ZoneBorders(3222,3375,3199,3387)) + registerMapZone(zone, ZoneBorders(3180,3420,3165,3435)) + registerMapZone(zone, ZoneBorders(3280,3422,3266,3435)) on(31298, SCENERY, "read"){player, _ -> val pickpocketCount = GlobalStats.getDailyGuardPickpockets() SystemLogger.logInfo("Is equal? ${pickpocketCount == 0}") when(pickpocketCount){ - 0 -> ContentAPI.sendDialogue(player, "The Varrock Palace guards are pleased to announce that crime is at an all-time low, without a single guard in the palace or at the city gates being pickpocketed today.") - 1 -> ContentAPI.sendDialogue(player, "One of the Varrock Palace guards was pickpocketed today. He was close to tears at having lost his last few gold pieces." ) - else -> ContentAPI.sendDialogue(player, "Guards in the Varrock Palace are on full alert due to increasing levels of pickpocketing. So far today, $pickpocketCount guards have had their money pickpocketed in the palace or at the city gates.") + 0 -> sendDialogue(player, "The Varrock Palace guards are pleased to announce that crime is at an all-time low, without a single guard in the palace or at the city gates being pickpocketed today.") + 1 -> sendDialogue(player, "One of the Varrock Palace guards was pickpocketed today. He was close to tears at having lost his last few gold pieces." ) + else -> sendDialogue(player, "Guards in the Varrock Palace are on full alert due to increasing levels of pickpocketing. So far today, $pickpocketCount guards have had their money pickpocketed in the palace or at the city gates.") } return@on true } diff --git a/Server/src/main/kotlin/rs09/game/interaction/object/WizardGuildPortals.kt b/Server/src/main/kotlin/rs09/game/interaction/object/WizardGuildPortals.kt index 960b9c88c..8ccabc2ff 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/object/WizardGuildPortals.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/object/WizardGuildPortals.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.`object` -import api.ContentAPI +import api.* import core.game.world.map.Location import rs09.game.interaction.InteractionListener @@ -12,23 +12,23 @@ class WizardGuildPortals : InteractionListener() { override fun defineListeners() { on(WTOWER_PORTAL, SCENERY, "enter"){player, _ -> - ContentAPI.teleport(player, Location.create(3109, 3159, 0)) - ContentAPI.sendMessage(player, "You enter the magic portal...") - ContentAPI.sendMessage(player, "You teleport to the Wizards' tower.") + teleport(player, Location.create(3109, 3159, 0)) + sendMessage(player, "You enter the magic portal...") + sendMessage(player, "You teleport to the Wizards' tower.") return@on true } on(DWTOWER_PORTAL, SCENERY, "enter"){player, _ -> - ContentAPI.teleport(player, Location.create(2907, 3333, 0)) - ContentAPI.sendMessage(player, "You enter the magic portal...") - ContentAPI.sendMessage(player, "You teleport to the Dark Wizards' tower.") + teleport(player, Location.create(2907, 3333, 0)) + sendMessage(player, "You enter the magic portal...") + sendMessage(player, "You teleport to the Dark Wizards' tower.") return@on true } on(SORC_TOWER_PORTAL, SCENERY, "enter"){player, _ -> - ContentAPI.teleport(player, Location.create(2703, 3406, 0)) - ContentAPI.sendMessage(player, "You enter the magic portal...") - ContentAPI.sendMessage(player, "You teleport to Thormac the Sorceror's house.") + teleport(player, Location.create(2703, 3406, 0)) + sendMessage(player, "You enter the magic portal...") + sendMessage(player, "You teleport to Thormac the Sorceror's house.") return@on true } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeInterfaceListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeInterfaceListeners.kt index 7b63d7a9a..579d38d56 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeInterfaceListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/object/canoestation/CanoeInterfaceListeners.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.`object`.canoestation -import api.ContentAPI +import api.* import core.cache.def.impl.VarbitDefinition import core.game.component.Component import core.game.content.global.travel.canoe.Canoe @@ -47,7 +47,7 @@ class CanoeInterfaceListeners : InterfaceListener() { } player.lock() - ContentAPI.animate(player,CanoeUtils.getShapeAnimation(axe)) + animate(player,CanoeUtils.getShapeAnimation(axe)) player.pulseManager.run(object : Pulse(3) { override fun pulse(): Boolean { if (RandomFunction.random(if (canoe == Canoe.WAKA) 8 else 6) == 1) { @@ -59,7 +59,7 @@ class CanoeInterfaceListeners : InterfaceListener() { player.unlock() return true } - ContentAPI.animate(player,CanoeUtils.getShapeAnimation(axe)) + animate(player,CanoeUtils.getShapeAnimation(axe)) return false } }) @@ -112,7 +112,7 @@ class CanoeInterfaceListeners : InterfaceListener() { 0 -> { player.interfaceManager.openOverlay(Component(Components.FADE_TO_BLACK_120)) player.interfaceManager.open(Component(Components.CANOE_TRAVEL_758)) - ContentAPI.animateInterface(player, Components.CANOE_TRAVEL_758, 3, interfaceAnimationId) + animateInterface(player, Components.CANOE_TRAVEL_758, 3, interfaceAnimationId) } 2 -> { PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 2)) diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/LumbridgeListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/LumbridgeListeners.kt index b4511f0cb..fd27506fd 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/region/LumbridgeListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/LumbridgeListeners.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.region -import api.ContentAPI +import api.* import rs09.GlobalStats import rs09.game.interaction.InteractionListener @@ -12,9 +12,9 @@ class LumbridgeListeners : InteractionListener() { on(CHURCH_SIGN, SCENERY, "read"){player, _ -> val deaths = GlobalStats.getDailyDeaths() if(deaths > 0){ - ContentAPI.sendDialogue(player, "So far today $deaths unlucky adventurers have died on RuneScape and been sent to their respawn location. Be careful out there.") + sendDialogue(player, "So far today $deaths unlucky adventurers have died on RuneScape and been sent to their respawn location. Be careful out there.") } else { - ContentAPI.sendDialogue(player, "So far today not a single adventurer on RuneScape has met their end grisly or otherwise. Either the streets are getting safer or adventurers are getting warier.") + sendDialogue(player, "So far today not a single adventurer on RuneScape has met their end grisly or otherwise. Either the streets are getting safer or adventurers are getting warier.") } return@on true } diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/MorytaniaListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/MorytaniaListeners.kt index b5f8dd5a6..c7676dc36 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/region/MorytaniaListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/MorytaniaListeners.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.region -import api.ContentAPI +import api.* import core.game.content.global.action.DoorActionHandler import core.game.node.entity.skill.agility.AgilityHandler import core.game.system.task.Pulse @@ -40,13 +40,13 @@ class MorytaniaListeners : InteractionListener() { if(player.location.y == 3457){ DoorActionHandler.handleAutowalkDoor(player, node.asScenery()) GlobalScope.launch { - ContentAPI.findLocalNPC(player, NPCs.ULIZIUS_1054)?.sendChat("Oh my! You're still alive!", 2) + findLocalNPC(player, NPCs.ULIZIUS_1054)?.sendChat("Oh my! You're still alive!", 2) } } else { if (player.questRepository.hasStarted("Nature Spirit")) { DoorActionHandler.handleAutowalkDoor(player, node.asScenery()) } else { - ContentAPI.sendNPCDialogue( + sendNPCDialogue( player, NPCs.ULIZIUS_1054, "I'm sorry, but I'm afraid it's too dangerous to let you through this gate right now." @@ -67,7 +67,7 @@ class MorytaniaListeners : InteractionListener() { var failAnim = Animation(770) var fromGrotto = false - ContentAPI.lock(player,10) + lock(player,10) // Switch to south facing animations if jumping from Grotto if (start.y == 3331) { @@ -79,10 +79,10 @@ class MorytaniaListeners : InteractionListener() { val end = if (fromGrotto) failWater else start AgilityHandler.forceWalk(player, -1, start, end, failAnim, 15, 0.0, null,0).endAnimation = swimAnim AgilityHandler.forceWalk(player, -1, failWater, failLand, swimAnim, 15, 2.0, null,3) - ContentAPI.submitIndividualPulse(player, object : Pulse(2){ + submitIndividualPulse(player, object : Pulse(2){ override fun pulse(): Boolean { - ContentAPI.visualize(player,failAnim,splashGFX) - ContentAPI.teleport(player,failWater) + visualize(player,failAnim,splashGFX) + teleport(player,failWater) // Deal 1-6 damage but wait until the player is back on land AgilityHandler.fail(player,0,failLand,swimAnim,Random.nextInt(1,7),failMessage) return true diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenUtils.kt b/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenUtils.kt index 045d15924..5c5ae99eb 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenUtils.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenUtils.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.region.dungeons.brimhaven -import api.ContentAPI +import api.* import core.game.content.global.action.ClimbActionHandler import core.game.node.scenery.Scenery import core.game.node.scenery.SceneryBuilder @@ -49,8 +49,8 @@ object BrimhavenUtils { val dir = AgilityHandler.forceWalk(player, -1, player.location, node.location, Animation.create(769), 10, 0.0, null).direction val loc = player.location - ContentAPI.registerLogoutListener(player, "steppingstone"){p -> - ContentAPI.teleport(p, loc) + registerLogoutListener(player, "steppingstone"){p -> + teleport(p, loc) } World.Pulser.submit(object : Pulse(3, player) { @@ -73,7 +73,7 @@ object BrimhavenUtils { } override fun stop() { - ContentAPI.clearLogoutListener(player, "steppingstone") + clearLogoutListener(player, "steppingstone") super.stop() } }) diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/taverley/TaverleyDungeonListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/taverley/TaverleyDungeonListeners.kt index a1653061c..ed559503e 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/taverley/TaverleyDungeonListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/taverley/TaverleyDungeonListeners.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.region.dungeons.taverley -import api.ContentAPI +import api.* import core.game.content.global.action.DoorActionHandler import org.rs09.consts.Items import org.rs09.consts.Scenery @@ -14,8 +14,8 @@ class TaverleyDungeonListeners : InteractionListener() { override fun defineListeners() { on(BD_GATE, SCENERY, "open"){player, node -> - if(!ContentAPI.inInventory(player, Items.DUSTY_KEY_1590)){ - ContentAPI.sendMessage(player, "This gate seems to be locked.") + if(!inInventory(player, Items.DUSTY_KEY_1590)){ + sendMessage(player, "This gate seems to be locked.") } else { DoorActionHandler.handleAutowalkDoor(player, node.asScenery()) } @@ -27,8 +27,8 @@ class TaverleyDungeonListeners : InteractionListener() { when(player.location.y){ 9689 -> DoorActionHandler.handleAutowalkDoor(player, node.asScenery()) //inside the cell going out 9690 -> { //outside the cell going in - if(!ContentAPI.inInventory(player, Items.JAIL_KEY_1591)){ - ContentAPI.sendMessage(player, "This door is locked.") + if(!inInventory(player, Items.JAIL_KEY_1591)){ + sendMessage(player, "This door is locked.") } else { DoorActionHandler.handleAutowalkDoor(player, node.asScenery()) } diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/JatizsoListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/JatizsoListeners.kt index 38d366122..617828539 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/JatizsoListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/JatizsoListeners.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.region.rellekka -import api.ContentAPI +import api.* import core.game.content.dialogue.FacialExpression import core.game.content.global.action.SpecialLadders import core.game.node.entity.npc.NPC @@ -43,68 +43,68 @@ class JatizsoListeners : InteractionListener() { on(GATES_CLOSED, SCENERY, "open"){player, node -> if(NORTH_GATE_ZONE.insideBorder(player)){ if(node.id == GATES_CLOSED.first()){ - val other = ContentAPI.getScenery(node.location.transform(1, 0, 0)) ?: return@on true - ContentAPI.replaceScenery(node.asScenery(), node.id + 1, -1, Direction.EAST) - ContentAPI.replaceScenery(other.asScenery(), other.id - 1, -1, Direction.NORTH_EAST) + val other = getScenery(node.location.transform(1, 0, 0)) ?: return@on true + replaceScenery(node.asScenery(), node.id + 1, -1, Direction.EAST) + replaceScenery(other.asScenery(), other.id - 1, -1, Direction.NORTH_EAST) } else { - val other = ContentAPI.getScenery(node.location.transform(-1, 0, 0)) ?: return@on true - ContentAPI.replaceScenery(node.asScenery(), node.id + 1, -1, Direction.NORTH_EAST) - ContentAPI.replaceScenery(other.asScenery(), other.id, -1, Direction.EAST) + val other = getScenery(node.location.transform(-1, 0, 0)) ?: return@on true + replaceScenery(node.asScenery(), node.id + 1, -1, Direction.NORTH_EAST) + replaceScenery(other.asScenery(), other.id, -1, Direction.EAST) } } else if(WEST_GATE_ZONE.insideBorder(player)){ if(node.id == GATES_CLOSED.first()){ - val other = ContentAPI.getScenery(node.location.transform(0, 1, 0)) ?: return@on true - ContentAPI.replaceScenery(node.asScenery(), node.id + 1, -1, Direction.WEST) - ContentAPI.replaceScenery(other.asScenery(), other.id + 1, -1, Direction.NORTH) + val other = getScenery(node.location.transform(0, 1, 0)) ?: return@on true + replaceScenery(node.asScenery(), node.id + 1, -1, Direction.WEST) + replaceScenery(other.asScenery(), other.id + 1, -1, Direction.NORTH) } else { - val other = ContentAPI.getScenery(node.location.transform(0, -1, 0)) ?: return@on true - ContentAPI.replaceScenery(node.asScenery(), node.id + 1, -1, Direction.NORTH) - ContentAPI.replaceScenery(other.asScenery(), other.id + 1, -1, Direction.WEST) + val other = getScenery(node.location.transform(0, -1, 0)) ?: return@on true + replaceScenery(node.asScenery(), node.id + 1, -1, Direction.NORTH) + replaceScenery(other.asScenery(), other.id + 1, -1, Direction.WEST) } } else if(SOUTH_GAE_ZONE.insideBorder(player)){ if(node.id == GATES_CLOSED.first()){ - val other = ContentAPI.getScenery(node.location.transform(-1, 0, 0)) ?: return@on true - ContentAPI.replaceScenery(node.asScenery(), node.id + 1, -1, Direction.SOUTH) - ContentAPI.replaceScenery(other.asScenery(), other.id - 1, -1, Direction.EAST) + val other = getScenery(node.location.transform(-1, 0, 0)) ?: return@on true + replaceScenery(node.asScenery(), node.id + 1, -1, Direction.SOUTH) + replaceScenery(other.asScenery(), other.id - 1, -1, Direction.EAST) } else { - val other = ContentAPI.getScenery(node.location.transform(1, 0, 0)) ?: return@on true - ContentAPI.replaceScenery(node.asScenery(), node.id + 1, -1, Direction.EAST) - ContentAPI.replaceScenery(other.asScenery(), other.id, -1, Direction.SOUTH) + val other = getScenery(node.location.transform(1, 0, 0)) ?: return@on true + replaceScenery(node.asScenery(), node.id + 1, -1, Direction.EAST) + replaceScenery(other.asScenery(), other.id, -1, Direction.SOUTH) } } - ContentAPI.playAudio(player, ContentAPI.getAudio(81)) + playAudio(player, getAudio(81)) return@on true } on(TOWER_GUARDS, NPC, "watch-shouting"){player, _ -> - val local = ContentAPI.findLocalNPC(player, NPCs.GUARD_5489) - ContentAPI.lock(player, 200) - ContentAPI.face(local!!, Location.create(2371, 3801, 2)) + val local = findLocalNPC(player, NPCs.GUARD_5489) + lock(player, 200) + face(local!!, Location.create(2371, 3801, 2)) local.asNpc().isRespawn = false - ContentAPI.submitIndividualPulse(player, object : Pulse(4){ + submitIndividualPulse(player, object : Pulse(4){ var id = NPCs.GUARD_5489 var counter = 0 - val other = ContentAPI.findLocalNPC(player, getOther(NPCs.GUARD_5489)) + val other = findLocalNPC(player, getOther(NPCs.GUARD_5489)) override fun start() { other?.isRespawn = false } override fun pulse(): Boolean { - val npc = ContentAPI.findLocalNPC(player, id) ?: return false + val npc = findLocalNPC(player, id) ?: return false val index = when(id){ NPCs.GUARD_5489 -> 0 else -> 1 } if(index == 1 && counter == 5) return true - ContentAPI.sendChat(npc, LINES[index][counter]) + sendChat(npc, LINES[index][counter]) if(npc.id != NPCs.GUARD_5489) counter++ id = getOther(id) return false } override fun stop() { - ContentAPI.unlock(player) + unlock(player) other?.isRespawn = true local.asNpc().isRespawn = true super.stop() @@ -122,8 +122,8 @@ class JatizsoListeners : InteractionListener() { } on(BELL, SCENERY, "ring-bell"){player, _ -> - ContentAPI.playAudio(player, Audio(15)) - ContentAPI.sendMessage(player, "You ring the warning bell, but everyone ignores it!") + playAudio(player, Audio(15)) + sendMessage(player, "You ring the warning bell, but everyone ignores it!") return@on true } @@ -133,7 +133,7 @@ class JatizsoListeners : InteractionListener() { } on(KING_CHEST, SCENERY, "open"){player, node -> - ContentAPI.sendPlayerDialogue(player, "I probably shouldn't mess with that.", FacialExpression.HALF_THINKING) + sendPlayerDialogue(player, "I probably shouldn't mess with that.", FacialExpression.HALF_THINKING) return@on true } @@ -142,13 +142,13 @@ class JatizsoListeners : InteractionListener() { } //Climb handling for the ladders in the towers around the city walls. - ContentAPI.addClimbDest(Location.create(2388, 3804, 0),Location.create(2387, 3804, 2)) - ContentAPI.addClimbDest(Location.create(2388, 3804, 2),Location.create(2387, 3804, 0)) - ContentAPI.addClimbDest(Location.create(2388, 3793, 0),Location.create(2387, 3793, 2)) - ContentAPI.addClimbDest(Location.create(2388, 3793, 2),Location.create(2387, 3793, 0)) - ContentAPI.addClimbDest(Location.create(2410, 3823, 0),Location.create(2410, 3824, 2)) - ContentAPI.addClimbDest(Location.create(2410, 3823, 2),Location.create(2410, 3824, 0)) - ContentAPI.addClimbDest(Location.create(2421, 3823, 0),Location.create(2421, 3824, 2)) - ContentAPI.addClimbDest(Location.create(2421, 3823, 2),Location.create(2421, 3824, 0)) + addClimbDest(Location.create(2388, 3804, 0),Location.create(2387, 3804, 2)) + addClimbDest(Location.create(2388, 3804, 2),Location.create(2387, 3804, 0)) + addClimbDest(Location.create(2388, 3793, 0),Location.create(2387, 3793, 2)) + addClimbDest(Location.create(2388, 3793, 2),Location.create(2387, 3793, 0)) + addClimbDest(Location.create(2410, 3823, 0),Location.create(2410, 3824, 2)) + addClimbDest(Location.create(2410, 3823, 2),Location.create(2410, 3824, 0)) + addClimbDest(Location.create(2421, 3823, 0),Location.create(2421, 3824, 2)) + addClimbDest(Location.create(2421, 3823, 2),Location.create(2421, 3824, 0)) } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/NeitiznotListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/NeitiznotListeners.kt index 2526bdbde..316393fc1 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/NeitiznotListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/NeitiznotListeners.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.region.rellekka -import api.ContentAPI +import api.* import core.game.content.dialogue.FacialExpression import core.game.node.Node import core.game.node.entity.npc.NPC @@ -18,22 +18,22 @@ class NeitiznotListeners : InteractionListener() { override fun defineListeners() { on(STUMP, SCENERY, "cut-wood"){player, _ -> - ContentAPI.sendPlayerDialogue(player, "I should probably leave this alone.", FacialExpression.HALF_THINKING) + sendPlayerDialogue(player, "I should probably leave this alone.", FacialExpression.HALF_THINKING) return@on true } val zone = object : MapZone("Yakzone", true){ override fun handleUseWith(player: Player, used: Item?, with: Node?): Boolean { if(with is NPC && with.id == NPCs.YAK_5529){ - ContentAPI.sendMessage(player, "The cow doesn't want that.") + sendMessage(player, "The cow doesn't want that.") return true } return false } } - ContentAPI.registerMapZone(zone, ZoneBorders(2313,3786,2331,3802)) - ContentAPI.addClimbDest(Location.create(2363, 3799, 0), Location.create(2364, 3799, 2)) - ContentAPI.addClimbDest(Location.create(2363, 3799, 2), Location.create(2362, 3799, 0)) + registerMapZone(zone, ZoneBorders(2313,3786,2331,3802)) + addClimbDest(Location.create(2363, 3799, 0), Location.create(2364, 3799, 2)) + addClimbDest(Location.create(2363, 3799, 2), Location.create(2362, 3799, 0)) } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/wilderness/RoguesCastleListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/wilderness/RoguesCastleListeners.kt index 53af624dd..c3440ab59 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/region/wilderness/RoguesCastleListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/wilderness/RoguesCastleListeners.kt @@ -1,6 +1,6 @@ package rs09.game.interaction.region.wilderness -import api.ContentAPI +import api.* import core.game.node.scenery.Scenery import core.game.node.entity.combat.ImpactHandler import core.game.node.entity.player.Player @@ -15,7 +15,7 @@ import rs09.game.interaction.InteractionListener class RoguesCastleListeners : InteractionListener() { - val CHEST_ANIM = ContentAPI.getAnimation(536) + val CHEST_ANIM = getAnimation(536) val FLOOR_1_CHESTS = intArrayOf(14773, 14774) val FLOOR_2_CHESTS = intArrayOf(38834, 38835) @@ -28,55 +28,55 @@ class RoguesCastleListeners : InteractionListener() { on(FLOOR_1_CHESTS, SCENERY, "search"){player, node -> val scenery = node.asScenery() - if(ContentAPI.getCharge(scenery) == 0){ - ContentAPI.sendMessage(player, "This chest has already been looted.") + if(getCharge(scenery) == 0){ + sendMessage(player, "This chest has already been looted.") return@on true } - if(ContentAPI.freeSlots(player) == 0){ - ContentAPI.sendMessage(player, "You don't have enough space to do that.") + if(freeSlots(player) == 0){ + sendMessage(player, "You don't have enough space to do that.") return@on true } val item = FLOOR_1_LOOT.roll()[0] addLoot(player, item) - ContentAPI.setCharge(scenery, 0) + setCharge(scenery, 0) return@on true } on(FLOOR_2_CHESTS, SCENERY, "open"){player, node -> - ContentAPI.sendMessage(player, "This chest appears to be locked.") + sendMessage(player, "This chest appears to be locked.") return@on true } on(FLOOR_2_CHESTS, SCENERY, "pick-lock"){player, node -> val scenery = node.asScenery() - if(!ContentAPI.inInventory(player, Items.LOCKPICK_1523)){ - ContentAPI.sendMessage(player, "You need a lockpick in order to attempt this.") + if(!inInventory(player, Items.LOCKPICK_1523)){ + sendMessage(player, "You need a lockpick in order to attempt this.") return@on true } - if(!ContentAPI.hasLevelDyn(player, Skills.THIEVING, 13)){ - ContentAPI.sendMessage(player, "You need a Thieving level of 13 to attempt this.") + if(!hasLevelDyn(player, Skills.THIEVING, 13)){ + sendMessage(player, "You need a Thieving level of 13 to attempt this.") return@on true } - ContentAPI.sendMessage(player, "You attempt to pick the lock on the chest...") - ContentAPI.submitIndividualPulse(player, object : Pulse(2){ + sendMessage(player, "You attempt to pick the lock on the chest...") + submitIndividualPulse(player, object : Pulse(2){ override fun pulse(): Boolean { val success = RandomFunction.roll(10) // 1/10 chance to succeed if(success){ - ContentAPI.replaceScenery(scenery, scenery.id + 1, 20) - ContentAPI.rewardXP(player, Skills.THIEVING, 300.0) + replaceScenery(scenery, scenery.id + 1, 20) + rewardXP(player, Skills.THIEVING, 300.0) } else { val dealsDamage = RandomFunction.roll(10) // 1/10 chance to deal damage on a fail if(dealsDamage) { - ContentAPI.impact(player, RandomFunction.random(1, 3), ImpactHandler.HitsplatType.NORMAL) - ContentAPI.sendMessage(player, "You activated a trap on the chest!") + impact(player, RandomFunction.random(1, 3), ImpactHandler.HitsplatType.NORMAL) + sendMessage(player, "You activated a trap on the chest!") } } - ContentAPI.sendMessage(player, "You ${if(success) "manage" else "fail"} to pick the lock on the chest.") + sendMessage(player, "You ${if(success) "manage" else "fail"} to pick the lock on the chest.") return true } }) @@ -87,17 +87,17 @@ class RoguesCastleListeners : InteractionListener() { on(FLOOR_2_CHESTS, SCENERY, "search"){player, node -> val scenery = node.asScenery() - if(ContentAPI.getCharge(scenery) == 0){ - ContentAPI.sendMessage(player, "This chest has already been looted.") + if(getCharge(scenery) == 0){ + sendMessage(player, "This chest has already been looted.") return@on true } val loot = FLOOR_2_LOOT.roll()[0] - if(ContentAPI.freeSlots(player) > 0){ - ContentAPI.addItemOrDrop(player, loot.id, loot.amount) - ContentAPI.sendMessage(player, "In the chest you find some ${loot.name.toLowerCase() + if(!loot.name.endsWith("s")) "s" else ""}!") - ContentAPI.setCharge(scenery, 0) - ContentAPI.rewardXP(player, Skills.THIEVING, 60.0) + if(freeSlots(player) > 0){ + addItemOrDrop(player, loot.id, loot.amount) + sendMessage(player, "In the chest you find some ${loot.name.toLowerCase() + if(!loot.name.endsWith("s")) "s" else ""}!") + setCharge(scenery, 0) + rewardXP(player, Skills.THIEVING, 60.0) } return@on true @@ -105,20 +105,20 @@ class RoguesCastleListeners : InteractionListener() { } fun openChest(player: Player, scenery: Scenery){ - ContentAPI.animate(player, CHEST_ANIM) - ContentAPI.submitIndividualPulse(player, object : Pulse(ContentAPI.animationDuration(CHEST_ANIM)){ + animate(player, CHEST_ANIM) + submitIndividualPulse(player, object : Pulse(animationDuration(CHEST_ANIM)){ override fun pulse(): Boolean { - return true.also { ContentAPI.replaceScenery(scenery, scenery.id + 1, 20) } + return true.also { replaceScenery(scenery, scenery.id + 1, 20) } } }) } fun addLoot(player: Player, item: Item){ - ContentAPI.sendMessage(player, "You search the chest...") - ContentAPI.submitIndividualPulse(player, object : Pulse(){ + sendMessage(player, "You search the chest...") + submitIndividualPulse(player, object : Pulse(){ override fun pulse(): Boolean { - ContentAPI.sendMessage(player, "... and find some ${item.name.toLowerCase() + if(!item.name.endsWith("s")) "s" else ""}!") - ContentAPI.addItemOrDrop(player, item.id, item.amount) + sendMessage(player, "... and find some ${item.name.toLowerCase() + if(!item.name.endsWith("s")) "s" else ""}!") + addItemOrDrop(player, item.id, item.amount) return true } }) diff --git a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt index 1284bb11f..6e6ad9e3c 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.combat.handlers -import api.ContentAPI +import api.* import api.EquipmentSlot import core.game.container.impl.EquipmentContainer import core.game.content.quest.tutorials.tutorialisland.TutorialSession @@ -153,7 +153,7 @@ open class MeleeSwingHandler effectiveAttackLevel = floor(effectiveAttackLevel) effectiveAttackLevel *= (entity.properties.bonuses[entity.properties.attackStyle.bonusType] + 64) - val amuletName = (if(entity is Player) ContentAPI.getItemFromEquipment(entity, EquipmentSlot.AMULET)?.name ?: "null" else "null").toLowerCase() + val amuletName = (if(entity is Player) getItemFromEquipment(entity, EquipmentSlot.AMULET)?.name ?: "null" else "null").toLowerCase() val victimName = entity.properties.combatPulse.getVictim()?.name ?: "none" if(entity is Player && entity.slayer.task?.ids?.contains((entity.properties.combatPulse?.getVictim()?.id ?: 0)) == true) @@ -184,7 +184,7 @@ open class MeleeSwingHandler } //Strength skillcape perk - if(entity is Player && SkillcapePerks.isActive(SkillcapePerks.FINE_ATTUNEMENT, entity) && ContentAPI.getItemFromEquipment(entity, EquipmentSlot.WEAPON)?.definition?.getRequirement(Skills.STRENGTH) != 0) + if(entity is Player && SkillcapePerks.isActive(SkillcapePerks.FINE_ATTUNEMENT, entity) && getItemFromEquipment(entity, EquipmentSlot.WEAPON)?.definition?.getRequirement(Skills.STRENGTH) != 0) bonus = ceil(bonus * 1.20).toInt() cumulativeStr *= getSetMultiplier(entity, Skills.STRENGTH) diff --git a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/BlastFurnaceOre.kt b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/BlastFurnaceOre.kt index 31de1e91b..b34df17cb 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/BlastFurnaceOre.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/BlastFurnaceOre.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.npc.other -import api.ContentAPI +import api.* import core.game.node.entity.npc.AbstractNPC import core.game.node.entity.player.Player import core.game.world.map.Location @@ -50,7 +50,7 @@ class BlastFurnaceOre : AbstractNPC { override fun handleTickActions() { delay-- - if(delay <= 0 && ContentAPI.getWorldTicks() % 2 == 0) { //run every other tick + if(delay <= 0 && getWorldTicks() % 2 == 0) { //run every other tick if(counter > 0){ properties.teleportLocation = location.transform(0, -1, 0) counter-- diff --git a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/FremennikGuards.kt b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/FremennikGuards.kt index f57617276..5b69ee13a 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/FremennikGuards.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/FremennikGuards.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.npc.other -import api.ContentAPI +import api.* import core.game.node.entity.npc.AbstractNPC import core.game.world.map.Location import core.plugin.Initializable @@ -23,8 +23,8 @@ class FremennikGuards : AbstractNPC { override fun tick() { if(this.isRespawn) { when (id) { - NPCs.GUARD_5489 -> if (ContentAPI.getWorldTicks() % 5 == 0) ContentAPI.sendChat(this, "JATIZSO!") - NPCs.GUARD_5490 -> if (ContentAPI.getWorldTicks() % 8 == 0) ContentAPI.sendChat(this, "NEITIZNOT!") + NPCs.GUARD_5489 -> if (getWorldTicks() % 5 == 0) sendChat(this, "JATIZSO!") + NPCs.GUARD_5490 -> if (getWorldTicks() % 8 == 0) sendChat(this, "NEITIZNOT!") } } super.tick() diff --git a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/HonourGuardGFI.kt b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/HonourGuardGFI.kt index deba6ad9e..aea65a8c0 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/HonourGuardGFI.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/HonourGuardGFI.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.npc.other -import api.ContentAPI +import api.* import core.game.node.entity.npc.AbstractNPC import core.game.world.map.Location import core.plugin.Initializable @@ -23,7 +23,7 @@ class HonourGuardGFI : AbstractNPC { override fun tick() { if(isActive && !inCombat() && RandomFunction.roll(10)){ - val localTrolls = ContentAPI.findLocalNPCs(this, intArrayOf(NPCs.ICE_TROLL_FEMALE_5523, NPCs.ICE_TROLL_MALE_5522, NPCs.ICE_TROLL_RUNT_5521, NPCs.ICE_TROLL_GRUNT_5524)) + val localTrolls = findLocalNPCs(this, intArrayOf(NPCs.ICE_TROLL_FEMALE_5523, NPCs.ICE_TROLL_MALE_5522, NPCs.ICE_TROLL_RUNT_5521, NPCs.ICE_TROLL_GRUNT_5524)) localTrolls.forEach{troll -> if(troll.location.withinDistance(location,6)) { attack(troll) diff --git a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/IceTrollJatizsoCaves.kt b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/IceTrollJatizsoCaves.kt index 3cbd154a5..54b0e36d1 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/IceTrollJatizsoCaves.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/IceTrollJatizsoCaves.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.npc.other -import api.ContentAPI +import api.* import core.game.node.entity.npc.AbstractNPC import core.game.world.map.Location import core.plugin.Initializable @@ -23,7 +23,7 @@ class IceTrollJatizsoCaves : AbstractNPC { } override fun tick() { - val nearbyMiner = ContentAPI.findLocalNPC(this, NPCs.MINER_5497) ?: return super.tick() + val nearbyMiner = findLocalNPC(this, NPCs.MINER_5497) ?: return super.tick() if(!inCombat() && nearbyMiner.location.withinDistance(location, 8)){ attack(nearbyMiner) } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/MortMyreGhastNPC.kt b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/MortMyreGhastNPC.kt index 5aa192d43..3e4ad4a09 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/MortMyreGhastNPC.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/MortMyreGhastNPC.kt @@ -1,7 +1,7 @@ package rs09.game.node.entity.npc.other import api.Container -import api.ContentAPI +import api.* import core.game.content.consumable.Consumables import core.game.content.consumable.Food import core.game.interaction.MovementPulse @@ -39,7 +39,7 @@ class MortMyreGhastNPC : AbstractNPC { val players = RegionManager.getLocalPlayers(this, 5).filter { !it.inCombat() } if(players.isNotEmpty()){ val player = players.random() - ContentAPI.submitIndividualPulse(this, object : MovementPulse(this, player){ + submitIndividualPulse(this, object : MovementPulse(this, player){ override fun pulse(): Boolean { animate(Animation(1093)) attemptLifeSiphon(player) @@ -48,7 +48,7 @@ class MortMyreGhastNPC : AbstractNPC { }) } } else { - val ticksTransformed = ContentAPI.getWorldTicks() - ContentAPI.getAttribute(this, "woke", 0) + val ticksTransformed = getWorldTicks() - getAttribute(this, "woke", 0) if(!inCombat() && ticksTransformed > 10){ reTransform() } @@ -70,18 +70,18 @@ class MortMyreGhastNPC : AbstractNPC { val consumable = Consumables.getConsumableById(i.id) if(consumable != null && consumable is Food) { hasFood = true - ContentAPI.removeItem(player, i, Container.INVENTORY) - ContentAPI.addItem(player, Items.ROTTEN_FOOD_2959) - ContentAPI.sendMessage(player, "You feel something attacking your backpack, and smell a terrible stench.") + removeItem(player, i, Container.INVENTORY) + addItem(player, Items.ROTTEN_FOOD_2959) + sendMessage(player, "You feel something attacking your backpack, and smell a terrible stench.") break } } if(!hasFood && RandomFunction.roll(3)) { - ContentAPI.sendMessage(player, "An attacking Ghast just misses you.") + sendMessage(player, "An attacking Ghast just misses you.") } else if(!hasFood){ - ContentAPI.impact(player, RandomFunction.random(3,6), ImpactHandler.HitsplatType.NORMAL) - ContentAPI.sendMessage(player, "A supernatural force draws energy from you.") + impact(player, RandomFunction.random(3,6), ImpactHandler.HitsplatType.NORMAL) + sendMessage(player, "A supernatural force draws energy from you.") } } } @@ -96,7 +96,7 @@ class MortMyreGhastNPC : AbstractNPC { reTransform() if(killer is Player){ NSUtils.incrementGhastKC(killer) - ContentAPI.rewardXP(killer, Skills.PRAYER, 30.0) + rewardXP(killer, Skills.PRAYER, 30.0) removeAttribute("woke") } } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/BarbarianOutpostCourse.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/BarbarianOutpostCourse.kt index 4b5d29642..f0db26a4a 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/BarbarianOutpostCourse.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/BarbarianOutpostCourse.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.agility -import api.ContentAPI +import api.* import core.cache.def.impl.ItemDefinition import core.cache.def.impl.NPCDefinition import core.cache.def.impl.SceneryDefinition @@ -62,20 +62,20 @@ class BarbarianOutpostCourse player.packetDispatch.sendMessage("You cannot climb from this side.") } val flag = if (node.location == Location(2536, 3553, 0)) 4 else if (node.location == Location(2539, 3553, 0)) 5 else 6 - ContentAPI.sendMessage(player, "You climb the low wall...") + sendMessage(player, "You climb the low wall...") AgilityHandler.forceWalk(player, flag, node.location.transform(-1, 0, 0), node.location.transform(1, 0, 0), Animation.create(839), 10, 13.5, null) } 455 -> player.barcrawlManager.read() 385 -> { - ContentAPI.sendMessage(player, "The scorpion stings you!") + sendMessage(player, "The scorpion stings you!") player.impactHandler.manualHit(player, 3, HitsplatType.NORMAL) } 386 -> { - ContentAPI.sendMessage(player, "The scorpion stings you!") + sendMessage(player, "The scorpion stings you!") player.impactHandler.manualHit(player, 3, HitsplatType.NORMAL) } 387 -> { - ContentAPI.sendMessage(player, "The scorpion stings you!") + sendMessage(player, "The scorpion stings you!") player.impactHandler.manualHit(player, 3, HitsplatType.NORMAL) } } @@ -89,11 +89,11 @@ class BarbarianOutpostCourse */ private fun handleRopeSwing(player: Player, `object`: Scenery) { if (player.location.y < 3554) { - ContentAPI.sendMessage(player, "You cannot do that from here.") + sendMessage(player, "You cannot do that from here.") return } if (ropeDelay > World.ticks) { - ContentAPI.sendMessage(player, "The rope is being used.") + sendMessage(player, "The rope is being used.") return } if (AgilityHandler.hasFailed(player, 1, 0.1)) { @@ -113,7 +113,7 @@ class BarbarianOutpostCourse private fun handleLogBalance(player: Player, `object`: Scenery) { val failed = AgilityHandler.hasFailed(player, 1, 0.5) val end = if (failed) Location.create(2545, 3546, 0) else Location.create(2541, 3546, 0) - ContentAPI.sendMessage(player, "You walk carefully across the slippery log...") + sendMessage(player, "You walk carefully across the slippery log...") AgilityHandler.walk(player, if (failed) -1 else 1, Location.create(2551, 3546, 0), end, Animation.create(155), if (failed) 0.0 else 13.5, if (failed) null else "...You make it safely to the other side.") if (failed) { AgilityHandler.walk(player, -1, player.location, Location.create(2545, 3546, 0), Animation.create(155), 0.0, null) @@ -161,7 +161,7 @@ class BarbarianOutpostCourse val failed = AgilityHandler.hasFailed(player, 1, 0.3) val end = if (failed) Location.create(2534, 3547, 1) else Location.create(2532, 3547, 1) AgilityHandler.walk(player, if (failed) -1 else 3, Location.create(2536, 3547, 1), end, Animation.create(157), if (failed) 0.0 else 22.0, if (failed) null else "You skillfully edge across the gap.") - ContentAPI.sendMessage(player, "You put your foot on the ledge and try to edge across..") + sendMessage(player, "You put your foot on the ledge and try to edge across..") if (failed) { AgilityHandler.fail(player, 3, Location.create(2534, 3545, 0), Animation(760), getHitAmount(player), "You slip and fall to the pit below.") return diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/GnomeStrongholdCourse.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/GnomeStrongholdCourse.kt index 5ab3765b3..021940b72 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/GnomeStrongholdCourse.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/GnomeStrongholdCourse.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.agility -import api.ContentAPI +import api.* import core.cache.def.impl.SceneryDefinition import core.game.node.Node import core.game.node.scenery.Scenery @@ -35,41 +35,41 @@ class GnomeStrongholdCourse when (`object`.id) { 2295 -> { TRAINERS[0]!!.sendChat("Okay get over that log, quick quick!") - ContentAPI.sendMessage(player, "You walk carefully across the slippery log...") + sendMessage(player, "You walk carefully across the slippery log...") AgilityHandler.walk(player, 0, Location.create(2474, 3436, 0), Location.create(2474, 3429, 0), Animation.create(155), 7.5, "...You make it safely to the other side.") return true } 2285 -> { TRAINERS[1]!!.sendChat("Move it, move it, move it!") - ContentAPI.sendMessage(player, "You climb the netting...") + sendMessage(player, "You climb the netting...") AgilityHandler.climb(player, 1, Animation.create(828), `object`.location.transform(0, -1, 1), 7.5, null) return true } 35970 -> { TRAINERS[2]!!.sendChat("That's it - straight up.") - ContentAPI.sendMessage(player, "You climb the tree..") + sendMessage(player, "You climb the tree..") AgilityHandler.climb(player, 2, Animation.create(828), Location.create(2473, 3420, 2), 5.0, "...To the platform above.") return true } 2312 -> { TRAINERS[3]!!.sendChat("Come on scaredy cat, get across that rope!") - ContentAPI.sendMessage(player, "You carefully cross the tightrope.") + sendMessage(player, "You carefully cross the tightrope.") AgilityHandler.walk(player, 3, Location.create(2477, 3420, 2), Location.create(2483, 3420, 2), Animation.create(155), 7.5, null) return true } 4059 -> { - ContentAPI.sendMessage(player, "You can't do that from here.") + sendMessage(player, "You can't do that from here.") return true } 2314, 2315 -> { - ContentAPI.sendMessage(player, "You climb down the tree..") + sendMessage(player, "You climb down the tree..") AgilityHandler.climb(player, 4, Animation.create(828), Location.create(2487, 3420, 0), 5.0, "You land on the ground.") return true } 2286 -> { TRAINERS[4]!!.sendChat("My Granny can move faster than you.") player.faceLocation(player.location.transform(0, 2, 0)) - ContentAPI.sendMessage(player, "You climb the netting...") + sendMessage(player, "You climb the netting...") AgilityHandler.climb(player, 5, Animation.create(828), player.location.transform(0, 2, 0), 7.5, null) return true } @@ -77,11 +77,11 @@ class GnomeStrongholdCourse val index = if (`object`.id == 154) 0 else 1 //If the player clicks on the left pipe, set index to 0, otherwise 1 val x = 2484 + index * 3 //change the x coordinates for walking/animations depending on index multiplier if (`object`.location.y == 3435) { - ContentAPI.sendMessage(player, "You can't do that from here.") + sendMessage(player, "You can't do that from here.") return true } if (USED_PIPES[index] > World.ticks) { - ContentAPI.sendMessage(player, "The pipe is being used.") + sendMessage(player, "The pipe is being used.") return true } USED_PIPES[index] = World.ticks + 10 diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/WildernessCourse.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/WildernessCourse.kt index 0b4562ef4..0cd8c517d 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/WildernessCourse.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/agility/WildernessCourse.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.agility -import api.ContentAPI +import api.* import core.cache.def.impl.SceneryDefinition import core.game.content.global.action.DoorActionHandler import core.game.node.Node @@ -76,7 +76,7 @@ class WildernessCourse 2 -> { val end = if (fail) Location.create(2998, 3924, 0) else if (`object`.id < 2309) Location.create(2998, 3917, 0) else Location.create(2998, 3930, 0) val start = if (`object`.id < 2309) player.location else Location.create(2998, 3917, 0) - ContentAPI.sendMessage(player, "You go through the gate and try to edge over the ridge...") + sendMessage(player, "You go through the gate and try to edge over the ridge...") AgilityHandler.walk(player, -1, start, end, Animation.create(155), if (fail) 0.0 else 15.00, if (fail) "You lose your footing and fail into the wolf pit." else "You skillfully balance across the ridge...") } 9 -> { @@ -104,7 +104,7 @@ class WildernessCourse */ private fun handlePipe(player: Player, `object`: Scenery) { if (`object`.location.y == 3948) { - ContentAPI.sendMessage(player, "You can't do that from here.") + sendMessage(player, "You can't do that from here.") return } if (player.skills.getLevel(Skills.AGILITY) < 49) { @@ -153,11 +153,11 @@ class WildernessCourse */ private fun handleRopeSwing(player: Player, `object`: Scenery) { if (player.location.y < 3554) { - ContentAPI.sendMessage(player, "You cannot do that from here.") + sendMessage(player, "You cannot do that from here.") return } if (ropeDelay > World.ticks) { - ContentAPI.sendMessage(player, "The rope is being used.") + sendMessage(player, "The rope is being used.") return } if (AgilityHandler.hasFailed(player, 1, 0.1)) { @@ -175,13 +175,13 @@ class WildernessCourse * @param object the object. */ private fun handleSteppingStones(player: Player, `object`: Scenery) { - ContentAPI.lock(player, 50) + lock(player, 50) val fail = AgilityHandler.hasFailed(player, 1, 0.3) val origLoc = player.location - ContentAPI.registerLogoutListener(player, "steppingstone"){p -> - ContentAPI.teleport(p, origLoc) + registerLogoutListener(player, "steppingstone"){p -> + teleport(p, origLoc) } - ContentAPI.submitWorldPulse(object : Pulse(2, player){ + submitWorldPulse(object : Pulse(2, player){ var counter = 0 override fun pulse(): Boolean { if (counter == 3 && fail) { @@ -190,8 +190,8 @@ class WildernessCourse } AgilityHandler.forceWalk(player, if (counter == 5) 2 else -1, player.location, player.location.transform(-1, 0, 0), Animation.create(741), 10, if (counter == 5) 20.0 else 0.0, if (counter != 0) null else "You carefully start crossing the stepping stones...") if(++counter == 6){ - ContentAPI.unlock(player) - ContentAPI.clearLogoutListener(player, "steppingstone") + unlock(player) + clearLogoutListener(player, "steppingstone") } return counter == 6 } @@ -206,7 +206,7 @@ class WildernessCourse private fun handleLogBalance(player: Player, `object`: Scenery) { val failed = AgilityHandler.hasFailed(player, 1, 0.5) val end = if (failed) Location.create(2998, 3945, 0) else Location.create(2994, 3945, 0) - ContentAPI.sendMessage(player, "You walk carefully across the slippery log...") + sendMessage(player, "You walk carefully across the slippery log...") AgilityHandler.walk(player, if (failed) -1 else 3, player.location, end, Animation.create(155), if (failed) 0.0 else 20.0, if (failed) null else "You skillfully edge across the gap.") if (failed) { World.Pulser.submit(object : Pulse(5, player) { diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/cooking/CookingDialogue.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/cooking/CookingDialogue.kt index 284cbee7d..52720e2a8 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/cooking/CookingDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/cooking/CookingDialogue.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.cooking -import api.ContentAPI +import api.* import core.cache.def.impl.ItemDefinition import core.game.node.scenery.Scenery import core.game.node.entity.player.link.RunScript @@ -54,7 +54,7 @@ class CookingDialogue(vararg val args: Any) : DialogueFile(){ val amount = getAmount(buttonID) when (amount) { -1 -> { - ContentAPI.sendInputDialogue(player!!, true, "Enter the amount:"){value -> + sendInputDialogue(player!!, true, "Enter the amount:"){value -> cook(player!!, `object`, initial, product, value as Int) } } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/crafting/leather/SpikyVambraces.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/crafting/leather/SpikyVambraces.kt index e5c014494..5fbb82940 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/crafting/leather/SpikyVambraces.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/crafting/leather/SpikyVambraces.kt @@ -1,7 +1,7 @@ package rs09.game.node.entity.skill.crafting.leather import api.Container -import api.ContentAPI +import api.* import core.game.interaction.NodeUsageEvent import core.game.interaction.UseWithHandler import core.game.node.entity.player.Player @@ -53,16 +53,16 @@ class SpikyVambraces: UseWithHandler(Items.KEBBIT_CLAWS_10113) { private fun craftVamb(player: Player, vamb: Int, product: Int, vambLeather: String){ if (player.skills.getLevel(Skills.CRAFTING) >= 32){ - if (ContentAPI.removeItem(player,vamb,Container.INVENTORY) && - ContentAPI.removeItem(player,Items.KEBBIT_CLAWS_10113,Container.INVENTORY) + if (removeItem(player,vamb,Container.INVENTORY) && + removeItem(player,Items.KEBBIT_CLAWS_10113,Container.INVENTORY) ) { - ContentAPI.addItem(player,product) + addItem(player,product) player.skills.addExperience(Skills.CRAFTING,6.0) - ContentAPI.sendMessage(player, "You carefully attach the sharp claws to the $vambLeather vambraces.") + sendMessage(player, "You carefully attach the sharp claws to the $vambLeather vambraces.") } } else{ - ContentAPI.sendMessage(player,"You need a crafting level of 32 to craft this.") + sendMessage(player,"You need a crafting level of 32 to craft this.") } } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt index eaf15ab7b..22de2f6b1 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.farming -import api.ContentAPI +import api.* import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills import core.game.node.item.Item @@ -46,8 +46,8 @@ class CompostBin(val player: Player, val bin: CompostBins) { isClosed = false } updateBit() - if(isSuperCompost) ContentAPI.rewardXP(player, Skills.FARMING, 8.5) - else ContentAPI.rewardXP(player, Skills.FARMING, 4.5) + if(isSuperCompost) rewardXP(player, Skills.FARMING, 8.5) + else rewardXP(player, Skills.FARMING, 4.5) return Item(item) } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CropHarvester.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CropHarvester.kt index 58652ab18..4936498d2 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CropHarvester.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CropHarvester.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.farming -import api.ContentAPI +import api.* import core.cache.def.impl.SceneryDefinition import core.game.interaction.OptionHandler import core.game.node.Node @@ -76,7 +76,7 @@ class CropHarvester : OptionHandler() { player.skills.addExperience(Skills.FARMING,plantable.harvestXP) if(patch.patch.type in livesBased){ patch.rollLivesDecrement( - ContentAPI.getDynLevel(player, Skills.FARMING), + getDynLevel(player, Skills.FARMING), requiredItem == Items.MAGIC_SECATEURS_7409 ) } else { diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FruitAndBerryPicker.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FruitAndBerryPicker.kt index d2b2bc32c..97a1e852a 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FruitAndBerryPicker.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FruitAndBerryPicker.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.farming -import api.ContentAPI +import api.* import core.cache.def.impl.SceneryDefinition import core.game.interaction.OptionHandler import core.game.node.Node @@ -68,7 +68,7 @@ class FruitAndBerryPicker : OptionHandler() { } player.animator.animate(animation) - ContentAPI.addItemOrDrop(player,reward.id,reward.amount) + addItemOrDrop(player,reward.id,reward.amount) player.skills.addExperience(Skills.FARMING,plantable.harvestXP) patch.setCurrentState(patch.getCurrentState() - 1) diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/LeprechaunNoter.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/LeprechaunNoter.kt index c7862fdb4..53b74294b 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/LeprechaunNoter.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/LeprechaunNoter.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.farming -import api.ContentAPI +import api.* import core.game.content.dialogue.DialoguePlugin import core.game.content.dialogue.FacialExpression import core.game.node.item.Item @@ -27,7 +27,7 @@ class LeprechaunNoter : InteractionListener() { if(player.inventory.remove(Item(usedItem.id,amt))){ player.inventory.add(Item(usedItem.noteChange,amt)) } - ContentAPI.sendItemDialogue(player,usedItem.id,"The leprechaun exchanges your items for banknotes.") + sendItemDialogue(player,usedItem.id,"The leprechaun exchanges your items for banknotes.") } else { // Unsure why the line below no longer functions, despite only changing the line above to be more correct. Using your note(NOT CROP) on the leprechaun no longer functions because of this. - Crash player.dialogueInterpreter.sendDialogues(npc.id,expr,"That IS a banknote!") diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/ToolLeprechaunInterface.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/ToolLeprechaunInterface.kt index 29639a985..7c25ee698 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/ToolLeprechaunInterface.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/ToolLeprechaunInterface.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.farming -import api.ContentAPI +import api.* import core.game.component.Component import core.game.node.entity.player.Player import core.game.node.entity.player.link.RunScript @@ -136,7 +136,7 @@ class ToolLeprechaunInterface : InterfaceListener() { } if(amount == -2){ - ContentAPI.sendInputDialogue(player, true, "Enter the amount:"){value -> + sendInputDialogue(player, true, "Enter the amount:"){value -> var amt = value as Int if(amt > hasAmount){ amt = hasAmount @@ -188,7 +188,7 @@ class ToolLeprechaunInterface : InterfaceListener() { player.dialogueInterpreter.sendDialogue("You don't have any of those stored.") } else { if(amount == -2){ - ContentAPI.sendInputDialogue(player, true, "Enter the amount:"){value -> + sendInputDialogue(player, true, "Enter the amount:"){value -> var amt = value as Int if(amt > hasAmount){ amt = hasAmount diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/UseWithPatchHandler.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/UseWithPatchHandler.kt index 872ad0001..c108fcf13 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/UseWithPatchHandler.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/UseWithPatchHandler.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.farming -import api.ContentAPI +import api.* import core.game.interaction.NodeUsageEvent import core.game.node.entity.skill.Skills import core.game.node.item.Item @@ -142,7 +142,7 @@ object UseWithPatchHandler{ override fun pulse(): Boolean { if(player.inventory.remove(event.usedItem,false)){ p.compost = if(usedItem.id == Items.SUPERCOMPOST_6034) CompostType.SUPER else CompostType.NORMAL - if(p.compost == CompostType.SUPER) ContentAPI.rewardXP(player, Skills.FARMING, 26.0) else ContentAPI.rewardXP(player, Skills.FARMING, 18.5) + if(p.compost == CompostType.SUPER) rewardXP(player, Skills.FARMING, 26.0) else rewardXP(player, Skills.FARMING, 18.5) if(p.plantable != null && p.plantable?.applicablePatch != PatchType.FLOWER) { p.harvestAmt += if(p.compost == CompostType.NORMAL) 1 else if(p.compost == CompostType.SUPER) 2 else 0 } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/gather/mining/MiningSkillPulse.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/gather/mining/MiningSkillPulse.kt index 79465394f..313b1fa27 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/gather/mining/MiningSkillPulse.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/gather/mining/MiningSkillPulse.kt @@ -1,6 +1,6 @@ package rs09.game.node.entity.skill.gather.mining -import api.ContentAPI +import api.* import core.cache.def.impl.ItemDefinition import core.game.container.impl.EquipmentContainer import core.game.content.dialogue.FacialExpression @@ -174,7 +174,7 @@ class MiningSkillPulse(private val player: Player, private val node: Node) : Pul if (!isMiningEssence) { var chance = 282 var altered = false - if (Item(player.equipment.getId(12)).name.toLowerCase().contains("ring of wealth") || ContentAPI.inEquipment(player, Items.RING_OF_THE_STAR_SPRITE_14652)) { + if (Item(player.equipment.getId(12)).name.toLowerCase().contains("ring of wealth") || inEquipment(player, Items.RING_OF_THE_STAR_SPRITE_14652)) { chance = (chance / 1.5).toInt() altered = true } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/hunter/pitfall/HunterPitfall.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/hunter/pitfall/HunterPitfall.kt index ebbbd4aa4..0fbd89bf4 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/hunter/pitfall/HunterPitfall.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/hunter/pitfall/HunterPitfall.kt @@ -1,6 +1,6 @@ import java.util.concurrent.TimeUnit; -import api.ContentAPI +import api.* import core.game.node.entity.Entity import core.game.node.entity.combat.CombatStyle import core.game.node.entity.impl.Animator.Priority; @@ -218,7 +218,7 @@ class PitfallListeners : InteractionListener() { //ForceMovement.run(pitfall_npc, pitfall_npc.getLocation(), pit.getLocation(), ForceMovement.WALK_ANIMATION, Animation(ANIM), dir, 8); //pitfall_npc.setLocation(pit.getLocation()); //pitfall_npc.walkingQueue.addPath(pit.location.x, pit.location.y); - ContentAPI.teleport(pitfall_npc, pit.location) + teleport(pitfall_npc, pit.location) pitfall_npc.startDeath(null) player.removeAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}") player.incrementAttribute("pitfall:count", -1) @@ -228,7 +228,7 @@ class PitfallListeners : InteractionListener() { //ForceMovement.run(pitfall_npc, pitfall_npc.getLocation(), dst, ForceMovement.WALK_ANIMATION, Animation(ANIM), dir, 8); //pitfall_npc.walkingQueue.addPath(npcdst.x, npcdst.y) val npcdst = dst.transform(dir, if(dir == Direction.SOUTH || dir == Direction.WEST) 1 else 0) - ContentAPI.teleport(pitfall_npc, npcdst) + teleport(pitfall_npc, npcdst) pitfall_npc.animate(Animation(5232, Priority.HIGH)) pitfall_npc.attack(player) pitfall_npc.setAttribute("last_pit_loc", pit.location) diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt index 847bb3319..dd1d2be1e 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt @@ -1,6 +1,6 @@ package core.game.node.entity.skill.runecrafting.abyss -import api.ContentAPI +import api.* import rs09.plugin.PluginManager.definePlugin import rs09.tools.stringtools.colorize import rs09.game.system.SystemLogger.logInfo @@ -99,8 +99,8 @@ class AbyssPlugin : InteractionListener() { BOIL("burn-down", arrayOf(Location.create(3024, 4833, 0), Location.create(3053, 4830, 0)), 7165) { override fun handle(player: Player, `object`: Scenery?) { `object` ?: return - if (!ContentAPI.inInventory(player, 590, 1)) { - ContentAPI.sendMessage(player, "You don't have a tinderbox to burn it.") + if (!inInventory(player, 590, 1)) { + sendMessage(player, "You don't have a tinderbox to burn it.") return } player.animate(Animation(733)) @@ -109,13 +109,13 @@ class AbyssPlugin : InteractionListener() { var count = 0 override fun pulse(): Boolean { when (count) { - 1 -> ContentAPI.sendMessage(player, "You attempt to burn your way through..") - 4 -> return if (RandomFunction.random(100) < ContentAPI.getStatLevel( + 1 -> sendMessage(player, "You attempt to burn your way through..") + 4 -> return if (RandomFunction.random(100) < getStatLevel( player, Skills.FIREMAKING ) ) { - ContentAPI.sendMessage( + sendMessage( player, colorize("%G...and manage to burn it down and get past.") ) @@ -123,7 +123,7 @@ class AbyssPlugin : InteractionListener() { player.unlock() true } else { - ContentAPI.sendMessage(player, colorize("%RYou fail to set it on fire.")) + sendMessage(player, colorize("%RYou fail to set it on fire.")) player.unlock() true } @@ -143,9 +143,9 @@ class AbyssPlugin : InteractionListener() { override fun handle(player: Player, `object`: Scenery?) { `object` ?: return logInfo("handled abyss mine") - val tool: SkillingTool = ContentAPI.getTool(player, true) ?: return + val tool: SkillingTool = getTool(player, true) ?: return if (tool == null) { - ContentAPI.sendMessage(player, "You need a pickaxe in order to do that.") + sendMessage(player, "You need a pickaxe in order to do that.") return } player.animate(tool.getAnimation()) @@ -154,18 +154,18 @@ class AbyssPlugin : InteractionListener() { var count = 0 override fun pulse(): Boolean { when (count) { - 1 -> ContentAPI.sendMessage(player, "You attempt to mine your way through..") - 4 -> return if (RandomFunction.random(100) < ContentAPI.getStatLevel( + 1 -> sendMessage(player, "You attempt to mine your way through..") + 4 -> return if (RandomFunction.random(100) < getStatLevel( player, Skills.MINING ) ) { - ContentAPI.sendMessage(player, colorize("%G...and manage to break through the rock.")) + sendMessage(player, colorize("%G...and manage to break through the rock.")) player.properties.teleportLocation = locations[getIndex(`object`)] player.unlock() true } else { - ContentAPI.sendMessage(player, colorize("%R...but fail to break-up the rock.")) + sendMessage(player, colorize("%R...but fail to break-up the rock.")) player.unlock() true } @@ -195,18 +195,18 @@ class AbyssPlugin : InteractionListener() { var count = 0 override fun pulse(): Boolean { when (count) { - 1 -> ContentAPI.sendMessage(player, "You attempt to chop your way through...") - 4 -> return if (RandomFunction.random(100) < ContentAPI.getStatLevel( + 1 -> sendMessage(player, "You attempt to chop your way through...") + 4 -> return if (RandomFunction.random(100) < getStatLevel( player, Skills.WOODCUTTING ) ) { - ContentAPI.sendMessage(player, colorize("%G...and manage to chop down the tendrils.")) + sendMessage(player, colorize("%G...and manage to chop down the tendrils.")) player.properties.teleportLocation = locations[getIndex(`object`)] player.unlock() true } else { - ContentAPI.sendMessage(player, colorize("%RYou fail to cut through the tendrils.")) + sendMessage(player, colorize("%RYou fail to cut through the tendrils.")) player.unlock() true } @@ -236,18 +236,18 @@ class AbyssPlugin : InteractionListener() { var count = 0 override fun pulse(): Boolean { when (count) { - 1 -> ContentAPI.sendMessage(player, "You attempt to squeeze through the narrow gap...") - 4 -> return if (RandomFunction.random(100) < ContentAPI.getStatLevel( + 1 -> sendMessage(player, "You attempt to squeeze through the narrow gap...") + 4 -> return if (RandomFunction.random(100) < getStatLevel( player, Skills.AGILITY ) ) { - ContentAPI.sendMessage(player, colorize("%G...and you manage to crawl through.")) + sendMessage(player, colorize("%G...and you manage to crawl through.")) player.properties.teleportLocation = locations[getIndex(`object`)] player.unlock() true } else { - ContentAPI.sendMessage(player, colorize("%RYou fail to squeeze through the narrow gap")) + sendMessage(player, colorize("%RYou fail to squeeze through the narrow gap")) player.unlock() true } @@ -307,13 +307,13 @@ class AbyssPlugin : InteractionListener() { var count = 0 override fun pulse(): Boolean { when (count) { - 1 -> ContentAPI.sendMessage(player, "You use your thieving skills to misdirect the eyes...") - 4 -> return if (RandomFunction.random(100) < ContentAPI.getStatLevel( + 1 -> sendMessage(player, "You use your thieving skills to misdirect the eyes...") + 4 -> return if (RandomFunction.random(100) < getStatLevel( player, Skills.THIEVING ) ) { - ContentAPI.sendMessage( + sendMessage( player, colorize("%G...and sneak past while they're not looking.") ) @@ -321,7 +321,7 @@ class AbyssPlugin : InteractionListener() { player.unlock() true } else { - ContentAPI.sendMessage(player, colorize("%RYou fail to distract the eyes.")) + sendMessage(player, colorize("%RYou fail to distract the eyes.")) player.unlock() true } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/skillcapeperks/SkillcapePerks.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/skillcapeperks/SkillcapePerks.kt index 59ed911ee..7f7aad6d3 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/skillcapeperks/SkillcapePerks.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/skillcapeperks/SkillcapePerks.kt @@ -64,11 +64,11 @@ enum class SkillcapePerks(val attribute: String, val effect: ((Player) -> Unit)? } }), TRICKS_OF_THE_TRADE("cape_perks:tott",{player -> - val hasHelmetBonus = api.ContentAPI.getAttribute(player, "cape_perks:tott:helmet-stored", false) + val hasHelmetBonus = api.getAttribute(player, "cape_perks:tott:helmet-stored", false) if(hasHelmetBonus){ - api.ContentAPI.sendDialogue(player, "Your cape's pockets are lined with all the utilities you need for slayer.") + api.sendDialogue(player, "Your cape's pockets are lined with all the utilities you need for slayer.") } else { - api.ContentAPI.sendDialogue(player, "Your cape is lined with empty pockets shaped like various utilities needed for slayer.") + api.sendDialogue(player, "Your cape is lined with empty pockets shaped like various utilities needed for slayer.") } }), NONE("cape_perks:none") diff --git a/Server/src/main/kotlin/rs09/game/system/command/oldsys/VisualCommand.kt b/Server/src/main/kotlin/rs09/game/system/command/oldsys/VisualCommand.kt index 216772078..83ce0edf1 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/oldsys/VisualCommand.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/oldsys/VisualCommand.kt @@ -1,6 +1,6 @@ package rs09.game.system.command.oldsys -import api.ContentAPI +import api.* import core.cache.Cache import core.game.container.access.InterfaceContainer import core.game.content.quest.tutorials.tutorialisland.CharacterDesign @@ -195,8 +195,8 @@ class VisualCommand : CommandPlugin() { return true } player!!.packetDispatch.sendSceneryAnimation(`object`, Animation(toInteger(args[args.size - 1]!!))) - //ContentAPI.sendMessage(player, `object`.definition.modelIds.map { it.toString() }.toString()) - ContentAPI.sendMessage(player, `object`.definition.animationId.toString()) + //sendMessage(player, `object`.definition.modelIds.map { it.toString() }.toString()) + sendMessage(player, `object`.definition.animationId.toString()) return true } "inter", "component", "interface" -> { @@ -227,7 +227,7 @@ class VisualCommand : CommandPlugin() { val value = (args!![1]!!.toString().toInt()) ?: 0 val cfg_index = (args.getOrNull(2)?.toString()?.toInt() ?: -1) if(cfg_index == -1){ - ContentAPI.submitWorldPulse(object : Pulse(3, player){ + submitWorldPulse(object : Pulse(3, player){ var pos = 32 var shift = 0 override fun pulse(): Boolean { @@ -243,7 +243,7 @@ class VisualCommand : CommandPlugin() { } }) } else { - ContentAPI.submitWorldPulse(object : Pulse(3, player) { + submitWorldPulse(object : Pulse(3, player) { var pos = 0 override fun pulse(): Boolean { player?.configManager?.forceSet(cfg_index, value shl pos, false) @@ -276,10 +276,10 @@ class VisualCommand : CommandPlugin() { } "loop_anim_on_i" -> { var anim = toInteger(args!![1]!!) - ContentAPI.submitWorldPulse(object : Pulse(3){ + submitWorldPulse(object : Pulse(3){ override fun pulse(): Boolean { player!!.packetDispatch.sendAnimationInterface(anim++, 224, 7) - ContentAPI.sendMessage(player, "${anim - 1}") + sendMessage(player, "${anim - 1}") return false } }) diff --git a/Server/src/main/kotlin/rs09/game/system/command/rottenpotato/RottenPotatoExtraDialogue.kt b/Server/src/main/kotlin/rs09/game/system/command/rottenpotato/RottenPotatoExtraDialogue.kt index 4898a0869..c29519c68 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/rottenpotato/RottenPotatoExtraDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/rottenpotato/RottenPotatoExtraDialogue.kt @@ -1,6 +1,6 @@ package rs09.game.system.command.rottenpotato -import api.ContentAPI +import api.* import api.InputType import core.game.content.dialogue.DialoguePlugin import core.game.node.entity.npc.NPC @@ -39,7 +39,7 @@ class RottenPotatoExtraDialogue(player: Player? = null) : DialoguePlugin(player) //Send Player Notification 1 -> { end() - ContentAPI.sendInputDialogue(player, InputType.STRING_LONG, "Enter the notification message:"){ value -> + sendInputDialogue(player, InputType.STRING_LONG, "Enter the notification message:"){ value -> val message = value as String for (p in Repository.players) { p ?: continue @@ -62,7 +62,7 @@ class RottenPotatoExtraDialogue(player: Player? = null) : DialoguePlugin(player) //Force Area NPC Chat 4 -> { end() - ContentAPI.sendInputDialogue(player, InputType.STRING_LONG,"Enter the chat message:"){ value -> + sendInputDialogue(player, InputType.STRING_LONG,"Enter the chat message:"){ value -> val msg = value as String RegionManager.getLocalNpcs(player).forEach { it.sendChat(msg) @@ -82,7 +82,7 @@ class RottenPotatoExtraDialogue(player: Player? = null) : DialoguePlugin(player) //AME Spawning 100 -> { end() - ContentAPI.sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value -> + sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value -> val other = Repository.getPlayerByName(value.toString().toLowerCase().replace(" ", "_")) if (other == null) { player.sendMessage(colorize("%RInvalid player name.")) diff --git a/Server/src/main/kotlin/rs09/game/system/command/rottenpotato/RottenPotatoRSHDDialogue.kt b/Server/src/main/kotlin/rs09/game/system/command/rottenpotato/RottenPotatoRSHDDialogue.kt index 0bf94afc6..6e6f6d223 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/rottenpotato/RottenPotatoRSHDDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/rottenpotato/RottenPotatoRSHDDialogue.kt @@ -1,6 +1,6 @@ package rs09.game.system.command.rottenpotato -import api.ContentAPI +import api.* import api.InputType import core.game.content.dialogue.DialoguePlugin import core.game.node.entity.player.Player @@ -54,7 +54,7 @@ class RottenPotatoRSHDDialogue(player: Player? = null) : DialoguePlugin(player) //View Bank 4 -> { end() - ContentAPI.sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value -> + sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value -> val other = Repository.getPlayerByName(value.toString().toLowerCase().replace(" ","_")) if(other == null){ player.sendMessage(colorize("%RInvalid player name.")) @@ -67,7 +67,7 @@ class RottenPotatoRSHDDialogue(player: Player? = null) : DialoguePlugin(player) //View Inventory 5 -> { end() - ContentAPI.sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value -> + sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value -> val other = Repository.getPlayerByName(value.toString().toLowerCase().replace(" ","_")) if(other == null){ player.sendMessage(colorize("%RInvalid player name.")) diff --git a/Server/src/main/kotlin/rs09/game/system/command/sets/FunCommandSet.kt b/Server/src/main/kotlin/rs09/game/system/command/sets/FunCommandSet.kt index cf8d118fa..70ef7c17c 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/sets/FunCommandSet.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/sets/FunCommandSet.kt @@ -1,6 +1,6 @@ package rs09.game.system.command.sets -import api.ContentAPI +import api.* import core.game.content.quest.tutorials.tutorialisland.CharacterDesign import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player @@ -152,10 +152,10 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) { val inv = player.inventory.toArray().filterNotNull() SpadeDigListener.registerListener(player.location){p -> for(item in inv){ - ContentAPI.addItemOrDrop(p, item.id, item.amount) - ContentAPI.sendMessage(p, "You dig and find ${if(item.amount > 1) "some" else "a"} ${item.name}") + addItemOrDrop(p, item.id, item.amount) + sendMessage(p, "You dig and find ${if(item.amount > 1) "some" else "a"} ${item.name}") } - ContentAPI.sendNews("${player.username} has found the hidden treasure! Congratulations!!!") + sendNews("${player.username} has found the hidden treasure! Congratulations!!!") SpadeDigListener.listeners.remove(loc) } player.inventory.clear() diff --git a/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt b/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt index 6a55379fa..61ec0d702 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt @@ -1,6 +1,6 @@ package rs09.game.system.command.sets -import api.ContentAPI +import api.* import api.InputType import core.cache.def.impl.ItemDefinition import core.cache.def.impl.NPCDefinition @@ -164,7 +164,7 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){ when(mode){ "buying" -> showGeBuy(player) "selling" -> showGeSell(player) - "search" -> ContentAPI.sendInputDialogue(player, InputType.STRING_LONG, "Enter search term:"){value -> + "search" -> sendInputDialogue(player, InputType.STRING_LONG, "Enter search term:"){value -> showOffers(player, value as String) } else -> reject(player, "Invalid mode used. Available modes are: buying, selling, search") @@ -199,7 +199,7 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){ if (player.attributes.containsKey("replyTo")) { player.setAttribute("keepDialogueAlive", true) val replyTo = player.getAttribute("replyTo", "").replace("_".toRegex(), " ") - ContentAPI.sendInputDialogue(player, InputType.MESSAGE ,StringUtils.formatDisplayName(replyTo)){ value -> + sendInputDialogue(player, InputType.MESSAGE ,StringUtils.formatDisplayName(replyTo)){ value -> CommunicationInfo.sendMessage(player, replyTo.toLowerCase(), value as String) player.removeAttribute("keepDialogueAlive") } @@ -551,11 +551,11 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){ for(i in 0..299) { val offer = offerList.elementAtOrNull(i) if (offer != null) - ContentAPI.setInterfaceText(player, offer, Components.QUESTJOURNAL_SCROLL_275, lineId++) + setInterfaceText(player, offer, Components.QUESTJOURNAL_SCROLL_275, lineId++) else - ContentAPI.setInterfaceText(player, "", Components.QUESTJOURNAL_SCROLL_275, lineId++) + setInterfaceText(player, "", Components.QUESTJOURNAL_SCROLL_275, lineId++) } - ContentAPI.openInterface(player, Components.QUESTJOURNAL_SCROLL_275) + openInterface(player, Components.QUESTJOURNAL_SCROLL_275) } fun showGeBuy(player: Player){ @@ -571,35 +571,35 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){ offers[offerIDs.key] = totalOffered } } - val offerList = offers.keys.map { "${ContentAPI.itemDefinition(it).name} - ${offers[it]}" }.sorted() + val offerList = offers.keys.map { "${itemDefinition(it).name} - ${offers[it]}" }.sorted() var lineId = 11 setScrollTitle(player, "Active Buy Offers") for(i in 0..299) { val offer = offerList.elementAtOrNull(i) if (offer != null) - ContentAPI.setInterfaceText(player, offer, Components.QUESTJOURNAL_SCROLL_275, lineId++) + setInterfaceText(player, offer, Components.QUESTJOURNAL_SCROLL_275, lineId++) else - ContentAPI.setInterfaceText(player, "", Components.QUESTJOURNAL_SCROLL_275, lineId++) + setInterfaceText(player, "", Components.QUESTJOURNAL_SCROLL_275, lineId++) } - ContentAPI.openInterface(player, Components.QUESTJOURNAL_SCROLL_275) + openInterface(player, Components.QUESTJOURNAL_SCROLL_275) } fun showOffers(player: Player, searchTerm: String){ val fakeOffers = ArrayList() OfferManager.OFFERS_BY_ITEMID.forEach { (id, offers) -> - if(searchTerm.toLowerCase().contains(ContentAPI.itemDefinition(id).name.toLowerCase()) || ContentAPI.itemDefinition(id).name.toLowerCase().contains(searchTerm.toLowerCase())){ + if(searchTerm.toLowerCase().contains(itemDefinition(id).name.toLowerCase()) || itemDefinition(id).name.toLowerCase().contains(searchTerm.toLowerCase())){ offers.forEach { - fakeOffers.add(FakeOffer(it.sell, ContentAPI.itemDefinition(id).name, it.amount)) + fakeOffers.add(FakeOffer(it.sell, itemDefinition(id).name, it.amount)) } } } OfferManager.BOT_OFFERS.forEach{ (id, amount) -> - val name = ContentAPI.getItemName(id) + val name = getItemName(id) if(searchTerm.toLowerCase().contains(name) || name.toLowerCase().contains(searchTerm.toLowerCase())) - fakeOffers.add(FakeOffer(true, ContentAPI.getItemName(id), amount)) + fakeOffers.add(FakeOffer(true, getItemName(id), amount)) } val buyingList = fakeOffers.filter { !it.sell } @@ -638,13 +638,13 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){ var lineId = 11 for(i in 0..299) { val offer = if(i < buyList.size) buyList.getOrNull(i) else sellList.getOrNull(i - (buyList.size)) - ContentAPI.setInterfaceText(player, offer ?: "", Components.QUESTJOURNAL_SCROLL_275, lineId++) + setInterfaceText(player, offer ?: "", Components.QUESTJOURNAL_SCROLL_275, lineId++) } - ContentAPI.openInterface(player, Components.QUESTJOURNAL_SCROLL_275) + openInterface(player, Components.QUESTJOURNAL_SCROLL_275) } fun setScrollTitle(player: Player, text: String){ - ContentAPI.setInterfaceText(player, text, Components.QUESTJOURNAL_SCROLL_275, 2) + setInterfaceText(player, text, Components.QUESTJOURNAL_SCROLL_275, 2) } class FakeOffer(val sell: Boolean,val name: String,val amount: Int) diff --git a/Server/src/main/kotlin/rs09/game/util/region/rellekka/RellekkaUtils.kt b/Server/src/main/kotlin/rs09/game/util/region/rellekka/RellekkaUtils.kt index 282ca96d7..bd123fd66 100644 --- a/Server/src/main/kotlin/rs09/game/util/region/rellekka/RellekkaUtils.kt +++ b/Server/src/main/kotlin/rs09/game/util/region/rellekka/RellekkaUtils.kt @@ -1,6 +1,6 @@ package rs09.game.util.region.rellekka -import api.ContentAPI +import api.* import core.game.node.entity.player.Player import core.game.system.task.Pulse import core.game.world.map.Location @@ -9,18 +9,18 @@ import org.rs09.consts.Components object RellekkaUtils { @JvmStatic fun sail(player: Player, destination: RellekkaDestination){ - ContentAPI.lock(player, 100) - ContentAPI.openOverlay(player, 115) - ContentAPI.openInterface(player, Components.MISC_SHIPJOURNEY_224) - ContentAPI.animateInterface(player, Components.MISC_SHIPJOURNEY_224, 7, destination.shipAnim) + lock(player, 100) + openOverlay(player, 115) + openInterface(player, Components.MISC_SHIPJOURNEY_224) + animateInterface(player, Components.MISC_SHIPJOURNEY_224, 7, destination.shipAnim) - val animDuration = ContentAPI.animationDuration(ContentAPI.getAnimation(destination.shipAnim)) - ContentAPI.submitWorldPulse(object : Pulse(animDuration){ + val animDuration = animationDuration(getAnimation(destination.shipAnim)) + submitWorldPulse(object : Pulse(animDuration){ override fun pulse(): Boolean { - ContentAPI.teleport(player, destination.destLoc) - ContentAPI.closeInterface(player) - ContentAPI.closeOverlay(player) - ContentAPI.unlock(player) + teleport(player, destination.destLoc) + closeInterface(player) + closeOverlay(player) + unlock(player) return true } }) diff --git a/Server/src/main/kotlin/rs09/game/world/World.kt b/Server/src/main/kotlin/rs09/game/world/World.kt index 136735e43..f9ffc5706 100644 --- a/Server/src/main/kotlin/rs09/game/world/World.kt +++ b/Server/src/main/kotlin/rs09/game/world/World.kt @@ -1,6 +1,6 @@ package rs09.game.world -import api.ContentAPI +import api.* import core.cache.Cache import core.cache.def.impl.SceneryDefinition import core.game.ge.GrandExchangeDatabase diff --git a/Server/src/main/kotlin/rs09/game/world/repository/Repository.kt b/Server/src/main/kotlin/rs09/game/world/repository/Repository.kt index 039ecd6b9..b2450e94d 100644 --- a/Server/src/main/kotlin/rs09/game/world/repository/Repository.kt +++ b/Server/src/main/kotlin/rs09/game/world/repository/Repository.kt @@ -87,7 +87,7 @@ object Repository { * I fucking hate java. */ @JvmStatic - @Deprecated("Old and bad",ReplaceWith("ContentAPI.sendNews()"),DeprecationLevel.WARNING) + @Deprecated("Old and bad",ReplaceWith("sendNews()"),DeprecationLevel.WARNING) fun sendNews(string: String){ sendNews(string,12) } diff --git a/Server/src/main/kotlin/rs09/worker/WorldClock.kt b/Server/src/main/kotlin/rs09/worker/WorldClock.kt index 208d2efcc..ad94dcc09 100644 --- a/Server/src/main/kotlin/rs09/worker/WorldClock.kt +++ b/Server/src/main/kotlin/rs09/worker/WorldClock.kt @@ -1,6 +1,6 @@ package rs09.worker -import api.ContentAPI +import api.* import core.game.system.task.Pulse import core.plugin.CorePluginTypes.Managers import gui.GuiEvent @@ -50,16 +50,16 @@ class WorldClock { ServerStore.clearDailyEntries() if(ServerConstants.DAILY_RESTART) { - ContentAPI.sendNews(colorize("%RSERVER GOING DOWN FOR DAILY RESTART IN 5 MINUTES!")) + sendNews(colorize("%RSERVER GOING DOWN FOR DAILY RESTART IN 5 MINUTES!")) ServerConstants.DAILY_RESTART = false - ContentAPI.submitWorldPulse(object : Pulse(100) { + submitWorldPulse(object : Pulse(100) { var counter = 0 override fun pulse(): Boolean { counter++ if (counter == 5) { exitProcess(0) } - ContentAPI.sendNews(colorize("%RSERVER GOING DOWN FOR DAILY RESTART IN ${5 - counter} MINUTE${if (counter < 4) "S" else ""}!")) + sendNews(colorize("%RSERVER GOING DOWN FOR DAILY RESTART IN ${5 - counter} MINUTE${if (counter < 4) "S" else ""}!")) return false } })