From ae838b939236271dc6b54532e3d62e82372a6270 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Wed, 3 Mar 2021 15:09:05 +0100 Subject: [PATCH] Trace times joined & kicked (#4844) * Trace times joined & kicked * Make mindustry.* import obsolete --- core/assets/bundles/bundle.properties | 4 +++- core/src/mindustry/core/NetServer.java | 3 ++- core/src/mindustry/io/TypeIO.java | 4 +++- core/src/mindustry/net/Administration.java | 5 ++++- core/src/mindustry/ui/dialogs/TraceDialog.java | 4 ++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index c76e21001d..671a34ebaf 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -216,9 +216,11 @@ server.hidden = Hidden trace = Trace Player trace.playername = Player name: [accent]{0} trace.ip = IP: [accent]{0} -trace.id = Unique ID: [accent]{0} +trace.id = ID: [accent]{0} trace.mobile = Mobile Client: [accent]{0} trace.modclient = Custom Client: [accent]{0} +trace.times.joined = Times Joined: [accent]{0} +trace.times.kicked = Times Kicked: [accent]{0} invalidid = Invalid client ID! Submit a bug report. server.bans = Bans server.bans.none = No banned players found! diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index 36d24770dc..5054402310 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -735,7 +735,8 @@ public class NetServer implements ApplicationListener{ other.kick(KickReason.kick); info("&lc@ has kicked @.", player.name, other.name); }else if(action == AdminAction.trace){ - TraceInfo info = new TraceInfo(other.con.address, other.uuid(), other.con.modclient, other.con.mobile); + PlayerInfo stats = netServer.admins.getInfo(other.uuid()); + TraceInfo info = new TraceInfo(other.con.address, other.uuid(), other.con.modclient, other.con.mobile, stats.timesJoined, stats.timesKicked); if(player.con != null){ Call.traceInfo(player.con, other, info); }else{ diff --git a/core/src/mindustry/io/TypeIO.java b/core/src/mindustry/io/TypeIO.java index 9e8ab187dd..e91ebedb6f 100644 --- a/core/src/mindustry/io/TypeIO.java +++ b/core/src/mindustry/io/TypeIO.java @@ -572,10 +572,12 @@ public class TypeIO{ writeString(write, trace.uuid); write.b(trace.modded ? (byte)1 : 0); write.b(trace.mobile ? (byte)1 : 0); + write.i(trace.timesJoined); + write.i(trace.timesKicked); } public static TraceInfo readTraceInfo(Reads read){ - return new TraceInfo(readString(read), readString(read), read.b() == 1, read.b() == 1); + return new TraceInfo(readString(read), readString(read), read.b() == 1, read.b() == 1, read.i(), read.i()); } public static void writeStringData(DataOutput buffer, String string) throws IOException{ diff --git a/core/src/mindustry/net/Administration.java b/core/src/mindustry/net/Administration.java index bd312bacdf..3ef4784dda 100644 --- a/core/src/mindustry/net/Administration.java +++ b/core/src/mindustry/net/Administration.java @@ -584,12 +584,15 @@ public class Administration{ public static class TraceInfo{ public String ip, uuid; public boolean modded, mobile; + public int timesJoined, timesKicked; - public TraceInfo(String ip, String uuid, boolean modded, boolean mobile){ + public TraceInfo(String ip, String uuid, boolean modded, boolean mobile, int timesJoined, int timesKicked){ this.ip = ip; this.uuid = uuid; this.modded = modded; this.mobile = mobile; + this.timesJoined = timesJoined; + this.timesKicked = timesKicked; } } diff --git a/core/src/mindustry/ui/dialogs/TraceDialog.java b/core/src/mindustry/ui/dialogs/TraceDialog.java index c6582aa005..53b4f59b92 100644 --- a/core/src/mindustry/ui/dialogs/TraceDialog.java +++ b/core/src/mindustry/ui/dialogs/TraceDialog.java @@ -32,6 +32,10 @@ public class TraceDialog extends BaseDialog{ table.row(); table.add(Core.bundle.format("trace.mobile", info.mobile)); table.row(); + table.add(Core.bundle.format("trace.times.joined", info.timesJoined)); + table.row(); + table.add(Core.bundle.format("trace.times.kicked", info.timesKicked)); + table.row(); table.add().pad(5); table.row();