46 lines
1.5 KiB
Java
46 lines
1.5 KiB
Java
/*
|
|
* Copyright (c) 2017 univento.eu - All rights reserved
|
|
* You are not allowed to use, distribute or modify this code
|
|
*/
|
|
|
|
package eu.univento.core.api.effects;
|
|
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import net.minecraft.server.v1_12_R1.PacketPlayOutGameStateChange;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* @author janhektor, joethei
|
|
*/
|
|
public class Blackscreen {
|
|
private static Map<UUID, Integer> ticksLeft = new HashMap<>();
|
|
|
|
public static void setupUtil(Plugin instance) {
|
|
Bukkit.getScheduler().runTaskTimer(instance, () -> {
|
|
for (UUID uuid : Blackscreen.ticksLeft.keySet()) {
|
|
Player p = Bukkit.getPlayer(uuid);
|
|
if (p == null) {
|
|
Blackscreen.ticksLeft.remove(uuid);
|
|
} else if (Blackscreen.ticksLeft.get(uuid) > 0) {
|
|
Blackscreen.ticksLeft.put(uuid, Blackscreen.ticksLeft.get(uuid) - 2);
|
|
} else {
|
|
Blackscreen.ticksLeft.remove(uuid);
|
|
}
|
|
}
|
|
}
|
|
, 0L, 2);
|
|
}
|
|
|
|
public static void setBlack(CustomPlayer p, int seconds) {
|
|
ticksLeft.put(p.getUniqueId(), seconds * 20);
|
|
PacketPlayOutGameStateChange packet = new PacketPlayOutGameStateChange(4, 0);
|
|
p.sendPacket(packet);
|
|
|
|
}
|
|
} |