Skip to content

Commit f78b07f

Browse files
committed
chore: merge api-14 for additions
Signed-off-by: Gabriel Harris-Rouquette <[email protected]>
2 parents 700c16b + c4ed14f commit f78b07f

File tree

5 files changed

+86
-5
lines changed

5 files changed

+86
-5
lines changed

src/main/java/org/spongepowered/api/adventure/SpongeComponents.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@
2626

2727
import net.kyori.adventure.audience.Audience;
2828
import net.kyori.adventure.text.Component;
29+
import net.kyori.adventure.text.ComponentLike;
30+
import net.kyori.adventure.text.VirtualComponent;
2931
import net.kyori.adventure.text.event.ClickEvent;
3032
import net.kyori.adventure.text.flattener.ComponentFlattener;
3133
import org.spongepowered.api.Sponge;
3234
import org.spongepowered.api.command.CommandCause;
3335
import org.spongepowered.api.registry.DefaultedRegistryReference;
3436

3537
import java.util.function.Consumer;
38+
import java.util.function.Function;
3639

3740
/**
3841
* Additional SpongeAPI-specific methods for working with {@link Component}s and related.
@@ -111,6 +114,17 @@ public static ComponentFlattener flattener() {
111114
return SpongeComponents.factory().flattener();
112115
}
113116

117+
/**
118+
* Creates a new {@link VirtualComponent} that will be used to
119+
* render each {@link Audience} their own version of
120+
* the received message.
121+
*
122+
* @return The virtual component
123+
*/
124+
public static VirtualComponent receiverVirtualComponent(final Function<Audience, ComponentLike> apply) {
125+
return SpongeComponents.factory().receiverVirtualComponent(apply);
126+
}
127+
114128
private static Factory factory() {
115129
return Sponge.game().factoryProvider().provide(Factory.class);
116130
}
@@ -137,5 +151,6 @@ Component render(
137151

138152
ComponentFlattener flattener();
139153

154+
VirtualComponent receiverVirtualComponent(Function<Audience, ComponentLike> apply);
140155
}
141156
}
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/data/Keys.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,12 +861,32 @@ public final class Keys {
861861
public static final Key<MapValue<EntityType<?>, Double>> CUSTOM_ATTACK_DAMAGE = Keys.mapKey(ResourceKey.sponge("custom_attack_damage"), new TypeToken<EntityType<?>>() {}, TypeToken.get(Double.class));
862862

863863
/**
864-
* The resource pack model index of an {@link ItemStack}.
864+
* List of floats used by items model definitions.
865865
*
866-
* <p>Resource packs can use the same index in their files to replace the
867-
* item model of an ItemStack.</p>
866+
* @see <a href="https://minecraft.wiki/w/Items_model_definition">Items model definition</a>
868867
*/
869-
public static final Key<Value<Integer>> CUSTOM_MODEL_DATA = Keys.key(ResourceKey.sponge("custom_model_data"), Integer.class);
868+
public static final Key<ListValue<Float>> CUSTOM_MODEL_DATA_FLOATS = Keys.listKey(ResourceKey.sponge("custom_model_data_floats"), Float.class);
869+
870+
/**
871+
* List of booleans used by items model definitions.
872+
*
873+
* @see <a href="https://minecraft.wiki/w/Items_model_definition">Items model definition</a>
874+
*/
875+
public static final Key<ListValue<Boolean>> CUSTOM_MODEL_DATA_FLAGS = Keys.listKey(ResourceKey.sponge("custom_model_data_flags"), Boolean.class);
876+
877+
/**
878+
* List of strings used by items model definitions.
879+
*
880+
* @see <a href="https://minecraft.wiki/w/Items_model_definition">Items model definition</a>
881+
*/
882+
public static final Key<ListValue<String>> CUSTOM_MODEL_DATA_STRINGS = Keys.listKey(ResourceKey.sponge("custom_model_data_strings"), String.class);
883+
884+
/**
885+
* List of colors used by items model definitions.
886+
*
887+
* @see <a href="https://minecraft.wiki/w/Items_model_definition">Items model definition</a>
888+
*/
889+
public static final Key<ListValue<Color>> CUSTOM_MODEL_DATA_COLORS = Keys.listKey(ResourceKey.sponge("custom_model_data_colors"), Color.class);
870890

871891
/**
872892
* The custom name of an {@link Entity}, {@link ItemStack} or {@link BlockEntity}.

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)