Added UUID banning

This commit is contained in:
Anuken
2018-03-06 19:22:50 -05:00
parent 1038f35883
commit 686e526e8c
15 changed files with 242 additions and 45 deletions

View File

@@ -6,6 +6,7 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
@@ -97,6 +98,24 @@ public class AndroidLauncher extends AndroidApplication{
public boolean isDebug() { public boolean isDebug() {
return false; return false;
} }
@Override
public byte[] getUUID() {
try {
String s = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i + 1), 16));
}
return data;
}catch (Exception e){
return null;
}
}
}; };
if(doubleScaleTablets && isTablet(this.getContext())){ if(doubleScaleTablets && isTablet(this.getContext())){

View File

@@ -41,12 +41,15 @@ text.server.friendlyfire=Friendly Fire
text.trace=Trace Player text.trace=Trace Player
text.trace.playername=Player name: [accent]{0} text.trace.playername=Player name: [accent]{0}
text.trace.ip=IP: [accent]{0} text.trace.ip=IP: [accent]{0}
text.trace.id=Unique ID: [accent]{0}
text.trace.android=Android Client: [accent]{0}
text.trace.modclient=Custom Client: [accent]{0} text.trace.modclient=Custom Client: [accent]{0}
text.trace.totalblocksbroken=Total blocks broken: [accent]{0} text.trace.totalblocksbroken=Total blocks broken: [accent]{0}
text.trace.structureblocksbroken=Structure blocks broken: [accent]{0} text.trace.structureblocksbroken=Structure blocks broken: [accent]{0}
text.trace.lastblockbroken=Last block broken: [accent]{0} text.trace.lastblockbroken=Last block broken: [accent]{0}
text.trace.totalblocksplaced=Total blocks placed: [accent]{0} text.trace.totalblocksplaced=Total blocks placed: [accent]{0}
text.trace.lastblockplaced=Last block placed: [accent]{0} text.trace.lastblockplaced=Last block placed: [accent]{0}
text.invalidid=Invalid client ID! Submit a bug report.
text.server.bans=Bans text.server.bans=Bans
text.server.bans.none=No banned players found! text.server.bans.none=No banned players found!
text.server.admins=Admins text.server.admins=Admins

View File

@@ -1,7 +1,7 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Sat Mar 03 12:04:38 EST 2018 #Tue Mar 06 19:13:04 EST 2018
version=release version=release
androidBuildCode=333 androidBuildCode=335
name=Mindustry name=Mindustry
code=3.4 code=3.4
build=30 build=31

View File

@@ -1,6 +1,5 @@
package io.anuke.mindustry.core; package io.anuke.mindustry.core;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.IntMap; import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.IntSet; import com.badlogic.gdx.utils.IntSet;
@@ -68,11 +67,20 @@ public class NetClient extends Module {
c.name = player.name; c.name = player.name;
c.android = android; c.android = android;
c.color = Color.rgba8888(player.color); c.color = Color.rgba8888(player.color);
c.uuid = Platform.instance.getUUID();
if(c.uuid == null){
ui.showError("$text.invalidid");
ui.loadfrag.hide();
disconnectQuietly();
return;
}
Net.send(c, SendMode.tcp); Net.send(c, SendMode.tcp);
Timers.runTask(dataTimeout, () -> { Timers.runTask(dataTimeout, () -> {
if (!gotData) { if (!gotData) {
Gdx.app.error("Mindustry", "Failed to load data!"); Log.err("Failed to load data!");
ui.loadfrag.hide(); ui.loadfrag.hide();
Net.disconnect(); Net.disconnect();
} }

View File

@@ -1,9 +1,6 @@
package io.anuke.mindustry.core; package io.anuke.mindustry.core;
import com.badlogic.gdx.utils.ByteArray; import com.badlogic.gdx.utils.*;
import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.TimeUtils;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.SyncEntity; import io.anuke.mindustry.entities.SyncEntity;
@@ -51,18 +48,27 @@ public class NetServer extends Module{
Events.on(GameOverEvent.class, () -> weapons.clear()); Events.on(GameOverEvent.class, () -> weapons.clear());
Net.handleServer(Connect.class, (id, connect) -> { Net.handleServer(Connect.class, (id, connect) -> {
if(admins.isBanned(connect.addressTCP)){ if(admins.isIPBanned(connect.addressTCP)){
Net.kickConnection(id, KickReason.banned); Net.kickConnection(id, KickReason.banned);
} }
}); });
Net.handleServer(ConnectPacket.class, (id, packet) -> { Net.handleServer(ConnectPacket.class, (id, packet) -> {
String uuid = new String(Base64Coder.encode(packet.uuid));
if(Net.getConnection(id) == null || if(Net.getConnection(id) == null ||
admins.isBanned(Net.getConnection(id).address)) return; admins.isIPBanned(Net.getConnection(id).address)) return;
if(admins.isIDBanned(uuid)){
Net.kickConnection(id, KickReason.banned);
return;
}
String ip = Net.getConnection(id).address; String ip = Net.getConnection(id).address;
admins.setKnownName(ip, packet.name); admins.setKnownName(ip, packet.name);
admins.setKnownIP(uuid, ip);
admins.getTrace(ip).uuid = uuid;
admins.getTrace(ip).android = packet.android;
if(packet.version != Version.build && Version.build != -1 && packet.version != -1){ if(packet.version != Version.build && Version.build != -1 && packet.version != -1){
Net.kickConnection(id, packet.version > Version.build ? KickReason.serverOutdated : KickReason.clientOutdated); Net.kickConnection(id, packet.version > Version.build ? KickReason.serverOutdated : KickReason.clientOutdated);
@@ -270,7 +276,7 @@ public class NetServer extends Module{
String ip = Net.getConnection(other.clientid).address; String ip = Net.getConnection(other.clientid).address;
if(packet.action == AdminAction.ban){ if(packet.action == AdminAction.ban){
admins.banPlayer(ip); admins.banPlayerIP(ip);
Net.kickConnection(other.clientid, KickReason.banned); Net.kickConnection(other.clientid, KickReason.banned);
Log.info("&lc{0} has banned {1}.", player.name, other.name); Log.info("&lc{0} has banned {1}.", player.name, other.name);
}else if(packet.action == AdminAction.kick){ }else if(packet.action == AdminAction.kick){

View File

@@ -30,6 +30,8 @@ public abstract class Platform {
return true; return true;
} }
public boolean isDebug(){return false;} public boolean isDebug(){return false;}
/**Must be 8 bytes in length.*/
public byte[] getUUID(){return null;}
public ThreadProvider getThreadProvider(){ public ThreadProvider getThreadProvider(){
return new ThreadProvider() { return new ThreadProvider() {
@Override public boolean isOnThread() {return true;} @Override public boolean isOnThread() {return true;}

View File

@@ -7,16 +7,20 @@ import io.anuke.ucore.core.Settings;
public class Administration { public class Administration {
private Json json = new Json(); private Json json = new Json();
private Array<String> bannedIPS = new Array<>(); private Array<String> bannedIPs = new Array<>();
private Array<String> bannedIDs = new Array<>();
private Array<String> admins = new Array<>(); private Array<String> admins = new Array<>();
private ObjectMap<String, String> known = new ObjectMap<>(); private ObjectMap<String, String> ipNames = new ObjectMap<>();
private ObjectMap<String, String> idIPs = new ObjectMap<>();
private ObjectMap<String, TraceInfo> traces = new ObjectMap<>(); private ObjectMap<String, TraceInfo> traces = new ObjectMap<>();
public Administration(){ public Administration(){
Settings.defaultList( Settings.defaultList(
"bans", "{}", "bans", "{}",
"bannedIDs", "{}",
"admins", "{}", "admins", "{}",
"knownIPs", "{}" "knownIPs", "{}",
"knownIDs", "{}"
); );
load(); load();
@@ -34,35 +38,81 @@ public class Administration {
/**Sets last known name for an IP.*/ /**Sets last known name for an IP.*/
public void setKnownName(String ip, String name){ public void setKnownName(String ip, String name){
known.put(ip, name); ipNames.put(ip, name);
saveKnown();
}
/**Sets last known UUID for an IP.*/
public void setKnownIP(String id, String ip){
idIPs.put(id, ip);
saveKnown(); saveKnown();
} }
/**Returns the last known name for an IP. Returns 'unknown' if this IP has an unknown username.*/ /**Returns the last known name for an IP. Returns 'unknown' if this IP has an unknown username.*/
public String getLastName(String ip){ public String getLastName(String ip){
return known.get(ip, "unknown"); return ipNames.get(ip, "unknown");
}
/**Returns the last known IP for a UUID. Returns 'unknown' if this IP has an unknown IP.*/
public String getLastIP(String id){
return idIPs.get(id, "unknown");
}
/**Return the last known device ID associated with an IP. Returns 'unknown' if this IP has an unknown device.*/
public String getLastID(String ip){
for(String id : idIPs.keys()){
if(idIPs.get(id).equals(ip)){
return id;
}
}
return "unknown";
} }
/**Returns list of banned IPs.*/ /**Returns list of banned IPs.*/
public Array<String> getBanned(){ public Array<String> getBanned(){
return bannedIPS; return bannedIPs;
}
/**Returns list of banned IDs.*/
public Array<String> getBannedIDs(){
return bannedIDs;
} }
/**Bans a player by IP; returns whether this player was already banned.*/ /**Bans a player by IP; returns whether this player was already banned.*/
public boolean banPlayer(String ip){ public boolean banPlayerIP(String ip){
if(bannedIPS.contains(ip, false)) if(bannedIPs.contains(ip, false))
return false; return false;
bannedIPS.add(ip); bannedIPs.add(ip);
saveBans();
return true;
}
/**Bans a player by UUID.*/
public boolean banPlayerID(String id){
if(bannedIDs.contains(id, false))
return false;
bannedIDs.add(id);
saveBans(); saveBans();
return true; return true;
} }
/**Unbans a player by IP; returns whether this player was banned in the first place..*/ /**Unbans a player by IP; returns whether this player was banned in the first place..*/
public boolean unbanPlayer(String ip){ public boolean unbanPlayerIP(String ip){
if(!bannedIPS.contains(ip, false)) if(!bannedIPs.contains(ip, false))
return false; return false;
bannedIPS.removeValue(ip, false); bannedIPs.removeValue(ip, false);
saveBans();
return true;
}
/**Unbans a player by IP; returns whether this player was banned in the first place..*/
public boolean unbanPlayerID(String ip){
if(!bannedIDs.contains(ip, false))
return false;
bannedIDs.removeValue(ip, false);
saveBans(); saveBans();
return true; return true;
@@ -93,8 +143,12 @@ public class Administration {
return true; return true;
} }
public boolean isBanned(String ip){ public boolean isIPBanned(String ip){
return bannedIPS.contains(ip, false); return bannedIPs.contains(ip, false);
}
public boolean isIDBanned(String uuid){
return bannedIDs.contains(uuid, false);
} }
public boolean isAdmin(String ip){ public boolean isAdmin(String ip){
@@ -102,12 +156,14 @@ public class Administration {
} }
private void saveKnown(){ private void saveKnown(){
Settings.putString("knownIPs", json.toJson(known)); Settings.putString("knownIPs", json.toJson(ipNames));
Settings.putString("knownIDs", json.toJson(idIPs));
Settings.save(); Settings.save();
} }
private void saveBans(){ private void saveBans(){
Settings.putString("bans", json.toJson(bannedIPS)); Settings.putString("bans", json.toJson(bannedIPs));
Settings.putString("bannedIDs", json.toJson(bannedIDs));
Settings.save(); Settings.save();
} }
@@ -117,9 +173,11 @@ public class Administration {
} }
private void load(){ private void load(){
bannedIPS = json.fromJson(Array.class, Settings.getString("bans")); bannedIPs = json.fromJson(Array.class, Settings.getString("bans"));
bannedIDs = json.fromJson(Array.class, Settings.getString("bannedIDs"));
admins = json.fromJson(Array.class, Settings.getString("admins")); admins = json.fromJson(Array.class, Settings.getString("admins"));
known = json.fromJson(ObjectMap.class, Settings.getString("knownIPs")); ipNames = json.fromJson(ObjectMap.class, Settings.getString("knownIPs"));
idIPs = json.fromJson(ObjectMap.class, Settings.getString("knownIDs"));
} }
} }

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.net; package io.anuke.mindustry.net;
import com.badlogic.gdx.utils.Base64Coder;
import com.badlogic.gdx.utils.reflect.ClassReflection; import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.badlogic.gdx.utils.reflect.ReflectionException; import com.badlogic.gdx.utils.reflect.ReflectionException;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
@@ -56,6 +57,7 @@ public class Packets {
public String name; public String name;
public boolean android; public boolean android;
public int color; public int color;
public byte[] uuid;
@Override @Override
public void write(ByteBuffer buffer) { public void write(ByteBuffer buffer) {
@@ -64,6 +66,7 @@ public class Packets {
buffer.put(name.getBytes()); buffer.put(name.getBytes());
buffer.put(android ? (byte)1 : 0); buffer.put(android ? (byte)1 : 0);
buffer.putInt(color); buffer.putInt(color);
buffer.put(uuid);
} }
@Override @Override
@@ -75,6 +78,8 @@ public class Packets {
name = new String(bytes); name = new String(bytes);
android = buffer.get() == 1; android = buffer.get() == 1;
color = buffer.getInt(); color = buffer.getInt();
uuid = new byte[8];
buffer.get(uuid);
} }
} }
@@ -625,6 +630,7 @@ public class Packets {
buffer.putShort((short)info.ip.getBytes().length); buffer.putShort((short)info.ip.getBytes().length);
buffer.put(info.ip.getBytes()); buffer.put(info.ip.getBytes());
buffer.put(info.modclient ? (byte)1 : 0); buffer.put(info.modclient ? (byte)1 : 0);
buffer.put(info.android ? (byte)1 : 0);
buffer.putInt(info.totalBlocksBroken); buffer.putInt(info.totalBlocksBroken);
buffer.putInt(info.structureBlocksBroken); buffer.putInt(info.structureBlocksBroken);
@@ -632,6 +638,7 @@ public class Packets {
buffer.putInt(info.totalBlocksPlaced); buffer.putInt(info.totalBlocksPlaced);
buffer.putInt(info.lastBlockPlaced.id); buffer.putInt(info.lastBlockPlaced.id);
buffer.put(Base64Coder.decode(info.uuid));
} }
@Override @Override
@@ -645,11 +652,16 @@ public class Packets {
info.playerid = id; info.playerid = id;
info.modclient = buffer.get() == 1; info.modclient = buffer.get() == 1;
info.android = buffer.get() == 1;
info.totalBlocksBroken = buffer.getInt(); info.totalBlocksBroken = buffer.getInt();
info.structureBlocksBroken = buffer.getInt(); info.structureBlocksBroken = buffer.getInt();
info.lastBlockBroken = Block.getByID(buffer.getInt()); info.lastBlockBroken = Block.getByID(buffer.getInt());
info.totalBlocksPlaced = buffer.getInt(); info.totalBlocksPlaced = buffer.getInt();
info.lastBlockPlaced = Block.getByID(buffer.getInt()); info.lastBlockPlaced = Block.getByID(buffer.getInt());
byte[] uuid = new byte[8];
buffer.get(uuid);
info.uuid = new String(Base64Coder.encode(uuid));
} }
} }
} }

View File

@@ -7,6 +7,7 @@ public class TraceInfo {
public int playerid; public int playerid;
public String ip; public String ip;
public boolean modclient; public boolean modclient;
public boolean android;
public int totalBlocksBroken; public int totalBlocksBroken;
public int structureBlocksBroken; public int structureBlocksBroken;
@@ -15,6 +16,8 @@ public class TraceInfo {
public int totalBlocksPlaced; public int totalBlocksPlaced;
public Block lastBlockPlaced = Blocks.air; public Block lastBlockPlaced = Blocks.air;
public String uuid;
public TraceInfo(String ip){ public TraceInfo(String ip){
this.ip = ip; this.ip = ip;
} }

View File

@@ -41,7 +41,7 @@ public class BansDialog extends FloatingDialog {
res.add().growX(); res.add().growX();
res.addImageButton("icon-cancel", 14*3, () -> { res.addImageButton("icon-cancel", 14*3, () -> {
ui.showConfirm("$text.confirm", "$text.confirmunban", () -> { ui.showConfirm("$text.confirm", "$text.confirmunban", () -> {
netServer.admins.unbanPlayer(ip); netServer.admins.unbanPlayerIP(ip);
setup(); setup();
}); });
}).size(h).pad(-14f); }).size(h).pad(-14f);

View File

@@ -25,8 +25,12 @@ public class TraceDialog extends FloatingDialog {
table.row(); table.row();
table.add(Bundles.format("text.trace.ip", info.ip)); table.add(Bundles.format("text.trace.ip", info.ip));
table.row(); table.row();
table.add(Bundles.format("text.trace.id", info.uuid));
table.row();
table.add(Bundles.format("text.trace.modclient", info.modclient)); table.add(Bundles.format("text.trace.modclient", info.modclient));
table.row(); table.row();
table.add(Bundles.format("text.trace.android", info.android));
table.row();
table.add().pad(5); table.add().pad(5);
table.row(); table.row();

View File

@@ -129,7 +129,7 @@ public class PlayerListFragment implements Fragment{
t.addImageButton("icon-ban", 14*2, () -> { t.addImageButton("icon-ban", 14*2, () -> {
ui.showConfirm("$text.confirm", "$text.confirmban", () -> { ui.showConfirm("$text.confirm", "$text.confirmban", () -> {
if(Net.server()) { if(Net.server()) {
netServer.admins.banPlayer(connection.address); netServer.admins.banPlayerIP(connection.address);
Net.kickConnection(player.clientid, KickReason.banned); Net.kickConnection(player.clientid, KickReason.banned);
}else{ }else{
NetEvents.handleAdministerRequest(player, AdminAction.ban); NetEvents.handleAdministerRequest(player, AdminAction.ban);

View File

@@ -12,6 +12,7 @@ import io.anuke.ucore.UCore;
import io.anuke.ucore.util.Strings; import io.anuke.ucore.util.Strings;
import javax.swing.*; import javax.swing.*;
import java.net.NetworkInterface;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@@ -98,4 +99,17 @@ public class DesktopPlatform extends Platform {
public ThreadProvider getThreadProvider() { public ThreadProvider getThreadProvider() {
return new DefaultThreadImpl(); return new DefaultThreadImpl();
} }
@Override
public byte[] getUUID() {
try {
byte[] bytes = NetworkInterface.getNetworkInterfaces().nextElement().getHardwareAddress();
byte[] result = new byte[8];
System.arraycopy(bytes, 0, result, 0, bytes.length);
return result;
}catch (Exception e){
e.printStackTrace();
return null;
}
}
} }

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration; import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback; import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback;
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderState; import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderState;
import com.badlogic.gdx.utils.Base64Coder;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
@@ -17,8 +18,10 @@ import com.google.gwt.user.client.ui.*;
import io.anuke.mindustry.Mindustry; import io.anuke.mindustry.Mindustry;
import io.anuke.mindustry.io.Platform; import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.ucore.core.Settings;
import java.util.Date; import java.util.Date;
import java.util.Random;
public class HtmlLauncher extends GwtApplication { public class HtmlLauncher extends GwtApplication {
static final int WIDTH = 800; static final int WIDTH = 800;
@@ -112,6 +115,22 @@ public class HtmlLauncher extends GwtApplication {
String ref = Document.get().getReferrer(); String ref = Document.get().getReferrer();
return !ref.startsWith("https") && !ref.contains("itch.io"); return !ref.startsWith("https") && !ref.contains("itch.io");
} }
@Override
public byte[] getUUID(){
Settings.defaults("uuid", "");
String uuid = Settings.getString("uuid");
if(uuid.isEmpty()){
byte[] result = new byte[8];
new Random().nextBytes(result);
uuid = new String(Base64Coder.encode(result));
Settings.putString("uuid", uuid);
Settings.save();
return result;
}
return Base64Coder.decode(uuid);
}
}; };
return new Mindustry(); return new Mindustry();

View File

@@ -252,7 +252,7 @@ public class ServerControl extends Module {
} }
}); });
handler.register("kick", "<username>", "Kick a person by name.", arg -> { handler.register("kick", "<username...>", "Kick a person by name.", arg -> {
if(!state.is(State.playing)) { if(!state.is(State.playing)) {
err("Not hosting a game yet. Calm down."); err("Not hosting a game yet. Calm down.");
return; return;
@@ -275,7 +275,7 @@ public class ServerControl extends Module {
} }
}); });
handler.register("ban", "<username>", "Ban a person by name.", arg -> { handler.register("ban", "<username...>", "Ban a person by name.", arg -> {
if(!state.is(State.playing)) { if(!state.is(State.playing)) {
err("Can't ban people by name with no players."); err("Can't ban people by name with no players.");
return; return;
@@ -292,29 +292,42 @@ public class ServerControl extends Module {
if(target != null){ if(target != null){
String ip = Net.getConnection(target.clientid).address; String ip = Net.getConnection(target.clientid).address;
netServer.admins.banPlayer(ip); netServer.admins.banPlayerIP(ip);
netServer.admins.banPlayerID(netServer.admins.getTrace(ip).uuid);
Net.kickConnection(target.clientid, KickReason.banned); Net.kickConnection(target.clientid, KickReason.banned);
info("Banned player by IP: {0}", ip); info("Banned player by IP and ID: {0} / {1}", ip, netServer.admins.getTrace(ip).uuid);
}else{ }else{
info("Nobody with that name could be found."); info("Nobody with that name could be found.");
} }
}); });
handler.register("bans", "List all banned IPs.", arg -> { handler.register("bans", "List all banned IPs and IDs.", arg -> {
Array<String> bans = netServer.admins.getBanned(); Array<String> bans = netServer.admins.getBanned();
if(bans.size == 0){ if(bans.size == 0){
Log.info("No banned players have been found."); Log.info("No IP-banned players have been found.");
}else{ }else{
Log.info("&lyBanned players:"); Log.info("&lyBanned players [IP]:");
for(String string : bans){ for(String string : bans){
Log.info(" &ly {0} / Last known name: '{1}'", string, netServer.admins.getLastName(string)); Log.info(" &ly {0} / Last known name: '{1}'", string, netServer.admins.getLastName(string));
} }
} }
Array<String> idbans = netServer.admins.getBannedIDs();
if(idbans.size == 0){
Log.info("No ID-banned players have been found.");
}else{
Log.info("&lmBanned players [ID]:");
for(String string : idbans){
Log.info(" &lm '{0}' / Last known name: '{1}' / Last known IP: '{2}'", string,
netServer.admins.getLastName(netServer.admins.getLastIP(string)), netServer.admins.getLastIP(string));
}
}
}); });
handler.register("banip", "<ip>", "Ban a person by IP.", arg -> { handler.register("banip", "<ip>", "Ban a person by IP.", arg -> {
if(netServer.admins.banPlayer(arg[0])) { if(netServer.admins.banPlayerIP(arg[0])) {
info("Banned player by IP: {0}.", arg[0]); info("Banned player by IP: {0}.", arg[0]);
for(Player player : playerGroup.all()){ for(Player player : playerGroup.all()){
@@ -328,15 +341,49 @@ public class ServerControl extends Module {
} }
}); });
handler.register("unbanip", "<ip>", "Unban a person by IP.", arg -> { handler.register("banid", "<id>", "Ban a person by their unique ID.", arg -> {
if(netServer.admins.unbanPlayer(arg[0])) { if(netServer.admins.banPlayerID(arg[0])) {
info("Banned player by ID: {0}.", arg[0]);
for(Player player : playerGroup.all()){
if(netServer.admins.getTrace(Net.getConnection(player.clientid).address).uuid.equals(arg[0])){
Net.kickConnection(player.clientid, KickReason.banned);
break;
}
}
}else{
err("That ID is already banned!");
}
});
handler.register("unbanip", "<ip>", "Completely unban a person by IP.", arg -> {
if(netServer.admins.unbanPlayerIP(arg[0])) {
info("Unbanned player by IP: {0}.", arg[0]); info("Unbanned player by IP: {0}.", arg[0]);
for(String s : netServer.admins.getBannedIDs()){
if(netServer.admins.getLastIP(s).equals(arg[0])){
netServer.admins.unbanPlayerID(s);
Log.info("Also unbanned UUID '{0}' as it corresponds to this IP.", s);
}
}
}else{ }else{
err("That IP is not banned!"); err("That IP is not banned!");
} }
}); });
handler.register("admin", "<username>", "Make a user admin", arg -> { handler.register("unbanid", "<id>", "Completely unban a person by ID.", arg -> {
if(netServer.admins.unbanPlayerID(arg[0])) {
info("&lmUnbanned player by ID: {0}.", arg[0]);
String ip = netServer.admins.getLastIP(arg[0]);
if(!ip.equals("unknown")) {
netServer.admins.unbanPlayerIP(ip);
Log.info("Also unbanned IP '{0}' as it corresponds to this ID.", ip);
}
}else{
err("That IP is not banned!");
}
});
handler.register("admin", "<username...>", "Make a user admin", arg -> {
if(!state.is(State.playing)) { if(!state.is(State.playing)) {
err("Open the server first."); err("Open the server first.");
return; return;
@@ -361,7 +408,7 @@ public class ServerControl extends Module {
} }
}); });
handler.register("unadmin", "<username>", "Removes admin status from a player", arg -> { handler.register("unadmin", "<username...>", "Removes admin status from a player", arg -> {
if(!state.is(State.playing)) { if(!state.is(State.playing)) {
err("Open the server first."); err("Open the server first.");
return; return;
@@ -484,7 +531,7 @@ public class ServerControl extends Module {
} }
}); });
handler.register("trace", "<username>", "Trace a player's actions", arg -> { handler.register("trace", "<username...>", "Trace a player's actions", arg -> {
if(!state.is(State.playing)) { if(!state.is(State.playing)) {
err("Open the server first."); err("Open the server first.");
return; return;
@@ -504,7 +551,9 @@ public class ServerControl extends Module {
Log.info("&lcTrace info for player '{0}':", target.name); Log.info("&lcTrace info for player '{0}':", target.name);
Log.info(" &lyEntity ID: {0}", info. playerid); Log.info(" &lyEntity ID: {0}", info. playerid);
Log.info(" &lyIP: {0}", info.ip); Log.info(" &lyIP: {0}", info.ip);
Log.info(" &lyUUID: {0}", info.uuid);
Log.info(" &lycustom client: {0}", info.modclient); Log.info(" &lycustom client: {0}", info.modclient);
Log.info(" &lyandroid: {0}", info.android);
Log.info(""); Log.info("");
Log.info(" &lytotal blocks broken: {0}", info.totalBlocksBroken); Log.info(" &lytotal blocks broken: {0}", info.totalBlocksBroken);
Log.info(" &lystructure blocks broken: {0}", info.structureBlocksBroken); Log.info(" &lystructure blocks broken: {0}", info.structureBlocksBroken);