Skip to content

Commit 177298d

Browse files
committed
do some finalising in Frequency
1 parent b53e5fa commit 177298d

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/main/java/mekanism/common/lib/frequency/Frequency.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ protected static <BUF extends ByteBuf, FREQ extends Frequency> StreamCodec<BUF,
4545
private String name;
4646

4747
@Nullable
48-
private UUID ownerUUID;
49-
private String ownerName;
48+
private final UUID ownerUUID;
49+
private final String ownerName;
5050

5151
private boolean valid = true;
5252
private SecurityMode securityMode;
5353

5454
private final FrequencyType<?> frequencyType;
5555

5656
/**
57-
* @param owner Should only be null if we have incomplete data that we are loading
57+
* Owner username is looked up so that we can sync it (and more importantly have it
58+
* set in single player when network connections don't serialize and deserialize)
59+
*
60+
* @param owner Should only be null if we have incomplete data that we are loading.
5861
*/
5962
protected Frequency(FrequencyType<?> frequencyType, String name, @Nullable UUID owner, SecurityMode securityMode) {
60-
this.frequencyType = frequencyType;
61-
this.name = name;
62-
this.securityMode = securityMode;
63-
setOwnerUUID(owner);
63+
this(frequencyType, name, owner, MekanismUtils.getLastKnownUsername(owner), securityMode);
6464
}
6565

6666
protected Frequency(FrequencyType<?> frequencyType, String name, @Nullable UUID owner, String ownerName, SecurityMode securityMode) {
@@ -149,12 +149,6 @@ public String getOwnerName() {
149149
return ownerName;
150150
}
151151

152-
private void setOwnerUUID(@Nullable UUID uuid) {
153-
ownerUUID = uuid;
154-
//Look up the username of the owner so that we can sync it (and more importantly have it set in single player when network connections don't serialize and deserialize)
155-
ownerName = MekanismUtils.getLastKnownUsername(ownerUUID);
156-
}
157-
158152
/**
159153
* This is the hashCode that is used for determining if a frequency is dirty. Override this if your frequency type has more things that may mean it needs to be
160154
* re-synced.
@@ -178,6 +172,9 @@ public int hashCode() {
178172

179173
@Override
180174
public boolean equals(Object obj) {
175+
if (this == obj) {
176+
return true;
177+
}
181178
if (obj instanceof Frequency other) {
182179
if (frequencyType == FrequencyType.SECURITY || securityMode == other.securityMode) {
183180
return ownerUUID != null && name.equals(other.name) && ownerUUID.equals(other.ownerUUID);

0 commit comments

Comments
 (0)