diff --git a/.vscode/settings.json b/.vscode/settings.json index 9d16c36..f90d5c3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -21,6 +21,7 @@ "mkdir", "npcs", "sqlite", + "staysafe", "teamcolors", "testremove", "unban", diff --git a/varo/src/main/java/de/cliffbreak/varo/managers/GameTimeManager.java b/varo/src/main/java/de/cliffbreak/varo/managers/GameTimeManager.java index 6b0c552..61d459c 100644 --- a/varo/src/main/java/de/cliffbreak/varo/managers/GameTimeManager.java +++ b/varo/src/main/java/de/cliffbreak/varo/managers/GameTimeManager.java @@ -7,6 +7,7 @@ import java.time.LocalTime; import java.time.ZoneId; import java.time.temporal.ChronoUnit; +import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitRunnable; import de.cliffbreak.varo.Varo; @@ -14,12 +15,11 @@ import de.cliffbreak.varo.Varo; public class GameTimeManager { private final Varo plugin; - // private static final int firstPlayTimeMinutes = 50; + private static final int firstPlayTimeMinutes = 50; private static final int firstPlayTimeLoginMinutes = 10; - private static final int protectionPeriodMinutes = 2; - private static final int firstPlayTimeMinutes = 2; // private static final int firstPlayTimeMinutes = 360; // private static final int protectionPeriodMinutes = 11; + private static final int protectionPeriodMinutes = 4; // private static final LocalTime firstPlayStart = LocalTime.of(19, 20, 00); private static final LocalTime firstPlayStart = LocalTime.now().plusMinutes(1); private static final int firstRoundPreStartMinutes = 1; @@ -124,6 +124,12 @@ public class GameTimeManager { } else if (currentDay() == 1 && (timeDelta <= firstRoundPreStartMinutes * -60 && timeDelta > protectionPeriodMinutes * -60)) { plugin.getGameManager().setProtectionPhase(); + if ((timeDelta - protectionPeriodMinutes * -60) % 60 == 0) { + Bukkit.broadcastMessage(plugin.getLangUtils().get("Service.Protection").replace("%minutes%", + "" + (timeDelta - protectionPeriodMinutes * -60) / 60)); + } else if ((timeDelta - protectionPeriodMinutes * -60) == 1) { + Bukkit.broadcastMessage(plugin.getLangUtils().get("Service.ProtectionOver")); + } } else if (currentDay() > 1 && (timeDelta <= 0 && timeDelta > playTimeSeconds * -1)) { plugin.getGameManager().setIngame(); } else if (currentDay() == 1 diff --git a/varo/src/main/java/de/cliffbreak/varo/managers/NPCManager.java b/varo/src/main/java/de/cliffbreak/varo/managers/NPCManager.java index dc16d60..0be882e 100644 --- a/varo/src/main/java/de/cliffbreak/varo/managers/NPCManager.java +++ b/varo/src/main/java/de/cliffbreak/varo/managers/NPCManager.java @@ -200,9 +200,13 @@ public class NPCManager { public void addDamage(final Player damager, final int id, final double damage, final boolean isCritical) { for (final EntityPlayer npc : this.npcs) { if (npc.getId() == id) { + final World world = npc.getWorld().getWorld(); + if (!world.getPVP()) { + // Don't add damage if PVP is disabled + return; + } npc.setHealth((float) (npc.getHealth() - damage)); - final World world = npc.getWorld().getWorld(); final Location loc = new Location(world, npc.locX(), npc.locY(), npc.locZ()); if (npc.getHealth() > 0.0F) { for (final Player connectionPlayer : Bukkit.getOnlinePlayers()) { diff --git a/varo/src/main/java/de/cliffbreak/varo/utils/LangUtils.java b/varo/src/main/java/de/cliffbreak/varo/utils/LangUtils.java index f4051ba..93078e0 100644 --- a/varo/src/main/java/de/cliffbreak/varo/utils/LangUtils.java +++ b/varo/src/main/java/de/cliffbreak/varo/utils/LangUtils.java @@ -23,6 +23,10 @@ public class LangUtils { this.config.addDefault("Service.LoadingCountdown", "§r§l Noch: %02d:%02d"); this.config.addDefault("Service.BannedDead", "§4Du bist gestorben.\n \n§cDamit bist du aus §eVaro§c ausgeschieden."); + this.config.addDefault("Service.Protection", + "§ aDie Schutzzeit ist in §2§l%minutes% Minuten§r§a vorbei. §r§7§o#staysafe"); + this.config.addDefault("Service.ProtectionOver", + " §c§lAchtung: §r§aDie Schutzzeit ist§2§l JETZT§r§a vorbei. §r§7§o#staysafe"); this.config.addDefault("Error.NoPlayer", "§c§lFehler:§r§c Dieses Kommando kann nur durch einen Spieler ausgeführt werden."); this.config.addDefault("Error.ResourcepackDeclined",