From 05c01382a94ad254090f6df5ac00b0af78622114 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Wed, 22 Nov 2023 21:33:16 +0100 Subject: [PATCH 1/4] fix recipes stonecutting and smithing done --- .../org/spongepowered/api/item/recipe/RecipeRegistration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/spongepowered/api/item/recipe/RecipeRegistration.java b/src/main/java/org/spongepowered/api/item/recipe/RecipeRegistration.java index a33cf51d57..905b955a2d 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/RecipeRegistration.java +++ b/src/main/java/org/spongepowered/api/item/recipe/RecipeRegistration.java @@ -32,5 +32,5 @@ *

All registrations through the API will generate into the Vanilla data pack system

*/ public interface RecipeRegistration extends DataPackEntry { - + Recipe recipe(); } From 92b85c19187a76b62e55a3004190aff08f276b8a Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Fri, 24 Nov 2023 23:22:20 +0100 Subject: [PATCH 2/4] fix advancement trigger registry triggers are now in registry --- .../java/org/spongepowered/api/registry/RegistryTypes.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index cb94503c5a..d4d773c1af 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -266,6 +266,8 @@ public final class RegistryTypes { public static final DefaultedRegistryType STRUCTURE_TYPE = RegistryTypes.minecraftKeyInGame("worldgen/structure_type"); + public static final DefaultedRegistryType> TRIGGER = RegistryTypes.minecraftKeyInGame("trigger_type"); + public static final DefaultedRegistryType VILLAGER_TYPE = RegistryTypes.minecraftKeyInGame("villager_type"); public static final DefaultedRegistryType WORLD_TYPE = RegistryTypes.minecraftKeyInServer("dimension_type"); @@ -490,8 +492,6 @@ public final class RegistryTypes { public static final DefaultedRegistryType TRANSACTION_TYPE = RegistryTypes.spongeKeyInGame("transaction_type"); - public static final DefaultedRegistryType> TRIGGER = RegistryTypes.spongeKeyInGame("trigger"); - public static final DefaultedRegistryType TROPICAL_FISH_SHAPE = RegistryTypes.spongeKeyInGame("tropical_fish_shape"); public static final DefaultedRegistryType TILT = RegistryTypes.spongeKeyInGame("tilt"); From c91c23890ebf8d93391452006c482d57f1f0580a Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sat, 25 Nov 2023 02:53:20 +0100 Subject: [PATCH 3/4] [breaking] Scoreboard API for 1.20.4 --- .../spongepowered/api/scoreboard/Score.java | 34 +++++- .../api/scoreboard/ScoreFormat.java | 76 +++++++++++++ .../api/scoreboard/Scoreboard.java | 4 +- .../api/scoreboard/objective/Objective.java | 106 ++++++++++++++++-- 4 files changed, 205 insertions(+), 15 deletions(-) create mode 100644 src/main/java/org/spongepowered/api/scoreboard/ScoreFormat.java diff --git a/src/main/java/org/spongepowered/api/scoreboard/Score.java b/src/main/java/org/spongepowered/api/scoreboard/Score.java index b95d2c8569..64d87f09c0 100644 --- a/src/main/java/org/spongepowered/api/scoreboard/Score.java +++ b/src/main/java/org/spongepowered/api/scoreboard/Score.java @@ -25,8 +25,10 @@ package org.spongepowered.api.scoreboard; import net.kyori.adventure.text.Component; +import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.api.scoreboard.objective.Objective; +import java.util.Optional; import java.util.Set; /** @@ -39,7 +41,7 @@ public interface Score { * * @return The name of this score */ - Component name(); + String name(); /** * Gets the current score value. @@ -69,6 +71,36 @@ public interface Score { */ void setLocked(boolean locked); + // TODO javadocs + + /** + * Sets this score display + * + * @param display the display + */ + void setDisplay(@Nullable Component display); + + /** + * Returns this score display + * + * @return the display + */ + Optional display(); + + /** + * Sets the score number format + * + * @param format the number format + */ + void setNumberFormat(@Nullable ScoreFormat format); + + /** + * Returns the score number format + * + * @return the number format + */ + Optional numberFormat(); + /** * Returns a {@link Set} of parent {@link Objective}s this {@link Score} is * registered to. diff --git a/src/main/java/org/spongepowered/api/scoreboard/ScoreFormat.java b/src/main/java/org/spongepowered/api/scoreboard/ScoreFormat.java new file mode 100644 index 0000000000..329324a22c --- /dev/null +++ b/src/main/java/org/spongepowered/api/scoreboard/ScoreFormat.java @@ -0,0 +1,76 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.scoreboard; + +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.Style; +import org.spongepowered.api.Sponge; + +/** + * A Score Number Format + */ +public interface ScoreFormat { + + static ScoreFormat blank() { + return Sponge.game().factoryProvider().provide(Factory.class).blank(); + } + + static ScoreFormat fixed(Component component) { + return Sponge.game().factoryProvider().provide(Factory.class).fixed(component); + } + + static ScoreFormat styled(Style style) { + return Sponge.game().factoryProvider().provide(Factory.class).styled(style); + } + + interface Factory { + + /** + * Blank score formatting. + * + * @return the format + */ + ScoreFormat blank(); + + /** + * Fixed score formatting + * + * @param component the fixed component + * + * @return the format + */ + ScoreFormat fixed(Component component); + + /** + * Styled number formatting + * + * @param style the style + * + * @return the format + */ + ScoreFormat styled(Style style); + } + +} diff --git a/src/main/java/org/spongepowered/api/scoreboard/Scoreboard.java b/src/main/java/org/spongepowered/api/scoreboard/Scoreboard.java index e8d8d7b808..a43fc9a4fc 100644 --- a/src/main/java/org/spongepowered/api/scoreboard/Scoreboard.java +++ b/src/main/java/org/spongepowered/api/scoreboard/Scoreboard.java @@ -193,7 +193,7 @@ default Set objectivesByCriterion(Supplier crite * @param name The name whose scores are being retrieved * @return A set of all scores for the name */ - Set scores(Component name); + Set scores(String name); /** * Removes all scores with the specified name on this scoreboard, @@ -201,7 +201,7 @@ default Set objectivesByCriterion(Supplier crite * * @param name The name to remove all scores for */ - void removeScores(Component name); + void removeScores(String name); /** * Gets a {@link Team} by name on this scoreboard. diff --git a/src/main/java/org/spongepowered/api/scoreboard/objective/Objective.java b/src/main/java/org/spongepowered/api/scoreboard/objective/Objective.java index 00cf258dc3..6c8237ab73 100644 --- a/src/main/java/org/spongepowered/api/scoreboard/objective/Objective.java +++ b/src/main/java/org/spongepowered/api/scoreboard/objective/Objective.java @@ -26,6 +26,8 @@ import net.kyori.adventure.text.Component; import org.spongepowered.api.Sponge; +import org.spongepowered.api.entity.Entity; +import org.spongepowered.api.profile.GameProfile; import org.spongepowered.api.scoreboard.Score; import org.spongepowered.api.scoreboard.Scoreboard; import org.spongepowered.api.scoreboard.criteria.Criterion; @@ -103,7 +105,7 @@ static Builder builder() { * * @return The set of {@link Score}s for this objective */ - Map scores(); + Map scores(); /** * Returns whether this objective has a {@link Score} with the given name. @@ -111,7 +113,25 @@ static Builder builder() { * @param name The name of the {@link Score} to check for. * @return Whether this objective has a {@link Score} with the given name. */ - boolean hasScore(Component name); + boolean hasScore(String name); + + + /** + * Returns whether this objective has a {@link Score} with the given entity. + * + * @param entity The entity of the {@link Score} to check for. + * @return Whether this objective has a {@link Score} with the given entity. + */ + boolean hasScore(Entity entity); + + + /** + * Returns whether this objective has a {@link Score} with the given profile. + * + * @param profile The profile of the {@link Score} to check for. + * @return Whether this objective has a {@link Score} with the given profile. + */ + boolean hasScore(GameProfile profile); /** * Adds the specified {@link Score} to this objective. @@ -125,9 +145,9 @@ static Builder builder() { * Gets an entry's {@link Score} for this objective, if it exists. * * @param name The name of the {@link Score} to get. - * @return The {@link Score} for te specified {@link Component}, if it exists. + * @return The {@link Score} for the specified name, if it exists. */ - default Optional findScore(final Component name) { + default Optional findScore(final String name) { if (!this.hasScore(name)) { return Optional.empty(); } @@ -140,25 +160,87 @@ default Optional findScore(final Component name) { *

If the {@link Score} does not exist, it will be created.

* * @param name The name of the {@link Score} to get - * @return The {@link Score} for the specified {@link Component} + * @return The {@link Score} for the specified name */ - Score findOrCreateScore(Component name); + Score findOrCreateScore(String name); /** - * Removes the specified {@link Score} from this objective, if present. + * Removes the {@link Score} with the specified name from this objective, if present. * - * @param score The {@link Score} to remove + * @param name The name of the {@link Score} to remove. * @return Whether the score existed on this objective */ - boolean removeScore(Score score); + boolean removeScore(String name); /** - * Removes the {@link Score} with the specified name from this objective, if present. + * Gets an entry's {@link Score} for this objective, if it exists. * - * @param name The name of the {@link Score} to remove. + * @param entity The entity of the {@link Score} to get. + * @return The {@link Score} for the specified entity, if it exists. + */ + default Optional findScore(final Entity entity) { + if (!this.hasScore(entity)) { + return Optional.empty(); + } + return Optional.of(this.findOrCreateScore(entity)); + } + + /** + * Gets an entry's {@link Score} for this objective. + * + *

If the {@link Score} does not exist, it will be created.

+ * + * @param entity The name of the {@link Score} to get + * @return The {@link Score} for the specified entity + */ + Score findOrCreateScore(Entity entity); + + /** + * Removes the {@link Score} with the specified entity from this objective, if present. + * + * @param entity The entity of the {@link Score} to remove. + * @return Whether the score existed on this objective + */ + boolean removeScore(Entity entity); + + /** + * Gets an entry's {@link Score} for this objective, if it exists. + * + * @param profile The profile of the {@link Score} to get. + * @return The {@link Score} for the specified profile, if it exists. + */ + default Optional findScore(final GameProfile profile) { + if (!this.hasScore(profile)) { + return Optional.empty(); + } + return Optional.of(this.findOrCreateScore(profile)); + } + + /** + * Gets an entry's {@link Score} for this objective. + * + *

If the {@link Score} does not exist, it will be created.

+ * + * @param profile The profile of the {@link Score} to get + * @return The {@link Score} for the specified profile + */ + Score findOrCreateScore(GameProfile profile); + + /** + * Removes the {@link Score} with the specified profile from this objective, if present. + * + * @param profile The profile of the {@link Score} to remove. * @return Whether the score existed on this objective */ - boolean removeScore(Component name); + boolean removeScore(GameProfile profile); + + /** + * Removes the specified {@link Score} from this objective, if present. + * + * @param score The {@link Score} to remove + * @return Whether the score existed on this objective + */ + boolean removeScore(Score score); /** * Returns a {@link Set} of parent {@link Scoreboard}s this From ef584a582f84354eb2d565dd28539b222a9e6185 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Tue, 5 Dec 2023 21:51:39 +0100 Subject: [PATCH 4/4] BuiltIn Registries --- .../api/event/lifecycle/RegisterRegistryValueEvent.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/spongepowered/api/event/lifecycle/RegisterRegistryValueEvent.java b/src/main/java/org/spongepowered/api/event/lifecycle/RegisterRegistryValueEvent.java index b5ad65060e..d812948098 100644 --- a/src/main/java/org/spongepowered/api/event/lifecycle/RegisterRegistryValueEvent.java +++ b/src/main/java/org/spongepowered/api/event/lifecycle/RegisterRegistryValueEvent.java @@ -27,6 +27,7 @@ import org.spongepowered.api.Engine; import org.spongepowered.api.ResourceKey; import org.spongepowered.api.event.GenericEvent; +import org.spongepowered.api.registry.DefaultedRegistryValue; import org.spongepowered.api.registry.RegistryType; public interface RegisterRegistryValueEvent extends LifecycleEvent { @@ -38,6 +39,11 @@ interface RegistryStep { RegistryStep register(ResourceKey key, T value); } + interface BuiltIn extends LifecycleEvent { + + RegistryStep registry(RegistryType registryType); + } + interface GameScoped extends RegisterRegistryValueEvent { }