feat: show animation during cooldown

This commit is contained in:
Simon Giesel 2020-05-19 22:06:17 +02:00
parent 59c5b5cec9
commit 190be306ef

View file

@ -5,15 +5,22 @@ import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import com.destroystokyo.paper.Title;
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import de.cliffbreak.varo.Varo;
import de.cliffbreak.varo.uitls.PacketReader;
@ -35,12 +42,15 @@ public class PlayerJoinQuitListener implements Listener {
"hat den Server verlassen."));
}
this.plugin.getTeamManager().setAFK(e.getPlayer().getName());
if (!e.getPlayer().getLocation().getWorld().getEnvironment().equals(Environment.THE_END)) {
this.plugin.getPlayerCache().setPlayerLocationCache(e.getPlayer().getUniqueId().toString().replace("-", ""),
e.getPlayer().getLocation());
}
}
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent e) {
e.setJoinMessage(null);
this.plugin.getNPCManager().removeClone(e.getPlayer());
this.plugin.getNPCManager().syncClones(e.getPlayer());
this.plugin.getTeamManager().setTeam(e.getPlayer());
@ -52,11 +62,6 @@ public class PlayerJoinQuitListener implements Listener {
Bukkit.broadcast(
this.plugin.getMessageUtils().getServiceMessage(e.getPlayer().getName(), "hat den Server betreten."));
if (this.plugin.getConfig().getBoolean("Varo.Debug")) {
e.getPlayer().sendMessage("\n§7§l######### §9Cliffbreak.de - §lVaro §7§l#########\n \n"
+ " §cWarning: §r§c Plugin is running in DEBUG mode!\n ");
}
new BukkitRunnable() {
@Override
public void run() {
@ -64,6 +69,44 @@ public class PlayerJoinQuitListener implements Listener {
"73046237cc843964dbe32fb9c76c0144cdbf90af");
}
}.runTaskLater(plugin, 5); // wait 5 ticks
// Login cooldown + Animation
final Player p = e.getPlayer();
World w = null;
for (World world : Bukkit.getWorlds()) {
if (world.getEnvironment().equals(Environment.THE_END)) {
w = world;
}
}
p.teleport(new Location(w, 0, 0, 100));
p.setGameMode(GameMode.SPECTATOR);
p.setFlying(true);
p.setFlySpeed(0.0f);
final Title title = new Title("Varo 2020", "Bitte warte, bis das Spiel geladen hat...", 20, 8 * 20, 20);
p.sendTitle(title);
final BukkitTask hidePlayersTask = new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers())
p.hidePlayer(plugin, player);
}
}.runTaskTimer(this.plugin, 0l, 1l);
new BukkitRunnable() {
@Override
public void run() {
plugin.getNPCManager().removeClone(e.getPlayer());
p.setGameMode(GameMode.SURVIVAL);
p.setFlySpeed(0.1f);
p.setFlying(false);
p.teleport(plugin.getPlayerCache().getPlayerLocationCache(p.getUniqueId().toString().replace("-", "")));
hidePlayersTask.cancel();
for (Player player : Bukkit.getOnlinePlayers())
p.showPlayer(plugin, player);
}
}.runTaskLater(this.plugin, 10 * 20);
}
@EventHandler