Merge branch '6.0' of https://github.com/Anuken/Mindustry into object-config

# Conflicts:
#	core/src/mindustry/entities/traits/BuilderTrait.java
#	core/src/mindustry/entities/type/TileEntity.java
#	core/src/mindustry/game/EventType.java
#	core/src/mindustry/game/Schematics.java
#	core/src/mindustry/input/InputHandler.java
#	core/src/mindustry/io/TypeIO.java
#	core/src/mindustry/world/Block.java
#	core/src/mindustry/world/blocks/distribution/Sorter.java
This commit is contained in:
Anuken
2020-03-03 21:33:03 -05:00
1356 changed files with 28653 additions and 24877 deletions
+31 -16
View File
@@ -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,9 +39,8 @@ 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);
}
player.getInfo().lastSentMessage = message;
return null;
}else{
player.getInfo().messageInfractions = 0;
@@ -87,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);
@@ -102,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){
@@ -173,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;
}
@@ -191,7 +190,7 @@ public class Administration{
}
}
bannedIPs.removeValue(ip, false);
bannedIPs.remove(ip, false);
if(found){
save();
@@ -213,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;
}
@@ -231,7 +230,7 @@ public class Administration{
}
/**
* Returns list of all players with admin status
* Returns list of all players which are banned
*/
public Array<PlayerInfo> getBanned(){
Array<PlayerInfo> result = new Array<>();
@@ -325,7 +324,8 @@ public class Administration{
ObjectSet<PlayerInfo> result = new ObjectSet<>();
for(PlayerInfo info : playerInfo.values()){
if(info.lastName.toLowerCase().equals(name.toLowerCase()) || (info.names.contains(name, false))
if(info.lastName.equalsIgnoreCase(name) || (info.names.contains(name, false))
|| Strings.stripColors(Strings.stripColors(info.lastName)).equals(name)
|| info.ips.contains(name, false) || info.id.equals(name)){
result.add(info);
}
@@ -334,6 +334,19 @@ public class Administration{
return result;
}
/** Finds by name, using contains(). */
public ObjectSet<PlayerInfo> searchNames(String name){
ObjectSet<PlayerInfo> result = new ObjectSet<>();
for(PlayerInfo info : playerInfo.values()){
if(info.names.contains(n -> n.toLowerCase().contains(name.toLowerCase()) || Strings.stripColors(n).trim().toLowerCase().contains(name))){
result.add(info);
}
}
return result;
}
public Array<PlayerInfo> findByIPs(String ip){
Array<PlayerInfo> result = new Array<>();
@@ -397,6 +410,7 @@ public class Administration{
/** Server configuration definition. Each config value can be a string, boolean or number. */
public enum Config{
name("The server name as displayed on clients.", "Server", "servername"),
desc("The server description, displayed under the name. Max 100 characters.", "off"),
port("The port to host on.", Vars.port),
autoUpdate("Whether to auto-update and exit when a new bleeding-edge update arrives.", false),
showConnectMessages("Whether to display connect/disconnect messages.", true),
@@ -405,7 +419,7 @@ public class Administration{
crashReport("Whether to send crash reports.", false, "crashreport"),
logging("Whether to log everything to files.", true),
strict("Whether strict mode is on - corrects positions and prevents duplicate UUIDs.", true),
antiSpam("Whether spammers are automatically kicked and rate-limited.", true),
antiSpam("Whether spammers are automatically kicked and rate-limited.", headless),
messageRateLimit("Message rate limit in seconds. 0 to disable.", 0),
messageSpamKick("How many times a player must send a message before the cooldown to get kicked. 0 to disable.", 3),
socketInput("Allows a local application to control this server through a local TCP socket.", false, "socket", () -> Events.fire(Trigger.socketConfigChanged)),
@@ -501,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. */
@@ -525,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;
@@ -540,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;
@@ -555,6 +569,7 @@ public class Administration{
player = null;
type = null;
tile = null;
block = null;
}
}