From ae3d9e93b5b4172feb4010228a52328729ddcb5d Mon Sep 17 00:00:00 2001 From: ceikry Date: Sun, 25 Jul 2021 23:52:34 -0500 Subject: [PATCH] Fixed a bunch of potential bugs. --- .../core/cache/bzip2/BZip2Decompressor.java | 4 - .../main/java/core/cache/def/Definition.java | 4 +- .../java/core/cache/def/impl/CS2Mapping.java | 4 +- .../cache/def/impl/GraphicDefinition.java | 2 +- .../core/cache/def/impl/NPCDefinition.java | 8 +- .../cache/def/impl/SceneryDefinition.java | 3 +- .../core/cache/gzip/GZipDecompressor.java | 2 +- .../cache/misc/buffer/ByteBufferUtils.java | 3 +- .../java/core/game/container/Container.java | 2 +- .../game/content/activity/duel/DuelRule.java | 8 -- .../activity/mta/impl/AlchemistZone.java | 4 +- .../pyramidplunder/PyramidPlunderNPC.java | 1 - .../tzhaar/TzhaarFightPitsPlugin.java | 10 +- .../wguild/animator/AnimationRoom.java | 4 +- .../content/cutscene/DBRCutscenePlugin.java | 2 +- .../free/dragonslayer/DragonSlayerPlugin.java | 6 +- .../quest/free/dragonslayer/ElvargNPC.java | 2 +- .../therestlessghost/RestlessGhostPlugin.java | 2 +- .../tutorialisland/TutorialStage.java | 5 +- .../src/main/java/core/game/ge/GEItemSet.java | 13 +-- .../inter/BoltEnchantingInterface.java | 24 ----- .../entity/npc/bosses/TormentedDemonNPC.java | 2 +- .../npc/familiar/MinotaurFamiliarNPC.java | 2 +- .../link/request/assist/AssistSession.java | 2 +- .../player/link/spawn/PKScoreBoard.java | 6 +- .../entity/skill/agility/AgilityHandler.java | 39 ++++---- .../skill/agility/pyramid/MovingBlockNPC.java | 4 +- .../skill/construction/BuildHotspot.java | 2 +- .../skill/construction/HouseManager.java | 3 + .../skill/cooking/recipe/stew/StewRecipe.java | 14 +-- .../skill/crafting/gem/GemCutPulse.java | 3 - .../game/system/communication/ClanEntry.java | 1 + .../game/system/monitor/ExceptionLog.java | 98 ------------------- .../core/game/system/monitor/MessageLog.java | 2 +- .../game/system/script/ScriptCompiler.java | 3 +- .../system/security/EncryptionManager.java | 2 +- .../main/java/core/game/world/map/Region.java | 8 -- .../java/core/game/world/map/RegionManager.kt | 41 ++++---- .../game/world/map/build/LandscapeParser.java | 6 +- .../core/game/world/map/path/Pathfinder.java | 4 +- .../world/update/flag/player/ChatFlag.java | 4 +- .../main/java/core/gui/tab/StatisticsTab.java | 5 +- .../src/main/java/core/tools/StringUtils.java | 10 +- .../java/rs09/game/ai/pvp/PVPAIPActions.java | 2 +- .../main/kotlin/rs09/game/ge/OfferManager.kt | 6 +- 45 files changed, 129 insertions(+), 253 deletions(-) delete mode 100644 Server/src/main/java/core/game/system/monitor/ExceptionLog.java diff --git a/Server/src/main/java/core/cache/bzip2/BZip2Decompressor.java b/Server/src/main/java/core/cache/bzip2/BZip2Decompressor.java index 0af0ddc5a..f62ec1145 100644 --- a/Server/src/main/java/core/cache/bzip2/BZip2Decompressor.java +++ b/Server/src/main/java/core/cache/bzip2/BZip2Decompressor.java @@ -100,10 +100,6 @@ public class BZip2Decompressor { i1++; j1--; } while (true); - if (j1 == 0) { - i = 1; - break; - } abyte0[i1] = byte4; i1++; j1--; diff --git a/Server/src/main/java/core/cache/def/Definition.java b/Server/src/main/java/core/cache/def/Definition.java index 40b227a2e..609bd80d5 100644 --- a/Server/src/main/java/core/cache/def/Definition.java +++ b/Server/src/main/java/core/cache/def/Definition.java @@ -140,7 +140,9 @@ public class Definition { if (examine == null) { try { examine = handlers.get("examine").toString(); - } catch (Exception e){} + } catch (Exception e){ + e.printStackTrace(); + } if(examine == null) { if (name.length() > 0) { examine = "It's a" + (StringUtils.isPlusN(name) ? "n " : " ") + name + "."; diff --git a/Server/src/main/java/core/cache/def/impl/CS2Mapping.java b/Server/src/main/java/core/cache/def/impl/CS2Mapping.java index b5b7b9d5f..cc1914b50 100644 --- a/Server/src/main/java/core/cache/def/impl/CS2Mapping.java +++ b/Server/src/main/java/core/cache/def/impl/CS2Mapping.java @@ -3,6 +3,8 @@ package core.cache.def.impl; import java.io.BufferedWriter; import java.io.FileWriter; import java.nio.ByteBuffer; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; @@ -71,7 +73,7 @@ public final class CS2Mapping { */ public static void main(String... args) throws Throwable { GameWorld.prompt(false); - BufferedWriter bw = new BufferedWriter(new FileWriter("./cs2.txt")); + BufferedWriter bw = Files.newBufferedWriter(Paths.get("./cs2.txt")); for (int i = 0; i < 10000; i++) { CS2Mapping mapping = forId(i); if (mapping == null) { diff --git a/Server/src/main/java/core/cache/def/impl/GraphicDefinition.java b/Server/src/main/java/core/cache/def/impl/GraphicDefinition.java index e10933de5..e554a3b1e 100644 --- a/Server/src/main/java/core/cache/def/impl/GraphicDefinition.java +++ b/Server/src/main/java/core/cache/def/impl/GraphicDefinition.java @@ -48,7 +48,7 @@ public class GraphicDefinition { if (def != null) { return def; } - byte[] data = Cache.getIndexes()[21].getFileData(gfxId >>> 735411752, gfxId & 0xff); + byte[] data = Cache.getIndexes()[21].getFileData(gfxId >>> 8, gfxId & 0xff); def = new GraphicDefinition(); def.graphicsId = gfxId; if (data != null) { diff --git a/Server/src/main/java/core/cache/def/impl/NPCDefinition.java b/Server/src/main/java/core/cache/def/impl/NPCDefinition.java index 4a118143f..d5c020a34 100644 --- a/Server/src/main/java/core/cache/def/impl/NPCDefinition.java +++ b/Server/src/main/java/core/cache/def/impl/NPCDefinition.java @@ -57,10 +57,10 @@ public final class NPCDefinition extends Definition { */ public boolean isVisibleOnMap; - /** +/* *//** * The examine option value - */ - public String examine; + *//* + public String examine;*/ /** * The drop tables. @@ -201,7 +201,7 @@ public final class NPCDefinition extends Definition { NPCDefinition def = DEFINITIONS.get(id); if (def == null) { def = new NPCDefinition(id); - byte[] data = Cache.getIndexes()[18].getFileData(id >>> 134238215, id & 0x7f); + byte[] data = Cache.getIndexes()[18].getFileData(id >>> 7, id & 0x7f); if (data == null) { if (id != -1) { // System.out.println("Failed loading NPC " + id + "."); diff --git a/Server/src/main/java/core/cache/def/impl/SceneryDefinition.java b/Server/src/main/java/core/cache/def/impl/SceneryDefinition.java index 1e55ae82f..4ee150b44 100644 --- a/Server/src/main/java/core/cache/def/impl/SceneryDefinition.java +++ b/Server/src/main/java/core/cache/def/impl/SceneryDefinition.java @@ -6,6 +6,7 @@ import core.cache.misc.buffer.ByteBufferUtils; import core.game.interaction.OptionHandler; import core.game.node.entity.player.Player; import core.game.node.object.Scenery; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import rs09.game.system.SystemLogger; import rs09.game.world.GameWorld; @@ -1670,6 +1671,6 @@ public class SceneryDefinition extends Definition { * @return The container id. */ public static int getContainerId(int id) { - return id >>> 1998118472; + return id >>> 8; } } \ No newline at end of file diff --git a/Server/src/main/java/core/cache/gzip/GZipDecompressor.java b/Server/src/main/java/core/cache/gzip/GZipDecompressor.java index 021751497..0b4506456 100644 --- a/Server/src/main/java/core/cache/gzip/GZipDecompressor.java +++ b/Server/src/main/java/core/cache/gzip/GZipDecompressor.java @@ -7,7 +7,7 @@ public class GZipDecompressor { private static final Inflater inflaterInstance = new Inflater(true); - public static final void decompress(ByteBuffer buffer, byte data[]) { + public static final void decompress(ByteBuffer buffer, byte[] data) { synchronized (inflaterInstance) { if (~buffer.get(buffer.position()) != -32 || buffer.get(buffer.position() + 1) != -117) { data = null; diff --git a/Server/src/main/java/core/cache/misc/buffer/ByteBufferUtils.java b/Server/src/main/java/core/cache/misc/buffer/ByteBufferUtils.java index c481ffd6c..6c08a9db1 100644 --- a/Server/src/main/java/core/cache/misc/buffer/ByteBufferUtils.java +++ b/Server/src/main/java/core/cache/misc/buffer/ByteBufferUtils.java @@ -2,6 +2,7 @@ package core.cache.misc.buffer; import java.io.ObjectInputStream; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; /** * Holds utility methods for reading/writing a byte buffer. @@ -29,7 +30,7 @@ public final class ByteBufferUtils { * @param buffer The byte buffer. */ public static void putString(String s, ByteBuffer buffer) { - buffer.put(s.getBytes()).put((byte) 0); + buffer.put(s.getBytes(StandardCharsets.UTF_8)).put((byte) 0); } /** diff --git a/Server/src/main/java/core/game/container/Container.java b/Server/src/main/java/core/game/container/Container.java index 44857663c..d21244289 100644 --- a/Server/src/main/java/core/game/container/Container.java +++ b/Server/src/main/java/core/game/container/Container.java @@ -521,7 +521,7 @@ public class Container { int id = buffer.getShort() & 0xFFFF; int amount = buffer.getInt(); int charge = buffer.getInt(); - if (id >= ItemDefinition.getDefinitions().size() || id < 0 || slot >= items.length || slot < 0) { + if (id >= ItemDefinition.getDefinitions().size() || slot >= items.length || slot < 0) { continue; } Item item = items[slot] = new Item(id, amount, charge); diff --git a/Server/src/main/java/core/game/content/activity/duel/DuelRule.java b/Server/src/main/java/core/game/content/activity/duel/DuelRule.java index cdcfb8fb2..88de3f9d7 100644 --- a/Server/src/main/java/core/game/content/activity/duel/DuelRule.java +++ b/Server/src/main/java/core/game/content/activity/duel/DuelRule.java @@ -69,12 +69,4 @@ public enum DuelRule { public int getEquipmentSlot() { return equipmentSlot; } - - /** - * Sets the equipmentSlot. - * @param equipmentSlot the equipmentSlot to set - */ - public void setEquipmentSlot(int equipmentSlot) { - this.equipmentSlot = equipmentSlot; - } } \ No newline at end of file diff --git a/Server/src/main/java/core/game/content/activity/mta/impl/AlchemistZone.java b/Server/src/main/java/core/game/content/activity/mta/impl/AlchemistZone.java index 8ee51fb65..cdb4c2021 100644 --- a/Server/src/main/java/core/game/content/activity/mta/impl/AlchemistZone.java +++ b/Server/src/main/java/core/game/content/activity/mta/impl/AlchemistZone.java @@ -305,7 +305,7 @@ public class AlchemistZone extends MTAZone { int alchIndex = indexer + index; if (indexer != 0) { if (indexer >= 4 && index < 4) { - if (indexer == 4 && indexer - index < 4 || indexer - index < 4) { + if (indexer == 4 && indexer - index < 4) { return null; } if (indexer == 4) { @@ -430,7 +430,7 @@ public class AlchemistZone extends MTAZone { * Sets the cost. * @param cost the cost to set. */ - public void setCost(int cost) { + private void setCost(int cost) { this.cost = cost; } diff --git a/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderNPC.java b/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderNPC.java index c3b89ee1d..4b062cb62 100644 --- a/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderNPC.java +++ b/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderNPC.java @@ -56,7 +56,6 @@ public abstract class PyramidPlunderNPC extends AbstractNPC { public PyramidPlunderNPC(int id, Location location, Player player) { super(id, location); this.player = player; - this.quotes = quotes; this.endTime = (int) (GameWorld.getTicks() + (1000 / 0.6)); } diff --git a/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightPitsPlugin.java b/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightPitsPlugin.java index 07f671b52..79482f29d 100644 --- a/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightPitsPlugin.java +++ b/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightPitsPlugin.java @@ -138,12 +138,12 @@ public final class TzhaarFightPitsPlugin extends ActivityPlugin { // Become the Champion of the Fight Pits if (lastVictor != null) { lastVictor.getAchievementDiaryManager().finishTask(lastVictor, DiaryType.KARAMJA, 2, 0); + addTokkul(lastVictor); + lastVictor.getAppearance().setSkullIcon(SKULL_ID); + lastVictor.getUpdateMasks().register(new AppearanceFlag(lastVictor)); + lastVictor.getPacketDispatch().sendString("Current Champion: " + getChampionName(), INTERFACE_ID, 0); + resetDamagePulse(lastVictor); } - addTokkul(lastVictor); - lastVictor.getAppearance().setSkullIcon(SKULL_ID); - lastVictor.getUpdateMasks().register(new AppearanceFlag(lastVictor)); - lastVictor.getPacketDispatch().sendString("Current Champion: " + getChampionName(), INTERFACE_ID, 0); - resetDamagePulse(lastVictor); RegionManager.forId(9552).getPlanes()[0].getNpcs().get(0).setAttribute("fp_champn", getChampionName()); } minutes = 0; diff --git a/Server/src/main/java/core/game/content/activity/wguild/animator/AnimationRoom.java b/Server/src/main/java/core/game/content/activity/wguild/animator/AnimationRoom.java index 64399996a..f091efbd4 100644 --- a/Server/src/main/java/core/game/content/activity/wguild/animator/AnimationRoom.java +++ b/Server/src/main/java/core/game/content/activity/wguild/animator/AnimationRoom.java @@ -181,7 +181,9 @@ public final class AnimationRoom extends MapZone implements Plugin { } } } - animateArmour(event.getPlayer(), (Scenery) event.getUsedWith(), set); + if(set != null) { + animateArmour(event.getPlayer(), (Scenery) event.getUsedWith(), set); + } return true; } diff --git a/Server/src/main/java/core/game/content/cutscene/DBRCutscenePlugin.java b/Server/src/main/java/core/game/content/cutscene/DBRCutscenePlugin.java index 2a07b37a6..03fbebdca 100644 --- a/Server/src/main/java/core/game/content/cutscene/DBRCutscenePlugin.java +++ b/Server/src/main/java/core/game/content/cutscene/DBRCutscenePlugin.java @@ -392,7 +392,7 @@ public final class DBRCutscenePlugin extends CutscenePlugin { getWiseOldMan().animate(CAST_ANIMATION); getWiseOldMan().graphics(new Graphics(433)); if (target instanceof Entity) { - Projectile.create(getWiseOldMan(), target instanceof Entity ? ((Entity) target) : null, 434).send(); + Projectile.create(getWiseOldMan(), (Entity) target, 434).send(); } else { Projectile projectile = Projectile.create(getWiseOldMan(), null, 434, 30, 30, 41, 140, 0, 0); projectile.setEndLocation((Location) target); diff --git a/Server/src/main/java/core/game/content/quest/free/dragonslayer/DragonSlayerPlugin.java b/Server/src/main/java/core/game/content/quest/free/dragonslayer/DragonSlayerPlugin.java index 681d87eca..0d1a639d2 100644 --- a/Server/src/main/java/core/game/content/quest/free/dragonslayer/DragonSlayerPlugin.java +++ b/Server/src/main/java/core/game/content/quest/free/dragonslayer/DragonSlayerPlugin.java @@ -150,7 +150,7 @@ public final class DragonSlayerPlugin extends OptionHandler { InteractionListeners.run(node.getId(),0,"equip",player,node); break; case 742: - if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD) || player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { + if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for"); player.getPacketDispatch().sendMessage("your reward!"); return true; @@ -169,7 +169,7 @@ public final class DragonSlayerPlugin extends OptionHandler { movement.run(player, 10); return true; } - if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD) || player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { + if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for"); player.getPacketDispatch().sendMessage("your reward!"); return true; @@ -318,7 +318,7 @@ public final class DragonSlayerPlugin extends OptionHandler { case 2604: switch (option) { case "search": - if (!player.getInventory().containsItem(DragonSlayer.MAZE_PIECE) && !player.getInventory().containsItem(DragonSlayer.MAZE_PIECE)) { + if (!player.getInventory().containsItem(DragonSlayer.MAZE_PIECE)) { if (!player.getInventory().add(DragonSlayer.MAZE_PIECE)) { GroundItemManager.create(DragonSlayer.MAZE_PIECE, player); } diff --git a/Server/src/main/java/core/game/content/quest/free/dragonslayer/ElvargNPC.java b/Server/src/main/java/core/game/content/quest/free/dragonslayer/ElvargNPC.java index e5e7ad0cf..8a8376c1c 100644 --- a/Server/src/main/java/core/game/content/quest/free/dragonslayer/ElvargNPC.java +++ b/Server/src/main/java/core/game/content/quest/free/dragonslayer/ElvargNPC.java @@ -148,7 +148,7 @@ public final class ElvargNPC extends AbstractNPC { return super.isAttackable(entity, style); } final Player player = (Player) entity; - if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD) || player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { + if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for"); player.getPacketDispatch().sendMessage("your reward!"); return true; diff --git a/Server/src/main/java/core/game/content/quest/free/therestlessghost/RestlessGhostPlugin.java b/Server/src/main/java/core/game/content/quest/free/therestlessghost/RestlessGhostPlugin.java index 2b2c99f1e..508bc9222 100644 --- a/Server/src/main/java/core/game/content/quest/free/therestlessghost/RestlessGhostPlugin.java +++ b/Server/src/main/java/core/game/content/quest/free/therestlessghost/RestlessGhostPlugin.java @@ -80,7 +80,7 @@ public final class RestlessGhostPlugin extends OptionHandler { switch (option) { case "open": switch (id) { - case 2145: + default: toggleCoffin(player, object); break; } diff --git a/Server/src/main/java/core/game/content/quest/tutorials/tutorialisland/TutorialStage.java b/Server/src/main/java/core/game/content/quest/tutorials/tutorialisland/TutorialStage.java index 0f1a71c17..046911153 100644 --- a/Server/src/main/java/core/game/content/quest/tutorials/tutorialisland/TutorialStage.java +++ b/Server/src/main/java/core/game/content/quest/tutorials/tutorialisland/TutorialStage.java @@ -967,10 +967,9 @@ public enum TutorialStage { /** * Represents if it is a login stage. * @param login the login value. - * @return {@code True} if so. */ - public boolean isLogin(boolean login) { - return this.login = login; + public void isLogin(boolean login) { + this.login = login; } /** diff --git a/Server/src/main/java/core/game/ge/GEItemSet.java b/Server/src/main/java/core/game/ge/GEItemSet.java index 0042c1e3a..c0794e0c5 100644 --- a/Server/src/main/java/core/game/ge/GEItemSet.java +++ b/Server/src/main/java/core/game/ge/GEItemSet.java @@ -2,6 +2,7 @@ package core.game.ge; import core.game.node.item.Item; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -75,20 +76,12 @@ public enum GEItemSet { return itemId; } - /** - * Sets the itemId. - * @param itemId The itemId to set. - */ - public void setItemId(int itemId) { - this.itemId = itemId; - } - /** * Gets the components. * @return The components. */ public int[] getComponents() { - return components; + return Arrays.copyOf(components, components.length); } /** @@ -104,6 +97,6 @@ public enum GEItemSet { * @return The item array. */ public static Item[] getItemArray() { - return itemArray; + return Arrays.copyOf(itemArray, itemArray.length); } } \ No newline at end of file diff --git a/Server/src/main/java/core/game/interaction/inter/BoltEnchantingInterface.java b/Server/src/main/java/core/game/interaction/inter/BoltEnchantingInterface.java index 86f6e40b3..f1d3dffac 100644 --- a/Server/src/main/java/core/game/interaction/inter/BoltEnchantingInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/BoltEnchantingInterface.java @@ -185,14 +185,6 @@ public final class BoltEnchantingInterface extends ComponentPlugin { return button; } - /** - * Sets the button. - * @param button The button to set. - */ - public void setButton(int button) { - this.button = button; - } - /** * Gets the bolt. * @return The bolt. @@ -201,14 +193,6 @@ public final class BoltEnchantingInterface extends ComponentPlugin { return bolt; } - /** - * Sets the bolt. - * @param bolt The bolt to set. - */ - public void setBolt(int bolt) { - this.bolt = bolt; - } - /** * Gets the level. * @return The level. @@ -217,14 +201,6 @@ public final class BoltEnchantingInterface extends ComponentPlugin { return level; } - /** - * Sets the level. - * @param level The level to set. - */ - public void setLevel(int level) { - this.level = level; - } - /** * Gets the runes. * @return The runes. diff --git a/Server/src/main/java/core/game/node/entity/npc/bosses/TormentedDemonNPC.java b/Server/src/main/java/core/game/node/entity/npc/bosses/TormentedDemonNPC.java index 702399b7a..df824b3e7 100644 --- a/Server/src/main/java/core/game/node/entity/npc/bosses/TormentedDemonNPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/bosses/TormentedDemonNPC.java @@ -115,7 +115,7 @@ public class TormentedDemonNPC extends AbstractNPC { @Override public void checkImpact(BattleState state) { - if (fireShield && state.getAttacker().isPlayer() && state.getEstimatedHit() > 0 && state.getWeapon() != null && (state.getWeapon().getId() == 6746 || state.getWeapon().getId() == 6746 || state.getWeapon().getId() == 732)) { + if (fireShield && state.getAttacker().isPlayer() && state.getEstimatedHit() > 0 && state.getWeapon() != null && (state.getWeapon().getId() == 6746 || state.getWeapon().getId() == 732)) { shieldDelay = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60); fireShield = false; setAttribute("shield-player", state.getAttacker()); diff --git a/Server/src/main/java/core/game/node/entity/npc/familiar/MinotaurFamiliarNPC.java b/Server/src/main/java/core/game/node/entity/npc/familiar/MinotaurFamiliarNPC.java index e6f6319c6..83b5222af 100644 --- a/Server/src/main/java/core/game/node/entity/npc/familiar/MinotaurFamiliarNPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/familiar/MinotaurFamiliarNPC.java @@ -55,7 +55,7 @@ public final class MinotaurFamiliarNPC implements Plugin { familiar.sendFamiliarHit(target, RandomFunction.random(maxHit)); Projectile.magic(familiar, target, 1497, 80, 36, 70, 10).send(); familiar.visualize(Animation.create(8026), Graphics.create(1496)); - if (!(familiar instanceof BronzeMinotaurNPC && familiar instanceof RuneMinotaurNPC) && RandomFunction.random(10) < 6) { + if (!(familiar instanceof BronzeMinotaurNPC || familiar instanceof RuneMinotaurNPC) && RandomFunction.random(10) < 6) { final int ticks = 2 + (int) Math.floor(familiar.getLocation().getDistance(target.getLocation()) * 0.5); GameWorld.getPulser().submit(new Pulse(ticks) { @Override diff --git a/Server/src/main/java/core/game/node/entity/player/link/request/assist/AssistSession.java b/Server/src/main/java/core/game/node/entity/player/link/request/assist/AssistSession.java index 1d225f7d4..e596895ad 100644 --- a/Server/src/main/java/core/game/node/entity/player/link/request/assist/AssistSession.java +++ b/Server/src/main/java/core/game/node/entity/player/link/request/assist/AssistSession.java @@ -406,7 +406,7 @@ public final class AssistSession extends Pulse implements RequestModule { if (getPlayer() != p) { int index = getSkillIndex(slot); if (index != -1) { - if (index != -1 && !isRestricted()) { + if (!isRestricted()) { int level = p.getSkills().getLevel(slot); int pLevel = player.getSkills().getLevel(slot); if (pLevel < level) { diff --git a/Server/src/main/java/core/game/node/entity/player/link/spawn/PKScoreBoard.java b/Server/src/main/java/core/game/node/entity/player/link/spawn/PKScoreBoard.java index 7e3721854..99f8ed69f 100644 --- a/Server/src/main/java/core/game/node/entity/player/link/spawn/PKScoreBoard.java +++ b/Server/src/main/java/core/game/node/entity/player/link/spawn/PKScoreBoard.java @@ -114,7 +114,7 @@ public final class PKScoreBoard { int score = player.getSavedData().getSpawnData().getKills(); int myScore = 0; for (int i = 0; i < names.length; i++) { - if (names[i].equals(player.getName()) || names[i].equals(player.getName())) { + if (names[i].equals(player.getName())) { myScore = scores[i]; break; } @@ -152,13 +152,13 @@ public final class PKScoreBoard { if (scores[index] == score) { return; } - if (names[index].equals(player.getName()) || names[index].equals(player.getName())) { + if (names[index].equals(player.getName())) { scores[index] = score; return; } for (int i = SIZE - 2; i >= index; i--) { String name = names[i]; - if (name.equals(player.getName()) || name.equals(player.getName())) { + if (name.equals(player.getName())) { name = names[--i]; } scores[i + 1] = scores[i]; 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 b81f26dd6..4ccca3d9e 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 @@ -103,27 +103,28 @@ 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) { - boolean dmg = false; - @Override - public boolean pulse() { - ContentAPI.teleport(player, dest, TeleportManager.TeleportType.INSTANT); - ContentAPI.animate(player, Animation.RESET, true); - if(!dmg) { - if (hit > 0) { - player.getImpactHandler().setDisabledTicks(0); - ContentAPI.impact(player, hit, HitsplatType.NORMAL); + ContentAPI.submitWorldPulse(new Pulse(ContentAPI.animationDuration(anim), player) { + boolean dmg = false; + + @Override + public boolean pulse() { + ContentAPI.teleport(player, dest, TeleportManager.TeleportType.INSTANT); + ContentAPI.animate(player, Animation.RESET, true); + if (!dmg) { + if (hit > 0) { + player.getImpactHandler().setDisabledTicks(0); + ContentAPI.impact(player, hit, HitsplatType.NORMAL); + } + if (message != null) { + ContentAPI.sendMessage(player, message); + } + dmg = true; } - if (message != null) { - ContentAPI.sendMessage(player, message); - } - dmg = true; + setDelay(0); + return player.getLocation().equals(dest); } - setDelay(0); - return player.getLocation().equals(dest); - } - }); + }); + } } /** diff --git a/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/MovingBlockNPC.java b/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/MovingBlockNPC.java index 292b445ce..6c96397ef 100644 --- a/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/MovingBlockNPC.java +++ b/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/MovingBlockNPC.java @@ -134,7 +134,9 @@ public final class MovingBlockNPC extends AbstractNPC { } player.lock(4); player.setAttribute("block-move", GameWorld.getTicks() + 4); - AgilityHandler.failWalk(player, close ? 1 : 3, player.getLocation(), dest, AgilityPyramidCourse.transformLevel(dest), Animation.create(3066), 10, 8, null, getId() == 3124 ? Direction.WEST : Direction.SOUTH); + if(dest != null) { + AgilityHandler.failWalk(player, close ? 1 : 3, player.getLocation(), dest, AgilityPyramidCourse.transformLevel(dest), Animation.create(3066), 10, 8, null, getId() == 3124 ? Direction.WEST : Direction.SOUTH); + } return true; } }); diff --git a/Server/src/main/java/core/game/node/entity/skill/construction/BuildHotspot.java b/Server/src/main/java/core/game/node/entity/skill/construction/BuildHotspot.java index 5c8577c43..b3cefa033 100644 --- a/Server/src/main/java/core/game/node/entity/skill/construction/BuildHotspot.java +++ b/Server/src/main/java/core/game/node/entity/skill/construction/BuildHotspot.java @@ -375,7 +375,7 @@ public enum BuildHotspot { /** * The linked hotspots */ - private static List linkedHotspots = new ArrayList(); + private static final List linkedHotspots = new ArrayList(); /** * Configures hotspots. diff --git a/Server/src/main/java/core/game/node/entity/skill/construction/HouseManager.java b/Server/src/main/java/core/game/node/entity/skill/construction/HouseManager.java index 000df4337..5629301fa 100644 --- a/Server/src/main/java/core/game/node/entity/skill/construction/HouseManager.java +++ b/Server/src/main/java/core/game/node/entity/skill/construction/HouseManager.java @@ -494,6 +494,9 @@ public final class HouseManager { chunkY = 7 - chunkY; break; } + default: { + + } } for (Hotspot h : room.getHotspots()) { if ((h.getChunkX() == chunkX || h.getChunkX2() == chunkX) && (h.getChunkY() == chunkY || h.getChunkY2() == chunkY) && h.getHotspot().getObjectId(style) == object.getId()) { diff --git a/Server/src/main/java/core/game/node/entity/skill/cooking/recipe/stew/StewRecipe.java b/Server/src/main/java/core/game/node/entity/skill/cooking/recipe/stew/StewRecipe.java index e53e8da1d..17f6c4a08 100644 --- a/Server/src/main/java/core/game/node/entity/skill/cooking/recipe/stew/StewRecipe.java +++ b/Server/src/main/java/core/game/node/entity/skill/cooking/recipe/stew/StewRecipe.java @@ -47,13 +47,15 @@ public class StewRecipe extends Recipe { public void mix(Player player, NodeUsageEvent event) { Item first = event.getUsedItem(); Item second = event.getBaseItem(); - if (player.getInventory().remove(first) && player.getInventory().remove(second)) { - if (first.getId() == BOWL_OF_WATER.getId() || second.getId() == BOWL_OF_WATER.getId()) { - player.getInventory().add(first.getId() == POTATO.getId() ? INCOMPLETE_STEW : first.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : second.getId() == POTATO.getId() ? INCOMPLETE_STEW : second.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : null); - } else { - player.getInventory().add(UNCOOKED_STEW); + if(first != null && second != null) { + if (player.getInventory().remove(first) && player.getInventory().remove(second)) { + if (first.getId() == BOWL_OF_WATER.getId() || second.getId() == BOWL_OF_WATER.getId()) { + player.getInventory().add(first.getId() == POTATO.getId() ? INCOMPLETE_STEW : first.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : second.getId() == POTATO.getId() ? INCOMPLETE_STEW : second.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : null); + } else { + player.getInventory().add(UNCOOKED_STEW); + } + player.getPacketDispatch().sendMessage(getMixMessage(event)); } - player.getPacketDispatch().sendMessage(getMixMessage(event)); } } diff --git a/Server/src/main/java/core/game/node/entity/skill/crafting/gem/GemCutPulse.java b/Server/src/main/java/core/game/node/entity/skill/crafting/gem/GemCutPulse.java index c023e0c3c..206a09851 100644 --- a/Server/src/main/java/core/game/node/entity/skill/crafting/gem/GemCutPulse.java +++ b/Server/src/main/java/core/game/node/entity/skill/crafting/gem/GemCutPulse.java @@ -68,9 +68,6 @@ public final class GemCutPulse extends SkillPulse { @Override public boolean reward() { - if (++ticks % 1 != 0) { - return false; - } if (player.getInventory().remove(gem.getUncut())) { final Item item = gem.getGem(); player.getInventory().add(item); diff --git a/Server/src/main/java/core/game/system/communication/ClanEntry.java b/Server/src/main/java/core/game/system/communication/ClanEntry.java index 1e74baa80..55d2280cc 100644 --- a/Server/src/main/java/core/game/system/communication/ClanEntry.java +++ b/Server/src/main/java/core/game/system/communication/ClanEntry.java @@ -46,6 +46,7 @@ public class ClanEntry { @Override public boolean equals(Object o) { + if(o == null) return false; ClanEntry e = (ClanEntry) o; if (name != null && !name.equals(e.name)) { return false; diff --git a/Server/src/main/java/core/game/system/monitor/ExceptionLog.java b/Server/src/main/java/core/game/system/monitor/ExceptionLog.java deleted file mode 100644 index d5b742c39..000000000 --- a/Server/src/main/java/core/game/system/monitor/ExceptionLog.java +++ /dev/null @@ -1,98 +0,0 @@ -package core.game.system.monitor; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; - -/** - * Handles exception logging. - * @author Emperor - */ -public final class ExceptionLog extends PrintStream { - - /** - * The logger. - */ - private final PrintStream logger; - - /** - * Constructs a new {@code ExceptionLog} {@code Object} - * @param file The output file directory. - * @throws IOException When an I/O exception occurs. - */ - public ExceptionLog(String file) throws IOException { - super(new File(file)); - this.logger = System.err; - } - - @Override - public void println(String message) { - logger.println(message); - } - - @Override - public PrintStream printf(String message, Object... objects) { - logger.printf(message, objects); - return super.printf(message, objects); - } - - @Override - public void println(boolean message) { - logger.println(message); - } - - @Override - public void println(int message) { - logger.println(message); - } - - @Override - public void println(double message) { - logger.println(message); - } - - @Override - public void println(char message) { - logger.println(message); - } - - @Override - public void println(long message) { - logger.println(message); - } - - @Override - public void println(Object message) { - logger.println(message); - } - - @Override - public void print(boolean message) { - logger.print(message); - } - - @Override - public void print(int message) { - logger.print(message); - } - - @Override - public void print(double message) { - logger.print(message); - } - - @Override - public void print(char message) { - logger.print(message); - } - - @Override - public void print(long message) { - logger.print(message); - } - - @Override - public void print(Object message) { - logger.print(message); - } -} \ No newline at end of file diff --git a/Server/src/main/java/core/game/system/monitor/MessageLog.java b/Server/src/main/java/core/game/system/monitor/MessageLog.java index f01ae34cf..bcf7772e7 100644 --- a/Server/src/main/java/core/game/system/monitor/MessageLog.java +++ b/Server/src/main/java/core/game/system/monitor/MessageLog.java @@ -21,7 +21,7 @@ public class MessageLog { /** * The date format used. */ - private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); /** * The messages. diff --git a/Server/src/main/java/core/game/system/script/ScriptCompiler.java b/Server/src/main/java/core/game/system/script/ScriptCompiler.java index 2e5645f88..fddc305a2 100644 --- a/Server/src/main/java/core/game/system/script/ScriptCompiler.java +++ b/Server/src/main/java/core/game/system/script/ScriptCompiler.java @@ -14,6 +14,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.nio.file.Files; import java.util.*; /** @@ -105,7 +106,7 @@ public final class ScriptCompiler { */ public static ScriptContext parseRaw(File file) throws Throwable { loadInstructions(); - BufferedReader br = new BufferedReader(new FileReader(file)); + BufferedReader br = Files.newBufferedReader(file.toPath()); lineId = -1; String line; builder = null; diff --git a/Server/src/main/java/core/game/system/security/EncryptionManager.java b/Server/src/main/java/core/game/system/security/EncryptionManager.java index fd8aa59b1..0b038fb3b 100644 --- a/Server/src/main/java/core/game/system/security/EncryptionManager.java +++ b/Server/src/main/java/core/game/system/security/EncryptionManager.java @@ -190,7 +190,7 @@ public class EncryptionManager { * @return the decoded value of x */ private static byte char64(char x) { - if ((int) x < 0 || (int) x > index_64.length) + if ((int) x > index_64.length) return -1; return index_64[(int) x]; } diff --git a/Server/src/main/java/core/game/world/map/Region.java b/Server/src/main/java/core/game/world/map/Region.java index 5d894d57d..78b580d7c 100644 --- a/Server/src/main/java/core/game/world/map/Region.java +++ b/Server/src/main/java/core/game/world/map/Region.java @@ -507,14 +507,6 @@ public class Region { this.loaded = loaded; } - /** - * Gets the viewAmount. - * @return The viewAmount. - */ - public int getViewAmount() { - return viewAmount; - } - /** * Sets the viewAmount. * @param viewAmount The viewAmount to set. diff --git a/Server/src/main/java/core/game/world/map/RegionManager.kt b/Server/src/main/java/core/game/world/map/RegionManager.kt index 93d5e891b..12c889371 100644 --- a/Server/src/main/java/core/game/world/map/RegionManager.kt +++ b/Server/src/main/java/core/game/world/map/RegionManager.kt @@ -33,17 +33,20 @@ object RegionManager { */ @JvmStatic fun forId(regionId: Int): Region { - LOCK.tryLock(10000, TimeUnit.MILLISECONDS) - var region = REGION_CACHE[regionId] - if (region == null) { - region = Region((regionId shr 8) and 0xFF, regionId and 0xFF) - if(region!!.regionId != regionId){ - SystemLogger.logErr("IDs do NOT match - ${region!!.regionId} supposed to be $regionId") + if(LOCK.tryLock() || LOCK.tryLock(10000, TimeUnit.MILLISECONDS)) { + var region = REGION_CACHE[regionId] + if (region == null) { + region = Region((regionId shr 8) and 0xFF, regionId and 0xFF) + if (region!!.regionId != regionId) { + SystemLogger.logErr("IDs do NOT match - ${region!!.regionId} supposed to be $regionId") + } + REGION_CACHE[regionId] = region } - REGION_CACHE[regionId] = region + LOCK.unlock() + return REGION_CACHE[regionId]!! } - LOCK.unlock() - return REGION_CACHE[regionId]!! + SystemLogger.logErr("UNABLE TO OBTAIN LOCK WHEN GETTING REGION BY ID. RETURNING BLANK REGION.") + return Region(0,0) } /** @@ -51,15 +54,16 @@ object RegionManager { */ @JvmStatic fun pulse() { - LOCK.tryLock(10000,TimeUnit.MILLISECONDS) - for (r in REGION_CACHE.values) { - if (r != null && r.isActive) { - for (p in r.planes) { - p.pulse() + if(LOCK.tryLock() || LOCK.tryLock(10000,TimeUnit.MILLISECONDS)) { + for (r in REGION_CACHE.values) { + if (r.isActive) { + for (p in r.planes) { + p.pulse() + } } } + LOCK.unlock() } - LOCK.unlock() } /** @@ -788,9 +792,10 @@ object RegionManager { @JvmStatic fun addRegion(id: Int, region: Region){ - LOCK.tryLock(10000, TimeUnit.MILLISECONDS) - REGION_CACHE[id] = region - LOCK.unlock() + if(lock.tryLock() || LOCK.tryLock(10000, TimeUnit.MILLISECONDS)) { + REGION_CACHE[id] = region + LOCK.unlock() + } } /** diff --git a/Server/src/main/java/core/game/world/map/build/LandscapeParser.java b/Server/src/main/java/core/game/world/map/build/LandscapeParser.java index 85ffd8ebc..95734f9cf 100644 --- a/Server/src/main/java/core/game/world/map/build/LandscapeParser.java +++ b/Server/src/main/java/core/game/world/map/build/LandscapeParser.java @@ -45,7 +45,9 @@ public final class LandscapeParser { int type = configuration >> 2; int z = location >> 12; r.setObjectCount(r.getObjectCount() + 1); - if (x >= 0 && y >= 0 && x < 64 && y < 64) { + if (x < 0 || y < 0 || x >= 64 || y >= 64) { + System.out.println("Object out of bounds: " + objectId + " - " + x + ", " + y + ", " + z); + } else { if ((mapscape[1][x][y] & 0x2) == 2) { z--; } @@ -53,8 +55,6 @@ public final class LandscapeParser { Scenery object = new Scenery(objectId, Location.create((r.getX() << 6) + x, (r.getY() << 6) + y, z), type, rotation); flagScenery(r.getPlanes()[z], x, y, object, true, storeObjects); } - } else { - System.out.println("Object out of bounds: " + objectId + " - " + x + ", " + y + ", " + z); } } } diff --git a/Server/src/main/java/core/game/world/map/path/Pathfinder.java b/Server/src/main/java/core/game/world/map/path/Pathfinder.java index 6c9cb36ba..28fe256ae 100644 --- a/Server/src/main/java/core/game/world/map/path/Pathfinder.java +++ b/Server/src/main/java/core/game/world/map/path/Pathfinder.java @@ -183,7 +183,7 @@ public abstract class Pathfinder { */ public static boolean canDecorationInteract(int curX, int curY, int size, int destX, int destY, int rotation, int type, int z, ClipMaskSupplier clipMaskSupplier) { if (size != 1) { - if (destX >= curX && destX <= (curX + size) - 1 && destY >= destY && destY <= (destY + size) - 1) { + if (destX >= curX && destX <= (curX + size) - 1 && destY <= (destY + size) - 1) { return true; } } else if (destX == curX && curY == destY) { @@ -307,7 +307,7 @@ public abstract class Pathfinder { */ public static boolean canDoorInteract(int curX, int curY, int size, int destX, int destY, int type, int rotation, int z, ClipMaskSupplier clipMaskSupplier) { if (size != 1) { - if (destX >= curX && destX <= size + curX - 1 && destY >= destY && destY <= destY + size - 1) { + if (destX >= curX && destX <= size + curX - 1 && destY <= destY + size - 1) { return true; } } else if (curX == destX && destY == curY) { diff --git a/Server/src/main/java/core/game/world/update/flag/player/ChatFlag.java b/Server/src/main/java/core/game/world/update/flag/player/ChatFlag.java index ca11afcee..cdefd314d 100644 --- a/Server/src/main/java/core/game/world/update/flag/player/ChatFlag.java +++ b/Server/src/main/java/core/game/world/update/flag/player/ChatFlag.java @@ -6,6 +6,8 @@ import core.game.world.update.flag.context.ChatMessage; import core.net.packet.IoBuffer; import core.tools.StringUtils; +import java.nio.charset.StandardCharsets; + /** * Handles the chat flag. * @author Emperor @@ -24,7 +26,7 @@ public class ChatFlag extends UpdateFlag { public void write(IoBuffer buffer) { byte[] chatStr = new byte[256]; chatStr[0] = (byte) context.getText().length(); - int offset = 1 + StringUtils.encryptPlayerChat(chatStr, 0, 1, context.getText().length(), context.getText().getBytes()); + int offset = 1 + StringUtils.encryptPlayerChat(chatStr, 0, 1, context.getText().length(), context.getText().getBytes(StandardCharsets.UTF_8)); buffer.putLEShort(context.getEffects()); // 0x8000 does something (you'd // need to send something // extra. diff --git a/Server/src/main/java/core/gui/tab/StatisticsTab.java b/Server/src/main/java/core/gui/tab/StatisticsTab.java index be5a5d8a5..67a065b5f 100644 --- a/Server/src/main/java/core/gui/tab/StatisticsTab.java +++ b/Server/src/main/java/core/gui/tab/StatisticsTab.java @@ -21,6 +21,9 @@ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; /** * Handles server info tab. @@ -314,7 +317,7 @@ public class StatisticsTab extends ConsoleTab { * @param file The file to log to. */ protected static void logQueues(File file) { - try (BufferedWriter bw = new BufferedWriter(new FileWriter(file, true))) { + try (BufferedWriter bw = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8, StandardOpenOption.APPEND)) { bw.append("/////////////////////////////////////////////////////////////////////////"); bw.newLine(); bw.append("/////////////////////////////////////////////////////////////////////////"); diff --git a/Server/src/main/java/core/tools/StringUtils.java b/Server/src/main/java/core/tools/StringUtils.java index 8637707b8..b0a941986 100644 --- a/Server/src/main/java/core/tools/StringUtils.java +++ b/Server/src/main/java/core/tools/StringUtils.java @@ -329,16 +329,16 @@ public final class StringUtils { try { i_27_ += i_25_; int i_29_ = 0; - int i_30_ = i_26_ << -2116795453; + int i_30_ = i_26_ << 3; for (; i_27_ > i_25_; i_25_++) { int i_31_ = 0xff & is_28_[i_25_]; int i_32_ = anIntArray233[i_31_]; int i_33_ = aByteArray235[i_31_]; - int i_34_ = i_30_ >> -1445887805; + int i_34_ = i_30_ >> 3; int i_35_ = i_30_ & 0x7; - i_29_ &= (-i_35_ >> 473515839); + i_29_ &= (-i_35_ >> 31); i_30_ += i_33_; - int i_36_ = ((-1 + (i_35_ - -i_33_)) >> -1430991229) + i_34_; + int i_36_ = ((-1 + (i_35_ - -i_33_)) >> 3) + i_34_; i_35_ += 24; is[i_34_] = (byte) (i_29_ = (i_29_ | (i_32_ >>> i_35_))); if ((i_36_ ^ 0xffffffff) < (i_34_ ^ 0xffffffff)) { @@ -362,7 +362,7 @@ public final class StringUtils { } } } - return -i_26_ + ((7 + i_30_) >> -662855293); + return -i_26_ + ((7 + i_30_) >> 3); } catch (RuntimeException runtimeexception) { } return 0; diff --git a/Server/src/main/java/rs09/game/ai/pvp/PVPAIPActions.java b/Server/src/main/java/rs09/game/ai/pvp/PVPAIPActions.java index a2ad48d4f..25b6f6830 100644 --- a/Server/src/main/java/rs09/game/ai/pvp/PVPAIPActions.java +++ b/Server/src/main/java/rs09/game/ai/pvp/PVPAIPActions.java @@ -75,7 +75,7 @@ public class PVPAIPActions { pvp_players.remove(bot); return true; } - if (!pvp_players.contains(target) || !Pathfinder.find(bot, target[0]).isSuccessful() || !canAttack(bot, target[0])) { + if (!pvp_players.contains(target[0]) || !Pathfinder.find(bot, target[0]).isSuccessful() || !canAttack(bot, target[0])) { target[0] = pvp_players.get(RandomFunction.getRandom(pvp_players.size() - 1)); } attackTarget(player, bot, target[0]); diff --git a/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt b/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt index 6f9733d61..10addc699 100644 --- a/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt +++ b/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt @@ -132,6 +132,7 @@ object OfferManager { } } } catch (e: IOException) { + GE_OFFER_LOCK.unlock() SystemLogger.logWarn("Unable to load bot offers. Perhaps it doesn't exist?") } } @@ -216,7 +217,7 @@ object OfferManager { return false } OFFER_MAPPING.remove(offer.uid) - OFFERS_BY_ITEMID[offer.itemID]!!.remove(offer) + OFFERS_BY_ITEMID[offer.itemID]?.remove(offer) GE_OFFER_LOCK.unlock() return true } @@ -227,7 +228,7 @@ object OfferManager { if (!OFFERS_BY_ITEMID.containsKey(offer.itemID)) { OFFERS_BY_ITEMID[offer.itemID] = mutableListOf() } - OFFERS_BY_ITEMID[offer.itemID]!!.add(offer) + OFFERS_BY_ITEMID[offer.itemID]?.add(offer) GE_OFFER_LOCK.unlock() } @@ -326,6 +327,7 @@ object OfferManager { } } catch (e: Exception) { e.printStackTrace() + GE_OFFER_LOCK.unlock() } GE_OFFER_LOCK.unlock() }