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");
|
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);
|
return WorldGuard.getInstance().getPlatform().getSessionManager().registerHandler(factory, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,10 +42,21 @@ public class PvPModeListener implements Listener {
|
|||||||
if (source == null)
|
if (source == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check for target's invulnerability BEFORE pvp-mode flag because it can also
|
// The first code portion applies to any region, not only PvpMode
|
||||||
// happen when the option pvp_mode.invulnerability.apply_to_pvp_flag is on
|
|
||||||
|
// Check for minimum level
|
||||||
final Player target = (Player) event.getEntity();
|
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 (targetData.getCombat().isInvulnerable()) {
|
||||||
if (event.getDamage() > 0) {
|
if (event.getDamage() > 0) {
|
||||||
final long left = targetData.getCombat().getInvulnerableTill() - System.currentTimeMillis();
|
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
|
// If attacker is still invulnerable and cannot deal damage
|
||||||
final PlayerData sourceData = PlayerData.get(source);
|
|
||||||
if (!MMOCore.plugin.configManager.pvpModeInvulnerabilityCanDamage && sourceData.getCombat().isInvulnerable()) {
|
if (!MMOCore.plugin.configManager.pvpModeInvulnerabilityCanDamage && sourceData.getCombat().isInvulnerable()) {
|
||||||
if (event.getDamage() > 0) {
|
if (event.getDamage() > 0) {
|
||||||
final long left = sourceData.getCombat().getInvulnerableTill() - System.currentTimeMillis();
|
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))
|
if (!MythicLib.plugin.getFlags().isFlagAllowed(target.getLocation(), CustomFlag.PVP_MODE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Starting from here, this only applies to PvpMode-regions.
|
||||||
|
|
||||||
// Defender has not enabled PvP mode
|
// Defender has not enabled PvP mode
|
||||||
if (!targetData.getCombat().isInPvpMode()) {
|
if (!targetData.getCombat().isInPvpMode()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -27,14 +27,14 @@ import java.util.logging.Level;
|
|||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
public final CommandVerbose commandVerbose = new CommandVerbose();
|
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;
|
pvpModeEnabled, pvpModeInvulnerabilityCanDamage;
|
||||||
public String partyChatPrefix, noSkillBoundPlaceholder;
|
public String partyChatPrefix, noSkillBoundPlaceholder;
|
||||||
public ChatColor staminaFull, staminaHalf, staminaEmpty;
|
public ChatColor staminaFull, staminaHalf, staminaEmpty;
|
||||||
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;
|
public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills, minCombatLevel;
|
||||||
public final List<EntityDamageEvent.DamageCause> combatLogDamageCauses = new ArrayList<>();
|
public final List<EntityDamageEvent.DamageCause> combatLogDamageCauses = new ArrayList<>();
|
||||||
|
|
||||||
private final FileConfiguration messages;
|
private final FileConfiguration messages;
|
||||||
@ -144,6 +144,7 @@ public class ConfigManager {
|
|||||||
pvpModeInvulnerabilityTimeCommand = config.getDouble("pvp_mode.invulnerability.time.command");
|
pvpModeInvulnerabilityTimeCommand = config.getDouble("pvp_mode.invulnerability.time.command");
|
||||||
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");
|
||||||
|
|
||||||
// Resources
|
// Resources
|
||||||
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);
|
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);
|
||||||
|
@ -217,19 +217,10 @@ hotbar-swapping:
|
|||||||
# If the player has to sneak to swap hotbars
|
# If the player has to sneak to swap hotbars
|
||||||
crouching: true
|
crouching: true
|
||||||
|
|
||||||
# Set this to true to allow players
|
# Set this to true to allow players in
|
||||||
# in creative mode to enter casting mode
|
# creative mode to enter casting mode
|
||||||
can-creative-cast: false
|
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.
|
# Prevents mobs spawned from spawners from giving MMO XP points.
|
||||||
prevent-spawner-xp: true
|
prevent-spawner-xp: true
|
||||||
|
|
||||||
@ -298,6 +289,10 @@ pvp_mode:
|
|||||||
# Requires /reload when changed
|
# Requires /reload when changed
|
||||||
enabled: false
|
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)
|
# 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
|
||||||
@ -314,8 +309,8 @@ pvp_mode:
|
|||||||
# to end this invulnerable time period.
|
# to end this invulnerable time period.
|
||||||
can_damage: false
|
can_damage: false
|
||||||
|
|
||||||
# When enabled, leaving a no-PVP zone and entering a PVP zone
|
# When enabled, leaving a no-PVP zone and entering a
|
||||||
# will apply the SAME invulnerability time.
|
# PVP zone will apply the SAME invulnerability time.
|
||||||
# Requires /reload when changed
|
# Requires /reload when changed
|
||||||
apply_to_pvp_flag: false
|
apply_to_pvp_flag: false
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user