feat: improve protection period

This commit is contained in:
Simon Giesel 2020-05-31 21:29:02 +02:00
parent c323ea7075
commit 764e0ac5ba
4 changed files with 19 additions and 4 deletions

View file

@ -21,6 +21,7 @@
"mkdir", "mkdir",
"npcs", "npcs",
"sqlite", "sqlite",
"staysafe",
"teamcolors", "teamcolors",
"testremove", "testremove",
"unban", "unban",

View file

@ -7,6 +7,7 @@ import java.time.LocalTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import de.cliffbreak.varo.Varo; import de.cliffbreak.varo.Varo;
@ -14,12 +15,11 @@ import de.cliffbreak.varo.Varo;
public class GameTimeManager { public class GameTimeManager {
private final Varo plugin; 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 firstPlayTimeLoginMinutes = 10;
private static final int protectionPeriodMinutes = 2;
private static final int firstPlayTimeMinutes = 2;
// private static final int firstPlayTimeMinutes = 360; // private static final int firstPlayTimeMinutes = 360;
// private static final int protectionPeriodMinutes = 11; // 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.of(19, 20, 00);
private static final LocalTime firstPlayStart = LocalTime.now().plusMinutes(1); private static final LocalTime firstPlayStart = LocalTime.now().plusMinutes(1);
private static final int firstRoundPreStartMinutes = 1; private static final int firstRoundPreStartMinutes = 1;
@ -124,6 +124,12 @@ public class GameTimeManager {
} else if (currentDay() == 1 && (timeDelta <= firstRoundPreStartMinutes * -60 } else if (currentDay() == 1 && (timeDelta <= firstRoundPreStartMinutes * -60
&& timeDelta > protectionPeriodMinutes * -60)) { && timeDelta > protectionPeriodMinutes * -60)) {
plugin.getGameManager().setProtectionPhase(); 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)) { } else if (currentDay() > 1 && (timeDelta <= 0 && timeDelta > playTimeSeconds * -1)) {
plugin.getGameManager().setIngame(); plugin.getGameManager().setIngame();
} else if (currentDay() == 1 } else if (currentDay() == 1

View file

@ -200,9 +200,13 @@ public class NPCManager {
public void addDamage(final Player damager, final int id, final double damage, final boolean isCritical) { public void addDamage(final Player damager, final int id, final double damage, final boolean isCritical) {
for (final EntityPlayer npc : this.npcs) { for (final EntityPlayer npc : this.npcs) {
if (npc.getId() == id) { 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)); npc.setHealth((float) (npc.getHealth() - damage));
final World world = npc.getWorld().getWorld();
final Location loc = new Location(world, npc.locX(), npc.locY(), npc.locZ()); final Location loc = new Location(world, npc.locX(), npc.locY(), npc.locZ());
if (npc.getHealth() > 0.0F) { if (npc.getHealth() > 0.0F) {
for (final Player connectionPlayer : Bukkit.getOnlinePlayers()) { for (final Player connectionPlayer : Bukkit.getOnlinePlayers()) {

View file

@ -23,6 +23,10 @@ public class LangUtils {
this.config.addDefault("Service.LoadingCountdown", "§r§l Noch: %02d:%02d"); this.config.addDefault("Service.LoadingCountdown", "§r§l Noch: %02d:%02d");
this.config.addDefault("Service.BannedDead", this.config.addDefault("Service.BannedDead",
"§4Du bist gestorben.\n \n§cDamit bist du aus §eVaro§c ausgeschieden."); "§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", this.config.addDefault("Error.NoPlayer",
"§c§lFehler:§r§c Dieses Kommando kann nur durch einen Spieler ausgeführt werden."); "§c§lFehler:§r§c Dieses Kommando kann nur durch einen Spieler ausgeführt werden.");
this.config.addDefault("Error.ResourcepackDeclined", this.config.addDefault("Error.ResourcepackDeclined",