diff --git a/src/main/java/net/minestom/server/advancements/notifications/Notification.java b/src/main/java/net/minestom/server/advancements/notifications/Notification.java deleted file mode 100644 index e84bf5339aa..00000000000 --- a/src/main/java/net/minestom/server/advancements/notifications/Notification.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.minestom.server.advancements.notifications; - -import net.kyori.adventure.text.Component; -import net.minestom.server.advancements.FrameType; -import net.minestom.server.item.ItemStack; -import net.minestom.server.item.Material; -import org.jetbrains.annotations.NotNull; - -/** - * Represents a message which can be sent using the {@link NotificationCenter}. - * @since 1.0.0 - * @deprecated As of Minestom 22a8ccabfae38c53df0605000aa7eed49765c1ab, because the Maintainability is very hard and - * can break everytime from Mojang side because bad api design use {@link net.minestom.server.notifications.Notification#builder()} instead. - */ -@Deprecated(since = "1.4.1", forRemoval = true) -public record Notification(@NotNull Component title, @NotNull FrameType frameType, @NotNull ItemStack icon) { - public Notification(@NotNull Component title, @NotNull FrameType frameType, @NotNull Material icon) { - this(title, frameType, ItemStack.of(icon)); - } -} diff --git a/src/main/java/net/minestom/server/advancements/notifications/NotificationCenter.java b/src/main/java/net/minestom/server/advancements/notifications/NotificationCenter.java deleted file mode 100644 index 968c75fbd21..00000000000 --- a/src/main/java/net/minestom/server/advancements/notifications/NotificationCenter.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.minestom.server.advancements.notifications; - -import net.kyori.adventure.text.Component; -import net.minestom.server.entity.Player; -import net.minestom.server.network.packet.server.play.AdvancementsPacket; -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; -import java.util.List; - -/** - * @since 1.0.0 - * Used to send one or multiples {@link Notification}. - *

- * Works by sending a completed advancement and remove it immediately. - *

- * You can simply create a {@link Notification} object and call {@link #send(Notification, Player)}. - * @deprecated As of Minestom 22a8ccabfae38c53df0605000aa7eed49765c1ab, because the Maintainability is very hard and - * can break everytime from Mojang side because bad api design use {@link net.minestom.server.notifications.Notification#builder()} instead. - */ -@Deprecated(since = "1.4.1", forRemoval = true) -public final class NotificationCenter { - private static final String IDENTIFIER = "minestom:notification"; - private static final AdvancementsPacket REMOVE_PACKET = new AdvancementsPacket(false, List.of(), List.of(IDENTIFIER), List.of()); - - /** - * Can't create an instance, use the static methods instead. - */ - private NotificationCenter() { - } - - /** - * Send a {@link Notification} to one player. - * - * @param notification the {@link Notification} to send - * @param player the player to send the notification to - */ - public static void send(@NotNull Notification notification, @NotNull Player player) { - player.sendPacket(createPacket(notification)); - player.sendPacket(REMOVE_PACKET); - } - - /** - * Send a {@link Notification} to a collection of players. - * - * @param notification the {@link Notification} to send - * @param players the collection of players to send the notification to - */ - public static void send(@NotNull Notification notification, @NotNull Collection players) { - // Can't use PacketWriterUtils because we need the packets to come in the correct order - players.forEach(player -> send(notification, player)); - } - - /** - * Create the {@link AdvancementsPacket} responsible for showing the Toast to players - * - * @param notification the notification - * @return the packet used to show the Toast - */ - private static AdvancementsPacket createPacket(Notification notification) { - // For An advancement to be shown, it must have all of its criteria achieved (progress 100%) - // Create a Criteria that we can set to 100% achieved. - final var displayData = new AdvancementsPacket.DisplayData( - notification.title(), Component.text("Articdive was here. #Minestom"), - notification.icon(), notification.frameType(), - 0x6, null, 0f, 0f); - - final var criteria = new AdvancementsPacket.Criteria("minestom:some_criteria", - new AdvancementsPacket.CriterionProgress(System.currentTimeMillis())); - - final var advancement = new AdvancementsPacket.Advancement(null, displayData, - List.of(new AdvancementsPacket.Requirement(List.of(criteria.criterionIdentifier()))), - false); - - final var mapping = new AdvancementsPacket.AdvancementMapping(IDENTIFIER, advancement); - final var progressMapping = new AdvancementsPacket.ProgressMapping(IDENTIFIER, - new AdvancementsPacket.AdvancementProgress(List.of(criteria))); - - return new AdvancementsPacket(false, List.of(mapping), List.of(), List.of(progressMapping)); - } -}