Placement config code cleanup

This commit is contained in:
Anuken
2020-09-05 20:41:50 -04:00
parent c483ae2c23
commit f87bd78674
14 changed files with 67 additions and 92 deletions

View File

@@ -27,21 +27,10 @@ public class Administration{
/** All player info. Maps UUIDs to info. This persists throughout restarts. Do not access directly. */
private ObjectMap<String, PlayerInfo> playerInfo = new ObjectMap<>();
private IntIntMap lastPlaced = new IntIntMap();
public Administration(){
load();
Events.on(ResetEvent.class, e -> lastPlaced = new IntIntMap());
//keep track of who placed what on the server
Events.on(BlockBuildEndEvent.class, e -> {
//players should be able to configure their own tiles
if(net.server() && e.unit != null && e.unit.isPlayer()){
lastPlaced.put(e.tile.pos(), e.unit.getPlayer().id());
}
});
//anti-spam
addChatFilter((player, message) -> {
long resetTime = Config.messageRateLimit.num() * 1000;
@@ -80,12 +69,6 @@ public class Administration{
action.type != ActionType.placeBlock &&
Config.antiSpam.bool()){
//make sure players can configure their own stuff, e.g. in schematics - but only once.
if(lastPlaced.get(action.tile.pos(), -1) == action.player.id()){
lastPlaced.remove(action.tile.pos());
return true;
}
Ratekeeper rate = action.player.getInfo().rate;
if(rate.allow(Config.interactRateWindow.num() * 1000, Config.interactRateLimit.num())){
return true;
@@ -93,13 +76,6 @@ public class Administration{
if(rate.occurences > Config.interactRateKick.num()){
action.player.kick("You are interacting with too many blocks.", 1000 * 30);
}else if(action.player.getInfo().messageTimer.get(60f * 2f)){
//I don't know what causes this so I'll make it log an error instead
new Exception("!!REPORT TO ANUKE: " + action.player.name + " was (likely) incorrectly ratelimited. " +
"action=" + action.type +
" player=" + action.player.name + "#" + action.player.id +
" tile=" + action.tile).printStackTrace();
action.player.sendMessage("[scarlet]You are interacting with blocks too quickly.");
}