From 29dce26bf62525ccca110c9c0dee91ec319be404 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 14 Jun 2019 20:55:32 +0100 Subject: [PATCH] Clean up checkstyle warning Fixes #251, closes #252 --- config/checkstyle/suppressions.xml | 4 --- .../shared/computer/blocks/TileComputer.java | 2 +- .../computer/blocks/TileComputerBase.java | 26 +++++++++---------- .../shared/turtle/blocks/TileTurtle.java | 2 +- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml index a6dd2983d..0cafe14ef 100644 --- a/config/checkstyle/suppressions.xml +++ b/config/checkstyle/suppressions.xml @@ -3,10 +3,6 @@ "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd"> - - - diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java index 210e15098..7769f174d 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java @@ -32,7 +32,7 @@ public class TileComputer extends TileComputerBase ServerComputer computer = new ServerComputer( getWorld(), id, - m_label, + label, instanceID, family, ComputerCraft.terminalWidth_computer, diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java index f049ef940..7034d91b7 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java @@ -47,7 +47,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT { private int m_instanceID = -1; private int m_computerID = -1; - protected String m_label = null; + protected String label = null; private boolean m_on = false; boolean m_startOn = false; private boolean m_fresh = false; @@ -190,7 +190,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT m_fresh = false; m_computerID = computer.getID(); - m_label = computer.getLabel(); + label = computer.getLabel(); m_on = computer.isOn(); if( computer.hasOutputChanged() ) updateOutput(); @@ -212,9 +212,9 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT { nbt.setInteger( "computerID", m_computerID ); } - if( m_label != null ) + if( label != null ) { - nbt.setString( "label", m_label ); + nbt.setString( "label", label ); } nbt.setBoolean( "on", m_on ); return super.writeToNBT( nbt ); @@ -248,7 +248,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT m_computerID = id; // Load label - m_label = nbt.hasKey( "label" ) ? nbt.getString( "label" ) : null; + label = nbt.hasKey( "label" ) ? nbt.getString( "label" ) : null; // Load power state m_startOn = nbt.getBoolean( "on" ); @@ -361,7 +361,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public final String getLabel() { - return m_label; + return label; } @Override @@ -378,9 +378,9 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public final void setLabel( String label ) { - if( getWorld().isRemote || Objects.equals( m_label, label ) ) return; + if( getWorld().isRemote || Objects.equals( this.label, label ) ) return; - m_label = label; + this.label = label; ServerComputer computer = getServerComputer(); if( computer != null ) computer.setLabel( label ); markDirty(); @@ -454,7 +454,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT { super.writeDescription( nbt ); if( m_instanceID >= 0 ) nbt.setInteger( "instanceID", m_instanceID ); - if( m_label != null ) nbt.setString( "label", m_label ); + if( label != null ) nbt.setString( "label", label ); if( m_computerID >= 0 ) nbt.setInteger( "computerID", m_computerID ); } @@ -463,7 +463,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT { super.readDescription( nbt ); m_instanceID = nbt.getInteger( "instanceID" ); - m_label = nbt.hasKey( "label" ) ? nbt.getString( "label" ) : null; + label = nbt.hasKey( "label" ) ? nbt.getString( "label" ) : null; m_computerID = nbt.hasKey( "computerID" ) ? nbt.getInteger( "computerID" ) : -1; } @@ -474,7 +474,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT unload(); m_instanceID = copy.m_instanceID; m_computerID = copy.m_computerID; - m_label = copy.m_label; + label = copy.label; m_on = copy.m_on; m_startOn = copy.m_startOn; updateBlock(); @@ -493,13 +493,13 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public String getName() { - return hasCustomName() ? m_label : getBlockType().getTranslationKey(); + return hasCustomName() ? label : getBlockType().getTranslationKey(); } @Override public boolean hasCustomName() { - return !Strings.isNullOrEmpty( m_label ); + return !Strings.isNullOrEmpty( label ); } @Nonnull 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 b96dd6868..353ce8d5d 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java @@ -95,7 +95,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default protected ServerComputer createComputer( int instanceID, int id ) { ServerComputer computer = new ServerComputer( - getWorld(), id, m_label, instanceID, getFamily(), + getWorld(), id, label, instanceID, getFamily(), ComputerCraft.terminalWidth_turtle, ComputerCraft.terminalHeight_turtle ); computer.setPosition( getPos() );