forked from Upstream/mmocore
Min combat level
This commit is contained in:
parent
482eeb9e8b
commit
fe2340f8cb
@ -22,7 +22,7 @@ public class PvPModeListener implements Listener {
|
||||
Validate.isTrue(registerHandler(PvPFlagHandler.FACTORY), "Could not register WG handler for PvP");
|
||||
}
|
||||
|
||||
private boolean registerHandler(Handler.Factory factory) {
|
||||
private boolean registerHandler(Handler.Factory<?> factory) {
|
||||
return WorldGuard.getInstance().getPlatform().getSessionManager().registerHandler(factory, null);
|
||||
}
|
||||
|
||||
@ -42,10 +42,21 @@ public class PvPModeListener implements Listener {
|
||||
if (source == null)
|
||||
return;
|
||||
|
||||
// Check for target's invulnerability BEFORE pvp-mode flag because it can also
|
||||
// happen when the option pvp_mode.invulnerability.apply_to_pvp_flag is on
|
||||
// The first code portion applies to any region, not only PvpMode
|
||||
|
||||
// Check for minimum level
|
||||
final Player target = (Player) event.getEntity();
|
||||
final PlayerData targetData = PlayerData.get(target);
|
||||
final PlayerData targetData = PlayerData.get(target), sourceData = PlayerData.get(source);
|
||||
final int minLevel = MMOCore.plugin.configManager.minCombatLevel;
|
||||
if (minLevel > 0 && (targetData.getLevel() < minLevel || sourceData.getLevel() < minLevel)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for target's invulnerability BEFORE pvp-mode flag because it can also
|
||||
* happen when the option pvp_mode.invulnerability.apply_to_pvp_flag is on
|
||||
*/
|
||||
if (targetData.getCombat().isInvulnerable()) {
|
||||
if (event.getDamage() > 0) {
|
||||
final long left = targetData.getCombat().getInvulnerableTill() - System.currentTimeMillis();
|
||||
@ -57,7 +68,6 @@ public class PvPModeListener implements Listener {
|
||||
}
|
||||
|
||||
// If attacker is still invulnerable and cannot deal damage
|
||||
final PlayerData sourceData = PlayerData.get(source);
|
||||
if (!MMOCore.plugin.configManager.pvpModeInvulnerabilityCanDamage && sourceData.getCombat().isInvulnerable()) {
|
||||
if (event.getDamage() > 0) {
|
||||
final long left = sourceData.getCombat().getInvulnerableTill() - System.currentTimeMillis();
|
||||
@ -72,6 +82,8 @@ public class PvPModeListener implements Listener {
|
||||
if (!MythicLib.plugin.getFlags().isFlagAllowed(target.getLocation(), CustomFlag.PVP_MODE))
|
||||
return;
|
||||
|
||||
// Starting from here, this only applies to PvpMode-regions.
|
||||
|
||||
// Defender has not enabled PvP mode
|
||||
if (!targetData.getCombat().isInPvpMode()) {
|
||||
event.setCancelled(true);
|
||||
|
@ -27,14 +27,14 @@ import java.util.logging.Level;
|
||||
public class ConfigManager {
|
||||
public final CommandVerbose commandVerbose = new CommandVerbose();
|
||||
|
||||
public boolean overrideVanillaExp, canCreativeCast, passiveSkillNeedBound, cobbleGeneratorXP, saveDefaultClassInfo, attributesAsClassInfo, splitProfessionExp, disableQuestBossBar,
|
||||
public boolean overrideVanillaExp, canCreativeCast, passiveSkillNeedBound, cobbleGeneratorXP, saveDefaultClassInfo, splitProfessionExp, disableQuestBossBar,
|
||||
pvpModeEnabled, pvpModeInvulnerabilityCanDamage;
|
||||
public String partyChatPrefix, noSkillBoundPlaceholder;
|
||||
public ChatColor staminaFull, staminaHalf, staminaEmpty;
|
||||
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;
|
||||
public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills, minCombatLevel;
|
||||
public final List<EntityDamageEvent.DamageCause> combatLogDamageCauses = new ArrayList<>();
|
||||
|
||||
private final FileConfiguration messages;
|
||||
@ -144,6 +144,7 @@ public class ConfigManager {
|
||||
pvpModeInvulnerabilityTimeCommand = config.getDouble("pvp_mode.invulnerability.time.command");
|
||||
pvpModeInvulnerabilityTimeRegionChange = config.getDouble("pvp_mode.invulnerability.time.region_change");
|
||||
pvpModeInvulnerabilityCanDamage = config.getBoolean("pvp_mode.invulnerability.can_damage");
|
||||
minCombatLevel = config.getInt("pvp_mode.min_level");
|
||||
|
||||
// Resources
|
||||
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);
|
||||
|
@ -217,19 +217,10 @@ hotbar-swapping:
|
||||
# If the player has to sneak to swap hotbars
|
||||
crouching: true
|
||||
|
||||
# Set this to true to allow players
|
||||
# in creative mode to enter casting mode
|
||||
# Set this to true to allow players in
|
||||
# creative mode to enter casting mode
|
||||
can-creative-cast: false
|
||||
|
||||
# Not implemented yet
|
||||
ability-targeting-options:
|
||||
|
||||
# Prevent heals/buffs on players in a different guild
|
||||
cant-heal-enemies: true
|
||||
|
||||
# Prevent heals/buffs UNLESS the player is in your party/guild
|
||||
cant-heal-neutrals: false
|
||||
|
||||
# Prevents mobs spawned from spawners from giving MMO XP points.
|
||||
prevent-spawner-xp: true
|
||||
|
||||
@ -298,6 +289,10 @@ pvp_mode:
|
||||
# Requires /reload when changed
|
||||
enabled: false
|
||||
|
||||
# Minimum level in order to fight other players.
|
||||
# Set to 0 to fully disable
|
||||
min_level: 0
|
||||
|
||||
# Delay after any attack during which the player will stay in PvP Mode (seconds)
|
||||
# Has to be lower than 'cooldown.combat'
|
||||
combat_timeout: 30
|
||||
@ -314,8 +309,8 @@ pvp_mode:
|
||||
# to end this invulnerable time period.
|
||||
can_damage: false
|
||||
|
||||
# When enabled, leaving a no-PVP zone and entering a PVP zone
|
||||
# will apply the SAME invulnerability time.
|
||||
# When enabled, leaving a no-PVP zone and entering a
|
||||
# PVP zone will apply the SAME invulnerability time.
|
||||
# Requires /reload when changed
|
||||
apply_to_pvp_flag: false
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user