Added configurable anti-grief

This commit is contained in:
Anuken
2018-05-05 20:20:34 -04:00
parent 37a73eda37
commit 299c2af59b
4 changed files with 124 additions and 7 deletions

View File

@@ -10,13 +10,10 @@ import io.anuke.mindustry.game.EventType.GameOverEvent;
import io.anuke.mindustry.game.GameMode;
import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.io.Version;
import io.anuke.mindustry.net.*;
import io.anuke.mindustry.net.Administration.PlayerInfo;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.NetConnection;
import io.anuke.mindustry.net.NetEvents;
import io.anuke.mindustry.net.Packets.ChatPacket;
import io.anuke.mindustry.net.Packets.KickReason;
import io.anuke.mindustry.net.TraceInfo;
import io.anuke.mindustry.ui.fragments.DebugFragment;
import io.anuke.mindustry.world.Map;
import io.anuke.mindustry.world.Tile;
@@ -254,7 +251,7 @@ public class ServerControl extends Module {
}
});
handler.register("friendlyfire", "<on/off>", "Enable or disable friendly fire", arg -> {
handler.register("friendlyfire", "<on/off>", "Enable or disable friendly fire.", arg -> {
String s = arg[0];
if(s.equalsIgnoreCase("on")){
NetEvents.handleFriendlyFireChange(true);
@@ -269,6 +266,35 @@ public class ServerControl extends Module {
}
});
handler.register("antigrief", "[on/off] [max-break] [cooldown-in-ms]", "Enable or disable anti-grief.", arg -> {
if(arg.length == 0){
info("Anti-grief is currently &lc{0}.", netServer.admins.isAntiGrief() ? "on" : "off");
return;
}
String s = arg[0];
if(s.equalsIgnoreCase("on")){
netServer.admins.setAntiGrief(true);
info("Anti-grief enabled.");
}else if(s.equalsIgnoreCase("off")){
netServer.admins.setAntiGrief(false);
info("Anti-grief disabled.");
}else{
err("Incorrect command usage.");
}
if(arg.length >= 2) {
try {
int maxbreak = Integer.parseInt(arg[1]);
int cooldown = (arg.length >= 3 ? Integer.parseInt(arg[2]) : Administration.defaultBreakCooldown);
netServer.admins.setAntiGriefParams(maxbreak, cooldown);
info("Anti-grief parameters set.");
} catch (NumberFormatException e) {
err("Invalid number format.");
}
}
});
handler.register("shuffle", "<normal/custom/both/off>", "Set map shuffling.", arg -> {
try{