Add ExploitFix.PreventPluginNPCInteraction to experience.yml

Read the changelog for why
This commit is contained in:
nossr50
2020-12-28 12:58:03 -08:00
parent e8d51f42f3
commit a4ef322fa5
7 changed files with 26 additions and 9 deletions

View File

@ -152,6 +152,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
public boolean isPistonExploitPrevented() { return config.getBoolean("ExploitFix.Pistons", false); }
public boolean allowUnsafeEnchantments() { return config.getBoolean("ExploitFix.UnsafeEnchantments", false); }
public boolean isCOTWBreedingPrevented() { return config.getBoolean("ExploitFix.COTWBreeding", true); }
public boolean isNPCInteractionPrevented() { return config.getBoolean("ExploitFix.PreventPluginNPCInteraction", true); }
public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }

View File

@ -312,7 +312,8 @@ public class EntityListener implements Listener {
return;
}
if (Misc.isNPCEntityExcludingVillagers(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) {
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(defender)) || !defender.isValid() || !(defender instanceof LivingEntity)) {
return;
}
@ -322,7 +323,7 @@ public class EntityListener implements Listener {
return;
}
if (Misc.isNPCEntityExcludingVillagers(attacker)) {
if (ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(attacker)) {
return;
}
@ -502,7 +503,7 @@ public class EntityListener implements Listener {
}
*/
if (Misc.isNPCEntityExcludingVillagers(entity) || !entity.isValid() || !(entity instanceof LivingEntity)) {
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(entity)) || !entity.isValid() || !(entity instanceof LivingEntity)) {
return;
}
@ -649,7 +650,7 @@ public class EntityListener implements Listener {
LivingEntity entity = event.getEntity();
if (Misc.isNPCEntityExcludingVillagers(entity)) {
if (ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(entity)) {
return;
}
@ -957,7 +958,7 @@ public class EntityListener implements Listener {
LivingEntity livingEntity = event.getEntity();
if (!UserManager.hasPlayerDataKey(player)
|| Misc.isNPCEntityExcludingVillagers(livingEntity)
|| (ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(livingEntity))
|| persistentDataLayer.hasMobFlag(MobMetaFlagType.EGG_MOB, livingEntity)
|| persistentDataLayer.hasMobFlag(MobMetaFlagType.MOB_SPAWNER_MOB, livingEntity)) {
return;

View File

@ -895,7 +895,7 @@ public class PlayerListener implements Listener {
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntityExcludingVillagers(player) || !UserManager.hasPlayerDataKey(player)) {
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(player)) || !UserManager.hasPlayerDataKey(player)) {
return;
}

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.party.Party;

View File

@ -321,8 +321,10 @@ public final class CombatUtils {
EntityType entityType = painSource.getType();
if (target instanceof Player) {
if (Misc.isNPCEntityExcludingVillagers(target)) {
return;
if(ExperienceConfig.getInstance().isNPCInteractionPrevented()) {
if (Misc.isNPCEntityExcludingVillagers(target)) {
return;
}
}
Player player = (Player) target;
@ -692,7 +694,7 @@ public final class CombatUtils {
break;
}
if (Misc.isNPCEntityExcludingVillagers(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(entity)) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
continue;
}

View File

@ -35,6 +35,10 @@ ExploitFix:
TreeFellerReducedXP: true
PistonCheating: true
SnowGolemExcavation: true
# This include NPCs from stuff like Citizens, this is not a setting for Vanilla Minecraft Villagers (Which can be considered NPCs)
# mcMMO normally doesn't process attacks against an Entity if it is an NPC from another plugin
# Of course, mcMMO doesn't know for sure whether or not something is an NPC, it checks a few known things, see our source code to see how
PreventPluginNPCInteraction: true
Experience_Bars:
# Turn this to false if you wanna disable XP bars
Enable: true