1. Этот сайт использует файлы cookie. Продолжая пользоваться данным сайтом, Вы соглашаетесь на использование нами Ваших файлов cookie. Узнать больше.
  2. Вы находитесь в сообществе Rubukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на различные языки плагины наших коллег из других стран.
    Скрыть объявление
Скрыть объявление
В преддверии глобального обновления, мы проводим исследования, которые помогут нам сделать опыт пользования форумом ещё удобнее. Помогите нам, примите участие!

Помогите Помогите обновить код на последнюю версию

Тема в разделе "Разработка плагинов для новичков", создана пользователем hgtrrrrrr551, 23 фев 2021.

  1. Dymeth

    Dymeth Активный участник Пользователь

    Баллы:
    98
    Имя в Minecraft:
    Dymeth
    Достаточно было прислать только проблемный участок. А без кода наши полномочия всё...
     
  2. Автор темы
    hgtrrrrrr551

    hgtrrrrrr551 Ньюби Пользователь

    Баллы:
    1
    Код:
        public void setTimeLeft(float timeleft) {
            Iterator<String> tplayers = this.players.keySet().iterator();
            while (tplayers.hasNext()) {
              String splayer = tplayers.next();
              Player player = Bukkit.getServer().getPlayerExact(splayer);
              if (player != null && player.isOnline()) {
                player.setExp(timeleft);
                continue;
              }
              this.players.remove(splayer);
            }
        }
    Код:
    package com.tux2mc.colorshuffle;
    import org.bukkit.ChatColor;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.Bukkit;
    import java.util.Random;
    public class CSTimer implements Runnable {
        CSArena arena;
        ColorShuffle plugin;
        int ticksforround;
        int status;
        int colorround;
        boolean iscolorshuffle;
        Random rand;
        int tickstilendofround;
        public CSTimer(final ColorShuffle plugin, final CSArena arena) {
            this.ticksforround = 200;
            this.status = 1;
            this.colorround = 0;
            this.iscolorshuffle = false;
            this.rand = new Random();
            this.tickstilendofround = this.ticksforround;
            this.plugin = plugin;
            this.arena = arena;
            this.ticksforround = arena.getFirstRoundTicks();
        }
        @Override
        public void run() {
            if (this.arena.getPlayers().size() == 0) {
                this.arena.resetArena();
                return;
            }
            if (this.status == 0) {
                this.arena.roundEnded();
                ++this.status;
                this.colorround = 0;
                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this.plugin, (Runnable) this, 15L);
            } else if (this.status == 1) {
                ++this.status;
                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this.plugin, (Runnable) this, 45L);
            } else if (this.status == 2) {
                this.arena.replaceFloor();
                this.arena.spinColors(false);
                ++this.colorround;
                ++this.status;
                if (this.rand.nextInt(5) == 1) {
                    this.iscolorshuffle = true;
                    this.arena.sendMessageToPlayers(
                            ChatColor.GOLD + "It's time for the " + this.plugin.colorize("C O L O R  S H U F F L E!"));
                } else {
                    this.iscolorshuffle = false;
                }
                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this.plugin, (Runnable) this, 7L);
            } else if (this.status == 3) {
                this.arena.spinColors(false);
                if (this.iscolorshuffle) {
                    this.arena.shuffleMats();
                }
                switch (++this.colorround) {
                case 2:
                    this.arena.sendMessageToPlayers(
                            String.valueOf(this.plugin.getColorShufflePrefix()) + ChatColor.GREEN + " 3");
                    break;
                case 4:
                    this.arena.sendMessageToPlayers(
                            String.valueOf(this.plugin.getColorShufflePrefix()) + ChatColor.GREEN + " 2");
                    break;
                case 6:
                    this.arena.sendMessageToPlayers(
                            String.valueOf(this.plugin.getColorShufflePrefix()) + ChatColor.GREEN + " 1");
                    break;
                }
                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this.plugin, (Runnable) this, 7L);
                if (this.colorround > 6) {
                    ++this.status;
                }
            } else if (this.status == 4) {
                this.arena.startRound();
                if (this.arena.getRound() > 1) {
                    this.ticksforround *= (int) (1.0 - this.arena.getDecay());
                }
                this.tickstilendofround = this.ticksforround;
                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this.plugin, (Runnable) this, 5L);
                ++this.status;
            } else if (this.status == 5) {
                this.tickstilendofround -= 5;
                final float timeleft = this.tickstilendofround / (float) this.ticksforround;
                this.arena.setTimeLeft(timeleft);
                if (this.tickstilendofround < 5) {
                    this.status = 0;
                    Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this.plugin, (Runnable) this,
                            (long) this.tickstilendofround);
                } else {
                    Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this.plugin, (Runnable) this, 5L);
                }
            }
        }
    }
     

Поделиться этой страницей