Вопрос Как сделать время до открытие АирДропа с помощью голограммы?

Версия Minecraft
1.16.X

Mikita

Заблокирован
Сообщения
57
Решения
3
Знаю, мега тупой вопрос, но не могу это сделать, пробывал гуглить и ничего, вот как я спавню аирдроп: (/airdropspawn):

Java:
            World world = Bukkit.getWorld("world");
            Random random = new Random();
            int maxX = Main.getInstance().getConfig().getInt("airdrop.location-spawn.maxX");
            int mixX = Main.getInstance().getConfig().getInt("airdrop.location-spawn.mixX");
            int maxZ = Main.getInstance().getConfig().getInt("airdrop.location-spawn.maxZ");
            int mixZ = Main.getInstance().getConfig().getInt("airdrop.location-spawn.mixZ");
            int x = random.nextInt(maxX) - mixX;
            int z = random.nextInt(maxZ) - mixZ;
            int y = world.getHighestBlockYAt(x, z);
            if (y >= 10 && y <= 256) {
                Location location = new Location(world, x, y, z);
                Block block = location.getBlock();
                Hologram hologram = new Hologram(location);
                hologram.setTime(60);
                final Material originalBlockType = block.getType();
                // hg
                // hg
                String materialName = Main.getInstance().getConfig().getString("airdrop.material");
                Material material = Material.valueOf(materialName);
                block.setType(material);
                ShulkerBox box = (ShulkerBox) block.getState();
                box.getPersistentDataContainer().set(
                        NamespacedKey.fromString("airdrop"),
                        PersistentDataType.STRING, "airdrop"
                );
                BukkitRunnable timer = new BukkitRunnable() {
                    @Override
                    public void run() {
                        block.setType(originalBlockType);
                        String died = Main.getInstance().getConfig().getString("messages.died-airdrop");
                        ChatUtils.sendMsgAll(died);
                        deleteRegion(name);
                    }
                };
                timer.runTaskLater(Main.getInstance(), 1200);


                fillInventoryWithRandomLoot(box.getInventory());
                String sound = Main.getInstance().getConfig().getString("airdrop.sound");
                ChatUtils.playServerSound(Sound.valueOf(sound));
                ChatUtils.sendTitleAll();
                String t = String.valueOf(location.getX());
                String j = String.valueOf(location.getY());
                String u = String.valueOf(location.getZ());

                String messagespawn = Main.getInstance().getConfig().getString("messages.spawn-airdrop")
                                .replace("{x}", t)
                                .replace("{y}", j)
                                .replace("{z}", u);

                ChatUtils.sendMsgAll(messagespawn);
 
Можно конкретизировать вопрос? Не особо понятно
если я правильно его понял, он хочет сделать голограмму над аирдропами, на которой будет таймер (ну грубо говоря плейсхолдер)
 
если я правильно его понял, он хочет сделать голограмму над аирдропами, на которой будет таймер (ну грубо говоря плейсхолдер)
сделать метод вывода таймера, и вывести его на голограмму
 
Java:
public void startAirdropCountdown(Location airdropLocation, int seconds) {
    Hologram countdownHologram = createHologram(airdropLocation, "Аирдроп откроется через: " + seconds + " секунд");

    new BukkitRunnable() {
        int timeLeft = seconds;

        @Override
        public void run() {
            if (timeLeft <= 0) {
                updateHologram(countdownHologram, "Аирдроп открыт!");
                countdownHologram.delete();
                this.cancel();
                // Логика открытия аирдропа
            } else {
                updateHologram(countdownHologram, "Аирдроп откроется через: " + timeLeft + " секунд");
                timeLeft--;
            }
        }
    }.runTaskTimer(yourPluginInstance, 0L, 20L); // 20 ticks = 1 second
}
Знаю, мега тупой вопрос, но не могу это сделать, пробывал гуглить и ничего, вот как я спавню аирдроп: (/airdropspawn):

Java:
            World world = Bukkit.getWorld("world");
            Random random = new Random();
            int maxX = Main.getInstance().getConfig().getInt("airdrop.location-spawn.maxX");
            int mixX = Main.getInstance().getConfig().getInt("airdrop.location-spawn.mixX");
            int maxZ = Main.getInstance().getConfig().getInt("airdrop.location-spawn.maxZ");
            int mixZ = Main.getInstance().getConfig().getInt("airdrop.location-spawn.mixZ");
            int x = random.nextInt(maxX) - mixX;
            int z = random.nextInt(maxZ) - mixZ;
            int y = world.getHighestBlockYAt(x, z);
            if (y >= 10 && y <= 256) {
                Location location = new Location(world, x, y, z);
                Block block = location.getBlock();
                Hologram hologram = new Hologram(location);
                hologram.setTime(60);
                final Material originalBlockType = block.getType();
                // hg
                // hg
                String materialName = Main.getInstance().getConfig().getString("airdrop.material");
                Material material = Material.valueOf(materialName);
                block.setType(material);
                ShulkerBox box = (ShulkerBox) block.getState();
                box.getPersistentDataContainer().set(
                        NamespacedKey.fromString("airdrop"),
                        PersistentDataType.STRING, "airdrop"
                );
                BukkitRunnable timer = new BukkitRunnable() {
                    @Override
                    public void run() {
                        block.setType(originalBlockType);
                        String died = Main.getInstance().getConfig().getString("messages.died-airdrop");
                        ChatUtils.sendMsgAll(died);
                        deleteRegion(name);
                    }
                };
                timer.runTaskLater(Main.getInstance(), 1200);


                fillInventoryWithRandomLoot(box.getInventory());
                String sound = Main.getInstance().getConfig().getString("airdrop.sound");
                ChatUtils.playServerSound(Sound.valueOf(sound));
                ChatUtils.sendTitleAll();
                String t = String.valueOf(location.getX());
                String j = String.valueOf(location.getY());
                String u = String.valueOf(location.getZ());

                String messagespawn = Main.getInstance().getConfig().getString("messages.spawn-airdrop")
                                .replace("{x}", t)
                                .replace("{y}", j)
                                .replace("{z}", u);

                ChatUtils.sendMsgAll(messagespawn);
 
Назад
Сверху Снизу