feat: add border shrinking
This commit is contained in:
parent
92786862cd
commit
876d718ccb
4 changed files with 44 additions and 16 deletions
|
@ -80,7 +80,7 @@ public class Varo extends JavaPlugin {
|
|||
this.config.addDefault("Varo.Bans", new ArrayList<String>());
|
||||
this.config.addDefault("Varo.Border.X", 0);
|
||||
this.config.addDefault("Varo.Border.Z", 0);
|
||||
this.config.addDefault("Varo.Border.Size", 4000); // 2.000x2.000
|
||||
this.config.addDefault("Varo.Border.Size", 1250 * 2); // 1.250x1.250
|
||||
this.config.addDefault("Varo.Border.NextSize", this.config.getDefaults().get("Varo.Border.Size"));
|
||||
this.config.addDefault("Varo.Border.LastUpdate", Instant.now().toEpochMilli());
|
||||
this.config.options().copyDefaults(true);
|
||||
|
|
|
@ -28,7 +28,6 @@ public class PlayerJoinQuitListener implements Listener {
|
|||
if (!this.plugin.getTeamManager().hasTeam(e.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
this.plugin.getTeamManager().setAFK(e.getPlayer().getName());
|
||||
if (!this.plugin.getBanUtils().isBanned(e.getPlayer().getUniqueId())) {
|
||||
Bukkit.broadcast(this.plugin.getMessageUtils().getServiceMessage(e.getPlayer().getName(),
|
||||
"hat den Server verlassen."));
|
||||
|
@ -41,6 +40,7 @@ public class PlayerJoinQuitListener implements Listener {
|
|||
&& !this.plugin.getBanUtils().isBanned(e.getPlayer().getUniqueId())) {
|
||||
this.plugin.getNPCManager().createClone(e.getPlayer());
|
||||
}
|
||||
this.plugin.getTeamManager().setAFK(e.getPlayer().getName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.cliffbreak.varo.managers;
|
|||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
@ -23,8 +24,8 @@ public class BorderManager {
|
|||
final int size = this.plugin.getConfig().getInt("Varo.Border.Size");
|
||||
final int x = this.plugin.getConfig().getInt("Varo.Border.X");
|
||||
final int z = this.plugin.getConfig().getInt("Varo.Border.Z");
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
Environment env = world.getEnvironment();
|
||||
for (final World world : Bukkit.getWorlds()) {
|
||||
final Environment env = world.getEnvironment();
|
||||
if (env.equals(Environment.THE_END))
|
||||
continue;
|
||||
final WorldBorder border = world.getWorldBorder();
|
||||
|
@ -33,23 +34,46 @@ public class BorderManager {
|
|||
border.setSize(env.equals(Environment.NORMAL) ? size : (size / 8));
|
||||
border.setWarningDistance(25);
|
||||
border.setWarningTime(0);
|
||||
border.setDamageAmount(1);
|
||||
border.setDamageAmount(0.2);
|
||||
border.setDamageBuffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
public LocalDateTime shrinkBorder() {
|
||||
this.plugin.getConfig().set("Varo.Border.LastUpdate", Instant.now().toEpochMilli());
|
||||
int size = this.plugin.getConfig().getInt("Varo.Border.NextSize");
|
||||
size = size - 150; // 75*2 for both directions
|
||||
private void setBorderSize(final int size, final int time) {
|
||||
System.out.println("Size: " + size);
|
||||
System.out.println("Time: " + time);
|
||||
for (final World world : Bukkit.getWorlds()) {
|
||||
final Environment env = world.getEnvironment();
|
||||
if (env.equals(Environment.THE_END))
|
||||
continue;
|
||||
final WorldBorder border = world.getWorldBorder();
|
||||
border.setSize(env.equals(Environment.NORMAL) ? size : (size / 8), (long) time);
|
||||
}
|
||||
}
|
||||
|
||||
public void shrinkBorder(final int playTimeSeconds) {
|
||||
final int size = this.plugin.getConfig().getInt("Varo.Border.NextSize");
|
||||
this.setBorderSize(size, playTimeSeconds);
|
||||
this.plugin.getConfig().set("Varo.Border.Size", size);
|
||||
this.plugin.saveConfig();
|
||||
return LocalDateTime.now();
|
||||
}
|
||||
|
||||
public LocalDateTime broadcastBorderShrink() {
|
||||
final Instant curr = Instant.now();
|
||||
this.plugin.getConfig().set("Varo.Border.LastUpdate", curr.toEpochMilli());
|
||||
int size = this.plugin.getConfig().getInt("Varo.Border.NextSize");
|
||||
size = size - 110; // 55*2 for both directions
|
||||
this.plugin.getConfig().set("Varo.Border.NextSize", size);
|
||||
this.plugin.saveConfig();
|
||||
this.plugin.getDiscordBot()
|
||||
.broadcastMessage("@everyone In 30 Minuten geht es los!\nDie Border schrumpft heute auf " + size / 2
|
||||
+ "x" + size / 2 + " Blöcke.");
|
||||
return curr.atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
}
|
||||
|
||||
public int addPlayerDeath() {
|
||||
int size = this.plugin.getConfig().getInt("Varo.Border.NextSize");
|
||||
size = size - 50; // 25*2 for both directions
|
||||
size = size - 40; // 20*2 for both directions
|
||||
this.plugin.getConfig().set("Varo.Border.NextSize", size);
|
||||
this.plugin.saveConfig();
|
||||
return size;
|
||||
|
|
|
@ -20,10 +20,12 @@ public class GameTimeManager {
|
|||
private static final int firstPlayTimeMinutes = 50;
|
||||
private static final int firstPlayTimeLoginMinutes = 10;
|
||||
private static final LocalTime firstPlayStart = LocalTime.of(19, 10, 00);
|
||||
// private static final int playTimeMinutes = 30;
|
||||
private static final int playTimeMinutes = 250;
|
||||
private static final int playTimeMinutes = 30;
|
||||
private static final int playTimeLoginMinutes = 5;
|
||||
private static final LocalTime playStart = LocalTime.of(19, 30, 00);
|
||||
// private static final LocalTime playStart = LocalTime.now().plusMinutes(30);
|
||||
// private static final LocalTime playStart = LocalTime.now().plusMinutes(1);
|
||||
// private static final LocalTime playStart = LocalTime.now();
|
||||
|
||||
public GameTimeManager(final Varo plugin) {
|
||||
this.plugin = plugin;
|
||||
|
@ -127,7 +129,6 @@ public class GameTimeManager {
|
|||
@Override
|
||||
public void run() {
|
||||
final LocalDateTime now = LocalDateTime.now();
|
||||
System.out.println(lastUpdate);
|
||||
if (lastUpdate.getDayOfYear() < now.getDayOfYear()) {
|
||||
if (currentDay() <= 1) {
|
||||
System.out.println("Day 1 or smaller");
|
||||
|
@ -136,11 +137,14 @@ public class GameTimeManager {
|
|||
if (now.getHour() == playStart.minusMinutes(30).getHour()
|
||||
&& now.getMinute() == playStart.minusMinutes(30).getMinute()) {
|
||||
System.out.println("Shrinking Border");
|
||||
lastUpdate = plugin.getBorderManager().shrinkBorder();
|
||||
lastUpdate = plugin.getBorderManager().broadcastBorderShrink();
|
||||
}
|
||||
}
|
||||
if (now.getHour() == playStart.getHour() && now.getMinute() == playStart.getMinute()) {
|
||||
System.out.println("Shrinking Border");
|
||||
plugin.getBorderManager().shrinkBorder(playTimeMinutes * 60);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(this.plugin, 0, 60 * 20);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue