diff --git a/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java b/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java index 2f531723f..768afd017 100644 --- a/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java @@ -17,8 +17,8 @@ import java.util.*; public class HTTPAPI implements ILuaAPI { - private IAPIEnvironment m_apiEnvironment; - private List m_httpRequests; + private final IAPIEnvironment m_apiEnvironment; + private final List m_httpRequests; public HTTPAPI( IAPIEnvironment environment ) { diff --git a/src/main/java/dan200/computercraft/core/apis/HTTPRequest.java b/src/main/java/dan200/computercraft/core/apis/HTTPRequest.java index 55390c262..b7f816ad7 100644 --- a/src/main/java/dan200/computercraft/core/apis/HTTPRequest.java +++ b/src/main/java/dan200/computercraft/core/apis/HTTPRequest.java @@ -278,8 +278,8 @@ public class HTTPRequest return null; } - private Object m_lock = new Object(); - private URL m_url; + private final Object m_lock = new Object(); + private final URL m_url; private final String m_urlString; private boolean m_complete; diff --git a/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java b/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java index 01edb43a6..64a39c801 100644 --- a/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java @@ -235,9 +235,9 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange } } - private IAPIEnvironment m_environment; + private final IAPIEnvironment m_environment; private FileSystem m_fileSystem; - private PeripheralWrapper[] m_peripherals; + private final PeripheralWrapper[] m_peripherals; private boolean m_running; public PeripheralAPI( IAPIEnvironment _environment ) diff --git a/src/main/java/dan200/computercraft/core/apis/TermAPI.java b/src/main/java/dan200/computercraft/core/apis/TermAPI.java index 926cc51b9..dfaf3afd0 100644 --- a/src/main/java/dan200/computercraft/core/apis/TermAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/TermAPI.java @@ -15,8 +15,8 @@ import javax.annotation.Nonnull; public class TermAPI implements ILuaAPI { - private Terminal m_terminal; - private IComputerEnvironment m_environment; + private final Terminal m_terminal; + private final IComputerEnvironment m_environment; public TermAPI( IAPIEnvironment _environment ) { diff --git a/src/main/java/dan200/computercraft/core/computer/Computer.java b/src/main/java/dan200/computercraft/core/computer/Computer.java index 51c38eb29..460982ff1 100644 --- a/src/main/java/dan200/computercraft/core/computer/Computer.java +++ b/src/main/java/dan200/computercraft/core/computer/Computer.java @@ -186,26 +186,26 @@ public class Computer private boolean m_blinking; private ILuaMachine m_machine; - private List m_apis; - private APIEnvironment m_apiEnvironment; + private final List m_apis; + private final APIEnvironment m_apiEnvironment; - private Terminal m_terminal; + private final Terminal m_terminal; private FileSystem m_fileSystem; private IWritableMount m_rootMount; - private int[] m_internalOutput; - private int[] m_internalBundledOutput; + private final int[] m_internalOutput; + private final int[] m_internalBundledOutput; private boolean m_internalOutputChanged; - private int[] m_externalOutput; - private int[] m_externalBundledOutput; + private final int[] m_externalOutput; + private final int[] m_externalBundledOutput; private boolean m_externalOutputChanged; - private int[] m_input; - private int[] m_bundledInput; + private final int[] m_input; + private final int[] m_bundledInput; private boolean m_inputChanged; - private IPeripheral[] m_peripherals; + private final IPeripheral[] m_peripherals; public Computer( IComputerEnvironment environment, Terminal terminal, int id ) { diff --git a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java index 98297fe23..49d739c95 100644 --- a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java +++ b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java @@ -13,14 +13,14 @@ import java.util.concurrent.LinkedBlockingQueue; public class ComputerThread { - private static Object m_lock; + private static final Object m_lock; private static Thread m_thread; - private static WeakHashMap > m_computerTasks; - private static ArrayList > m_computerTasksActive; - private static ArrayList > m_computerTasksPending; - private static Object m_defaultQueue; - private static Object m_monitor; + private static final WeakHashMap > m_computerTasks; + private static final ArrayList > m_computerTasksActive; + private static final ArrayList > m_computerTasksPending; + private static final Object m_defaultQueue; + private static final Object m_monitor; private static boolean m_running; private static boolean m_stopped; diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java index b26a59440..f3033e5f8 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java @@ -84,7 +84,7 @@ public abstract class ModemPeripheral private INetwork m_network; private IComputerAccess m_computer; - private Map m_channels; + private final Map m_channels; private boolean m_open; private boolean m_changed; diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/TileCable.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/TileCable.java index c1dcd71f4..8eb6669e3 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/TileCable.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/TileCable.java @@ -233,13 +233,13 @@ public class TileCable extends TileModemBase // Members - private Map> m_receivers; - private Queue m_transmitQueue; + private final Map> m_receivers; + private final Queue m_transmitQueue; private boolean m_peripheralAccessAllowed; private int m_attachedPeripheralID; - private Map m_peripheralsByName; + private final Map m_peripheralsByName; private Map m_peripheralWrappersByName; private boolean m_peripheralsKnown; private boolean m_destroyed; diff --git a/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java b/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java index 78ad00e5a..f54d07425 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java @@ -447,16 +447,8 @@ public class TilePrinter extends TilePeripheralBase { synchronized( m_inventory ) { - ItemStack inkStack = m_inventory[0]; - if( inkStack == null || !isInk(inkStack) ) - { - return false; - } - if( getPaperLevel() > 0 ) - { - return true; - } - return false; + ItemStack inkStack = m_inventory[ 0 ]; + return inkStack != null && isInk( inkStack ) && getPaperLevel() > 0; } } diff --git a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java index de8b2669e..69f100edc 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java @@ -52,10 +52,6 @@ public class PocketModemPeripheral extends WirelessModemPeripheral @Override public boolean equals( IPeripheral other ) { - if( other instanceof PocketModemPeripheral ) - { - return true; - } - return false; + return other instanceof PocketModemPeripheral; } } diff --git a/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java index 86dd2adb5..1702855f9 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java @@ -112,7 +112,6 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy } catch( Exception e ) { - continue; } } return null; diff --git a/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java index edbc78a2b..09c80c0b9 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java @@ -245,11 +245,7 @@ public class TileTurtle extends TileComputerBase } else { - if( exploder != null && ( exploder instanceof EntityLivingBase || exploder instanceof EntityFireball ) ) - { - return true; - } - return false; + return exploder != null && (exploder instanceof EntityLivingBase || exploder instanceof EntityFireball); } } @@ -705,11 +701,7 @@ public class TileTurtle extends TileComputerBase case 5: upgrade = getUpgrade( TurtleSide.Left ); break; default: return false; } - if( upgrade != null && upgrade.getType().isPeripheral() ) - { - return true; - } - return false; + return upgrade != null && upgrade.getType().isPeripheral(); } public void transferStateFrom( TileTurtle copy ) diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java index 48ce2d373..787a8532a 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java @@ -140,11 +140,7 @@ public class TurtleTool implements ITurtleUpgrade { IBlockState state = world.getBlockState( pos ); Block block = state.getBlock(); - if( block.isAir( state, world, pos ) || block == Blocks.BEDROCK || state.getBlockHardness( world, pos ) <= -1.0F ) - { - return false; - } - return true; + return !block.isAir( state, world, pos ) && block != Blocks.BEDROCK && state.getBlockHardness( world, pos ) > -1.0F; } protected boolean canHarvestBlock( World world, BlockPos pos ) diff --git a/src/main/java/dan200/computercraft/shared/util/IDAssigner.java b/src/main/java/dan200/computercraft/shared/util/IDAssigner.java index d6eda9687..b1eb6910e 100644 --- a/src/main/java/dan200/computercraft/shared/util/IDAssigner.java +++ b/src/main/java/dan200/computercraft/shared/util/IDAssigner.java @@ -50,7 +50,6 @@ public class IDAssigner } catch( NumberFormatException e ) { - continue; } } }