aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/events
diff options
context:
space:
mode:
authorMaximusbarcz <maxim.baranek@gmail.com>2023-01-07 20:49:03 +0100
committerMaximusbarcz <maxim.baranek@gmail.com>2023-01-07 20:49:03 +0100
commitab1ddc8e008ed93392ea3918da1d669dd1b4822c (patch)
tree433a63693e274cbe941f2b20481bf102c10807d4 /src/main/java/dev/mayaqq/ygasi/events
parent399d370aacfe3ba1aa6b400dd70ededa1014eb86 (diff)
downloadygasi-ab1ddc8e008ed93392ea3918da1d669dd1b4822c.tar.gz
ygasi-ab1ddc8e008ed93392ea3918da1d669dd1b4822c.tar.bz2
ygasi-ab1ddc8e008ed93392ea3918da1d669dd1b4822c.zip
Added even more translations!
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/events')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java21
-rw-r--r--src/main/java/dev/mayaqq/ygasi/events/RegisterEvents.java7
2 files changed, 28 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
diff --git a/src/main/java/dev/mayaqq/ygasi/events/RegisterEvents.java b/src/main/java/dev/mayaqq/ygasi/events/RegisterEvents.java
new file mode 100644
index 0000000..08476f1
--- /dev/null
+++ b/src/main/java/dev/mayaqq/ygasi/events/RegisterEvents.java
@@ -0,0 +1,7 @@
+package dev.mayaqq.ygasi.events;
+
+public class RegisterEvents {
+ public static void register() {
+ PlayerConnectEvent.onJoin();
+ }
+}