Yeah, you read the title correctly. PJA source . Anyways... I was going to use it for a project, but then shit hit the fan and now I'm just working on it for pleasure. This will probably be one of many more releases.
Features:
Code:
- Rewrote item definitions and NPC definitions. Ready for JSON serialization.
- Added an 'ActiveClasses' class which instantiates all classes that need to be kept alive throughout the server's online duration.
- Added zones and a zone manager.
- Added anti macro system, untested (>.<)
- Added definition loader.
- Loaded new json definitons for both items and npcs.
- Completely rewrote firemaking, would say it's 95% done. Clipped, as well as supports the colored fires. Also the existing fires run on a separate thread.
Known bugs:
Code:
- To fix the 'change pw bug' java.io.EOFException: Unexpected end of ZLIB input stream (Haven't got around to fixing it yet, but this should help you out.)
I plan to slowly rewrite most of the content. However, I cannot say when the next release will be. If there's any features you guys want added just leave a comment below and I might do it. I would say the biggest difference between this and the original is the conversion from XML to JSON for data. There's still data I have yet to convert, but I'll eventually get it done.
Here's is class I wrote in an attempt to prevent people for auto clicking. Basically what you would do is assign the class to an individual player and each time they click it would the click time to the differentials array. Every so often you could check the time differentials and if the average between all of them is a really small number, they're probably auto clicking because a person wouldn't be able to simulate that very well, nor would they want to probably. I haven't tested this yet but here's the class so let me know what you think about it.
Code:
package org.hyperion.rs2.util.anticheat;
import java.util.ArrayList;
/**
* Helps prevent player's from auto clicking.
* @author Stephen Andrews
*/
public class MouseUtility {
/**
* An array of all time differentials.
*/
private ArrayList<Long> differentials = new ArrayList<Long>();
/**
* The last click invoked by the player.
*/
private long lastClick;
/**
* The current click invoked by the player.
*/
private long currentClick;
/**
* Gets the differentials array.
* @return The differentials array.
*/
public ArrayList<Long> getDifferentials() {
return differentials;
}
/**
* Gets the time differential between the clicks.
* @return The time differential.
*/
public long getTimeDifferential() {
return currentClick - lastClick;
}
/**
* Gets the last click.
* @return The last click.
*/
public long getLastClick() {
return lastClick;
}
/**
* Sets the last click.
* @param clickTime The time of the click.
*/
public void setLastClick(long clickTime) {
lastClick = clickTime;
}
/**
* Gets the current click.
* @return The current click.
*/
public long getCurrentClick() {
return currentClick;
}
/**
* Sets the current click.
* @param clickTime The time of the click.
*/
public void setCurrentClick(long clickTime) {
currentClick = clickTime;
}
/**
* Creates a 'pulse' which logs the player's current and last click.
* @param time The time of the client in ms.
*/
public void pulse(long time) {
if (currentClick == 0) {
currentClick = time;
} else {
lastClick = currentClick;
currentClick = time;
differentials.add(getTimeDifferential());
}
}
/**
* Determines whether or not a player is to be suspected of macroing.
* @return <code>true</code> if so, <code>false</code> if not.
*/
public boolean suspiciousActivity() {
int sum = 0;
for (long stamp : differentials) {
sum += stamp;
}
if (sum/differentials.size() <= 200) {
return true;
}
return false;
}
/**
* Clears the differentials array.
*/
public void clear() {
differentials.clear();
}
}
If there seems to be suspicious activity, all I have it doing now is alerting staff:
Code:
package org.hyperion.rs2.event.impl;
import org.hyperion.rs2.event.Event;
import org.hyperion.rs2.model.Player;
import org.hyperion.rs2.model.World;
import org.hyperion.rs2.util.Yeller;
public class MacroCheckEvent extends Event {
/**
* The macro check cycle.
*/
private final static long DELAY = 600000;
/**
* Constructs a macro check event.
* @param delay The delay of the event.
*/
public MacroCheckEvent() {
super(DELAY);
}
@Override
public void execute() {
for (Player player : World.getWorld().getPlayers()) {
if (player.getMouseUtility().suspiciousActivity()) {
Yeller.alertStaff(player.getName() + " may be macroing. Please investigate this.");
}
player.getMouseUtility().clear();
}
}
}
Anyways time for some media.
Credits:
- Original PJA creators
- Nikki (Used some of her work for the clipping on firemaking)
Enjoy guys