Thread: PacketThrottleFilter (Will stop massing)

Page 1 of 5 123 ... LastLast
Results 1 to 10 of 47
  1. #1 PacketThrottleFilter (Will stop massing) 
    Gander
    Guest
    You can easily modify this to work with your server.

    Code:
    package org.gander.core.packet;
    
    import org.gander.core.Session;
    
    /**
     * @author Gander
     * @Date: 10-Feb-2008
     * @Time: 16:59:20.
     */
    public class PacketThrottleFilter {
    
        public PacketThrottleFilter() {
            this.lastPacketRecieved = System.currentTimeMillis();
            this.setThrottleDelay(1500); // 1.5 seconds
        }
    
    
        /**
         * Check's if the packet 
         * @param id the packetID to be nested
         * @return  true if the delay is less than <code>throttleDelay</code>
         */
        public boolean packetThrottled(int id) {
    
            if((id != this.lastPacketID) && (this.lastPacketID != 0)) {
                return false;
            }
    
            boolean foundPacket = false;
            for(int i = 0; i < throttleFilters.length; i++){
                if(throttleFilters[i] == id) {
                    foundPacket = true;
                    break;
                }
            }
    
            if(!foundPacket) {
                return foundPacket; 
            }
    
            int check = (int)(System.currentTimeMillis() - this.lastPacketRecieved);
            if(check < this.throttleDelay) {
                return true;
            }
    
            this.lastPacketID = id;
            this.lastPacketRecieved = System.currentTimeMillis();
             return false;
        }
    
        /**
         * Set's the Delay to the parameter
         * @param delay the delay to set the ThrottleDelay to the <code>delay</code>
         */
        public void setThrottleDelay(int delay) {
            this.throttleDelay = delay;
        }
    
        /**
         * Get's the last packet time
         * @return the last packet Time
         */
        public long getLastPacketTime(){
            return this.lastPacketRecieved;
        }
    
        /**
         * Gets the Throttle delay
         * @return  An integer representing the Throttle delay
         */
        public int getThrottledDelay() {
            return this.throttleDelay;
        }
    
       private static final int[] throttleFilters = {185, 4, 103, 132, 252, 41, 145, 72, 122, 181, 87, 155, 192, 236, 73};
       private long lastPacketRecieved;
       private int throttleDelay = 0;
       private int lastPacketID = 0;
    }

    Clues:

    Code:
    private PacketThrottleFilter packetThrottleFilter;
    Code:
    this.packetThrottleFilter = new PacketThrottleFilter()
    Code:
    if(this.packetThrottleFilter.packetThrottled(packeType) { 
       return false;
    }
    It will stop anyone spamming the same packet over and over again. (1.5 Second delay)

    I'm not going to wipe your *** for you and tell you how to implement it, if you know how to implement it then you deserve to have it.
     

  2. #2  
    Registered Member
    Yamaha's Avatar
    Join Date
    Nov 2007
    Age
    28
    Posts
    597
    Thanks given
    0
    Thanks received
    0
    Rep Power
    141
    Thanks nice one Gander.
     

  3. #3  
    Registered Member

    Join Date
    Jul 2006
    Age
    27
    Posts
    1,247
    Thanks given
    0
    Thanks received
    5
    Rep Power
    190
    nice gander
    just yoricka...
     

  4. #4  
    Reload
    Guest
    Nice one gander
     

  5. #5  
    Registered Member
    fabjan's Avatar
    Join Date
    Jul 2007
    Age
    27
    Posts
    552
    Thanks given
    0
    Thanks received
    0
    Rep Power
    101
    nice one Gander, the java conventions seem OK to me..
    going to use for sure
    Please vote:
    [Only registered and activated users can see links. ]
    btb.servegame.com:
     

  6. #6  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,747
    Thanks given
    354
    Thanks received
    1,368
    Rep Power
    3032
    gander, u suck. stop referencing rs2d.
     

  7. #7  
    Gander
    Guest
    Quote Originally Posted by super_ View Post
    gander, u suck. stop referencing rs2d.
    wat r u talkin about m8??????????????????????????????????????/
     

  8. #8  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,747
    Thanks given
    354
    Thanks received
    1,368
    Rep Power
    3032
    Quote Originally Posted by Gander View Post
    wat r u talkin about m8??????????????????????????????????????/
    you get all your ideas and **** from rs2d.
     

  9. #9  
    mr s' sock
    Guest
    Definately not needed, this is the reason actionTimer is made.
     

  10. #10  
    Registered Member

    Join Date
    Aug 2007
    Posts
    2,395
    Thanks given
    2
    Thanks received
    63
    Rep Power
    558
    Definately not needed, this is the reason actionTimer is made.
    lol,
    you can click trough the action timer

    does this really stops massing?
    it seems to be, but have u tested?
    [Only registered and activated users can see links. ]
     

Page 1 of 5 123 ... LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •