@@ -60,7 +60,7 @@ public void onDamage(EntityDamageByEntityEvent event) {
6060 // a player is killing something
6161 if (event .getDamager () instanceof Player ) {
6262 Player player = (Player ) event .getDamager ();
63- if (player .getGameMode () != GameMode .SURVIVAL ) {
63+ if (player .getGameMode () == GameMode .CREATIVE || player . getGameMode () == GameMode . SPECTATOR ) {
6464 return ;
6565 }
6666 // a player killed something with their fist
@@ -103,6 +103,9 @@ public void onDamage(EntityDamageByEntityEvent event) {
103103 // if the shooter is a player
104104 if (arrow .getShooter () instanceof Player ) {
105105 Player player = (Player ) arrow .getShooter ();
106+ if (player .getGameMode () == GameMode .CREATIVE || player .getGameMode () == GameMode .SPECTATOR ) {
107+ return ;
108+ }
106109 ItemStack heldItem = player .getInventory ().getItem (player .getInventory ().getHeldItemSlot ());
107110 if (heldItem == null ) {
108111 return ;
@@ -122,6 +125,9 @@ public void onDamage(EntityDamageByEntityEvent event) {
122125 // player is taken damage but not being killed
123126 if (livingEntity instanceof Player ) {
124127 Player player = (Player ) livingEntity ;
128+ if (player .getGameMode () == GameMode .CREATIVE || player .getGameMode () == GameMode .SPECTATOR ) {
129+ return ;
130+ }
125131 PlayerInventory inventory = player .getInventory ();
126132 for (ItemStack armor : inventory .getArmorContents ()) {
127133 if (armor != null ) {
@@ -142,6 +148,9 @@ public void onDamage(EntityDamageEvent event) {
142148 // player is taken damage but not being killed
143149 if (livingEntity instanceof Player ) {
144150 Player player = (Player ) livingEntity ;
151+ if (player .getGameMode () == GameMode .CREATIVE || player .getGameMode () == GameMode .SPECTATOR ) {
152+ return ;
153+ }
145154 PlayerInventory inventory = player .getInventory ();
146155 for (ItemStack armor : inventory .getArmorContents ()) {
147156 if (armor != null ) {
@@ -162,6 +171,9 @@ public void onDamage(EntityDamageByBlockEvent event) {
162171 // player is taken damage but not being killed
163172 if (livingEntity instanceof Player ) {
164173 Player player = (Player ) livingEntity ;
174+ if (player .getGameMode () == GameMode .CREATIVE || player .getGameMode () == GameMode .SPECTATOR ) {
175+ return ;
176+ }
165177 PlayerInventory inventory = player .getInventory ();
166178 for (ItemStack armor : inventory .getArmorContents ()) {
167179 if (armor != null ) {
0 commit comments