Max combat level difference

This commit is contained in:
Jules 2023-03-11 18:39:59 +01:00
parent b8624733da
commit e5743a7011
4 changed files with 15 additions and 1 deletions

View File

@ -63,6 +63,14 @@ public class PvPModeListener implements Listener {
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.cannot-hit.low-level-self").send(source); MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.cannot-hit.low-level-self").send(source);
return; 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;
}
} }
/* /*

View File

@ -34,7 +34,7 @@ public class ConfigManager {
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown; public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
public double lootChestsChanceWeight, dropItemsChanceWeight, fishingDropsChanceWeight, partyMaxExpSplitRange, pvpModeToggleOnCooldown, pvpModeToggleOffCooldown, pvpModeCombatCooldown, public double lootChestsChanceWeight, dropItemsChanceWeight, fishingDropsChanceWeight, partyMaxExpSplitRange, pvpModeToggleOnCooldown, pvpModeToggleOffCooldown, pvpModeCombatCooldown,
pvpModeCombatTimeout, pvpModeInvulnerabilityTimeRegionChange, pvpModeInvulnerabilityTimeCommand, pvpModeRegionEnterCooldown, pvpModeRegionLeaveCooldown; pvpModeCombatTimeout, pvpModeInvulnerabilityTimeRegionChange, pvpModeInvulnerabilityTimeCommand, pvpModeRegionEnterCooldown, pvpModeRegionLeaveCooldown;
public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills, minCombatLevel; public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills, minCombatLevel, maxCombatLevelDifference;
public final List<EntityDamageEvent.DamageCause> combatLogDamageCauses = new ArrayList<>(); public final List<EntityDamageEvent.DamageCause> combatLogDamageCauses = new ArrayList<>();
private final FileConfiguration messages; private final FileConfiguration messages;
@ -145,6 +145,7 @@ public class ConfigManager {
pvpModeInvulnerabilityTimeRegionChange = config.getDouble("pvp_mode.invulnerability.time.region_change"); pvpModeInvulnerabilityTimeRegionChange = config.getDouble("pvp_mode.invulnerability.time.region_change");
pvpModeInvulnerabilityCanDamage = config.getBoolean("pvp_mode.invulnerability.can_damage"); pvpModeInvulnerabilityCanDamage = config.getBoolean("pvp_mode.invulnerability.can_damage");
minCombatLevel = config.getInt("pvp_mode.min_level"); minCombatLevel = config.getInt("pvp_mode.min_level");
maxCombatLevelDifference = config.getInt("pvp_mode.max_level_difference");
// Resources // Resources
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN); staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);

View File

@ -293,6 +293,10 @@ pvp_mode:
# Set to 0 to fully disable # Set to 0 to fully disable
min_level: 0 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) # Delay after any attack during which the player will stay in PvP Mode (seconds)
# Has to be lower than 'cooldown.combat' # Has to be lower than 'cooldown.combat'
combat_timeout: 30 combat_timeout: 30

View File

@ -35,6 +35,7 @@ pvp-mode:
# When you cannot hit another player # When you cannot hit another player
cannot-hit: 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-target: '&cYou cannot fight this player as their level is too low.'
low-level-self: '&cYour level is too low to fight other players.' low-level-self: '&cYour level is too low to fight other players.'
pvp-mode-disabled-target: '&cThis player has not toggled on PvP.' pvp-mode-disabled-target: '&cThis player has not toggled on PvP.'