Skip to content

Commit

Permalink
fix for MC Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Faithcaio committed Sep 29, 2023
1 parent a004b9f commit e84c8c6
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 83 deletions.
22 changes: 4 additions & 18 deletions src/main/java/org/spongepowered/api/advancement/Advancement.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.ResourceKeyed;
import org.spongepowered.api.advancement.criteria.AdvancementCriterion;
import org.spongepowered.api.data.persistence.DataSerializable;
import org.spongepowered.api.util.RespawnLocation;

import java.util.Collection;
import java.util.List;
Expand All @@ -37,23 +39,7 @@
/**
* An advancement.
*/
public interface Advancement extends ComponentLike, ResourceKeyed, DataSerializable {

/**
* Gets the {@link AdvancementTree} this advancement is located in,
* will only be present if the root advancement was used to create
* a {@link AdvancementTree}.
*
* @return The advancement tree
*/
Optional<AdvancementTree> tree();

/**
* Gets all the children {@link Advancement}s.
*
* @return The children advancements
*/
Collection<Advancement> children();
public interface Advancement extends ComponentLike, DataSerializable {

/**
* Gets all the {@link AdvancementCriterion} that should be achieved
Expand All @@ -72,7 +58,7 @@ public interface Advancement extends ComponentLike, ResourceKeyed, DataSerializa
*
* @return The parent advancement, if present
*/
Optional<Advancement> parent();
Optional<ResourceKey> parent();

/**
* Gets the {@link DisplayInfo} of this advancement, if present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,30 @@
*/
package org.spongepowered.api.advancement;

import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.ResourceKeyed;
import org.spongepowered.api.entity.living.player.Player;

import java.util.Collection;
import java.util.Optional;

/**
* Represents the tree (tab) layout of a {@link AdvancementTree}.
* A node in a {@link AdvancementTree}
* visible to a {@link Player} once the root {@link Advancement} gets achieved.
*/
public interface TreeLayout {

/**
* Gets the {@link AdvancementTree} this layout is assigned to.
*
* @return The tree
*/
AdvancementTree tree();
public interface AdvancementNode extends ResourceKeyed {

/**
* Gets all the {@link TreeLayoutElement}s that are
* present in this layout.
* Gets the root {@link Advancement}.
*
* @return The tree layout elements
* @return The root advancement
*/
Collection<TreeLayoutElement> elements();
Advancement rootAdvancement();

/**
* Gets the {@link TreeLayoutElement} for the specified {@link Advancement},
* {@link Optional#empty()} will be returned if the advancement is not present
* in the tree or if there is no {@link DisplayInfo} present.
* Gets all the children {@link Advancement}s.
*
* @param advancement The advancement
* @return The tree layout element
* @return The children advancements
*/
Optional<TreeLayoutElement> element(Advancement advancement);
Collection<AdvancementNode> children();

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.spongepowered.api.datapack.DataPackEntry;
import org.spongepowered.api.util.ResourceKeyedBuilder;

import java.util.Optional;

/**
* A template for an {@link Advancement}.
*/
Expand All @@ -52,19 +54,36 @@ static Builder builder() {
*/
Advancement advancement();

/**
* Gets the {@link AdvancementTree} of this advancement
* will only be present if it is a root advancement.
*
* @return The advancement tree
*/
Optional<AdvancementTree> tree();

/**
* A builder to create {@link Advancement}s.
*/
interface Builder extends ResourceKeyedBuilder<AdvancementTemplate, Builder> {

/**
* Sets the parent {@link Advancement}.
* Sets the parent {@link Advancement} template.
* <p>For the root advancement use {@link #root}</p>
*
* @param parent The parent advancement
* @return This builder, for chaining
*/
Builder parent(AdvancementTemplate parent);

/**
* Sets the parent {@link Advancement} key.
* <p>For the root advancement use {@link #root}</p>
*
* @param parent The parent advancement
* @return This builder, for chaining
*/
Builder parent(Advancement parent);
Builder parent(ResourceKey parent);

/**
* Sets this advancement as root.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,49 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.entity.living.player.Player;

import java.util.Collection;
import java.util.Optional;

/**
* Represents a {@link Advancement} tree or tab menu. The tree will become
* visible to a {@link Player} once the root {@link Advancement} gets achieved.
* visible to a {@link Player} once the {@link #rootAdvancement() root advancement} gets achieved.
*/
public interface AdvancementTree {
public interface AdvancementTree extends AdvancementNode {

/**
* Gets the root {@link Advancement}.
* Gets the background texture of this tree.
*
* @return The root advancement
* @return The background texture
*/
Advancement rootAdvancement();
Optional<ResourceKey> backgroundPath();

/**
* Gets the background texture of this tree.
* Gets all the {@link TreeLayoutElement}s that are
* present in this layout.
*
* @return The background texture
* @return The tree layout elements
*/
Optional<ResourceKey> backgroundPath();
Collection<TreeLayoutElement> layoutElements();

/**
* Gets the {@link TreeLayoutElement} for the specified {@link Advancement},
* {@link Optional#empty()} will be returned if the advancement is not present
* in the tree or if there is no {@link DisplayInfo} present.
*
* @param advancement The advancement
* @return The tree layout element
*/
Optional<TreeLayoutElement> layoutElement(AdvancementTemplate advancement);


/**
* Gets the {@link TreeLayoutElement} for the specified {@link Advancement},
* {@link Optional#empty()} will be returned if the advancement is not present
* in the tree or if there is no {@link DisplayInfo} present.
*
* @param advancementKey The advancement key
* @return The tree layout element
*/
Optional<TreeLayoutElement> layoutElement(ResourceKey advancementKey);

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.spongepowered.math.vector.Vector2d;

/**
* Represents a element in the {@link TreeLayout}.
* Represents a layout element in the {@link AdvancementTree}.
*/
public interface TreeLayoutElement {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.advancement.Advancement;
import org.spongepowered.api.advancement.criteria.trigger.FilteredTrigger;
import org.spongepowered.api.advancement.criteria.trigger.FilteredTriggerConfiguration;
import org.spongepowered.api.advancement.criteria.trigger.Trigger;
import org.spongepowered.api.util.CopyableBuilder;
import org.spongepowered.api.util.Nameable;

Expand Down Expand Up @@ -127,6 +129,13 @@ static Builder builder() {
*/
Optional<FilteredTrigger<?>> trigger();

/**
* Gets the {@link Trigger} of this {@link AdvancementCriterion}, if present.
*
* @return The trigger
*/
Optional<Trigger<?>> type();

/**
* A builder to create {@link AdvancementCriterion}s.
*/
Expand All @@ -142,10 +151,11 @@ interface BaseBuilder<T extends AdvancementCriterion, B extends BaseBuilder<T, B
/**
* Sets the {@link FilteredTrigger}.
*
* @param type The trigger type
* @param trigger The filtered trigger
* @return This builder, for chaining
*/
B trigger(FilteredTrigger<?> trigger);
<C extends FilteredTriggerConfiguration> B trigger(Trigger<C> type, FilteredTrigger<C> trigger);

/**
* Sets the name of the {@link AdvancementCriterion}. Names can be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ static Builder<?> builder() {
return Sponge.game().builderProvider().provide(Builder.class);
}

/**
* Gets the {@link Trigger}.
*
* @return The type
*/
Trigger<C> type();

/**
* Gets the {@link FilteredTriggerConfiguration} of this trigger.
*
Expand All @@ -66,22 +59,13 @@ static Builder<?> builder() {
interface Builder<C extends FilteredTriggerConfiguration> extends org.spongepowered.api.util.Builder<FilteredTrigger<C>, Builder<C>>,
CopyableBuilder<FilteredTrigger<C>, Builder<C>> {

/**
* Sets the {@link Trigger}.
*
* @param type The trigger type
* @param <T> The configuration type
* @return This builder, for chaining
*/
<T extends FilteredTriggerConfiguration> Builder<T> type(Trigger<T> type);

/**
* Sets the {@link FilteredTriggerConfiguration}.
*
* @param config The configuration
* @return This builder, for chaining
*/
Builder<C> config(C config);
<T extends FilteredTriggerConfiguration> Builder<T> config(T config);

/**
* Builds the {@link FilteredTrigger}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.spongepowered.api.event.advancement.CriterionEvent;
import org.spongepowered.api.registry.DefaultedRegistryValue;
import org.spongepowered.api.scoreboard.criteria.Criterion;
import org.spongepowered.api.util.Builder;
import org.spongepowered.api.util.CopyableBuilder;
import org.spongepowered.api.util.ResourceKeyedBuilder;
import org.spongepowered.api.util.annotation.CatalogedBy;
Expand All @@ -55,7 +56,7 @@
*/
@SuppressWarnings("unchecked")
@CatalogedBy(Triggers.class)
public interface Trigger<C extends FilteredTriggerConfiguration> extends DefaultedRegistryValue, ResourceKeyed {
public interface Trigger<C extends FilteredTriggerConfiguration> extends DefaultedRegistryValue {

/**
* Creates a new {@link Builder} which can be used to create
Expand Down Expand Up @@ -103,7 +104,7 @@ static Builder<?> builder() {
*
* @param <C> The configuration type
*/
interface Builder<C extends FilteredTriggerConfiguration> extends ResourceKeyedBuilder<Trigger<C>, Builder<C>>,
interface Builder<C extends FilteredTriggerConfiguration> extends org.spongepowered.api.util.Builder<Trigger<C>, Builder<C>>,
CopyableBuilder<Trigger<C>, Builder<C>> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import org.spongepowered.api.Sponge;
import org.spongepowered.api.advancement.Advancement;
import org.spongepowered.api.advancement.AdvancementTemplate;
import org.spongepowered.api.advancement.criteria.AdvancementCriterion;
import org.spongepowered.api.command.CommandCause;
import org.spongepowered.api.data.persistence.DataView;
Expand Down Expand Up @@ -204,7 +205,7 @@ interface Builder extends org.spongepowered.api.util.Builder<Selector, Builder>
* @param advancement The advancement that players must have.
* @return This builder, for chaining
*/
Builder addAdvancement(Advancement advancement);
Builder addAdvancement(AdvancementTemplate advancement);

/**
* Adds an {@link Advancement} constraint to this selector, requiring
Expand All @@ -213,7 +214,7 @@ interface Builder extends org.spongepowered.api.util.Builder<Selector, Builder>
* @param advancement The advancement that players must not have.
* @return This builder, for chaining
*/
Builder addNotAdvancement(Advancement advancement);
Builder addNotAdvancement(AdvancementTemplate advancement);

/**
* Adds an {@link AdvancementCriterion} constraint to this selector,
Expand All @@ -224,7 +225,7 @@ interface Builder extends org.spongepowered.api.util.Builder<Selector, Builder>
* @param criterion The criterion the player must have
* @return This builder, for chaining
*/
Builder addAdvancementCriterion(Advancement advancement, AdvancementCriterion criterion);
Builder addAdvancementCriterion(AdvancementTemplate advancement, AdvancementCriterion criterion);

/**
* Adds an {@link AdvancementCriterion} constraint to this selector,
Expand All @@ -235,7 +236,7 @@ interface Builder extends org.spongepowered.api.util.Builder<Selector, Builder>
* @param criterion The criterion the player must not have
* @return This builder, for chaining
*/
Builder addNotAdvancementCriterion(Advancement advancement, AdvancementCriterion criterion);
Builder addNotAdvancementCriterion(AdvancementTemplate advancement, AdvancementCriterion criterion);

/**
* Adds an {@link DataView} as an NBT style constraint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.spongepowered.api.Server;
import org.spongepowered.api.advancement.Advancement;
import org.spongepowered.api.advancement.AdvancementProgress;
import org.spongepowered.api.advancement.AdvancementTemplate;
import org.spongepowered.api.advancement.AdvancementTree;
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.type.SkinPart;
Expand Down Expand Up @@ -280,7 +281,7 @@ default SetValue.Mutable<SkinPart> displayedSkinParts() {
* @param advancement The advancement
* @return The advancement progress
*/
AdvancementProgress progress(Advancement advancement);
AdvancementProgress progress(AdvancementTemplate advancement);

/**
* Gets all the {@link AdvancementTree}s that this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
*/
package org.spongepowered.api.event.advancement;

import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.advancement.Advancement;
import org.spongepowered.api.advancement.AdvancementTemplate;
import org.spongepowered.api.advancement.criteria.AdvancementCriterion;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
import org.spongepowered.api.event.Event;
Expand Down Expand Up @@ -52,6 +54,13 @@ public interface AdvancementEvent extends Event {
*/
Advancement advancement();

/**
* Gets the {@link Advancement} that is being targeted.
*
* @return The advancement
*/
ResourceKey advancementKey();

/**
* Is called when a {@link Advancement} is granted/unlocked.
*
Expand Down
Loading

0 comments on commit e84c8c6

Please sign in to comment.