Fixed a bunch of potential bugs.
This commit is contained in:
@@ -100,10 +100,6 @@ public class BZip2Decompressor {
|
||||
i1++;
|
||||
j1--;
|
||||
} while (true);
|
||||
if (j1 == 0) {
|
||||
i = 1;
|
||||
break;
|
||||
}
|
||||
abyte0[i1] = byte4;
|
||||
i1++;
|
||||
j1--;
|
||||
|
||||
+3
-1
@@ -140,7 +140,9 @@ public class Definition<T extends Node> {
|
||||
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 + ".";
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -57,10 +57,10 @@ public final class NPCDefinition extends Definition<NPC> {
|
||||
*/
|
||||
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<NPC> {
|
||||
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 + ".");
|
||||
|
||||
@@ -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<Scenery> {
|
||||
* @return The container id.
|
||||
*/
|
||||
public static int getContainerId(int id) {
|
||||
return id >>> 1998118472;
|
||||
return id >>> 8;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -181,7 +181,9 @@ public final class AnimationRoom extends MapZone implements Plugin<Object> {
|
||||
}
|
||||
}
|
||||
}
|
||||
animateArmour(event.getPlayer(), (Scenery) event.getUsedWith(), set);
|
||||
if(set != null) {
|
||||
animateArmour(event.getPlayer(), (Scenery) event.getUsedWith(), set);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ public final class RestlessGhostPlugin extends OptionHandler {
|
||||
switch (option) {
|
||||
case "open":
|
||||
switch (id) {
|
||||
case 2145:
|
||||
default:
|
||||
toggleCoffin(player, object);
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-3
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -55,7 +55,7 @@ public final class MinotaurFamiliarNPC implements Plugin<Object> {
|
||||
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
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-1
@@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -375,7 +375,7 @@ public enum BuildHotspot {
|
||||
/**
|
||||
* The linked hotspots
|
||||
*/
|
||||
private static List<BuildHotspot[]> linkedHotspots = new ArrayList<BuildHotspot[]>();
|
||||
private static final List<BuildHotspot[]> linkedHotspots = new ArrayList<BuildHotspot[]>();
|
||||
|
||||
/**
|
||||
* Configures hotspots.
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
+8
-6
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,9 +68,6 @@ public final class GemCutPulse extends SkillPulse<Item> {
|
||||
|
||||
@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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<ChatMessage> {
|
||||
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.
|
||||
|
||||
@@ -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("/////////////////////////////////////////////////////////////////////////");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user