forked from Upstream/mmocore
Added invulnerability when using /pvpmode inside of region
This commit is contained in:
parent
9bd830efb7
commit
07a61b900e
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmocore.command;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.comp.flags.CustomFlag;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.command.api.RegisteredCommand;
|
||||
@ -39,7 +40,17 @@ public class PvpModeCommand extends RegisteredCommand {
|
||||
|
||||
playerData.getCombat().setPvpMode(!playerData.getCombat().isInPvpMode());
|
||||
playerData.getCooldownMap().applyCooldown(COOLDOWN_KEY, playerData.getCombat().isInPvpMode() ? MMOCore.plugin.configManager.pvpModeToggleOnCooldown : MMOCore.plugin.configManager.pvpModeToggleOffCooldown);
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.toggle-" + (playerData.getCombat().isInPvpMode() ? "on" : "off")).send((Player) sender);
|
||||
|
||||
// Toggling on when in PVP region
|
||||
if (playerData.getCombat().isInPvpMode() &&
|
||||
MythicLib.plugin.getFlags().isFlagAllowed(playerData.getPlayer(), CustomFlag.PVP_MODE)) {
|
||||
playerData.getCombat().applyInvulnerability();
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.toggle.on-invulnerable", "time",
|
||||
MythicLib.plugin.getMMOConfig().decimal.format(MMOCore.plugin.configManager.pvpModeInvulnerability)).send(playerData.getPlayer());
|
||||
|
||||
// Just send message otherwise
|
||||
} else
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.toggle." + (playerData.getCombat().isInPvpMode() ? "on" : "off")).send((Player) sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -82,8 +82,8 @@ public class PvPModeHandler extends FlagValueChangeHandler<State> {
|
||||
final String msgPath = (playerData.getCombat().isInPvpMode() && !playerData.getCombat().canQuitPvpMode()) ? "allowed" : "denied";
|
||||
lastMessage = System.currentTimeMillis();
|
||||
final double remaining = (playerData.getCombat().getLastHit() + MMOCore.plugin.configManager.pvpModeCombatTimeout * 1000.0D - System.currentTimeMillis()) / 1000.0D;
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.leave.pvp-" + msgPath, new String[]{"remaining",
|
||||
(MythicLib.plugin.getMMOConfig()).decimal.format(remaining)}).send(playerData.getPlayer());
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.leave.pvp-" + msgPath, "remaining",
|
||||
(MythicLib.plugin.getMMOConfig()).decimal.format(remaining)).send(playerData.getPlayer());
|
||||
}
|
||||
} else if (newPvpMode && !lastPvpMode) {
|
||||
|
||||
@ -95,8 +95,8 @@ public class PvPModeHandler extends FlagValueChangeHandler<State> {
|
||||
// Send message
|
||||
if (canSendMessage()) {
|
||||
lastMessage = System.currentTimeMillis();
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.enter.pvp-mode-" + (applyInvulnerability ? "on" : "off"), new String[]{"time",
|
||||
(MythicLib.plugin.getMMOConfig()).decimal.format(MMOCore.plugin.configManager.pvpModeInvulnerability)}).send(playerData.getPlayer());
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.enter.pvp-mode-" + (applyInvulnerability ? "on" : "off"), "time",
|
||||
MythicLib.plugin.getMMOConfig().decimal.format(MMOCore.plugin.configManager.pvpModeInvulnerability)).send(playerData.getPlayer());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -32,8 +32,14 @@ booster-expired: '&cExpired!'
|
||||
# PvP Mode
|
||||
pvp-mode:
|
||||
cooldown: '&cPlease wait {remaining} seconds to use this command again.'
|
||||
toggle-on: '&aPvP Mode on.'
|
||||
toggle-off: '&cPvP Mode off.'
|
||||
|
||||
# When using /pvpmode
|
||||
toggle:
|
||||
on: '&aPvP Mode on.'
|
||||
on-invulnerable: '&aPvP Mode on. You are now invulnerable for {time} seconds.'
|
||||
off: '&cPvP Mode off.'
|
||||
|
||||
# Entering/leaving regions with specific flag value
|
||||
leave:
|
||||
pvp-allowed: '&cYou left a PVP zone but are still vulnerable for {remaining} seconds!'
|
||||
pvp-denied: '&cYou left the PVP zone.'
|
||||
|
Loading…
Reference in New Issue
Block a user