diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/region/pvpmode/PvPModeListener.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/region/pvpmode/PvPModeListener.java index 126b7c85..8b55bb89 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/region/pvpmode/PvPModeListener.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/region/pvpmode/PvPModeListener.java @@ -63,6 +63,14 @@ public class PvPModeListener implements Listener { MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.cannot-hit.low-level-self").send(source); return; } + + final int maxLevelDiff = MMOCore.plugin.configManager.maxCombatLevelDifference; + if (maxLevelDiff > 0 && Math.abs(targetData. getLevel() - sourceData.getLevel()) > maxLevelDiff) { + event.setCancelled(true); + if (event.getDamage() > 0) + MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.cannot-hit.high-level-difference").send(source); + return; + } } /* diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java index 5b16a38a..aa8e7764 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java @@ -34,7 +34,7 @@ public class ConfigManager { public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown; public double lootChestsChanceWeight, dropItemsChanceWeight, fishingDropsChanceWeight, partyMaxExpSplitRange, pvpModeToggleOnCooldown, pvpModeToggleOffCooldown, pvpModeCombatCooldown, pvpModeCombatTimeout, pvpModeInvulnerabilityTimeRegionChange, pvpModeInvulnerabilityTimeCommand, pvpModeRegionEnterCooldown, pvpModeRegionLeaveCooldown; - public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills, minCombatLevel; + public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills, minCombatLevel, maxCombatLevelDifference; public final List combatLogDamageCauses = new ArrayList<>(); private final FileConfiguration messages; @@ -145,6 +145,7 @@ public class ConfigManager { pvpModeInvulnerabilityTimeRegionChange = config.getDouble("pvp_mode.invulnerability.time.region_change"); pvpModeInvulnerabilityCanDamage = config.getBoolean("pvp_mode.invulnerability.can_damage"); minCombatLevel = config.getInt("pvp_mode.min_level"); + maxCombatLevelDifference = config.getInt("pvp_mode.max_level_difference"); // Resources staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN); diff --git a/MMOCore-Dist/src/main/resources/config.yml b/MMOCore-Dist/src/main/resources/config.yml index e30e3bac..1ad31185 100644 --- a/MMOCore-Dist/src/main/resources/config.yml +++ b/MMOCore-Dist/src/main/resources/config.yml @@ -293,6 +293,10 @@ pvp_mode: # Set to 0 to fully disable min_level: 0 + # Maximum level difference in order to fight other players. + # Set to 0 to fully disable + max_level_difference: 10 + # Delay after any attack during which the player will stay in PvP Mode (seconds) # Has to be lower than 'cooldown.combat' combat_timeout: 30 diff --git a/MMOCore-Dist/src/main/resources/default/messages.yml b/MMOCore-Dist/src/main/resources/default/messages.yml index 1fa73d39..06f11f18 100644 --- a/MMOCore-Dist/src/main/resources/default/messages.yml +++ b/MMOCore-Dist/src/main/resources/default/messages.yml @@ -35,6 +35,7 @@ pvp-mode: # When you cannot hit another player cannot-hit: + high-level-difference: '&cLevel difference is too high to fight this player.' low-level-target: '&cYou cannot fight this player as their level is too low.' low-level-self: '&cYour level is too low to fight other players.' pvp-mode-disabled-target: '&cThis player has not toggled on PvP.'