Thread: Modified PJA #459

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 Modified PJA #459 
    Registered Member
    Stephen OG's Avatar
    Join Date
    Aug 2014
    Posts
    173
    Thanks given
    114
    Thanks received
    56
    Rep Power
    182
    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.

    Spoiler for Media:






    Credits:
    - Original PJA creators
    - Nikki (Used some of her work for the clipping on firemaking)

    Enjoy guys
    Reply With Quote  
     

  2. #2  
    Registered Member K Suave's Avatar
    Join Date
    Dec 2008
    Posts
    298
    Thanks given
    54
    Thanks received
    17
    Rep Power
    2
    java.lang.ArithmeticException: / by zero

    error giving by ur class when used to check suspiciousActivity()
    Reply With Quote  
     

  3. #3  
    Registered Member
    Stephen OG's Avatar
    Join Date
    Aug 2014
    Posts
    173
    Thanks given
    114
    Thanks received
    56
    Rep Power
    182
    Quote Originally Posted by Denzel View Post
    java.lang.ArithmeticException: / by zero

    error giving by ur class when used to check suspiciousActivity()
    Code:
    	public boolean suspiciousActivity() {
    		if (differentials.size() <= 0) {
    			return false;
    		}
    		
    		int sum = 0;
    		for (long stamp : differentials) {
    			sum += stamp;
    		}
    		
    		if (sum/differentials.size() <= 200) {
    			return true;
    		}
    		
    		return false;
    	}
    Also make sure you call pulse on clicking actions. Like I said, I never implemented it fully.
    Reply With Quote  
     

  4. #4  
    Banned Modified PJA #459 Market Banned


    Join Date
    Jan 2011
    Age
    26
    Posts
    3,112
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    Code:
    Added an 'ActiveClasses' class which instantiates all classes that need to be kept alive throughout the server's online duration.
    ummm what

    Code:
    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.
    why would you allocate a new thread just to handle logic for fires? that's what cycle based tasks are for


    not trying to hate on you, just curious
    Reply With Quote  
     

  5. #5  
    Officially Running

    Mr Dream's Avatar
    Join Date
    Dec 2013
    Posts
    1,922
    Thanks given
    555
    Thanks received
    295
    Rep Power
    905
    Error when running server!!!
    Attached image
    Attached image
    Reply With Quote  
     

  6. #6  
    Registered Member
    Stephen OG's Avatar
    Join Date
    Aug 2014
    Posts
    173
    Thanks given
    114
    Thanks received
    56
    Rep Power
    182
    Quote Originally Posted by lare96 View Post
    Code:
    Added an 'ActiveClasses' class which instantiates all classes that need to be kept alive throughout the server's online duration.
    ummm what

    Code:
    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.
    why would you allocate a new thread just to handle logic for fires? that's what cycle based tasks are for


    not trying to hate on you, just curious
    Well, when I was learning about threads I assumed that any task that would become sort of bloated should be run on a separate thread. Also, if there's a couple hundred fires in the world wouldn't that create considerable stress on the server? Any criticism is welcomed by the way since I'm self taught I don't really know the 'industry standards' I guess.

    Also so the active classes bit. I basically created one class to host other classes that should be instantiated once and kept alive throughout the server being run. So for instance the definition loader class contains arrays of all the definitions so I have one instance of that and to keep clutter down I made the active classes to hold all of those types of classes. Then in the constructor for active classes all of classes in it are instantiated.

    Quote Originally Posted by Fear Figment View Post
    Error when running server!!!
    What's the error?
    Reply With Quote  
     

  7. #7  
    Banned
    Join Date
    Mar 2014
    Posts
    628
    Thanks given
    109
    Thanks received
    181
    Rep Power
    0
    Thanks for the contribution.
    Reply With Quote  
     

  8. #8  
    Banned
    Join Date
    Mar 2014
    Posts
    155
    Thanks given
    159
    Thanks received
    24
    Rep Power
    0
    Thanks for the contribution.
    Reply With Quote  
     

  9. #9  
    Banned Modified PJA #459 Market Banned


    Join Date
    Jan 2011
    Age
    26
    Posts
    3,112
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    Quote Originally Posted by Meth View Post
    Well, when I was learning about threads I assumed that any task that would become sort of bloated should be run on a separate thread. Also, if there's a couple hundred fires in the world wouldn't that create considerable stress on the server? Any criticism is welcomed by the way since I'm self taught I don't really know the 'industry standards' I guess.
    100 fires is not going to create any stress on the server at all, actually handling logic for 1000 fires wouldn't even take 1 millisecond. having 50 different threads running at the same time, all executing basic logic that can be done on the game thread is a waste of resources
    Reply With Quote  
     

  10. #10  
    Registered Member
    Stephen OG's Avatar
    Join Date
    Aug 2014
    Posts
    173
    Thanks given
    114
    Thanks received
    56
    Rep Power
    182
    Quote Originally Posted by lare96 View Post
    100 fires is not going to create any stress on the server at all, actually handling logic for 1000 fires wouldn't even take 1 millisecond. having 50 different threads running at the same time, all executing basic logic that can be done on the game thread is a waste of resources
    Thanks for the advice, I'll remove it
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Compiling PJA 459 with eclipse
    By redvader in forum Help
    Replies: 15
    Last Post: 04-09-2012, 01:18 AM
  2. Character Files (PJA 459)
    By extra in forum Help
    Replies: 1
    Last Post: 07-28-2010, 10:54 AM
  3. PJA 459 compiler no eclipse needed
    By 2O15 in forum Configuration
    Replies: 26
    Last Post: 07-01-2010, 07:47 AM
  4. Problems with PJA 459 [Hyperion]
    By Renew in forum Help
    Replies: 4
    Last Post: 06-25-2010, 01:41 AM
  5. Pja 459
    By Renew in forum Help
    Replies: 5
    Last Post: 05-13-2010, 10:58 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •