Added explicit log when ship is renamed

This is to help admins when players use offensive ship names since the
original crew my not be the authors
This commit is contained in:
LemADEC 2017-07-31 21:58:08 +02:00
parent 726ce4f860
commit c1804b0f03
2 changed files with 29 additions and 1 deletions

View file

@ -131,7 +131,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced imple
}
}
isEnabled = tagCompound.getBoolean("isEnabled");
isEnabled = tagCompound.hasKey("isEnabled") && tagCompound.getBoolean("isEnabled");
setCommand(tagCompound.getString("command"));
setFront(tagCompound.getInteger("front"));
setRight(tagCompound.getInteger("right"));
@ -417,7 +417,15 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced imple
return null;
}
if (arguments.length == 1) {
final String shipNamePrevious = core.shipName;
core.shipName = ((String) arguments[0]).replace("/", "").replace(".", "").replace("\\", ".");
if ( core.shipName == null
|| !core.shipName.equals(shipNamePrevious) ) {
WarpDrive.logger.info(String.format("Ship renamed from '%s' to '%s' with player(s) %s",
shipNamePrevious == null ? "-null-" : shipNamePrevious,
core.shipName,
core.getAllPlayersOnShip()));
}
}
return new Object[] { core.shipName };
}

View file

@ -370,6 +370,26 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy implements ISta
}
}
public String getAllPlayersOnShip() {
final AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX + 0.99D, maxY + 0.99D, maxZ + 0.99D);
final List list = worldObj.getEntitiesWithinAABBExcludingEntity(null, axisalignedbb);
final StringBuilder stringBuilderResult = new StringBuilder();
boolean isFirst = true;
for (Object object : list) {
if (!(object instanceof EntityPlayer)) {
continue;
}
if (isFirst) {
isFirst = false;
} else {
stringBuilderResult.append(", ");
}
stringBuilderResult.append(((EntityPlayer) object).getCommandSenderName());
}
return stringBuilderResult.toString();
}
private void updateIsolationState() {
// Search block in cube around core
int xMax, yMax, zMax;