diff options
author | Maximusbarcz <maxim.baranek@gmail.com> | 2023-01-20 23:06:47 +0100 |
---|---|---|
committer | Maximusbarcz <maxim.baranek@gmail.com> | 2023-01-20 23:06:47 +0100 |
commit | adaecef7df47ccdbfbda6f438c28696ff1ce8822 (patch) | |
tree | 46397c9d175ca67a69b7033189fec26dd6c6b4ae /src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java | |
parent | 531bb27e7eb07e08e1e423d0cf01c297fef890f6 (diff) | |
download | ygasi-adaecef7df47ccdbfbda6f438c28696ff1ce8822.tar.gz ygasi-adaecef7df47ccdbfbda6f438c28696ff1ce8822.tar.bz2 ygasi-adaecef7df47ccdbfbda6f438c28696ff1ce8822.zip |
I redid all the advancements and also started work on the second Offence2 ability
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java')
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java | 15 |
1 files changed, 15 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 index 97cd225..6723d01 100644 --- a/src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java +++ b/src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java @@ -2,8 +2,12 @@ package dev.mayaqq.ygasi.events; import dev.mayaqq.ygasi.registry.ConfigRegistry; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; +import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; +import java.util.UUID; + +import static dev.mayaqq.ygasi.abilities.mercenary.Offence2.playerSwords; import static dev.mayaqq.ygasi.registry.ItemRegistry.SKILL_BOOK; public class PlayerConnectEvent { @@ -16,4 +20,15 @@ public class PlayerConnectEvent { } }); } + public static void onPlayerDisconnect() { + ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> { + if (playerSwords.get(handler.player.getUuidAsString()) != null) { + playerSwords.get(handler.player.getUuidAsString()).forEach(uuid -> { + Entity sword = handler.player.getWorld().getEntity(UUID.fromString(uuid)); + sword.remove(Entity.RemovalReason.DISCARDED); + }); + playerSwords.remove(handler.player.getUuidAsString()); + } + }); + } }
\ No newline at end of file |