aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java b/src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java
new file mode 100644
index 0000000..26b5051
--- /dev/null
+++ b/src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java
@@ -0,0 +1,21 @@
+package dev.mayaqq.ygasi.events;
+
+import dev.mayaqq.ygasi.registry.ConfigRegistry;
+import dev.mayaqq.ygasi.util.YgasiUtils;
+import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Identifier;
+
+import static dev.mayaqq.ygasi.Ygasi.SKILL_BOOK;
+
+public class PlayerConnectEvent {
+ public static void onJoin() {
+ ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
+ if (!handler.player.getScoreboardTags().contains("skill_book_unlocked") && ConfigRegistry.CONFIG.enableSkillBook) {
+ handler.player.addScoreboardTag("skill_book_unlocked");
+ handler.player.getInventory().offerOrDrop(new ItemStack(SKILL_BOOK));
+ YgasiUtils.grantAdvancementCriterion(handler.player, new Identifier("ygasi", "recipes/minecraft_ygasi/skill_book"), "opened_skill_menu");
+ }
+ });
+ }
+} \ No newline at end of file