Clean up checkstyle warning

Fixes #251, closes #252
This commit is contained in:
SquidDev 2019-06-14 20:55:32 +01:00
parent 717ab69093
commit 29dce26bf6
4 changed files with 15 additions and 19 deletions

View File

@ -3,10 +3,6 @@
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<!-- Has a public m_label field. We need to check if this is used in other projects before renaming it. -->
<suppress checks="MemberName" files=".*[\\/]TileComputerBase.java"
message="Name 'm_label' must match pattern .*" />
<!-- All the config options and method fields. -->
<suppress checks="StaticVariableName" files=".*[\\/]ComputerCraft.java" />
<suppress checks="StaticVariableName" files=".*[\\/]ComputerCraftAPI.java" />

View File

@ -32,7 +32,7 @@ protected ServerComputer createComputer( int instanceID, int id )
ServerComputer computer = new ServerComputer(
getWorld(),
id,
m_label,
label,
instanceID,
family,
ComputerCraft.terminalWidth_computer,

View File

@ -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 void update()
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 NBTTagCompound writeToNBT( NBTTagCompound nbt )
{
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 @@ else if( nbt.hasKey( "userDir" ) )
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 final int getComputerID()
@Override
public final String getLabel()
{
return m_label;
return label;
}
@Override
@ -378,9 +378,9 @@ public final void setComputerID( int id )
@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 @@ protected void writeDescription( @Nonnull NBTTagCompound nbt )
{
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 @@ protected void readDescription( @Nonnull NBTTagCompound nbt )
{
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 @@ protected void transferStateFrom( TileComputerBase copy )
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 IPeripheral getPeripheral( @Nonnull EnumFacing side )
@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

View File

@ -95,7 +95,7 @@ public boolean hasMoved()
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() );