Merge pull request #8 from dginovker/master

update
This commit is contained in:
The Celery Man 2020-03-28 18:10:02 -05:00 committed by GitHub
commit 7cda4b92f0
28 changed files with 1279 additions and 836 deletions

1
.gitignore vendored
View file

@ -10,3 +10,4 @@ CompiledServer/**/*.jar
**/.idea/workspace.xml
**/.idea/*
*.class
CompiledServer/

1
Server/.gitignore vendored
View file

@ -13,3 +13,4 @@ data/profile/**
*.eml
*.userlibraries
data/players/**
data/eco/offer_dispatch_db.emp

View file

@ -41,7 +41,6 @@ wef6qwe4r561:3:0:0:0:0:0:0:0:0:0:0:0:0:
Sister 13:3:12600:9793:0:20590:6186:24325:0:13288:0:0:23285:0:
IsidraJr:58:0:0:0:0:0:0:0:0:0:0:0:0:
BeDeMaSa0891:3:0:0:0:0:0:0:0:0:0:0:0:0:
Jazzy Otto:101:22689:0:22692:1419:22695:0:0:22698:0:0:22701:0:
JustSkillezZ:50:1017:0:0:1387:426:0:0:428:0:0:0:0:
Elcangri11:39:1017:1007:1727:1381:1035:1199:0:1033:0:1059:1061:0:
haroldas 99r:13:1017:1019:1731:843:0:0:0:1015:0:1059:1061:0:
@ -58,7 +57,6 @@ laitukas29:3:0:0:0:0:0:0:0:0:0:0:0:0:
AFRODITA-23:38:0:0:0:0:0:0:0:0:0:0:0:0:
Monrojas:50:0:1029:1725:1381:0:0:0:1099:0:1065:1061:0:
stejler:114:21266:6570:19553:4151:21301:12954:0:21304:0:7462:11840:0:
r0cK4eV3r:103:11850:11852:0:0:11854:0:0:11856:0:11858:11860:0:
Loamjytuner:3:0:0:0:0:0:0:0:0:0:0:0:0:
u smoke mid:92:12293:10499:10364:1387:1121:1197:0:1071:0:1065:11840:0:
MIMIYEEET:64:0:10499:0:861:0:0:0:0:0:0:0:0:

View file

@ -1 +1,11 @@
#Format:
#name:cblevel:helmet:cape:neck:weapon:chest:shield:unknown:legs:unknown:gloves:boots:
sicriona:103:1163:1023:1725:1333:1127:1201:0:1079:0:2922:1061:0:
czar:110:1149:6568:1704:4587:10564:6524:0:4585:0:1059:1061:
loving puppy:95:11665:6568:1704:4587:8839:14767:0:8840:0:8842:1061:
rattle63:83:14096:10499:1704:4151:14094:14767:0:14095:0:8842:1061:
baluga:110:10828:6568:10354:4151:3140:6524:0:4087:0:8842:11732:
crabcake:115:10828:10446:10354:4151:10564:6524:0:4087:0:8842:11732:
Red:94:1163:6568:10354:7158:10564:0:0:4087:0:1059:11732:
puglet:120:10828:6568:6585:11696:4757:0:0:8840:0:1059:3105:
linux:10000:10828:10069:1725:4151:3140:14767:0:4087:0:1059:3105:

View file

@ -13,6 +13,7 @@ import java.util.Map;
/**
* Represents a container which contains items.
*
* @author Emperor
*/
public class Container {
@ -49,6 +50,7 @@ public class Container {
/**
* Constructs a new {@code Container} {@code Object}.
*
* @param capacity The capacity.
*/
public Container(int capacity) {
@ -57,6 +59,7 @@ public class Container {
/**
* Constructs a new {@code Container.java} {@code Object}.
*
* @param capacity the capacity.
* @param items the items to add.
*/
@ -67,6 +70,7 @@ public class Container {
/**
* Constructs a new {@code Container} {@code Object}.
*
* @param capacity The capacity.
* @param type The container type.
*/
@ -76,6 +80,7 @@ public class Container {
/**
* Constructs a new {@code Container} {@code Object}.
*
* @param capacity The capacity.
* @param type The container type.
* @param sortType The sort type.
@ -90,6 +95,7 @@ public class Container {
/**
* Registers a container listener.
*
* @param listener The container listener.
* @return This container instance, for chaining.
*/
@ -100,6 +106,7 @@ public class Container {
/**
* Adds the items.
*
* @param items The items to add.
* @return {@code True} if successfully added <b>all</b> items.
*/
@ -120,6 +127,7 @@ public class Container {
/**
* Inserts an item into a specific slot.
*
* @param fromSlot The original slot of the item.
* @param toSlot The slot to insert into.
*/
@ -129,6 +137,7 @@ public class Container {
/**
* Inserts an item into a specific slot.
*
* @param fromSlot The original slot of the item.
* @param toSlot The slot to insert into.
* @param update If the container packets should be sent.
@ -149,6 +158,7 @@ public class Container {
/**
* Adds an item to this container if full it goes to ground.
*
* @param item the item.
* @param player the player.
* @param ground
@ -163,7 +173,7 @@ public class Container {
}
public boolean addIfDoesntHave(final Item item) {
if(containsItem(item)) {
if (containsItem(item)) {
return false;
} else {
return add(item);
@ -173,6 +183,7 @@ public class Container {
/**
* Adds an item to this container.
*
* @param item The item.
* @return {@code True} if the item got added.
*/
@ -182,6 +193,7 @@ public class Container {
/**
* Adds an item to this container.
*
* @param item The item to add.
* @param fireListener If we should update.
* @param preferredSlot The slot to add the item in, when possible.
@ -193,6 +205,7 @@ public class Container {
/**
* Adds an item to this container.
*
* @param item The item to add.
* @param fireListener If we should update.
* @param preferredSlot The slot to add the item in, when possible.
@ -256,6 +269,7 @@ public class Container {
/**
* Removes a set of items.
*
* @param items The set of items.
* @return {@code True} if all items got successfully removed.
*/
@ -272,6 +286,7 @@ public class Container {
/**
* Removes an item.
*
* @param item The item.
* @return {@code True} if the item got removed, {@code false} if not.
*/
@ -281,6 +296,7 @@ public class Container {
/**
* Removes an item.
*
* @param item The item to remove.
* @param fireListener If the fire listener should be "notified".
* @return {@code True} if the item got removed, <br> {@code false} if not.
@ -295,6 +311,7 @@ public class Container {
/**
* Removes an item from this container.
*
* @param item The item.
* @param slot The item slot.
* @param fireListener If the fire listener should be "notified".
@ -346,6 +363,7 @@ public class Container {
/**
* Replaces the item on the given slot with the argued item.
*
* @param item The item.
* @param slot The slot.
* @return The old item.
@ -356,6 +374,7 @@ public class Container {
/**
* Replaces the item on the given slot with the argued item.
*
* @param item The item.
* @param slot The slot.
* @param fireListener If the listener should be "notified".
@ -422,6 +441,21 @@ public class Container {
/**
* Gets the item on the given slot.
*
* @param slot The slot.
* @return The id of the item on the slot, or 0 if the item wasn't there.
*/
public int getAsId(int slot) {
if (slot < 0 || slot >= items.length || items[slot] == null) {
return 0;
}
return items[slot].getId();
}
/**
* Gets the item on the given slot.
*
* @param slot The slot.
* @return The item on the slot, or {@code null} if the item wasn't there.
*/
@ -434,6 +468,7 @@ public class Container {
/**
* Gets the item on the given slot.
*
* @param slot The slot.
* @return The item on the slot, or a new constructed item with id 0 if the
* item wasn't there.
@ -448,6 +483,7 @@ public class Container {
/**
* Gets the item id on the given slot.
*
* @param slot The slot.
* @return The id of the item on the slot.
*/
@ -464,6 +500,7 @@ public class Container {
/**
* Parses the container data from the byte buffer.
*
* @param buffer The byte buffer.
* @return The total value of all items (G.E price > Store price > High
* alchemy price).
@ -487,6 +524,7 @@ public class Container {
/**
* Saves the item data on the byte buffer.
*
* @param buffer The byte buffer.
* @return The total value of all items (G.E price > Store price > High
* alchemy price).
@ -510,6 +548,7 @@ public class Container {
/**
* Copies the container to this container.
*
* @param c The container to copy.
*/
public void copy(Container c) {
@ -526,6 +565,7 @@ public class Container {
/**
* Formats a container for the SQL database.
*
* @return the string.
*/
public String format() {
@ -550,6 +590,7 @@ public class Container {
/**
* Checks if the container contains an item.
*
* @param item the Item
* @return {@code True} if so.
*/
@ -559,6 +600,7 @@ public class Container {
/**
* Checks if the containers contains these items.
*
* @param items the items.
* @return {@code True} if so.
*/
@ -573,6 +615,7 @@ public class Container {
/**
* Checks if the container contains an item.
*
* @param itemId The item id.
* @param amount The amount.
* @return {@code True} if so.
@ -591,6 +634,7 @@ public class Container {
/**
* Checks if the containers contains ONE item.
*
* @param itemId
* @return
*/
@ -605,10 +649,11 @@ public class Container {
/**
* Checks if the container contains all items.
*
* @param the itemIds to check
* @return {@code True} if so.
*/
public boolean containsAll(int...itemIds) {
public boolean containsAll(int... itemIds) {
for (int i : itemIds) {
if (!containsOneItem(i)) {
return false;
@ -619,6 +664,7 @@ public class Container {
/**
* Adds a container to this container.
*
* @param container The container.
*/
public void addAll(Container container) {
@ -627,6 +673,7 @@ public class Container {
/**
* Checks the maximum amount of this item we can add.
*
* @param item The item.
* @return The maximum amount we can add.
*/
@ -644,6 +691,7 @@ public class Container {
/**
* Checks if the container has space for the item.
*
* @param item The item to check.
* @return {@code True} if so.
*/
@ -653,6 +701,7 @@ public class Container {
/**
* Checks if this container has space to add the other container.
*
* @param c The other container.
* @return {@code True} if so.
*/
@ -674,6 +723,7 @@ public class Container {
/**
* Gets the item slot.
*
* @param item The item.
* @return The slot of the item in this container.
*/
@ -693,6 +743,7 @@ public class Container {
/**
* Gets the item instance.
*
* @param item the item.
* @return the item.
*/
@ -702,6 +753,7 @@ public class Container {
/**
* Gets the next free slot.
*
* @return The slot, or <code>-1</code> if there are no available slots.
*/
public int freeSlot() {
@ -715,6 +767,7 @@ public class Container {
/**
* Gets the slot of where to add the item.
*
* @param item The item to add.
* @return The slot where the item will go.
*/
@ -734,6 +787,7 @@ public class Container {
/**
* Gets the number of free slots.
*
* @return The number of free slots.
*/
public int freeSlots() {
@ -742,6 +796,7 @@ public class Container {
/**
* Gets the size of this container.
*
* @return The size of this container.
*/
public int itemCount() {
@ -756,6 +811,7 @@ public class Container {
/**
* Checks if the player has all the item ids in the inventory.
*
* @param itemIds The item ids.
* @return {@code True} if so.
*/
@ -770,6 +826,7 @@ public class Container {
/**
* Gets the amount of an item.
*
* @param item The item.
* @return The amount of this item in this container.
*/
@ -788,6 +845,7 @@ public class Container {
/**
* Gets the amount.
*
* @param id the id.
* @return the amount.
*/
@ -812,6 +870,7 @@ public class Container {
/**
* Checks if the container is empty.
*
* @return {@code True} if so.
*/
public boolean isEmpty() {
@ -825,6 +884,7 @@ public class Container {
/**
* Checks if the container is full.
*
* @return {@code True} if so.
*/
public boolean isFull() {
@ -840,6 +900,7 @@ public class Container {
/**
* Clears the container.
*
* @param update If the container should be updated.
*/
public void clear(boolean update) {
@ -852,6 +913,7 @@ public class Container {
/**
* Gets the wealth.
*
* @return the wealth.
*/
public int getWealth() {
@ -867,6 +929,7 @@ public class Container {
/**
* Returns an array representing this container.
*
* @return The array.
*/
public Item[] toArray() {
@ -875,6 +938,7 @@ public class Container {
/**
* Gets the listeners.
*
* @return The listeners.
*/
public List<ContainerListener> getListeners() {
@ -883,6 +947,7 @@ public class Container {
/**
* Gets the capacity.
*
* @return The capacity of this container.
*/
public int capacity() {
@ -891,6 +956,7 @@ public class Container {
/**
* Gets the event.
*
* @return the event.
*/
public ContainerEvent getEvent() {

View file

@ -86,6 +86,7 @@ public abstract class ClueScrollPlugin extends MapZone implements Plugin<Object>
}
nextStage(player, clue);
if (casket) {
player.getStatisticsManager().getCLUES_COMPLETED().incrementAmount();
player.getInventory().replace(level.getCasket(), clue.getSlot());
} else {
player.getInventory().remove(clue);

View file

@ -154,6 +154,7 @@ public final class GatheringSkillPulse extends SkillPulse<GameObject> {
Projectile.create(player, null, 1776, 35, 30, 20, 25).transform(player, new Location(player.getLocation().getX() + 2, player.getLocation().getY()), true, 25, 25).send();
player.getSkills().addExperience(Skills.WOODCUTTING, resource.getExperience());
player.getSkills().addExperience(Skills.FIREMAKING, resource.getExperience());
player.getStatisticsManager().getLOGS_OBTAINED().incrementAmount();
return false;
}
int reward = resource.getReward();
@ -176,6 +177,7 @@ public final class GatheringSkillPulse extends SkillPulse<GameObject> {
player.getPacketDispatch().sendMessage("You cut a branch from the Dramen tree.");
} else {
player.getPacketDispatch().sendMessage("You get some " + ItemDefinition.forId(reward).getName().toLowerCase() + ".");
player.getStatisticsManager().getLOGS_OBTAINED().incrementAmount();
}
// Calculate if the player should receive a bonus gem or bonus ore or both
if (!isMiningEssence && isMining) {

View file

@ -211,6 +211,10 @@ public abstract class Entity extends Node {
* @param killer The killer of this entity.
*/
public void finalizeDeath(Entity killer) {
if (killer.isPlayer()) {
if (!((Player)killer).isArtificial())
((Player)killer).getStatisticsManager().getENTITIES_KILLED().incrementAmount();
}
skills.restore();
skills.rechargePrayerPoints();
impactHandler.getImpactQueue().clear();

View file

@ -65,6 +65,7 @@ import org.crandor.game.node.entity.player.link.prayer.PrayerType;
import org.crandor.game.node.entity.player.link.quest.QuestRepository;
import org.crandor.game.node.entity.player.link.request.RequestManager;
import org.crandor.game.node.entity.player.link.skillertasks.SkillerTasks;
import org.crandor.game.node.entity.player.link.statistics.PlayerStatisticsManager;
import org.crandor.game.node.item.GroundItem;
import org.crandor.game.node.item.GroundItemManager;
import org.crandor.game.node.item.Item;
@ -99,6 +100,7 @@ import org.crandor.net.packet.out.SkillLevel;
import org.crandor.net.packet.out.UpdateSceneGraph;
import org.crandor.plugin.Plugin;
import org.crandor.tools.StringUtils;
import plugin.activity.pyramidplunder.PlunderObjectManager;
/**
@ -303,6 +305,11 @@ public class Player extends Entity {
*/
private final JobsMinigameManager jobsManager = new JobsMinigameManager(this);
/**
* The statistics manager.
*/
private final PlayerStatisticsManager statisticsManager = new PlayerStatisticsManager(this);
/**
* The logout plugins.
*/
@ -537,6 +544,10 @@ public class Player extends Entity {
}
getPacketDispatch().sendMessage("Oh dear, you are dead!");
if (!isArtificial()) {
getStatisticsManager().getDEATHS().incrementAmount();
}
//If player was a Hardcore Ironman, announce that they died
if (this.getIronmanManager().getMode().equals(IronmanMode.HARDCORE)){ //if this was checkRestriction, ultimate irons would be moved to HARDCORE_DEAD as well
String gender = this.isMale() ? "Man " : "Woman ";
@ -1342,4 +1353,8 @@ public class Player extends Entity {
public JobsMinigameManager getJobsManager() {
return jobsManager;
}
public PlayerStatisticsManager getStatisticsManager() {
return statisticsManager;
}
}

View file

@ -184,12 +184,11 @@ public class AIPlayer extends Player {
++n;
String line = sc.nextLine();
if (rand.nextInt(n) == 0) { //Chance of overwriting line is lower and lower
OSRScopyLine = line;
if (line.length() < 3) //probably an empty line
if (line.length() < 3 || line.startsWith("#")) //probably an empty line
{
System.out.println("Something went wrong reading line [" + line + "] from /data/botdata/" + fileName);
updateRandomOSRScopyLine(fileName);
continue;
}
OSRScopyLine = line;
}
}
} catch (FileNotFoundException e) {
@ -199,7 +198,9 @@ public class AIPlayer extends Player {
}
private static String retrieveRandomName(String fileName) {
do {
updateRandomOSRScopyLine(fileName);
} while (OSRScopyLine.startsWith("#")); //Comment
return OSRScopyLine.split(":")[0];
}

View file

@ -66,10 +66,12 @@ public class CombatState {
bot.tick--;
bot.eat(379);
if (bot.randomType < 30) {
bot.getSkills().setLevel(Skills.PRAYER, 99);
bot.getSkills().setStaticLevel(Skills.PRAYER, 99);
if (!(bot.getPrayer().getActive().contains(PrayerType.PROTECT_FROM_MELEE)))
bot.getPrayer().toggle(PrayerType.PROTECT_FROM_MELEE);
}
if (!bot.inCombat())
{

View file

@ -3,6 +3,7 @@ package org.crandor.game.node.entity.player.ai.minigamebots.pestcontrol;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.ai.pvmbots.PvMBots;
import org.crandor.game.node.entity.player.link.prayer.PrayerType;
import org.crandor.game.world.map.Location;
import org.crandor.net.packet.in.InteractionPacket;
import org.crandor.tools.RandomFunction;
@ -88,6 +89,7 @@ public class PestControlTestBot extends PvMBots {
}
private void attackNPCs() {
this.getWalkingQueue().setRunning(true);
List<Entity> creatures = FindTargets(this, 15);
if (creatures == null || creatures.isEmpty())
{
@ -96,7 +98,11 @@ public class PestControlTestBot extends PvMBots {
this.setCustomState("Going to portals");
combathandler.goToPortals();
} else {
try {
randomWalkAroundPoint(getMyPestControlSession(this).getSquire().getLocation(), 3);
} catch (NullPointerException e) {
//Do nothing, game just finished
}
movetimer = new Random().nextInt(15) + 6;
}
} else {
@ -121,6 +127,10 @@ public class PestControlTestBot extends PvMBots {
if (new Random().nextInt(insideBoatWalks) <= 1)
{
insideBoatWalks *= 1.5;
if (new Random().nextInt(4) == 1)
{
this.getWalkingQueue().setRunning(!this.getWalkingQueue().isRunning());
}
if (new Random().nextInt(7) == 1)
{
this.walkToPosSmart(new Location(2660, 2638));
@ -136,6 +146,10 @@ public class PestControlTestBot extends PvMBots {
}
private void enterBoat() {
if (getPrayer().getActive().contains(PrayerType.PROTECT_FROM_MELEE)) {
getPrayer().toggle(PrayerType.PROTECT_FROM_MELEE);
}
if (new Random().nextInt(3) <= 1) //Don't join instantly
{
return;

View file

@ -9,6 +9,7 @@ import org.crandor.game.node.entity.player.ai.resource.task.ResourceTasks;
import org.crandor.game.node.entity.player.ai.skillingbot.SkillingBotsBuilder;
import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.GameWorld;
import org.crandor.game.world.map.Location;
import java.sql.ResultSet;
import java.sql.Statement;
@ -39,7 +40,6 @@ public class ResourceAIPManager {
public void immerseWorld() { //There's probably a better place for this (it adds bot at bootup)
PvMBotsBuilder.immersiveSpawns();
LumbridgeBotHandler.immersiveLumbridge();
//AIPBuilder.immersiveSpawns();
//SkillingBotsBuilder.immersiveSpawnsSkillingBots();
System.out.println("Loaded immerseWorld");
}

View file

@ -40,8 +40,6 @@ public class SkillingBot extends AIPlayer {
default:
break;
}
// TODO Auto-generated constructor stub
}
@Override

View file

@ -177,6 +177,7 @@ public final class SkillingBotsBuilder extends AIPlayer {
bot.setInteractionRange(25);
}
//These bots are disabled because they somehow break pets
public static void immersiveSpawnsSkillingBots()
{
// Varrock Mine

View file

@ -149,6 +149,9 @@ public final class PlayerParser {
case 46:
player.getSkills().parseExpRate(buffer);
break;
case 47:
player.getStatisticsManager().parse(buffer);
break;
default:
System.err.println("[Player parsing] Unhandled opcode: " + opcode + " for " + player.getName() + " - [log=" + Arrays.toString(opcodeLog) + "].");
break;
@ -303,6 +306,8 @@ public final class PlayerParser {
player.getSkills().saveExpRate(buffer.put((byte) 46));
player.getStatisticsManager().save(buffer.put((byte)47));
buffer.put((byte) 0); // EOF opcode
buffer.flip();
File file = new File(directory + "players/" + player.getName() + ".save");

View file

@ -0,0 +1,115 @@
package org.crandor.game.node.entity.player.link.statistics;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.info.login.SavingModule;
/**
* Stuff
* @author jamix77
*
*/
public class PlayerStatisticsManager implements SavingModule {
/**
* Array of statistics.
*/
private final ArrayList<Statistic> STATISTICS = new ArrayList<Statistic>();
private Statistic
AL_KHARID_GATE_PASSES,
FLAX_PICKED,
CLUES_COMPLETED,
ENTITIES_KILLED,
DEATHS,
LOGS_OBTAINED;
/**
* The player instance for this manager.
*/
private final Player player;
public PlayerStatisticsManager(Player player) {
this.player = player;
if (!player.isArtificial())
initStats();
}
private void initStats() {
AL_KHARID_GATE_PASSES = new Statistic(player,this);
FLAX_PICKED = new Statistic(player,this);
CLUES_COMPLETED = new Statistic(player,this);
LOGS_OBTAINED = new Statistic(player,this);
ENTITIES_KILLED = new Statistic(player,this);
DEATHS = new Statistic(player,this);
}
@Override
public void save(ByteBuffer buffer) {
for (int i = 0; i < STATISTICS.size(); i++) {
Statistic s = STATISTICS.get(i);
buffer.put((byte) 1).putInt(i).putInt(s.getStatisticalAmount());
}
buffer.put((byte)0);
}
@Override
public void parse(ByteBuffer buffer) {
int opcode;
while ((opcode = buffer.get() & 0xFF) != 0) {
switch (opcode) {
case 1:
int index = buffer.getInt();
int amount = buffer.getInt();
STATISTICS.get(index).setStatisticalAmount(amount);
break;
}
}
}
/**
* Add a statistic to the arraylist.
* @param statistic
*/
public void addStatistic(Statistic statistic) {
STATISTICS.add(statistic);
}
public ArrayList<Statistic> getSTATISTICS() {
return STATISTICS;
}
public Statistic getAL_KHARID_GATE_PASSES() {
return AL_KHARID_GATE_PASSES;
}
public Statistic getFLAX_PICKED() {
return FLAX_PICKED;
}
public Statistic getCLUES_COMPLETED() {
return CLUES_COMPLETED;
}
public Statistic getLOGS_OBTAINED() {
return LOGS_OBTAINED;
}
public Statistic getENTITIES_KILLED() {
return ENTITIES_KILLED;
}
public Statistic getDEATHS() {
return DEATHS;
}
}

View file

@ -0,0 +1,85 @@
package org.crandor.game.node.entity.player.link.statistics;
import org.crandor.game.node.entity.player.Player;
/**
* A singular statistic.
* @author jamix77
*
*/
public class Statistic {
/**
* The player instance for this manager.
*/
private final Player player;
/**
* The amount of the statistic.
*/
private int statisticalAmount;
/**
*
* Constructs a new @{Code Statistic} object.
* @param player
*/
public Statistic(Player player, PlayerStatisticsManager sm) {
this(player,0,sm);
}
/**
*
* Constructs a new @{Code Statistic} object.
* @param player
* @param amount
*/
public Statistic(Player player,int amount, PlayerStatisticsManager sm) {
this.player = player;
this.statisticalAmount = amount;
sm.addStatistic(this);
}
/**
* Increase only by one.
*/
public void incrementAmount() {
increaseAmount(1);
}
/**
* Decrease only by one.
*/
public void decrementAmount() {
decreaseAmount(1);
}
/**
* Increase by a certain amount.
* @param amount
*/
public void increaseAmount(int amount) {
statisticalAmount += amount;
}
/**
* Decrease by a certain amount.
* @param amount
*/
public void decreaseAmount(int amount) {
statisticalAmount -= amount;
}
/**
* @return the amount
*/
public int getStatisticalAmount() {
return statisticalAmount;
}
public void setStatisticalAmount(int statisticalAmount) {
this.statisticalAmount = statisticalAmount;
}
}

View file

@ -5,6 +5,7 @@ import org.crandor.game.content.activity.ActivityManager;
import org.crandor.game.interaction.OptionHandler;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.ai.pvmbots.PvMBotsBuilder;
import org.crandor.game.node.entity.player.info.Rights;
import org.crandor.game.node.item.Item;
import org.crandor.game.node.object.GameObject;
@ -15,12 +16,17 @@ import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.plugin.Plugin;
import java.util.ArrayList;
/**
* Handles pest control objects.
* @author Emperor
*/
public final class PCObjectHandler extends OptionHandler {
public boolean pcbotsSpawned = false;
public ArrayList<String> playersJoined = new ArrayList<>();
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
// Barricades
@ -91,6 +97,17 @@ public final class PCObjectHandler extends OptionHandler {
}
switch (object.getId()) {
case 14315: // Novice
if (!pcbotsSpawned) { //First person to join gets bots to play with
pcbotsSpawned = true;
for (int pestBotsAmount = 0; pestBotsAmount < 20; pestBotsAmount++) {
PvMBotsBuilder.createPestControlTestBot(new Location(2657, 2640));
}
}
if (!playersJoined.contains(player.getUsername())) { //You also get +1 bot for every friend
playersJoined.add(player.getUsername());
PvMBotsBuilder.createPestControlTestBot(new Location(2657, 2640));
}
startActivity(player, "pest control novice", Location.create(2661, 2639, 0));
return true;
case 25631: // Intermediate

View file

@ -1,6 +1,7 @@
package plugin.command;
import org.crandor.game.container.Container;
import org.crandor.game.container.impl.EquipmentContainer;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.interaction.Interaction;
import org.crandor.game.node.entity.player.Player;
@ -145,7 +146,7 @@ public final class AIPCommandPlugin extends CommandPlugin {
player.setAttribute("aip_legion", PVPAIPActions.pvp_players = new ArrayList<>());
}
for (int i = 0; i < size; i++) {
final AIPlayer aip = AIPBuilder.create( generateLocation(player));
final AIPlayer aip = AIPBuilder.create(generateLocation(player));
aip.setControler(player);
aip.getAppearance().setGender(RandomFunction.random(3) == 1 ? Gender.FEMALE : Gender.MALE);
@ -216,6 +217,25 @@ public final class AIPCommandPlugin extends CommandPlugin {
case "immersiveworld":
case "immersive":
ResourceAIPManager.get().immerseWorld();
player.sendMessage("Started immersive world, 2");
return true;
case "botdataform":
//Dumps your current character info in the form used by data/botdata
//name:cblevel:helmet:cape:neck:weapon:chest:shield:unknown:legs:unknown:gloves:boots:
System.out.println(player.getUsername() + ":"
+ player.getProperties().getCurrentCombatLevel() + ":"
+ player.getEquipment().getAsId(EquipmentContainer.SLOT_HAT) + ":"
+ player.getEquipment().getAsId(EquipmentContainer.SLOT_CAPE) + ":"
+ player.getEquipment().getAsId(EquipmentContainer.SLOT_AMULET) + ":"
+ player.getEquipment().getAsId(EquipmentContainer.SLOT_WEAPON) + ":"
+ player.getEquipment().getAsId(EquipmentContainer.SLOT_CHEST) + ":"
+ player.getEquipment().getAsId(EquipmentContainer.SLOT_SHIELD) + ":"
+ "0" + ":"
+ player.getEquipment().getAsId(EquipmentContainer.SLOT_LEGS) + ":"
+ "0" + ":"
+ player.getEquipment().getAsId(EquipmentContainer.SLOT_HANDS) + ":"
+ player.getEquipment().getAsId(EquipmentContainer.SLOT_FEET) + ":"
);
return true;
case "fishtest":
SkillingBotsBuilder.spawnTroutLumbridge(new Location(3241, 3242));
@ -254,7 +274,7 @@ public final class AIPCommandPlugin extends CommandPlugin {
try {
arg2 = Integer.parseInt(args[1]);
} catch (Exception e) {
arg2 = 123;
arg2 = 20;
}
for (int pestBotsAmount = 0; pestBotsAmount < arg2; pestBotsAmount++) {
PvMBotsBuilder.createPestControlTestBot(player.getLocation());

View file

@ -26,6 +26,7 @@ import org.crandor.game.node.entity.player.ai.resource.ResourceAIPManager;
import org.crandor.game.node.entity.player.info.login.PlayerParser;
import org.crandor.game.node.entity.player.link.IronmanMode;
import org.crandor.game.node.entity.player.link.appearance.Gender;
import org.crandor.game.node.entity.player.link.music.MusicEntry;
import org.crandor.game.node.entity.player.link.quest.Quest;
import org.crandor.game.node.entity.player.link.skillertasks.Difficulty;
import org.crandor.game.node.entity.state.EntityState;
@ -100,6 +101,17 @@ public final class DeveloperCommandPlugin extends CommandPlugin {
@Override
public boolean parse(final Player player, String name, String[] args) {
switch (name) {
case "unlockmusic":
for (MusicEntry me : MusicEntry.getSongs().values()) {
player.getMusicPlayer().unlock(me.getId());
}
break;
case "playsong":
player.getMusicPlayer().play(MusicEntry.getSongs().get(Integer.parseInt(args[1])));
player.sendMessage("Playing song: " + MusicEntry.getSongs().get(Integer.parseInt(args[1])).getName());
break;
case "find":
try {
player.getAttributes().put("spawning_items", true);

View file

@ -2,10 +2,14 @@ package plugin.command;
import org.crandor.ServerConstants;
import org.crandor.game.component.Component;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.info.PlayerDetails;
import org.crandor.game.node.entity.player.info.Rights;
import org.crandor.game.node.entity.player.info.login.PlayerParser;
import org.crandor.game.node.entity.player.link.IronmanMode;
import org.crandor.game.node.entity.player.link.RunScript;
import org.crandor.game.node.entity.player.link.music.MusicEntry;
import org.crandor.game.node.entity.player.link.quest.Quest;
import org.crandor.game.node.entity.player.link.quest.QuestRepository;
import org.crandor.game.system.command.CommandPlugin;
@ -53,6 +57,27 @@ public final class PlayerCommandPlugin extends CommandPlugin {
TutorialStage.load(player, stage, false);
break;
*/
case "stats":
player.setAttribute("runscript", new RunScript() {
@Override
public boolean handle() {
try {
Player target = new Player(PlayerDetails.getDetails((String)value));
PlayerParser.parse(target);
if (!target.getDetails().parse()) return true;
sendHiscore(player,target);
}
catch (Exception e) {player.getDialogueInterpreter().sendPlainMessage(false, "That isn't a valid name.");}
return true;
}
});
player.getDialogueInterpreter().sendInput(true, "Enter a username:");
break;
case "shop":
CREDIT_STORE.open(player);
@ -255,6 +280,49 @@ public final class PlayerCommandPlugin extends CommandPlugin {
player.getPacketDispatch().sendString("<col=2c3e50>Reset all of your bank tabs.", 275, lineId++);
}
private void sendHiscore(Player player, Player target) {
if (player.getInterfaceManager().isOpened()) {
player.sendMessage("Finish what you're currently doing.");
return;
}
player.getInterfaceManager().open(new Component(275));
//CLear old data
for (int i = 0; i < 311; i++) {
player.getPacketDispatch().sendString("", 275, i);
}
// Title
//14 Ult IM
//13 IM
//15 HCIM
player.getPacketDispatch().sendString("" + (target.getRights() == Rights.ADMINISTRATOR ? "<img=1>" : (target.getRights() == Rights.PLAYER_MODERATOR ? "<img=0>" : (target.getIronmanManager().getMode() == IronmanMode.STANDARD ? "<img=13>" : (target.getIronmanManager().getMode() == IronmanMode.ULTIMATE ? "<img=14>" : (target.getIronmanManager().getMode() == IronmanMode.HARDCORE ? "<img=15>" : ""))))) + "<col=ae1515>" + target.getUsername() + "</col>'s stats.", 275, 2);
// Content
int lineId = 11;
player.getPacketDispatch().sendString("Total level: " + target.getSkills().getTotalLevel(), 275, lineId++);
player.getPacketDispatch().sendString("Total xp: " + StringUtils.getFormattedNumber(target.getSkills().getTotalXp()), 275, lineId++);
for (int i = 0; i < Skills.SKILL_NAME.length; i++) {
player.getPacketDispatch().sendString("" + Skills.SKILL_NAME[i] + ": " + target.getSkills().getStaticLevel(i) + " (" + StringUtils.getFormattedNumber((int) Math.round(target.getSkills().getExperience(i))) + ")", 275, lineId++);
}
//stats
player.getPacketDispatch().sendString("<col=ecf0f1>(Since 27/03/2020)</col> Al kharid passes: " + target.getStatisticsManager().getAL_KHARID_GATE_PASSES().getStatisticalAmount(), 275, lineId++);
player.getPacketDispatch().sendString("<col=ecf0f1>(Since 27/03/2020)</col> Logs chopped: " + target.getStatisticsManager().getLOGS_OBTAINED().getStatisticalAmount(), 275, lineId++);
player.getPacketDispatch().sendString("<col=ecf0f1>(Since 27/03/2020)</col> Flax picked: " + target.getStatisticsManager().getFLAX_PICKED().getStatisticalAmount(), 275, lineId++);
player.getPacketDispatch().sendString("<col=ecf0f1>(Since 27/03/2020)</col> Clue scrolls completed: " + target.getStatisticsManager().getCLUES_COMPLETED().getStatisticalAmount(), 275, lineId++);
player.getPacketDispatch().sendString("<col=ecf0f1>(Since 27/03/2020)</col> Enemies killed: " + target.getStatisticsManager().getENTITIES_KILLED().getStatisticalAmount(), 275, lineId++);
player.getPacketDispatch().sendString("<col=ecf0f1>(Since 27/03/2020)</col> Deaths: " + target.getStatisticsManager().getDEATHS().getStatisticalAmount(), 275, lineId++);
player.getPacketDispatch().sendString("Music tracks unlocked: " + target.getMusicPlayer().getUnlocked().size() + "/" + MusicEntry.getSongs().size(), 275, lineId++);
//quests
player.getPacketDispatch().sendString("", 275, lineId++);
player.getPacketDispatch().sendString("<u><col=0000FF>Quests Completed:", 275, lineId++);
for (Quest q : QuestRepository.getQuests().values()) {
player.getPacketDispatch().sendString("" + (q.isCompleted(target) ? "<col=00FF00>" : "<col=ae1515>") + q.getName() + " ", 275, lineId++);
}
}
/**
* Sends information about donating.
* @param player The player.

View file

@ -103,6 +103,7 @@ public final class BorderGuardDialogue extends DialoguePlugin {
}
if (player.getInventory().remove(COINS)) {
DoorActionHandler.handleAutowalkDoor(player, door);
player.getStatisticsManager().getAL_KHARID_GATE_PASSES().incrementAmount();
} else {
player.getPacketDispatch().sendMessage("You need 10 gold coins to pay the toll.");
}

View file

@ -2,6 +2,7 @@ package plugin.dialogue;
import org.crandor.game.content.dialogue.DialoguePlugin;
import org.crandor.game.content.dialogue.FacialExpression;
import org.crandor.game.content.skill.Skills;
import org.crandor.game.node.entity.npc.NPC;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.link.quest.Quest;
@ -104,6 +105,9 @@ public final class CaveMonk extends DialoguePlugin {
end();
break;
case 20:
if (player.getSkills().getLevel(Skills.PRAYER) > 2 && player.getSkills().getPrayerPoints() > 2) {
player.getSkills().decrementPrayerPoints(player.getSkills().getLevel(Skills.PRAYER) - 2);
}
player.getProperties().setTeleportLocation(DUNGEON);
end();
break;

View file

@ -120,6 +120,7 @@ public final class FieldPickingPlugin extends OptionHandler {
int charge = object.getCharge();
player.getAudioManager().send(2581);
player.getPacketDispatch().sendMessage("You pick some flax.");
player.getStatisticsManager().getFLAX_PICKED().incrementAmount();
if (charge > 1000 + RandomFunction.random(2, 8)) {
object.setActive(false);
object.setCharge(1000);

View file

@ -25,6 +25,7 @@ public class TollGateOptionPlugin extends OptionHandler {
player.getInventory().remove(new Item(995, 10));
player.getPacketDispatch().sendMessage("You quickly pay the 10 gold toll and go through the gates.");
DoorActionHandler.handleAutowalkDoor(player, (GameObject) node);
player.getStatisticsManager().getAL_KHARID_GATE_PASSES().incrementAmount();
return true;
} else {
player.getPacketDispatch().sendMessage("You need 10 gold to pass through the gates.");