mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-25 22:17:59 +07:00
Crash fix / Cleanup
This commit is contained in:
parent
e0a94f694b
commit
6c5eff1143
@ -255,9 +255,9 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
if(health <= 0){
|
||||
onDeath();
|
||||
}
|
||||
|
||||
Block previous = tile.block();
|
||||
tile.block().update(tile);
|
||||
if(cons != null){
|
||||
if(tile.block() == previous && cons != null){
|
||||
cons.update(this);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package io.anuke.mindustry.net;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
|
||||
import static io.anuke.mindustry.Vars.headless;
|
||||
@ -31,15 +30,6 @@ public class Administration{
|
||||
load();
|
||||
}
|
||||
|
||||
public boolean isAntiGrief(){
|
||||
return Settings.getBool("antigrief");
|
||||
}
|
||||
|
||||
public void setAntiGrief(boolean antiGrief){
|
||||
Settings.putBool("antigrief", antiGrief);
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public boolean allowsCustomClients(){
|
||||
return Settings.getBool("allow-custom", !headless);
|
||||
}
|
||||
@ -49,10 +39,6 @@ public class Administration{
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public boolean isValidateReplace(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setAntiGriefParams(int maxBreak, int cooldown){
|
||||
Settings.putInt("antigrief-max", maxBreak);
|
||||
Settings.putInt("antigrief-cooldown", cooldown);
|
||||
@ -63,42 +49,6 @@ public class Administration{
|
||||
return editLogs;
|
||||
}
|
||||
|
||||
public boolean validateBreak(String id, String ip){
|
||||
if(!isAntiGrief() || isAdmin(id, ip)) return true;
|
||||
|
||||
PlayerInfo info = getCreateInfo(id);
|
||||
|
||||
if(info.lastBroken == null || info.lastBroken.length != Settings.getInt("antigrief-max")){
|
||||
info.lastBroken = new long[Settings.getInt("antigrief-max")];
|
||||
}
|
||||
|
||||
long[] breaks = info.lastBroken;
|
||||
|
||||
int shiftBy = 0;
|
||||
for(int i = 0; i < breaks.length && breaks[i] != 0; i++){
|
||||
if(TimeUtils.timeSinceMillis(breaks[i]) >= Settings.getInt("antigrief-cooldown")){
|
||||
shiftBy = i;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < breaks.length; i++){
|
||||
breaks[i] = (i + shiftBy >= breaks.length) ? 0 : breaks[i + shiftBy];
|
||||
}
|
||||
|
||||
int remaining = 0;
|
||||
for(int i = 0; i < breaks.length; i++){
|
||||
if(breaks[i] == 0){
|
||||
remaining = breaks.length - i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(remaining == 0) return false;
|
||||
|
||||
breaks[breaks.length - remaining] = TimeUtils.millis();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call when a player joins to update their information here.
|
||||
*/
|
||||
@ -349,8 +299,6 @@ public class Administration{
|
||||
public boolean banned, admin;
|
||||
public long lastKicked; //last kicked timestamp
|
||||
|
||||
public long[] lastBroken;
|
||||
|
||||
PlayerInfo(String id){
|
||||
this.id = id;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class ConsumeItemFilter extends Consume{
|
||||
public boolean valid(Block block, TileEntity entity){
|
||||
for(int i = 0; i < Item.all().size; i++){
|
||||
Item item = Item.getByID(i);
|
||||
if(entity.items.has(item) && this.filter.test(item)){
|
||||
if(entity.items != null && entity.items.has(item) && this.filter.test(item)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class ConsumeItems extends Consume{
|
||||
|
||||
@Override
|
||||
public boolean valid(Block block, TileEntity entity){
|
||||
return entity.items.has(items);
|
||||
return entity.items != null && entity.items.has(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +56,7 @@ public class ConsumeLiquidFilter extends Consume{
|
||||
|
||||
@Override
|
||||
public boolean valid(Block block, TileEntity entity){
|
||||
return filter.test(entity.liquids.current()) && entity.liquids.currentAmount() >= use(block);
|
||||
return entity.liquids != null && filter.test(entity.liquids.current()) && entity.liquids.currentAmount() >= use(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,7 +13,6 @@ import io.anuke.mindustry.game.Version;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.net.Administration;
|
||||
import io.anuke.mindustry.net.Administration.PlayerInfo;
|
||||
import io.anuke.mindustry.net.EditLog;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
@ -337,36 +336,7 @@ public class ServerControl extends Module{
|
||||
boolean value = arg[0].equalsIgnoreCase("on");
|
||||
debug = value;
|
||||
info("Debug mode is now {0}.", value ? "on" : "off");
|
||||
});
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
});
|
||||
});.0
|
||||
|
||||
handler.register("allow-custom-clients", "[on/off]", "Allow or disallow custom clients.", arg -> {
|
||||
if(arg.length == 0){
|
||||
|
Loading…
Reference in New Issue
Block a user