Skip to content

Commit 2781035

Browse files
committed
Merge remote-tracking branch 'origin/api-13' into api-14
2 parents 5586e8b + 576aaf1 commit 2781035

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.data;
26+
27+
import org.spongepowered.api.data.value.CollectionValue;
28+
29+
import java.util.Collection;
30+
31+
public interface CollectionDataProvider<E, V extends Collection<E>, C extends CollectionValue<E, V>> extends DataProvider<C, V> {
32+
33+
DataTransactionResult offerSingle(DataHolder.Mutable dataHolder, E element);
34+
35+
DataTransactionResult removeSingle(DataHolder.Mutable dataHolder, E element);
36+
}

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)