From c6e1ace60544e49aa146708a565d5661afa47775 Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Fri, 1 Dec 2023 03:23:01 +0000 Subject: [PATCH] feat: add nucleoid wrapped message --- .../xyz/nucleoid/extras/NucleoidExtras.java | 23 +++++++++++++++++++ .../data/nucleoid_extras/lang/en_us.json | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/main/java/xyz/nucleoid/extras/NucleoidExtras.java b/src/main/java/xyz/nucleoid/extras/NucleoidExtras.java index 93c3aad..6767596 100644 --- a/src/main/java/xyz/nucleoid/extras/NucleoidExtras.java +++ b/src/main/java/xyz/nucleoid/extras/NucleoidExtras.java @@ -3,7 +3,13 @@ import eu.pb4.playerdata.api.PlayerDataApi; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; +import net.fabricmc.fabric.api.networking.v1.PacketSender; +import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.network.ServerPlayNetworkHandler; +import net.minecraft.text.ClickEvent; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -22,6 +28,8 @@ import xyz.nucleoid.extras.scheduled_stop.ScheduledStop; import xyz.nucleoid.extras.sidebar.NucleoidSidebar; +import java.util.Calendar; + public final class NucleoidExtras implements ModInitializer { public static final String ID = "nucleoid_extras"; public static final Logger LOGGER = LogManager.getLogger(NucleoidExtras.class); @@ -50,9 +58,24 @@ public void onInitialize() { PlayerDataApi.register(PlayerLobbyState.STORAGE); ServerTickEvents.END_SERVER_TICK.register(NucleoidExtras::onServerTick); + ServerPlayConnectionEvents.JOIN.register(NucleoidExtras::onPlayerJoin); ServerChangePortalBackend.register(); } + private static void onPlayerJoin(ServerPlayNetworkHandler handler, PacketSender sender, MinecraftServer server) { + Calendar calendar = Calendar.getInstance(); + if (calendar.get(Calendar.YEAR) == 2023 && calendar.get(Calendar.MONTH) == Calendar.DECEMBER) { + handler.getPlayer().sendMessage( + Text.translatable("text.nucleoid_extras.wrapped.join", handler.getPlayer().getUuidAsString()) + .formatted(Formatting.GREEN) + .styled(style -> style.withClickEvent(new ClickEvent( + ClickEvent.Action.OPEN_URL, + "https://stats.nucleoid.xyz/players/" + handler.getPlayer().getUuidAsString() + "/wrapped" + ))) + ); + } + } + private static void onServerTick(MinecraftServer server) { int ticks = server.getTicks(); var config = NucleoidExtrasConfig.get(); diff --git a/src/main/resources/data/nucleoid_extras/lang/en_us.json b/src/main/resources/data/nucleoid_extras/lang/en_us.json index 924fe7a..e64c352 100644 --- a/src/main/resources/data/nucleoid_extras/lang/en_us.json +++ b/src/main/resources/data/nucleoid_extras/lang/en_us.json @@ -391,6 +391,8 @@ "text.nucleoid_extras.ui.action.more": "Right-click for more...", + "text.nucleoid_extras.wrapped.join": "Nucleoid Wrapped 2023 is here! Check out yours at https://stats.nucleoid.xyz/players/%s/wrapped", + "advancements.nucleoid_extras.root.title": "Nucleoid", "advancements.nucleoid_extras.root.description": "Advancements for Nucleoid", "advancements.nucleoid_extras.first_tater.title": "My First Tater",