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 committed Dec 1, 2023
1 parent 920f0a5 commit c6e1ace
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

2 comments on commit c6e1ace

@haykam821
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would make sense to eventually spin this message into a generic event (previously discussed here) or message of the day system so that playtests and other time-sensitive activities could be announced in-game from the backend.

@ashhhleyyy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's something I've been working on for the new backend. i've just been really busy with uni stuff at the minute - this was a 3am implementation just so I could get it out

Please sign in to comment.