mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 09:27:58 +01:00
Cleanup annotations and imports
This commit is contained in:
parent
2c2f1b6cee
commit
316ecbbf5a
@ -53,7 +53,6 @@ import net.minestom.server.utils.validate.Check;
|
||||
import net.minestom.server.world.Difficulty;
|
||||
import net.minestom.server.world.DimensionTypeManager;
|
||||
import net.minestom.server.world.biomes.BiomeManager;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
@ -833,7 +832,7 @@ public final class MinecraftServer implements ForwardingAudience.Single {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Audience audience() {
|
||||
public @NotNull Audience audience() {
|
||||
return getConnectionManager();
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package net.minestom.server.adventure;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.minestom.server.sound.Sound;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
@ -2,21 +2,18 @@ package net.minestom.server.adventure;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.bossbar.BossBar.*;
|
||||
import net.kyori.adventure.bossbar.BossBar.Color;
|
||||
import net.kyori.adventure.bossbar.BossBar.Flag;
|
||||
import net.kyori.adventure.bossbar.BossBar.Overlay;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.GlobalEventHandler;
|
||||
import net.minestom.server.event.player.PlayerDisconnectEvent;
|
||||
import net.minestom.server.network.packet.server.play.BossBarPacket;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Handler;
|
||||
|
||||
import static net.minestom.server.network.packet.server.play.BossBarPacket.Action.*;
|
||||
|
||||
@ -69,31 +66,31 @@ public class BossBarManager implements BossBar.Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bossBarNameChanged(@NonNull BossBar bar, @NonNull Component oldName, @NonNull Component newName) {
|
||||
public void bossBarNameChanged(@NotNull BossBar bar, @NotNull Component oldName, @NotNull Component newName) {
|
||||
Holder holder = this.bars.get(bar);
|
||||
this.updatePlayers(holder.createTitleUpdate(newName), holder.players);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bossBarProgressChanged(@NonNull BossBar bar, float oldProgress, float newProgress) {
|
||||
public void bossBarProgressChanged(@NotNull BossBar bar, float oldProgress, float newProgress) {
|
||||
Holder holder = this.bars.get(bar);
|
||||
this.updatePlayers(holder.createPercentUpdate(newProgress), holder.players);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bossBarColorChanged(@NonNull BossBar bar, @NonNull Color oldColor, @NonNull Color newColor) {
|
||||
public void bossBarColorChanged(@NotNull BossBar bar, @NotNull Color oldColor, @NotNull Color newColor) {
|
||||
Holder holder = this.bars.get(bar);
|
||||
this.updatePlayers(holder.createColorUpdate(newColor), holder.players);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bossBarOverlayChanged(@NonNull BossBar bar, BossBar.@NonNull Overlay oldOverlay, BossBar.@NonNull Overlay newOverlay) {
|
||||
public void bossBarOverlayChanged(@NotNull BossBar bar, BossBar.@NotNull Overlay oldOverlay, BossBar.@NotNull Overlay newOverlay) {
|
||||
Holder holder = this.bars.get(bar);
|
||||
this.updatePlayers(holder.createOverlayUpdate(newOverlay), holder.players);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bossBarFlagsChanged(@NonNull BossBar bar, @NonNull Set<BossBar.Flag> flagsAdded, @NonNull Set<BossBar.Flag> flagsRemoved) {
|
||||
public void bossBarFlagsChanged(@NotNull BossBar bar, @NotNull Set<BossBar.Flag> flagsAdded, @NotNull Set<BossBar.Flag> flagsRemoved) {
|
||||
Holder holder = this.bars.get(bar);
|
||||
this.updatePlayers(holder.createFlagsUpdate(), holder.players);
|
||||
}
|
||||
@ -162,11 +159,11 @@ public class BossBarManager implements BossBar.Listener {
|
||||
this.registered = false;
|
||||
}
|
||||
|
||||
BossBarPacket createRemovePacket() {
|
||||
@NotNull BossBarPacket createRemovePacket() {
|
||||
return this.createGenericPacket(REMOVE, packet -> {});
|
||||
}
|
||||
|
||||
BossBarPacket createAddPacket() {
|
||||
@NotNull BossBarPacket createAddPacket() {
|
||||
return this.createGenericPacket(ADD, packet -> {
|
||||
packet.title = MinecraftServer.getSerializationManager().serialize(bar.name());
|
||||
packet.color = bar.color().ordinal();
|
||||
@ -176,37 +173,37 @@ public class BossBarManager implements BossBar.Listener {
|
||||
});
|
||||
}
|
||||
|
||||
BossBarPacket createPercentUpdate(float newPercent) {
|
||||
@NotNull BossBarPacket createPercentUpdate(float newPercent) {
|
||||
return this.createGenericPacket(UPDATE_HEALTH, packet -> packet.health = newPercent);
|
||||
}
|
||||
|
||||
BossBarPacket createColorUpdate(@NotNull Color color) {
|
||||
@NotNull BossBarPacket createColorUpdate(@NotNull Color color) {
|
||||
return this.createGenericPacket(UPDATE_STYLE, packet -> {
|
||||
packet.color = color.ordinal();
|
||||
packet.division = bar.overlay().ordinal();
|
||||
});
|
||||
}
|
||||
|
||||
BossBarPacket createTitleUpdate(@NotNull Component title) {
|
||||
@NotNull BossBarPacket createTitleUpdate(@NotNull Component title) {
|
||||
return this.createGenericPacket(UPDATE_TITLE, packet -> packet.title = MinecraftServer.getSerializationManager().serialize(title));
|
||||
}
|
||||
|
||||
BossBarPacket createFlagsUpdate() {
|
||||
@NotNull BossBarPacket createFlagsUpdate() {
|
||||
return createFlagsUpdate(bar.flags());
|
||||
}
|
||||
|
||||
BossBarPacket createFlagsUpdate(@NotNull Set<Flag> newFlags) {
|
||||
@NotNull BossBarPacket createFlagsUpdate(@NotNull Set<Flag> newFlags) {
|
||||
return this.createGenericPacket(UPDATE_FLAGS, packet -> packet.flags = serializeFlags(bar.flags()));
|
||||
}
|
||||
|
||||
BossBarPacket createOverlayUpdate(@NotNull Overlay overlay) {
|
||||
@NotNull BossBarPacket createOverlayUpdate(@NotNull Overlay overlay) {
|
||||
return this.createGenericPacket(UPDATE_STYLE, packet -> {
|
||||
packet.division = overlay.ordinal();
|
||||
packet.color = bar.color().ordinal();
|
||||
});
|
||||
}
|
||||
|
||||
BossBarPacket createGenericPacket(@NotNull BossBarPacket.Action action, @NotNull Consumer<BossBarPacket> consumer) {
|
||||
@NotNull BossBarPacket createGenericPacket(@NotNull BossBarPacket.Action action, @NotNull Consumer<BossBarPacket> consumer) {
|
||||
BossBarPacket packet = new BossBarPacket();
|
||||
packet.uuid = this.uuid;
|
||||
packet.action = action;
|
||||
|
@ -2,7 +2,6 @@ package net.minestom.server.adventure;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -22,7 +21,7 @@ public class WrapperAudience implements ForwardingAudience {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterable<? extends Audience> audiences() {
|
||||
public @NotNull Iterable<? extends Audience> audiences() {
|
||||
return this.audiences;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
import net.minestom.server.permission.Permission;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -23,7 +22,7 @@ public class ConsoleSender implements CommandSender {
|
||||
private final Set<Permission> permissions = new CopyOnWriteArraySet<>();
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull Identity source, @NonNull Component message, @NonNull MessageType type) {
|
||||
public void sendMessage(@NotNull Identity source, @NotNull Component message, @NotNull MessageType type) {
|
||||
// we don't use the serializer here as we just need the plain text of the message
|
||||
LOGGER.info(PlainComponentSerializer.plain().serialize(message));
|
||||
}
|
||||
|
@ -69,7 +69,6 @@ import net.minestom.server.utils.time.TimeUnit;
|
||||
import net.minestom.server.utils.time.UpdateOption;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -818,7 +817,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull Identity source, @NonNull Component message, @NonNull MessageType type) {
|
||||
public void sendMessage(@NotNull Identity source, @NotNull Component message, @NotNull MessageType type) {
|
||||
ChatMessagePacket chatMessagePacket = new ChatMessagePacket(MinecraftServer.getSerializationManager().serialize(message), type, source.uuid());
|
||||
playerConnection.sendPacket(chatMessagePacket);
|
||||
}
|
||||
@ -927,12 +926,12 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(net.kyori.adventure.sound.@NonNull Sound sound) {
|
||||
public void playSound(net.kyori.adventure.sound.@NotNull Sound sound) {
|
||||
this.playSound(sound, this.position.getX(), this.position.getY(), this.position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(net.kyori.adventure.sound.@NonNull Sound sound, double x, double y, double z) {
|
||||
public void playSound(net.kyori.adventure.sound.@NotNull Sound sound, double x, double y, double z) {
|
||||
Sound minestomSound = AdventureUtils.asSound(sound.name());
|
||||
|
||||
if (minestomSound == null) {
|
||||
@ -959,7 +958,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSound(@NonNull SoundStop stop) {
|
||||
public void stopSound(@NotNull SoundStop stop) {
|
||||
StopSoundPacket packet = new StopSoundPacket();
|
||||
packet.flags = 0x0;
|
||||
|
||||
@ -1021,7 +1020,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerListHeaderAndFooter(@NonNull Component header, @NonNull Component footer) {
|
||||
public void sendPlayerListHeaderAndFooter(@NotNull Component header, @NotNull Component footer) {
|
||||
PlayerListHeaderAndFooterPacket packet = new PlayerListHeaderAndFooterPacket();
|
||||
packet.header = MinecraftServer.getSerializationManager().serialize(header);
|
||||
packet.footer = MinecraftServer.getSerializationManager().serialize(footer);
|
||||
@ -1097,14 +1096,14 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTitle(@NonNull Title title) {
|
||||
public void showTitle(@NotNull Title title) {
|
||||
for (TitlePacket titlePacket : TitlePacket.of(title)) {
|
||||
playerConnection.sendPacket(titlePacket);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(@NonNull Component message) {
|
||||
public void sendActionBar(@NotNull Component message) {
|
||||
TitlePacket titlePacket = new TitlePacket(TitlePacket.Action.SET_ACTION_BAR, MinecraftServer.getSerializationManager().serialize(message));
|
||||
playerConnection.sendPacket(titlePacket);
|
||||
}
|
||||
@ -1149,12 +1148,12 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showBossBar(@NonNull BossBar bar) {
|
||||
public void showBossBar(@NotNull BossBar bar) {
|
||||
MinecraftServer.getBossBarManager().addBossBar(this, bar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideBossBar(@NonNull BossBar bar) {
|
||||
public void hideBossBar(@NotNull BossBar bar) {
|
||||
MinecraftServer.getBossBarManager().removeBossBar(this, bar);
|
||||
}
|
||||
|
||||
@ -1186,7 +1185,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openBook(@NonNull Book book) {
|
||||
public void openBook(@NotNull Book book) {
|
||||
// make the book
|
||||
ItemStack writtenBook = new ItemStack(Material.WRITTEN_BOOK, (byte) 1);
|
||||
writtenBook.setItemMeta(WrittenBookMeta.fromAdventure(book));
|
||||
|
@ -39,7 +39,6 @@ import net.minestom.server.utils.time.TimeUnit;
|
||||
import net.minestom.server.utils.time.UpdateOption;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -1108,7 +1107,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterable<? extends Audience> audiences() {
|
||||
public @NotNull Iterable<? extends Audience> audiences() {
|
||||
return this.getPlayers();
|
||||
}
|
||||
}
|
@ -26,7 +26,6 @@ import net.minestom.server.utils.async.AsyncUtils;
|
||||
import net.minestom.server.utils.callback.validator.PlayerValidator;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.apache.commons.text.similarity.JaroWinklerDistance;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -533,7 +532,7 @@ public final class ConnectionManager implements ForwardingAudience {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterable<? extends Audience> audiences() {
|
||||
public @NotNull Iterable<? extends Audience> audiences() {
|
||||
return this.getOnlinePlayers();
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,10 @@ import net.minestom.server.network.packet.server.play.TeamsPacket;
|
||||
import net.minestom.server.network.packet.server.play.TeamsPacket.CollisionRule;
|
||||
import net.minestom.server.network.packet.server.play.TeamsPacket.NameTagVisibility;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
@ -429,7 +426,7 @@ public class Team implements ForwardingAudience {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterable<? extends Audience> audiences() {
|
||||
public @NotNull Iterable<? extends Audience> audiences() {
|
||||
if (!this.isPlayerMembersUpToDate) {
|
||||
this.playerMembers.clear();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user