Refactored world name formatting

This commit is contained in:
Unknown 2018-06-29 01:30:15 +02:00 committed by unknown
parent aff96ea7bf
commit 616eeb3118
45 changed files with 279 additions and 294 deletions

View file

@ -74,9 +74,9 @@ public class BreathingManager {
}
if (WarpDriveConfig.LOGGING_BREATHING) {
WarpDrive.logger.warn(String.format("Entity spawn denied @ %s (%d %d %d) entityId '%s'",
entityLivingBase.world.provider.getSaveFolder(),
x, y, z, idEntity));
WarpDrive.logger.warn(String.format("Entity spawn denied %s entityId '%s'",
Commons.format(entityLivingBase.world, x, y, z),
idEntity));
}
return false;
}

View file

@ -63,9 +63,8 @@ public class CommonProxy {
return false;
}
if (WarpDriveConfig.LOGGING_BREAK_PLACE) {
WarpDrive.logger.info("isBlockBreakCanceled by " + uuidPlayer
+ " at " + blockPosSource.getX() + " " + blockPosSource.getY() + " " + blockPosSource.getZ()
+ " to " + world.provider.getDimensionType().getName() + " " + blockPosEvent.getX() + " " + blockPosEvent.getY() + " " + blockPosEvent.getZ());
WarpDrive.logger.info(String.format("isBlockBreakCanceled by %s %s to block %s",
uuidPlayer, Commons.format(world, blockPosSource), Commons.format(world, blockPosEvent)));
}
final IBlockState blockState = world.getBlockState(blockPosEvent);
@ -75,8 +74,8 @@ public class CommonProxy {
getFakePlayer(uuidPlayer, (WorldServer) world, blockPosSource));
MinecraftForge.EVENT_BUS.post(breakEvent);
if (WarpDriveConfig.LOGGING_BREAK_PLACE) {
WarpDrive.logger.info("isBlockBreakCanceled player " + breakEvent.getPlayer()
+ " isCanceled " + breakEvent.isCanceled());
WarpDrive.logger.info(String.format("isBlockBreakCanceled player %s isCanceled %s",
breakEvent.getPlayer(), breakEvent.isCanceled()));
}
return breakEvent.isCanceled();
}
@ -89,10 +88,9 @@ public class CommonProxy {
return false;
}
if (WarpDriveConfig.LOGGING_BREAK_PLACE) {
WarpDrive.logger.info("isBlockPlaceCanceled by " + uuidPlayer
+ " at " + blockPosSource.getX() + " " + blockPosSource.getY() + " " + blockPosSource.getZ()
+ " to " + world.provider.getDimensionType().getName() + " " + blockPosEvent.getX() + " " + blockPosEvent.getY() + " " + blockPosEvent.getZ()
+ " of " + blockState);
WarpDrive.logger.info(String.format("isBlockPlaceCanceled by %s %s to block %s %s",
uuidPlayer, Commons.format(world, blockPosSource),
Commons.format(world, blockPosEvent), blockState));
}
final BlockEvent.PlaceEvent placeEvent = new BlockEvent.PlaceEvent(
new BlockSnapshot(world, blockPosEvent, blockState),
@ -102,7 +100,8 @@ public class CommonProxy {
MinecraftForge.EVENT_BUS.post(placeEvent);
if (WarpDriveConfig.LOGGING_BREAK_PLACE) {
WarpDrive.logger.info("isBlockPlaceCanceled player " + placeEvent.getPlayer() + " isCanceled " + placeEvent.isCanceled());
WarpDrive.logger.info(String.format("isBlockPlaceCanceled player %s isCanceled %s",
placeEvent.getPlayer(), placeEvent.isCanceled()));
}
return placeEvent.isCanceled();
}

View file

@ -7,6 +7,8 @@ import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.data.VectorI;
import cr0s.warpdrive.world.SpaceTeleporter;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.state.IBlockState;
@ -283,6 +285,52 @@ public class Commons {
return result.toString();
}
public static String format(final World world) {
if (world == null) {
return "~NULL~";
}
// world.getProviderName() is MultiplayerChunkCache on client, ServerChunkCache on local server, (undefined method) on dedicated server
// world.provider.getSaveFolder() is null for the Overworld, other dimensions shall define it
final String saveFolder = world.provider.getSaveFolder();
if (saveFolder == null || saveFolder.isEmpty()) {
final int dimension = world.provider.getDimension();
if (dimension != 0) {
assert(false);
return String.format("~invalid dimension %d~", dimension);
}
// world.getWorldInfo().getWorldName() is MpServer on client side, or the server.properties' world name on server side
final String worldName = world.getWorldInfo().getWorldName();
if (worldName.equals("MpServer")) {
return "overworld";
}
return worldName;
}
return saveFolder;
}
public static String format(final World world, @Nonnull final BlockPos blockPos) {
return format(world, blockPos.getX(), blockPos.getY(), blockPos.getZ());
}
public static String format(final World world, final int x, final int y, final int z) {
return String.format("@ %s (%d %d %d)",
format(world),
x, y, z);
}
public static String format(final World world, @Nonnull final Vector3 vector3) {
return format(world, vector3.x, vector3.y, vector3.z);
}
public static String format(final World world, final double x, final double y, final double z) {
return String.format("@ %s (%.2f %.2f %.2f)",
format(world),
x, y, z);
}
public static String sanitizeFileName(final String name) {
return name.replace("/", "").replace(".", "").replace("\\", ".");
}

View file

@ -119,9 +119,8 @@ public class Particle {
if (explosionStrength > 0.0F) {
final float amountFactor = Math.max(1.25F, amount / 1000.0F);
world.newExplosion(null, v3Position.x, v3Position.y, v3Position.z, explosionStrength * amountFactor, true, true);
WarpDrive.logger.info(String.format("Explosion in %s @ (%.1f %.1f %.1f) with strength %.3f due to %d mg of %s",
world.provider.getSaveFolder(),
v3Position.x, v3Position.y, v3Position.z,
WarpDrive.logger.info(String.format("Explosion %s with strength %.3f due to %d mg of %s",
Commons.format(world, v3Position),
explosionStrength * amountFactor,
amount,
this));

View file

@ -177,8 +177,8 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I
@Optional.Method(modid = "DefenseTech")
public void onEMP(final World world, final int x, final int y, final int z, final defense.api.IExplosion explosiveEMP) {
if (WarpDriveConfig.LOGGING_WEAPON) {
WarpDrive.logger.info(String.format("EMP received @ %s (%d %d %d) from %s with energy %d and radius %.1f",
world.provider.getSaveFolder(), x, y, z,
WarpDrive.logger.info(String.format("EMP received %s from %s with energy %d and radius %.1f",
Commons.format(world, x, y, z),
explosiveEMP, explosiveEMP.getEnergy(), explosiveEMP.getRadius()));
}
// EMP tower = 3k Energy, 60 radius
@ -190,8 +190,8 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I
} else {
if (!isInvalidEMPreported) {
isInvalidEMPreported = true;
WarpDrive.logger.warn(String.format("EMP received @ %s (%d %d %d) from %s with energy %d and unsupported radius %.1f",
world.provider.getSaveFolder(), x, y, z,
WarpDrive.logger.warn(String.format("EMP received %s from %s with energy %d and unsupported radius %.1f",
Commons.format(world, x, y, z),
explosiveEMP, explosiveEMP.getEnergy(), explosiveEMP.getRadius()));
Commons.dumpAllThreads();
}

View file

@ -507,9 +507,8 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
@Override
public String toString() {
return String.format("%s @ %s (%d %d %d)",
return String.format("%s %s",
getClass().getSimpleName(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
Commons.format(world, pos));
}
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.block;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.event.ChunkLoadingHandler;
@ -73,9 +74,8 @@ public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractE
final int ticketSize = ticket.getMaxChunkListDepth();
final ArrayList<ChunkPos> chunksToLoad = getChunksToLoad();
if (chunksToLoad.size() > ticketSize) {
WarpDrive.logger.error(String.format("Too many chunk requested for loading @ %s (%d %d %d)",
world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ()));
WarpDrive.logger.error(String.format("Too many chunk requested for loading %s",
Commons.format(world, pos)));
return;
}
@ -161,7 +161,7 @@ public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractE
if (WarpDriveConfig.LOGGING_CHUNK_LOADING) {
WarpDrive.logger.info(String.format("Collecting %d chunks to be loaded @ %s from %s to %s",
count,
world.provider.getSaveFolder(),
Commons.format(world),
chunkMin, chunkMax));
}
final ArrayList<ChunkPos> chunkCoords = new ArrayList<>(count);

View file

@ -207,8 +207,8 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
}
final String methodName = "-?-";
if (WarpDriveConfig.LOGGING_LUA) {
WarpDrive.logger.info(String.format("LUA call at (%d %d %d) to %s(%s).%s(%s)",
pos.getX(), pos.getY(), pos.getZ(),
WarpDrive.logger.info(String.format("LUA call %s to %s(%s).%s(%s)",
Commons.format(world, pos),
peripheralName, context, methodName, Commons.format(arguments)));
}
return arguments;
@ -218,8 +218,8 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
protected String CC_getMethodNameAndLogCall(final int methodIndex, @Nonnull final Object[] arguments) {
final String methodName = methodsArray[methodIndex];
if (WarpDriveConfig.LOGGING_LUA) {
WarpDrive.logger.info(String.format("LUA call at (%d %d %d) to %s.%s(%s)",
pos.getX(), pos.getY(), pos.getZ(),
WarpDrive.logger.info(String.format("LUA call %s to %s.%s(%s)",
Commons.format(world, pos),
peripheralName, methodName, Commons.format(arguments)));
}
return methodName;
@ -339,10 +339,9 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
}
} catch (final Exception exception) {
exception.printStackTrace();
WarpDrive.logger.error(String.format("Failed to mount ComputerCraft scripts for %s @ %s (%d %d %d), isFirstTick %s",
WarpDrive.logger.error(String.format("Failed to mount ComputerCraft scripts for %s %s, isFirstTick %s",
peripheralName,
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ(),
Commons.format(world, pos),
isFirstTick()));
}
}

View file

@ -266,13 +266,4 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading {
return super.callMethod(computer, context, method, arguments);
}
@Override
public String toString() {
return String.format(
"%s @ %s (%d %d %d)",
getClass().getSimpleName(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
}
}

View file

@ -656,10 +656,9 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
@Override
public String toString() {
return String.format("%s Beam \'%d\' @ %s (%d %d %d)",
return String.format("%s Beam \'%d\' %s",
getClass().getSimpleName(),
beamFrequency,
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
Commons.format(world, pos));
}
}

View file

@ -56,12 +56,4 @@ public class TileEntityAcceleratorController extends TileEntityAbstractEnergy im
public void onBlockUpdatedInArea(final VectorI vector, final IBlockState blockState) {
}
@Override
public String toString() {
return String.format("%s @ \'%s\' (%d %d %d)",
getClass().getSimpleName(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
}
}

View file

@ -130,14 +130,6 @@ public class TileEntityAirGenerator extends TileEntityAbstractEnergy {
return true;
}
@Override
public String toString() {
return String.format("%s @ %s (%d %d %d)",
getClass().getSimpleName(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
}
// Common OC/CC methods
public Object[] enable(final Object[] arguments) {
if (arguments.length == 1 && arguments[0] != null) {

View file

@ -158,14 +158,6 @@ public class TileEntityAirGeneratorTiered extends TileEntityAbstractEnergy {
return true;
}
@Override
public String toString() {
return String.format("%s @ %s (%d %d %d)",
getClass().getSimpleName(),
world == null ? "~NULL~" : world.getWorldInfo().getWorldName(),
pos.getX(), pos.getY(), pos.getZ());
}
public Object[] enable(final Object[] arguments) {
if (arguments.length == 1 && arguments[0] != null) {
isEnabled = Commons.toBool(arguments[0]);

View file

@ -832,12 +832,4 @@ public class TileEntityShipScanner extends TileEntityAbstractInterfaced implemen
entityPlayer.inventory.markDirty();
}
}
@Override
public String toString() {
return String.format("%s @ %s (%d %d %d)",
getClass().getSimpleName(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
}
}

View file

@ -560,12 +560,4 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
}
return state;
}
@Override
public String toString() {
return String.format("%s @ \'%s\' %d, %d, %d",
getClass().getSimpleName(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
}
}

View file

@ -162,10 +162,9 @@ public class TileEntityCamera extends TileEntityAbstractInterfaced implements IV
@Override
public String toString() {
return String.format("%s %d @ %s (%d %d %d)",
return String.format("%s %d %s",
getClass().getSimpleName(),
videoChannel,
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
videoChannel,
Commons.format(world, pos));
}
}

View file

@ -123,10 +123,9 @@ public class TileEntityMonitor extends TileEntityAbstractInterfaced implements I
@Override
public String toString() {
return String.format("%s %d @ %s (%d %d %d)",
return String.format("%s %d %s",
getClass().getSimpleName(),
videoChannel,
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
Commons.format(world, pos));
}
}

View file

@ -113,11 +113,7 @@ public class TileEntityRadar extends TileEntityAbstractEnergy {
final Vector3 vec3Position = StarMapRegistry.getUniversalCoordinates(celestialObject, pos.getX(), pos.getY(), pos.getZ());
return new Object[] { pos.getX(), pos.getY(), pos.getZ(), celestialObject.getDisplayName(), vec3Position.x, vec3Position.y, vec3Position.z };
} else {
String name = world.provider.getSaveFolder();
if (name == null || name.isEmpty()) {
name = "DIM" + world.provider.getDimension();
}
return new Object[] { pos.getX(), pos.getY(), pos.getZ(), name, pos.getX(), pos.getY(), pos.getZ() };
return new Object[] { pos.getX(), pos.getY(), pos.getZ(), Commons.format(world), pos.getX(), pos.getY(), pos.getZ() };
}
}

View file

@ -746,10 +746,9 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
@Override
public String toString() {
return String.format("%s %s @ %s (%d %d %d)",
return String.format("%s %s %s",
getClass().getSimpleName(),
connectedComputers == null ? "~NULL~" : connectedComputers,
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
connectedComputers == null ? "~NULL~" : connectedComputers,
Commons.format(world, pos));
}
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.block.energy;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumComponentType;
@ -185,10 +186,9 @@ public class TileEntityEnergyBank extends TileEntityAbstractEnergy {
@Override
public String toString() {
return String.format("%s @ %s (%d %d %d) %8d",
return String.format("%s %s %8d",
getClass().getSimpleName(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ(),
Commons.format(world, pos),
energy_getEnergyStored());
}
}

View file

@ -202,10 +202,9 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
@Override
public String toString() {
return String.format("%s Beam \'%d\' @ %s (%d %d %d)",
return String.format("%s Beam \'%d\' %s",
getClass().getSimpleName(),
beamFrequency,
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
Commons.format(world, pos));
}
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.block.forcefield;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBeamFrequency;
import cr0s.warpdrive.block.TileEntityAbstractBase;
@ -130,9 +131,8 @@ public class TileEntityForceField extends TileEntityAbstractBase {
// projector is disabled or out of power
world.setBlockToAir(pos);
if (WarpDriveConfig.LOGGING_FORCEFIELD) {
WarpDrive.logger.info(String.format("Removed a force field from an offline projector @ %s (%d %d %d)",
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ()));
WarpDrive.logger.info(String.format("Removed a force field from an offline projector %s",
Commons.format(world, pos)));
}
}
}
@ -144,9 +144,8 @@ public class TileEntityForceField extends TileEntityAbstractBase {
if (gracePeriod_calls < 0) {
world.setBlockToAir(pos);
if (WarpDriveConfig.LOGGING_FORCEFIELD) {
WarpDrive.logger.info(String.format("Removed a force field with no projector defined @ %s (%d %d %d)",
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ()));
WarpDrive.logger.info(String.format("Removed a force field with no projector defined %s",
Commons.format(world, pos)));
}
}
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.block.movement;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.CelestialObjectManager;
@ -277,10 +278,9 @@ public class TileEntityShipController extends TileEntityAbstractShipController {
@Override
public String toString() {
final TileEntityShipCore tileEntityShipCore = tileEntityShipCoreWeakReference == null ? null : tileEntityShipCoreWeakReference.get();
return String.format("%s \'%s\' @ %s (%d %d %d)",
return String.format("%s \'%s\' %s",
getClass().getSimpleName(),
tileEntityShipCore == null ? "-NULL-" : tileEntityShipCore.shipName,
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
Commons.format(world, pos.getX(), pos.getY(), pos.getZ()));
}
}

View file

@ -1194,10 +1194,9 @@ public class TileEntityShipCore extends TileEntityAbstractShipController impleme
@Override
public String toString() {
return String.format("%s \'%s\' @ %s (%d %d %d)",
return String.format("%s '%s' %s",
getClass().getSimpleName(),
shipName,
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
Commons.format(world, pos));
}
}

View file

@ -287,10 +287,9 @@ public class TileEntityTransporterBeacon extends TileEntityAbstractEnergy implem
@Override
public String toString() {
return String.format("%s @ %s (%d %d %d) %8d EU linked to %s %s",
return String.format("%s %s %8d EU linked to %s %s",
getClass().getSimpleName(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ(),
Commons.format(world, pos),
energy_getEnergyStored(),
nameTransporterCore, uuidTransporterCore);
}

View file

@ -861,8 +861,8 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergy implemen
WarpDriveConfig.TRANSPORTER_ENERGIZING_ENERGY_FACTORS[4]) ) );
if (WarpDriveConfig.LOGGING_TRANSPORTER) {
WarpDrive.logger.info(String.format("Transporter parameters at (%d %d %d) are range (actual %d max %d) lockStrength (actual %.5f optimal %.5f speed %.5f)",
pos.getX(), pos.getY(), pos.getZ(),
WarpDrive.logger.info(String.format("Transporter parameters at %s are range (actual %d max %d) lockStrength (actual %.5f optimal %.5f speed %.5f)",
Commons.format(world, pos),
rangeActual, rangeMax,
lockStrengthActual, lockStrengthOptimal, lockStrengthSpeed));
}
@ -1794,11 +1794,10 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergy implemen
@Override
public String toString() {
return String.format("%s \'%s\' %s Beam %d @ %s (%d %d %d)",
return String.format("%s \'%s\' %s Beam %d %s",
getClass().getSimpleName(),
transporterName, uuid,
beamFrequency,
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
Commons.format(world, pos));
}
}

View file

@ -152,12 +152,10 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan
@Override
public String toString() {
return String.format("%s Beam \'%d\' Camera \'%d\' @ %s (%d %d %d)",
return String.format("%s Beam \'%d\' Camera \'%d\' %s",
getClass().getSimpleName(),
beamFrequency,
videoChannel,
world == null ? "~NULL~" : world.getWorldInfo().getWorldName(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
Commons.format(world, pos));
}
}

View file

@ -33,12 +33,4 @@ public class TileEntityWeaponController extends TileEntityAbstractInterfaced {
public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) {
return super.writeToNBT(tagCompound);
}
@Override
public String toString() {
return String.format("%s @ %s (%d %d %d)",
getClass().getSimpleName(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
pos.getX(), pos.getY(), pos.getZ());
}
}

View file

@ -73,11 +73,11 @@ public class CommandBed extends CommandBase {
final BlockPos bedLocation = entityPlayerMP.getBedLocation(entityPlayerMP.world.provider.getDimension());
if (bedLocation == null) {
Commons.addChatMessage(entityPlayerMP, new TextComponentString(String.format("§cTeleportation failed:\nyou need to set your bed location in %s",
entityPlayerMP.world.provider.getDimensionType().getName())));
Commons.format(entityPlayerMP.world))));
if (args.length != 0) {
Commons.addChatMessage(commandSender, new TextComponentString(String.format("§cTeleportation failed for player %s:\nplayer needs to set his/her bed location in %s",
entityPlayerMP.getName(),
entityPlayerMP.world.provider.getDimensionType().getName())));
entityPlayerMP.getName(),
Commons.format(entityPlayerMP.world))));
}
continue;
}
@ -85,24 +85,23 @@ public class CommandBed extends CommandBase {
final Block block = entityPlayerMP.world.getBlockState(bedLocation).getBlock();
if (!(block instanceof BlockBed)) {
Commons.addChatMessage(entityPlayerMP, new TextComponentString(String.format("§cTeleportation failed:\nyour bed is no longer there in %s",
entityPlayerMP.world.provider.getSaveFolder())));
Commons.format(entityPlayerMP.world))));
if (args.length != 0) {
Commons.addChatMessage(commandSender, new TextComponentString(String.format("§cTeleportation failed for player %s:\nbed is no longer there in %s",
entityPlayerMP.getName(),
entityPlayerMP.world.provider.getSaveFolder())));
entityPlayerMP.getName(),
Commons.format(entityPlayerMP.world))));
}
continue;
}
entityPlayerMP.setPositionAndUpdate(bedLocation.getX() + 0.5D, bedLocation.getY() + 0.5D, bedLocation.getZ() + 0.5D);
Commons.addChatMessage(entityPlayerMP, new TextComponentString(String.format("Teleporting to (%d %d %d)",
bedLocation.getX(), bedLocation.getY(), bedLocation.getZ())));
Commons.addChatMessage(entityPlayerMP, new TextComponentString(String.format("Teleporting to %s",
Commons.format(entityPlayerMP.world, bedLocation))));
if (args.length != 0) {
Commons.addChatMessage(commandSender, new TextComponentString(String.format("Teleporting player %s to %s @ (%d %d %d)",
entityPlayerMP.getName(),
entityPlayerMP.world.provider.getSaveFolder(),
bedLocation.getX(), bedLocation.getY(), bedLocation.getZ())));
Commons.addChatMessage(commandSender, new TextComponentString(String.format("Teleporting player %s to %s",
entityPlayerMP.getName(),
Commons.format(entityPlayerMP.world, bedLocation))));
}
}
}

View file

@ -67,12 +67,14 @@ public class CommandDebug extends CommandBase {
return;
}
WarpDrive.logger.info("/" + getName() + " " + dim + " " + x + "," + y + "," + z + " " + block + ":" + metadata + " " + actions);
WarpDrive.logger.info(String.format("/%s %d (%d %d %d) %s:%d %s",
getName(), dim, x, y, z, block, metadata, actions));
final World world = DimensionManager.getWorld(dim);
final BlockPos blockPos = new BlockPos(x, y, z);
final TileEntity tileEntity = world.getTileEntity(blockPos);
WarpDrive.logger.info("[" + getName() + "] In dimension " + world.getProviderName() + " - " + world.getWorldInfo().getWorldName()
+ ", Current block is " + world.getBlockState(blockPos) + ", tile entity is " + ((tileEntity == null) ? "undefined" : "defined"));
WarpDrive.logger.info(String.format("[%s] %s, Current block is %s, tile entity is %s",
getName(), Commons.format(world),
world.getBlockState(blockPos), ((tileEntity == null) ? "undefined" : "defined")));
final String side = FMLCommonHandler.instance().getEffectiveSide().isClient() ? "Client" : "Server";
// I(nvalidate), V(alidate), A(set air), R(emoveEntity), P(setBlock), S(etEntity)
@ -80,24 +82,29 @@ public class CommandDebug extends CommandBase {
for (final char cAction : actions.toUpperCase().toCharArray()) {
switch (cAction) {
case 'I':
WarpDrive.logger.info("[" + getName() + "] " + side + ": invalidating");
WarpDrive.logger.info(String.format("[%s] %s: invalidating",
getName(), side));
if (tileEntity != null) {
tileEntity.invalidate();
}
break;
case 'V':
WarpDrive.logger.info("[" + getName() + "] " + side + ": validating");
WarpDrive.logger.info(String.format("[%s] %s: validating",
getName(), side));
if (tileEntity != null) {
tileEntity.validate();
}
break;
case 'A':
WarpDrive.logger.info("[" + getName() + "] " + side + ": setting to Air");
WarpDrive.logger.info(String.format("[%s] %s: setting to Air",
getName(), side));
bReturn = world.setBlockToAir(blockPos);
WarpDrive.logger.info("[" + getName() + "] " + side + ": returned " + bReturn);
WarpDrive.logger.info(String.format("[%s] %s: returned %s",
getName(), side, bReturn));
break;
case 'R':
WarpDrive.logger.info("[" + getName() + "] " + side + ": remove entity");
WarpDrive.logger.info(String.format("[%s] %s: remove entity",
getName(), side));
world.removeTileEntity(blockPos);
break;
case '0':
@ -108,27 +115,34 @@ public class CommandDebug extends CommandBase {
case '5':
case '6':
case '7':
WarpDrive.logger.info("[" + getName() + "] " + side + ": set block " + x + ", " + y + ", " + z + " to " + block + ":" + metadata);
WarpDrive.logger.info(String.format("[%s] %s: set block (%d %d %d) to %s:%s" ,
getName(), side, x, y, z, block, metadata));
bReturn = world.setBlockState(blockPos, Block.getBlockById(block).getStateFromMeta(metadata), cAction - '0');
WarpDrive.logger.info("[" + getName() + "] " + side + ": returned " + bReturn);
WarpDrive.logger.info(String.format("[%s] %s: returned %s",
getName(), side, bReturn));
break;
case 'P':
WarpDrive.logger.info("[" + getName() + "] " + side + ": set block " + x + ", " + y + ", " + z + " to " + block + ":" + metadata);
WarpDrive.logger.info(String.format("[%s] %s: set block (%d %d %d) to %s:%s",
getName(), side, x, y, z, block, metadata));
bReturn = world.setBlockState(blockPos, Block.getBlockById(block).getStateFromMeta(metadata), 2);
WarpDrive.logger.info("[" + getName() + "] " + side + ": returned " + bReturn);
WarpDrive.logger.info(String.format("[%s] %s: returned %s",
getName(), side, bReturn));
break;
case 'S':
WarpDrive.logger.info("[" + getName() + "] " + side + ": set entity");
WarpDrive.logger.info(String.format("[%s] %s: set entity",
getName(), side));
world.setTileEntity(blockPos, tileEntity);
break;
case 'C':
WarpDrive.logger.info("[" + getName() + "] " + side + ": update containing block info");
WarpDrive.logger.info(String.format("[%s] %s: update containing block info",
getName(), side));
if (tileEntity != null) {
tileEntity.updateContainingBlockInfo();
}
break;
default:
WarpDrive.logger.info("[" + getName() + "] " + side + ": invalid step '" + cAction + "'");
WarpDrive.logger.info(String.format("[%s] %s: invalid step '%s",
getName(), side, cAction));
break;
}
}

View file

@ -69,9 +69,8 @@ public class CommandDump extends CommandBase {
}
// actually dump
WarpDrive.logger.info(String.format("Dumping content from container @ %s (%d %d %d):",
world.provider.getDimensionType().getName(),
x, y, z));
WarpDrive.logger.info(String.format("Dumping content from container %s:",
Commons.format(world, x, y, z)));
for (int indexSlot = 0; indexSlot < inventory.getSizeInventory(); indexSlot++) {
final ItemStack itemStack = inventory.getStackInSlot(indexSlot);
if (itemStack != null) {

View file

@ -174,11 +174,14 @@ public class CommandSpace extends CommandBase {
}
// inform player
final String message = "§aTeleporting player " + entityPlayerMP.getName() + " to dimension " + dimensionIdTarget + "..."; // + ":" + worldTarget.provider.getSaveFolder();
final String message = String.format("§aTeleporting player %s to %s (%d)",
entityPlayerMP.getName(),
Commons.format(worldTarget), dimensionIdTarget);
Commons.addChatMessage(commandSender, new TextComponentString(message));
WarpDrive.logger.info(message);
if (commandSender != entityPlayerMP) {
Commons.addChatMessage(entityPlayerMP, new TextComponentString(commandSender.getName() + " is teleporting you to dimension " + dimensionIdTarget)); // + ":" + worldTarget.getWorldInfo().getWorldName());
Commons.addChatMessage(entityPlayerMP, new TextComponentString(String.format("%s is teleporting you to %s (%d)",
commandSender.getName(), Commons.format(worldTarget), dimensionIdTarget)));
}
// find a good spot

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.config.structures;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.LocalProfiler;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -109,9 +110,8 @@ public class AsteroidFieldInstance extends AbstractStructureInstance {
// Place an asteroid
final AbstractStructure asteroid = StructureManager.getStructure(world.rand, StructureManager.GROUP_ASTEROIDS, null);
if (asteroid == null) {
WarpDrive.logger.error(String.format("Unable to generate big asteroid in DIM%d @ (%d %d %d), probably a bad configuration",
world.provider.getDimension(),
aX, aY, aZ));
WarpDrive.logger.error(String.format("Unable to generate big asteroid %s, probably a bad configuration",
Commons.format(world, aX, aY, aZ)));
} else {
asteroid.generate(world, world.rand, new BlockPos(aX, aY, aZ));
}
@ -133,9 +133,8 @@ public class AsteroidFieldInstance extends AbstractStructureInstance {
if (world.rand.nextInt(400) != 1) {
final AbstractStructure asteroid = StructureManager.getStructure(world.rand, StructureManager.GROUP_ASTEROIDS, null);
if (asteroid == null) {
WarpDrive.logger.error(String.format("Unable to generate small asteroid in DIM%d @ (%d %d %d), probably a bad configuration",
world.provider.getDimension(),
aX, aY, aZ));
WarpDrive.logger.error(String.format("Unable to generate small asteroid %s, probably a bad configuration",
Commons.format(world, aX, aY, aZ)));
} else {
asteroid.generate(world, world.rand, new BlockPos(aX, aY, aZ));
}
@ -164,9 +163,8 @@ public class AsteroidFieldInstance extends AbstractStructureInstance {
if (world.rand.nextBoolean()) {
final AbstractStructure gasCloud = StructureManager.getStructure(world.rand, StructureManager.GROUP_GAS_CLOUDS, null);
if (gasCloud == null) {
WarpDrive.logger.error(String.format("Unable to generate gas cloud in DIM%d @ (%d %d %d), probably a bad configuration",
world.provider.getDimension(),
aX, aY, aZ));
WarpDrive.logger.error(String.format("Unable to generate gas cloud %s, probably a bad configuration",
Commons.format(world, aX, aY, aZ)));
} else {
gasCloud.generate(world, world.rand, new BlockPos(aX, aY, aZ));
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.config.structures;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import java.util.Random;
@ -30,9 +31,8 @@ public class StructureGroup implements IStringSerializable {
}
final AbstractStructure abstractStructure = StructureManager.getStructure(random, group, name);
if (abstractStructure == null) {
WarpDrive.logger.warn(String.format("Celestial object @ %s (%d %d %d) refers to unknown structure %s. Probably a bad configuration. Skipping for now.",
world.provider.getSaveFolder(),
x, y, z,
WarpDrive.logger.warn(String.format("Celestial object %s refers to unknown structure %s. Probably a bad configuration. Skipping for now.",
Commons.format(world, x, y, z),
getName()));
return;
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.data;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -29,8 +30,8 @@ public class CamerasRegistry {
return cam;
} else {
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
WarpDrive.logger.info("Removing 'dead' camera at "
+ cam.position.getX() + ", " + cam.position.getY() + ", " + cam.position.getZ() + " (while searching)");
WarpDrive.logger.info(String.format("Removing 'dead' camera %s (while searching)",
Commons.format(world, cam.position)));
}
it.remove();
}
@ -57,14 +58,15 @@ public class CamerasRegistry {
private static boolean isCamAlive(final World world, final CameraRegistryItem cam) {
if (world.provider.getDimension() != cam.dimensionId) {
WarpDrive.logger.error("Inconsistent world with camera " + world.provider.getDimension() + " vs " + cam.dimensionId);
WarpDrive.logger.error(String.format("Inconsistent world with camera %s: world %d vs cam %d",
cam, world.provider.getDimension(), cam.dimensionId));
return false;
}
if (!world.getChunkFromBlockCoords(cam.position).isLoaded()) {
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
WarpDrive.logger.info("Reporting an 'unloaded' camera in dimension " + cam.dimensionId + " at "
+ cam.position.getX() + ", " + cam.position.getY() + ", " + cam.position.getZ());
WarpDrive.logger.info(String.format("Reporting an 'unloaded' camera %s",
Commons.format(world, cam.position)));
}
return false;
}
@ -72,8 +74,8 @@ public class CamerasRegistry {
if ( block != WarpDrive.blockCamera
&& block != WarpDrive.blockLaserCamera ) {
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
WarpDrive.logger.info("Reporting a 'dead' camera in dimension " + cam.dimensionId + " at "
+ cam.position.getX() + ", " + cam.position.getY() + ", " + cam.position.getZ());
WarpDrive.logger.info(String.format("Reporting a 'dead' camera %s",
Commons.format(world, cam.position)));
}
return false;
}
@ -89,8 +91,8 @@ public class CamerasRegistry {
cam = it.next();
if (!isCamAlive(world, cam)) {
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
WarpDrive.logger.info("Removing 'dead' camera in dimension " + cam.dimensionId + " at "
+ cam.position.getX() + ", " + cam.position.getY() + ", " + cam.position.getZ());
WarpDrive.logger.info(String.format("Removing 'dead' camera %s",
Commons.format(world, cam.position)));
}
it.remove();
}
@ -103,8 +105,8 @@ public class CamerasRegistry {
final CameraRegistryItem cam = getCamByPosition(world, position);
if (cam != null) {
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
WarpDrive.logger.info("Removing camera by request in dimension " + cam.dimensionId + " at "
+ cam.position.getX() + ", " + cam.position.getY() + ", " + cam.position.getZ());
WarpDrive.logger.info(String.format("Removing camera by request %s",
Commons.format(world, cam.position)));
}
registry.remove(cam);
}
@ -118,22 +120,23 @@ public class CamerasRegistry {
final CameraRegistryItem existingCam = getCamByPosition(world, cam.position);
if (existingCam == null) {
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
WarpDrive.logger.info("Adding 'live' camera at "
+ cam.position.getX() + ", " + cam.position.getY() + ", " + cam.position.getZ()
+ " with video channel '" + cam.videoChannel + "'");
WarpDrive.logger.info(String.format("Adding 'live' camera %s with video channel %s",
Commons.format(world, cam.position),
cam.videoChannel));
}
registry.add(cam);
} else if (existingCam.videoChannel != cam.videoChannel) {
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
WarpDrive.logger.info("Updating 'live' camera at "
+ cam.position.getX() + ", " + cam.position.getY() + ", " + cam.position.getZ()
+ " from video channel '" + existingCam.videoChannel + "' to video channel '" + cam.videoChannel + "'");
WarpDrive.logger.info(String.format("Updating 'live' camera %s from video channel %d to video channel %d",
Commons.format(world, cam.position),
existingCam.videoChannel, cam.videoChannel));
}
existingCam.videoChannel = cam.videoChannel;
}
} else {
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
WarpDrive.logger.info("Unable to update 'dead' camera at " + cam.position.getX() + ", " + cam.position.getY() + ", " + cam.position.getZ());
WarpDrive.logger.info(String.format("Unable to update 'dead' camera %s",
Commons.format(world, cam.position)));
}
}
}
@ -142,10 +145,12 @@ public class CamerasRegistry {
if (world == null) {
return;
}
WarpDrive.logger.info("Cameras registry for dimension " + world.provider.getSaveFolder() + ":");
WarpDrive.logger.info(String.format("Cameras registry for %s:",
Commons.format(world)));
for (final CameraRegistryItem cam : registry) {
WarpDrive.logger.info("- " + cam.videoChannel + " (" + cam.position.getX() + ", " + cam.position.getY() + ", " + cam.position.getZ() + ")");
WarpDrive.logger.info(String.format("- %d (%d %d %d)",
cam.videoChannel, cam.position.getX(), cam.position.getY(), cam.position.getZ()));
}
}
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.data;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBlockTransformer;
import cr0s.warpdrive.api.ITransformation;
@ -378,9 +379,8 @@ public class JumpBlock {
if (tileEntity != null) {
final Class<?> teClass = tileEntity.getClass();
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
WarpDrive.logger.info(String.format("Refreshing clients @ %s (%d %d %d) with %s derived from %s",
world.provider.getSaveFolder(),
blockPos.getX(), blockPos.getY(), blockPos.getZ(),
WarpDrive.logger.info(String.format("Refreshing clients %s with %s derived from %s",
Commons.format(world, blockPos),
teClass,
teClass.getSuperclass()));
}

View file

@ -245,11 +245,10 @@ public class JumpShip {
@Override
public String toString() {
return String.format("%s/%d \'%s\' @ %s (%d %d %d)",
getClass().getSimpleName(), hashCode(),
shipCore == null ? "~NULL~" : (shipCore.uuid + ":" + shipCore.shipName),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
core.getX(), core.getY(), core.getZ());
return String.format("%s/%d \'%s\' %s",
getClass().getSimpleName(), hashCode(),
shipCore == null ? "~NULL~" : (shipCore.uuid + ":" + shipCore.shipName),
Commons.format(world, core));
}
public boolean checkBorders(final StringBuilder reason) {

View file

@ -97,9 +97,8 @@ public class StateAir {
chunkData = ChunkHandler.getChunkData(world, blockPos.getX(), blockPos.getY(), blockPos.getZ());
if (chunkData == null) {
// chunk isn't loaded, abort treatment or it'll trigger a CME
throw new ExceptionChunkNotLoaded(String.format("Air refresh aborted @ %s (%d %d %d)",
world.provider.getDimensionType().getName(),
blockPos.getX(), blockPos.getY(), blockPos.getZ()));
throw new ExceptionChunkNotLoaded(String.format("Air refresh aborted %s",
Commons.format(world, blockPos.getX(), blockPos.getY(), blockPos.getZ())));
}
chunk = null;
}
@ -337,9 +336,8 @@ public class StateAir {
if ((dataAir & BLOCK_MASK) != BLOCK_AIR_PLACEABLE) {
// state was out of sync => skip
if (WarpDrive.isDev) {
WarpDrive.logger.info(String.format("Desynchronized air state detected @ %s (%d %d %d): %8x -> %s",
world.provider.getSaveFolder(),
blockPos.getX(), blockPos.getY(), blockPos.getZ(), dataAirLegacy, this));
WarpDrive.logger.info(String.format("Desynchronized air state detected %s: %8x -> %s",
Commons.format(world, blockPos), dataAirLegacy, this));
}
return;
}

View file

@ -46,7 +46,8 @@ public class EntityParticleBunch extends Entity {
public EntityParticleBunch(final World world) {
super(world);
if (WarpDriveConfig.LOGGING_ACCELERATOR) {
WarpDrive.logger.info(this + " created in dimension " + world.provider.getSaveFolder());
WarpDrive.logger.info(String.format("%s created in dimension %s",
this, Commons.format(world)));
}
}
@ -187,10 +188,9 @@ public class EntityParticleBunch extends Entity {
@Nonnull
@Override
public String toString() {
return String.format("%s/%d @ \'%s\' %.2f %.2f %.2f",
getClass().getSimpleName(),
getEntityId(),
world == null ? "~NULL~" : world.provider.getSaveFolder(),
posX, posY, posZ);
return String.format("%s/%d %s",
getClass().getSimpleName(),
getEntityId(),
Commons.format(world, posX, posY, posZ));
}
}

View file

@ -46,7 +46,7 @@ public class ChunkHandler {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("%s world %s load.",
event.getWorld().isRemote ? "Client" : "Server",
event.getWorld().provider.getDimensionType().getName()));
Commons.format(event.getWorld())));
}
}
@ -64,7 +64,7 @@ public class ChunkHandler {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("%s world %s chunk [%d, %d] generating",
world.isRemote ? "Client" : "Server",
world.provider.getDimensionType().getName(),
Commons.format(world),
chunkX, chunkZ));
}
@ -82,7 +82,7 @@ public class ChunkHandler {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("%s world %s chunk %s loading data (1)",
event.getWorld().isRemote ? "Client" : "Server",
event.getWorld().provider.getDimensionType().getName(),
Commons.format(event.getWorld()),
event.getChunk().getPos()));
}
@ -97,7 +97,7 @@ public class ChunkHandler {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("%s world %s chunk %s loaded (2)",
event.getWorld().isRemote ? "Client" : "Server",
event.getWorld().provider.getDimensionType().getName(),
Commons.format(event.getWorld()),
event.getChunk().getPos()));
}
@ -113,7 +113,7 @@ public class ChunkHandler {
public void onWatchChunk(ChunkWatchEvent.Watch event) {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("World %s chunk %s watch by %s",
event.getPlayer().world.getWorldInfo().getWorldName(),
Commons.format(event.getPlayer().world),
event.getChunk(),
event.getPlayer()));
}
@ -126,7 +126,7 @@ public class ChunkHandler {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("%s world %s chunk %s save data",
event.getWorld().isRemote ? "Client" : "Server",
event.getWorld().provider.getDimensionType().getName(),
Commons.format(event.getWorld()),
event.getChunk().getPos()));
}
final ChunkData chunkData = getChunkData(event.getWorld().isRemote, event.getWorld().provider.getDimension(), event.getChunk().x, event.getChunk().z, false);
@ -135,7 +135,7 @@ public class ChunkHandler {
} else if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.error(String.format("%s world %s chunk %s is saving data without loading it first!",
event.getWorld().isRemote ? "Client" : "Server",
event.getWorld().provider.getDimensionType().getName(),
Commons.format(event.getWorld()),
event.getChunk().getPos()));
}
}
@ -149,7 +149,7 @@ public class ChunkHandler {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("%s world %s saved.",
event.getWorld().isRemote ? "Client" : "Server",
event.getWorld().provider.getDimensionType().getName()));
Commons.format(event.getWorld())));
}
if (event.getWorld().isRemote) {
@ -168,7 +168,7 @@ public class ChunkHandler {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("%s world %s unload",
event.getWorld().isRemote ? "Client" : "Server",
event.getWorld().provider.getDimensionType().getName()));
Commons.format(event.getWorld())));
}
// get dimension data
@ -194,7 +194,7 @@ public class ChunkHandler {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("%s world %s chunk %s unload",
event.getWorld().isRemote ? "Client" : "Server",
event.getWorld().provider.getDimensionType().getName(),
Commons.format(event.getWorld()),
event.getChunk().getPos()));
}
@ -204,7 +204,7 @@ public class ChunkHandler {
} else if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.error(String.format("%s world %s chunk %s is unloading without loading it first!",
event.getWorld().isRemote ? "Client" : "Server",
event.getWorld().provider.getDimensionType().getName(),
Commons.format(event.getWorld()),
event.getChunk().getPos()));
}
}
@ -216,7 +216,7 @@ public class ChunkHandler {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("%s world %s chunk %s unwatch by %s",
event.player.world.isRemote ? "Client" : "Server",
event.player.world.provider.getSaveFolder(),
Commons.format(event.player.world),
event.chunk,
event.player));
}
@ -237,10 +237,9 @@ public class ChunkHandler {
chunkData.onBlockUpdated(x, y, z);
} else {
if (WarpDriveConfig.LOGGING_WORLD_GENERATION) {
WarpDrive.logger.error(String.format("%s world %s block updating at (%d %d %d), while chunk isn't loaded!",
WarpDrive.logger.error(String.format("%s block updating %s, while chunk isn't loaded!",
world.isRemote ? "Client" : "Server",
world.provider.getDimensionType().getName(),
x, y, z));
Commons.format(world, x, y, z)));
Commons.dumpAllThreads();
}
}
@ -254,9 +253,9 @@ public class ChunkHandler {
public static ChunkData getChunkData(final World world, final int x, final int y, final int z) {
final ChunkData chunkData = getChunkData(world.isRemote, world.provider.getDimension(), x, y, z);
if (chunkData == null) {
WarpDrive.logger.error(String.format("Trying to get data from an non-loaded chunk in %s world %s @ (%d %d %d)",
WarpDrive.logger.error(String.format("Trying to get data from an non-loaded chunk in %s %s",
world.isRemote ? "Client" : "Server",
world.provider.getSaveFolder(), x, y, z));
Commons.format(world, x, y, z)));
LocalProfiler.printCallStats();
Commons.dumpAllThreads();
assert(false);
@ -345,9 +344,8 @@ public class ChunkHandler {
try {
return chunkData.getStateAir(world, x, y, z);
} catch (final ExceptionChunkNotLoaded exceptionChunkNotLoaded) {
WarpDrive.logger.warn(String.format("Aborting air evaluation: chunk isn't loaded @ %s (%d %d %d)",
world.provider.getSaveFolder(),
x, y, z));
WarpDrive.logger.warn(String.format("Aborting air evaluation: chunk isn't loaded %s",
Commons.format(world, x, y, z)));
return null;
}
}
@ -380,7 +378,7 @@ public class ChunkHandler {
if (WarpDriveConfig.LOGGING_CHUNK_HANDLER) {
WarpDrive.logger.info(String.format("%s world %s chunk %s is being removed from updateTick (size is %d)",
world.isRemote ? "Client" : "Server",
world.provider.getSaveFolder(),
Commons.format(world),
chunkData.getChunkCoords(),
mapRegistryItems.size()));
}
@ -391,7 +389,7 @@ public class ChunkHandler {
} catch (final ConcurrentModificationException exception) {
WarpDrive.logger.error(String.format("%s world %s had some chunks changed outside main thread? (size %d -> %d)",
world.isRemote ? "Client" : "Server",
world.provider.getSaveFolder(),
Commons.format(world),
sizeBefore, mapRegistryItems.size()));
exception.printStackTrace();
LocalProfiler.printCallStats();

View file

@ -1,6 +1,8 @@
package cr0s.warpdrive.event;
import com.google.common.collect.ImmutableSet;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractChunkLoading;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -41,9 +43,8 @@ public class ChunkLoadingHandler implements LoadingCallback {
final int z = tagCompound.getInteger("posZ");
final TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
if (!(tileEntity instanceof TileEntityAbstractChunkLoading)) {
WarpDrive.logger.error(String.format("Unable to resume chunkloading @ %s (%d %d %d): invalid tile entity %s",
world.provider.getSaveFolder(),
x, y, z,
WarpDrive.logger.error(String.format("Unable to resume chunkloading %s: invalid tile entity %s",
Commons.format(world, x, y, z),
tileEntity == null ? "-null-" : tileEntity));
ForgeChunkManager.releaseTicket(ticket);
continue;
@ -52,9 +53,8 @@ public class ChunkLoadingHandler implements LoadingCallback {
final TileEntityAbstractChunkLoading tileEntityAbstractChunkLoading = (TileEntityAbstractChunkLoading) tileEntity;
final boolean shouldChunkLoad = tileEntityAbstractChunkLoading.shouldChunkLoad();
if (!shouldChunkLoad) {
WarpDrive.logger.warn(String.format("Unable to resume chunkloading @ %s (%d %d %d): chunk loader is disabled or out of power %s",
world.provider.getSaveFolder(),
x, y, z,
WarpDrive.logger.warn(String.format("Unable to resume chunkloading %s: chunk loader is disabled or out of power %s",
Commons.format(world, x, y, z),
tileEntity));
ForgeChunkManager.releaseTicket(ticket);
continue;
@ -70,21 +70,20 @@ public class ChunkLoadingHandler implements LoadingCallback {
public static Ticket forgeTicket_requestNormal(final World world, final TileEntity tileEntity) {
if (ForgeChunkManager.ticketCountAvailableFor(WarpDrive.instance, world) <= 0) {
WarpDrive.logger.error(String.format("No ChunkLoader tickets available for %s",
world.provider.getSaveFolder()));
Commons.format(world)));
return null;
}
final Ticket ticket = ForgeChunkManager.requestTicket(WarpDrive.instance, world, Type.NORMAL);
if (ticket == null) {
WarpDrive.logger.error(String.format("Failed to register ChunkLoader Ticket for %s",
world.provider.getSaveFolder()));
Commons.format(world)));
return null;
}
if (WarpDriveConfig.LOGGING_CHUNK_LOADING) {
WarpDrive.logger.info(String.format("Forcing chunk loading @ %s (%d %d %d)",
ticket.world.provider.getSaveFolder(),
tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ()));
WarpDrive.logger.info(String.format("Forcing chunk loading %s",
Commons.format(ticket.world, tileEntity.getPos())));
}
final NBTTagCompound tagCompound = ticket.getModData();
@ -109,7 +108,7 @@ public class ChunkLoadingHandler implements LoadingCallback {
public static void forgeTicket_addChunks(final Ticket ticket, final ChunkPos chunk) {
if (WarpDrive.isDev) {
WarpDrive.logger.info(String.format("Forcing chunk loading @ %s %s",
ticket.world.provider.getSaveFolder(),
Commons.format(ticket.world),
chunk));
}
ForgeChunkManager.forceChunk(ticket, chunk);
@ -125,16 +124,15 @@ public class ChunkLoadingHandler implements LoadingCallback {
final int x = tagCompound.getInteger("posX");
final int y = tagCompound.getInteger("posY");
final int z = tagCompound.getInteger("posZ");
WarpDrive.logger.info(String.format("Releasing chunk loading @ %s (%d %d %d)",
ticket.world.provider.getSaveFolder(),
x, y, z));
WarpDrive.logger.info(String.format("Releasing chunk loading %s",
Commons.format(ticket.world, x, y, z)));
}
final ImmutableSet<ChunkPos> chunks = ticket.getChunkList();
for (final ChunkPos chunk : chunks) {
if (WarpDrive.isDev) {
WarpDrive.logger.info(String.format("Releasing chunk loading @ %s %s",
ticket.world.provider.getSaveFolder(),
Commons.format(ticket.world),
chunk));
}
ForgeChunkManager.unforceChunk(ticket, chunk);

View file

@ -56,8 +56,8 @@ public class EMPReceiver implements IEMPReceiver, ICapabilityProvider {
}
if (WarpDriveConfig.LOGGING_WEAPON) {
WarpDrive.logger.info(String.format("EMP received @ %s (%.1f %.1f %.1f) from %s with source %s and radius %.1f",
world.provider.getSaveFolder(), x, y, z,
WarpDrive.logger.info(String.format("EMP received %s from %s with source %s and radius %.1f",
Commons.format(world, x, y, z),
blastEMP, blastEMP.getBlastSource(), blastEMP.getBlastRadius()));
}
// EMP tower = 3k Energy, 60 radius
@ -69,8 +69,8 @@ public class EMPReceiver implements IEMPReceiver, ICapabilityProvider {
} else {
if (!isInvalidEMPReported) {
isInvalidEMPReported = true;
WarpDrive.logger.warn(String.format("EMP received @ %s (%.1f %.1f %.1f) from %s with source %s and unsupported radius %.1f",
world.provider.getSaveFolder(), x, y, z,
WarpDrive.logger.warn(String.format("EMP received @ %s from %s with source %s and unsupported radius %.1f",
Commons.format(world, x, y, z),
blastEMP, blastEMP.getBlastSource(), blastEMP.getBlastRadius()));
Commons.dumpAllThreads();
}

View file

@ -334,12 +334,13 @@ public class JumpSequencer extends AbstractSequencer {
private boolean forceSourceChunks(final StringBuilder reason) {
if (WarpDriveConfig.LOGGING_JUMP) {
WarpDrive.logger.info(this + " Forcing source chunks in " + sourceWorld.provider.getDimensionType().getName());
WarpDrive.logger.info(String.format("%s Forcing source chunks in %s",
this, Commons.format(sourceWorld)));
}
sourceWorldTicket = ForgeChunkManager.requestTicket(WarpDrive.instance, sourceWorld, Type.NORMAL);
if (sourceWorldTicket == null) {
reason.append(String.format("Chunkloading rejected in source world %s. Aborting.",
sourceWorld.provider.getSaveFolder()));
Commons.format(sourceWorld)));
return false;
}
@ -366,12 +367,13 @@ public class JumpSequencer extends AbstractSequencer {
private boolean forceTargetChunks(final StringBuilder reason) {
LocalProfiler.start("Jump.forceTargetChunks");
if (WarpDriveConfig.LOGGING_JUMP) {
WarpDrive.logger.info(this + " Forcing target chunks in " + targetWorld.provider.getDimensionType().getName());
WarpDrive.logger.info(String.format("%s Forcing target chunks in %s",
this, Commons.format(targetWorld)));
}
targetWorldTicket = ForgeChunkManager.requestTicket(WarpDrive.instance, targetWorld, Type.NORMAL);
if (targetWorldTicket == null) {
reason.append(String.format("Chunkloading rejected in target world %s. Aborting.",
targetWorld.provider.getSaveFolder()));
Commons.format(targetWorld)));
return false;
}
@ -581,7 +583,8 @@ public class JumpSequencer extends AbstractSequencer {
}
if (betweenWorlds && WarpDriveConfig.LOGGING_JUMP) {
WarpDrive.logger.info(this + " From world " + sourceWorld.provider.getDimensionType().getName() + " to " + targetWorld.provider.getDimensionType().getName());
WarpDrive.logger.info(String.format("%s From world %s to %s",
this, Commons.format(sourceWorld), Commons.format(targetWorld)));
}
// Calculate jump vector
@ -685,8 +688,8 @@ public class JumpSequencer extends AbstractSequencer {
final CelestialObject celestialObjectTarget = CelestialObjectManager.get(targetWorld, (int) aabbTarget.minX, (int) aabbTarget.minZ);
if (celestialObjectTarget == null) {
if (WarpDriveConfig.LOGGING_JUMP) {
WarpDrive.logger.error(String.format("There's no world border defined for dimension %s (%d)",
targetWorld.provider.getSaveFolder(), targetWorld.provider.getDimension()));
WarpDrive.logger.error(String.format("There's no world border defined for %s (%d)",
Commons.format(targetWorld), targetWorld.provider.getDimension()));
}
} else {
@ -824,8 +827,8 @@ public class JumpSequencer extends AbstractSequencer {
final CelestialObject celestialObject = CelestialObjectManager.getClosestChild(sourceWorld, ship.core.getX(), ship.core.getZ());
// anything defined?
if (celestialObject == null) {
reason.append(String.format("Unable to reach space from this location!\nThere's no celestial object defined for current dimension %s (%d).",
sourceWorld.provider.getSaveFolder(), sourceWorld.provider.getDimension()));
reason.append(String.format("Unable to reach space from this location!\nThere's no celestial object defined for %s (%d).",
Commons.format(sourceWorld), sourceWorld.provider.getDimension()));
return false;
}
@ -865,8 +868,8 @@ public class JumpSequencer extends AbstractSequencer {
case HYPERSPACE_ENTERING: {
// anything defined?
if (celestialObjectSource.parent == null) {
reason.append(String.format("Unable to reach hyperspace!\nThere's no parent defined for current dimension %s (%d).",
sourceWorld.provider.getSaveFolder(), sourceWorld.provider.getDimension()));
reason.append(String.format("Unable to reach hyperspace!\nThere's no parent defined for %s (%d).",
Commons.format(sourceWorld), sourceWorld.provider.getDimension()));
return false;
}
// (target world border is checked systematically after movement checks)
@ -894,8 +897,8 @@ public class JumpSequencer extends AbstractSequencer {
case PLANET_TAKEOFF: {
// anything defined?
if (celestialObjectSource.parent == null) {
reason.append(String.format("Unable to take off!\nThere's no parent defined for current dimension %s (%d).",
sourceWorld.provider.getSaveFolder(), sourceWorld.provider.getDimension()));
reason.append(String.format("Unable to take off!\nThere's no parent defined for %s (%d).",
Commons.format(sourceWorld), sourceWorld.provider.getDimension()));
return false;
}
@ -1586,9 +1589,8 @@ public class JumpSequencer extends AbstractSequencer {
public int compare(final TileEntity o1, final TileEntity o2) {
if (o1.getPos().getX() == o2.getPos().getX() && o1.getPos().getY() == o2.getPos().getY() && o1.getPos().getZ() == o2.getPos().getZ()) {
if (WarpDriveConfig.LOGGING_JUMP) {
WarpDrive.logger.warn(String.format("Removing TE duplicates: detected duplicate in %s @ %d %d %d: %s vs %s",
o1.getWorld().provider.getDimensionType().getName(),
o1.getPos().getX(), o1.getPos().getY(), o1.getPos().getZ(),
WarpDrive.logger.warn(String.format("Removing TE duplicates: detected duplicate %s: %s vs %s",
Commons.format(o1.getWorld(), o1.getPos()),
o1, o2));
final NBTTagCompound nbtTagCompound1 = new NBTTagCompound();
o1.writeToNBT(nbtTagCompound1);
@ -1621,10 +1623,10 @@ public class JumpSequencer extends AbstractSequencer {
@Override
public String toString() {
return String.format("%s/%d \'%s\' @ %s (%d %d %d) #%d",
getClass().getSimpleName(), hashCode(),
(ship == null || ship.shipCore == null) ? "~NULL~" : (ship.shipCore.uuid + ":" + ship.shipCore.shipName),
sourceWorld == null ? "~NULL~" : sourceWorld.provider.getSaveFolder(),
ship == null ? -1 : ship.core.getX(), ship == null ? -1 : ship.core.getY(), ship == null ? -1 : ship.core.getZ(),
ticks);
getClass().getSimpleName(), hashCode(),
(ship == null || ship.shipCore == null) ? "~NULL~" : (ship.shipCore.uuid + ":" + ship.shipCore.shipName),
Commons.format(sourceWorld),
ship == null ? -1 : ship.core.getX(), ship == null ? -1 : ship.core.getY(), ship == null ? -1 : ship.core.getZ(),
ticks);
}
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.render;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.CelestialObject;
import cr0s.warpdrive.data.CelestialObjectManager;
@ -31,7 +32,7 @@ public class RenderOverlayLocation {
final int z = MathHelper.floor(entityPlayer.posZ);
// get celestial object
String name = entityPlayer.world.provider.getDimensionType().getName();
String name = Commons.format(entityPlayer.world);
String description = "";
final CelestialObject celestialObject = CelestialObjectManager.get(entityPlayer.world, x, z);
if (celestialObject != null) {

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.world;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.Filler;
@ -141,10 +142,9 @@ public class WorldGenStructure {
final GenericSet<Loot> lootSet = WarpDriveConfig.LootManager.getRandomSetFromGroup(rand, group);
if (lootSet == null) {
WarpDrive.logger.warn(String.format("No LootSet found with group %s for inventory @ %s (%d %d %d): check your configuration",
WarpDrive.logger.warn(String.format("No LootSet found with group %s for inventory %s: check your configuration",
group,
world.provider.getSaveFolder(),
x, y, z));
Commons.format(world, x, y, z)));
return;
}
@ -168,11 +168,10 @@ public class WorldGenStructure {
}
}
if (!isAdded) {
WarpDrive.logger.info(String.format("Unable to find a valid loot from LootSet %s for inventory %s in @ %s (%d %d %d): check your configuration",
WarpDrive.logger.info(String.format("Unable to find a valid loot from LootSet %s for inventory %s in %s: check your configuration",
lootSet.getFullName(),
inventory.getName() == null ? "-null name-" : inventory.getName(),
world.provider.getSaveFolder(),
x, y, z));
Commons.format(world, x, y, z)));
}
}
}