Exploit Prevention config pt 2

This commit is contained in:
nossr50 2019-03-14 17:34:13 -07:00
parent d272d60112
commit 094850ab85
7 changed files with 92 additions and 44 deletions

View File

@ -14,10 +14,15 @@ Version 2.2.0
All config nodes will now use Capital letters at the start of each nodes name and after each hyphen (-)
All config nodes now include a comment with the default value of the node to use as reference
Expanded settings relating to purging users who have not leveled or users who had not logged in for many months
NOTE: Not every config key that was renamed will be listed here
Fixed a bug where players who started at level 1 would not be purged from the DB for being "powerless"
Fixed a potential bug where players could be awarded XP for cancelled tame events
Exploit related config options will now be found in "exploit-prevention"
Exploit Prevention's "EndermanEndermiteFarms" renamed -> "Endermen-Endermite-Fix"
Added toggle for pistons marking natural blocks as unnatural after being moved to prevent afk stone farms
Added toggle for marking spawned mobs for giving modified XP
Added toggle for tamed mobs to give combat XP when struck
Settings related to Player Leveling are now found in "player_leveling.conf"
Player Leveling's "TruncateSkills" renamed -> "Reduce-Player-Skills-Above-Cap"

View File

@ -4,6 +4,7 @@ import com.gmail.nossr50.config.collectionconfigs.RepairConfig;
import com.gmail.nossr50.config.collectionconfigs.SalvageConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.hocon.SerializedConfigLoader;
import com.gmail.nossr50.config.hocon.antiexploit.ConfigExploitPrevention;
import com.gmail.nossr50.config.hocon.database.ConfigDatabase;
import com.gmail.nossr50.config.hocon.playerleveling.ConfigLeveling;
import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard;
@ -67,6 +68,7 @@ public final class ConfigManager {
private SerializedConfigLoader<ConfigScoreboard> configScoreboard;
private SerializedConfigLoader<ConfigLeveling> configLeveling;
private SerializedConfigLoader<ConfigWorldBlacklist> configWorldBlacklist;
private SerializedConfigLoader<ConfigExploitPrevention> configExploitPrevention;
private MainConfig mainConfig;
private FishingTreasureConfig fishingTreasureConfig;
private ExcavationTreasureConfig excavationTreasureConfig;
@ -102,6 +104,7 @@ public final class ConfigManager {
configScoreboard = new SerializedConfigLoader<>(ConfigScoreboard.class, "scoreboard.conf", null);
configLeveling = new SerializedConfigLoader<>(ConfigLeveling.class, "player_leveling.conf", null);
configWorldBlacklist = new SerializedConfigLoader<>(ConfigWorldBlacklist.class, "world_blacklist.conf", null);
configExploitPrevention = new SerializedConfigLoader<>(ConfigExploitPrevention.class, "exploit_prevention.conf", null);
mainConfig = new MainConfig();
@ -327,4 +330,8 @@ public final class ConfigManager {
public ConfigWorldBlacklist getConfigWorldBlacklist() {
return configWorldBlacklist.getConfig();
}
public ConfigExploitPrevention getConfigExploitPrevention() {
return configExploitPrevention.getConfig();
}
}

View File

@ -222,12 +222,12 @@ public class ExperienceConfig extends ConfigValidated {
* FORMULA SETTINGS
*/
/* EXPLOIT TOGGLES */
public boolean isEndermanEndermiteFarmingPrevented() {
return getBooleanValue(EXPLOIT_FIX, ENDERMAN_ENDERMITE_FARMS);
}
public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
/* Curve settings */
public FormulaType getFormulaType() {
return FormulaType.getFormulaType(getStringValue(EXPERIENCE_FORMULA, CURVE));

View File

@ -1,32 +0,0 @@
package com.gmail.nossr50.config.hocon.antiexploit;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class AntiExploit {
private static final boolean ENDERMEN_ENDERMITE_DEFAULT = true;
private static final boolean PISTONS_MARK_BLOCKS_DEFAULT = true;
public static final boolean SPAWNED_MOBS_DEFAULT = true;
/*
* CONFIG NODES
*/
@Setting(value = "Endermen-Endermite-Fix",
comment = "Removes XP from Endermen that target endermite, this is a common exploit in The End because of how rapidly they can spawn." +
"\nIt is recommended that you leave this on as it allows players to easily gain massive amounts of combat XP" +
"\nDefault value: "+ENDERMEN_ENDERMITE_DEFAULT)
private boolean endermenEndermiteFix = ENDERMEN_ENDERMITE_DEFAULT;
@Setting(value = "Pistons-Mark-Blocks-As-Unnatural",
comment = "Unnatural blocks give no XP." +
"This helps prevent complex automated stone farms that enable auto clickers to gain XP passively.")
private boolean pistonsMarkBlocksUnnatural = PISTONS_MARK_BLOCKS_DEFAULT;
@Setting(value = "Spawned-Mobs-Give-No-XP",
comment = "Spawned mobs will not give players combat XP." +
"\nThis includes mobs spawned from a nether portal, mob spawner, or eggs." +
"\nThis will not include mobs spawned from commands, typically.")
private boolean spawnedMobsGiveNoXP = SPAWNED_MOBS_DEFAULT;
}

View File

@ -0,0 +1,57 @@
package com.gmail.nossr50.config.hocon.antiexploit;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigExploitPrevention {
private static final boolean ENDERMEN_ENDERMITE_DEFAULT = true;
private static final boolean PISTONS_MARK_BLOCKS_DEFAULT = true;
public static final boolean SPAWNED_MOBS_DEFAULT = true;
public static final boolean TAMED_MOB_DEFAULT = true;
/*
* CONFIG NODES
*/
@Setting(value = "Endermen-Endermite-Fix",
comment = "Removes XP from Endermen that target endermite, this is a common exploit in The End because of how rapidly they can spawn." +
"\nIt is recommended that you leave this on as it allows players to easily gain massive amounts of combat XP" +
"\nDefault value: "+ENDERMEN_ENDERMITE_DEFAULT)
private boolean endermenEndermiteFix = ENDERMEN_ENDERMITE_DEFAULT;
@Setting(value = "Pistons-Mark-Blocks-As-Unnatural",
comment = "Unnatural blocks give no XP." +
"This helps prevent complex automated stone farms that enable auto clickers to gain XP passively." +
"\nDefault value: "+PISTONS_MARK_BLOCKS_DEFAULT)
private boolean pistonsMarkBlocksUnnatural = PISTONS_MARK_BLOCKS_DEFAULT;
@Setting(value = "Spawned-Mobs-Have-Modified-XP-Values",
comment = "Spawned mobs will give different XP values than their naturally spawning counterparts" +
"\nBy default, spawned mob XP is reduced to zero, but you could change it in the experience config to whatever you want." +
"\nSpawned mobs include mobs spawned from a nether portal, mob spawner, or eggs." +
"\nThis will not include mobs spawned from commands, typically." +
"\nDefault value: "+SPAWNED_MOBS_DEFAULT)
private boolean markSpawnedMobs = SPAWNED_MOBS_DEFAULT;
@Setting(value = "Prevent-Tamed-Mob-XP", comment = "Prevents tamed entities from giving any XP" +
"\nDefault value: "+TAMED_MOB_DEFAULT)
private boolean preventTamedMobXp = TAMED_MOB_DEFAULT;
public boolean getEndermenEndermiteFix() {
return endermenEndermiteFix;
}
public boolean doPistonsMarkBlocksUnnatural() {
return pistonsMarkBlocksUnnatural;
}
public boolean doSpawnedEntitiesGiveModifiedXP() {
return markSpawnedMobs;
}
public boolean doTamedEntitiesGiveXP() {
return preventTamedMobXp;
}
}

View File

@ -107,6 +107,8 @@ public class BlockListener implements Listener {
for (Block b : event.getBlocks()) {
if (BlockUtils.shouldBeWatched(b.getState())) {
movedBlock = b.getRelative(direction);
if(mcMMO.getConfigManager().getConfigExploitPrevention().doPistonsMarkBlocksUnnatural())
mcMMO.getPlaceStore().setTrue(movedBlock);
}
}

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.meta.OldName;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
@ -71,7 +70,7 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTargetEntity(EntityTargetLivingEntityEvent event)
{
if(!ExperienceConfig.getInstance().isEndermanEndermiteFarmingPrevented())
if(!mcMMO.getConfigManager().getConfigExploitPrevention().getEndermenEndermiteFix())
return;
//Prevent entities from giving XP if they target endermite
@ -645,6 +644,8 @@ public class EntityListener implements Listener {
case NETHER_PORTAL:
case SPAWNER:
case SPAWNER_EGG:
if(mcMMO.getConfigManager().getConfigExploitPrevention().doSpawnedEntitiesGiveModifiedXP())
{
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
Entity passenger = entity.getPassenger();
@ -652,6 +653,7 @@ public class EntityListener implements Listener {
if (passenger != null) {
passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
}
}
return;
case BREEDING:
@ -894,10 +896,17 @@ public class EntityListener implements Listener {
return;
}
if(!event.isCancelled())
{
if(mcMMO.getConfigManager().getConfigExploitPrevention().doTamedEntitiesGiveXP())
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity);
}
}
/**
* Handle EntityTarget events.
*