nossr50 1 سال پیش
والد
کامیت
4d85f24d98
2فایلهای تغییر یافته به همراه16 افزوده شده و 13 حذف شده
  1. 2 1
      Changelog.txt
  2. 14 12
      src/main/java/com/gmail/nossr50/listeners/EntityListener.java

+ 2 - 1
Changelog.txt

@@ -1,5 +1,6 @@
 Version 2.1.230
 Version 2.1.230
-    Fixed an error that could happen when mcMMO was saving when parties were disabled by party.yml
+    Fixed an error that could happen when mcMMO was saving when parties were disabled by party.yml (thanks IAISI & L4BORG)
+    Fixed several exceptions when checking PVP damage when parties were disabled by party.yml (thanks IAISI & L4BORG)
 
 
 Version 2.1.229
 Version 2.1.229
     Added new party.yml config, which lets admins disable the party system entirely without having to use permissions
     Added new party.yml config, which lets admins disable the party system entirely without having to use permissions

+ 14 - 12
src/main/java/com/gmail/nossr50/listeners/EntityListener.java

@@ -9,7 +9,6 @@ import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.metadata.MobMetaFlagType;
 import com.gmail.nossr50.metadata.MobMetaFlagType;
 import com.gmail.nossr50.metadata.MobMetadataService;
 import com.gmail.nossr50.metadata.MobMetadataService;
-import com.gmail.nossr50.party.PartyManager;
 import com.gmail.nossr50.runnables.TravelingBlockMetaCleanup;
 import com.gmail.nossr50.runnables.TravelingBlockMetaCleanup;
 import com.gmail.nossr50.skills.archery.Archery;
 import com.gmail.nossr50.skills.archery.Archery;
 import com.gmail.nossr50.skills.mining.BlastMining;
 import com.gmail.nossr50.skills.mining.BlastMining;
@@ -259,16 +258,16 @@ public class EntityListener implements Listener {
     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
     public void onEntityCombustByEntityEvent(EntityCombustByEntityEvent event) {
     public void onEntityCombustByEntityEvent(EntityCombustByEntityEvent event) {
         //Prevent players from setting fire to each other if they are in the same party
         //Prevent players from setting fire to each other if they are in the same party
-        if(mcMMO.p.getPartyConfig().isPartyEnabled() && event.getEntity() instanceof Player defender) {
+        if(event.getEntity() instanceof Player defender) {
 
 
             if(event.getCombuster() instanceof Projectile projectile) {
             if(event.getCombuster() instanceof Projectile projectile) {
                 if(projectile.getShooter() instanceof Player attacker) {
                 if(projectile.getShooter() instanceof Player attacker) {
-                    if(checkParties(event, defender, attacker)) {
+                    if(checkIfInPartyOrSamePlayer(event, defender, attacker)) {
                         event.setCancelled(true);
                         event.setCancelled(true);
                     }
                     }
                 }
                 }
             } else if(event.getCombuster() instanceof Player attacker) {
             } else if(event.getCombuster() instanceof Player attacker) {
-                if(checkParties(event, defender, attacker)) {
+                if(checkIfInPartyOrSamePlayer(event, defender, attacker)) {
                     event.setCancelled(true);
                     event.setCancelled(true);
                 }
                 }
             }
             }
@@ -364,8 +363,8 @@ public class EntityListener implements Listener {
             //If the attacker is a Player or a projectile belonging to a player
             //If the attacker is a Player or a projectile belonging to a player
             if(attacker instanceof Projectile projectile) {
             if(attacker instanceof Projectile projectile) {
                 if(projectile.getShooter() instanceof Player attackingPlayer && !attackingPlayer.equals(defendingPlayer)) {
                 if(projectile.getShooter() instanceof Player attackingPlayer && !attackingPlayer.equals(defendingPlayer)) {
-                    //Check for party friendly fire and cancel the event
-                    if (mcMMO.p.getPartyConfig().isPartyEnabled() && checkParties(event, defendingPlayer, attackingPlayer)) {
+                    //Check for friendly fire and cancel the event
+                    if (checkIfInPartyOrSamePlayer(event, defendingPlayer, attackingPlayer)) {
                         return;
                         return;
                     }
                     }
                 }
                 }
@@ -383,7 +382,7 @@ public class EntityListener implements Listener {
                     }
                     }
                 }
                 }
             } else if (attacker instanceof Player attackingPlayer){
             } else if (attacker instanceof Player attackingPlayer){
-                if (mcMMO.p.getPartyConfig().isPartyEnabled() && checkParties(event, defendingPlayer, attackingPlayer))
+                if (checkIfInPartyOrSamePlayer(event, defendingPlayer, attackingPlayer))
                     return;
                     return;
             }
             }
         }
         }
@@ -482,14 +481,17 @@ public class EntityListener implements Listener {
         }
         }
     }
     }
 
 
-    public boolean checkParties(Cancellable event, Player defendingPlayer, Player attackingPlayer) {
-        if (!UserManager.hasPlayerDataKey(defendingPlayer) || !UserManager.hasPlayerDataKey(attackingPlayer)) {
+    public boolean checkIfInPartyOrSamePlayer(Cancellable event, Player defendingPlayer, Player attackingPlayer) {
+        // This check is probably necessary outside of the party system
+        if (defendingPlayer.equals(attackingPlayer)) {
             return true;
             return true;
         }
         }
 
 
-        // We want to make sure we're not gaining XP or applying abilities
-        // when we hit ourselves
-        if (defendingPlayer.equals(attackingPlayer)) {
+        if(!pluginRef.isPartySystemEnabled()) {
+            return false;
+        }
+
+        if (!UserManager.hasPlayerDataKey(defendingPlayer) || !UserManager.hasPlayerDataKey(attackingPlayer)) {
             return true;
             return true;
         }
         }