Skip to content

Commit

Permalink
refactor: component field visibility public (#5191)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrueckert authored Dec 6, 2023
1 parent 1b57c1b commit d81cc97
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class GetterSetterComponent implements Component<GetterSetterComponent> {
public transient boolean getterUsed;
public transient boolean setterUsed;

private Vector3f value = new Vector3f(0, 0, 0);
public Vector3f value = new Vector3f(0, 0, 0);

Check warning on line 12 in engine-tests/src/main/java/org/terasology/unittest/stubs/GetterSetterComponent.java

View check run for this annotation

Terasology Jenkins.io / SpotBugs

PA_PUBLIC_PRIMITIVE_ATTRIBUTE

LOW: Primitive field org.terasology.unittest.stubs.GetterSetterComponent.value is public and set from inside the class, which makes it too exposed. Consider making it private to limit external accessibility.
Raw output
no message found

public Vector3f getValue() {
getterUsed = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.terasology.gestalt.entitysystem.component.Component;

public class GetterSetterComponent implements Component<GetterSetterComponent> {
private int value;
public int value;

public void setValue(int value) {
this.value = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class SectorSimulationComponent implements Component<SectorSimulationComp
* This is used to calculate the delta between simulation events, and should not be changed outside of this class
* or the {@link SectorSimulationSystem}.
*/
protected long lastSimulationTime;
public long lastSimulationTime;

/**
* Create a new {@link SectorSimulationComponent} with the default max delta.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
@ForceBlockActive
public final class DelayedActionComponent implements Component<DelayedActionComponent> {
private Map<String, Long> actionIdsWakeUp = new HashMap<>();
private long lowestWakeUp = Long.MAX_VALUE;
public Map<String, Long> actionIdsWakeUp = new HashMap<>();
public long lowestWakeUp = Long.MAX_VALUE;

Check warning on line 21 in engine/src/main/java/org/terasology/engine/logic/delay/DelayedActionComponent.java

View check run for this annotation

Terasology Jenkins.io / SpotBugs

PA_PUBLIC_PRIMITIVE_ATTRIBUTE

LOW: Primitive field org.terasology.engine.logic.delay.DelayedActionComponent.lowestWakeUp is public and set from inside the class, which makes it too exposed. Consider making it private to limit external accessibility.
Raw output
no message found

public DelayedActionComponent() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/
@ForceBlockActive
public final class PeriodicActionComponent implements Component<PeriodicActionComponent> {
private Map<String, Long> actionIdsWakeUp = new HashMap<>();
private Map<String, Long> actionIdsPeriod = new HashMap<>();
private long lowestWakeUp = Long.MAX_VALUE;
public Map<String, Long> actionIdsWakeUp = new HashMap<>();
public Map<String, Long> actionIdsPeriod = new HashMap<>();
public long lowestWakeUp = Long.MAX_VALUE;

Check warning on line 22 in engine/src/main/java/org/terasology/engine/logic/delay/PeriodicActionComponent.java

View check run for this annotation

Terasology Jenkins.io / SpotBugs

PA_PUBLIC_PRIMITIVE_ATTRIBUTE

LOW: Primitive field org.terasology.engine.logic.delay.PeriodicActionComponent.lowestWakeUp is public and set from inside the class, which makes it too exposed. Consider making it private to limit external accessibility.
Raw output
no message found

public PeriodicActionComponent() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ public final class LocationComponent implements Component<LocationComponent>, Re

// Relative to
@Replicate

Check warning on line 32 in engine/src/main/java/org/terasology/engine/logic/location/LocationComponent.java

View check run for this annotation

Terasology Jenkins.io / SpotBugs

PA_PUBLIC_PRIMITIVE_ATTRIBUTE

LOW: Primitive field org.terasology.engine.logic.location.LocationComponent.parent is public and set from inside the class, which makes it too exposed. Consider making it private to limit external accessibility.
Raw output
no message found
EntityRef parent = EntityRef.NULL;
public EntityRef parent = EntityRef.NULL;
@Replicate
List<EntityRef> children = Lists.newArrayList();
public List<EntityRef> children = Lists.newArrayList();
// Standard position/rotation
@Replicate
@TextField
final Vector3f position = new Vector3f();
public final Vector3f position = new Vector3f();
@Replicate
Quaternionf rotation = new Quaternionf();
public Quaternionf rotation = new Quaternionf();
@Replicate

Check warning on line 42 in engine/src/main/java/org/terasology/engine/logic/location/LocationComponent.java

View check run for this annotation

Terasology Jenkins.io / SpotBugs

PA_PUBLIC_PRIMITIVE_ATTRIBUTE

LOW: Primitive field org.terasology.engine.logic.location.LocationComponent.scale is public and set from inside the class, which makes it too exposed. Consider making it private to limit external accessibility.
Raw output
no message found
float scale = 1.0f;
public float scale = 1.0f;
@Replicate
Vector3f lastPosition = new Vector3f();
public Vector3f lastPosition = new Vector3f();
@Replicate
Quaternionf lastRotation = new Quaternionf();
private boolean isDirty = false;
public Quaternionf lastRotation = new Quaternionf();
public boolean isDirty = false;

Check warning on line 48 in engine/src/main/java/org/terasology/engine/logic/location/LocationComponent.java

View check run for this annotation

Terasology Jenkins.io / SpotBugs

PA_PUBLIC_PRIMITIVE_ATTRIBUTE

LOW: Primitive field org.terasology.engine.logic.location.LocationComponent.isDirty is public and set from inside the class, which makes it too exposed. Consider making it private to limit external accessibility.
Raw output
no message found

public LocationComponent() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public class FirstPersonHeldItemMountPointComponent implements Component<FirstPe
public Quaternionf rotationQuaternion;
public float scale = 1f;

private boolean trackingDataReceived;
public boolean trackingDataReceived;


// The hand/tool models seem to have an origin other than the pivot point. This is a best-effort correction,
// in the form of a 4x4 homogeneous transformation matrix
private Matrix4f toolAdjustmentMatrix = new Matrix4f(
public Matrix4f toolAdjustmentMatrix = new Matrix4f(
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, (float) Math.cos(230. * TeraMath.DEG_TO_RAD), (float) Math.sin(230. * TeraMath.DEG_TO_RAD), 0.0f,
0.0f, (float) -Math.sin(230. * TeraMath.DEG_TO_RAD), (float) Math.cos(230. * TeraMath.DEG_TO_RAD), 0.0f,

Check warning on line 33 in engine/src/main/java/org/terasology/engine/logic/players/FirstPersonHeldItemMountPointComponent.java

View check run for this annotation

Terasology Jenkins.io / SpotBugs

PA_PUBLIC_PRIMITIVE_ATTRIBUTE

LOW: Primitive field org.terasology.engine.logic.players.FirstPersonHeldItemMountPointComponent.toolAdjustmentMatrix is public and set from inside the class, which makes it too exposed. Consider making it private to limit external accessibility.
Raw output
no message found
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class NetworkComponent implements Component<NetworkComponent> {

// Network identifier for the entity
@Replicate
private int networkId;
public int networkId;

@Override
public void copyFrom(NetworkComponent other) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public final class PingComponent implements Component<PingComponent> {

@Replicate
private Map<EntityRef, Long> pings = new HashMap<>();
public Map<EntityRef, Long> pings = new HashMap<>();

public void setValues(Map<EntityRef, Long> values) {
pings.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
public final class BlockComponent implements Component<BlockComponent> {
@Replicate

Check warning on line 14 in engine/src/main/java/org/terasology/engine/world/block/BlockComponent.java

View check run for this annotation

Terasology Jenkins.io / SpotBugs

PA_PUBLIC_PRIMITIVE_ATTRIBUTE

LOW: Primitive field org.terasology.engine.world.block.BlockComponent.position is public and set from inside the class, which makes it too exposed. Consider making it private to limit external accessibility.
Raw output
no message found
protected Vector3i position = new Vector3i();
public Vector3i position = new Vector3i();
@Replicate
protected Block block;
public Block block;

public BlockComponent() {
}
Expand Down

0 comments on commit d81cc97

Please sign in to comment.