forked from Upstream/mmocore
Fixed pvp mode
This commit is contained in:
parent
f23e520635
commit
4ae7fa4387
@ -81,20 +81,21 @@ public class PvPModeHandler extends FlagValueChangeHandler<State> {
|
||||
if (canSendMessage()) {
|
||||
final String msgPath = (playerData.getCombat().isInPvpMode() && !playerData.getCombat().canQuitPvpMode()) ? "allowed" : "denied";
|
||||
lastMessage = System.currentTimeMillis();
|
||||
double remaining = (playerData.getCombat().getLastHit() + MMOCore.plugin.configManager.pvpModeCombatTimeout * 1000.0D - System.currentTimeMillis()) / 1000.0D;
|
||||
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());
|
||||
}
|
||||
} else if (newPvpMode && !lastPvpMode) {
|
||||
|
||||
// Apply invulnerability
|
||||
if (playerData.getCombat().isInPvpMode())
|
||||
final boolean applyInvulnerability = playerData.getCombat().isInPvpMode() && playerData.getCombat().canQuitPvpMode();
|
||||
if (applyInvulnerability)
|
||||
playerData.getCombat().applyInvulnerability();
|
||||
|
||||
// Send message
|
||||
if (canSendMessage()) {
|
||||
lastMessage = System.currentTimeMillis();
|
||||
MMOCore.plugin.configManager.getSimpleMessage("pvp-mode.enter.pvp-mode-" + (playerData.getCombat().isInPvpMode() ? "on" : "off"), new String[]{"time",
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,12 @@ public class PvPModeListener implements Listener {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void unblockPvp(DisallowedPVPEvent event) {
|
||||
PlayerData defender;
|
||||
if (!PlayerData.get(event.getAttacker()).getCombat().isInPvpMode() || !(defender = PlayerData.get(event.getDefender())).getCombat().isInPvpMode())
|
||||
if (PlayerData.get(event.getAttacker()).getCombat().isInPvpMode() || !(defender = PlayerData.get(event.getDefender())).getCombat().isInPvpMode())
|
||||
return;
|
||||
|
||||
if (!defender.getCombat().canQuitPvpMode() ||
|
||||
(!defender.getCombat().isInvulnerable() && MythicLib.plugin.getFlags().isFlagAllowed(event.getDefender().getLocation(), CustomFlag.PVP_MODE)))
|
||||
if (MythicLib.plugin.getEntities().canInteract(event.getAttacker(), event.getDefender(), InteractionType.OFFENSE_ACTION, true))
|
||||
if (MythicLib.plugin.getEntities().checkPvpInteractionRules(event.getAttacker(), event.getDefender(), InteractionType.OFFENSE_ACTION, true))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user