From f5b313f6a3935160e5fbb0b240041408bc115700 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 1 Jul 2019 10:29:51 +0200 Subject: [PATCH] Code cleanup --- src/main/java/cr0s/warpdrive/CommonProxy.java | 9 ++++++--- .../warpdrive/block/building/TileEntityShipScanner.java | 8 ++++++-- .../warpdrive/block/movement/TileEntityShipCore.java | 2 +- src/main/java/cr0s/warpdrive/command/CommandRender.java | 1 - src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java | 4 ++-- src/main/java/cr0s/warpdrive/core/ClassTransformer.java | 1 + .../java/cr0s/warpdrive/entity/EntityParticleBunch.java | 1 - src/main/java/cr0s/warpdrive/render/RenderCommons.java | 4 ++-- src/main/java/cr0s/warpdrive/render/RenderSpaceSky.java | 3 ++- 9 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/cr0s/warpdrive/CommonProxy.java b/src/main/java/cr0s/warpdrive/CommonProxy.java index 3f33ff46..1df447c5 100644 --- a/src/main/java/cr0s/warpdrive/CommonProxy.java +++ b/src/main/java/cr0s/warpdrive/CommonProxy.java @@ -5,6 +5,8 @@ import cr0s.warpdrive.event.EMPReceiver; import cr0s.warpdrive.event.ItemHandler; import cr0s.warpdrive.event.LivingHandler; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.lang.ref.WeakReference; import java.util.UUID; import java.util.WeakHashMap; @@ -28,7 +30,8 @@ public class CommonProxy { private static final WeakHashMap> fakePlayers = new WeakHashMap<>(100); - private static EntityPlayerMP getPlayer(final WorldServer world, final UUID uuidPlayer) { + @Nullable + private static EntityPlayerMP getPlayer(@Nonnull final WorldServer world, final UUID uuidPlayer) { assert world.getMinecraftServer() != null; for (final EntityPlayerMP entityPlayerMP : world.getMinecraftServer().getPlayerList().getPlayers()) { if (entityPlayerMP.getUniqueID() == uuidPlayer) { @@ -59,7 +62,7 @@ public class CommonProxy { } public static boolean isBlockBreakCanceled(final UUID uuidPlayer, final BlockPos blockPosSource, - final World world, final BlockPos blockPosEvent) { + @Nonnull final World world, final BlockPos blockPosEvent) { if (world.isRemote || !(world instanceof WorldServer)) { return false; } @@ -84,7 +87,7 @@ public class CommonProxy { } public static boolean isBlockPlaceCanceled(final UUID uuidPlayer, final BlockPos blockPosSource, - final World world, final BlockPos blockPosEvent, final IBlockState blockState) { + @Nonnull final World world, final BlockPos blockPosEvent, final IBlockState blockState) { if (world.isRemote || !(world instanceof WorldServer)) { return false; } diff --git a/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java b/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java index 7b7baa13..e8cfdbbe 100644 --- a/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java +++ b/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java @@ -75,7 +75,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements private int laserTicks = 0; private int scanTicks = 0; private int deployTicks = 0; - + private int searchTicks = 0; private String playerName = ""; @@ -421,7 +421,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements // Returns true on success and reason string private boolean deployShip(final String fileName, final int offsetX, final int offsetY, final int offsetZ, - final byte rotationSteps, final boolean isForced, final WarpDriveText reason) { + final byte rotationSteps, final boolean isForced, final WarpDriveText reason) { targetX = pos.getX() + offsetX; targetY = pos.getY() + offsetY; targetZ = pos.getZ() + offsetZ; @@ -678,6 +678,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements return state(); } + @Nonnull private Object[] scan() { // Already scanning? if (enumShipScannerState != EnumShipScannerState.IDLE) { @@ -692,6 +693,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements return new Object[] { success, 3, Commons.removeFormatting( reason.getUnformattedText() ) }; } + @Nonnull private Object[] filename() { if (enumShipScannerState != EnumShipScannerState.IDLE && !schematicFileName.isEmpty()) { if (enumShipScannerState == EnumShipScannerState.DEPLOYING) { @@ -704,6 +706,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements return new Object[] { true, schematicFileName }; } + @Nonnull private Object[] deploy(final Object[] arguments) { if (arguments == null || arguments.length != 5) { return new Object[] { false, "Invalid arguments count, you need <.schematic file name>, , , , !" }; @@ -743,6 +746,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements return new Object[] { isSuccess, Commons.removeFormatting( reason.getUnformattedText() ) }; } + @Nonnull private Object[] state() { switch (enumShipScannerState) { default: diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java index 6a1b1aa7..37892162 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java @@ -159,7 +159,7 @@ public class TileEntityShipCore extends TileEntityAbstractShipController impleme if (ticksCooldown > 0) { ticksCooldown--; - // report coo down time when a command is requested + // report cool down time when a command is requested if ( isEnabled && isCommandConfirmed && enumShipCommand.isMovement() ) { diff --git a/src/main/java/cr0s/warpdrive/command/CommandRender.java b/src/main/java/cr0s/warpdrive/command/CommandRender.java index e25ea81e..9e6c72f1 100644 --- a/src/main/java/cr0s/warpdrive/command/CommandRender.java +++ b/src/main/java/cr0s/warpdrive/command/CommandRender.java @@ -41,7 +41,6 @@ public class CommandRender extends AbstractCommand { if (args.length > 0) { Commons.addChatMessage(commandSender, new TextComponentString(getUsage(commandSender))); return; - } final EntityPlayerMP entityPlayer = commandSender instanceof EntityPlayerMP ? (EntityPlayerMP) commandSender : null; diff --git a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java index a0adf254..a1d04dae 100644 --- a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java +++ b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java @@ -821,13 +821,13 @@ public class WarpDriveConfig { TOOLTIP_ADD_ORE_DICTIONARY_NAME = EnumTooltipCondition.valueOf(config.get("tooltip", "add_ore_dictionary_name", TOOLTIP_ADD_ORE_DICTIONARY_NAME.name(), String.format(commentTooltip, "ore dictionary names")).getString()); TOOLTIP_ADD_ARMOR_POINTS = EnumTooltipCondition.valueOf(config.get("tooltip", "add_armor_points", TOOLTIP_ADD_ARMOR_POINTS.name(), - String.format(commentTooltip, "armor points")).getString()); + String.format(commentTooltip, "armor points")).getString()); TOOLTIP_ADD_BURN_TIME = EnumTooltipCondition.valueOf(config.get("tooltip", "add_burn_time", TOOLTIP_ADD_BURN_TIME.name(), String.format(commentTooltip, "burn time")).getString()); TOOLTIP_ADD_DURABILITY = EnumTooltipCondition.valueOf(config.get("tooltip", "add_durability", TOOLTIP_ADD_DURABILITY.name(), String.format(commentTooltip, "durability")).getString()); TOOLTIP_ADD_ENCHANTABILITY = EnumTooltipCondition.valueOf(config.get("tooltip", "add_enchantability", TOOLTIP_ADD_ENCHANTABILITY.name(), - String.format(commentTooltip, "armor & tool enchantability")).getString()); + String.format(commentTooltip, "armor & tool enchantability")).getString()); TOOLTIP_ADD_ENTITY_ID = EnumTooltipCondition.valueOf(config.get("tooltip", "add_entity_id", TOOLTIP_ADD_ENTITY_ID.name(), String.format(commentTooltip, "entity id")).getString()); TOOLTIP_ADD_FLAMMABILITY = EnumTooltipCondition.valueOf(config.get("tooltip", "add_flammability", TOOLTIP_ADD_FLAMMABILITY.name(), diff --git a/src/main/java/cr0s/warpdrive/core/ClassTransformer.java b/src/main/java/cr0s/warpdrive/core/ClassTransformer.java index cc26b8c3..075f5bc0 100644 --- a/src/main/java/cr0s/warpdrive/core/ClassTransformer.java +++ b/src/main/java/cr0s/warpdrive/core/ClassTransformer.java @@ -155,6 +155,7 @@ public class ClassTransformer implements net.minecraft.launchwrapper.IClassTrans sizeClass.put(shortName, size + bytes.length); } + @Nonnull public static String getClientValidation() { final StringBuilder result = new StringBuilder().append(new Date().toString()); for (final String key : countClass.keySet()) { diff --git a/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java b/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java index e4e59a47..60007396 100644 --- a/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java +++ b/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java @@ -9,7 +9,6 @@ import cr0s.warpdrive.data.Vector3; import javax.annotation.Nonnull; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; diff --git a/src/main/java/cr0s/warpdrive/render/RenderCommons.java b/src/main/java/cr0s/warpdrive/render/RenderCommons.java index 72bad93a..19e14edf 100644 --- a/src/main/java/cr0s/warpdrive/render/RenderCommons.java +++ b/src/main/java/cr0s/warpdrive/render/RenderCommons.java @@ -240,8 +240,8 @@ public class RenderCommons { for (int i = 0; i < 4; ++i) { renderer .pos( Float.intBitsToFloat(vData[size * i ]), - Float.intBitsToFloat(vData[size * i + 1]), - Float.intBitsToFloat(vData[size * i + 2])) + Float.intBitsToFloat(vData[size * i + 1]), + Float.intBitsToFloat(vData[size * i + 2]) ) .color(255, 255, 255, 255) .tex(Float.intBitsToFloat(vData[size * i + uv]), Float.intBitsToFloat(vData[size * i + uv + 1])) .lightmap(l1, l2) diff --git a/src/main/java/cr0s/warpdrive/render/RenderSpaceSky.java b/src/main/java/cr0s/warpdrive/render/RenderSpaceSky.java index c9159592..e00bac58 100644 --- a/src/main/java/cr0s/warpdrive/render/RenderSpaceSky.java +++ b/src/main/java/cr0s/warpdrive/render/RenderSpaceSky.java @@ -8,6 +8,7 @@ import cr0s.warpdrive.data.CelestialObject.RenderData; import cr0s.warpdrive.data.StarMapRegistry; import cr0s.warpdrive.data.Vector3; +import javax.annotation.Nonnull; import java.awt.Color; import java.util.Random; @@ -489,7 +490,7 @@ public class RenderSpaceSky extends IRenderHandler { // colorization loosely inspired from Hertzsprung-Russell diagram // (we're using it for non-star objects too, so yeah...) - private static int getStarColorRGB(final Random rand) { + private static int getStarColorRGB(@Nonnull final Random rand) { final double colorType = rand.nextDouble(); final float hue; final float saturation;