Skip to content
Merged
3 changes: 0 additions & 3 deletions api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import org.jspecify.annotations.NullMarked;

/**
* Adventure: a serverside user interface library for Minecraft: Java Edition.
*
* <p>See the <a href="https://docs.papermc.io/adventure/">documentation</a>
* for usage and dependency information for this project and associated libraries.</p>
*/
@NullMarked
module net.kyori.adventure.api {
requires transitive net.kyori.adventure.key;
requires transitive org.jspecify;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* A receiver of Minecraft media.
*/
@NullMarked
package net.kyori.adventure.audience;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Boss bars.
*/
@NullMarked
package net.kyori.adventure.bossbar;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Common builder-related gizmos.
*/
@NullMarked
package net.kyori.adventure.builder;

import org.jspecify.annotations.NullMarked;
3 changes: 3 additions & 0 deletions api/src/main/java/net/kyori/adventure/chat/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Chat-related data.
*/
@NullMarked
package net.kyori.adventure.chat;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
* @sinceMinecraft 1.21.6
* @since 4.22
*/
@NullMarked
package net.kyori.adventure.dialog;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
*
* @sinceMinecraft 1.16
*/
@NullMarked
package net.kyori.adventure.identity;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@
* Internal things, not for public use.
*/
@org.jetbrains.annotations.ApiStatus.Internal
@NullMarked
package net.kyori.adventure.internal;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@
* Internal properties.
*/
@org.jetbrains.annotations.ApiStatus.Internal
@NullMarked
package net.kyori.adventure.internal.properties;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Content that works on inventory items.
*/
@NullMarked
package net.kyori.adventure.inventory;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@
*
* @see <a href="https://minecraft.wiki/w/NBT_format">minecraft.wiki/w/NBT_format</a>
*/
@NullMarked
package net.kyori.adventure.nbt.api;

import org.jspecify.annotations.NullMarked;
3 changes: 3 additions & 0 deletions api/src/main/java/net/kyori/adventure/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
* <p>See the <a href="https://docs.papermc.io/adventure/">documentation</a>
* for usage and dependency information for this project and associated libraries.</p>
*/
@NullMarked
package net.kyori.adventure;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* {@link net.kyori.adventure.util.TriState} based permission checking.
*/
@NullMarked
package net.kyori.adventure.permission;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Key/Value based pointers to information.
*/
@NullMarked
package net.kyori.adventure.pointer;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Data for controlling resource packs.
*/
@NullMarked
package net.kyori.adventure.resource;

import org.jspecify.annotations.NullMarked;
3 changes: 3 additions & 0 deletions api/src/main/java/net/kyori/adventure/sound/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Data for controlling sound playback.
*/
@NullMarked
package net.kyori.adventure.sound;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public sealed interface NBTComponent<C extends NBTComponent<C>> extends Componen
*
* @since 5.0.0
*/
boolean INTERPRET_DEFAULT = true;
boolean INTERPRET_DEFAULT = false;

/**
* Gets the NBT path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private CopyToClipboardImpl() {

static final class ShowDialogImpl extends AbstractAction implements Action.ShowDialog {
private ShowDialogImpl() {
super("show_dialog", true, Payload.Dialog.class);
super("show_dialog", false, Payload.Dialog.class);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Events that occur when players interact with components.
*/
@NullMarked
package net.kyori.adventure.text.event;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

import static java.util.Objects.requireNonNull;

record ComponentFlattenerImpl(InheritanceAwareMap<Component, Handler> flatteners, Function<Component, String> unknownHandler, int maxNestedDepth) implements ComponentFlattener {
record ComponentFlattenerImpl(InheritanceAwareMap<Component, Handler> flatteners, @Nullable Function<Component, String> unknownHandler, int maxNestedDepth) implements ComponentFlattener {
static final ComponentFlattener BASIC = new BuilderImpl()
.mapper(KeybindComponent.class, component -> component.keybind()) // IntelliJ is wrong here, this is fine
.mapper(KeybindComponent.class, component -> component.keybind())
.mapper(SelectorComponent.class, SelectorComponent::pattern)
.mapper(TextComponent.class, TextComponent::content)
.mapper(TranslatableComponent.class, component -> {
Expand All @@ -60,7 +60,7 @@ record ComponentFlattenerImpl(InheritanceAwareMap<Component, Handler> flatteners
final ObjectContents contents = component.contents();
if (contents instanceof final SpriteObjectContents spriteContents) {
final Key atlas = spriteContents.atlas();
return String.format("[%s:%s]", spriteContents.sprite().asMinimalString(), !atlas.equals(SpriteObjectContents.DEFAULT_ATLAS) ? "@" + atlas.asMinimalString() : "");
return String.format("[%s%s]", spriteContents.sprite().asMinimalString(), !atlas.equals(SpriteObjectContents.DEFAULT_ATLAS) ? "@" + atlas.asMinimalString() : "");
} else if (contents instanceof final PlayerHeadObjectContents playerHeadContents) {
return String.format("[%s head]", playerHeadContents.name() != null ? playerHeadContents.name() : "unknown player");
}
Expand Down Expand Up @@ -111,7 +111,7 @@ private void flatten0(final Component input, final FlattenerListener listener, f
}

final Component component = entry.component;
final @Nullable Handler flattener = this.flattener(component);
final Handler flattener = this.flattener(component);
final Style componentStyle = component.style();

// Push the style to both the listener and the stack (so we can pop later).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Flatteners to convert component trees into linear strings.
*/
@NullMarked
package net.kyori.adventure.text.flattener;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public sealed interface NamedTextColor extends TextColor permits NamedTextColorI
*
* @since 4.0.0
*/
Index<String, NamedTextColor> NAMES = Index.create(NamedTextColor::toString, NamedTextColorImpl.Values.VALUES);
Index<String, NamedTextColor> NAMES = Index.create(NamedTextColor::name, NamedTextColorImpl.Values.VALUES);

/**
* Gets the named color exactly matching the provided color.
Expand Down Expand Up @@ -175,4 +175,12 @@ static NamedTextColor nearestTo(final TextColor any) {
if (any instanceof final NamedTextColor namedTextColor) return namedTextColor;
return TextColor.nearestColorTo(NamedTextColorImpl.Values.VALUES, any);
}

/**
* The name of this named text color.
*
* @return the name
* @since 5.0.0
*/
String name();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Formats which may be applied to components.
*/
@NullMarked
package net.kyori.adventure.text.format;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Types related to {@link net.kyori.adventure.text.ObjectComponent}.
*/
@NullMarked
package net.kyori.adventure.text.object;

import org.jspecify.annotations.NullMarked;
3 changes: 3 additions & 0 deletions api/src/main/java/net/kyori/adventure/text/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Data for controlling components, their styles, and events.
*/
@NullMarked
package net.kyori.adventure.text;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ public abstract class TranslatableComponentRenderer<C> extends AbstractComponent
MERGES = Collections.unmodifiableSet(merges);
}

public TranslatableComponentRenderer() {
}

/**
* Creates a {@link TranslatableComponentRenderer} using the {@link Translator} to translate.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Component rendering.
*/
@NullMarked
package net.kyori.adventure.text.renderer;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Serialization and deserialization for components.
*/
@NullMarked
package net.kyori.adventure.text.serializer;

import org.jspecify.annotations.NullMarked;
3 changes: 3 additions & 0 deletions api/src/main/java/net/kyori/adventure/title/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Data for controlling titles.
*/
@NullMarked
package net.kyori.adventure.title;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Translations and translation registries.
*/
@NullMarked
package net.kyori.adventure.translation;

import org.jspecify.annotations.NullMarked;
3 changes: 0 additions & 3 deletions api/src/main/java/net/kyori/adventure/util/Listenable.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
public abstract class Listenable<L> {
private final List<L> listeners = new CopyOnWriteArrayList<>();

public Listenable() {
}

/**
* Process an action for each listener.
*
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/net/kyori/adventure/util/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
/**
* Miscellaneous utilities.
*/
@NullMarked
package net.kyori.adventure.util;

import org.jspecify.annotations.NullMarked;
13 changes: 6 additions & 7 deletions api/src/test/java/net/kyori/adventure/bossbar/BossBarTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.concurrent.atomic.AtomicReference;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;

import static com.google.common.truth.Truth.assertThat;
Expand All @@ -45,27 +44,27 @@ public class BossBarTest {
private final AtomicInteger flags = new AtomicInteger();
private final BossBar.Listener listener = new BossBar.Listener() {
@Override
public void bossBarNameChanged(final @NotNull BossBar bar, final @NotNull Component oldName, final @NotNull Component newName) {
public void bossBarNameChanged(final BossBar bar, final Component oldName, final Component newName) {
BossBarTest.this.name.incrementAndGet();
}

@Override
public void bossBarProgressChanged(final @NotNull BossBar bar, final float oldProgress, final float newProgress) {
public void bossBarProgressChanged(final BossBar bar, final float oldProgress, final float newProgress) {
BossBarTest.this.progress.incrementAndGet();
}

@Override
public void bossBarColorChanged(final @NotNull BossBar bar, final BossBar.@NotNull Color oldColor, final BossBar.@NotNull Color newColor) {
public void bossBarColorChanged(final BossBar bar, final BossBar.Color oldColor, final BossBar.Color newColor) {
BossBarTest.this.color.incrementAndGet();
}

@Override
public void bossBarOverlayChanged(final @NotNull BossBar bar, final BossBar.@NotNull Overlay oldOverlay, final BossBar.@NotNull Overlay newOverlay) {
public void bossBarOverlayChanged(final BossBar bar, final BossBar.Overlay oldOverlay, final BossBar.Overlay newOverlay) {
BossBarTest.this.overlay.incrementAndGet();
}

@Override
public void bossBarFlagsChanged(final @NotNull BossBar bar, final @NotNull Set<BossBar.Flag> oldFlags, final @NotNull Set<BossBar.Flag> newFlags) {
public void bossBarFlagsChanged(final BossBar bar, final Set<BossBar.Flag> oldFlags, final Set<BossBar.Flag> newFlags) {
BossBarTest.this.flags.incrementAndGet();
}
};
Expand Down Expand Up @@ -229,7 +228,7 @@ static class Changes implements BossBar.Listener {
final AtomicReference<Set<BossBar.Flag>> flagsRemoved = new AtomicReference<>(Collections.emptySet());

@Override
public void bossBarFlagsChanged(final @NotNull BossBar bar, final @NotNull Set<BossBar.Flag> flagsAdded, final @NotNull Set<BossBar.Flag> flagsRemoved) {
public void bossBarFlagsChanged(final BossBar bar, final Set<BossBar.Flag> flagsAdded, final Set<BossBar.Flag> flagsRemoved) {
this.flagsAdded.set(flagsAdded);
this.flagsRemoved.set(flagsRemoved);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void testRebuildWithNoChanges() {
@Test
void testRebuildEmptyChildren() {
final C c0 = this.buildOne();
final B b0 = c0.toBuilder();
final B b0 = (B) c0.toBuilder();
final C c1 = b0.build();
assertEquals(c0, c1);
assertThat(c0.children()).isEmpty();
Expand All @@ -276,7 +276,7 @@ void testRebuildEmptyChildren() {
void testRebuildChild() {
final Component child = Component.text("abc");
final C c0 = this.builder().append(child).build();
final B b0 = c0.toBuilder();
final B b0 = (B) c0.toBuilder();
final C c1 = b0.build();
assertEquals(c0, c1);
forEachTransformAndAssertIterable(Arrays.asList(c0, c1), Component::children, subject -> subject.containsExactly(child).inOrder());
Expand All @@ -288,8 +288,8 @@ void testRebuildChildren() {
final Component child2 = Component.text("def");
final C c0 = this.builder().append(child1, child2).build();
final C c1 = this.builder().append(Arrays.asList(child1, child2)).build();
final B b0 = c0.toBuilder();
final B b1 = c1.toBuilder();
final B b0 = (B) c0.toBuilder();
final B b1 = (B) c1.toBuilder();
final C c2 = b0.build();
final C c3 = b1.build();
assertAllEqualToEachOther(c0, c1, c2, c3);
Expand Down
Loading
Loading