Fixed compilation errors / Re-added basic trace dialog

This commit is contained in:
Anuken
2019-05-10 16:02:05 -04:00
parent 0ff56e3a68
commit 68faae69c5
7 changed files with 52 additions and 33 deletions

View File

@@ -20,6 +20,7 @@ import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.game.Version;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.gen.RemoteReadClient;
import io.anuke.mindustry.net.Administration.TraceInfo;
import io.anuke.mindustry.net.*;
import io.anuke.mindustry.net.Net.SendMode;
import io.anuke.mindustry.net.Packets.*;
@@ -158,6 +159,13 @@ public class NetClient implements ApplicationListener{
return "[#" + player.color.toString().toUpperCase() + "]" + name;
}
@Remote(variants = Variant.one)
public static void onTraceInfo(Player player, TraceInfo info){
if(player != null){
ui.traces.show(player, info);
}
}
@Remote(variants = Variant.one, priority = PacketPriority.high)
public static void onKick(KickReason reason){
netClient.disconnectQuietly();

View File

@@ -29,6 +29,7 @@ import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.gen.RemoteReadServer;
import io.anuke.mindustry.net.*;
import io.anuke.mindustry.net.Administration.PlayerInfo;
import io.anuke.mindustry.net.Administration.TraceInfo;
import io.anuke.mindustry.net.Packets.*;
import io.anuke.mindustry.world.Tile;
@@ -355,11 +356,12 @@ public class NetServer implements ApplicationListener{
netServer.kick(other.con.id, KickReason.kick);
Log.info("&lc{0} has kicked {1}.", player.name, other.name);
}else if(action == AdminAction.trace){
TraceInfo info = new TraceInfo(other.con.address, other.uuid, other.con.modclient, other.con.mobile);
//TODO implement
if(player.con != null){
//Call.onTraceInfo(player.con.id, other.con.trace);
Call.onTraceInfo(player.con.id, other, info);
}else{
//NetClient.onTraceInfo(other.con.trace);
NetClient.onTraceInfo(other, info);
}
Log.info("&lc{0} has requested trace info of {1}.", player.name, other.name);
}
@@ -478,7 +480,7 @@ public class NetServer implements ApplicationListener{
sent++;
if(syncStream.position() > maxSnapshotSize){
if(syncStream.size() > maxSnapshotSize){
dataStream.close();
byte[] syncBytes = syncStream.toByteArray();
Call.onEntitySnapshot(player.con.id, (byte)group.getID(), (short)sent, (short)syncBytes.length, Net.compressSnapshot(syncBytes));

View File

@@ -12,6 +12,7 @@ import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
import io.anuke.mindustry.entities.traits.ShooterTrait;
import io.anuke.mindustry.entities.type.*;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.net.Administration.TraceInfo;
import io.anuke.mindustry.net.Packets.AdminAction;
import io.anuke.mindustry.net.Packets.KickReason;
import io.anuke.mindustry.type.*;
@@ -281,6 +282,19 @@ public class TypeIO{
return bytes;
}
@WriteClass(TraceInfo.class)
public static void writeTraceInfo(ByteBuffer buffer, TraceInfo trace){
writeString(buffer, trace.ip);
writeString(buffer, trace.uuid);
buffer.put(trace.modded ? (byte)1 : 0);
buffer.put(trace.mobile ? (byte)1 : 0);
}
@ReadClass(TraceInfo.class)
public static TraceInfo readTraceInfo(ByteBuffer buffer){
return new TraceInfo(readString(buffer), readString(buffer), buffer.get() == 1, buffer.get() == 1);
}
public static void writeStringData(DataOutput buffer, String string) throws IOException{
if(string != null){
byte[] bytes = string.getBytes(charset);

View File

@@ -285,4 +285,16 @@ public class Administration{
}
}
public static class TraceInfo{
public String ip, uuid;
public boolean modded, mobile;
public TraceInfo(String ip, String uuid, boolean modded, boolean mobile){
this.ip = ip;
this.uuid = uuid;
this.modded = modded;
this.mobile = mobile;
}
}
}

View File

@@ -1,21 +1,26 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.net.Administration.TraceInfo;
public class TraceDialog extends FloatingDialog{
public TraceDialog(){
super("$trace");
addCloseButton();
setFillParent(false);
}
/*
public void show(Player player, SessionInfo info){
public void show(Player player, TraceInfo info){
cont.clear();
Table table = new Table("clear");
table.margin(14);
table.defaults().pad(1);
/*
table.defaults().left();
table.add(Core.bundle.format("trace.playername", player.name));
table.row();
@@ -23,33 +28,16 @@ public class TraceDialog extends FloatingDialog{
table.row();
table.add(Core.bundle.format("trace.id", info.uuid));
table.row();
table.add(Core.bundle.format("trace.modclient", info.modclient));
table.add(Core.bundle.format("trace.modclient", info.modded));
table.row();
table.add(Core.bundle.format("trace.android", info.android));
table.add(Core.bundle.format("trace.mobile", info.mobile));
table.row();
table.add().pad(5);
table.row();
//disabled until further notice
/*
table.add(Core.bundle.format("trace.totalblocksbroken", info.totalBlocksBroken));
table.row();
table.add(Core.bundle.format("trace.structureblocksbroken", info.structureBlocksBroken));
table.row();
table.add(Core.bundle.format("trace.lastblockbroken", info.lastBlockBroken.localizedName));
table.row();
table.add().pad(5);
table.row();
table.add(Core.bundle.format("trace.totalblocksplaced", info.totalBlocksPlaced));
table.row();
table.add(Core.bundle.format("trace.lastblockplaced", info.lastBlockPlaced.localizedName));
table.row();
cont.add(table);
show();
}*/
}
}

View File

@@ -128,7 +128,7 @@ public class PlayerListFragment extends Fragment{
.touchable(() -> Net.client() ? Touchable.disabled : Touchable.enabled)
.checked(user.isAdmin);
t.addImageButton("icon-zoom-small", "clear-partial", 14 * 2, () -> ui.showError("Currently unimplemented.")/*Call.onAdminRequest(user, AdminAction.trace)*/);
t.addImageButton("icon-zoom-small", "clear-partial", 14 * 2, () -> Call.onAdminRequest(user, AdminAction.trace));
}).padRight(12).size(bs + 10f, bs);
}