Cleanup continues
This commit is contained in:
@@ -5,11 +5,11 @@ import arc.func.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import arc.util.pooling.*;
|
||||
import arc.util.pooling.Pool.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Administration{
|
||||
//anti-spam
|
||||
addChatFilter((player, message) -> {
|
||||
long resetTime = Config.messageRateLimit.num() * 1000;
|
||||
if(Config.antiSpam.bool() && !player.isLocal && !player.isAdmin){
|
||||
if(Config.antiSpam.bool() && !player.isLocal() && !player.admin()){
|
||||
//prevent people from spamming messages quickly
|
||||
if(resetTime > 0 && Time.timeSinceMillis(player.getInfo().lastMessageTime) < resetTime){
|
||||
//supress message
|
||||
@@ -39,7 +39,7 @@ public class Administration{
|
||||
player.getInfo().messageInfractions ++;
|
||||
//kick player for spamming and prevent connection if they've done this several times
|
||||
if(player.getInfo().messageInfractions >= Config.messageSpamKick.num() && Config.messageSpamKick.num() != 0){
|
||||
player.con.kick("You have been kicked for spamming.", 1000 * 60 * 2);
|
||||
player.con().kick("You have been kicked for spamming.", 1000 * 60 * 2);
|
||||
}
|
||||
return null;
|
||||
}else{
|
||||
@@ -86,7 +86,7 @@ public class Administration{
|
||||
}
|
||||
|
||||
/** Filters out a chat message. */
|
||||
public @Nullable String filterMessage(Player player, String message){
|
||||
public @Nullable String filterMessage(Playerc player, String message){
|
||||
String current = message;
|
||||
for(ChatFilter f : chatFilters){
|
||||
current = f.filter(player, message);
|
||||
@@ -101,7 +101,7 @@ public class Administration{
|
||||
}
|
||||
|
||||
/** @return whether this action is allowed by the action filters. */
|
||||
public boolean allowAction(Player player, ActionType type, Tile tile, Cons<PlayerAction> setter){
|
||||
public boolean allowAction(Playerc player, ActionType type, Tile tile, Cons<PlayerAction> setter){
|
||||
PlayerAction act = Pools.obtain(PlayerAction.class, PlayerAction::new);
|
||||
setter.get(act.set(player, type, tile));
|
||||
for(ActionFilter filter : actionFilters){
|
||||
@@ -172,7 +172,7 @@ public class Administration{
|
||||
getCreateInfo(id).banned = true;
|
||||
|
||||
save();
|
||||
Events.fire(new PlayerBanEvent(Vars.playerGroup.find(p -> id.equals(p.uuid))));
|
||||
Events.fire(new PlayerBanEvent(Groups.player.find(p -> id.equals(p.uuid()))));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ public class Administration{
|
||||
info.banned = false;
|
||||
bannedIPs.removeAll(info.ips, false);
|
||||
save();
|
||||
Events.fire(new PlayerUnbanEvent(Vars.playerGroup.find(p -> id.equals(p.uuid))));
|
||||
Events.fire(new PlayerUnbanEvent(Groups.player.find(p -> id.equals(p.uuid()))));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ public class Administration{
|
||||
/** Handles chat messages from players and changes their contents. */
|
||||
public interface ChatFilter{
|
||||
/** @return the filtered message; a null string signals that the message should not be sent. */
|
||||
@Nullable String filter(Player player, String message);
|
||||
@Nullable String filter(Playerc player, String message);
|
||||
}
|
||||
|
||||
/** Allows or disallows player actions. */
|
||||
@@ -539,7 +539,7 @@ public class Administration{
|
||||
/** Defines a (potentially dangerous) action that a player has done in the world.
|
||||
* These objects are pooled; do not cache them! */
|
||||
public static class PlayerAction implements Poolable{
|
||||
public @NonNull Player player;
|
||||
public @NonNull Playerc player;
|
||||
public @NonNull ActionType type;
|
||||
public @NonNull Tile tile;
|
||||
|
||||
@@ -554,7 +554,7 @@ public class Administration{
|
||||
public @Nullable Item item;
|
||||
public int itemAmount;
|
||||
|
||||
public PlayerAction set(Player player, ActionType type, Tile tile){
|
||||
public PlayerAction set(Playerc player, ActionType type, Tile tile){
|
||||
this.player = player;
|
||||
this.type = type;
|
||||
this.tile = tile;
|
||||
|
||||
@@ -118,7 +118,7 @@ public class CrashSender{
|
||||
ex(() -> value.addChild("revision", new JsonValue(Version.revision)));
|
||||
ex(() -> value.addChild("net", new JsonValue(fn)));
|
||||
ex(() -> value.addChild("server", new JsonValue(fs)));
|
||||
ex(() -> value.addChild("players", new JsonValue(Vars.playerGroup.size())));
|
||||
ex(() -> value.addChild("players", new JsonValue(Groups.player.size())));
|
||||
ex(() -> value.addChild("state", new JsonValue(Vars.state.getState().name())));
|
||||
ex(() -> value.addChild("os", new JsonValue(System.getProperty("os.name") + "x" + (OS.is64Bit ? "64" : "32"))));
|
||||
ex(() -> value.addChild("trace", new JsonValue(parseException(exception))));
|
||||
|
||||
@@ -3,7 +3,6 @@ package mindustry.net;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.net.Administration.*;
|
||||
@@ -16,8 +15,9 @@ import static mindustry.Vars.netServer;
|
||||
|
||||
public abstract class NetConnection{
|
||||
public final String address;
|
||||
public String uuid = "AAAAAAAA", usid = uuid;
|
||||
public boolean mobile, modclient;
|
||||
public @Nullable Player player;
|
||||
public @Nullable Playerc player;
|
||||
|
||||
/** ID of last recieved client snapshot. */
|
||||
public int lastRecievedClientSnapshot = -1;
|
||||
@@ -37,8 +37,8 @@ public abstract class NetConnection{
|
||||
public void kick(KickReason reason){
|
||||
Log.info("Kicking connection {0}; Reason: {1}", address, reason.name());
|
||||
|
||||
if(player != null && (reason == KickReason.kick || reason == KickReason.banned || reason == KickReason.vote) && player.uuid != null){
|
||||
PlayerInfo info = netServer.admins.getInfo(player.uuid);
|
||||
if((reason == KickReason.kick || reason == KickReason.banned || reason == KickReason.vote)){
|
||||
PlayerInfo info = netServer.admins.getInfo(uuid);
|
||||
info.timesKicked++;
|
||||
info.lastKicked = Math.max(Time.millis() + 30 * 1000, info.lastKicked);
|
||||
}
|
||||
@@ -59,11 +59,9 @@ public abstract class NetConnection{
|
||||
public void kick(String reason, int kickDuration){
|
||||
Log.info("Kicking connection {0}; Reason: {1}", address, reason.replace("\n", " "));
|
||||
|
||||
if(player != null && player.uuid != null){
|
||||
PlayerInfo info = netServer.admins.getInfo(player.uuid);
|
||||
info.timesKicked++;
|
||||
info.lastKicked = Math.max(Time.millis() + kickDuration, info.lastKicked);
|
||||
}
|
||||
PlayerInfo info = netServer.admins.getInfo(uuid);
|
||||
info.timesKicked++;
|
||||
info.lastKicked = Math.max(Time.millis() + kickDuration, info.lastKicked);
|
||||
|
||||
Call.onKick(this, reason);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package mindustry.net;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.maps.Map;
|
||||
@@ -16,7 +16,7 @@ import static mindustry.Vars.*;
|
||||
|
||||
public class NetworkIO{
|
||||
|
||||
public static void writeWorld(Player player, OutputStream os){
|
||||
public static void writeWorld(Playerc player, OutputStream os){
|
||||
|
||||
try(DataOutputStream stream = new DataOutputStream(os)){
|
||||
stream.writeUTF(JsonIO.write(state.rules));
|
||||
@@ -62,7 +62,7 @@ public class NetworkIO{
|
||||
}
|
||||
|
||||
public static ByteBuffer writeServerData(){
|
||||
String name = (headless ? Config.name.string() : player.name);
|
||||
String name = (headless ? Config.name.string() : player.name());
|
||||
String description = headless && !Config.desc.string().equals("off") ? Config.desc.string() : "";
|
||||
String map = world.getMap() == null ? "None" : world.getMap().name();
|
||||
|
||||
@@ -71,7 +71,7 @@ public class NetworkIO{
|
||||
writeString(buffer, name, 100);
|
||||
writeString(buffer, map);
|
||||
|
||||
buffer.putInt(playerGroup.size());
|
||||
buffer.putInt(Groups.player.size());
|
||||
buffer.putInt(state.wave);
|
||||
buffer.putInt(Version.build);
|
||||
writeString(buffer, Version.type);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package mindustry.net;
|
||||
|
||||
import mindustry.entities.type.Player;
|
||||
import mindustry.gen.*;
|
||||
|
||||
/**
|
||||
* Thrown when a client sends invalid information.
|
||||
*/
|
||||
public class ValidateException extends RuntimeException{
|
||||
public final Player player;
|
||||
public final Playerc player;
|
||||
|
||||
public ValidateException(Player player, String s){
|
||||
public ValidateException(Playerc player, String s){
|
||||
super(s);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user