Use JDK map for throttle
This commit is contained in:
parent
59b32a8621
commit
8e77cb35ff
@ -2,13 +2,15 @@ package net.md_5.bungee;
|
||||
|
||||
import gnu.trove.map.hash.TObjectLongHashMap;
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class ConnectionThrottle
|
||||
{
|
||||
|
||||
private final TObjectLongHashMap<InetAddress> throttle = new TObjectLongHashMap<>();
|
||||
private final Map<InetAddress, Long> throttle = new HashMap<>();
|
||||
private final int throttleTime;
|
||||
|
||||
public void unthrottle(InetAddress address)
|
||||
@ -18,10 +20,10 @@ public class ConnectionThrottle
|
||||
|
||||
public boolean throttle(InetAddress address)
|
||||
{
|
||||
long value = throttle.get( address );
|
||||
Long value = throttle.get( address );
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
throttle.put( address, currentTime );
|
||||
return value != 0 && currentTime - value < throttleTime;
|
||||
return value != null && currentTime - value < throttleTime;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user