Skip to content

Commit 5bd9f8f

Browse files
committed
Add User#hasPlayedBefore
1 parent 2fa1dfb commit 5bd9f8f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/java/org/spongepowered/api/entity/living/player/User.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package org.spongepowered.api.entity.living.player;
2626

2727
import org.spongepowered.api.ResourceKey;
28+
import org.spongepowered.api.Server;
2829
import org.spongepowered.api.block.entity.EnderChest;
2930
import org.spongepowered.api.data.DataHolder;
3031
import org.spongepowered.api.data.Keys;
@@ -203,4 +204,13 @@ default Value.Mutable<VanishState> vanishState() {
203204
return this.requireValue(Keys.VANISH_STATE).asMutable();
204205
}
205206

207+
/**
208+
* Gets if the {@link User} has played on the {@link Server} before. Added
209+
* as a utility.
210+
*
211+
* @return True if played before, false otherwise
212+
*/
213+
default boolean hasPlayedBefore() {
214+
return !this.firstJoined().map(Value::get).equals(this.lastJoined().map(Value::get));
215+
}
206216
}

src/main/java/org/spongepowered/api/entity/living/player/server/ServerPlayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ default Value.Mutable<Boolean> hasViewedCredits() {
299299
* @return True if played before, false otherwise
300300
*/
301301
default boolean hasPlayedBefore() {
302-
return !this.firstJoined().equals(this.lastPlayed());
302+
return !this.firstJoined().map(Value::get).equals(this.lastJoined().map(Value::get));
303303
}
304304

305305
/**

0 commit comments

Comments
 (0)