Merge branch 'master' of https://github.com/Anuken/Mindustry into 4.0

This commit is contained in:
Anuken
2018-04-14 20:45:46 -04:00
3 changed files with 84 additions and 8 deletions

View File

@@ -81,6 +81,8 @@ public class NetServer extends Module{
return; return;
} }
Log.info("Recieved connect packet for player '{0}' / UUID {1} / IP {2}", packet.name, uuid, trace.ip);
String ip = Net.getConnection(id).address; String ip = Net.getConnection(id).address;
admins.updatePlayerJoined(uuid, ip, packet.name); admins.updatePlayerJoined(uuid, ip, packet.name);
@@ -94,8 +96,6 @@ public class NetServer extends Module{
trace.modclient = true; trace.modclient = true;
} }
Log.info("Sending data to player '{0}' / {1}", packet.name, id);
Player player = new Player(); Player player = new Player();
player.isAdmin = admins.isAdmin(uuid, ip); player.isAdmin = admins.isAdmin(uuid, ip);
player.clientid = id; player.clientid = id;
@@ -165,12 +165,12 @@ public class NetServer extends Module{
TraceInfo info = admins.getTrace(Net.getConnection(id).address); TraceInfo info = admins.getTrace(Net.getConnection(id).address);
Weapon weapon = Upgrade.getByID((byte)packet.data); Weapon weapon = Upgrade.getByID((byte)packet.data);
float wtrc = 60; float wtrc = 80;
if(!Timers.get("fastshoot-" + id + "-" + weapon.id, wtrc)){ if(!Timers.get("fastshoot-" + id + "-" + weapon.id, wtrc)){
info.fastShots.getAndIncrement(weapon.id, 0, 1); info.fastShots.getAndIncrement(weapon.id, 0, 1);
if(info.fastShots.get(weapon.id, 0) > (int)(wtrc / (weapon.getReload() / 2f)) + 2){ if(info.fastShots.get(weapon.id, 0) > (int)(wtrc / (weapon.getReload() / 2f)) + 6){
kick(id, KickReason.kick); kick(id, KickReason.kick);
} }
}else{ }else{

View File

@@ -184,6 +184,18 @@ public class Administration {
return result; return result;
} }
public Array<PlayerInfo> findByIPs(String ip){
Array<PlayerInfo> result = new Array<>();
for(PlayerInfo info : playerInfo.values()){
if(info.ips.contains(ip, false)){
result.add(info);
}
}
return result;
}
public PlayerInfo getInfo(String id){ public PlayerInfo getInfo(String id){
return getCreateInfo(id); return getCreateInfo(id);
} }

View File

@@ -330,7 +330,11 @@ public class ServerControl extends Module {
Log.info("&lmBanned players [IP]:"); Log.info("&lmBanned players [IP]:");
for(String string : ipbans){ for(String string : ipbans){
PlayerInfo info = netServer.admins.findByIP(string); PlayerInfo info = netServer.admins.findByIP(string);
Log.info(" &lm '{0}' / Last known name: '{1}' / ID: '{2}'", string, info.lastName, info.id); if(info != null) {
Log.info(" &lm '{0}' / Last known name: '{1}' / ID: '{2}'", string, info.lastName, info.id);
}else{
Log.info(" &lm '{0}' (No known name or info)", string);
}
} }
} }
}); });
@@ -340,7 +344,9 @@ public class ServerControl extends Module {
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()){
if(Net.getConnection(player.clientid).address.equals(arg[0])){ if(Net.getConnection(player.clientid) != null &&
Net.getConnection(player.clientid).address != null &&
Net.getConnection(player.clientid).address.equals(arg[0])){
netServer.kick(player.clientid, KickReason.banned); netServer.kick(player.clientid, KickReason.banned);
break; break;
} }
@@ -493,6 +499,37 @@ public class ServerControl extends Module {
info("Saved to slot {0}.", slot); info("Saved to slot {0}.", slot);
}); });
handler.register("griefers", "[min-break:place-ratio] [min-breakage]", "Find possible griefers currently online.", arg -> {
if(!state.is(State.playing)) {
err("Open the server first.");
return;
}
try {
float ratio = arg.length > 0 ? Float.parseFloat(arg[0]) : 0.5f;
int minbreak = arg.length > 1 ? Integer.parseInt(arg[1]) : 100;
boolean found = false;
for (Player player : playerGroup.all()) {
TraceInfo info = netServer.admins.getTrace(Net.getConnection(player.clientid).address);
if(info.totalBlocksBroken >= minbreak && info.totalBlocksBroken / Math.max(info.totalBlocksPlaced, 1f) >= ratio){
info("&ly - Player '{0}' / UUID &lm{1}&ly found: &lc{2}&ly broken and &lc{3}&ly placed.",
player.name, info.uuid, info.totalBlocksBroken, info.totalBlocksPlaced);
found = true;
}
}
if (!found) {
info("No griefers matching the criteria have been found.");
}
}catch (NumberFormatException e){
err("Invalid number format.");
}
});
handler.register("gameover", "Force a game over.", arg -> { handler.register("gameover", "Force a game over.", arg -> {
if(state.is(State.menu)){ if(state.is(State.menu)){
info("Not playing a map."); info("Not playing a map.");
@@ -535,8 +572,8 @@ public class ServerControl extends Module {
} }
}); });
handler.register("find", "<name> [check-all-names]", "Find player info(s) by name. Can optionally check for all names a player has had.", arg -> { handler.register("find", "<name...>", "Find player info(s) by name. Can optionally check for all names a player has had.", arg -> {
boolean checkAll = arg.length == 2 && arg[1].equals("true"); boolean checkAll = true;
Array<PlayerInfo> infos = netServer.admins.findByName(arg[0], checkAll); Array<PlayerInfo> infos = netServer.admins.findByName(arg[0], checkAll);
@@ -562,6 +599,33 @@ public class ServerControl extends Module {
} }
}); });
handler.register("findip", "<ip>", "Find player info(s) by IP.", arg -> {
Array<PlayerInfo> infos = netServer.admins.findByIPs(arg[0]);
if(infos.size == 1) {
PlayerInfo info = infos.peek();
Log.info("&lcTrace info for player '{0}' / UUID {1}:", info.lastName, info.id);
Log.info(" &lyall names used: {0}", info.names);
Log.info(" &lyIP: {0}", info.lastIP);
Log.info(" &lyall IPs used: {0}", info.ips);
Log.info(" &lytimes joined: {0}", info.timesJoined);
Log.info(" &lytimes kicked: {0}", info.timesKicked);
Log.info("");
Log.info(" &lytotal blocks broken: {0}", info.totalBlocksBroken);
Log.info(" &lytotal blocks placed: {0}", info.totalBlockPlaced);
}else if(infos.size > 1){
Log.info("&lcMultiple people have been found with that IP:");
for(PlayerInfo info : infos){
Log.info(" &ly{0}", info.id);
}
Log.info("&lcUse the info command to examine each person individually.");
}else{
info("Nobody with that IP could be found.");
}
});
handler.register("info", "<UUID>", "Get global info for a player's UUID.", arg -> { handler.register("info", "<UUID>", "Get global info for a player's UUID.", arg -> {
PlayerInfo info = netServer.admins.getInfoOptional(arg[0]); PlayerInfo info = netServer.admins.getInfoOptional(arg[0]);