Skip to content

Commit 8f162db

Browse files
committed
fix(bedwars): disable damage on conditions
1 parent c894b05 commit 8f162db

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package net.swofty.type.bedwarsgame.events;
2+
3+
import net.minestom.server.entity.Entity;
4+
import net.swofty.pvp.events.PrepareAttackEvent;
5+
import net.swofty.type.bedwarsgame.game.Game;
6+
import net.swofty.type.bedwarsgame.game.GameStatus;
7+
import net.swofty.type.bedwarsgame.user.BedWarsPlayer;
8+
import net.swofty.type.generic.entity.npc.HypixelNPC;
9+
import net.swofty.type.generic.event.EventNodes;
10+
import net.swofty.type.generic.event.HypixelEvent;
11+
import net.swofty.type.generic.event.HypixelEventClass;
12+
13+
public class ActionEntityAttack implements HypixelEventClass {
14+
15+
@HypixelEvent(node = EventNodes.ALL, requireDataLoaded = false)
16+
public void run(PrepareAttackEvent event) {
17+
if (event.getEntity() instanceof BedWarsPlayer player) {
18+
Game game = player.getGame();
19+
if (game == null) {
20+
event.setCancelled(true);
21+
return;
22+
}
23+
24+
if (game.getGameStatus() != GameStatus.IN_PROGRESS) {
25+
event.setCancelled(true);
26+
return;
27+
}
28+
29+
for (Entity entity : HypixelNPC.getPerPlayerNPCs().get(player.getUuid()).getEntityImpls().values()) {
30+
if (event.getTarget() == entity) {
31+
event.setCancelled(true);
32+
return;
33+
}
34+
}
35+
}
36+
}
37+
38+
}

0 commit comments

Comments
 (0)