Power-based ammo / Refactoring / IP kicks / Fixes
This commit is contained in:
@@ -24,6 +24,7 @@ public class Administration{
|
||||
public Seq<ChatFilter> chatFilters = new Seq<>();
|
||||
public Seq<ActionFilter> actionFilters = new Seq<>();
|
||||
public Seq<String> subnetBans = new Seq<>();
|
||||
public ObjectMap<String, Long> kickedIPs = new ObjectMap<>();
|
||||
|
||||
/** All player info. Maps UUIDs to info. This persists throughout restarts. Do not access directly. */
|
||||
private ObjectMap<String, PlayerInfo> playerInfo = new ObjectMap<>();
|
||||
@@ -86,6 +87,20 @@ public class Administration{
|
||||
});
|
||||
}
|
||||
|
||||
/** @return time at which a player would be pardoned for a kick (0 means they were never kicked) */
|
||||
public long getKickTime(String uuid, String ip){
|
||||
return Math.max(getInfo(uuid).lastKicked, kickedIPs.get(ip, 0L));
|
||||
}
|
||||
|
||||
/** Sets up kick duration for a player. */
|
||||
public void handleKicked(String uuid, String ip, long duration){
|
||||
kickedIPs.put(ip, Math.max(kickedIPs.get(ip, 0L), Time.millis() + duration));
|
||||
|
||||
PlayerInfo info = getInfo(uuid);
|
||||
info.timesKicked++;
|
||||
info.lastKicked = Math.max(Time.millis() + duration, info.lastKicked);
|
||||
}
|
||||
|
||||
public Seq<String> getSubnetBans(){
|
||||
return subnetBans;
|
||||
}
|
||||
|
||||
@@ -65,9 +65,7 @@ public abstract class NetConnection{
|
||||
|
||||
Log.info("Kicking connection @; Reason: @", address, reason.replace("\n", " "));
|
||||
|
||||
PlayerInfo info = netServer.admins.getInfo(uuid);
|
||||
info.timesKicked++;
|
||||
info.lastKicked = Math.max(Time.millis() + kickDuration, info.lastKicked);
|
||||
netServer.admins.handleKicked(uuid, address, kickDuration);
|
||||
|
||||
Call.kick(this, reason);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user