File tree Expand file tree Collapse file tree
type.bedwarsgame/src/main/java/net/swofty/type/bedwarsgame/events Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments