From 0893709187f5c787f6e6c3f360ef406761cd198a Mon Sep 17 00:00:00 2001 From: Dueris Date: Sun, 2 Jun 2024 15:20:04 -0700 Subject: [PATCH] fix orb of origins not clearing powers --- .../genesismc/factory/powers/holder/PowerType.java | 2 +- .../me/dueris/genesismc/screen/ScreenNavigator.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/origins/src/main/java/me/dueris/genesismc/factory/powers/holder/PowerType.java b/origins/src/main/java/me/dueris/genesismc/factory/powers/holder/PowerType.java index f70819e30..9981a2dbd 100644 --- a/origins/src/main/java/me/dueris/genesismc/factory/powers/holder/PowerType.java +++ b/origins/src/main/java/me/dueris/genesismc/factory/powers/holder/PowerType.java @@ -135,8 +135,8 @@ public void forPlayer(Player player) { } public void removePlayer(Player player) { - this.hasPlayers = false; this.players.remove((CraftPlayer) player); + this.hasPlayers = !this.players.isEmpty(); } public boolean isActive(Player player) { diff --git a/origins/src/main/java/me/dueris/genesismc/screen/ScreenNavigator.java b/origins/src/main/java/me/dueris/genesismc/screen/ScreenNavigator.java index 52769a0af..75200ffaa 100644 --- a/origins/src/main/java/me/dueris/genesismc/screen/ScreenNavigator.java +++ b/origins/src/main/java/me/dueris/genesismc/screen/ScreenNavigator.java @@ -2,6 +2,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import javassist.NotFoundException; import me.dueris.genesismc.GenesisMC; import me.dueris.genesismc.content.OrbOfOrigins; import me.dueris.genesismc.event.OrbInteractEvent; @@ -170,9 +171,14 @@ public void onOrbClick(PlayerInteractEvent e) { if (!((CraftPlayer) p).getHandle().getAbilities().instabuild) { Util.consumeItem(e.getItem()); } - for (Layer layer : CraftApoli.getLayersFromRegistry()) { + CraftApoli.getLayersFromRegistry().forEach(layer -> { + try { + PowerHolderComponent.unassignPowers(p, layer); + } catch (NotFoundException ee) { + throw new RuntimeException(ee); + } PowerHolderComponent.setOrigin(p, layer, CraftApoli.emptyOrigin()); - } + }); OrbInteractEvent event = new OrbInteractEvent(p); getServer().getPluginManager().callEvent(event); }