Skip to content

Commit

Permalink
feat: add nucleoid wrapped message
Browse files Browse the repository at this point in the history
  • Loading branch information
ashhhleyyy authored and Gegy committed Dec 9, 2023
1 parent 5851126 commit a791e73
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/xyz/nucleoid/extras/NucleoidExtras.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/data/nucleoid_extras/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a791e73

Please sign in to comment.