no pvp damage event fix
This commit is contained in:
parent
90b4375853
commit
0416f4bfd2
4 changed files with 18 additions and 6 deletions
|
@ -20,6 +20,7 @@
|
||||||
package net.tylermurphy.hideAndSeek.game;
|
package net.tylermurphy.hideAndSeek.game;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -271,9 +272,9 @@ public class Board {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTeam(Player player) {
|
private static String getTeam(Player player) {
|
||||||
if(isHider(player)) return ChatColor.GOLD + "HIDER";
|
if(isHider(player)) return message("HIDER_TEAM_NAME").toString();
|
||||||
else if(isSeeker(player)) return ChatColor.RED + "SEEKER";
|
else if(isSeeker(player)) return message("SEEKER_TEAM_NAME").toString();
|
||||||
else if(isSpectator(player)) return ChatColor.GRAY + "SPECTATOR";
|
else if(isSpectator(player)) return message("SPECTATOR_TEAM_NAME").toString();
|
||||||
else return ChatColor.WHITE + "UNKNOWN";
|
else return ChatColor.WHITE + "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,10 +189,19 @@ public class EventListener implements Listener {
|
||||||
}
|
}
|
||||||
if(event.isCancelled()) return;
|
if(event.isCancelled()) return;
|
||||||
if (player.getHealth() - event.getFinalDamage() < 0.5 || !pvpEnabled) {
|
if (player.getHealth() - event.getFinalDamage() < 0.5 || !pvpEnabled) {
|
||||||
if(!pvpEnabled && !Board.isSeeker(player)){
|
if (event instanceof EntityDamageByEntityEvent && !pvpEnabled) {
|
||||||
|
Entity damager = ((EntityDamageByEntityEvent) event).getDamager();
|
||||||
|
if (damager instanceof Player) {
|
||||||
|
Player atacker = (Player) damager;
|
||||||
|
if(!Board.isSeeker(atacker)){
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (spawnPosition == null) return;
|
if (spawnPosition == null) return;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if(Version.atLeast("1.9")) {
|
if(Version.atLeast("1.9")) {
|
||||||
|
|
|
@ -58,6 +58,7 @@ Localization:
|
||||||
STOP: "Das Spiel wurde gestoppt."
|
STOP: "Das Spiel wurde gestoppt."
|
||||||
HIDER_TEAM_NAME: "&6&lHIDER"
|
HIDER_TEAM_NAME: "&6&lHIDER"
|
||||||
SEEKER_TEAM_NAME: "&c&lSEEKER"
|
SEEKER_TEAM_NAME: "&c&lSEEKER"
|
||||||
|
SPECTATOR_TEAM_NAME: "&8&lSPECTATOR"
|
||||||
HIDERS_SUBTITLE: "Verstecke dich gut vor den Seekern!"
|
HIDERS_SUBTITLE: "Verstecke dich gut vor den Seekern!"
|
||||||
SEEKERS_SUBTITLE: "Finde alle Hider!"
|
SEEKERS_SUBTITLE: "Finde alle Hider!"
|
||||||
SPECTATOR_SUBTITLE: "Du bist mitten im spiel beigetreten."
|
SPECTATOR_SUBTITLE: "Du bist mitten im spiel beigetreten."
|
||||||
|
|
|
@ -59,6 +59,7 @@ Localization:
|
||||||
STOP: "Game has been force stopped."
|
STOP: "Game has been force stopped."
|
||||||
HIDER_TEAM_NAME: "&6&lHIDER"
|
HIDER_TEAM_NAME: "&6&lHIDER"
|
||||||
SEEKER_TEAM_NAME: "&c&lSEEKER"
|
SEEKER_TEAM_NAME: "&c&lSEEKER"
|
||||||
|
SPECTATOR_TEAM_NAME: "&8&lSPECTATOR"
|
||||||
HIDERS_SUBTITLE: "Hide away from the seekers"
|
HIDERS_SUBTITLE: "Hide away from the seekers"
|
||||||
SEEKERS_SUBTITLE: "Eliminate all hiders"
|
SEEKERS_SUBTITLE: "Eliminate all hiders"
|
||||||
SPECTATOR_SUBTITLE: "You joined mid-game."
|
SPECTATOR_SUBTITLE: "You joined mid-game."
|
||||||
|
|
Loading…
Reference in a new issue