Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.broken.cheststorage.ChestStorage;
- import org.broken.cheststorage.cache.ContainerRegistry;
- import org.broken.cheststorage.util.YamlSettingsContainers;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.scheduler.BukkitTask;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Objects;
- public class TeleportLinkItemsTask extends BukkitRunnable {
- private final ChestStorage plugin = ChestStorage.getInstance();
- private BukkitTask task;
- private static final Map<Location, TeleportItems> hopersuctionTeleportmap = new HashMap<>();
- public void start() {
- if (task != null && (Bukkit.getScheduler().isCurrentlyRunning(task.getTaskId()) || Bukkit.getScheduler().isQueued(task.getTaskId())))
- Bukkit.getScheduler().cancelTask(task.getTaskId());
- task = runTaskTimer(ChestStorage.getInstance(), 0L, 1L);
- }
- public void tick() {
- }
- public void stop() {
- task.cancel();
- }
- private final ContainerRegistry registry = ContainerRegistry.getInstance();
- @Override
- public void run() {
- //System.out.println("test ");
- task();
- }
- private void task() {
- if (registry.getContainerlocations() != null)
- for (Location locations : registry.getContainerlocations()) {
- if (!locations.getWorld().isChunkLoaded(locations.getBlockX() >> 4, locations.getBlockZ() >> 4))
- continue;
- ContainerRegistry.TypeOfContainer typeOfContainer = registry.getTypeofContainer(locations);
- if (locations != null && Objects.equals(typeOfContainer, ContainerRegistry.TypeOfContainer.LINKEDCONTAINER))
- if (!hopersuctionTeleportmap.containsKey(locations)) {
- int secondsForPickupTeleport = YamlSettingsContainers.getSecondsForPickupTeleport(registry.getContainerFileName(locations), registry.getCurrentUpdate(locations));
- hopersuctionTeleportmap.put(locations, new TeleportItems(secondsForPickupTeleport * 20, locations));
- }
- }
- if (!hopersuctionTeleportmap.isEmpty())
- //System.out.println(hopersuctionTeleportmap);
- hopersuctionTeleportmap.values().forEach(TeleportItems::run);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement