Skocz do zawartości
  • 0

Bukkit Runable


Grex

Pytanie

Klasa główna mojego pluginu zawiera coś takiego:

package pl.Greexowy.FlintMC;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import pl.Greexowy.FlintMC.commands.*;
import pl.Greexowy.FlintMC.listeners.*;

import java.io.IOException;
import java.net.ConnectException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;

public class FlintMCPlugin extends JavaPlugin implements Listener {
    @Override
    public void onEnable() {
        new BukkitRunnable() {
            public void run() {
                for (Player players : Bukkit.getOnlinePlayers()) {
                    if(players.getOpenInventory().getTitle().equals(ChatColor.RED + "Wybierz Arene UHC - SOLO")) {
                        Inventory inventory = players.getOpenInventory().getTopInventory();

                        String uhcSoloArena1Players = PlaceholderAPI.setPlaceholders(players, "%bungee_solouhc1%");
                        String uhcSoloArena2Players = PlaceholderAPI.setPlaceholders(players, "%bungee_solouhc2%");
                        String uhcSoloArena3Players = PlaceholderAPI.setPlaceholders(players, "%bungee_solouhc3%");
                        String uhcSoloArena4Players = PlaceholderAPI.setPlaceholders(players, "%bungee_solouhc4%");
                        String uhcSoloArena5Players = PlaceholderAPI.setPlaceholders(players, "%bungee_solouhc5%");

                        // Podserwery Solo UHC
                        ItemStack suhc1Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc1SelectMeta = suhc1Select.getItemMeta();
                        suhc1SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 1");
                        List<String> lore1Uhc = new ArrayList<String>();
                        lore1Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcSoloArena1Players);
                        suhc1SelectMeta.setLore(lore1Uhc);
                        suhc1Select.setItemMeta(suhc1SelectMeta);
                        inventory.setItem(20, suhc1Select);

                        ItemStack suhc2Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc2SelectMeta = suhc2Select.getItemMeta();
                        suhc2SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 2");
                        List<String> lore2Uhc = new ArrayList<String>();
                        lore2Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcSoloArena2Players);
                        suhc2SelectMeta.setLore(lore2Uhc);
                        suhc2Select.setItemMeta(suhc2SelectMeta);
                        inventory.setItem(21, suhc2Select);

                        ItemStack suhc3Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc3SelectMeta = suhc3Select.getItemMeta();
                        suhc3SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 3");
                        List<String> lore3Uhc = new ArrayList<String>();
                        lore3Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcSoloArena3Players);
                        suhc3SelectMeta.setLore(lore3Uhc);
                        suhc3Select.setItemMeta(suhc3SelectMeta);
                        inventory.setItem(22, suhc3Select);

                        ItemStack suhc4Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc4SelectMeta = suhc4Select.getItemMeta();
                        suhc4SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 4");
                        List<String> lore4Uhc = new ArrayList<String>();
                        lore4Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcSoloArena4Players);
                        suhc4SelectMeta.setLore(lore4Uhc);
                        suhc4Select.setItemMeta(suhc4SelectMeta);
                        inventory.setItem(23, suhc4Select);

                        ItemStack suhc5Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc5SelectMeta = suhc5Select.getItemMeta();
                        suhc5SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 5");
                        List<String> lore5Uhc = new ArrayList<String>();
                        lore5Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcSoloArena5Players);
                        suhc5SelectMeta.setLore(lore5Uhc);
                        suhc5Select.setItemMeta(suhc5SelectMeta);
                        inventory.setItem(24, suhc5Select);
                    } else if(players.getOpenInventory().getTitle().equals(ChatColor.RED + "Wybierz Arene UHC - DUELS")) {
                        Inventory inventory = players.getOpenInventory().getTopInventory();

                        String uhcDuelArena1Players = PlaceholderAPI.setPlaceholders(players, "%bungee_dueluhc1%");
                        String uhcDuelArena2Players = PlaceholderAPI.setPlaceholders(players, "%bungee_dueluhc2%");
                        String uhcDuelArena3Players = PlaceholderAPI.setPlaceholders(players, "%bungee_dueluhc3%");
                        String uhcDuelArena4Players = PlaceholderAPI.setPlaceholders(players, "%bungee_dueluhc4%");
                        String uhcDuelArena5Players = PlaceholderAPI.setPlaceholders(players, "%bungee_dueluhc5%");

                        ItemStack suhc1Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc1SelectMeta = suhc1Select.getItemMeta();
                        suhc1SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 1");
                        List<String> lore1Uhc = new ArrayList<String>();
                        lore1Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcDuelArena1Players);
                        suhc1SelectMeta.setLore(lore1Uhc);
                        suhc1Select.setItemMeta(suhc1SelectMeta);
                        inventory.setItem(20, suhc1Select);

                        ItemStack suhc2Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc2SelectMeta = suhc2Select.getItemMeta();
                        suhc2SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 2");
                        List<String> lore2Uhc = new ArrayList<String>();
                        lore2Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcDuelArena2Players);
                        suhc2SelectMeta.setLore(lore2Uhc);
                        suhc2Select.setItemMeta(suhc2SelectMeta);
                        inventory.setItem(21, suhc2Select);

                        ItemStack suhc3Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc3SelectMeta = suhc3Select.getItemMeta();
                        suhc3SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 3");
                        List<String> lore3Uhc = new ArrayList<String>();
                        lore3Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcDuelArena3Players);
                        suhc3SelectMeta.setLore(lore3Uhc);
                        suhc3Select.setItemMeta(suhc3SelectMeta);
                        inventory.setItem(22, suhc3Select);

                        ItemStack suhc4Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc4SelectMeta = suhc4Select.getItemMeta();
                        suhc4SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 4");
                        List<String> lore4Uhc = new ArrayList<String>();
                        lore4Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcDuelArena4Players);
                        suhc4SelectMeta.setLore(lore4Uhc);
                        suhc4Select.setItemMeta(suhc4SelectMeta);
                        inventory.setItem(23, suhc4Select);

                        ItemStack suhc5Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc5SelectMeta = suhc5Select.getItemMeta();
                        suhc5SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 5");
                        List<String> lore5Uhc = new ArrayList<String>();
                        lore5Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcDuelArena5Players);
                        suhc5SelectMeta.setLore(lore5Uhc);
                        suhc5Select.setItemMeta(suhc5SelectMeta);
                        inventory.setItem(24, suhc5Select);
                    } else if(players.getOpenInventory().getTitle().equals(ChatColor.RED + "Wybierz Arene UHC - TRIO")) {
                        Inventory inventory = players.getOpenInventory().getTopInventory();

                        String uhcTrioArena1Players = PlaceholderAPI.setPlaceholders(players, "%bungee_triouhc1%");
                        String uhcTrioArena2Players = PlaceholderAPI.setPlaceholders(players, "%bungee_triouhc2%");
                        String uhcTrioArena3Players = PlaceholderAPI.setPlaceholders(players, "%bungee_triouhc3%");
                        String uhcTrioArena4Players = PlaceholderAPI.setPlaceholders(players, "%bungee_triouhc4%");
                        String uhcTrioArena5Players = PlaceholderAPI.setPlaceholders(players, "%bungee_triouhc5%");

                        ItemStack suhc1Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc1SelectMeta = suhc1Select.getItemMeta();
                        suhc1SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 1");
                        List<String> lore1Uhc = new ArrayList<String>();
                        lore1Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcTrioArena1Players);
                        suhc1SelectMeta.setLore(lore1Uhc);
                        suhc1Select.setItemMeta(suhc1SelectMeta);
                        inventory.setItem(20, suhc1Select);

                        ItemStack suhc2Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc2SelectMeta = suhc2Select.getItemMeta();
                        suhc2SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 2");
                        List<String> lore2Uhc = new ArrayList<String>();
                        lore2Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcTrioArena2Players);
                        suhc2SelectMeta.setLore(lore2Uhc);
                        suhc2Select.setItemMeta(suhc2SelectMeta);
                        inventory.setItem(21, suhc2Select);

                        ItemStack suhc3Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc3SelectMeta = suhc3Select.getItemMeta();
                        suhc3SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 3");
                        List<String> lore3Uhc = new ArrayList<String>();
                        lore3Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcTrioArena3Players);
                        suhc3SelectMeta.setLore(lore3Uhc);
                        suhc3Select.setItemMeta(suhc3SelectMeta);
                        inventory.setItem(22, suhc3Select);

                        ItemStack suhc4Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc4SelectMeta = suhc4Select.getItemMeta();
                        suhc4SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 4");
                        List<String> lore4Uhc = new ArrayList<String>();
                        lore4Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcTrioArena4Players);
                        suhc4SelectMeta.setLore(lore4Uhc);
                        suhc4Select.setItemMeta(suhc4SelectMeta);
                        inventory.setItem(23, suhc4Select);

                        ItemStack suhc5Select = new ItemStack(Material.WOOL, 1, (short) 1);
                        ItemMeta suhc5SelectMeta = suhc5Select.getItemMeta();
                        suhc5SelectMeta.setDisplayName(ChatColor.GOLD + "Arena 5");
                        List<String> lore5Uhc = new ArrayList<String>();
                        lore5Uhc.add(ChatColor.GRAY + "Graczy: " + ChatColor.YELLOW + uhcTrioArena5Players);
                        suhc5SelectMeta.setLore(lore5Uhc);
                        suhc5Select.setItemMeta(suhc5SelectMeta);
                        inventory.setItem(24, suhc5Select);
                    }
                }
            }
        }.runTaskTimer(this, 0, 20);
    }
}

Jednak liczba graczy się nie aktualizuje. Ktoś dołączy, jest nadal Gracze: 0
Nazwy podserwerów na pewno się sprawdzają, dodałem PlaceHodlerAPI, i Plugin PlaceHolderAPI jest na serwerze. W innych pluginach ta zmienna %bungee_nazwaserwera% działa, a w moim nie. Zawsze pisze 0. Dodałem w plugin.yml:
 

softdepend: [PlaceholderAPI]

 

Odnośnik do komentarza
https://skript.pl/temat/39742-bukkit-runable/
Udostępnij na innych stronach

0 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

Nie udzielono jeszcze odpowiedzi na to pytanie

Dołącz do dyskusji

Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.

Nieaktywny
Odpowiedz na pytanie...

×   Wklejono zawartość z formatowaniem.   Usuń formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Odnośnik został automatycznie osadzony.   Przywróć wyświetlanie jako odnośnik

×   Przywrócono poprzednią zawartość.   Wyczyść edytor

×   Nie możesz bezpośrednio wkleić grafiki. Dodaj lub załącz grafiki z adresu URL.

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...