Removed lots of dead code
This commit is contained in:
@@ -242,6 +242,10 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<useFile>false</useFile>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
<version>2.22.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
+3
-3
@@ -48,7 +48,7 @@ public final class Cache {
|
||||
* @throws Throwable When an exception occurs.
|
||||
*/
|
||||
public static void init(String path) throws Throwable {
|
||||
SystemLogger.logInfo("Initializing cache...");
|
||||
SystemLogger.logInfo(Cache.class, "Initializing cache...");
|
||||
byte[] cacheFileBuffer = new byte[520];
|
||||
RandomAccessFile containersInformFile = new RandomAccessFile(path + File.separator + "main_file_cache.idx255", "r");
|
||||
RandomAccessFile dataFile = new RandomAccessFile(path + File.separator + "main_file_cache.dat2", "r");
|
||||
@@ -61,7 +61,7 @@ public final class Cache {
|
||||
CacheFile cacheFile = new CacheFile(i, new RandomAccessFile(f, "r"), dataFile, 1000000, cacheFileBuffer);
|
||||
cacheFileManagers[i] = new CacheFileManager(cacheFile, true);
|
||||
if (cacheFileManagers[i].getInformation() == null) {
|
||||
SystemLogger.logErr("Error loading cache index " + i + ": no information.");
|
||||
SystemLogger.logErr(Cache.class, "Error loading cache index " + i + ": no information.");
|
||||
cacheFileManagers[i] = null;
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public final class Cache {
|
||||
public static ByteBuffer getArchiveData(int index, int archive, boolean priority, int encryptionValue) {
|
||||
byte[] data = index == 255 ? referenceFile.getContainerData(archive) : cacheFileManagers[index].getCacheFile().getContainerData(archive);
|
||||
if (data == null || data.length < 1) {
|
||||
SystemLogger.logErr("Invalid JS-5 request - " + index + ", " + archive + ", " + priority + ", " + encryptionValue + "!");
|
||||
SystemLogger.logErr(Cache.class, "Invalid JS-5 request - " + index + ", " + archive + ", " + priority + ", " + encryptionValue + "!");
|
||||
return null;
|
||||
}
|
||||
int compression = data[0] & 0xff;
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class DataMap {
|
||||
|
||||
public int getInt(int key){
|
||||
if(!dataStore.containsKey(key)){
|
||||
SystemLogger.logErr("Invalid value passed for key: " + key + " map: " + id);
|
||||
SystemLogger.logErr(this.getClass(), "Invalid value passed for key: " + key + " map: " + id);
|
||||
return -1;
|
||||
}
|
||||
return (int) dataStore.get(key);
|
||||
|
||||
@@ -294,7 +294,7 @@ public class ItemDefinition extends Definition<Item> {
|
||||
}
|
||||
ItemDefinition def = ItemDefinition.parseDefinition(itemId, ByteBuffer.wrap(data));
|
||||
if (def == null) {
|
||||
SystemLogger.logErr("Could not load item definitions for id " + itemId + " - no definitions found!");
|
||||
SystemLogger.logErr(ItemDefinition.class, "Could not load item definitions for id " + itemId + " - no definitions found!");
|
||||
return ;
|
||||
}
|
||||
if(itemId == 14958)
|
||||
@@ -1530,7 +1530,7 @@ public class ItemDefinition extends Definition<Item> {
|
||||
ItemDefinition def = forId(nodeId);
|
||||
if (def == null) {
|
||||
if (nodeId == 22937)
|
||||
SystemLogger.logErr("[ItemDefinition] No definition for item id " + nodeId + "!");
|
||||
SystemLogger.logErr(ItemDefinition.class, "[ItemDefinition] No definition for item id " + nodeId + "!");
|
||||
return null;
|
||||
}
|
||||
OptionHandler handler = def.getConfiguration("option:" + name);
|
||||
|
||||
@@ -72,7 +72,7 @@ public class RenderAnimationDefinition {
|
||||
if (data != null) {
|
||||
defs.parse(ByteBuffer.wrap(data));
|
||||
} else {
|
||||
SystemLogger.logErr("No definitions found for render animation " + animId + ", size=" + Cache.getIndexes()[2].getFilesSize(32) + "!");
|
||||
SystemLogger.logErr(RenderAnimationDefinition.class, "No definitions found for render animation " + animId + ", size=" + Cache.getIndexes()[2].getFilesSize(32) + "!");
|
||||
}
|
||||
return defs;
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ public class SceneryDefinition extends Definition<Scenery> {
|
||||
// SystemLogger.logErr("----------------------------------------------------\n\n\n");
|
||||
while (true) {
|
||||
if (!buffer.hasRemaining()) {
|
||||
SystemLogger.logErr("[ObjectDefinition] Buffer empty for " + objectId);
|
||||
SystemLogger.logErr(SceneryDefinition.class, "Buffer empty for " + objectId);
|
||||
break;
|
||||
}
|
||||
int opcode = buffer.get() & 0xFF;
|
||||
@@ -801,7 +801,7 @@ public class SceneryDefinition extends Definition<Scenery> {
|
||||
}
|
||||
} else {
|
||||
if (opcode != 0) {
|
||||
SystemLogger.logErr("Unhandled object definition opcode: " + opcode);
|
||||
SystemLogger.logErr(SceneryDefinition.class, "Unhandled object definition opcode: " + opcode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class Struct {
|
||||
|
||||
public int getInt(int key){
|
||||
if(!dataStore.containsKey(key)){
|
||||
SystemLogger.logErr("Invalid value passed for key: " + key + " struct: " + id);
|
||||
SystemLogger.logErr(this.getClass(), "Invalid value passed for key: " + key + " struct: " + id);
|
||||
return -1;
|
||||
}
|
||||
return (int) dataStore.get(key);
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
package core.game.component;
|
||||
|
||||
/**
|
||||
* Used to generate component option settings.
|
||||
* @author Mangis
|
||||
*/
|
||||
public final class AccessMaskBuilder {
|
||||
|
||||
/**
|
||||
* Contains the value which should be sent in access mask packet.
|
||||
*/
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* Sets default option setting.
|
||||
* @param allowed If the packet for the default option should be sent to the
|
||||
* server.
|
||||
*/
|
||||
public void allowDefaultOption(boolean allowed) {
|
||||
value &= ~(0x1);
|
||||
if (allowed) {
|
||||
value |= 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets right click option settings. If specified option is not allowed, it
|
||||
* will not appear in right click menu and the packet will not be send to
|
||||
* server when clicked.
|
||||
* @param optionId The option index.
|
||||
* @param show If the option is allowed.
|
||||
*/
|
||||
public void showMenuOption(int optionId, boolean show) {
|
||||
if (optionId < 0 || optionId > 9) {
|
||||
throw new IllegalArgumentException("Option index must be 0-9.");
|
||||
}
|
||||
value &= ~(0x1 << (optionId + 1));
|
||||
if (show) {
|
||||
value |= (0x1 << (optionId + 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets use on option settings. If nothing is allowed then 'use' option will
|
||||
* not appear in right click menu.
|
||||
*/
|
||||
public void setUseOnSettings(boolean groundItems, boolean npcs, boolean objects, boolean otherPlayer, boolean selfPlayer, boolean component) {
|
||||
int useFlag = 0;
|
||||
if (groundItems) {
|
||||
useFlag |= 0x1;
|
||||
}
|
||||
if (npcs) {
|
||||
useFlag |= 0x2;
|
||||
}
|
||||
if (objects) {
|
||||
useFlag |= 0x4;
|
||||
}
|
||||
if (otherPlayer) {
|
||||
useFlag |= 0x8;
|
||||
}
|
||||
if (selfPlayer) {
|
||||
useFlag |= 0x10;
|
||||
}
|
||||
if (component) {
|
||||
useFlag |= 0x20;
|
||||
}
|
||||
value &= ~(127 << 7); // disable
|
||||
value |= useFlag << 7;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets interface events depth. For example, we have inventory interface
|
||||
* which is opened on gameframe interface (548) If depth is 1, then the
|
||||
* clicks in inventory will also invoke click event handler scripts on
|
||||
* gameframe interface.
|
||||
* @param depth The depth value.
|
||||
*/
|
||||
public void setInterfaceEventsDepth(int depth) {
|
||||
if (depth < 0 || depth > 7) {
|
||||
throw new IllegalArgumentException("depth must be 0-7.");
|
||||
}
|
||||
value &= ~(0x7 << 18);
|
||||
value |= (depth << 18);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags other component options being allowed to be used on this component.
|
||||
* @param allow If an option can be used on this component.
|
||||
*/
|
||||
public void allowUsage(boolean allow) {
|
||||
value &= ~(1 << 22);
|
||||
if (allow) {
|
||||
value |= (1 << 22);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value.
|
||||
* @return The value.
|
||||
*/
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
package core.game.container.access;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
|
||||
/**
|
||||
* Contains the mask value methods. The 'access mask' is actually just a bit
|
||||
* register that contains permissions for a specific interface (@Peterbjornx)
|
||||
* @date 5/02/2013
|
||||
* @author Stacx
|
||||
* @author Emperor
|
||||
* @deprecated This is a really bad way of doing what this class needs to do. Please use {@link api.IfaceSettingsBuilder}.
|
||||
*/
|
||||
@Deprecated()
|
||||
public final class BitregisterAssembler {
|
||||
|
||||
/**
|
||||
* The register size.
|
||||
*/
|
||||
public static final int SIZE = 32 - 1;
|
||||
|
||||
/**
|
||||
* Examine option.
|
||||
*/
|
||||
public static final int EXAMINE_OPT = 9;
|
||||
|
||||
/**
|
||||
* Allow dragging.
|
||||
*/
|
||||
public static final int DRAGABLE = 17;
|
||||
|
||||
/**
|
||||
* Allow switching item slots.
|
||||
*/
|
||||
public static final int SLOT_SWITCH = 20;
|
||||
|
||||
/**
|
||||
* The flags.
|
||||
*/
|
||||
private boolean[] permissions = new boolean[SIZE];
|
||||
|
||||
/**
|
||||
* Constructs a new {@code BitregisterAssembler} {@code Object}.
|
||||
* @param permissions The permissions.
|
||||
*/
|
||||
public BitregisterAssembler(int... permissions) {
|
||||
for (int i : permissions) {
|
||||
this.permissions[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code BitregisterAssembler} {@code Object}.
|
||||
*/
|
||||
public BitregisterAssembler(String[] options) {
|
||||
enableOptions(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the given options ({@code null} options will remain disabled).
|
||||
* @param options The options.
|
||||
*/
|
||||
public void enableOptions(String...options) {
|
||||
if (options.length > 9) {
|
||||
throw new IllegalStateException("Too many options specified - maximum 9 allowed!");
|
||||
}
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
if (options[i] != null && !options[i].equals("null")) {
|
||||
permissions[i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the examine option.
|
||||
*/
|
||||
public void enableExamineOption() {
|
||||
permissions[EXAMINE_OPT] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables items being dragged.
|
||||
*/
|
||||
public void enableDragging() {
|
||||
permissions[DRAGABLE] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables item switching slots (& dragging).
|
||||
*/
|
||||
public void enableSlotSwitch() {
|
||||
enableDragging();
|
||||
permissions[SLOT_SWITCH] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>Send</b> and assemble a bit register for our
|
||||
* @param player , the player instance
|
||||
* @param interfaceIndex , the interface index
|
||||
* @param childIndex , the child index for our interface
|
||||
* @param offset , the offset for the loop in client
|
||||
* @param length , the length of our loop
|
||||
*/
|
||||
public static void send(Player player, int interfaceIndex, int childIndex, int offset, int length, BitregisterAssembler assembler) {
|
||||
if (offset >= length) {
|
||||
throw new RuntimeException("Offset cannot excess length. length = " + length);
|
||||
}
|
||||
player.getPacketDispatch().sendIfaceSettings(assembler.calculateRegister(), childIndex, interfaceIndex, offset, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the register.
|
||||
* @return The value.
|
||||
*/
|
||||
public int calculateRegister() {
|
||||
int value = 0;
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
if (permissions[i]) {
|
||||
value |= 2 << i;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package core.game.container.access;
|
||||
|
||||
import api.IfaceSettingsBuilder;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.net.packet.PacketRepository;
|
||||
@@ -37,14 +38,16 @@ public class InterfaceContainer {
|
||||
private static int generate(Player player, Item[] itemArray, String[] options, int interfaceIndex, int childIndex, int x, int y, int key) {
|
||||
Object[] clientScript = new Object[options.length + 7];
|
||||
player.getPacketDispatch().sendRunScript(CLIENT_SCRIPT_INDEX, generateScriptArguments(options.length), populateScript(clientScript, options, interfaceIndex << 16 | childIndex, x, y, key));
|
||||
BitregisterAssembler.send(player, interfaceIndex, childIndex, 0, itemArray.length, new BitregisterAssembler(options));
|
||||
int settings = new IfaceSettingsBuilder().enableAllOptions().build();
|
||||
player.getPacketDispatch().sendIfaceSettings(settings, childIndex, interfaceIndex, 0, itemArray.length);
|
||||
PacketRepository.send(ContainerPacket.class, new ContainerContext(player, -1, -2, key, itemArray, itemArray.length, false));
|
||||
return increment();
|
||||
}
|
||||
|
||||
public static int generateOptions(Player player, String[] options, int interfaceIndex, int childIndex, int x, int y, int key){
|
||||
player.getPacketDispatch().sendRunScript(CLIENT_SCRIPT_INDEX, generateScriptArguments(options.length), populateScript(new Object[options.length + 7],options,interfaceIndex << 16 | childIndex, x, y, key));
|
||||
BitregisterAssembler.send(player,interfaceIndex,childIndex,0,28,new BitregisterAssembler(options));
|
||||
int settings = new IfaceSettingsBuilder().enableAllOptions().build();
|
||||
player.getPacketDispatch().sendIfaceSettings(settings, childIndex, interfaceIndex, 0, 28);
|
||||
return increment();
|
||||
}
|
||||
|
||||
@@ -76,7 +79,8 @@ public class InterfaceContainer {
|
||||
int key = increment();
|
||||
Object[] clientScript = new Object[options.length + 7];
|
||||
player.getPacketDispatch().sendRunScript(CLIENT_SCRIPT_INDEX, generateScriptArguments(options.length), populateScript(clientScript, options, interfaceId << 16 | childId, x, y, key));
|
||||
BitregisterAssembler.send(player, interfaceId, childId, 0, itemLength, new BitregisterAssembler(options));
|
||||
int settings = new IfaceSettingsBuilder().enableAllOptions().build();
|
||||
player.getPacketDispatch().sendIfaceSettings(settings, childId, interfaceId, 0, itemLength);
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -125,7 +129,6 @@ public class InterfaceContainer {
|
||||
/**
|
||||
* Default method to generate and send an item array for the client.
|
||||
* @return The container key.
|
||||
* @see {@link InterfaceContainer.generate}
|
||||
*/
|
||||
public static int generateItems(Player player, Item[] itemArray, String[] options, int interfaceIndex, int childIndex) {
|
||||
return generateItems(player, itemArray, options, interfaceIndex, childIndex, 7, 3, increment());
|
||||
@@ -134,7 +137,6 @@ public class InterfaceContainer {
|
||||
/**
|
||||
* Default method to generate and send an item array for the client.
|
||||
* @return The container key.
|
||||
* @see {@link InterfaceContainer.generate}
|
||||
*/
|
||||
public static int generateItems(Player player, Item[] itemArray, String[] options, int interfaceIndex, int childIndex, int key) {
|
||||
return generateItems(player, itemArray, options, interfaceIndex, childIndex, 7, 3, key);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package core.game.container.impl;
|
||||
|
||||
import api.IfaceSettingsBuilder;
|
||||
import core.game.container.access.InterfaceContainer;
|
||||
import kotlin.ranges.IntRange;
|
||||
import org.rs09.consts.Vars;
|
||||
import rs09.ServerConstants;
|
||||
import core.game.component.Component;
|
||||
import core.game.container.*;
|
||||
import core.game.container.access.BitregisterAssembler;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.IronmanMode;
|
||||
import core.game.node.item.Item;
|
||||
@@ -128,10 +129,8 @@ public final class BankContainer extends Container {
|
||||
player.getInventory().getListeners().add(listener);
|
||||
player.getInventory().refresh();
|
||||
player.varpManager.get(1249).setVarbit(0,lastAmountX).send(player);
|
||||
BitregisterAssembler assembly = new BitregisterAssembler(0, 1, 2, 3, 4, 5);
|
||||
assembly.enableExamineOption();
|
||||
assembly.enableSlotSwitch();
|
||||
player.getPacketDispatch().sendIfaceSettings(assembly.calculateRegister(), 0, 763, 0, 27);
|
||||
int settings = new IfaceSettingsBuilder().enableOptions(new IntRange(0, 5)).enableExamine().enableSlotSwitch().build();
|
||||
player.getPacketDispatch().sendIfaceSettings(settings, 0, 763, 0, 27);
|
||||
player.getPacketDispatch().sendRunScript(1451, "");
|
||||
open = true;
|
||||
setTabConfigurations();
|
||||
@@ -159,10 +158,8 @@ public final class BankContainer extends Container {
|
||||
player.getInventory().refresh();
|
||||
player.varpManager.get(1249).setVarbit(0,lastAmountX).send(player);
|
||||
player.getPacketDispatch().sendIfaceSettings(1278, 73, 762, 0, SIZE);
|
||||
BitregisterAssembler assembly = new BitregisterAssembler(0, 1, 2, 3, 4, 5);
|
||||
assembly.enableExamineOption();
|
||||
assembly.enableSlotSwitch();
|
||||
player.getPacketDispatch().sendIfaceSettings(assembly.calculateRegister(), 0, 763, 0, 27);
|
||||
int settings = new IfaceSettingsBuilder().enableOptions(new IntRange(0,5)).enableExamine().enableSlotSwitch().build();
|
||||
player.getPacketDispatch().sendIfaceSettings(settings, 0, 763, 0, 27);
|
||||
player.getPacketDispatch().sendRunScript(1451, "");
|
||||
open = true;
|
||||
this.player.getBank().setTabConfigurations(player);
|
||||
|
||||
@@ -50,7 +50,7 @@ public final class ActivityManager {
|
||||
ActivityPlugin plugin = ACTIVITIES.get(name);
|
||||
if (plugin == null) {
|
||||
if (GameWorld.getSettings().isDevMode()) {
|
||||
SystemLogger.logErr("Unhandled activity - " + name + "!");
|
||||
SystemLogger.logErr(ActivityManager.class, "Unhandled activity - " + name + "!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ public final class GodwarsMapzone extends MapZone implements Plugin<Object> {
|
||||
}
|
||||
|
||||
if (DoorActionHandler.handleAutowalkDoor(player, object)) {
|
||||
SystemLogger.logInfo(player.getUsername() + " entered " + faction.name() + " gwd boss room");
|
||||
SystemLogger.logInfo(this.getClass(), player.getUsername() + " entered " + faction.name() + " gwd boss room");
|
||||
increaseKillcount(player, faction, -required);
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ public class GuardDialoguePlugin extends DialoguePlugin {
|
||||
stage = -1;
|
||||
break;
|
||||
default:
|
||||
SystemLogger.logErr("Unhandled dialogue stage=" + stage);
|
||||
SystemLogger.logErr(this.getClass(), "Unhandled dialogue stage=" + stage);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public abstract class DialoguePlugin implements Plugin<Player> {
|
||||
}
|
||||
|
||||
if (npc == null) {
|
||||
SystemLogger.logWarn(
|
||||
SystemLogger.logWarn(this.getClass(),
|
||||
args[0].getClass().getSimpleName() +
|
||||
"Is not assigning an NPC. Whoever did that should fix it."
|
||||
);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package core.game.content.global.action;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.system.communication.CommunicationInfo;
|
||||
import rs09.game.interaction.SpadeDigListener;
|
||||
import rs09.game.system.SystemLogger;
|
||||
import core.game.system.task.Pulse;
|
||||
@@ -62,7 +63,7 @@ public final class DigSpadeHandler {
|
||||
*/
|
||||
public static boolean register(Location location, DigAction action) {
|
||||
if (ACTIONS.containsKey(location)) {
|
||||
SystemLogger.logErr("Already contained dig reward for location " + location + ".");
|
||||
SystemLogger.logErr(CommunicationInfo.class, "Already contained dig reward for location " + location + ".");
|
||||
return false;
|
||||
}
|
||||
ACTIONS.put(location, action);
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class DropItemHandler {
|
||||
return false;
|
||||
}
|
||||
if (player.getAttribute("equipLock:" + item.getId(), 0) > GameWorld.getTicks()) {
|
||||
SystemLogger.logAlert(player + ", tried to do the drop & equip dupe.");
|
||||
SystemLogger.logAlert(DropItemHandler.class, player + ", tried to do the drop & equip dupe.");
|
||||
return true;
|
||||
}
|
||||
if (player.getInventory().replace(null, item.getSlot()) == item) {
|
||||
|
||||
@@ -119,7 +119,7 @@ public abstract class HolidayEvent extends MapZone implements Plugin<Object> {
|
||||
if (isActive()) {
|
||||
setCurrent(this);
|
||||
ZoneBuilder.configure(this);
|
||||
SystemLogger.logInfo("Holiday event active [type=" + type + "]!");
|
||||
SystemLogger.logInfo(this.getClass(), "Holiday event active [type=" + type + "]!");
|
||||
}
|
||||
EVENTS.add(this);
|
||||
return this;
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
package core.game.content.quest.free.therestlessghost;
|
||||
|
||||
import core.game.component.Component;
|
||||
import core.game.container.access.BitregisterAssembler;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
import core.plugin.Initializable;
|
||||
|
||||
+1
-1
@@ -289,7 +289,7 @@ public class DwarfCannonPlugin extends OptionHandler {
|
||||
}
|
||||
Part part = Part.forId(button);
|
||||
if (part == null) {
|
||||
SystemLogger.logErr("Unhandled part id - " + button + "!");
|
||||
SystemLogger.logErr(this.getClass(), "Unhandled part id - " + button + "!");
|
||||
return true;
|
||||
}
|
||||
if (this.tool.getPart() != part) {
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class ClueScrollPlugin extends MapZone implements Plugin<Object>
|
||||
if(clue.getClueId() == 2681)
|
||||
return;
|
||||
if (CLUE_SCROLLS.containsKey(clue.getClueId())) {
|
||||
SystemLogger.logErr("Error! Plugin already registered with clue id - " + clue.getClueId() + ", trying to register " + clue.getClass().getCanonicalName() + " the real plugin using the id is " + CLUE_SCROLLS.get(clue.getClueId()).getClass().getCanonicalName() + "!");
|
||||
SystemLogger.logErr(this.getClass(), "Error! Plugin already registered with clue id - " + clue.getClueId() + ", trying to register " + clue.getClass().getCanonicalName() + " the real plugin using the id is " + CLUE_SCROLLS.get(clue.getClueId()).getClass().getCanonicalName() + "!");
|
||||
return;
|
||||
}
|
||||
List<ClueScrollPlugin> organized = (List<ClueScrollPlugin>) ORGANIZED.get(clue.getLevel());
|
||||
@@ -169,7 +169,7 @@ public abstract class ClueScrollPlugin extends MapZone implements Plugin<Object>
|
||||
public static Item getClue(ClueLevel clueLevel) {
|
||||
List<ClueScrollPlugin> clues = ORGANIZED.get(clueLevel);
|
||||
if (clues == null) {
|
||||
SystemLogger.logErr("Error! There are no clues for level " + clueLevel + "!");
|
||||
SystemLogger.logErr(ClueScrollPlugin.class, "Error! There are no clues for level " + clueLevel + "!");
|
||||
return null;
|
||||
}
|
||||
ClueScrollPlugin clue = clues.get(RandomFunction.random(clues.size()));
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
package core.game.ge;
|
||||
|
||||
import core.cache.def.impl.ItemDefinition;
|
||||
import rs09.game.system.config.ItemConfigParser;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Handles the buying limitations.
|
||||
* @author Emperor
|
||||
*/
|
||||
public final class BuyingLimitation {
|
||||
|
||||
/**
|
||||
* Mapping holding buying amounts per player for every item id.
|
||||
*/
|
||||
private static final Map<Integer, Map<Integer, Integer>> CACHE = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructs a new {@code BuyingLimitation} {@code Object}.
|
||||
*/
|
||||
private BuyingLimitation() {
|
||||
/*
|
||||
* empty.
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum amount the player can buy of this item.
|
||||
* @param itemId The item id.
|
||||
* @param playerUID The player UID.
|
||||
* @return The maximum amount to buy.
|
||||
*/
|
||||
public static int getMaximumBuy(int itemId, int playerUID) {
|
||||
Map<Integer, Integer> data = CACHE.get(itemId);
|
||||
Integer current = 0;
|
||||
if (data != null) {
|
||||
current = data.get(playerUID);
|
||||
}
|
||||
if (current == null) {
|
||||
current = 0;
|
||||
}
|
||||
return ItemDefinition.forId(itemId).getConfiguration(ItemConfigParser.GE_LIMIT, 25000) - current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the currently bought amount.
|
||||
* @param itemId The item id.
|
||||
* @param playerUID The player UID.
|
||||
* @param amount The amount.
|
||||
*/
|
||||
public static void updateBoughtAmount(int itemId, int playerUID, int amount) {
|
||||
Map<Integer, Integer> data = CACHE.get(itemId);
|
||||
if (data == null) {
|
||||
CACHE.put(itemId, data = new HashMap<>());
|
||||
}
|
||||
Integer current = data.get(playerUID);
|
||||
if (current == null) {
|
||||
current = 0;
|
||||
}
|
||||
current += amount;
|
||||
data.put(playerUID, current);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the offer is limited.
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
public static boolean isLimited(int itemId, int playerUID) {
|
||||
Map<Integer, Integer> data = CACHE.get(itemId);
|
||||
if (data == null) {
|
||||
return false;
|
||||
}
|
||||
Integer current = data.get(playerUID);
|
||||
if (current == null) {
|
||||
return false;
|
||||
}
|
||||
int max = ItemDefinition.forId(itemId).getConfiguration(ItemConfigParser.GE_LIMIT, 25000);
|
||||
return current >= max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the cached data.
|
||||
*/
|
||||
public static void clear() {
|
||||
CACHE.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
package core.game.ge;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents a grand exchange entry, which contains the item id, current price
|
||||
* and previous prices.
|
||||
* @author Emperor
|
||||
*/
|
||||
public final class GrandExchangeEntry {
|
||||
|
||||
/**
|
||||
* The item id.
|
||||
*/
|
||||
private final int itemId;
|
||||
|
||||
/**
|
||||
* The item value.
|
||||
*/
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* The value log.
|
||||
*/
|
||||
private int[] valueLog = new int[256];
|
||||
|
||||
/**
|
||||
* The log length.
|
||||
*/
|
||||
private int logLength;
|
||||
|
||||
/**
|
||||
* The amount of unique trades completed.
|
||||
*/
|
||||
private int uniqueTrades;
|
||||
|
||||
/**
|
||||
* The total value amount of each the unique trades. <br> This is used to
|
||||
* calculate the average price, so we know whether or not to update price.
|
||||
*/
|
||||
private long totalValue;
|
||||
|
||||
/**
|
||||
* The last update time stamp.
|
||||
*/
|
||||
private long lastUpdate;
|
||||
|
||||
/**
|
||||
* The mapping of completed buying offers.
|
||||
*/
|
||||
private Map<Integer, Integer> boughtMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructs a new {@code GrandExchangeEntry} {@code Object}.
|
||||
* @param itemId The item id.
|
||||
*/
|
||||
public GrandExchangeEntry(int itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the item value.
|
||||
* @param value The new item value to set.
|
||||
*/
|
||||
public void updateValue(int value) {
|
||||
int[] newValueLog = new int[256];
|
||||
System.arraycopy(valueLog, 0, newValueLog, 1, logLength);
|
||||
newValueLog[0] = this.value;
|
||||
this.valueLog = newValueLog;
|
||||
this.value = value;
|
||||
this.uniqueTrades = 0;
|
||||
this.totalValue = 0;
|
||||
if (++logLength > 255) {
|
||||
logLength = 255;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Influences the price of this item.
|
||||
* @param value The value offered in the exchange.
|
||||
*/
|
||||
public void influenceValue(int value) {
|
||||
if (value < this.value * 0.5) { // Makes sure the player can't influence
|
||||
// too much
|
||||
value = (int) (this.value * 0.5);
|
||||
} else if (value > this.value * 1.5) {
|
||||
value = (int) (this.value * 1.5);
|
||||
}
|
||||
uniqueTrades++;
|
||||
totalValue += value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the itemId.
|
||||
* @return The itemId.
|
||||
*/
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value.
|
||||
* @return The value.
|
||||
*/
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the valueLog.
|
||||
* @return The valueLog.
|
||||
*/
|
||||
public int[] getValueLog() {
|
||||
return valueLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the valueLog.
|
||||
* @param valueLog The valueLog to set.
|
||||
*/
|
||||
public void setValueLog(int[] valueLog) {
|
||||
this.valueLog = valueLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the uniqueTrades.
|
||||
* @return The uniqueTrades.
|
||||
*/
|
||||
public int getUniqueTrades() {
|
||||
return uniqueTrades;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the uniqueTrades.
|
||||
* @param uniqueTrades The uniqueTrades to set.
|
||||
*/
|
||||
public void setUniqueTrades(int uniqueTrades) {
|
||||
this.uniqueTrades = uniqueTrades;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the totalValue.
|
||||
* @return The totalValue.
|
||||
*/
|
||||
public long getTotalValue() {
|
||||
return totalValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the totalValue.
|
||||
* @param totalValue The totalValue to set.
|
||||
*/
|
||||
public void setTotalValue(long totalValue) {
|
||||
this.totalValue = totalValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lastUpdate.
|
||||
* @return The lastUpdate.
|
||||
*/
|
||||
public long getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the lastUpdate.
|
||||
* @param lastUpdate The lastUpdate to set.
|
||||
*/
|
||||
public void setLastUpdate(long lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the logLength.
|
||||
* @return The logLength.
|
||||
*/
|
||||
public int getLogLength() {
|
||||
return logLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logLength.
|
||||
* @param logLength The logLength to set.
|
||||
*/
|
||||
public void setLogLength(int logLength) {
|
||||
this.logLength = logLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boughtMap.
|
||||
* @return The boughtMap.
|
||||
*/
|
||||
public Map<Integer, Integer> getBoughtMap() {
|
||||
return boughtMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the boughtMap.
|
||||
* @param boughtMap The boughtMap to set.
|
||||
*/
|
||||
public void setBoughtMap(Map<Integer, Integer> boughtMap) {
|
||||
this.boughtMap = boughtMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GrandExchangeEntry [itemId=" + itemId + ", value=" + value + ", valueLog=" + Arrays.toString(valueLog) + ", logLength=" + logLength + ", uniqueTrades=" + uniqueTrades + ", totalValue=" + totalValue + ", lastUpdate=" + lastUpdate + ", boughtMap=" + boughtMap + "]";
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import core.game.world.update.flag.player.FaceLocationFlag;
|
||||
import core.net.packet.PacketRepository;
|
||||
import core.net.packet.context.InteractionOptionContext;
|
||||
import core.net.packet.out.InteractionOption;
|
||||
import rs09.game.interaction.IntType;
|
||||
import rs09.game.interaction.InteractionListeners;
|
||||
import rs09.game.system.SystemLogger;
|
||||
import rs09.game.world.GameWorld;
|
||||
@@ -86,7 +87,7 @@ public class Interaction {
|
||||
player.dispatch(new InteractionEvent(node, option.getName().toLowerCase()));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
SystemLogger.logErr(this.getClass().getName() + e.getMessage());
|
||||
SystemLogger.logErr(this.getClass(), this.getClass().getName() + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ public class Interaction {
|
||||
if (player.getLocks().isInteractionLocked() || player.getZoneMonitor().interact(node, option)) {
|
||||
return true;
|
||||
}
|
||||
if(InteractionListeners.run(node.getId(),0,option.getName(),player,node)){
|
||||
if(InteractionListeners.run(node.getId(), IntType.ITEM, option.getName(),player,node)){
|
||||
return true;
|
||||
}
|
||||
if (option.getHandler() == null || !option.getHandler().handle(player, node, option.getName().toLowerCase())) {
|
||||
@@ -119,7 +120,7 @@ public class Interaction {
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
SystemLogger.logErr(this.getClass().getName() + e.getMessage());
|
||||
SystemLogger.logErr(this.getClass(), this.getClass().getName() + e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -150,7 +151,7 @@ public class Interaction {
|
||||
player.getPacketDispatch().sendMessage("Nothing interesting happens.");
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
SystemLogger.logErr(this.getClass().getName() + e.getMessage());
|
||||
SystemLogger.logErr(this.getClass(), this.getClass().getName() + e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -188,7 +189,7 @@ public class Interaction {
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
SystemLogger.logErr(this.getClass().getName() + e.getMessage());
|
||||
SystemLogger.logErr(this.getClass(), this.getClass().getName() + e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -233,9 +233,9 @@ public abstract class MovementPulse extends Pulse {
|
||||
return;
|
||||
}
|
||||
if(destination.getLocation() == null){
|
||||
SystemLogger.logAlert(destination.getId() + " < ID");
|
||||
SystemLogger.logAlert(destination.getName() + " < NAME");
|
||||
SystemLogger.logAlert("ASDAD");
|
||||
SystemLogger.logAlert(this.getClass(), destination.getId() + " < ID");
|
||||
SystemLogger.logAlert(this.getClass(), destination.getName() + " < NAME");
|
||||
SystemLogger.logAlert(this.getClass(), "ASDAD");
|
||||
return;
|
||||
}
|
||||
boolean inside = isInsideEntity(mover.getLocation());
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class OptionHandler implements Plugin<Object> {
|
||||
final SceneryDefinition definition = SceneryDefinition.forId(wrapper);
|
||||
final List<Integer> list = new ArrayList<>(20);
|
||||
if (definition.getChildrenIds() == null) {
|
||||
SystemLogger.logErr("Null child wrapper in option handler wrapperId=" + wrapper);
|
||||
SystemLogger.logErr(this.getClass(), "Null child wrapper in option handler wrapperId=" + wrapper);
|
||||
return new int[] { wrapper };
|
||||
}
|
||||
for (int child : definition.getChildrenIds()) {
|
||||
|
||||
@@ -210,7 +210,7 @@ public abstract class UseWithHandler implements Plugin<Object> {
|
||||
final SceneryDefinition definition = SceneryDefinition.forId(wrapper);
|
||||
final List<Integer> list = new ArrayList<>(20);
|
||||
if (definition.getChildrenIds() == null) {
|
||||
SystemLogger.logErr("Null child wrapper in option handler wrapperId=" + wrapper);
|
||||
SystemLogger.logErr(this.getClass(), "Null child wrapper in option handler wrapperId=" + wrapper);
|
||||
return new int[]{wrapper};
|
||||
}
|
||||
for (int child : definition.getChildrenIds()) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import core.game.component.ComponentPlugin;
|
||||
import core.game.container.Container;
|
||||
import core.game.container.ContainerEvent;
|
||||
import core.game.container.ContainerListener;
|
||||
import core.game.container.access.BitregisterAssembler;
|
||||
import core.game.container.access.InterfaceContainer;
|
||||
import core.game.container.impl.EquipmentContainer;
|
||||
import core.game.interaction.OptionHandler;
|
||||
@@ -22,6 +21,7 @@ import core.net.packet.out.ContainerPacket;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
import rs09.game.content.global.action.EquipHandler;
|
||||
import rs09.game.interaction.IntType;
|
||||
import rs09.game.interaction.InteractionListeners;
|
||||
import rs09.game.world.GameWorld;
|
||||
|
||||
@@ -82,7 +82,7 @@ public final class EquipmentInterface extends ComponentPlugin {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
if (item == null) return true;
|
||||
InteractionListeners.run(item.getId(),0,"equip",p, item);
|
||||
InteractionListeners.run(item.getId(), IntType.ITEM,"equip",p, item);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -164,10 +164,6 @@ public final class EquipmentInterface extends ComponentPlugin {
|
||||
EquipmentContainer.update(p);
|
||||
p.getInterfaceManager().openSingleTab(new Component(670));
|
||||
InterfaceContainer.generateItems(p, p.getInventory().toArray(), new String[] { "Equip" }, 670, 0, 7, 4, 93);
|
||||
BitregisterAssembler assembly = new BitregisterAssembler(new String[] { "Equip" });
|
||||
assembly.enableExamineOption();
|
||||
assembly.enableSlotSwitch();
|
||||
p.getPacketDispatch().sendIfaceSettings(assembly.calculateRegister(), 0, 670, 0, 27);
|
||||
p.getInventory().getListeners().add(listener);
|
||||
p.getInventory().refresh();
|
||||
ItemDefinition.statsUpdate(p);
|
||||
@@ -192,7 +188,7 @@ public final class EquipmentInterface extends ComponentPlugin {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
if(InteractionListeners.run(item.getId(),0,"operate",player,item)){
|
||||
if(InteractionListeners.run(item.getId(),IntType.ITEM,"operate",player,item)){
|
||||
return;
|
||||
}
|
||||
OptionHandler handler = item.getOperateHandler();
|
||||
|
||||
@@ -31,7 +31,7 @@ public final class WorldMapInterface extends ComponentPlugin {
|
||||
player.updateSceneGraph(true);
|
||||
return true;
|
||||
default:
|
||||
//SystemLogger.logErr("World map: buttonid: " + button + ", opcode: " + opcode + ", slot: " + slot);
|
||||
//SystemLogger.logErr(this.getClass(), "World map: buttonid: " + button + ", opcode: " + opcode + ", slot: " + slot);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,19 @@
|
||||
package core.game.interaction.item
|
||||
|
||||
import api.*
|
||||
import core.Util
|
||||
import core.cache.def.impl.ItemDefinition
|
||||
import core.plugin.Initializable
|
||||
import core.game.interaction.OptionHandler
|
||||
import core.plugin.Plugin
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.game.interaction.item.ExplorersRingPlugin
|
||||
import core.game.node.Node
|
||||
import api.hasLevelStat
|
||||
import api.sendMessage
|
||||
import api.teleport
|
||||
import api.visualize
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.TeleportManager.TeleportType
|
||||
import core.game.node.entity.skill.Skills
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import org.json.simple.JSONObject
|
||||
import org.rs09.consts.Items
|
||||
import rs09.ServerStore
|
||||
import rs09.ServerStore.Companion.getBoolean
|
||||
import rs09.ServerStore.Companion.getInt
|
||||
import rs09.game.interaction.IntType
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
/**
|
||||
@@ -33,7 +28,7 @@ class ExplorersRingPlugin : InteractionListener {
|
||||
|
||||
|
||||
override fun defineListeners() {
|
||||
on(RINGS, ITEM, "run-replenish"){player, node ->
|
||||
on(RINGS, IntType.ITEM, "run-replenish"){player, node ->
|
||||
val charges = getStoreFile().getInt(player.username.toLowerCase() + ":run")
|
||||
if (charges >= getRingLevel(node.id)) {
|
||||
sendMessage(player,"You have used all the charges you can for one day.")
|
||||
@@ -49,7 +44,7 @@ class ExplorersRingPlugin : InteractionListener {
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(RINGS, ITEM, "low-alchemy"){player, _ ->
|
||||
on(RINGS, IntType.ITEM, "low-alchemy"){player, _ ->
|
||||
if (!hasLevelStat(player, Skills.MAGIC, 21)) {
|
||||
sendMessage(player,"You need a Magic level of 21 in order to do that.")
|
||||
return@on true
|
||||
@@ -65,12 +60,12 @@ class ExplorersRingPlugin : InteractionListener {
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(RINGS, ITEM, "cabbage-port"){player, node ->
|
||||
on(RINGS, IntType.ITEM, "cabbage-port"){player, node ->
|
||||
teleport(player)
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(RINGS, ITEM, "operate", "rub"){player, node ->
|
||||
on(RINGS, IntType.ITEM, "operate", "rub"){player, node ->
|
||||
if(getRingLevel(node.id) < 3){
|
||||
sendMessage(player, "This item can not be operated.")
|
||||
return@on true
|
||||
|
||||
@@ -5,6 +5,7 @@ import api.openBankAccount
|
||||
import core.game.content.global.shop.CulinomancerShop
|
||||
import org.rs09.consts.Scenery
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.IntType
|
||||
|
||||
/**
|
||||
* Handles the culino chest options.
|
||||
@@ -16,12 +17,12 @@ class CulinoChestListener : InteractionListener {
|
||||
}
|
||||
|
||||
override fun defineListeners() {
|
||||
on(CULINO_CHEST, SCENERY, "buy-items", "buy-food"){player, _ ->
|
||||
on(CULINO_CHEST, IntType.SCENERY, "buy-items", "buy-food"){player, _ ->
|
||||
CulinomancerShop.openShop(player, food = getUsedOption(player).lowercase() == "buy-food")
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(CULINO_CHEST, SCENERY, "bank"){player, _ ->
|
||||
on(CULINO_CHEST, IntType.SCENERY, "bank"){player, _ ->
|
||||
openBankAccount(player)
|
||||
return@on true
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import core.net.packet.context.MinimapStateContext
|
||||
import core.net.packet.out.MinimapState
|
||||
import core.tools.RandomFunction
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.IntType
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.plugin.ClassScanner
|
||||
|
||||
@@ -39,7 +40,7 @@ class GardenObjectsPlugin : InteractionListener {
|
||||
SqirkMakingDialogue().init()
|
||||
ClassScanner.definePlugin(SorceressGardenObject())
|
||||
|
||||
on(SQIRK_TREES, SCENERY, "pick-fruit"){player, node ->
|
||||
on(SQIRK_TREES, IntType.SCENERY, "pick-fruit"){player, node ->
|
||||
val def = SeasonDefinitions.forTreeId(node.id)
|
||||
if (def != null) {
|
||||
player.lock()
|
||||
@@ -73,7 +74,7 @@ class GardenObjectsPlugin : InteractionListener {
|
||||
}
|
||||
|
||||
|
||||
on(FOUNTAIN, SCENERY, "drink-from"){player, _ ->
|
||||
on(FOUNTAIN, IntType.SCENERY, "drink-from"){player, _ ->
|
||||
player.lock()
|
||||
GameWorld.Pulser.submit(object : Pulse(1, player) {
|
||||
var counter = 0
|
||||
@@ -101,7 +102,7 @@ class GardenObjectsPlugin : InteractionListener {
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(SHELVES, SCENERY, "search"){player, node ->
|
||||
on(SHELVES, IntType.SCENERY, "search"){player, node ->
|
||||
if (player.inventory.freeSlots() < 1) {
|
||||
player.sendMessage("You don't have enough space in your inventory to take a beer glass.")
|
||||
} else {
|
||||
@@ -112,7 +113,7 @@ class GardenObjectsPlugin : InteractionListener {
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(HERBS, SCENERY, "pick"){player, node ->
|
||||
on(HERBS, IntType.SCENERY, "pick"){player, node ->
|
||||
val herbDef = HerbDefinition.forId(node.getId())
|
||||
if (herbDef != null) {
|
||||
handleElementalGarden(player, node.asScenery(), herbDef)
|
||||
|
||||
@@ -63,7 +63,7 @@ public abstract class AbstractNPC extends NPC implements Plugin<Object> {
|
||||
if (mapping.containsKey(id)) {
|
||||
String name = mapping.get(id).getClass().getSimpleName();
|
||||
if (name != getClass().getSimpleName()) {
|
||||
SystemLogger.logErr("[" + getClass().getSimpleName() + "] - Warning: Mapping already contained NPC id " + id + "! (" + name + ")");
|
||||
SystemLogger.logErr(this.getClass(), "[" + getClass().getSimpleName() + "] - Warning: Mapping already contained NPC id " + id + "! (" + name + ")");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,11 +57,11 @@ public final class CELEMinorTable implements StartupListener {
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.CELEDT_DATA_PATH != null && !new File(ServerConstants.CELEDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr("Can't locate CELEDT file at " + ServerConstants.CELEDT_DATA_PATH);
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate CELEDT file at " + ServerConstants.CELEDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.CELEDT_DATA_PATH);
|
||||
logInfo("Loaded up Chaos Elemental drop table from " + ServerConstants.CELEDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Loaded up Chaos Elemental drop table from " + ServerConstants.CELEDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,11 +57,11 @@ public final class RareDropTable implements StartupListener {
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.RDT_DATA_PATH != null && !new File(ServerConstants.RDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr("Can't locate RDT file at " + ServerConstants.RDT_DATA_PATH);
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate RDT file at " + ServerConstants.RDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.RDT_DATA_PATH);
|
||||
logInfo("Initialized Rare Drop Table from " + ServerConstants.RDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Initialized Rare Drop Table from " + ServerConstants.RDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -341,7 +341,7 @@ public class Player extends Entity {
|
||||
@Override
|
||||
public void init() {
|
||||
if(!artificial)
|
||||
SystemLogger.logInfo(getUsername() + " initialising...");
|
||||
SystemLogger.logInfo(this.getClass(), getUsername() + " initialising...");
|
||||
if (!artificial) {
|
||||
getProperties().setSpawnLocation(ServerConstants.HOME_LOCATION);
|
||||
getDetails().getSession().setObject(this);
|
||||
|
||||
+2
-2
@@ -210,7 +210,7 @@ public final class LoginConfiguration {
|
||||
*/
|
||||
public static final void config(final Player player) {
|
||||
if(!player.isArtificial())
|
||||
SystemLogger.logInfo("configuring player " + player.getUsername());
|
||||
SystemLogger.logInfo(LoginConfiguration.class, "configuring player " + player.getUsername());
|
||||
player.getInventory().refresh();
|
||||
player.getEquipment().refresh();
|
||||
player.getSkills().refresh();
|
||||
@@ -227,7 +227,7 @@ public final class LoginConfiguration {
|
||||
player.getEmoteManager().refresh();
|
||||
player.getInterfaceManager().openInfoBars();
|
||||
if(!player.isArtificial())
|
||||
SystemLogger.logInfo("finished configuring player " + player.getUsername());
|
||||
SystemLogger.logInfo(LoginConfiguration.class, "finished configuring player " + player.getUsername());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class PlayerParser {
|
||||
assert os != null;
|
||||
os.close();
|
||||
} catch (Exception f){
|
||||
SystemLogger.logWarn("Unable to close file copiers in PlayerParser.java line 216.");
|
||||
SystemLogger.logWarn(PlayerParser.class, "Unable to close file copiers in PlayerParser.java line 216.");
|
||||
f.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public final class InterfaceManager {
|
||||
public Component openWindowsPane(Component windowsPane, boolean overlap) {
|
||||
this.windowsPane = windowsPane;
|
||||
if (windowsPane.getDefinition().getType() != InterfaceType.WINDOW_PANE) {
|
||||
SystemLogger.logErr("Set interface type to WINDOW_PANE for component " + windowsPane.getId() + ", definition requires updating!");
|
||||
SystemLogger.logErr(this.getClass(), "Set interface type to WINDOW_PANE for component " + windowsPane.getId() + ", definition requires updating!");
|
||||
windowsPane.getDefinition().setType(InterfaceType.WINDOW_PANE);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public final class InterfaceManager {
|
||||
public void openWindowsPane(Component windowsPane, int type) {
|
||||
this.windowsPane = windowsPane;
|
||||
if (windowsPane.getDefinition().getType() != InterfaceType.WINDOW_PANE) {
|
||||
SystemLogger.logErr("Set interface type to WINDOW_PANE for component " + windowsPane.getId() + ", definition requires updating!");
|
||||
SystemLogger.logErr(this.getClass(), "Set interface type to WINDOW_PANE for component " + windowsPane.getId() + ", definition requires updating!");
|
||||
windowsPane.getDefinition().setType(InterfaceType.SINGLE_TAB);
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ public final class InterfaceManager {
|
||||
*/
|
||||
public Component openSingleTab(Component component) {
|
||||
if (component.getDefinition().getType() != InterfaceType.SINGLE_TAB) {
|
||||
SystemLogger.logErr("Set interface type to SINGLE_TAB for component " + component.getId() + ", definition requires updating!");
|
||||
SystemLogger.logErr(this.getClass(), "Set interface type to SINGLE_TAB for component " + component.getId() + ", definition requires updating!");
|
||||
component.getDefinition().setType(InterfaceType.SINGLE_TAB);
|
||||
}
|
||||
component.open(player);
|
||||
@@ -453,11 +453,11 @@ public final class InterfaceManager {
|
||||
throw new IllegalStateException("Attack tab can only be instanced as " + WeaponInterface.class.getCanonicalName() + "!");
|
||||
}
|
||||
if (component.getDefinition().getTabIndex() != slot) {
|
||||
SystemLogger.logErr("Set tab index to " + slot + " for component " + component.getId() + ", definition requires updating!");
|
||||
SystemLogger.logErr(this.getClass(), "Set tab index to " + slot + " for component " + component.getId() + ", definition requires updating!");
|
||||
component.getDefinition().setTabIndex(slot);
|
||||
}
|
||||
if (component.getDefinition().getType() != InterfaceType.TAB) {
|
||||
SystemLogger.logErr("Set interface type to TAB for component " + component.getId() + ", definition requires updating!");
|
||||
SystemLogger.logErr(this.getClass(), "Set interface type to TAB for component " + component.getId() + ", definition requires updating!");
|
||||
component.getDefinition().setType(InterfaceType.TAB);
|
||||
}
|
||||
component.open(player);
|
||||
@@ -470,7 +470,7 @@ public final class InterfaceManager {
|
||||
*/
|
||||
public void openTab(Component component) {
|
||||
if (component.getDefinition().getTabIndex() < 0) {
|
||||
SystemLogger.logErr("No component definitions found for tab " + component.getId() + "!");
|
||||
SystemLogger.logErr(this.getClass(), "No component definitions found for tab " + component.getId() + "!");
|
||||
return;
|
||||
}
|
||||
openTab(component.getDefinition().getTabIndex(), component);
|
||||
@@ -500,7 +500,7 @@ public final class InterfaceManager {
|
||||
} else {
|
||||
chatbox = component;
|
||||
if (chatbox.getDefinition().getType() != InterfaceType.DIALOGUE && chatbox.getDefinition().getType() != InterfaceType.CHATBOX && chatbox.getDefinition().getType() != InterfaceType.CS_CHATBOX) {
|
||||
SystemLogger.logErr("Set interface type to CHATBOX for component " + component.getId() + ", definition requires updating!");
|
||||
SystemLogger.logErr(this.getClass(), "Set interface type to CHATBOX for component " + component.getId() + ", definition requires updating!");
|
||||
chatbox.getDefinition().setType(InterfaceType.DIALOGUE);
|
||||
}
|
||||
chatbox.open(player);
|
||||
@@ -606,7 +606,7 @@ public final class InterfaceManager {
|
||||
}
|
||||
overlay = component;
|
||||
if (overlay.getDefinition().getType() != InterfaceType.OVERLAY) {
|
||||
SystemLogger.logErr("Set interface type to OVERLAY for component " + component.getId() + ", definition requires updating!");
|
||||
SystemLogger.logErr(this.getClass(), "Set interface type to OVERLAY for component " + component.getId() + ", definition requires updating!");
|
||||
overlay.getDefinition().setType(InterfaceType.OVERLAY);
|
||||
overlay.getDefinition().setWalkable(true);
|
||||
}
|
||||
@@ -623,7 +623,7 @@ public final class InterfaceManager {
|
||||
}
|
||||
wildyOverlay = component;
|
||||
if (wildyOverlay.getDefinition().getType() != InterfaceType.WILDERNESS_OVERLAY) {
|
||||
SystemLogger.logErr("Set interface type to WILDERNESS_OVERLAY for component " + component.getId() + ", definition requires updating!");
|
||||
SystemLogger.logErr(this.getClass(), "Set interface type to WILDERNESS_OVERLAY for component " + component.getId() + ", definition requires updating!");
|
||||
wildyOverlay.getDefinition().setType(InterfaceType.WILDERNESS_OVERLAY);
|
||||
wildyOverlay.getDefinition().setWalkable(true);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public final class PacketDispatch {
|
||||
return;
|
||||
}
|
||||
if (message.length() > 255) {
|
||||
SystemLogger.logErr("Message length out of bounds (" + message + ")!");
|
||||
SystemLogger.logErr(this.getClass(), "Message length out of bounds (" + message + ")!");
|
||||
message = message.substring(0, 255);
|
||||
}
|
||||
PacketRepository.send(GameMessage.class, new GameMessageContext(player, message));
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class QuestRepository {
|
||||
if(oldStage < stage) {
|
||||
quests.put(quest.getIndex(), stage);
|
||||
} else {
|
||||
SystemLogger.logWarn(String.format("Nonmonotonic QuestRepository.setStage call for player \"%s\", quest \"%s\", old stage %d, new stage %d", player.getName(), quest.getName(), oldStage, stage));
|
||||
SystemLogger.logWarn(this.getClass(), String.format("Nonmonotonic QuestRepository.setStage call for player \"%s\", quest \"%s\", old stage %d, new stage %d", player.getName(), quest.getName(), oldStage, stage));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public final class QuestRepository {
|
||||
public boolean isComplete(String name) {
|
||||
Quest quest = getQuest(name);
|
||||
if (quest == null) {
|
||||
SystemLogger.logErr("Error can't check if quest is complete for " + name);
|
||||
SystemLogger.logErr(this.getClass(), "Error can't check if quest is complete for " + name);
|
||||
return false;
|
||||
}
|
||||
return quest.getStage(player) >= 100;
|
||||
@@ -219,7 +219,7 @@ public final class QuestRepository {
|
||||
public boolean hasStarted(String name) {
|
||||
Quest quest = getQuest(name);
|
||||
if (quest == null) {
|
||||
SystemLogger.logErr("Error can't check if quest is complete for " + name);
|
||||
SystemLogger.logErr(this.getClass(), "Error can't check if quest is complete for " + name);
|
||||
return false;
|
||||
}
|
||||
return quest.getStage(player) > 0;
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public final class BuildOptionPlugin extends OptionHandler {
|
||||
Hotspot hotspot = player.getHouseManager().getHotspot(object);
|
||||
if (hotspot == null || !isBuildable(player, object, hotspot)) {
|
||||
System.out.println(hotspot == null);
|
||||
SystemLogger.logErr("Construction (building): " + hotspot + " : " + object + " chunkX = " + object.getLocation().getChunkX() + ", chunkY = " + object.getLocation().getChunkY());
|
||||
SystemLogger.logErr(this.getClass(), "Construction (building): " + hotspot + " : " + object + " chunkX = " + object.getLocation().getChunkX() + ", chunkY = " + object.getLocation().getChunkY());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ public final class BuildingUtils {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SystemLogger.logErr("Couldn't find stairs! " + plane);
|
||||
SystemLogger.logErr(BuildingUtils.class, "Couldn't find stairs! " + plane);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -409,7 +409,7 @@ public final class BuildingUtils {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SystemLogger.logErr("Couldn't find stairs! " + plane);
|
||||
SystemLogger.logErr(BuildingUtils.class, "Couldn't find stairs! " + plane);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -632,8 +632,8 @@ public final class BuildingUtils {
|
||||
Direction[] directions = new Direction[4];
|
||||
boolean[] exit = Arrays.copyOf(exits, exits.length); //(0=east, 1=south, 2=west, 3=north)
|
||||
int[] info = getExitRequirements(player, z, roomX, roomY);//(0=west, 1=north, 2=east, 3=south)
|
||||
// SystemLogger.logErr("Available exits - [east=" + exit[0] + ", south=" + exit[1] + ", west=" + exit[2] + ", north=" + exit[3] + "]!");
|
||||
// SystemLogger.logErr("Required exits - [east=" + info[0] + ", south=" + info[1] + ", west=" + info[2] + ", north=" + info[3] + "]!");
|
||||
// SystemLogger.logErr(BuildingUtils.class, "Available exits - [east=" + exit[0] + ", south=" + exit[1] + ", west=" + exit[2] + ", north=" + exit[3] + "]!");
|
||||
// SystemLogger.logErr(BuildingUtils.class, "Required exits - [east=" + info[0] + ", south=" + info[1] + ", west=" + info[2] + ", north=" + info[3] + "]!");
|
||||
for (int i = 0; i < 4; i++) {
|
||||
boolean success = true;
|
||||
for (int j = 0; j < 4; j++) {
|
||||
|
||||
+3
-3
@@ -39,12 +39,12 @@ public final class ConstructionInterface extends ComponentPlugin {
|
||||
Hotspot hotspot = player.getAttribute("con:hotspot");
|
||||
Scenery object = player.getAttribute("con:hsobject");
|
||||
if (hotspot == null || object == null) {
|
||||
SystemLogger.logErr("Failed building decoration " + hotspot + " : " + object);
|
||||
SystemLogger.logErr(this.getClass(), "Failed building decoration " + hotspot + " : " + object);
|
||||
break;
|
||||
}
|
||||
slot = ((slot % 2 != 0) ? 4 : 0) + (slot >> 1);
|
||||
if (slot >= hotspot.getHotspot().getDecorations().length) {
|
||||
SystemLogger.logErr("Failed building decoration " + slot + "/" + hotspot.getHotspot().getDecorations().length);
|
||||
SystemLogger.logErr(this.getClass(), "Failed building decoration " + slot + "/" + hotspot.getHotspot().getDecorations().length);
|
||||
break;
|
||||
}
|
||||
boolean debug = player.isStaff();
|
||||
@@ -105,7 +105,7 @@ public final class ConstructionInterface extends ComponentPlugin {
|
||||
break;
|
||||
case 402:
|
||||
int index = button - 160;
|
||||
SystemLogger.logErr("BuildRoom Interface Index: " + index);
|
||||
SystemLogger.logErr(this.getClass(), "BuildRoom Interface Index: " + index);
|
||||
if (index > -1 && index < RoomProperties.values().length) {
|
||||
player.getDialogueInterpreter().open("con:room", RoomProperties.values()[index]);
|
||||
return true;
|
||||
|
||||
@@ -323,7 +323,7 @@ public final class HouseManager {
|
||||
*/
|
||||
public Location getEnterLocation() {
|
||||
if (houseRegion == null) {
|
||||
SystemLogger.logErr("House wasn't constructed yet!");
|
||||
SystemLogger.logErr(this.getClass(), "House wasn't constructed yet!");
|
||||
return null;
|
||||
}
|
||||
for (int x = 0; x < 8; x++) {
|
||||
|
||||
@@ -1,312 +0,0 @@
|
||||
package core.game.node.entity.skill.construction;
|
||||
|
||||
import core.cache.def.impl.SceneryDefinition;
|
||||
import core.game.component.Component;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.game.node.scenery.SceneryBuilder;
|
||||
import core.game.world.map.BuildRegionChunk;
|
||||
import core.game.world.map.Direction;
|
||||
import core.game.world.map.Location;
|
||||
import core.net.packet.PacketRepository;
|
||||
import core.net.packet.context.ContainerContext;
|
||||
import core.net.packet.out.ContainerPacket;
|
||||
import rs09.game.node.entity.skill.construction.Hotspot;
|
||||
import rs09.game.system.SystemLogger;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Used for building a room.
|
||||
* @author Emperor
|
||||
*
|
||||
*/
|
||||
public final class RoomBuilder {
|
||||
|
||||
/**
|
||||
* The directions array.
|
||||
*/
|
||||
public static final Direction[] DIRECTIONS = {
|
||||
Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST
|
||||
};
|
||||
|
||||
/**
|
||||
* Opens the building furniture interface.
|
||||
* @param player The player.
|
||||
* @param hotspot The hotspot.
|
||||
*/
|
||||
public static void openBuildInterface(Player player, BuildHotspot hotspot) {
|
||||
player.getInterfaceManager().open(new Component(396));
|
||||
Item[] items = new Item[7];
|
||||
int value = 1;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int offset = i * 5;
|
||||
if (i >= hotspot.getDecorations().length) {
|
||||
for (int j = 97; j < 102; j++) {
|
||||
player.getPacketDispatch().sendString("", 396, j + offset);
|
||||
}
|
||||
player.getPacketDispatch().sendString("", 396, 140 + i);
|
||||
value |= 1 << (i + 1);
|
||||
continue;
|
||||
}
|
||||
Decoration decoration = hotspot.getDecorations()[i];
|
||||
if (i < 4) {
|
||||
items[i * 2] = new Item(decoration.getInterfaceItem());
|
||||
} else {
|
||||
items[1 + ((i - 4) * 2)] = new Item(decoration.getInterfaceItem());
|
||||
}
|
||||
player.getPacketDispatch().sendString(SceneryDefinition.forId(decoration.getObjectId()).getName(), 396, 97 + offset);
|
||||
boolean hasRequirements = true;
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (j >= decoration.getItems().length) {
|
||||
player.getPacketDispatch().sendString("", 396, 98 + offset + j);
|
||||
} else {
|
||||
Item item = decoration.getItems()[j];
|
||||
if (!player.getInventory().containsItem(item)) {
|
||||
hasRequirements = false;
|
||||
}
|
||||
player.getPacketDispatch().sendString(item.getName() + ": " + item.getAmount(), 396, 98 + offset + j);
|
||||
}
|
||||
}
|
||||
player.getPacketDispatch().sendString("Lvl " + decoration.getLevel(), 396, 140 + i);
|
||||
if (hasRequirements) {
|
||||
value |= 1 << (i + 1);
|
||||
}
|
||||
}
|
||||
player.getConfigManager().set(261, value);
|
||||
PacketRepository.send(ContainerPacket.class, new ContainerContext(player, 396, 132, 91, items, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a decoration object.
|
||||
* @param player The player.
|
||||
* @param deco The decoration.
|
||||
* @param object The object.
|
||||
*/
|
||||
public static void buildDecoration(Player player, BuildHotspot hotspot, Decoration deco, Scenery object) {
|
||||
if(!player.isAdmin()){
|
||||
if (!player.getInventory().containsItems(deco.getItems())) {
|
||||
player.getPacketDispatch().sendMessage("You don't have the required items to build this.");
|
||||
return;
|
||||
}
|
||||
player.getInventory().remove(deco.getItems());
|
||||
}
|
||||
Location l = object.getLocation();
|
||||
Room room = player.getHouseManager().getRooms()[l.getZ()][l.getLocalX() >> 3][l.getLocalY() >> 3];
|
||||
Hotspot h = room.getHotspot(hotspot, l.getX(), l.getY());
|
||||
if (h != null) {
|
||||
switch(h.getHotspot().getType()) {
|
||||
case INDIVIDUAL:
|
||||
SceneryBuilder.replace(object, object.transform(deco.getObjectId()));
|
||||
h.setDecorationIndex(hotspot.getDecorationIndex(deco));
|
||||
break;
|
||||
case RECURSIVE:
|
||||
room.setAllDecorationIndex(hotspot.getDecorationIndex(deco), h.getHotspot());
|
||||
Scenery[][] objects = player.getHouseManager().getHouseRegion().getPlanes()[l.getZ()].getChunks()[l.getLocalX() >> 3][l.getLocalY() >> 3].getObjects();
|
||||
for (int j = 0; j < objects.length; j++) {
|
||||
for (int k = 0; k < objects[j].length; k++) {
|
||||
Scenery go = objects[j][k];
|
||||
if (go != null && go.getId() == object.getId()) {
|
||||
SceneryBuilder.replace(go, go.transform(deco.getObjectId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LINKED:
|
||||
BuildHotspot[] linkedHotspots = BuildHotspot.getLinkedHotspots(h.getHotspot());
|
||||
BuildRegionChunk chunk = (BuildRegionChunk) player.getHouseManager().getHouseRegion().getPlanes()[l.getZ()].getChunks()[l.getLocalX() >> 3][l.getLocalY() >> 3];
|
||||
for (int x = 0; x < 8; x++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
for(BuildHotspot bh : linkedHotspots) {
|
||||
int index = chunk.getIndex(x, y, bh.getObjectId());
|
||||
Scenery o = chunk.get(x, y, index);
|
||||
if (o != null && bh.getObjectId() == o.getId()) {
|
||||
SceneryBuilder.replace(o, o.transform(bh.getDecorations()[0].getObjectId()));
|
||||
room.setAllDecorationIndex(0, bh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the decoration
|
||||
* @param player the player
|
||||
* @param object the object to remove
|
||||
*/
|
||||
public static void removeDecoration(Player player, Scenery object) {
|
||||
Location l = object.getLocation();
|
||||
Room room = player.getHouseManager().getRooms()[l.getZ()][l.getLocalX() >> 3][l.getLocalY() >> 3];
|
||||
for (int i = 0; i < room.getHotspots().length; i++) {
|
||||
Hotspot hotspot = room.getHotspots()[i];
|
||||
if (hotspot.getChunkX() == l.getChunkOffsetX() && hotspot.getChunkY() == l.getChunkOffsetY()) {
|
||||
switch (hotspot.getHotspot().getType()) {
|
||||
case INDIVIDUAL:
|
||||
SceneryBuilder.replace(object, object.transform(hotspot.getHotspot().getObjectId()));
|
||||
hotspot.setDecorationIndex(-1);
|
||||
return;
|
||||
case RECURSIVE:
|
||||
room.setAllDecorationIndex(-1, hotspot.getHotspot());
|
||||
Scenery[][] objects = player.getHouseManager().getHouseRegion().getPlanes()[l.getZ()].getChunks()[l.getLocalX() >> 3][l.getLocalY() >> 3].getObjects();
|
||||
for (int j = 0; j < objects.length; j++) {
|
||||
for (int k = 0; k < objects[j].length; k++) {
|
||||
Scenery go = objects[j][k];
|
||||
if (go != null && go.getId() == object.getId()) {
|
||||
SceneryBuilder.replace(go, go.transform(hotspot.getHotspot().getObjectId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
case LINKED:
|
||||
//TODO
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a room.
|
||||
* @param player The player.
|
||||
* @param room The room to build.
|
||||
*/
|
||||
public static void buildRoom(Player player, Room room, int z, int x, int y) {
|
||||
SystemLogger.logErr("Building direction = " + room.getRotation().name());
|
||||
if(room.getRotation() != Direction.NORTH){
|
||||
room.setRotation(Direction.NORTH);
|
||||
player.getDialogueInterpreter().sendDialogue("Room rotation is currently disabled.");
|
||||
}
|
||||
player.getHouseManager().getRooms()[z][x][y] = room;
|
||||
player.getPacketDispatch().sendMessage("Building room " + room.getProperties() + ".");
|
||||
player.getHouseManager().reload(player, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks of a room exists
|
||||
* @param player the player
|
||||
* @param door the door hotspot the player is trying to build at
|
||||
* @return true if the room is built already
|
||||
*/
|
||||
public static boolean roomExists(Player player, Scenery door) {
|
||||
int[] location = getRoomPosition(door);
|
||||
return player.getHouseManager().getRooms()[player.getLocation().getZ()][location[0]][location[1]] != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the room offset.
|
||||
* @param door The door.
|
||||
* @return The room offset [x, y].
|
||||
*/
|
||||
public static int[] getRoomPosition(Scenery door) {
|
||||
Location l = door.getLocation();
|
||||
switch (door.getRotation()) {
|
||||
case 0: //West
|
||||
return new int[] { (l.getLocalX() >> 3) - 1, l.getLocalY() >> 3 };
|
||||
case 1: //North
|
||||
return new int[] { l.getLocalX() >> 3, (l.getLocalY() >> 3) + 1};
|
||||
case 2: //East
|
||||
return new int[] { (l.getLocalX() >> 3) + 1, l.getLocalY() >> 3 };
|
||||
case 3: //South
|
||||
return new int[] { l.getLocalX() >> 3, (l.getLocalY() >> 3) - 1};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the available rotations of the room to build.
|
||||
* @param exits The exits of the room.
|
||||
* @param door The door hotspot used.
|
||||
* @param roomX The room x-coordinate.
|
||||
* @param roomY The room y-coordinate.
|
||||
* @return The available rotations for the room [NORTH, EAST, SOUTH, WEST].
|
||||
*/
|
||||
public static Direction[] getAvailableRotations(Player player, boolean[] exits, Scenery door, int roomX, int roomY) {
|
||||
Direction[] directions = new Direction[4];
|
||||
//Exits go to: (0=east, 1=south, 2=west, 3=north)
|
||||
boolean[] exit = Arrays.copyOf(exits, exits.length);
|
||||
//Door goes to: (0=west, 1=north, 2=east, 3=south)
|
||||
int[] info = getExitRequirements(player, door.getLocation().getZ(), roomX, roomY);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
boolean success = true;
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (info[j] == 1 && !exit[j]) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
if (info[j] == -1 && exit[j]) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
directions[i] = Direction.NORTH;
|
||||
}
|
||||
System.out.println(i + ": " + Arrays.toString(exit) + " - " + Arrays.toString(info));
|
||||
boolean b = exit[0];
|
||||
for (int j = 0; j < exit.length - 1; j++) {
|
||||
exit[j] = exit[j + 1];
|
||||
}
|
||||
exit[exit.length - 1] = b;
|
||||
}
|
||||
Direction dir = directions[0];
|
||||
directions[0] = directions[2];
|
||||
directions[2] = dir;
|
||||
dir = directions[1];
|
||||
directions[1] = directions[3];
|
||||
directions[3] = dir;
|
||||
return directions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exit requirements for the given room.
|
||||
* @param roomX The room x-coordinate.
|
||||
* @param roomY The room y-coordinate.
|
||||
* @return The disabled exit indexes.
|
||||
*/
|
||||
private static int[] getExitRequirements(Player player, int z, int roomX, int roomY) {
|
||||
//1 2 3 0
|
||||
//0=east, 1=south, 2=west, 3=north).
|
||||
int[] exits = new int[4];
|
||||
if (roomX == 0) {
|
||||
exits[2] = -1;
|
||||
}
|
||||
else if (player.getHouseManager().hasExit(z, roomX - 1, roomY, Direction.EAST)) {
|
||||
exits[2] = 1;
|
||||
}
|
||||
else if (player.getHouseManager().getRooms()[z][roomX - 1][roomY] != null) {
|
||||
exits[2] = -1;
|
||||
}
|
||||
if (roomY == 7) {
|
||||
exits[1] = -1;
|
||||
}
|
||||
else if (player.getHouseManager().hasExit(z, roomX, roomY + 1, Direction.SOUTH)) {
|
||||
exits[1] = 1;
|
||||
}
|
||||
else if (player.getHouseManager().getRooms()[z][roomX][roomY + 1] != null) {
|
||||
exits[1] = -1;
|
||||
}
|
||||
if (roomX == 7) {
|
||||
exits[0] = -1;
|
||||
}
|
||||
else if (player.getHouseManager().hasExit(z, roomX + 1, roomY, Direction.WEST)) {
|
||||
exits[0] = 1;
|
||||
}
|
||||
else if (player.getHouseManager().getRooms()[z][roomX + 1][roomY] != null) {
|
||||
exits[0] = -1;
|
||||
}
|
||||
if (roomY == 0) {
|
||||
exits[3] = -1;
|
||||
}
|
||||
else if (player.getHouseManager().hasExit(z, roomX, roomY - 1, Direction.NORTH)) {
|
||||
exits[3] = 1;
|
||||
}
|
||||
else if (player.getHouseManager().getRooms()[z][roomX][roomY - 1] != null) {
|
||||
exits[3] = -1;
|
||||
}
|
||||
return exits;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import org.rs09.consts.Items.RAW_BEEF_2132
|
||||
import org.rs09.consts.Items.SEAWEED_401
|
||||
import org.rs09.consts.Items.UNCOOKED_CAKE_1889
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.IntType
|
||||
import rs09.game.node.entity.skill.cooking.CookingDialogue
|
||||
|
||||
/**
|
||||
@@ -32,7 +33,7 @@ class CookingRewrite : InteractionListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
|
||||
onUseWith(SCENERY,RAW_FOODS, *COOKING_OBJs){ player, used, with ->
|
||||
onUseWith(IntType.SCENERY,RAW_FOODS, *COOKING_OBJs){ player, used, with ->
|
||||
val item = used.asItem()
|
||||
val obj = with.asScenery()
|
||||
val range = obj.name.toLowerCase().contains("range")
|
||||
|
||||
+3
-2
@@ -2,13 +2,14 @@ package core.game.node.entity.skill.firemaking
|
||||
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.interaction.IntType
|
||||
|
||||
class FiremakingListener : InteractionListener
|
||||
{
|
||||
val logs = intArrayOf(1511, 1521, 1513, 1515, 1517, 1519, 1521, 2862, 3438, 3440, 3442, 3444, 3446, 3448, 6211, 6213, 6332, 6333, 7404, 7405, 7406, 8934, 9067, 10328, 10329, 10808, 10810, 10812, 11035, 12581, 12583, 3125)
|
||||
val logs = intArrayOf(1511, 1521, 1513, 1515, 1517, 1519, 2862, 3438, 3440, 3442, 3444, 3446, 3448, 6211, 6213, 6332, 6333, 7404, 7405, 7406, 8934, 9067, 10328, 10329, 10808, 10810, 10812, 11035, 12581, 12583, 3125)
|
||||
|
||||
override fun defineListeners() {
|
||||
onUseWith(ITEM, Items.TINDERBOX_590, *logs) { player, _, with ->
|
||||
onUseWith(IntType.ITEM, Items.TINDERBOX_590, *logs) { player, _, with ->
|
||||
player.pulseManager.run(FireMakingPulse(player, with.asItem(), null))
|
||||
return@onUseWith true
|
||||
}
|
||||
|
||||
@@ -645,7 +645,7 @@ public enum SkillingResource {
|
||||
static {
|
||||
for (SkillingResource resource : SkillingResource.values()) {
|
||||
if (RESOURCES.containsKey(resource.id)) {
|
||||
SystemLogger.logErr("Already contained resource " + resource.getId() + " - " + resource.name());
|
||||
SystemLogger.logErr(SkillingResource.class, "Already contained resource " + resource.getId() + " - " + resource.name());
|
||||
}
|
||||
RESOURCES.put(resource.id, resource);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public enum Traps {
|
||||
return;
|
||||
}
|
||||
if (instance.getWrapper(object) == null) {
|
||||
SystemLogger.logErr("NO WRAPPER (HUNTER DISMANTLE)");
|
||||
SystemLogger.logErr(this.getClass(), "NO WRAPPER (HUNTER DISMANTLE)");
|
||||
return;
|
||||
}
|
||||
player.faceLocation(object.getLocation());
|
||||
|
||||
@@ -579,7 +579,7 @@ public abstract class Familiar extends NPC implements Plugin<Object> {
|
||||
face(owner);
|
||||
}
|
||||
if (!isRenderable() && owner.isActive()) {
|
||||
// SystemLogger.logErr("Familiar in inactive region!");
|
||||
// SystemLogger.logErr(this.getClass(), "Familiar in inactive region!");
|
||||
getWalkingQueue().update();
|
||||
getUpdateMasks().prepare(this);
|
||||
}
|
||||
@@ -628,7 +628,7 @@ public abstract class Familiar extends NPC implements Plugin<Object> {
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
for (int id : getIds()) {
|
||||
if (FamiliarManager.getFamiliars().containsKey(id)) {
|
||||
SystemLogger.logErr("Familiar " + id + " was already registered!");
|
||||
SystemLogger.logErr(this.getClass(), "Familiar " + id + " was already registered!");
|
||||
return null;
|
||||
}
|
||||
FamiliarManager.getFamiliars().put(id, this);
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class SceneryBuilder {
|
||||
Scenery current = LandscapeParser.removeScenery(remove);
|
||||
if (current == null) {
|
||||
if (GameWorld.getSettings().isDevMode()) {
|
||||
SystemLogger.logErr("Object could not be replaced - object to remove is invalid.");
|
||||
SystemLogger.logErr(SceneryBuilder.class, "Object could not be replaced - object to remove is invalid.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public final class SceneryBuilder {
|
||||
Scenery current = LandscapeParser.removeScenery(remove);
|
||||
if (current == null) {
|
||||
if (GameWorld.getSettings().isDevMode()) {
|
||||
SystemLogger.logErr("Object could not be replaced - object to remove is invalid.");
|
||||
SystemLogger.logErr(SceneryBuilder.class, "Object could not be replaced - object to remove is invalid.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public final class SystemShutdownHook implements Runnable {
|
||||
if (SystemManager.isTerminated()) {
|
||||
return;
|
||||
}
|
||||
SystemLogger.logInfo("[SystemShutdownHook] Terminating...");
|
||||
SystemLogger.logInfo(this.getClass(), "[SystemShutdownHook] Terminating...");
|
||||
SystemManager.flag(SystemState.TERMINATED);
|
||||
}
|
||||
}
|
||||
@@ -34,14 +34,14 @@ public final class SystemTermination {
|
||||
* Terminates the system safely.
|
||||
*/
|
||||
public void terminate() {
|
||||
SystemLogger.logInfo("[SystemTerminator] Initializing termination sequence - do not shutdown!");
|
||||
SystemLogger.logInfo(this.getClass(), "Initializing termination sequence - do not shutdown!");
|
||||
try {
|
||||
SystemLogger.logInfo("[SystemTerminator] Stopping all bots...");
|
||||
SystemLogger.logInfo(this.getClass(), "Stopping all bots...");
|
||||
AIRepository.clearAllBots();
|
||||
SystemLogger.logInfo("[SystemTerminator] Shutting down networking...");
|
||||
SystemLogger.logInfo(this.getClass(), "Shutting down networking...");
|
||||
Server.setRunning(false);
|
||||
Server.getReactor().terminate();
|
||||
SystemLogger.logInfo("[SystemTerminator] Stopping all pulses...");
|
||||
SystemLogger.logInfo(this.getClass(), "Stopping all pulses...");
|
||||
GameWorld.getMajorUpdateWorker().stop();
|
||||
for (Iterator<Player> it = Repository.getPlayers().iterator(); it.hasNext();) {
|
||||
try {
|
||||
@@ -70,7 +70,7 @@ public final class SystemTermination {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SystemLogger.logInfo("[SystemTerminator] Server successfully terminated!");
|
||||
SystemLogger.logInfo(this.getClass(), "Server successfully terminated!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +79,7 @@ public final class SystemTermination {
|
||||
*/
|
||||
public void save(String directory) {
|
||||
File file = new File(directory);
|
||||
SystemLogger.logInfo("[SystemTerminator] Saving data [dir=" + file.getAbsolutePath() + "]...");
|
||||
SystemLogger.logInfo(this.getClass(), "Saving data [dir="+ file.getAbsolutePath() + "]...");
|
||||
if (!file.isDirectory()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ public final class CommunicationInfo {
|
||||
CommunicationInfo info = player.getDetails().getCommunication();
|
||||
Contact c = info.contacts.get(contact);
|
||||
if (c == null) {
|
||||
SystemLogger.logErr("Could not find contact " + contact + " to update clan rank!");
|
||||
SystemLogger.logErr(CommunicationInfo.class, "Could not find contact " + contact + " to update clan rank!");
|
||||
return;
|
||||
}
|
||||
c.setRank(clanRank);
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
package core.game.system.mysql;
|
||||
|
||||
import rs09.ServerConstants;
|
||||
import rs09.game.system.SystemLogger;
|
||||
import core.game.system.SystemManager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Manages the SQL connections.
|
||||
* @author Vexia
|
||||
*
|
||||
*/
|
||||
public final class SQLManager {
|
||||
|
||||
/**
|
||||
* If the sql manager is locally hosted. Generally you never should change this. Ignore this.
|
||||
*/
|
||||
public static final boolean LOCAL = false;
|
||||
|
||||
/**
|
||||
* The database URL.
|
||||
*/
|
||||
public static String DATABASE_URL;
|
||||
|
||||
/**
|
||||
* IF the sql manager is initialized.
|
||||
*/
|
||||
private static boolean initialized;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SQLManager} {@code Object}
|
||||
*/
|
||||
public SQLManager() {
|
||||
/**
|
||||
* empty.
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the sql manager.
|
||||
*/
|
||||
public static void init() {
|
||||
initialized = true;
|
||||
SystemManager.getSystemConfig().parse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-plugin parsing.
|
||||
*/
|
||||
public static void prePlugin() {
|
||||
//new NPCConfigSQLHandler().parse();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses data from the database for the server post plugin loading.
|
||||
*/
|
||||
public static void postPlugin() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a connection.
|
||||
* @return The connection.
|
||||
*/
|
||||
public static Connection getConnection() {
|
||||
DATABASE_URL = ServerConstants.DATABASE_ADDRESS + ":" + ServerConstants.DATABASE_PORT + "/" + ServerConstants.DATABASE_NAME + "?useTimezone=true&serverTimezone=UTC";
|
||||
try {
|
||||
return DriverManager.getConnection("jdbc:mysql://" + DATABASE_URL, ServerConstants.DATABASE_USER, ServerConstants.DATABASE_PASS);
|
||||
} catch (SQLException e) {
|
||||
SystemLogger.logErr("Mysql error message=" + e.getMessage() + ".");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the connection so it's available for usage.
|
||||
* @param connection The connection.
|
||||
*/
|
||||
public static void close(Connection connection) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the initialized.
|
||||
* @return the initialized
|
||||
*/
|
||||
public static boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bainitialized.
|
||||
* @param initialized the initialized to set.
|
||||
*/
|
||||
public static void setInitialized(boolean initialized) {
|
||||
SQLManager.initialized = initialized;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package core.game.world;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the game type.
|
||||
* @author Vexia
|
||||
*
|
||||
*/
|
||||
public enum GameType {
|
||||
ECONOMY,
|
||||
SPAWN;
|
||||
|
||||
/**
|
||||
* Parses the game type.
|
||||
* @param string the string.
|
||||
* @return {@code GameType} the type.
|
||||
*/
|
||||
public static GameType parse(String string) {
|
||||
return Boolean.parseBoolean(string) ? ECONOMY : SPAWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a game type for the name.
|
||||
* @param property the property.
|
||||
* @return the type.
|
||||
*/
|
||||
public static GameType forName(String property) {
|
||||
if (property == null) {
|
||||
return null;
|
||||
}
|
||||
return property.equals("economy") ? ECONOMY : property.equals("spawn") ? SPAWN : null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class BuildRegionChunk extends RegionChunk {
|
||||
@Override
|
||||
public void rotate(Direction direction) {
|
||||
if (rotation != 0) {
|
||||
SystemLogger.logErr("Region chunk was already rotated!");
|
||||
SystemLogger.logErr(this.getClass(), "Region chunk was already rotated!");
|
||||
return;
|
||||
}
|
||||
Scenery[][][] copy = new Scenery[ARRAY_SIZE][SIZE][SIZE];
|
||||
@@ -236,7 +236,7 @@ public class BuildRegionChunk extends RegionChunk {
|
||||
System.err.print(", ");
|
||||
}
|
||||
}
|
||||
SystemLogger.logErr("]!");
|
||||
SystemLogger.logErr(this.getClass(), "]!");
|
||||
throw new IllegalStateException("Insufficient array length for storing all objects! ");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.music.MusicZone;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.game.node.scenery.SceneryBuilder;
|
||||
import core.game.system.communication.CommunicationInfo;
|
||||
import core.game.system.task.Pulse;
|
||||
import core.game.world.map.build.DynamicRegion;
|
||||
import core.game.world.map.build.LandscapeParser;
|
||||
@@ -339,13 +340,13 @@ public class Region {
|
||||
*/
|
||||
private static boolean unload(Region r) {
|
||||
if (r.isViewed()) {
|
||||
SystemLogger.logErr("Players viewing region!");
|
||||
SystemLogger.logErr(CommunicationInfo.class, "Players viewing region!");
|
||||
r.flagActive();
|
||||
return false;
|
||||
}
|
||||
for (RegionPlane p : r.planes) {
|
||||
if (!p.getPlayers().isEmpty()) {
|
||||
SystemLogger.logErr("Players still in region!");
|
||||
SystemLogger.logErr(CommunicationInfo.class, "Players still in region!");
|
||||
r.flagActive();
|
||||
return false;
|
||||
}
|
||||
@@ -388,7 +389,7 @@ public class Region {
|
||||
public int decrementViewAmount() {
|
||||
synchronized (this) {
|
||||
if (viewAmount < 1) {
|
||||
//SystemLogger.logErr("View amount is " + (viewAmount - 1));
|
||||
//SystemLogger.logErr(this.getClass(), "View amount is " + (viewAmount - 1));
|
||||
viewAmount++;
|
||||
}
|
||||
return --viewAmount;
|
||||
|
||||
@@ -182,7 +182,7 @@ public class RegionChunk {
|
||||
*/
|
||||
public void rotate(Direction direction) {
|
||||
if (rotation != 0) {
|
||||
SystemLogger.logErr("Region chunk was already rotated!");
|
||||
SystemLogger.logErr(this.getClass(), "Region chunk was already rotated!");
|
||||
return;
|
||||
}
|
||||
Scenery[][] copy = new Scenery[SIZE][SIZE];
|
||||
|
||||
@@ -43,7 +43,7 @@ object RegionManager {
|
||||
LOCK.unlock()
|
||||
return REGION_CACHE[regionId]!!
|
||||
}
|
||||
SystemLogger.logErr("UNABLE TO OBTAIN LOCK WHEN GETTING REGION BY ID. RETURNING BLANK REGION.")
|
||||
SystemLogger.logErr(this::class.java, "UNABLE TO OBTAIN LOCK WHEN GETTING REGION BY ID. RETURNING BLANK REGION.")
|
||||
return Region(0,0)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
package core.gui;
|
||||
|
||||
|
||||
import core.gui.tab.GrandExchangeTab;
|
||||
import core.gui.tab.PlayerTab;
|
||||
import core.gui.tab.StatisticsTab;
|
||||
import core.gui.tab.UtilityTab;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* The console frame tool.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class ConsoleFrame extends JFrame {
|
||||
|
||||
/**
|
||||
* The console frame instance.
|
||||
*/
|
||||
public static final ConsoleFrame INSTANCE = new ConsoleFrame();
|
||||
|
||||
/**
|
||||
* The serail UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 6368064564449356833L;
|
||||
|
||||
/**
|
||||
* The size of the frame.
|
||||
*/
|
||||
private static final Dimension SIZE = new Dimension(1074, 664);
|
||||
|
||||
/**
|
||||
* The tabbed pane.
|
||||
*/
|
||||
private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
|
||||
/**
|
||||
* The statistics tab.
|
||||
*/
|
||||
private final StatisticsTab statisticsTab = StatisticsTab.INSTANCE.init();
|
||||
|
||||
/**
|
||||
* The player tab.
|
||||
*/
|
||||
private final PlayerTab playerTab = new PlayerTab();
|
||||
|
||||
/**
|
||||
* The grand exchange tab.
|
||||
*/
|
||||
private final GrandExchangeTab grandExchangeTab = new GrandExchangeTab();
|
||||
|
||||
/**
|
||||
* The utility tab.
|
||||
*/
|
||||
private final UtilityTab utilityTab = UtilityTab.getInstance();
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code consoleFrame} {@Code Object}
|
||||
*/
|
||||
private ConsoleFrame() {
|
||||
super("Console");
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the console frame.
|
||||
*
|
||||
* @return the frame.
|
||||
*/
|
||||
public ConsoleFrame init() {
|
||||
setLocationRelativeTo(null);
|
||||
setSize(SIZE);
|
||||
getContentPane().setLayout(null);
|
||||
tabbedPane.setBounds(0, 0, 1068, 636);
|
||||
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2);
|
||||
getContentPane().add(tabbedPane);
|
||||
addTabs(statisticsTab, utilityTab, playerTab, grandExchangeTab);
|
||||
setResizable(false);
|
||||
setVisible(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static void main(String... args) {
|
||||
INSTANCE.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tabs.
|
||||
*
|
||||
* @param tabs the tabs.
|
||||
*/
|
||||
public void addTabs(ConsoleTab... tabs) {
|
||||
for (ConsoleTab tab : tabs) {
|
||||
addTab(tab);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tab to the tabbed pane.
|
||||
*
|
||||
* @param tab the tab.
|
||||
*/
|
||||
public void addTab(ConsoleTab tab) {
|
||||
tabbedPane.add(tab.getName(), tab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the statisticsTab.
|
||||
*
|
||||
* @return the statisticsTab
|
||||
*/
|
||||
public StatisticsTab getStatisticsTab() {
|
||||
return statisticsTab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tabbedPane.
|
||||
*
|
||||
* @return the tabbedPane
|
||||
*/
|
||||
public JTabbedPane getTabbedPane() {
|
||||
return tabbedPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the playerTab.
|
||||
*
|
||||
* @return the playerTab
|
||||
*/
|
||||
public PlayerTab getPlayerTab() {
|
||||
return playerTab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the utilityTab.
|
||||
*
|
||||
* @return the utilityTab
|
||||
*/
|
||||
public UtilityTab getUtilityTab() {
|
||||
return utilityTab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance.
|
||||
*
|
||||
* @return the instance.
|
||||
*/
|
||||
public static ConsoleFrame getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the grandExchangeTab.
|
||||
*
|
||||
* @return the grandExchangeTab
|
||||
*/
|
||||
public GrandExchangeTab getGrandExchangeTab() {
|
||||
return grandExchangeTab;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package core.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* The console tab.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class ConsoleTab extends JPanel {
|
||||
|
||||
/**
|
||||
* The serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 2899642836866716523L;
|
||||
|
||||
/**
|
||||
* The name of the console tab.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code consoleTab} {@Code Object}
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
public ConsoleTab(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
setLayout(null);
|
||||
setBounds(new Rectangle(0, 0, 1068, 663));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package core.gui.component;
|
||||
|
||||
|
||||
import core.gui.ConsoleFrame;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* Loggs output to the gui console.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class ConsoleLogger extends PrintStream {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code WorkLogger} {@code Object}
|
||||
*
|
||||
* @param stream the stream.
|
||||
*/
|
||||
public ConsoleLogger(PrintStream stream) {
|
||||
super(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(String message) {
|
||||
log(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintStream printf(String message, Object... objects) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(boolean message) {
|
||||
log(String.valueOf(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(int message) {
|
||||
log(String.valueOf(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(double message) {
|
||||
log(String.valueOf(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(char message) {
|
||||
log("" + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(long message) {
|
||||
log("" + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to log the message.
|
||||
*
|
||||
* @param message the message.
|
||||
*/
|
||||
public void log(final String message) {
|
||||
ConsoleFrame.getInstance().getStatisticsTab().log(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
package core.gui.component;
|
||||
|
||||
|
||||
import core.game.container.Container;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.info.PlayerDetails;
|
||||
import core.game.node.item.Item;
|
||||
import rs09.game.world.GameWorld;
|
||||
import rs09.game.world.repository.Repository;
|
||||
import core.gui.ConsoleFrame;
|
||||
import core.tools.PlayerLoader;
|
||||
import core.tools.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Views a players details.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class PlayerViewer extends JPanel {
|
||||
|
||||
/**
|
||||
* The serail UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 1589056461884384398L;
|
||||
|
||||
/**
|
||||
* The name of the viewer.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The player details.
|
||||
*/
|
||||
private PlayerDetails details;
|
||||
|
||||
/**
|
||||
* The player file.
|
||||
*/
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code PlayerViewer} {@Code Object}
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
public PlayerViewer(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.details = PlayerLoader.getPlayerDetailFile(name);
|
||||
if (Repository.getPlayerByName(name) != null) {
|
||||
setPlayer(Repository.getPlayerByName(name));
|
||||
} else {
|
||||
if (GameWorld.getMajorUpdateWorker().getStarted()) {
|
||||
setPlayer(PlayerLoader.getPlayerFile(name));
|
||||
}
|
||||
}
|
||||
setBounds(new Rectangle(0, 0, 755, 539));
|
||||
setLayout(null);
|
||||
JButton btnClose = new JButton("Close");
|
||||
btnClose.addActionListener(e -> ConsoleFrame.getInstance().getPlayerTab().closeViewer(PlayerViewer.this));
|
||||
btnClose.setBounds(6, 6, 117, 29);
|
||||
add(btnClose);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "Info", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(6, 35, 286, 428);
|
||||
add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblName = new JLabel("Username: " + details.getUsername());
|
||||
lblName.setBounds(6, 16, 224, 16);
|
||||
panel.add(lblName);
|
||||
|
||||
JLabel lblIp = new JLabel("IP: " + details.getInfo().getIp());
|
||||
lblIp.setBounds(6, 96, 190, 16);
|
||||
panel.add(lblIp);
|
||||
|
||||
JLabel lblMac = new JLabel("Mac: " + details.getInfo().getMac());
|
||||
lblMac.setBounds(6, 124, 224, 16);
|
||||
panel.add(lblMac);
|
||||
|
||||
JLabel lblCompName = new JLabel("Comp name: " + details.getInfo().getCompName());
|
||||
lblCompName.setBounds(6, 208, 236, 16);
|
||||
panel.add(lblCompName);
|
||||
|
||||
JLabel lblLastLogin = new JLabel("Last login: " + new Date(details.getLastLogin()));
|
||||
lblLastLogin.setBounds(6, 152, 274, 16);
|
||||
panel.add(lblLastLogin);
|
||||
|
||||
JLabel lblStatus = new JLabel("Status: " + getStatus());
|
||||
lblStatus.setBounds(6, 236, 149, 16);
|
||||
panel.add(lblStatus);
|
||||
|
||||
// JLabel lblCredits = new JLabel("Credits: " + details.getShop().getCredits());
|
||||
// lblCredits.setBounds(6, 180, 139, 16);
|
||||
// panel.add(lblCredits);
|
||||
|
||||
JLabel lblRights = new JLabel("Rights: " + StringUtils.formatDisplayName(details.getRights().toString()));
|
||||
lblRights.setBounds(6, 68, 176, 16);
|
||||
panel.add(lblRights);
|
||||
|
||||
// JLabel lblDisplayName = new JLabel("Display name: " + details.getUsername());
|
||||
// lblDisplayName.setBounds(6, 40, 213, 16);
|
||||
// panel.add(lblDisplayName);
|
||||
|
||||
JLabel lblNetworth = new JLabel("Networth:");
|
||||
lblNetworth.setBounds(6, 264, 165, 16);
|
||||
panel.add(lblNetworth);
|
||||
|
||||
JLabel lblBanned = new JLabel("Banned: " + (details.getBanTime() > 0));
|
||||
lblBanned.setBounds(6, 292, 149, 16);
|
||||
panel.add(lblBanned);
|
||||
|
||||
JLabel lblMuted = new JLabel("Muted: " + (details.getMuteTime() > 0));
|
||||
lblMuted.setBounds(6, 317, 149, 16);
|
||||
panel.add(lblMuted);
|
||||
|
||||
JLabel lblActive = new JLabel("Active: " + checkActive());
|
||||
lblActive.setBounds(6, 342, 165, 16);
|
||||
panel.add(lblActive);
|
||||
if (player != null) {
|
||||
lblNetworth.setText("Networth: " + player.getMonitor().getNetworth() + "");
|
||||
}
|
||||
|
||||
JButton btnRefresh = new JButton("Refresh");
|
||||
btnRefresh.setBounds(124, 6, 117, 29);
|
||||
add(btnRefresh);
|
||||
|
||||
JButton btnViewContainer = new JButton("View Container");
|
||||
btnViewContainer.addActionListener(e -> {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
viewContainer();
|
||||
});
|
||||
btnViewContainer.setBounds(365, 6, 144, 29);
|
||||
add(btnViewContainer);
|
||||
|
||||
JButton btnDelete = new JButton("Delete");
|
||||
btnDelete.addActionListener(e -> {
|
||||
int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this account!?");
|
||||
if (result == 0) {
|
||||
ConsoleFrame.getInstance().getUtilityTab().delete(details);
|
||||
ConsoleFrame.getInstance().getPlayerTab().closeViewer(PlayerViewer.this);
|
||||
}
|
||||
});
|
||||
btnDelete.setBounds(244, 6, 117, 29);
|
||||
add(btnDelete);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the view containermanager.
|
||||
*/
|
||||
public void viewContainer() {
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
ActionListener listener = e -> {
|
||||
String name1 = e.getActionCommand();
|
||||
Container container = null;
|
||||
switch (name1) {
|
||||
case "Inventory":
|
||||
container = player.getInventory();
|
||||
break;
|
||||
case "Equipment":
|
||||
container = player.getEquipment();
|
||||
break;
|
||||
case "Bank":
|
||||
container = player.getBank();
|
||||
break;
|
||||
}
|
||||
if (container != null) {
|
||||
showContainer(container, name1);
|
||||
}
|
||||
};
|
||||
JButton invy = new JButton("Inventory");
|
||||
panel.add(invy);
|
||||
invy.addActionListener(listener);
|
||||
JButton equip = new JButton("Equipment");
|
||||
panel.add(equip);
|
||||
equip.addActionListener(listener);
|
||||
JButton bank = new JButton("Bank");
|
||||
bank.addActionListener(listener);
|
||||
panel.add(bank);
|
||||
JOptionPane.showConfirmDialog(null, panel, "View Container", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a container.
|
||||
*
|
||||
* @param container the container.
|
||||
* @param name the name.
|
||||
*/
|
||||
public void showContainer(core.game.container.Container container, String name) {
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
JScrollPane pane = new JScrollPane();
|
||||
DefaultListModel<String> model = new DefaultListModel<>();
|
||||
JList<String> list = new JList<>();
|
||||
for (Item i : container.toArray()) {
|
||||
if (i == null) {
|
||||
continue;
|
||||
}
|
||||
model.addElement(i.toString());
|
||||
}
|
||||
list.setModel(model);
|
||||
pane.setViewportView(list);
|
||||
panel.add(pane);
|
||||
JOptionPane.showConfirmDialog(null, panel, name, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player is active.
|
||||
*
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
public String checkActive() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date cutOff = null;
|
||||
long mili = 0;
|
||||
try {
|
||||
cutOff = sdf.parse("2014-6-10");
|
||||
mili = cutOff.getTime();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ((details.getLastLogin() < mili) ? "Not " : "") + "Active";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks active status.
|
||||
*
|
||||
* @return the status.
|
||||
*/
|
||||
public String getStatus() {
|
||||
return Repository.getPlayerByName(name) != null ? "Online" : "Offline";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the baplayer.
|
||||
*
|
||||
* @param player the player to set.
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package core.gui.tab;
|
||||
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.gui.ConsoleFrame;
|
||||
import core.gui.ConsoleTab;
|
||||
import rs09.game.ge.GrandExchangeOffer;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* A tab used to view the grand exchange.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class GrandExchangeTab extends ConsoleTab {
|
||||
|
||||
/**
|
||||
* The serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = -1619650762760289798L;
|
||||
|
||||
/**
|
||||
* The search field.
|
||||
*/
|
||||
private JTextField searchField;
|
||||
|
||||
/**
|
||||
* The jlist.
|
||||
*/
|
||||
private final JList<GrandExchangeOffer> list = new JList<GrandExchangeOffer>();
|
||||
|
||||
/**
|
||||
* The model.
|
||||
*/
|
||||
private final DefaultListModel<GrandExchangeOffer> model = new DefaultListModel<GrandExchangeOffer>();
|
||||
|
||||
/**
|
||||
* The id search field.
|
||||
*/
|
||||
private JTextField idSearchField;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code GrandExchangeTab} {@Code Object}
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public GrandExchangeTab() {
|
||||
super("Grand Exchange");
|
||||
list.setCellRenderer(new DefaultListCellRenderer() {
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
GrandExchangeOffer offer = (GrandExchangeOffer) value;
|
||||
if (offer == null) {
|
||||
return label;
|
||||
}
|
||||
Player player = null;
|
||||
for (Player p : ConsoleFrame.getInstance().getUtilityTab().getPlayers()) {
|
||||
if (p == null) {
|
||||
continue;
|
||||
}
|
||||
if (p.getDetails().getUid() == offer.getUid()) {
|
||||
player = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
label.setText((player == null ? "" : player.getName() + " - ") + offer.toString());
|
||||
return label;
|
||||
}
|
||||
|
||||
});
|
||||
list.setModel(model);
|
||||
JLabel lblSearch = new JLabel("Search player:");
|
||||
lblSearch.setBounds(24, 20, 95, 16);
|
||||
add(lblSearch);
|
||||
|
||||
searchField = new JTextField();
|
||||
searchField.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
searchPlayer();
|
||||
}
|
||||
});
|
||||
searchField.setBounds(119, 14, 185, 28);
|
||||
add(searchField);
|
||||
searchField.setColumns(10);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBounds(24, 78, 1015, 518);
|
||||
add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setBounds(6, 6, 375, 517);
|
||||
panel.add(scrollPane);
|
||||
scrollPane.setViewportView(list);
|
||||
|
||||
JButton btnDisplayDatabase = new JButton("Display Database");
|
||||
btnDisplayDatabase.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
displayDatabase();
|
||||
}
|
||||
});
|
||||
btnDisplayDatabase.setBounds(316, 15, 173, 29);
|
||||
add(btnDisplayDatabase);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("Search id:");
|
||||
lblNewLabel.setBounds(24, 48, 61, 16);
|
||||
add(lblNewLabel);
|
||||
|
||||
idSearchField = new JTextField();
|
||||
idSearchField.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
searchId();
|
||||
}
|
||||
});
|
||||
idSearchField.setColumns(10);
|
||||
idSearchField.setBounds(119, 48, 185, 28);
|
||||
add(idSearchField);
|
||||
|
||||
JButton btnNewButton = new JButton("Load");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ConsoleFrame.getInstance().getUtilityTab().populateList();
|
||||
}
|
||||
});
|
||||
btnNewButton.setBounds(316, 43, 173, 29);
|
||||
add(btnNewButton);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the player.
|
||||
*/
|
||||
private void searchPlayer() {
|
||||
model.clear();
|
||||
Player player = ConsoleFrame.getInstance().getUtilityTab().getPlayer(searchField.getText());
|
||||
if (player == null) {
|
||||
JOptionPane.showMessageDialog(null, "Error! No player found.");
|
||||
return;
|
||||
}
|
||||
/* for (GrandExchangeOffer o : player.getPlayerGrandExchange().getOfferRecords()) {
|
||||
if (o == null) {
|
||||
continue;
|
||||
}
|
||||
addOffer(o);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the id.
|
||||
*/
|
||||
private void searchId() {
|
||||
model.clear();
|
||||
int itemId = 0;
|
||||
try {
|
||||
itemId = Integer.parseInt(idSearchField.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
}
|
||||
/* for (GrandExchangeOffer o : OfferManager.getOffersForItem(itemId)) {
|
||||
if (o == null) {
|
||||
continue;
|
||||
}
|
||||
addOffer(o);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a g.e offer.
|
||||
*/
|
||||
private void addOffer(GrandExchangeOffer offer) {
|
||||
model.addElement(offer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a database.
|
||||
*/
|
||||
private void displayDatabase() {
|
||||
if (ConsoleFrame.getInstance().getUtilityTab().getPlayers().size() == 0) {
|
||||
JOptionPane.showMessageDialog(null, "Error! No data in DB yet. Press load.");
|
||||
return;
|
||||
}
|
||||
/* for (GrandExchangeOffer offer : OfferManager.getOFFER_MAPPING().values()) {
|
||||
model.addElement(offer);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
package core.gui.tab;
|
||||
|
||||
|
||||
import rs09.ServerConstants;
|
||||
import core.gui.ConsoleTab;
|
||||
import core.gui.component.PlayerViewer;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.SoftBevelBorder;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The player tab.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class PlayerTab extends ConsoleTab {
|
||||
|
||||
/**
|
||||
* The serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 8865322670299347942L;
|
||||
|
||||
/**
|
||||
* The list of player names to search through.
|
||||
*/
|
||||
private final List<String> playerNames = new ArrayList<>(20);
|
||||
|
||||
/**
|
||||
* The player name text field.
|
||||
*/
|
||||
private JTextField textField;
|
||||
|
||||
/**
|
||||
* The default model.
|
||||
*/
|
||||
private final DefaultListModel<String> model = new DefaultListModel<String>();
|
||||
|
||||
/**
|
||||
* The tabbed panes.
|
||||
*/
|
||||
private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
|
||||
/**
|
||||
* The mapping of open player viewers.
|
||||
*/
|
||||
private final Map<String, PlayerViewer> viewers = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code PlayerTab} {@Code Object}
|
||||
*/
|
||||
public PlayerTab() {
|
||||
super("Players");
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setBounds(6, 43, 260, 539);
|
||||
add(scrollPane);
|
||||
|
||||
final JList<String> list = new JList<String>();
|
||||
list.addListSelectionListener(e -> {
|
||||
if (list.getSelectedValue() != null) {
|
||||
openViewer(list.getSelectedValue());
|
||||
}
|
||||
});
|
||||
list.setModel(model);
|
||||
scrollPane.setViewportView(list);
|
||||
|
||||
JLabel lblSearchForPlayer = new JLabel("Search for player:");
|
||||
lblSearchForPlayer.setBounds(6, 15, 143, 16);
|
||||
add(lblSearchForPlayer);
|
||||
|
||||
textField = new JTextField();
|
||||
textField.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
model.clear();
|
||||
if (textField.getText() == null || textField.getText().length() < 1) {
|
||||
populatePlayerSearch();
|
||||
return;
|
||||
}
|
||||
for (String name : playerNames) {
|
||||
if (name.toLowerCase().contains(textField.getText())) {
|
||||
model.addElement(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
textField.setBounds(117, 9, 149, 28);
|
||||
add(textField);
|
||||
textField.setColumns(10);
|
||||
|
||||
tabbedPane.setBounds(278, 43, 755, 539);
|
||||
add(tabbedPane);
|
||||
|
||||
JButton btnRepopulate = new JButton("Repopulate");
|
||||
btnRepopulate.addActionListener(e -> populatePlayerSearch());
|
||||
btnRepopulate.setBounds(278, 10, 117, 29);
|
||||
add(btnRepopulate);
|
||||
populatePlayerSearch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a viewer for a player.
|
||||
*
|
||||
* @param name the name.
|
||||
* @return {@code True} if opened.
|
||||
*/
|
||||
public boolean openViewer(String name) {
|
||||
if (viewers.containsKey(name)) {
|
||||
return false;
|
||||
}
|
||||
PlayerViewer viewer = new PlayerViewer(name);
|
||||
viewers.put(name, viewer);
|
||||
tabbedPane.add(viewer.getName(), viewer);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes a viewer.
|
||||
*
|
||||
* @param viewer the viewer.
|
||||
* @return {@code True} if closed.
|
||||
*/
|
||||
public boolean closeViewer(PlayerViewer viewer) {
|
||||
if (!viewers.containsValue(viewer)) {
|
||||
JOptionPane.showMessageDialog(null, "Error! Viewer wasn't open.");
|
||||
return false;
|
||||
}
|
||||
viewers.remove(viewer.getName());
|
||||
tabbedPane.remove(viewer);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the searchable names.
|
||||
*/
|
||||
public void populatePlayerSearch() {
|
||||
playerNames.clear();
|
||||
model.clear();
|
||||
if(ServerConstants.PLAYER_SAVE_PATH == null) return;
|
||||
File f = new File(ServerConstants.PLAYER_SAVE_PATH);
|
||||
if (f.listFiles() == null) {
|
||||
System.out.println("Player directory was null!");
|
||||
return;
|
||||
}
|
||||
for (File file : Objects.requireNonNull(f.listFiles())) {
|
||||
String fileName = file.getName();
|
||||
if (!fileName.contains(".save")) continue;
|
||||
String playerName = fileName.replace(".save", "").trim();
|
||||
playerNames.add(playerName);
|
||||
model.addElement(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a searchable name to the list.
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
public void addSearchableName(String name) {
|
||||
playerNames.add(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the playerNames.
|
||||
*
|
||||
* @return the playerNames
|
||||
*/
|
||||
public List<String> getPlayerNames() {
|
||||
return playerNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the viewers.
|
||||
*
|
||||
* @return the viewers
|
||||
*/
|
||||
public Map<String, PlayerViewer> getViewers() {
|
||||
return viewers;
|
||||
}
|
||||
}
|
||||
@@ -1,669 +0,0 @@
|
||||
package core.gui.tab;
|
||||
|
||||
|
||||
import core.game.node.item.GroundItemManager;
|
||||
import core.game.system.SystemManager;
|
||||
import core.game.system.SystemState;
|
||||
import core.game.world.map.RegionManager;
|
||||
import core.gui.ConsoleTab;
|
||||
import rs09.Server;
|
||||
import rs09.ServerConstants;
|
||||
import rs09.game.world.GameWorld;
|
||||
import rs09.game.world.repository.Repository;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
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.
|
||||
*
|
||||
* @author Emperor
|
||||
*/
|
||||
public class StatisticsTab extends ConsoleTab {
|
||||
|
||||
/**
|
||||
* The serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 6164020580271944550L;
|
||||
|
||||
/**
|
||||
* The queue size.
|
||||
*/
|
||||
public static final int QUEUE_SIZE = 1 << 16;
|
||||
|
||||
/**
|
||||
* The performance data queue.
|
||||
*/
|
||||
private static short[] performanceQueue = new short[QUEUE_SIZE];
|
||||
|
||||
/**
|
||||
* The memory data queue.
|
||||
*/
|
||||
private static short[] memoryQueue = new short[QUEUE_SIZE];
|
||||
|
||||
/**
|
||||
* The current index of the performance queue.
|
||||
*/
|
||||
private static int queueIndex = 0;
|
||||
|
||||
/**
|
||||
* The current statistics zoom.
|
||||
*/
|
||||
private static int statisticsZoom = 5;
|
||||
|
||||
/**
|
||||
* The singleton.
|
||||
*/
|
||||
public static final StatisticsTab INSTANCE = new StatisticsTab();
|
||||
|
||||
/**
|
||||
* The statistics mouse coordinates.
|
||||
*/
|
||||
private Point statisticMousePoint = null;
|
||||
|
||||
/**
|
||||
* The zoom in button.
|
||||
*/
|
||||
private JButton zoomIn;
|
||||
|
||||
/**
|
||||
* The zoom out button.
|
||||
*/
|
||||
private JButton zoomOut;
|
||||
|
||||
/**
|
||||
* The reset button.
|
||||
*/
|
||||
private JButton resetButton;
|
||||
|
||||
/**
|
||||
* The save log button.
|
||||
*/
|
||||
private JButton saveLogButton;
|
||||
|
||||
/**
|
||||
* The shutdown button.
|
||||
*/
|
||||
private JButton shutdown;
|
||||
|
||||
/**
|
||||
* The file chooser instance.
|
||||
*/
|
||||
private JFileChooser fileChooser;
|
||||
|
||||
/**
|
||||
* If the tool tip is currently opened.
|
||||
*/
|
||||
private boolean toolTipOpened;
|
||||
|
||||
/**
|
||||
* The world statistics text pane.
|
||||
*/
|
||||
private StatsTextPane worldStatistics;
|
||||
|
||||
/**
|
||||
* The thread statistics text pane.
|
||||
*/
|
||||
private StatsTextPane threadStatistics;
|
||||
|
||||
/**
|
||||
* The working time of the main thread.
|
||||
*/
|
||||
private static long workingTime;
|
||||
|
||||
/**
|
||||
* The maximum amount of players being active at the same time.
|
||||
*/
|
||||
private static int maximumPlayers;
|
||||
|
||||
/**
|
||||
* The text area.
|
||||
*/
|
||||
private final JTextArea console = new JTextArea();
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code StatisticsTab} {@Code Object}
|
||||
*/
|
||||
public StatisticsTab() {
|
||||
super("Statistics");
|
||||
setLayout(null);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setBackground(UIManager.getColor("Button.background"));
|
||||
scrollPane.setBounds(6, 403, 1042, 189);
|
||||
scrollPane.setBorder(new TitledBorder(null, "Console", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
add(scrollPane);
|
||||
|
||||
console.setLineWrap(true);
|
||||
console.setBackground(UIManager.getColor("CheckBox.background"));
|
||||
console.setEditable(false);
|
||||
scrollPane.setViewportView(console);
|
||||
|
||||
JLabel label = new JLabel();
|
||||
label.setBounds(450, 345, 163, 16);
|
||||
add(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTipText(MouseEvent e) {
|
||||
if (e.getX() > getWidth() / 2 && e.getX() < getWidth()
|
||||
&& e.getY() > 2 && e.getY() < getHeight() / 2) {
|
||||
int max = (getWidth() / 2) / statisticsZoom;
|
||||
int index = queueIndex - (max - (e.getX() - (getWidth() / 2)) / statisticsZoom);
|
||||
toolTipOpened = true;
|
||||
if (index < 0) {
|
||||
return "Tick: null, time: null.";
|
||||
}
|
||||
return new StringBuilder("Tick: ").append(index).append(", time: ").append(performanceQueue[index] + 600).append(".").toString();
|
||||
}
|
||||
toolTipOpened = false;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getToolTipLocation(MouseEvent e) {
|
||||
if (e.getX() > getWidth() / 2 && e.getX() < getWidth()
|
||||
&& e.getY() > 2 && e.getY() < getHeight() / 2) {
|
||||
return new Point(e.getX() + 15, e.getY() + 10);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
drawPerformanceStatistics(this, g);
|
||||
}
|
||||
|
||||
/**
|
||||
* Positions the components.
|
||||
*/
|
||||
public void positionComponents() {
|
||||
int init = 90;
|
||||
int diff = 5;
|
||||
zoomIn.setLocation(getWidth() / 2 - (zoomIn.getWidth() / 2) - diff, 5 + init);
|
||||
zoomOut.setLocation(getWidth() / 2 - (zoomOut.getWidth() / 2) - diff, 30 + init);
|
||||
resetButton.setLocation(getWidth() / 2 - (resetButton.getWidth() / 2) - diff, 55 + init);
|
||||
saveLogButton.setLocation(getWidth() / 2 - (saveLogButton.getWidth() / 2) - diff, 80 + init);
|
||||
shutdown.setLocation(getWidth() / 2 - (shutdown.getWidth() / 2), 310);
|
||||
worldStatistics.setLocation(55, 310);
|
||||
threadStatistics.setLocation(shutdown.getX() + shutdown.getWidth() + 35, 310);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the server info tab.
|
||||
*
|
||||
* @return This instance.
|
||||
*/
|
||||
public StatisticsTab init() {
|
||||
initMaximumPlayers();
|
||||
fileChooser = new JFileChooser("./");
|
||||
zoomIn = new JButton("+");
|
||||
zoomIn.setLayout(null);
|
||||
zoomIn.setVisible(true);
|
||||
zoomIn.setSize(50, 20);
|
||||
zoomIn.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
zoomOut.setEnabled(true);
|
||||
if (++statisticsZoom > 20) {
|
||||
statisticsZoom = 20;
|
||||
zoomIn.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
drawPerformanceStatistics(StatisticsTab.this, getGraphics());
|
||||
}
|
||||
});
|
||||
zoomOut = new JButton("-");
|
||||
zoomOut.setLayout(null);
|
||||
zoomOut.setVisible(true);
|
||||
zoomOut.setSize(50, 20);
|
||||
zoomOut.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
zoomIn.setEnabled(true);
|
||||
if (--statisticsZoom < 2) {
|
||||
statisticsZoom = 2;
|
||||
zoomOut.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
drawPerformanceStatistics(StatisticsTab.this, getGraphics());
|
||||
}
|
||||
});
|
||||
resetButton = new JButton("x");
|
||||
resetButton.setLayout(null);
|
||||
resetButton.setVisible(true);
|
||||
resetButton.setSize(50, 20);
|
||||
resetButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
queueIndex = 0;
|
||||
}
|
||||
});
|
||||
saveLogButton = new JButton("", createImageIcon("Save16.gif"));
|
||||
saveLogButton.setLayout(null);
|
||||
saveLogButton.setVisible(true);
|
||||
saveLogButton.setSize(50, 20);
|
||||
saveLogButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int returnVal = fileChooser.showSaveDialog(StatisticsTab.this);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fileChooser.getSelectedFile();
|
||||
if (!file.getName().contains(".")) {
|
||||
file = new File(file.getPath() + ".txt");
|
||||
}
|
||||
logQueues(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
add(resetButton);
|
||||
add(zoomIn);
|
||||
add(zoomOut);
|
||||
add(saveLogButton);
|
||||
shutdown = new JButton("Shutdown");
|
||||
shutdown.setLayout(null);
|
||||
shutdown.setVisible(true);
|
||||
shutdown.setSize(100, 20);
|
||||
shutdown.addActionListener(e -> SystemManager.flag(SystemState.TERMINATED));
|
||||
add(shutdown);
|
||||
worldStatistics = new StatsTextPane().init();
|
||||
worldStatistics.setSize(390, 90);
|
||||
add(worldStatistics);
|
||||
updateWorldText();
|
||||
threadStatistics = new StatsTextPane().init();
|
||||
threadStatistics.setSize(390, 90);
|
||||
add(threadStatistics);
|
||||
updateThreadText();
|
||||
setLayout(null);
|
||||
setVisible(true);
|
||||
ToolTipManager.sharedInstance().setInitialDelay(0);
|
||||
positionComponents();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the maximum players count.
|
||||
*/
|
||||
private static void initMaximumPlayers() {
|
||||
setMaximumPlayers(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum amount of players.
|
||||
*
|
||||
* @param maximum The maximum.
|
||||
*/
|
||||
private static void setMaximumPlayers(int maximum) {
|
||||
maximumPlayers = maximum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the queues.
|
||||
*
|
||||
* @param file The file to log to.
|
||||
*/
|
||||
protected static void logQueues(File file) {
|
||||
try (BufferedWriter bw = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8, StandardOpenOption.APPEND)) {
|
||||
bw.append("/////////////////////////////////////////////////////////////////////////");
|
||||
bw.newLine();
|
||||
bw.append("/////////////////////////////////////////////////////////////////////////");
|
||||
bw.newLine();
|
||||
// bw.append("// " + CalenderDate.getFormattedDate() + " performance log results:");
|
||||
bw.newLine();
|
||||
bw.append("/////////////////////////////////////////////////////////////////////////");
|
||||
bw.newLine();
|
||||
for (int i = 0; i < queueIndex; i++) {
|
||||
bw.append(new StringBuilder("performance_report:memory_usage-[tick=").append(i).append(", mem=").append(memoryQueue[i]).append("mb]."));
|
||||
bw.newLine();
|
||||
}
|
||||
for (int i = 0; i < queueIndex; i++) {
|
||||
int value = 600 + performanceQueue[i];
|
||||
bw.append(new StringBuilder("performance_report:clock_speed-[tick=").append(i).append(", time=").append(value).append(", status=").append(value < 601 ? "NORMAL]." : "DELAYED]."));
|
||||
bw.newLine();
|
||||
}
|
||||
bw.append("/////////////////////////////////////////////////////////////////////////");
|
||||
bw.newLine();
|
||||
bw.flush();
|
||||
bw.close();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an image icon.
|
||||
*
|
||||
* @param path The path of the image file.
|
||||
* @return The image icon.
|
||||
*/
|
||||
private static ImageIcon createImageIcon(String path) {
|
||||
URL imgURL = StatisticsTab.class.getResource(path);
|
||||
if (imgURL != null) {
|
||||
return new ImageIcon(imgURL);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports the performance value.
|
||||
*
|
||||
* @param value The value.
|
||||
*/
|
||||
public static void reportPerformance(int value) {
|
||||
if (value >= Short.MAX_VALUE) {
|
||||
value = Short.MAX_VALUE - 1;
|
||||
}
|
||||
secureQueues();
|
||||
performanceQueue[queueIndex] = (short) value;
|
||||
memoryQueue[queueIndex++] = (short) ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1_000_000);
|
||||
INSTANCE.repaint();
|
||||
workingTime += (600 + value);
|
||||
if (INSTANCE.threadStatistics != null) {
|
||||
INSTANCE.updateThreadText();
|
||||
if ((GameWorld.getTicks() % 10) == 0) {
|
||||
INSTANCE.updateWorldText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the thread statistics text.
|
||||
*/
|
||||
public void updateThreadText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
long runtime = System.currentTimeMillis() - Server.startTime;
|
||||
double percentage = workingTime / (runtime * 0.01);
|
||||
long hours = runtime / 3600000;
|
||||
runtime -= hours * 3600000;
|
||||
long minutes = runtime / 60000;
|
||||
runtime -= minutes * 60000;
|
||||
long seconds = runtime / 1000;
|
||||
sb.append("Runtime: ").append(hours).append("h ").append(minutes).append("m ").append(seconds).append("s").append(" - ").append(GameWorld.getTicks()).append(" ticks").append("\n");
|
||||
sb.append("Working time: ").append(workingTime).append("ms").append(" - ").append(String.format("%.2f", percentage)).append("%").append("\n");
|
||||
sb.append("Average cycle: ").append(String.format("%.1f", (double) workingTime / GameWorld.getTicks())).append("ms").append("\n");
|
||||
threadStatistics.setText(sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the world statistics text.
|
||||
*/
|
||||
public void updateWorldText() {
|
||||
int players = Repository.getPlayers().size();
|
||||
if (players > getMaximumPlayers()) {
|
||||
setMaximumPlayers(players);
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Players: ").append(players).append(", max: ").append(getMaximumPlayers()).append("\n");
|
||||
sb.append("NPCs: ").append(Repository.getNpcs().size()).append("\n");
|
||||
sb.append("Regions: ").append(RegionManager.getRegionCache().size()).append("\n");
|
||||
sb.append("Ground items: ").append(GroundItemManager.getItems().size()).append("\n");
|
||||
worldStatistics.setText(sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the performance statistics.
|
||||
*
|
||||
* @param c The component.
|
||||
* @param g The graphics.
|
||||
*/
|
||||
private static void drawPerformanceStatistics(Component c, Graphics g) {
|
||||
int x = c.getWidth() / 2 + 48;
|
||||
int y = c.getHeight() / 2;
|
||||
|
||||
Point zero = new Point(x, y / 2);
|
||||
g.setColor(Color.LIGHT_GRAY);
|
||||
|
||||
//Fill the background rectangle.
|
||||
g.fillRect(x, 5, c.getWidth() - 4 - x, y - 5);
|
||||
g.setColor(Color.GRAY);
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < c.getWidth() - 4 - x; i += statisticsZoom) {
|
||||
g.drawLine((int) (zero.getX() + i), 5,
|
||||
(int) (zero.getX() + i), y - 1);
|
||||
count++;
|
||||
}
|
||||
|
||||
int space = (y / 2 - 10) / 4;
|
||||
g.setFont(new Font(null, Font.PLAIN, 9));
|
||||
for (int i = 0; i < 5; i++) {
|
||||
g.setColor(i == 0 ? Color.BLACK : Color.GRAY);
|
||||
g.drawLine(x, (int) zero.getY() - (space * i), c.getWidth() - 5, (int) zero.getY() - (space * i));
|
||||
g.drawLine(x, (int) zero.getY() + (space * i), c.getWidth() - 5, (int) zero.getY() + (space * i));
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawString("" + (i * 150), x - 18, (int) zero.getY() - (space * i) + 2);
|
||||
if (i != 0) {
|
||||
g.drawString("-" + (i * 150), x - 20, (int) zero.getY() + (space * i) + 2);
|
||||
}
|
||||
}
|
||||
g.setColor(Color.GREEN);
|
||||
for (int i = 1; i < count; i++) {
|
||||
int index = queueIndex - i;
|
||||
if (index < 1) {
|
||||
break;
|
||||
}
|
||||
int fromPoint = performanceQueue[index];
|
||||
int fromX = (count - i) * statisticsZoom;
|
||||
int fromY = (int) (-fromPoint / (600D / (space * 4)));
|
||||
int toPoint = index == 0 ? 0 : performanceQueue[index - 1];
|
||||
int toX = (count - i - 1) * statisticsZoom;
|
||||
int toY = (int) (-toPoint / (600D / (space * 4)));
|
||||
if (fromY < 0) {
|
||||
g.setColor(Color.RED);
|
||||
}
|
||||
g.drawLine((int) (zero.getX() + fromX), (int) (zero.getY() + fromY),
|
||||
(int) (zero.getX() + toX), (int) (zero.getY() + toY));
|
||||
if (fromY >= 0) {
|
||||
g.setColor(Color.GREEN);
|
||||
}
|
||||
}
|
||||
g.setColor(Color.BLACK);
|
||||
//Draw vertical line.
|
||||
g.drawLine(x, y + 4, x, 1);
|
||||
Point p = ((StatisticsTab) c).statisticMousePoint;
|
||||
if (p != null) {
|
||||
g.setColor(new Color(251, 230, 130));
|
||||
g.fillRoundRect((int) (p.getX() + 10), (int) (p.getY() - 10), 100, 50, 10, 10);
|
||||
}
|
||||
if (((StatisticsTab) c).toolTipOpened) {
|
||||
((StatisticsTab) c).setToolTipText("test");
|
||||
}
|
||||
drawMemoryStatistics(c, g);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the performance statistics.
|
||||
*
|
||||
* @param c The component.
|
||||
* @param g The graphics.
|
||||
*/
|
||||
private static void drawMemoryStatistics(Component c, Graphics g) {
|
||||
int x = 5;
|
||||
int y = c.getHeight() / 2;
|
||||
int endX = (c.getWidth() / 2) - 48;
|
||||
|
||||
Point zero = new Point(x + 18, y);
|
||||
g.setColor(Color.LIGHT_GRAY);
|
||||
|
||||
//Fill the background rectangle.
|
||||
g.fillRect((int) zero.getX(), 5, endX - x, y - 5);
|
||||
g.setColor(Color.GRAY);
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < endX - x; i += statisticsZoom) {
|
||||
g.drawLine((int) (zero.getX() + i), 5,
|
||||
(int) (zero.getX() + i), y - 1);
|
||||
count++;
|
||||
}
|
||||
|
||||
int space = (y) / 10;
|
||||
g.setFont(new Font(null, Font.PLAIN, 9));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
g.setColor(Color.GRAY);
|
||||
g.drawLine((int) zero.getX() - 2, (int) zero.getY() - (space * i), endX + 17, (int) zero.getY() - (space * i));
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawString("" + (i * 100), 2, (int) zero.getY() - (space * i) + 2);
|
||||
}
|
||||
g.setColor(Color.BLUE);
|
||||
for (int i = 1; i < count; i++) {
|
||||
int index = queueIndex - i;
|
||||
if (index < 1) {
|
||||
break;
|
||||
}
|
||||
int fromPoint = memoryQueue[index];
|
||||
int fromX = (count - i) * statisticsZoom;
|
||||
int fromY = (int) (fromPoint / (900D / (space * 10)));
|
||||
int toPoint = index == 0 ? 0 : memoryQueue[index - 1];
|
||||
int toX = (count - i - 1) * statisticsZoom;
|
||||
int toY = (int) (toPoint / (900D / (space * 10)));
|
||||
if (fromY < 0) {
|
||||
g.setColor(Color.RED);
|
||||
}
|
||||
g.drawLine((int) (zero.getX() + fromX), (int) (zero.getY() - fromY),
|
||||
(int) (zero.getX() + toX), (int) (zero.getY() - toY));
|
||||
if (fromY < 0) {
|
||||
g.setColor(Color.GREEN);
|
||||
}
|
||||
}
|
||||
g.setColor(Color.BLACK);
|
||||
//Draw horizontal line.
|
||||
g.drawLine((int) (zero.getX() - 4), (int) zero.getY(), endX + 21, (int) zero.getY());
|
||||
//Draw vertical line.
|
||||
g.drawLine((int) zero.getX(), (int) zero.getY() + 4, (int) zero.getX(), 1);
|
||||
Point p = ((StatisticsTab) c).statisticMousePoint;
|
||||
if (p != null) {
|
||||
g.setColor(new Color(251, 230, 130));
|
||||
g.fillRoundRect((int) (p.getX() + 10), (int) (p.getY() - 10), 100, 50, 10, 10);
|
||||
}
|
||||
if (((StatisticsTab) c).toolTipOpened) {
|
||||
((StatisticsTab) c).setToolTipText("test");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Secures the queues.
|
||||
*/
|
||||
private static void secureQueues() {
|
||||
if (queueIndex >= QUEUE_SIZE) {
|
||||
int lagSpikes = 0;
|
||||
int memoryUsageSpikes = 0;
|
||||
@SuppressWarnings("unused")
|
||||
int totalMemory = 0;
|
||||
@SuppressWarnings("unused")
|
||||
int totalCycleTime = 0;
|
||||
//Start at tick 500, the JVM has to "warm up" first.
|
||||
for (int i = 500; i < QUEUE_SIZE; i++) {
|
||||
if (performanceQueue[i] > 0) { //Anything above 0 (-600 + 600) = lag
|
||||
lagSpikes++;
|
||||
}
|
||||
if (memoryQueue[i] > 700) { //Over 700Mb
|
||||
memoryUsageSpikes++;
|
||||
}
|
||||
totalMemory += memoryQueue[i];
|
||||
totalCycleTime += performanceQueue[i];
|
||||
}
|
||||
if (lagSpikes > 350 || memoryUsageSpikes > 350) {
|
||||
logQueues(new File(ServerConstants.LOGS_PATH + "/system/Performance-log.txt"));
|
||||
}
|
||||
//System.out.println("Average cycle time: " + (600 + (totalCycleTime / (QUEUE_SIZE - 500))) + "ms.");
|
||||
//System.out.println("Average memory usage: " + (totalMemory / (QUEUE_SIZE - 500)) + "Mb.");
|
||||
queueIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message to the console.
|
||||
*
|
||||
* @param message the message.
|
||||
*/
|
||||
public void log(String message) {
|
||||
console.append(message + "\n");
|
||||
console.setCaretPosition(console.getDocument().getLength());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the statistics zoom.
|
||||
*
|
||||
* @param pixels The amount of pixels.
|
||||
*/
|
||||
public static void setStatisticsZoom(int pixels) {
|
||||
statisticsZoom = pixels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the workingTime.
|
||||
*
|
||||
* @return The workingTime.
|
||||
*/
|
||||
public static long getWorkingTime() {
|
||||
return workingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the workingTime.
|
||||
*
|
||||
* @param workingTime The workingTime to set.
|
||||
*/
|
||||
public static void setWorkingTime(long workingTime) {
|
||||
StatisticsTab.workingTime = workingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximumPlayers.
|
||||
*
|
||||
* @return The maximumPlayers.
|
||||
*/
|
||||
public static int getMaximumPlayers() {
|
||||
return maximumPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the statistics tab text pane.
|
||||
*
|
||||
* @author Emperor
|
||||
*/
|
||||
public final class StatsTextPane extends JTextPane {
|
||||
|
||||
/**
|
||||
* The serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 664276151176087663L;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code StatsTextPane} {@code Object}.
|
||||
*/
|
||||
public StatsTextPane() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the stats text pane.
|
||||
*
|
||||
* @return The stats text pane.
|
||||
*/
|
||||
public StatsTextPane init() {
|
||||
setEditable(false);
|
||||
setLayout(null);
|
||||
Font font = new Font("Monospaced", Font.PLAIN, 12);
|
||||
setFont(font);
|
||||
super.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
||||
super.setVisible(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,600 +0,0 @@
|
||||
package core.gui.tab;
|
||||
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.info.PlayerDetails;
|
||||
import core.game.node.entity.player.info.Rights;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.system.task.TaskExecutor;
|
||||
import core.gui.ConsoleFrame;
|
||||
import core.gui.ConsoleTab;
|
||||
import core.tools.PlayerLoader;
|
||||
import core.tools.StringUtils;
|
||||
import kotlin.Unit;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Handles the utility programs.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public final class UtilityTab extends ConsoleTab {
|
||||
/**
|
||||
* The {@link Logger} instance.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger(UtilityTab.class.getName());
|
||||
/**
|
||||
* The utility tab.
|
||||
*/
|
||||
private static final UtilityTab INSTANCE = new UtilityTab();
|
||||
|
||||
/**
|
||||
* The serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = -4962790192758757624L;
|
||||
|
||||
/**
|
||||
* The list of players.
|
||||
*/
|
||||
private final List<Player> players = new ArrayList<>(20);
|
||||
|
||||
/**
|
||||
* The mapping of ips & their users.
|
||||
*/
|
||||
private final Map<String, List<String>> IPS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The mapping of macs & their users.
|
||||
*/
|
||||
private final Map<String, List<String>> MACS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The mapping of comp names & their users.
|
||||
*/
|
||||
private final Map<String, List<String>> COMPS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The players loaded list.
|
||||
*/
|
||||
private final JLabel lblPlayersLoaded = new JLabel("Players loaded: ");
|
||||
|
||||
/**
|
||||
* If the map is being populated.
|
||||
*/
|
||||
private boolean populating;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code UtilityTab} {@Code Object}
|
||||
*/
|
||||
public UtilityTab() {
|
||||
super("Utilities");
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "Resolvers & Trackers", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBackground(UIManager.getColor("Button.background"));
|
||||
panel.setBounds(18, 98, 152, 219);
|
||||
add(panel);
|
||||
panel.setLayout(null);
|
||||
JButton btnResolveIp = new JButton("Resolve Ip");
|
||||
btnResolveIp.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
resolve(IPS);
|
||||
}
|
||||
});
|
||||
btnResolveIp.setBounds(17, 28, 117, 29);
|
||||
panel.add(btnResolveIp);
|
||||
|
||||
JButton btnResolveMac = new JButton("Resolve Mac");
|
||||
btnResolveMac.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
resolve(MACS);
|
||||
}
|
||||
});
|
||||
btnResolveMac.setBounds(17, 69, 117, 29);
|
||||
panel.add(btnResolveMac);
|
||||
|
||||
JButton btnResolveCompName = new JButton("Resolve Comp");
|
||||
btnResolveCompName.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
resolve(COMPS);
|
||||
}
|
||||
});
|
||||
btnResolveCompName.setBounds(17, 110, 117, 29);
|
||||
panel.add(btnResolveCompName);
|
||||
|
||||
JButton btnPopulateMaps = new JButton("Populate Maps");
|
||||
btnPopulateMaps.addActionListener(e -> {
|
||||
populateList();
|
||||
JOptionPane.showMessageDialog(null, "Finished populating maps!");
|
||||
});
|
||||
btnPopulateMaps.setBounds(405, 32, 236, 29);
|
||||
add(btnPopulateMaps);
|
||||
|
||||
JLabel lblMustBeDone = new JLabel("MUST BE DONE BEFORE RUNNING TOOLS");
|
||||
lblMustBeDone.setBounds(390, 6, 379, 16);
|
||||
add(lblMustBeDone);
|
||||
|
||||
lblPlayersLoaded.setBounds(460, 61, 157, 16);
|
||||
add(lblPlayersLoaded);
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_1.setLayout(null);
|
||||
panel_1.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Wealth & Items", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel_1.setBackground(UIManager.getColor("Button.background"));
|
||||
panel_1.setBounds(182, 98, 145, 219);
|
||||
add(panel_1);
|
||||
|
||||
JButton btnWealthScanner = new JButton("Wealth Scanner");
|
||||
btnWealthScanner.addActionListener(e -> wealthScanner());
|
||||
btnWealthScanner.setBounds(6, 29, 129, 29);
|
||||
panel_1.add(btnWealthScanner);
|
||||
|
||||
JButton btnItemScanner = new JButton("Item Scanner");
|
||||
btnItemScanner.addActionListener(e -> itemScanner());
|
||||
btnItemScanner.setBounds(6, 69, 129, 29);
|
||||
panel_1.add(btnItemScanner);
|
||||
|
||||
JPanel panel_2 = new JPanel();
|
||||
panel_2.setLayout(null);
|
||||
panel_2.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Player Utils", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel_2.setBackground(UIManager.getColor("Button.background"));
|
||||
panel_2.setBounds(345, 98, 145, 219);
|
||||
add(panel_2);
|
||||
|
||||
JButton btnStaffChecker = new JButton("Staff Scanner");
|
||||
btnStaffChecker.addActionListener(e -> staffScanner());
|
||||
btnStaffChecker.setBounds(6, 29, 129, 29);
|
||||
panel_2.add(btnStaffChecker);
|
||||
|
||||
JPanel panel_3 = new JPanel();
|
||||
panel_3.setLayout(null);
|
||||
panel_3.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Security", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel_3.setBackground(UIManager.getColor("Button.background"));
|
||||
panel_3.setBounds(502, 98, 145, 219);
|
||||
add(panel_3);
|
||||
|
||||
JButton btnMacViewer = new JButton("Mac Viewer");
|
||||
btnMacViewer.addActionListener(e -> viewMacs());
|
||||
btnMacViewer.setBounds(6, 29, 129, 29);
|
||||
panel_3.add(btnMacViewer);
|
||||
|
||||
JButton btnMacRemover = new JButton("Mac Remover");
|
||||
btnMacRemover.addActionListener(e -> removeMac());
|
||||
btnMacRemover.setBounds(6, 64, 129, 29);
|
||||
panel_3.add(btnMacRemover);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a mac.
|
||||
*/
|
||||
public void removeMac() {
|
||||
String mac = JOptionPane.showInputDialog("Enter address:");
|
||||
if (mac == null || mac.length() <= 1) {
|
||||
JOptionPane.showMessageDialog(null, "Error! Nothing entered.");
|
||||
return;
|
||||
}
|
||||
// if (SystemManager.getSecurity().isBanned(mac)) {
|
||||
// SystemManager.getSecurity().remove(mac);
|
||||
// JOptionPane.showMessageDialog(null, "Removed the mac - " + mac + "!");
|
||||
// } else {
|
||||
// JOptionPane.showMessageDialog(null, "Error! Couldn't find mac in system manager.");
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Views the banned macs.
|
||||
*/
|
||||
public void viewMacs() {
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
JScrollPane pane = new JScrollPane();
|
||||
DefaultListModel<String> model = new DefaultListModel<String>();
|
||||
JList<String> list = new JList<String>();
|
||||
// for (String i : SystemManager.getSecurity().getBannedAddresses()) {
|
||||
// if (i == null) {
|
||||
// continue;
|
||||
// }
|
||||
// model.addElement(i.toString());
|
||||
// }
|
||||
list.setModel(model);
|
||||
pane.setViewportView(list);
|
||||
panel.add(pane);
|
||||
JOptionPane.showConfirmDialog(null, panel, "Banned Addresses", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wealth scanner.
|
||||
*/
|
||||
public void wealthScanner() {
|
||||
String args = JOptionPane.showInputDialog("Enter item id:");
|
||||
int id = -1;
|
||||
if (args != null && args.length() > 0) {
|
||||
try {
|
||||
id = Integer.parseInt(args);
|
||||
} catch (NumberFormatException e) {
|
||||
id = -1;
|
||||
logger.log(Level.WARNING, "Error in wealth scanner, number exception!");
|
||||
}
|
||||
}
|
||||
List<String> data = wealthScanner(id);
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
JScrollPane pane = new JScrollPane();
|
||||
DefaultListModel<String> model = new DefaultListModel<String>();
|
||||
JList<String> list = new JList<String>();
|
||||
for (String i : data) {
|
||||
if (i == null) {
|
||||
continue;
|
||||
}
|
||||
model.addElement(i.toString());
|
||||
}
|
||||
list.setModel(model);
|
||||
pane.setViewportView(list);
|
||||
panel.add(pane);
|
||||
JOptionPane.showConfirmDialog(null, panel, "Wealth Scanner", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wealth scanner.
|
||||
*/
|
||||
public List<String> wealthScanner(int itemId) {
|
||||
Item item = null;
|
||||
if (itemId != -1) {
|
||||
item = new Item(itemId);
|
||||
}
|
||||
Object[][] mostWealthy = new Object[50][2];
|
||||
int player = 0;
|
||||
long count = 0;
|
||||
for (Player p : players) {
|
||||
if (p.getDetails().getRights() == Rights.PLAYER_MODERATOR) {
|
||||
continue;
|
||||
}
|
||||
if (item != null) {
|
||||
long old = count;
|
||||
count += p.getInventory().getAmount(item);
|
||||
count += p.getEquipment().getAmount(item);
|
||||
count += p.getBank().getAmount(item);
|
||||
if (old != count) {
|
||||
player++;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < mostWealthy.length; i++) {
|
||||
Long value = (Long) mostWealthy[i][0];
|
||||
if (value == null || value < p.getMonitor().getNetworth()) {
|
||||
for (int j = mostWealthy.length - 1; j > i; j--) {
|
||||
mostWealthy[j] = mostWealthy[j - 1];
|
||||
}
|
||||
mostWealthy[i] = new Object[2];
|
||||
mostWealthy[i][0] = p.getMonitor().getNetworth();
|
||||
mostWealthy[i][1] = p.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> formats = new ArrayList<>(20);
|
||||
for (int i = mostWealthy.length - 1; i >= 0; i--) {
|
||||
Object[] info = mostWealthy[i];
|
||||
if (info != null && info[0] != null) {
|
||||
formats.add(i + ": " + info[1] + " - " + NumberFormat.getNumberInstance(Locale.US).format((Long) info[0]) + " coins.");
|
||||
}
|
||||
}
|
||||
if (item != null) {
|
||||
formats.add(NumberFormat.getNumberInstance(Locale.US).format(count) + " occurrences of item " + item.getName() + " (id=" + item.getId() + ") by " + player + " players!");
|
||||
}
|
||||
return formats;
|
||||
}
|
||||
|
||||
/**
|
||||
* The item scanner.
|
||||
*/
|
||||
public void itemScanner() {
|
||||
String args = JOptionPane.showInputDialog("Enter item id:");
|
||||
Item item = new Item(11694);
|
||||
if (args != null && args.length() > 0) {
|
||||
try {
|
||||
item = new Item(Integer.parseInt(args));
|
||||
} catch (NumberFormatException e) {
|
||||
item = new Item(11694);
|
||||
logger.log(Level.WARNING, "Error in wealth scanner, number exception!");
|
||||
}
|
||||
}
|
||||
List<String> formats = itemScanner(item);
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
JScrollPane pane = new JScrollPane();
|
||||
DefaultListModel<String> model = new DefaultListModel<String>();
|
||||
JList<String> list = new JList<String>();
|
||||
for (String i : formats) {
|
||||
if (i == null) {
|
||||
continue;
|
||||
}
|
||||
model.addElement(i.toString());
|
||||
}
|
||||
list.setModel(model);
|
||||
pane.setViewportView(list);
|
||||
panel.add(pane);
|
||||
JOptionPane.showConfirmDialog(null, panel, "Item Scanner", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans for items in the eco.
|
||||
*/
|
||||
public List<String> itemScanner(Item item) {
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
for (Player p : players) {
|
||||
List<core.game.container.Container> containers = new ArrayList<>(20);
|
||||
containers.add(p.getInventory());
|
||||
containers.add(p.getBank());
|
||||
containers.add(p.getEquipment());
|
||||
int amount = 0;
|
||||
for (core.game.container.Container container : containers) {
|
||||
Item i = container.getItem(item);
|
||||
if (i != null) {
|
||||
amount += i.getAmount();
|
||||
}
|
||||
}
|
||||
if (amount > 0) {
|
||||
map.put(p.getName(), amount);
|
||||
}
|
||||
}
|
||||
List<String> formats = new ArrayList<>(20);
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
formats.add("Player name=" + entry.getKey() + ", contained a total of " + entry.getValue() + " " + item.getName() + ".");
|
||||
}
|
||||
if (formats.size() == 0) {
|
||||
formats.add("There were no occurrences of " + item + ".");
|
||||
}
|
||||
return formats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the address.
|
||||
*
|
||||
* @param map the map.
|
||||
*/
|
||||
public void resolve(Map<String, List<String>> map) {
|
||||
String address = JOptionPane.showInputDialog("Enter the address.");
|
||||
List<String> names = resolve(map, address, false);
|
||||
String string = "No names found registered with that address!";
|
||||
if (names == null) {
|
||||
JOptionPane.showMessageDialog(null, string);
|
||||
} else {
|
||||
string = "Names:" + Arrays.toString(names.toArray());
|
||||
JOptionPane.showMessageDialog(null, string);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves & tracks an adddress.
|
||||
*
|
||||
* @param map the map.
|
||||
* @param value the value.
|
||||
* @param name if the name or not.
|
||||
* @return the names resolved.
|
||||
*/
|
||||
public List<String> resolve(Map<String, List<String>> map, String value, boolean name) {
|
||||
List<String> names = null;
|
||||
String address = !name ? value : "";
|
||||
if (name) {
|
||||
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
||||
for (String s : entry.getValue()) {
|
||||
if (s.equals(value)) {
|
||||
address = entry.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
names = map.get(address);
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mapping.
|
||||
*
|
||||
* @param id the id.
|
||||
* @return the map.
|
||||
*/
|
||||
public Map<String, List<String>> getMap(int id) {
|
||||
return id == 1 ? IPS : id == 2 ? MACS : COMPS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the lists.
|
||||
*/
|
||||
public void populateList() {
|
||||
if (populating) {
|
||||
return;
|
||||
}
|
||||
populating = true;
|
||||
players.clear();
|
||||
TaskExecutor.execute(() -> {
|
||||
Thread.currentThread().setName("Utility Tab");
|
||||
ConsoleFrame.getInstance().getPlayerTab().getPlayerNames().clear();
|
||||
ConsoleFrame.getInstance().getPlayerTab().populatePlayerSearch();
|
||||
for (String name : ConsoleFrame.getInstance().getPlayerTab().getPlayerNames()) {
|
||||
Player player = PlayerLoader.getPlayerFile(name);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
PlayerDetails details = player.getDetails();
|
||||
if (details != null) {
|
||||
addAddressToMap(name, details.getIpAddress(), IPS);
|
||||
addAddressToMap(name, details.getMacAddress(), MACS);
|
||||
addAddressToMap(name, details.getCompName(), COMPS);
|
||||
players.add(player);
|
||||
}
|
||||
}
|
||||
populating = false;
|
||||
System.gc();
|
||||
lblPlayersLoaded.setText("Players loaded: " + players.size());
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the staff.
|
||||
*/
|
||||
public void staffScanner() {
|
||||
List<String> staff = new ArrayList<>(20);
|
||||
for (Player player : players) {
|
||||
if (player.getDetails().getRights() != Rights.REGULAR_PLAYER) {
|
||||
staff.add(player.getName() + " - " + StringUtils.formatDisplayName(player.getDetails().getRights().toString()));
|
||||
}
|
||||
}
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
JScrollPane pane = new JScrollPane();
|
||||
DefaultListModel<String> model = new DefaultListModel<String>();
|
||||
JList<String> list = new JList<String>();
|
||||
for (String i : staff) {
|
||||
if (i == null) {
|
||||
continue;
|
||||
}
|
||||
model.addElement(i.toString());
|
||||
}
|
||||
list.setModel(model);
|
||||
pane.setViewportView(list);
|
||||
panel.add(pane);
|
||||
JOptionPane.showConfirmDialog(null, panel, "Staff Scanner", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an address with its names to the map.
|
||||
*
|
||||
* @param name the name.
|
||||
* @param address the address.
|
||||
* @param map the map.
|
||||
*/
|
||||
public void addAddressToMap(String name, String address, Map<String, List<String>> map) {
|
||||
if (address == null) {
|
||||
return;
|
||||
}
|
||||
List<String> names = map.get(address);
|
||||
if (names == null) {
|
||||
names = new ArrayList<String>();
|
||||
}
|
||||
names.add(name);
|
||||
map.put(address, names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a player.
|
||||
*
|
||||
* @param details the details.
|
||||
*/
|
||||
public void delete(PlayerDetails details) {
|
||||
if (details.getRights() == Rights.PLAYER_MODERATOR) {
|
||||
return;
|
||||
}
|
||||
// TODO
|
||||
// Connection connection = SQLManager.getConnection();
|
||||
// PreparedStatement statement;
|
||||
// try {
|
||||
// statement = connection.prepareStatement("DELETE FROM " + "playerdata" + " WHERE " + "" + "username" + "='" + details.getUsername().toLowerCase() + "'");
|
||||
// statement.execute();
|
||||
// statement = connection.prepareStatement("DELETE FROM " + "highscores" + " WHERE " + "" + "username" + "='" + details.getUsername().toLowerCase() + "'");
|
||||
// statement.execute();
|
||||
// } catch (SQLException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// File detailFile = new File(GameConstants.getPlayerDetailsPath() + "/" + details.getUsername() + ".store");
|
||||
// File playerFile = new File(GameConstants.getPlayerSavePath() + "/" + details.getUsername() + ".store");
|
||||
// detailFile.delete();
|
||||
// playerFile.delete();
|
||||
// SQLManager.close(connection);
|
||||
// ConsoleFrame.getInstance().getPlayerTab().getPlayerNames().remove(details.getUsername());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @param name the name.
|
||||
* @return the player.
|
||||
*/
|
||||
public Player getPlayer(String name) {
|
||||
if (players.size() == 0) {
|
||||
populateList();
|
||||
return null;
|
||||
}
|
||||
for (Player p : players) {
|
||||
if (p.getName().equals(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ips.
|
||||
*
|
||||
* @return the ips.
|
||||
*/
|
||||
public Map<String, List<String>> getIps() {
|
||||
return IPS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macs.
|
||||
*
|
||||
* @return the macs.
|
||||
*/
|
||||
public Map<String, List<String>> getMacs() {
|
||||
return MACS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the comps.
|
||||
*
|
||||
* @return the comps.
|
||||
*/
|
||||
public Map<String, List<String>> getComps() {
|
||||
return COMPS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the players.
|
||||
*
|
||||
* @return the players.
|
||||
*/
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the populating.
|
||||
*
|
||||
* @return the populating
|
||||
*/
|
||||
public boolean isPopulating() {
|
||||
return populating;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bapopulating.
|
||||
*
|
||||
* @param populating the populating to set.
|
||||
*/
|
||||
public void setPopulating(boolean populating) {
|
||||
this.populating = populating;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance.
|
||||
*
|
||||
* @return the instance
|
||||
*/
|
||||
public static UtilityTab getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public final class MSEventHandler extends IoEventHandler {
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
SystemLogger.logErr("Failed connecting to Management Server!");
|
||||
SystemLogger.logErr(this.getClass(), "Failed connecting to Management Server!");
|
||||
WorldCommunicator.terminate();
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public final class WorldCommunicator {
|
||||
*/
|
||||
public static void connect() {
|
||||
try {
|
||||
SystemLogger.logInfo("Attempting to connect to management server...");
|
||||
SystemLogger.logInfo(WorldCommunicator.class, "Attempting to connect to management server...");
|
||||
setState(ManagementServerState.CONNECTING);
|
||||
/*if (isLocallyHosted()) {
|
||||
SystemLogger.log("Management server is hosted on local machine!");
|
||||
@@ -82,7 +82,7 @@ public final class WorldCommunicator {
|
||||
//}
|
||||
reactor.start();
|
||||
} catch (Throwable e) {
|
||||
SystemLogger.logErr("Unable to connect to management server");
|
||||
SystemLogger.logErr(WorldCommunicator.class, "Unable to connect to management server");
|
||||
e.printStackTrace();
|
||||
terminate();
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public final class WorldCommunicator {
|
||||
if (WorldCommunicator.state != state) {
|
||||
WorldCommunicator.state = state;
|
||||
state.set();
|
||||
SystemLogger.logInfo("Management server status: " + state + ".");
|
||||
SystemLogger.logInfo(WorldCommunicator.class, "Management server status: " + state + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,9 +97,9 @@ public final class GameReadEvent extends IoReadEvent {
|
||||
IncomingPacket packet = PacketRepository.getIncoming(opcode);
|
||||
session.setLastPing(System.currentTimeMillis());
|
||||
if (packet == null) {
|
||||
SystemLogger.logErr("Unhandled packet [opcode=" + opcode + ", previous=" + last + ", size=" + size + ", header=" + header + "]");
|
||||
SystemLogger.logErr(this.getClass(), "Unhandled packet [opcode=" + opcode + ", previous=" + last + ", size=" + size + ", header=" + header + "]");
|
||||
if (GameWorld.getSettings().isDevMode()) {
|
||||
SystemLogger.logErr("Unhandled packet [opcode=" + opcode + ", previous=" + last + ", size=" + size + ", header=" + header + "]");
|
||||
SystemLogger.logErr(this.getClass(), "Unhandled packet [opcode=" + opcode + ", previous=" + last + ", size=" + size + ", header=" + header + "]");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public final class GameReadEvent extends IoReadEvent {
|
||||
if(header == -3){
|
||||
System.out.println(buffer.remaining());
|
||||
}
|
||||
SystemLogger.logErr("Invalid packet [opcode=" + opcode + ", last=" + last + ", queued=" + usedQueuedBuffer + "], header=" + header+"!");
|
||||
SystemLogger.logErr(this.getClass(), "Invalid packet [opcode=" + opcode + ", last=" + last + ", queued=" + usedQueuedBuffer + "], header=" + header+"!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class HSReadEvent extends IoReadEvent {
|
||||
WorldList.sendUpdate(session, updateStamp);
|
||||
break;
|
||||
default:
|
||||
SystemLogger.logInfo("PKT " + opcode);
|
||||
SystemLogger.logInfo(this.getClass(), "PKT " + opcode);
|
||||
session.disconnect();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public final class MSReadEvent extends IoReadEvent {
|
||||
}
|
||||
return buffer.getShort() & 0xFFFF;
|
||||
}
|
||||
SystemLogger.logErr("Invalid packet [opcode=" + opcode + ", last=" + last + ", queued=" + usedQueuedBuffer + "]!");
|
||||
SystemLogger.logErr(this.getClass(), "Invalid packet [opcode=" + opcode + ", last=" + last + ", queued=" + usedQueuedBuffer + "]!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,20 +36,20 @@ public final class RegistryReadEvent extends IoReadEvent {
|
||||
switch (opcode) {
|
||||
case 0:
|
||||
WorldCommunicator.setState(ManagementServerState.NOT_AVAILABLE);
|
||||
SystemLogger.logErr("Failed registering world to AMS - [id=" + GameWorld.getSettings().getWorldId() + ", cause=World id out of bounds]!");
|
||||
SystemLogger.logErr(this.getClass(), "Failed registering world to AMS - [id=" + GameWorld.getSettings().getWorldId() + ", cause=World id out of bounds]!");
|
||||
break;
|
||||
case 1:
|
||||
session.setProducer(PRODUCER);
|
||||
WorldCommunicator.setState(ManagementServerState.AVAILABLE);
|
||||
SystemLogger.logInfo("Successfully registered world to AMS - [id=" + GameWorld.getSettings().getWorldId() + "]!");
|
||||
SystemLogger.logInfo(this.getClass(), "Successfully registered world to AMS - [id=" + GameWorld.getSettings().getWorldId() + "]!");
|
||||
break;
|
||||
case 2:
|
||||
WorldCommunicator.setState(ManagementServerState.NOT_AVAILABLE);
|
||||
SystemLogger.logErr("Failed registering world to AMS - [id=" + GameWorld.getSettings().getWorldId() + ", cause=World id already in use]!");
|
||||
SystemLogger.logErr(this.getClass(), "Failed registering world to AMS - [id=" + GameWorld.getSettings().getWorldId() + ", cause=World id already in use]!");
|
||||
break;
|
||||
case 3:
|
||||
WorldCommunicator.setState(ManagementServerState.NOT_AVAILABLE);
|
||||
SystemLogger.logErr("Failed registering world to AMS - [id=" + GameWorld.getSettings().getWorldId() + ", cause=Exception in AMS]!");
|
||||
SystemLogger.logErr(this.getClass(), "Failed registering world to AMS - [id=" + GameWorld.getSettings().getWorldId() + ", cause=Exception in AMS]!");
|
||||
break;
|
||||
default:
|
||||
System.out.println("??" + opcode);
|
||||
|
||||
@@ -191,7 +191,7 @@ public final class PacketRepository {
|
||||
if(context.getPlayer().getSession() == null) return;
|
||||
OutgoingPacket p = OUTGOING_PACKETS.get(clazz);
|
||||
if (p == null) {
|
||||
SystemLogger.logErr("Invalid outgoing packet [handler=" + clazz + ", context=" + context + "].");
|
||||
SystemLogger.logErr(PacketRepository.class, "Invalid outgoing packet [handler=" + clazz + ", context=" + context + "].");
|
||||
return;
|
||||
}
|
||||
if(!context.getPlayer().isArtificial()) {
|
||||
|
||||
@@ -8,6 +8,6 @@ import core.net.packet.IoBuffer;
|
||||
public class DummyPacket implements IncomingPacket {
|
||||
@Override
|
||||
public void decode(Player player, int opcode, IoBuffer buffer) {
|
||||
SystemLogger.logInfo("Received opcode " + opcode + " packet.");
|
||||
SystemLogger.logInfo(this.getClass(), "Received opcode " + opcode + " packet.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import core.net.packet.context.PlayerContext;
|
||||
import core.net.packet.out.ClearMinimapFlag;
|
||||
import rs09.ServerConstants;
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import rs09.game.interaction.IntType;
|
||||
import rs09.game.interaction.InteractionListener;
|
||||
import rs09.game.interaction.InteractionListeners;
|
||||
import rs09.game.world.repository.Repository;
|
||||
@@ -196,7 +197,7 @@ public final class InteractionPacket implements IncomingPacket {
|
||||
player.debug("spawn=" + npc.getProperties().getSpawnLocation() + ".");
|
||||
player.debug("Varp ID= " + npc.getDefinition().getConfigId() + " Offset=" + npc.getDefinition().getVarbitOffset() + " Size=" + npc.getDefinition().getVarbitSize());
|
||||
handleAIPLegion(player, 0, optionIndex, index);
|
||||
if(InteractionListeners.run(shown.getId(),2, option.getName(),player,npc)){
|
||||
if(InteractionListeners.run(shown.getId(),IntType.NPC, option.getName(),player,npc)){
|
||||
return;
|
||||
}
|
||||
if(PluginInteractionManager.handle(player,shown,option)){
|
||||
@@ -288,7 +289,7 @@ public final class InteractionPacket implements IncomingPacket {
|
||||
}
|
||||
handleAIPLegion(player, 1, optionIndex, x, y, objectId);
|
||||
|
||||
if(InteractionListeners.run(object.getId(),1, option.getName(),player,object)){
|
||||
if(InteractionListeners.run(object.getId(), IntType.SCENERY, option.getName(),player,object)){
|
||||
return;
|
||||
}
|
||||
if(PluginInteractionManager.handle(player,object)){
|
||||
@@ -320,7 +321,7 @@ public final class InteractionPacket implements IncomingPacket {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InteractionListeners.run(-1, InteractionListener.Companion.getPLAYER(), option.getName().toLowerCase(), player, target)) {
|
||||
if (!InteractionListeners.run(-1, IntType.PLAYER, option.getName().toLowerCase(), player, target)) {
|
||||
handleAIPLegion(player, 2, optionIndex, index);
|
||||
target.getInteraction().handle(player, option);
|
||||
}
|
||||
@@ -357,10 +358,10 @@ public final class InteractionPacket implements IncomingPacket {
|
||||
player.debug("Handled by quest interaction manager.");
|
||||
return;
|
||||
}
|
||||
if(InteractionListeners.run(item.getId(), InteractionListener.Companion.getGROUNDITEM(), option.getName(), player, item)) {
|
||||
if(InteractionListeners.run(item.getId(), IntType.GROUNDITEM, option.getName(), player, item)) {
|
||||
return;
|
||||
}
|
||||
if(InteractionListeners.run(item.getId(), InteractionListener.Companion.getITEM(), option.getName(), player, item)) {
|
||||
if(InteractionListeners.run(item.getId(), IntType.ITEM, option.getName(), player, item)) {
|
||||
return;
|
||||
}
|
||||
item.getInteraction().handle(player, option);
|
||||
|
||||
@@ -16,6 +16,7 @@ import core.net.packet.PacketRepository;
|
||||
import core.net.packet.context.PlayerContext;
|
||||
import core.net.packet.out.ClearMinimapFlag;
|
||||
import org.rs09.consts.Items;
|
||||
import rs09.game.interaction.IntType;
|
||||
import rs09.game.interaction.InteractionListeners;
|
||||
import rs09.game.node.entity.skill.farming.CompostBins;
|
||||
import rs09.game.node.entity.skill.farming.FarmingPatch;
|
||||
@@ -69,7 +70,7 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
if(PluginInteractionManager.handle(player,event)){
|
||||
return;
|
||||
}
|
||||
if(InteractionListeners.run(item,npc,2,player)){
|
||||
if(InteractionListeners.run(item,npc,IntType.NPC,player)){
|
||||
return;
|
||||
}
|
||||
if(player.getZoneMonitor().useWith(used,npc)){
|
||||
@@ -100,7 +101,7 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
if(PluginInteractionManager.handle(player,event)){
|
||||
return;
|
||||
}
|
||||
if(InteractionListeners.run(item, target, 4, player)){
|
||||
if(InteractionListeners.run(item, target, IntType.PLAYER, player)){
|
||||
return;
|
||||
}
|
||||
if(player.getZoneMonitor().useWith(used,player)){
|
||||
@@ -137,7 +138,7 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
RottenPotatoUseWithHandler.handle(used,player);
|
||||
return;
|
||||
}
|
||||
if(InteractionListeners.run(used,with,0,player)){
|
||||
if(InteractionListeners.run(used,with,IntType.ITEM,player)){
|
||||
return;
|
||||
}
|
||||
if(player.getZoneMonitor().useWith(used,with)){
|
||||
@@ -185,10 +186,10 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
RottenPotatoUseWithHandler.handle(object,player);
|
||||
return;
|
||||
}
|
||||
if(InteractionListeners.run(used,child,1,player)){
|
||||
if(InteractionListeners.run(used,child,IntType.SCENERY,player)){
|
||||
return;
|
||||
}
|
||||
if(InteractionListeners.run(used,object,1,player)){
|
||||
if(InteractionListeners.run(used,object,IntType.SCENERY,player)){
|
||||
return;
|
||||
}
|
||||
if(player.getZoneMonitor().useWith(used,object)){
|
||||
@@ -239,7 +240,7 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
}
|
||||
return;
|
||||
default:
|
||||
SystemLogger.logErr("Error in Item Action Packet! Unhandled opcode = " + buffer.opcode());
|
||||
SystemLogger.logErr(this.getClass(), "Error in Item Action Packet! Unhandled opcode = " + buffer.opcode());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,11 +63,11 @@ public class AccountRegister {
|
||||
response(session, RegistryResponse.SUCCESS);
|
||||
break;
|
||||
case 36://Register details
|
||||
SystemLogger.logInfo("Made it to final stage");
|
||||
SystemLogger.logInfo(AccountRegister.class, "Made it to final stage");
|
||||
buffer.get(); //Useless size being written that is already written in the RSA block
|
||||
buffer = Login.decryptRSABuffer(buffer, ServerConstants.EXPONENT, ServerConstants.MODULUS);
|
||||
if(buffer.get() != 10){ //RSA header (aka did this decrypt properly)
|
||||
SystemLogger.logInfo("Decryption failed during registration :(");
|
||||
SystemLogger.logInfo(AccountRegister.class, "Decryption failed during registration :(");
|
||||
response(session, RegistryResponse.CANNOT_CREATE);
|
||||
break;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class AccountRegister {
|
||||
});
|
||||
break;
|
||||
default:
|
||||
SystemLogger.logErr("Unhandled account registry opcode = " + opcode);
|
||||
SystemLogger.logErr(AccountRegister.class, "Unhandled account registry opcode = " + opcode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
package core.worker;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import core.game.system.SystemManager;
|
||||
import rs09.game.world.GameWorld;
|
||||
import rs09.game.world.repository.Repository;
|
||||
import core.game.world.update.UpdateSequence;
|
||||
import core.gui.tab.StatisticsTab;
|
||||
import core.plugin.CorePluginTypes.Managers;
|
||||
|
||||
*/
|
||||
/**
|
||||
* The major update worker, this handles the game updating etc.
|
||||
* @author Emperor
|
||||
*//*
|
||||
|
||||
public final class MajorUpdateWorker implements Runnable {
|
||||
|
||||
*/
|
||||
/**
|
||||
* The updating sequence to use.
|
||||
*//*
|
||||
|
||||
private final UpdateSequence sequence = new UpdateSequence();
|
||||
|
||||
*/
|
||||
/**
|
||||
* The executor.
|
||||
*//*
|
||||
|
||||
private final Executor EXECUTOR = Executors.newSingleThreadExecutor();
|
||||
|
||||
*/
|
||||
/**
|
||||
* The start time of a cycle.
|
||||
*//*
|
||||
|
||||
private long start;
|
||||
|
||||
*/
|
||||
/**
|
||||
* If the major update worker has started.
|
||||
*//*
|
||||
|
||||
private boolean started;
|
||||
|
||||
*/
|
||||
/**
|
||||
* Constructs a new {@code MajorUpdateWorker} {@code Object}.
|
||||
*//*
|
||||
|
||||
public MajorUpdateWorker() {
|
||||
*/
|
||||
/*
|
||||
* Empty.
|
||||
*//*
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Starts the update worker.
|
||||
*//*
|
||||
|
||||
public void start() {
|
||||
if (started) {
|
||||
return;
|
||||
}
|
||||
started = true;
|
||||
EXECUTOR.execute(MajorUpdateWorker.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (SystemManager.isActive()) {
|
||||
try {
|
||||
start = System.currentTimeMillis();
|
||||
sequence.start();
|
||||
sequence.run();
|
||||
sequence.end();
|
||||
//GameWorld.threadPool.
|
||||
GameWorld.pulse();
|
||||
Repository.getDisconnectionQueue().update();
|
||||
Managers.tick();
|
||||
sleep();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
started = false;
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Lets the current thread sleep.
|
||||
* @throws InterruptedException When the thread is interrupted.
|
||||
*//*
|
||||
|
||||
private void sleep() throws InterruptedException {
|
||||
// How many ticks off we are
|
||||
final int TICK_SPEED = (int) (600 / 1); //Allows you to make server ticks faster than normal
|
||||
StatisticsTab.reportPerformance((int) (System.currentTimeMillis() - start));
|
||||
long duration = TICK_SPEED - ((System.currentTimeMillis() - start) % TICK_SPEED);
|
||||
if (duration > 0) {
|
||||
Thread.sleep(duration);
|
||||
} else {
|
||||
SystemLogger.logErr("Updating cycle duration took " + -duration + "ms too long!");
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Gets the started.
|
||||
* @return The started.
|
||||
*//*
|
||||
|
||||
public boolean isStarted() {
|
||||
return started;
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Sets the started.
|
||||
* @param started The started to set.
|
||||
*//*
|
||||
|
||||
public void setStarted(boolean started) {
|
||||
this.started = started;
|
||||
}
|
||||
}*/
|
||||
@@ -1,26 +0,0 @@
|
||||
package plugin.drops;
|
||||
|
||||
import core.game.node.item.Item;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class DropPlugin implements Plugin<Object> {
|
||||
|
||||
//the list of NPCs this plugin can effect, if left blank it effects all NPCs.
|
||||
public int[] accepted_npcs;
|
||||
|
||||
//allows a super constructor to define the npcs
|
||||
public DropPlugin(int... accepted_npcs){
|
||||
this.accepted_npcs = accepted_npcs;
|
||||
}
|
||||
|
||||
//necessary for the plugin framework, doesnt need to be changed ever.
|
||||
@Override
|
||||
public Object fireEvent(String identifier, Object... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//defines an abstract method all drop plugins must implement
|
||||
public abstract List<Item> handle();
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package plugin.drops;
|
||||
|
||||
import core.game.node.item.Item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DropPlugins {
|
||||
public static HashMap<Integer,List<DropPlugin>> plugins = new HashMap<>();
|
||||
public static List<DropPlugin> globalPlugins = new ArrayList<>(20);
|
||||
public static List<Item> getDrops(int npc_id){
|
||||
List<Item> drops = new ArrayList<>(20);
|
||||
List<DropPlugin> toHandle = plugins.get(npc_id);
|
||||
if(toHandle != null) {
|
||||
for (DropPlugin plugin : toHandle) {
|
||||
drops.addAll(plugin.handle());
|
||||
}
|
||||
}
|
||||
if(!globalPlugins.isEmpty()) {
|
||||
for (DropPlugin plugin : globalPlugins) {
|
||||
drops.addAll(plugin.handle());
|
||||
}
|
||||
}
|
||||
return drops;
|
||||
}
|
||||
|
||||
public static void register(DropPlugin plugin){
|
||||
if(plugin.accepted_npcs.length > 0) {
|
||||
Arrays.stream(plugin.accepted_npcs).forEach(id -> {
|
||||
if (plugins.get(id) == null) {
|
||||
List<DropPlugin> newlist = new ArrayList<>(20);
|
||||
plugins.putIfAbsent(id, newlist);
|
||||
}
|
||||
plugins.get(id).add(plugin);
|
||||
});
|
||||
} else {
|
||||
globalPlugins.add(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package plugin.drops.mystery_box;
|
||||
|
||||
import core.game.node.item.Item;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
import core.plugin.PluginManifest;
|
||||
import org.rs09.consts.Items;
|
||||
import core.tools.RandomFunction;
|
||||
import plugin.drops.DropPlugin;
|
||||
import plugin.drops.DropPlugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Initializable
|
||||
@PluginManifest(name="MysteryBox")
|
||||
public class MysteryBoxDropper extends DropPlugin {
|
||||
|
||||
//percentage chance of it dropping, between 1 and 100.
|
||||
private int chance = 15;
|
||||
List<Item> drops = new ArrayList<>(20); //the list of dropped items
|
||||
|
||||
//standard way to initialize a drop plugin
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
DropPlugins.register(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
//default constructor used, called when the plugin manager initializes this plugin.
|
||||
//super() for a drop plugin simply means all NPCs can use this drop
|
||||
public MysteryBoxDropper(){
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Item> handle() {
|
||||
boolean willDrop = RandomFunction.random(chance) == RandomFunction.random(chance);
|
||||
drops.clear();
|
||||
if(willDrop){
|
||||
drops.add(new Item(Items.MYSTERY_BOX_6199));
|
||||
}
|
||||
return drops;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
/**
|
||||
* Holds all the plugin classes.
|
||||
*
|
||||
* @author Emperor
|
||||
*/
|
||||
package plugin;
|
||||
@@ -1,107 +0,0 @@
|
||||
package rs09.game.ai;
|
||||
|
||||
import core.game.content.dialogue.DialoguePlugin;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.info.Rights;
|
||||
|
||||
/**
|
||||
* Handles artificial intelligent player controls.
|
||||
* @author Emperor
|
||||
*/
|
||||
public final class AIPControlDialogue extends DialoguePlugin {
|
||||
|
||||
/**
|
||||
* The AIP to control.
|
||||
*/
|
||||
private AIPlayer aip;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code AIPControlDialogue} {@code Object}.
|
||||
*/
|
||||
public AIPControlDialogue() {
|
||||
/*
|
||||
* empty.
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code AIPControlDialogue} {@code Object}.
|
||||
* @param player The player.
|
||||
*/
|
||||
public AIPControlDialogue(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialoguePlugin newInstance(Player player) {
|
||||
return new AIPControlDialogue(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean open(Object... args) {
|
||||
if (player.getDetails().getRights() != Rights.ADMINISTRATOR) {
|
||||
return false;
|
||||
}
|
||||
aip = (AIPlayer) args[0];
|
||||
String select = "Select";
|
||||
if (player.getAttribute("aip_select") == aip) {
|
||||
select = "Deselect";
|
||||
}
|
||||
interpreter.sendOptions("AIP#" + aip.getUid() + " controls", select, "Settings", "Follow", "Stand-by", "Clear");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(int interfaceId, int buttonId) {
|
||||
switch (interfaceId) {
|
||||
case 234:
|
||||
switch (buttonId) {
|
||||
case 1:
|
||||
if (player.getAttribute("aip_select") == aip) {
|
||||
player.removeAttribute("aip_select");
|
||||
break;
|
||||
}
|
||||
player.setAttribute("aip_select", aip);
|
||||
break;
|
||||
case 2:
|
||||
interpreter.sendOptions("AIP#" + aip.getUid() + " settings", "Toggle run", "Toggle retaliate", "Toggle special attack");
|
||||
return true;
|
||||
case 3:
|
||||
aip.follow(player);
|
||||
player.removeAttribute("aip_select");
|
||||
break;
|
||||
case 4:
|
||||
aip.getPulseManager().clear();
|
||||
player.removeAttribute("aip_select");
|
||||
break;
|
||||
case 5:
|
||||
AIPlayer.deregister(aip.getUid());
|
||||
player.removeAttribute("aip_select");
|
||||
break;
|
||||
}
|
||||
close();
|
||||
return true;
|
||||
case 230:
|
||||
switch (buttonId) {
|
||||
case 1:
|
||||
aip.getSettings().toggleRun();
|
||||
break;
|
||||
case 2:
|
||||
aip.getSettings().toggleRetaliating();
|
||||
break;
|
||||
case 3:
|
||||
aip.getSettings().toggleSpecialBar();
|
||||
break;
|
||||
}
|
||||
close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,11 +52,6 @@ public class AIPlayer extends Player {
|
||||
*/
|
||||
private static final Map<Integer, AIPlayer> botMapping = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The aip control dialogue.
|
||||
*/
|
||||
private static final AIPControlDialogue CONTROL_DIAL = new AIPControlDialogue();
|
||||
|
||||
/**
|
||||
* A line of data from namesandarmor.txt that will be used to generate the appearance
|
||||
* Data in format:
|
||||
@@ -252,27 +247,6 @@ public class AIPlayer extends Player {
|
||||
super.init();
|
||||
getSettings().setRunToggled(true);
|
||||
CharacterDesign.randomize(this, false);
|
||||
getInteraction().set(new Option("Control", 7).setHandler(new OptionHandler() {
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(Player p, Node node, String option) {
|
||||
DialoguePlugin dial = CONTROL_DIAL.newInstance(p);
|
||||
if (dial != null && dial.open(AIPlayer.this)) {
|
||||
p.getDialogueInterpreter().setDialogue(dial);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalk() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}));
|
||||
getPlayerFlags().setLastSceneGraph(location);
|
||||
}
|
||||
|
||||
@@ -559,7 +533,7 @@ public class AIPlayer extends Player {
|
||||
Repository.getPlayers().remove(player);
|
||||
return;
|
||||
}
|
||||
//SystemLogger.logErr("Could not deregister AIP#" + uid + ": UID not added to the mapping!");
|
||||
//SystemLogger.logErr(this.getClass(), "Could not deregister AIP#" + uid + ": UID not added to the mapping!");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package rs09.game.ai.lumbridge;
|
||||
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.map.zone.ZoneBorders;
|
||||
import core.tools.RandomFunction;
|
||||
|
||||
public class DeadIdler extends AIPlayer {
|
||||
//Recreation of players I saw in w417 who seemed to have quit their computer after dying.
|
||||
|
||||
private int tick = RandomFunction.random(500);
|
||||
|
||||
public DeadIdler()
|
||||
{
|
||||
super(getRandomRespawnLoc());
|
||||
this.setCustomState("Lumbridge Bot");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
super.tick();
|
||||
if (this.tick > 0)
|
||||
{
|
||||
tick --;
|
||||
} else {
|
||||
AIPlayer.deregister(this.getUid());
|
||||
}
|
||||
}
|
||||
|
||||
private static Location getRandomRespawnLoc() {
|
||||
return new ZoneBorders(3219, 3218, 3223, 3219).getRandomLoc();
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package rs09.game.ai.lumbridge;
|
||||
|
||||
import rs09.game.world.GameWorld;
|
||||
import core.tools.RandomFunction;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* Creates a few random bots around Lumbridge area.
|
||||
* Code by Red Bracket
|
||||
*/
|
||||
public class LumbridgeBotHandler {
|
||||
public static void immersiveLumbridge()
|
||||
{
|
||||
//Generate a few random bots here and there
|
||||
System.out.println("[" + GameWorld.getSettings().getName() + "]: LumbridgeBotHandler: Initialized dead idlers.");
|
||||
generateDeadIdlers();
|
||||
}
|
||||
|
||||
private static void generateDeadIdlers() {
|
||||
Executors.newSingleThreadExecutor().execute(() -> {
|
||||
while (true) //Would probably be better if this could be "while game is running"
|
||||
{
|
||||
new DeadIdler();
|
||||
try {
|
||||
Thread.sleep(RandomFunction.random(300_000));
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("LumbridgeBotHandler can't sleep!!?");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package rs09.game.ai.pvmbots;
|
||||
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import core.game.node.entity.player.link.prayer.*;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.map.zone.impl.WildernessZone;
|
||||
|
||||
public class DragonKiller extends PvMBots{
|
||||
|
||||
private int tick = 0;
|
||||
|
||||
public DragonKiller(Location l) {
|
||||
super(l);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
super.tick();
|
||||
|
||||
//Despawn
|
||||
if (this.getSkills().getLifepoints() == 0 || this.getLocation().equals(new Location(0, 0)))
|
||||
//this.teleport(new Location(500, 500));
|
||||
//Despawning not being delayed causes 3 errors in the console
|
||||
AIPlayer.deregister(this.getUid());
|
||||
|
||||
if (this.checkVictimIsPlayer())
|
||||
{
|
||||
tryEscape();
|
||||
}
|
||||
|
||||
//Npc Combat
|
||||
if (tick == 0)
|
||||
{
|
||||
if (!this.inCombat())
|
||||
AttackNpcsInRadius(this, 15);
|
||||
this.tick = 10;
|
||||
}
|
||||
else
|
||||
this.tick--;
|
||||
|
||||
this.eat(379);
|
||||
this.getSkills().setLevel(Skills.PRAYER, 99);
|
||||
this.getSkills().setStaticLevel(Skills.PRAYER, 99);
|
||||
if (!(this.getPrayer().getActive().contains(PrayerType.PROTECT_FROM_MELEE)))
|
||||
this.getPrayer().toggle(PrayerType.PROTECT_FROM_MELEE);
|
||||
//this.getPrayer().toggle()
|
||||
}
|
||||
|
||||
public void tryEscape()
|
||||
{
|
||||
if (this.isTeleBlocked() == false)
|
||||
{
|
||||
if (WildernessZone.getWilderness(this) <= 20)
|
||||
{
|
||||
System.out.println("not Teleblocked");
|
||||
this.teleport(new Location(0, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
//run away
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package rs09.game.ai.pvmbots;
|
||||
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import core.game.node.entity.player.link.prayer.PrayerType;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.map.Location;
|
||||
|
||||
public class GiantMoleBot extends PvMBots{
|
||||
|
||||
public GiantMoleBot(Location l) {
|
||||
super(l);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
int tick = 0;
|
||||
int movetimer = 5;
|
||||
|
||||
private void checkLightSource()
|
||||
{
|
||||
if (!this.getInventory().containItems(33))
|
||||
{
|
||||
if (this.getInventory().containItems(36))
|
||||
this.getInventory().remove(new Item(36));
|
||||
this.getInventory().add(new Item(33));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
checkLightSource();
|
||||
super.tick();
|
||||
PrayerType type[] = {PrayerType.PROTECT_FROM_MELEE, PrayerType.PIETY};
|
||||
this.CheckPrayer(type);
|
||||
|
||||
//Despawn
|
||||
if (this.getSkills().getLifepoints() == 0)
|
||||
//this.teleport(new Location(500, 500));
|
||||
//Despawning not being delayed causes 3 errors in the console
|
||||
AIPlayer.deregister(this.getUid());
|
||||
|
||||
//Npc Combat
|
||||
if (this.tick == 0)
|
||||
{
|
||||
if (!this.inCombat())
|
||||
AttackNpcsInRadius(this, 50);
|
||||
this.tick = 5;
|
||||
}
|
||||
|
||||
else
|
||||
this.tick--;
|
||||
|
||||
/*if (this.movetimer == 0)
|
||||
{
|
||||
if (!this.inCombat())
|
||||
{
|
||||
this.randomWalk(10, 10);
|
||||
}
|
||||
this.movetimer = 4;
|
||||
}
|
||||
else
|
||||
this.movetimer--;*/
|
||||
//if (this.getSkills().getLifepoints() > 1)
|
||||
//this.eat();
|
||||
//this.getPrayer().toggle()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package rs09.game.ai.pvmbots;
|
||||
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import core.game.world.map.Location;
|
||||
|
||||
public class LowestBot extends PvMBots{
|
||||
|
||||
public LowestBot(Location l) {
|
||||
super(l);
|
||||
}
|
||||
|
||||
private int tick = 0;
|
||||
|
||||
@Override
|
||||
public void tick(){
|
||||
super.tick();
|
||||
|
||||
this.tick++;
|
||||
|
||||
//Despawn
|
||||
if (this.getSkills().getLifepoints() == 0)
|
||||
//this.teleport(new Location(500, 500));
|
||||
//Despawning not being delayed causes 3 errors in the console
|
||||
AIPlayer.deregister(this.getUid());
|
||||
|
||||
//Npc Combat
|
||||
if (this.tick % 10 == 0) {
|
||||
if (!this.inCombat())
|
||||
AttackNpcsInRadius(this, 5);
|
||||
}
|
||||
|
||||
if (this.tick == 100) this.tick = 0;
|
||||
|
||||
this.eat(329);
|
||||
//this.getPrayer().toggle()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package rs09.game.ai.pvmbots;
|
||||
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import core.game.world.map.Location;
|
||||
|
||||
public class NoobBot extends PvMBots{
|
||||
|
||||
private int tick = 0;
|
||||
private int movetimer = 0;
|
||||
|
||||
public NoobBot(Location l) {
|
||||
super(l);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
super.tick();
|
||||
|
||||
//Despawn
|
||||
if (this.getSkills().getLifepoints() == 0)
|
||||
//this.teleport(new Location(500, 500));
|
||||
//Despawning not being delayed causes 3 errors in the console
|
||||
AIPlayer.deregister(this.getUid());
|
||||
|
||||
//Npc Combat
|
||||
if (tick == 0)
|
||||
{
|
||||
if (!this.inCombat())
|
||||
AttackNpcsInRadius(this, 5);
|
||||
this.tick = 5;
|
||||
}
|
||||
else
|
||||
this.tick--;
|
||||
|
||||
this.eat(329);
|
||||
//this.getPrayer().toggle()
|
||||
//System.out.println(this.getPulseManager().getCurrent());
|
||||
|
||||
if (!this.inCombat())
|
||||
{
|
||||
if (movetimer == 0)
|
||||
{
|
||||
if (this.FindTargets(this, 5) == null)
|
||||
this.randomWalk(5, 5);
|
||||
this.movetimer = 10;
|
||||
}
|
||||
else
|
||||
movetimer --;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
package rs09.game.ai.pvp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import core.game.container.impl.EquipmentContainer;
|
||||
import core.game.content.consumable.Consumable;
|
||||
import core.game.content.consumable.Consumables;
|
||||
import core.game.content.consumable.Food;
|
||||
import core.game.content.consumable.effects.HealingEffect;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.system.task.Pulse;
|
||||
import rs09.game.world.GameWorld;
|
||||
import core.game.world.map.path.Pathfinder;
|
||||
import core.game.world.update.flag.context.ChatMessage;
|
||||
import core.game.world.update.flag.player.ChatFlag;
|
||||
import core.tools.RandomFunction;
|
||||
|
||||
public class PVPAIPActions {
|
||||
|
||||
public static List<AIPlayer> pvp_players = null;
|
||||
|
||||
private static final String[] trashMessages = {
|
||||
"I'll do your bloody nan in m8",
|
||||
"Your sister smells like a tuna sandwich",
|
||||
"You suck at bridding bro lmao",
|
||||
"Gf your bank :)",
|
||||
"Just delete your cache ur bad",
|
||||
"FFS mate get wrekt",
|
||||
"Dylan is a better pkr than u, kid..l0l"
|
||||
|
||||
|
||||
};
|
||||
|
||||
private static final String[] safeMessages = {
|
||||
"Safe up n00b",
|
||||
"No safe",
|
||||
"Get rekt m8",
|
||||
"Stop fkin eating scrub",
|
||||
"Dw, you're gunna die anyhow.. :)",
|
||||
"Either ur eating shrimps or I'm hitting high asf",
|
||||
"Once i kill u wanna rematch?",
|
||||
|
||||
};
|
||||
|
||||
public static void syncBotThread(final Player player) {
|
||||
if (pvp_players == null || pvp_players.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (int aip_index = 0; aip_index < pvp_players.size(); aip_index++) {
|
||||
final AIPlayer bot = pvp_players.get(aip_index);
|
||||
final AIPlayer[] target = {
|
||||
pvp_players.get(RandomFunction.getRandom(pvp_players.size() - 1))
|
||||
};
|
||||
bot.getProperties().setRetaliating(true);
|
||||
bot.setAttribute("dead", false);
|
||||
GameWorld.getPulser().submit(new Pulse(1, bot) {
|
||||
int ticks;
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
if (bot.getAttribute("dead", true)) {
|
||||
AIPlayer.deregister(bot.getUid());
|
||||
pvp_players.remove(bot);
|
||||
return true;
|
||||
}
|
||||
if (!bot.getInventory().contains(385, 1)) {
|
||||
flee(bot);
|
||||
return true;
|
||||
}
|
||||
//Inactivity logout timer.
|
||||
if (ticks++ == 5000 && !bot.getProperties().getCombatPulse().isInCombat() && !bot.getProperties().getCombatPulse().isAttacking() && bot.getWalkingQueue().getQueue().isEmpty()) {
|
||||
AIPlayer.deregister(bot.getUid());
|
||||
pvp_players.remove(bot);
|
||||
return true;
|
||||
}
|
||||
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]);
|
||||
//prayer(bot, target[0]);
|
||||
eat(bot, target[0]);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void attackTarget(Player player, AIPlayer bot, AIPlayer target) {
|
||||
//If bots target is not himself we continue.
|
||||
if (bot != target) {
|
||||
//If they are in combat or attacking:
|
||||
if (bot.getProperties().getCombatPulse().isInCombat() || bot.getProperties().getCombatPulse().isAttacking()) {
|
||||
//TODO: Pray
|
||||
Item weapon = bot.getEquipment().get(EquipmentContainer.SLOT_WEAPON);
|
||||
if (RandomFunction.getRandom(25) == 1) {
|
||||
if(bot.getSettings().getSpecialEnergy() == 100) { //TODO: Change 100 to their weielded weapons spec max amount
|
||||
bot.getSettings().toggleSpecialBar();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (RandomFunction.getRandom(25) == 1) {
|
||||
bot.attack(player);
|
||||
} else {
|
||||
//If a 1/50 chance is true, the attacker screams his opponents name hoping his team will dogpile him.
|
||||
int chatRandom = RandomFunction.getRandom(50);
|
||||
switch(chatRandom) {
|
||||
case 1:
|
||||
String target_name = target.getName().substring(0, 1).toUpperCase() + target.getName().substring(1);
|
||||
bot.getUpdateMasks().register(new ChatFlag(new ChatMessage(bot, target_name, 0, 0)));
|
||||
break;
|
||||
case 2:
|
||||
bot.getUpdateMasks().register(new ChatFlag(new ChatMessage(bot, trashMessages[RandomFunction.getRandom(trashMessages.length - 1)], 0, 0)));
|
||||
break;
|
||||
}
|
||||
bot.attack(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic flee method to run them to another part of the wilderness.
|
||||
* @param bot
|
||||
* TODO: Possibly make them run away and hop the ditch (I did not do this because we have no other actions than pking at the moment).
|
||||
*/
|
||||
private static void flee(final AIPlayer bot) {
|
||||
bot.sendChat("Outta food m8! Off!");
|
||||
bot.sendChat("Ahh!");
|
||||
bot.sendChat("GTFO M8");
|
||||
bot.sendChat("Someone spec him!");
|
||||
GameWorld.getPulser().submit(new Pulse(1, bot) {
|
||||
int ticks;
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
switch(ticks++) {
|
||||
case 1:
|
||||
bot.getProperties().getCombatPulse().stop();
|
||||
bot.getProperties().getCombatPulse().setNextAttack(RandomFunction.getRandom(10));
|
||||
Pathfinder.find(bot, bot.getLocation().transform(RandomFunction.random(-100, 100), RandomFunction.random(-100, 100), 0), false, Pathfinder.SMART).walk(bot);
|
||||
break;
|
||||
case 500:
|
||||
AIPlayer.deregister(bot.getUid());
|
||||
pvp_players.remove(bot);
|
||||
return true;
|
||||
}
|
||||
if (bot.getAttribute("dead", true)) {
|
||||
AIPlayer.deregister(bot.getUid());
|
||||
pvp_players.remove(bot);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the eating of the AI player bots.
|
||||
* @param bot
|
||||
* TODO: Possibly add more food choices.
|
||||
*/
|
||||
private static void eat(Player bot, AIPlayer target) {
|
||||
Item shark = new Item(385);
|
||||
//385 is shark, you can add more from there easier.
|
||||
if((bot.getSkills().getStaticLevel(Skills.HITPOINTS) > bot.getSkills().getLifepoints() * 3) && bot.getInventory().containsItem(shark)) {
|
||||
bot.lock(3);
|
||||
Item food = bot.getInventory().getItem(shark);
|
||||
Consumable consumable = Consumables.getConsumableById(food.getId());
|
||||
if (consumable == null) {
|
||||
consumable = new Food(new int[] {food.getId()}, new HealingEffect(1));
|
||||
}
|
||||
consumable.consume(food, bot);
|
||||
bot.getProperties().getCombatPulse().delayNextAttack(3);
|
||||
int chatRandom = RandomFunction.getRandom(50);
|
||||
if (chatRandom == 1) {
|
||||
bot.getUpdateMasks().register(new ChatFlag(new ChatMessage(bot, safeMessages[RandomFunction.getRandom(safeMessages.length - 1)], 0, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean canAttack(Player p, Player t) {
|
||||
int level = p.getSkullManager().getLevel();
|
||||
if (t.getSkullManager().getLevel() < level) {
|
||||
level = t.getSkullManager().getLevel();
|
||||
}
|
||||
int combat = p.getProperties().getCombatLevel();
|
||||
int targetCombat = t.getProperties().getCombatLevel();
|
||||
if (combat - level > targetCombat || combat + level < targetCombat) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,71 +0,0 @@
|
||||
package rs09.game.ai.resource;
|
||||
|
||||
import core.game.node.entity.skill.gather.SkillingResource;
|
||||
import core.game.node.entity.player.Player;
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import core.game.system.task.Pulse;
|
||||
import rs09.game.world.GameWorld;
|
||||
import rs09.game.world.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ResourceAIPActions {
|
||||
|
||||
public static List<AIPlayer> resource_players = null;
|
||||
|
||||
protected SkillingResource resource;
|
||||
|
||||
public static void syncBotThread(final Player player) {
|
||||
if (resource_players == null || resource_players.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (int aip_index = 0; aip_index < resource_players.size(); aip_index++) {
|
||||
final AIPlayer bot = resource_players.get(aip_index);
|
||||
GameWorld.getPulser().submit(new Pulse(1, bot) {
|
||||
int ticks;
|
||||
int ov;
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
/*if (bot.getInventory().freeSlots() < 1) {
|
||||
//flee(bot);
|
||||
return true;
|
||||
}*/
|
||||
//Inactivity logout timer.
|
||||
if (ticks++ == 5000/* && bot.getWalkingQueue().getQueue().isEmpty()*/) {
|
||||
AIPlayer.deregister(bot.getUid());
|
||||
resource_players.remove(bot);
|
||||
return true;
|
||||
}
|
||||
if (ov++ >= 3) {
|
||||
chopTree(bot);
|
||||
ov = 0;
|
||||
}
|
||||
// ov = 0;
|
||||
System.out.println("ResourceAIPActions" + ov);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean chopTree(final AIPlayer bot) {
|
||||
/*for (GameObject[] o : RegionManager.forId(bot.getLocation().getRegionId()).getPlanes()[0].getObjects()) {
|
||||
for (GameObject obj : o) {
|
||||
if (obj != null) {
|
||||
for (SkillingResource r : SkillingResource.values()) {
|
||||
if (obj.getId() == r.getId()) {
|
||||
Pathfinder.find(bot, obj).walk(bot);
|
||||
bot.sendChat("WE CHOPPIN");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
bot.attack(Repository.getNpcs().get(106));
|
||||
|
||||
// Pulse pulse = new GatheringSkillPulse(bot, node);
|
||||
// bot.getPulseManager().run(new GatheringSkillPulse(bot, node));
|
||||
// pulse.start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
package rs09.game.ai.resource;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import rs09.game.ai.resource.task.ResourceTask;
|
||||
import rs09.game.ai.resource.task.ResourceTasks;
|
||||
import core.game.system.task.Pulse;
|
||||
import rs09.game.world.GameWorld;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Package -> org.keldagrim.game.node.entity.player.ai.resource
|
||||
* Created on -> 9/13/2016 @12:42 PM for 530
|
||||
*
|
||||
* @author Ethan Kyle Millard
|
||||
*/
|
||||
public class ResourceAIPManager {
|
||||
|
||||
private long time = 0;
|
||||
|
||||
private Player player;
|
||||
|
||||
private static Map<ResourceTask, Long> TASKS = new HashMap<>();
|
||||
|
||||
public ResourceAIPManager init() {
|
||||
getTasks().put(ResourceTasks.WOODCUTTING.getResourceTask(), 0L);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceAIPManager runTask(Player player, String taskName) {
|
||||
for (Map.Entry<ResourceTask, Long> entry : getTasks().entrySet()) {
|
||||
if (entry.getKey().getTaskName().equalsIgnoreCase(taskName)) {
|
||||
if (entry.getValue() != 0) {
|
||||
message(player, "You have extended the task " + taskName + ".");
|
||||
} else {
|
||||
message(player, "You have activated the task " + taskName + ".");
|
||||
}
|
||||
}
|
||||
entry.getKey().setTaskName(taskName);
|
||||
entry.setValue(entry.getValue() + 70);
|
||||
this.player = player;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void reActivate(String name, long time) {
|
||||
for (Map.Entry<ResourceTask, Long> entry : TASKS.entrySet()) {
|
||||
if (entry.getKey().getTaskName().equalsIgnoreCase(name)) {
|
||||
entry.setValue(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceAIPManager load(Player player) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceAIPManager save(Player player) {
|
||||
/*if (GameWorld.getDatabaseManager().update("global", "DELETE FROM `members` WHERE worldid='" + GameWorld.getSettings().getWorldId() + "'") < 0)
|
||||
return this;*/
|
||||
System.out.println("Saving...");
|
||||
Iterator<Map.Entry<ResourceTask, Long>> iterator = getTasks().entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<ResourceTask, Long> entry = iterator.next();
|
||||
if (entry.getValue() <= 0)
|
||||
continue;
|
||||
StringBuilder query = new StringBuilder();
|
||||
query.append("UPDATE `members` SET `taskName`='" + entry.getKey().getTaskName() + "',`taskTime`='" + entry.getValue() + "' WHERE `username`='" + player.getUsername() + "'");
|
||||
System.out.println("ResourceAIPManager: " + query.toString());
|
||||
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void pulse(Player player) {
|
||||
GameWorld.getPulser().submit(new Pulse(1) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
|
||||
time++;
|
||||
|
||||
Iterator<Map.Entry<ResourceTask, Long>> iterator = getTasks().entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<ResourceTask, Long> entry = iterator.next();
|
||||
if (entry.getValue() > 0) {
|
||||
entry.setValue(entry.getValue() - 1);
|
||||
if (entry.getValue() == 50)
|
||||
message(player, "You have 30 minutes before " + entry.getKey().getTaskName() + " task ends.");
|
||||
if (entry.getValue() <= 0) {
|
||||
entry.getKey().setTime(0);
|
||||
entry.getKey().reward(player, entry.getKey().getTaskName());
|
||||
message(player, "The task " + entry.getKey().getTaskName() + " has now ended.");
|
||||
save(player);
|
||||
}
|
||||
if (time == 50) {
|
||||
entry.getKey().setTime(0);
|
||||
save(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ResourceAIPManager message(Player player, String message) {
|
||||
return message(player, message, true, "<col=027fc7>");
|
||||
}
|
||||
|
||||
public ResourceAIPManager message(Player player, String message, boolean tag) {
|
||||
return message(player, message, tag, "<col=027fc7>");
|
||||
}
|
||||
|
||||
public ResourceAIPManager notify(Player player, String message) {
|
||||
return message(player, message, true, "<col=800000>");
|
||||
}
|
||||
|
||||
public ResourceAIPManager notify(Player player, String message, boolean tag) {
|
||||
return message(player, message, tag, "<col=800000>");
|
||||
}
|
||||
|
||||
|
||||
public ResourceAIPManager message(Player player, String message, boolean tag, String color) {
|
||||
player.getPacketDispatch().sendMessage(color + (tag ? "[Resource Manager] - " : "") + message);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public static Map<ResourceTask, Long> getTasks() {
|
||||
return TASKS;
|
||||
}
|
||||
|
||||
private static ResourceAIPManager INSTANCE = new ResourceAIPManager();
|
||||
|
||||
public static ResourceAIPManager get() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package rs09.game.ai.resource.task;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
|
||||
/**
|
||||
* Package -> org.keldagrim.game.node.entity.player.ai.resource.task
|
||||
* Created on -> 9/13/2016 @12:44 PM for 530
|
||||
*
|
||||
* @author Ethan Kyle Millard
|
||||
*/
|
||||
public abstract class ResourceTask {
|
||||
|
||||
|
||||
private String taskName;
|
||||
private long time;
|
||||
|
||||
public ResourceTask(String taskName, long time) {
|
||||
this.taskName = taskName;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public abstract void reward(Player player, String eventName);
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return taskName;
|
||||
}
|
||||
|
||||
public void setTaskName(String taskName) {
|
||||
this.taskName = taskName;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package rs09.game.ai.resource.task;
|
||||
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.tools.RandomFunction;
|
||||
|
||||
/**
|
||||
* Package -> org.keldagrim.game.node.entity.player.ai.resource.task
|
||||
* Created on -> 9/13/2016 @12:43 PM for 530
|
||||
*
|
||||
* @author Ethan Kyle Millard
|
||||
*/
|
||||
public enum ResourceTasks {
|
||||
|
||||
WOODCUTTING(new ResourceTask("Willow Logs", 6000) {
|
||||
|
||||
@Override
|
||||
public void reward(Player player, String eventName) {
|
||||
if (player.getSkills().getLevel(Skills.WOODCUTTING) < 30) {
|
||||
player.sendMessage(reqirementMessage());
|
||||
return;
|
||||
}
|
||||
if (getTime() == 0) {
|
||||
player.getBank().add(new Item(1519, RandomFunction.random(700, 1000)));
|
||||
player.getSkills().addExperience(Skills.WOODCUTTING, RandomFunction.random(100000, 150000));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ResourceTask resourceTask;
|
||||
|
||||
|
||||
ResourceTasks(ResourceTask resourceTask) {
|
||||
this.resourceTask = resourceTask;
|
||||
}
|
||||
|
||||
public ResourceTask getResourceTask() {
|
||||
return resourceTask;
|
||||
}
|
||||
|
||||
|
||||
private static String reqirementMessage() {
|
||||
return "You do not meet the requirements for this task.";
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package rs09.game.ai.skillingbot;
|
||||
|
||||
import core.game.world.map.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.interaction.Option;
|
||||
import core.game.node.Node;
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import core.game.node.item.Item;
|
||||
import core.net.packet.in.InteractionPacket;
|
||||
|
||||
public class SkillingBot extends AIPlayer {
|
||||
|
||||
private int tick = 5;
|
||||
private ArrayList<Integer> interactNodeIds;
|
||||
private int fromWhereDoIdrop;
|
||||
private int skill;
|
||||
private int interactionRange;
|
||||
|
||||
public SkillingBot(Location l)
|
||||
{
|
||||
super(l);
|
||||
this.fromWhereDoIdrop = 0;
|
||||
this.interactionRange = 15;
|
||||
}
|
||||
|
||||
public SkillingBot(Location l, int skill, ArrayList<Integer> entrys)
|
||||
{
|
||||
super(l);
|
||||
this.skill = skill;
|
||||
this.fromWhereDoIdrop = 0;
|
||||
this.interactNodeIds = entrys;
|
||||
this.interactionRange = 15;
|
||||
|
||||
switch (this.skill)
|
||||
{
|
||||
case Skills.MINING:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
super.tick();
|
||||
|
||||
//Despawn
|
||||
if (this.getSkills().getLifepoints() == 0)
|
||||
AIPlayer.deregister(this.getUid());
|
||||
|
||||
//Interact with object
|
||||
if (this.tick <= 0)
|
||||
{
|
||||
this.tick = 5;
|
||||
if (this.skill == Skills.FISHING)
|
||||
this.tick = 20;
|
||||
|
||||
// Node test = getClosestNodeWithEntry(15, 15503);
|
||||
Node node;
|
||||
if (this.skill != Skills.FISHING)
|
||||
{
|
||||
node = getClosestNodeWithEntry(interactionRange, interactNodeIds);
|
||||
}
|
||||
else
|
||||
{
|
||||
node = getClosesCreature(interactionRange, interactNodeIds);
|
||||
// if (test != null)
|
||||
// System.out.println("interact with " + test.getName());
|
||||
}
|
||||
|
||||
if (node == null) {
|
||||
System.out.println("SkillingBot.java: Object not found " + this.skill);
|
||||
return;
|
||||
}
|
||||
|
||||
//System.out.println("free slots " + this.getInventory().freeSlots());
|
||||
|
||||
if (this.getInventory().isFull())
|
||||
{
|
||||
// System.out.println(this.getName() + " starts droping from " + fromWhereDoIdrop);
|
||||
for (int i = fromWhereDoIdrop; i < 28; i++)
|
||||
{
|
||||
Item drop = this.getInventory().get(i);
|
||||
final Option option = drop.getInteraction().get(4);
|
||||
drop.getInteraction().handleItemOption(this, option, this.getInventory());
|
||||
// System.out.println("drop item " + i);
|
||||
}
|
||||
}
|
||||
|
||||
int x = node.getLocation().getX();
|
||||
int y = node.getLocation().getY();
|
||||
if (this.skill != Skills.FISHING)
|
||||
{
|
||||
InteractionPacket.handleObjectInteraction(this, 0, x, y, node.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
InteractionPacket.handleNPCInteraction(this, 0, node.getIndex());
|
||||
}
|
||||
}
|
||||
else
|
||||
this.tick--;
|
||||
}
|
||||
|
||||
public int getSkill()
|
||||
{
|
||||
return this.skill;
|
||||
}
|
||||
|
||||
public int getFromWhereToDrop()
|
||||
{
|
||||
return this.fromWhereDoIdrop;
|
||||
}
|
||||
|
||||
public void setFromWhereDoIdrop(int id)
|
||||
{
|
||||
this.fromWhereDoIdrop = id;
|
||||
}
|
||||
|
||||
public void setInteractionRange(int range)
|
||||
{
|
||||
this.interactionRange = range;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user