Scoreboard

Discussion in 'Plugin Development' started by skales65, Jul 6, 2017.

  1. Offline

    skales65

    Hi guys. I am making a minigame plugin. I am working first time with scoreboard. I want to make sidebar counting kills of team red and blue (for example Zombie - 1 point, Player - 10 points). Do you know how to do it?
    Thank you very much :) .
    btw: I want to make zombie boss. It isn't working now. Do you know why?

    Sorry for my english

    Code:
    package me.skales65;
    import java.util.ArrayList;
    import java.util.List;
    import me.AdityaTD.TitleWelcomeMessage.TitlesAPI;
    import org.bukkit.*;
    import org.bukkit.ChatColor;
    import org.bukkit.GameMode;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.block.BlockFace;
    import org.bukkit.block.Chest;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Skeleton;
    import org.bukkit.entity.Spider;
    import org.bukkit.entity.Zombie;
    import org.bukkit.entity.ZombieVillager;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.event.player.PlayerTeleportEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    import org.bukkit.scheduler.BukkitScheduler;
    import org.bukkit.scheduler.BukkitTask;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;
    
    
    public class Apocalypse extends JavaPlugin implements Listener{
        ZombieVillager zombik1;
        ZombieVillager zombik;
        int cerveny = 0;
        int modry = 0;
        Score score1;
        Score score2;
        String sys = ChatColor.GRAY + "[" + ChatColor.RED + "" + ChatColor.BOLD + "Apocalypse" + ChatColor.GRAY + "]";
        boolean started = false;
        boolean checking = false;
        ArrayList<Player> red = new ArrayList<Player>();
        ArrayList<Player> blue = new ArrayList<Player>();
        public ArrayList<Player> list = new ArrayList<Player>();
        boolean starting = false;
        boolean emptylist = true;
        public void onEnable(){
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }
        @EventHandler
        public void onPlayerMove(PlayerMoveEvent e){
            if (!(list.isEmpty())){
                    emptylist = false;
                }
            if(started) checking = false;
            if (checking = true){
               
                if (emptylist) {
                for (Player p : list){
                    list.remove(p);
                    int t = (int) (Math.random() * 2);
                    if(t == 1){
                        red.add(p);
                        p.sendMessage("added to red");
                    } else {
                        blue.add(p);
                        p.sendMessage("added to blue");
                    }
                }
                }
            }
            if(Bukkit.getWorld("apocalypse_lobby").getPlayers().size() >= 1 && starting == false){
                starting = true;
                BukkitScheduler scheduler = getServer().getScheduler();
                    scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
                    int countDown = 11;
                    @Override
                    public void run() {
                        for(Player p : Bukkit.getWorld("apocalypse_lobby").getPlayers()){
                            countDown --;
                            p.setLevel(countDown);
                            if (countDown == 10 || countDown == 5 || countDown == 3 || countDown == 2 || countDown == 1){
                                p.playSound(p.getLocation(), Sound.ENTITY_VEX_DEATH, 1, 10);
                               
                                p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + "Hra začíná za " + countDown + " vteřin!");
                            }
                            if(countDown == 1){
                                checking = true;
                            }
                            if(countDown == 0){
                                started = true;
                                starting = false;
                                GameMode gm;
                                gm = GameMode.ADVENTURE;
                                p.setGameMode(gm);
                                p.sendMessage("");
                            p.sendMessage("");
                            p.sendMessage("");
                            p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + " -------------------");
                            p.sendMessage(sys);
                            p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + "        Hra začíná");
                            p.sendMessage(sys);
                            p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + " -------------------");
                            TitlesAPI.sendTitle(p, 30, 5 * 20, 10, ChatColor.RED + "" + ChatColor.BOLD + "Apocalypse");
                            TitlesAPI.sendTabTitle(p, ChatColor.RED + "" + ChatColor.BOLD + "Survivors", "");
                            World w = Bukkit.getWorld("apocalypse_1");
                            if (!(list.isEmpty())){
                                int t = (int) (Math.random() * 2);
                                if(t == 1){
                                    list.remove(p);
                                    red.add(p);
                                    p.sendMessage("added to red");
                                } else {
                                    list.remove(p);
                                    blue.add(p);
                                    p.sendMessage("added to blue");
                                }
                            }
                            //########################SCORE###########################
                            cerveny = 0;
                            modry = 0;
                            ScoreboardManager manager = Bukkit.getScoreboardManager();
                            Scoreboard board = manager.getNewScoreboard();
                            Objective objective = board.registerNewObjective("test", "dummy");
                            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                            objective.setDisplayName("Body");
                            score1 = objective.getScore(ChatColor.RED + "Červený Team: ");
                            score1.setScore(cerveny);
                            score2 = objective.getScore(ChatColor.RED + "Modrý Team: ");
                            score2.setScore(modry);
                            //########################SCORE###########################
                            for(Player p_red : red){
                                p_red.teleport(new Location(w, -324.50, 63.00, 224.50));
                            }
                            for(Player p_blue : blue){
                                p_blue.teleport(new Location(w, 193.50, 65.10, 132.50));
                            }
                            p.playSound(p.getLocation(), Sound.ENTITY_EVOCATION_ILLAGER_PREPARE_SUMMON, 10, 1);
                            p.playSound(p.getLocation(), Sound.MUSIC_END, 10, 1);
                         /* 1. - Blue spawn -> jeskyně
                            2. - "Dia"
                            3. - 5. - Base
                            */
                            //1.
                            Location chestloc1 = (Location) new Location(w, -324.00, 12.00, 239.50);
                            chestloc1.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest = (Chest) chestloc1.getBlock().getState();
                            chest.getInventory().clear();
                            ItemStack apple = new ItemStack (Material.APPLE, 8);
                            ItemStack air = new ItemStack (Material.AIR, 1);
                            ItemStack diasword = new ItemStack (Material.DIAMOND_SWORD, 1);
                            ItemStack irhelm = new ItemStack (Material.IRON_HELMET, 1);
                            ItemStack dirt = new ItemStack (Material.DIRT, 23);
                            chest.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                            //2.
                            Location chestloc2 = (Location) new Location(w, 108.00, 84.00, 423.00);
                            chestloc2.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest2 = (Chest) chestloc2.getBlock().getState().getData();
                            chest2.getInventory().clear();
                            chest2.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                            //3.
                            Location chestloc3 = (Location) new Location(w, -52.00, 116.00, 145.50);
                            chestloc3.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest3 = (Chest) chestloc3.getBlock().getState();
                            chest3.getInventory().clear();
                            chest3.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                            //4.
                            Location chestloc4 = (Location) new Location(w, -52.00, 116.00, 143.00);
                            chestloc4.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest4 = (Chest) chestloc4.getBlock().getState();
                            chest4.getInventory().clear();
                            chest4.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                            //5.
                            Location chestloc5 = (Location) new Location(w, -52.00, 116.00, 141.00);
                            chestloc5.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest5 = (Chest) chestloc5.getBlock().getState();
                            chest5.getInventory().clear();
                            chest5.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                            //6.
                            Location chestloc6 = (Location) new Location(w, -52.00, 116.00, 141.00);
                            chestloc6.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest6 = (Chest) chestloc6.getBlock().getState();
                            chest6.getInventory().clear();
                            chest6.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                           
                                }
                            }
                       
                        }
                    }, 0L, 20L);
                    /*
                    ##########################################
                    #----------------- RED ------------------#
                    ##########################################
                    */
                    BukkitScheduler scheduler1 = getServer().getScheduler();
                    scheduler1.scheduleAsyncDelayedTask(this, new Runnable() {
                    @Override
                    public void run() {
                            for (Player p_red : red){
                                TitlesAPI.sendTitle(p_red, 30, 5 * 20, 10, ChatColor.RED + "" + ChatColor.BOLD + "Wave 1");
                            Location loc = p_red.getLocation();
                            double x = loc.getX() - 10;
                            double y = loc.getY();
                            double z = loc.getZ() - 15;
                            Location loca = loc.add(x, y, z);
                            Block bl = loca.getBlock();
                            Material ma = bl.getType();
                            if (!(ma == Material.AIR)){
                                while (ma != Material.AIR){
                                    y++;
                                    loca = loc.add(x, y, z);
                                    if (ma == Material.AIR){
                                        p_red.getWorld().spawn(loca, ZombieVillager.class);
                                    }
                                }
                            } else {
                                p_red.getWorld().spawn(loca, ZombieVillager.class);
                            }
                           
                            zombik1 = (ZombieVillager) p_red.getWorld().spawn(p_red.getLocation(), ZombieVillager.class);
                            zombik1.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000, 3));
                            zombik1.setCustomName("Alfa");
                            zombik1.setCustomNameVisible(false);
                        }
                        }
                    }, 300L);
                    /*
                    ##########################################
                    #----------------- BLUE -----------------#
                    ##########################################
                    */
                    BukkitScheduler scheduler2 = getServer().getScheduler();
                    scheduler2.scheduleAsyncDelayedTask(this, new Runnable() {
                    @Override
                    public void run() {
                            for (Player p_blue : blue){
                                TitlesAPI.sendTitle(p_blue, 30, 5 * 20, 10, ChatColor.RED + "" + ChatColor.BOLD + "Wave 1");
                            Location loc = p_blue.getLocation();
                            double x = loc.getX() - 10;
                            double y = loc.getY();
                            double z = loc.getZ() - 15;
                            Location loca = loc.add(x, y, z);
                            Block bl = loca.getBlock();
                            Material ma = bl.getType();
                            if (!(ma == Material.AIR)){
                                while (ma != Material.AIR){
                                    y++;
                                    loca = loc.add(x, y, z);
                                    if (ma == Material.AIR){
                                        p_blue.getWorld().spawn(loca, ZombieVillager.class);
                                    }
                                }
                            } else {
                                p_blue.getWorld().spawn(loca, ZombieVillager.class);
                            }
                           
                            zombik = (ZombieVillager) p_blue.getWorld().spawn(p_blue.getLocation(), ZombieVillager.class);
                            zombik.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000, 3));
                            zombik.setCustomName("Alfa");
                            zombik.setCustomNameVisible(false);
                        }
                        }
                    }, 300L);
                   
                    }
                   
               
              
            }
       
       
    
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (sender instanceof Player){
                Player p = (Player) sender;
            if(command.getName().equalsIgnoreCase("watp")){
                   
                    list.add(p);
                    p.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "Budeš přesunut na herní lobby ");
                    World w = Bukkit.getWorld("apocalypse_lobby");
                    p.teleport(new Location(w, 37.00, 8.50, -4.00));
                    GameMode gm;
                    gm = GameMode.ADVENTURE;
                    p.setGameMode(gm);
                    if (p.getWorld().getName().equalsIgnoreCase("apocalypse_lobby")){
                         if(command.getName().equalsIgnoreCase("waleave")){
                            p.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "Opustil jsi herni lobby ");
                            World wo = Bukkit.getWorld("spawn2");
                            p.teleport(new Location(wo, -113.02, 68.00, -5.99));
                            GameMode GM;
                            GM = GameMode.SURVIVAL;
                            p.setGameMode(gm);
                            list.remove(p);
                         }
                    }
                    return true;
                }
            if (command.getName().equals("wared")){
                p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + " Připojil ses do červeného týmu!");
                list.remove(p);
                red.add(p);
            }
            else if (command.getName().equals("wablue")){
                p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + " Připojil ses do modrého týmu!");
                list.remove(p);
                blue.add(p);
            }
                  
               
            return false;
            }
        return false;
        }
        public void entityDeathEvent(EntityDeathEvent e){
            Entity ent = e.getEntity();
            if(e.getEntity() instanceof Zombie){
                for(Player p : red){
                    if(e.getEntity().getKiller().equals(p)){
                        cerveny = cerveny + 1;
                        score1.setScore(cerveny);p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + cerveny);
                    }
                }
                for(Player p : blue){
                    if(e.getEntity().getKiller().equals(p)){
                        modry = modry + 1;
                        score1.setScore(modry);
                    }
                }
            }
            if(e.getEntity() instanceof Skeleton){
                for(Player p : red){
                    if(e.getEntity().getKiller().equals(p)){
                        cerveny = cerveny + 1;
                        score1.setScore(cerveny);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + cerveny);
                    }
                }
                for(Player p : blue){
                    if(e.getEntity().getKiller().equals(p)){
                        modry = modry + 1;
                        score1.setScore(modry);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + modry);
                    }
                }
            }
            if(e.getEntity() instanceof Spider){
                for(Player p : red){
                    if(e.getEntity().getKiller().equals(p)){
                        cerveny = cerveny + 1;
                        score1.setScore(cerveny);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + cerveny);
                    }
                }
                for(Player p : blue){
                    if(e.getEntity().getKiller().equals(p)){
                        modry = modry + 1;
                        score1.setScore(modry);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + modry);
                    }
                }
            }
            if(e.getEntity().getCustomName().equals("Alfa")){
                e.getEntity().getWorld().spawnParticle(Particle.DRAGON_BREATH, e.getEntity().getLocation(), 100);
                e.getEntity().getWorld().spawnParticle(Particle.DRAGON_BREATH, e.getEntity().getLocation().add(0, 1, 0), 100);
                for(Player p : red){
                    if(e.getEntity().getKiller().equals(p)){
                        cerveny = cerveny + 5;
                        score1.setScore(cerveny);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre bylo přičteno 5 bodů. Současné skóre je " + cerveny);
                    }
                }
                for(Player p : blue){
                    if(e.getEntity().getKiller().equals(p)){
                        modry = modry + 5;
                        score1.setScore(modry);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre bylo přičteno 5 bodů. Současné skóre je " + modry);
                    }
                }
            }
            if(e.getEntity() instanceof Player){
                for(Player p : red){
                    if(e.getEntity().getKiller().equals(p)){
                        cerveny = cerveny + 10;
                        score1.setScore(cerveny);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre bylo přičteno 10 bodů. Současné skóre je " + cerveny);
                    }
                }
                for(Player p : blue){
                    if(e.getEntity().getKiller().equals(p)){
                        modry = modry + 10;
                        score1.setScore(modry);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre bylo přičteno 10 bodů. Současné skóre je " + modry);
                    }
                }
            }
        }
    }
     
  2. You have far too many imports. I just want to clean it up so it does not flood the whole code.
    Code:
    import java.util.*;
    import me.AdityaTD.TitleWelcomeMessage.TitlesAPI;
    import org.bukkit.*
    import org.bukkit.block.*;
    import org.bukkit.command.*;
    import org.bukkit.entity.*;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.event.player.*;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.*;
    import org.bukkit.scheduler.*;
    import org.bukkit.scoreboard.*;
    Do not create arraylists of players. When a player leaves the server, the arraylist may still contain the player, using up memory space and potentially creating NPEs. Instead, store the player's UUID and use Bukkit.getPlayer(UUID) to try and get the player. If this is null, then you know the player is not online.

    In one of the events (the one at the bottom) you forgot the @EventHandler tag. This is needed if you want the event to be triggered.

    Back to the main problem; How are you setting up your scoreboard? If you want it where the scores for each 'team' will be displayed on their own line, then the best way to do this would be to listen for the death event. When a player in a time dies, get the team they are on and then the score on the scoreboard that represents that team. From there, remove that score and replace it with the current score.

    As for the zombie boss, what is currently happening? What do you want to happen? Where is the code for the zombie boss?
     
  3. Offline

    skales65

    @Zombie_Striker
    ArrayList<UUID> red = new ArrayList<UUID>();
    UUID uuid = p.getUniqueId();
    red.add(uuid);
    And where must be Bukkit.getPlayer(UUID);?

    About that @EventHandler - It is everytime problem :pP Sorry

    scoreboard - Like if somebody from red team dies, it will write +10 poits to blue team? What about mobs?

    zombie boss - I have called it "Alfa"
    Code:
    zombik = (ZombieVillager) p_blue.getWorld().spawn(p_blue.getLocation(), ZombieVillager.class);
                            zombik.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000, 3));
                            zombik.setCustomName("Alfa");
                            zombik.setCustomNameVisible(false);
    (same for team red)
    Alfa isn't spawning
    But thanks for your help :)
     
    Last edited: Jul 7, 2017
  4. Offline

    skales65

  5. @skales65
    1. The UUID grabber should be put wherever you want to get the player's instance. All that does is turn the UUID to a player, so use that when you need the player's instance.
    2. ...
    3. What about mobs? What is supposed to happen when a mob dies/kills another player?
    4. Try using spawnEntity or one of the other methods.
     
  6. Offline

    skales65

    @Zombie_Striker
    1. like for adding to list? I used UUID uuid = p.getUniqueId();
    red.add(uuid);
    2. ._.
    3. When somebody from red/blue kill zombie/skeleton/spider/etc. it will count +1 point to his team.
    When somebody from red/blue kill player from another team it will cout + 10 points to hs team.
    Same with "Alfa"
    4. I don't know but it worked fine. I will try other methods as you say.
     
  7. Offline

    skales65

    @Zombie_Striker
    This is what I have now.
    I am still trying to spawn Alfa (I have tried spawnEntity - still nothing)
    I don't know how to work with ArrayList of UUID so I made playerQuitEvent. It doesn't work too :/
    Still don't have scoreboard but it isn't so big problem now.
    Code:
    package me.skales65;
    
    import java.util.*;
    import me.AdityaTD.TitleWelcomeMessage.TitlesAPI;
    import org.bukkit.*;
    import org.bukkit.block.*;
    import org.bukkit.command.*;
    import org.bukkit.entity.*;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.event.player.*;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.*;
    import org.bukkit.scheduler.*;
    import org.bukkit.scoreboard.*;
    
    
    public class Apocalypse extends JavaPlugin implements Listener{
        ArrayList<UUID> red1 = new ArrayList<UUID>();
        ZombieVillager zombik1;
        ZombieVillager zombik;
        int cerveny = 0;
        int modry = 0;
        Score score1;
        Score score2;
        String sys = ChatColor.GRAY + "[" + ChatColor.RED + "" + ChatColor.BOLD + "Apocalypse" + ChatColor.GRAY + "]";
        boolean started = false;
        boolean checking = false;
        ArrayList<Player> red = new ArrayList<Player>();
        ArrayList<Player> blue = new ArrayList<Player>();
        public ArrayList<Player> list = new ArrayList<Player>();
        boolean starting = false;
        boolean emptylist = true;
        public void onEnable(){
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }
        @EventHandler
        public void onPlayerMove(PlayerMoveEvent e){
            if (!(list.isEmpty())){
                    emptylist = false;
                }
            if(started) checking = false;
            if (checking = true){
               
                if (emptylist) {
                for (Player p : list){
                    list.remove(p);
                    int t = (int) (Math.random() * 2);
                    if(t == 1){
                        red.add(p);
                        p.sendMessage("added to red");
                    } else {
                        blue.add(p);
                        p.sendMessage("added to blue");
                    }
                }
                }
            }
            if(Bukkit.getWorld("apocalypse_lobby").getPlayers().size() >= 1 && starting == false){
                starting = true;
                BukkitScheduler scheduler = getServer().getScheduler();
                    scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
                    int countDown = 11;
                    @Override
                    public void run() {
                        for(Player p : Bukkit.getWorld("apocalypse_lobby").getPlayers()){
                            countDown --;
                            p.setLevel(countDown);
                            if (countDown == 10 || countDown == 5 || countDown == 3 || countDown == 2 || countDown == 1){
                                p.playSound(p.getLocation(), Sound.ENTITY_VEX_DEATH, 1, 10);
                               
                                p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + "Hra začíná za " + countDown + " vteřin!");
                            }
                            if(countDown == 1){
                                checking = true;
                            }
                            if(countDown == 0){
                                started = true;
                                starting = false;
                                GameMode gm;
                                gm = GameMode.ADVENTURE;
                                p.setGameMode(gm);
                                p.sendMessage("");
                            p.sendMessage("");
                            p.sendMessage("");
                            p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + " -------------------");
                            p.sendMessage(sys);
                            p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + "        Hra začíná");
                            p.sendMessage(sys);
                            p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + " -------------------");
                            TitlesAPI.sendTitle(p, 30, 5 * 20, 10, ChatColor.RED + "" + ChatColor.BOLD + "Apocalypse");
                            TitlesAPI.sendTabTitle(p, ChatColor.RED + "" + ChatColor.BOLD + "Survivors", "");
                            World w = Bukkit.getWorld("apocalypse_1");
                            if (!(list.isEmpty())){
                                int t = (int) (Math.random() * 2);
                                if(t == 1){
                                    list.remove(p);
                                    red.add(p);
                                    p.sendMessage("added to red");
                                } else {
                                    list.remove(p);
                                    blue.add(p);
                                    p.sendMessage("added to blue");
                                }
                            }
                            //########################SCORE###########################
                            cerveny = 0;
                            modry = 0;
                            ScoreboardManager manager = Bukkit.getScoreboardManager();
                            Scoreboard board = manager.getNewScoreboard();
                            Objective objective = board.registerNewObjective("test", "dummy");
                            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                            objective.setDisplayName("Body");
                            score1 = objective.getScore(ChatColor.RED + "Červený Team: ");
                            score1.setScore(cerveny);
                            score2 = objective.getScore(ChatColor.RED + "Modrý Team: ");
                            score2.setScore(modry);
                            //########################SCORE###########################
                            for(Player p_red : red){
                                p_red.teleport(new Location(w, -324.50, 63.00, 224.50));
                            }
                            for(Player p_blue : blue){
                                p_blue.teleport(new Location(w, 193.50, 65.10, 132.50));
                            }
                            p.playSound(p.getLocation(), Sound.ENTITY_EVOCATION_ILLAGER_PREPARE_SUMMON, 10, 1);
                            p.playSound(p.getLocation(), Sound.MUSIC_END, 10, 1);
                         /* 1. - Blue spawn -> jeskyně
                            2. - "Dia"
                            3. - 5. - Base
                            */
                            //1.
                            Location chestloc1 = (Location) new Location(w, -324.00, 12.00, 239.50);
                            chestloc1.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest = (Chest) chestloc1.getBlock().getState();
                            chest.getInventory().clear();
                            ItemStack apple = new ItemStack (Material.APPLE, 8);
                            ItemStack air = new ItemStack (Material.AIR, 1);
                            ItemStack diasword = new ItemStack (Material.DIAMOND_SWORD, 1);
                            ItemStack irhelm = new ItemStack (Material.IRON_HELMET, 1);
                            ItemStack dirt = new ItemStack (Material.DIRT, 23);
                            chest.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                            //2.
                            Location chestloc2 = (Location) new Location(w, 108.00, 84.00, 423.00);
                            chestloc2.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest2 = (Chest) chestloc2.getBlock().getState().getData();
                            chest2.getInventory().clear();
                            chest2.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                            //3.
                            Location chestloc3 = (Location) new Location(w, -52.00, 116.00, 145.50);
                            chestloc3.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest3 = (Chest) chestloc3.getBlock().getState();
                            chest3.getInventory().clear();
                            chest3.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                            //4.
                            Location chestloc4 = (Location) new Location(w, -52.00, 116.00, 143.00);
                            chestloc4.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest4 = (Chest) chestloc4.getBlock().getState();
                            chest4.getInventory().clear();
                            chest4.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                            //5.
                            Location chestloc5 = (Location) new Location(w, -52.00, 116.00, 141.00);
                            chestloc5.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest5 = (Chest) chestloc5.getBlock().getState();
                            chest5.getInventory().clear();
                            chest5.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                            //6.
                            Location chestloc6 = (Location) new Location(w, -52.00, 116.00, 141.00);
                            chestloc6.getBlock().getRelative(BlockFace.SOUTH).setType(Material.CHEST);
                            Chest chest6 = (Chest) chestloc6.getBlock().getState();
                            chest6.getInventory().clear();
                            chest6.getInventory().addItem(dirt,apple,air,air,air, diasword,air,irhelm);
                           
                                }
                            }
                       
                        }
                    }, 0L, 20L);
                    /*
                    ##########################################
                    #----------------- RED ------------------#
                    ##########################################
                    */
                    BukkitScheduler scheduler1 = getServer().getScheduler();
                    scheduler1.scheduleAsyncDelayedTask(this, new Runnable() {
                    @Override
                    public void run() {
                            for (Player p_red : red){
                                TitlesAPI.sendTitle(p_red, 30, 5 * 20, 10, ChatColor.RED + "" + ChatColor.BOLD + "Wave 1");
                            Location loc = p_red.getLocation();
                            double x = loc.getX() - 10;
                            double y = loc.getY();
                            double z = loc.getZ() - 15;
                            Location loca = loc.add(x, y, z);
                            Block bl = loca.getBlock();
                            Material ma = bl.getType();
                            if (!(ma == Material.AIR)){
                                while (ma != Material.AIR){
                                    y++;
                                    loca = loc.add(x, y, z);
                                    if (ma == Material.AIR){
                                        p_red.getWorld().spawn(loca, ZombieVillager.class);
                                    }
                                }
                            } else {
                                p_red.getWorld().spawn(loca, ZombieVillager.class);
                            }
                           
                            zombik = (ZombieVillager) p_red.getWorld().spawnEntity(p_red.getLocation(), EntityType.ZOMBIE_VILLAGER);
                            zombik.setCustomName("Alfa");
                            zombik.setCustomNameVisible(false);
                            zombik.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 18000, 2));
                        }
                        }
                    }, 300L);
                    /*
                    ##########################################
                    #----------------- BLUE -----------------#
                    ##########################################
                    */
                    BukkitScheduler scheduler2 = getServer().getScheduler();
                    scheduler2.scheduleAsyncDelayedTask(this, new Runnable() {
                    @Override
                    public void run() {
                            for (Player p_blue : blue){
                                TitlesAPI.sendTitle(p_blue, 30, 5 * 20, 10, ChatColor.RED + "" + ChatColor.BOLD + "Wave 1");
                            Location loc = p_blue.getLocation();
                            double x = loc.getX() - 10;
                            double y = loc.getY();
                            double z = loc.getZ() - 15;
                            Location loca = loc.add(x, y, z);
                            Block bl = loca.getBlock();
                            Material ma = bl.getType();
                            if (!(ma == Material.AIR)){
                                while (ma != Material.AIR){
                                    y++;
                                    loca = loc.add(x, y, z);
                                    if (ma == Material.AIR){
                                        p_blue.getWorld().spawn(loca, ZombieVillager.class);
                                    }
                                }
                            } else {
                                p_blue.getWorld().spawn(loca, ZombieVillager.class);
                            }
                           
                            zombik1 = (ZombieVillager) p_blue.getWorld().spawnEntity(p_blue.getLocation(), EntityType.ZOMBIE_VILLAGER);
                            zombik1.setCustomName("Alfa");
                            zombik1.setCustomNameVisible(false);
                            zombik1.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 18000, 2));
                        }
                        }
                    }, 300L);
                   
                    }
                   
               
              
            }
       
        @EventHandler
        public void onPlayerQuit(PlayerQuitEvent e){
            Player pl = e.getPlayer();
            Bukkit.getServer().broadcastMessage(pl + " Left");
            if(list.contains(pl)){
                list.remove(pl);
            }
            else if(red.contains(pl)){
                red.remove(pl);
            }
            else if(blue.contains(pl)){
                blue.remove(pl);
            }
        }
    
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (sender instanceof Player){
                Player p = (Player) sender;
            if(command.getName().equalsIgnoreCase("watp")){
                    UUID uuid = p.getUniqueId();
                    red1.add(uuid);
                    list.add(p);
                    p.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "Budeš přesunut na herní lobby ");
                    World w = Bukkit.getWorld("apocalypse_lobby");
                    p.teleport(new Location(w, 37.00, 8.50, -4.00));
                    GameMode gm;
                    gm = GameMode.ADVENTURE;
                    p.setGameMode(gm);
                    if (p.getWorld().getName().equalsIgnoreCase("apocalypse_lobby")){
                         if(command.getName().equalsIgnoreCase("waleave")){
                            p.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "Opustil jsi herni lobby ");
                            World wo = Bukkit.getWorld("spawn2");
                            p.teleport(new Location(wo, -113.02, 68.00, -5.99));
                            GameMode GM;
                            GM = GameMode.SURVIVAL;
                            p.setGameMode(gm);
                            list.remove(p);
                            if(red.contains(p)){
                                red.remove(p);
                            }
                            else if(blue.contains(p)){
                                blue.remove(p);
                            }
                         }
                    }
                    return true;
                }
            if (command.getName().equals("wared")){
                if(list.contains(p) || blue.contains(p)){
                    p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + " Připojil ses do červeného týmu!");
                    list.remove(p);
                    red.add(p);
                    if(blue.contains(p)){
                        blue.remove(p);
                    }
                }
            }
            else if (command.getName().equals("wablue")){
                if(list.contains(p) || red.contains(p)){
                    p.sendMessage(sys + ChatColor.RED + "" + ChatColor.BOLD + " Připojil ses do modrého týmu!");
                    list.remove(p);
                    blue.add(p);
                    if(red.contains(p)){
                        red.remove(p);
                    }
                }
            }
                  
               
            return false;
            }
        return false;
        }
        @EventHandler
        public void entityDeathEvent(EntityDeathEvent e){
            Entity ent = e.getEntity();
            if(e.getEntity() instanceof Zombie){
                for(Player p : red){
                    if(e.getEntity().getKiller().equals(p)){
                        cerveny = cerveny + 1;
                        score1.setScore(cerveny);p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + cerveny);
                    }
                }
                for(Player p : blue){
                    if(e.getEntity().getKiller().equals(p)){
                        modry = modry + 1;
                        score1.setScore(modry);
                    }
                }
            }
            if(e.getEntity() instanceof Skeleton){
                for(Player p : red){
                    if(e.getEntity().getKiller().equals(p)){
                        cerveny = cerveny + 1;
                        score1.setScore(cerveny);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + cerveny);
                    }
                }
                for(Player p : blue){
                    if(e.getEntity().getKiller().equals(p)){
                        modry = modry + 1;
                        score1.setScore(modry);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + modry);
                    }
                }
            }
            if(e.getEntity() instanceof Spider){
                for(Player p : red){
                    if(e.getEntity().getKiller().equals(p)){
                        cerveny = cerveny + 1;
                        score1.setScore(cerveny);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + cerveny);
                    }
                }
                for(Player p : blue){
                    if(e.getEntity().getKiller().equals(p)){
                        modry = modry + 1;
                        score1.setScore(modry);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + modry);
                    }
                }
            }
            if(e.getEntity().getCustomName().equals("Alfa")){
                e.getEntity().getWorld().spawnParticle(Particle.DRAGON_BREATH, e.getEntity().getLocation(), 100);
                e.getEntity().getWorld().spawnParticle(Particle.DRAGON_BREATH, e.getEntity().getLocation().add(0, 1, 0), 100);
                for(Player p : red){
                    if(e.getEntity().getKiller().equals(p)){
                        cerveny = cerveny + 5;
                        score1.setScore(cerveny);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre bylo přičteno 5 bodů. Současné skóre je " + cerveny);
                    }
                }
                for(Player p : blue){
                    if(e.getEntity().getKiller().equals(p)){
                        modry = modry + 5;
                        score1.setScore(modry);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre bylo přičteno 5 bodů. Současné skóre je " + modry);
                    }
                }
            }
            if(e.getEntity() instanceof Player){
                for(Player p : red){
                    if(e.getEntity().getKiller().equals(p)){
                        cerveny = cerveny + 10;
                        score1.setScore(cerveny);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre bylo přičteno 10 bodů. Současné skóre je " + cerveny);
                    }
                }
                for(Player p : blue){
                    if(e.getEntity().getKiller().equals(p)){
                        modry = modry + 10;
                        score1.setScore(modry);
                        p.sendMessage(sys + ChatColor.RED + "K týmovému skóre bylo přičteno 10 bodů. Současné skóre je " + modry);
                    }
                }
            }
        }
    }
     
  8. @skales65
    I see your issue:
    You are never re-setting ma. Ma will always be equal to AIR, because it always set to loca's initial block. Inside the while loop, if ma is not equal to air, set ma equal to the new loca's block type.
     
  9. Offline

    skales65

    @Zombie_Striker Thanks. Now I know some crashes of my server when I used this in another plugin with particles xD. But what about Alfa? Is this bad blocking him? (Sry I didn't tried it yet. I was out)
    And how does UUID works? I know it is tag for entire player but what with that list? When player quit it will automaticly remove from list? What if player quit and then join again?
     
  10. Offline

    skales65

    @Zombie_Striker
    Nice Alfa is spawning :). I have replaced Async scheduler with Sync scheduler. (I don't know what was it but now it works :) ).

    Now problem is only scoreboard and killing mobs.
     
  11. @skales65
    Odd. I don't remember being notified about the other post. Sorry it took this long to respond.

    Do you have the logs of when the server was crashing? Does it still crash?

    For the scoreboard, what exactly was it that you need help with?
     
  12. Offline

    skales65

    @Zombie_Striker
    Crashing is OK now I know why it crashed - "Ma will always be equal to AIR"

    About scoreboard - almost everything. I have made some code but it isn't working. Can you help?

    Code:
    ScoreboardManager manager = Bukkit.getScoreboardManager();
                            Scoreboard board = manager.getNewScoreboard();
                            Team team1 = board.registerNewTeam(ChatColor.RED + "Red");
                            Team team2 = board.registerNewTeam(ChatColor.BLUE + "Blue");
                            for(Player pl : red){
                                team1.addPlayer(pl);
                                if(!(pl.isOnline())) team1.removePlayer(pl);
                            }
                            for(Player pl : blue){
                                team2.addPlayer(pl);
                                if(!(pl.isOnline())) team2.removePlayer(pl);
                            }
                            team1.setPrefix(ChatColor.RED + "RED");
                            team2.setPrefix(ChatColor.BLUE + "BLUE");
                            team1.setAllowFriendlyFire(false);
                            team2.setAllowFriendlyFire(false);
                            Objective objective = board.registerNewObjective("test", "dummy");
                            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                            objective.setDisplayName("Display Name");
                            Score score1 = objective.getScore(ChatColor.GREEN + "Kills:");
                            score1.setScore(cerveny);
                            Score score2 = objective.getScore(ChatColor.GREEN + "Kills:");
                            score2.setScore(modry);
                            for(Player pl : red){
                                pl.setScoreboard(board);
                            }
                            for(Player pl : blue){
                                pl.setScoreboard(board);
                            }
    I have copied some files from net but it didn't work too.
    Or I need some other API?
     
  13. @skales65
    Have you made any changes to the Ma while loop since the last time you posted? If not, the issue is that ma is not being updated in the loop, which is why it is not changing.

    Are you sure the code is being read? Is the code reachable?
     
  14. Offline

    skales65

    @Zombie_Striker
    Ye I know that problem. It wasn't updated :) Please main problem is that scoreboard and counting points :) If it will be problem I can make another thread with it but I don't need it now.

    Ye code is normaly reachable.
    Code:
    Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh");
                            Bukkit.broadcastMessage(ChatColor.RED + "bruh");
                            ScoreboardManager manager = Bukkit.getScoreboardManager();
                            Scoreboard board = manager.getNewScoreboard();
                            Team team1 = board.registerNewTeam(ChatColor.RED + "Red");
                            Team team2 = board.registerNewTeam(ChatColor.BLUE + "Blue");
                            for(Player pl : red){
                                team1.addPlayer(pl);
                                if(!(pl.isOnline())) team1.removePlayer(pl);
                            }
                            for(Player pl : blue){
                                team2.addPlayer(pl);
                                if(!(pl.isOnline())) team2.removePlayer(pl);
                            }
                            team1.setPrefix(ChatColor.RED + "RED");
                            team2.setPrefix(ChatColor.BLUE + "BLUE");
                            team1.setAllowFriendlyFire(false);
                            team2.setAllowFriendlyFire(false);
                            Objective objective = board.registerNewObjective("test", "dummy");
                            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                            objective.setDisplayName("Display Name");
                            Score score1 = objective.getScore(ChatColor.GREEN + "Kills:");
                            score1.setScore(cerveny);
                            Score score2 = objective.getScore(ChatColor.GREEN + "Kills:");
                            score2.setScore(modry);
                            for(Player pl : red){
                                pl.setScoreboard(board);
                            }
                            for(Player pl : blue){
                                pl.setScoreboard(board);
                            }
    "bruh
    bruh"
    will show me in the chat
     
  15. @skales65
    Are you sure you are in the red or blue team? Are you sure that they are not empty?
     
  16. Offline

    skales65

    @Zombie_Striker
    Ye I have tried to write before check for team
    Code:
    for(Player pl : red){
                                pl.sendMessage("Checking for team red");
                            }
                            for(Player pl : blue){
                                pl.sendMessage("Checking for team blue");
                            }
    screenshot
    https://ctrlv.cz/FUkj

    I have tried to place it like
    Code:
    for(Player pl : red){
                                pl.setScoreboard(board);
                                pl.sendMessage("Checking for team red");
                            }
    but it didn't work. (whole code stucked)

    Am I using good API btw? I have Bukkit 1.11.2. Is this scoreboard working on it?
    Here is some copied scoreboards - didn't work too.

    Code:
    package me.skales65;
    
    import java.util.ArrayList;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitScheduler;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;
    
    public class ScoreBoard extends JavaPlugin implements Listener {
    
        static ArrayList<String> A = new ArrayList<String>();
       
        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
            Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "AnimateScoreboard is now enabled!");
        }
       
        public void add(final Player player) {
            final ScoreboardManager manager = Bukkit.getScoreboardManager();
            final Scoreboard board = manager.getNewScoreboard();
           
            Objective objective = board.registerNewObjective("Scoreboard", "dummy");
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
           
            Score spacer = objective.getScore("§f");
            spacer.setScore(2);
           
            Score score = objective.getScore(ChatColor.WHITE + "Thanks for playing!");
            score.setScore(1);
           
            A.clear();
            A.add("1");
           
            BukkitScheduler Scheduler = Bukkit.getServer().getScheduler();
            Scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
                @Override
                public void run() {
                    Integer i = A.size();
                    if(i == 1) {
                        objective.setDisplayName(Colors("&b&lAnimateScoreboard"));
                        A.add("A");
                    }
                    if(i == 2) {
                        objective.setDisplayName(Colors("&5&lAnimateScoreboard"));
                        A.add("B");
                    }
                    if(i == 3) {
                        objective.setDisplayName(Colors("&d&lAnimateScoreboard"));
                        A.add("C");
                    }
                    if(i == 3) {
                        A.clear();
                        A.add("1");
                    }
                }
            }, 0, 5);
            player.setScoreboard(board);
        }
       
        public static String Colors(String text) {
            return text.replaceAll("&", "§");
        }
       
        @EventHandler
        public void PlayerJoinEvent(PlayerJoinEvent e) {
            Player p = e.getPlayer();
            this.add(p);
        }
       
    }
    btw: do you know why it isn't removing player when he leave?
    Code:
    @EventHandler
        public void onPlayerQuit(PlayerQuitEvent e){
            Player p = e.getPlayer();
            if(list.contains(p)){
                list.remove(p);
            }
            else if(red.contains(p)){
                red.remove(p);
            }
            else if(blue.contains(p)){
                blue.remove(p);
            }
        }
     
  17. @skales65
    Then that means that either red clears itself between those two points, or one of the lines of coding is getting stuck. First, try moving the message out of the for loop. If that works, then red clears itself somehow. For this, you will need to re-read your code and move the line around until you find the line that is clearing the scoreboard.

    If it does not work, then one of the lines above is stopping the code. Move the message up until the message gets sent. If this is the case, post which line is causing the problem.
     
  18. Offline

    skales65

    @Zombie_Striker
    I have made this
    Code:
    for(Player pl : red){
                                pl.sendMessage("Checking for team red");
                            }
                            for(Player pl : blue){
                                pl.sendMessage("Checking for team blue");
                            }
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh");
                            Bukkit.broadcastMessage(ChatColor.RED + "bruh");
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh1");
                            ScoreboardManager manager = Bukkit.getScoreboardManager();
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_manager");
                            Scoreboard board = manager.getNewScoreboard();
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_board");
                            Team team1 = board.registerNewTeam(ChatColor.RED + "Red");
                            Team team2 = board.registerNewTeam(ChatColor.BLUE + "Blue");
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_teams");
                            for(Player pl : red){
                                team1.addPlayer(pl);
                                if(!(pl.isOnline())) team1.removePlayer(pl);
                            }
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_team_add");
                            for(Player pl : blue){
                                team2.addPlayer(pl);
                                if(!(pl.isOnline())) team2.removePlayer(pl);
                            }
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_team_add2");
                            team1.setPrefix(ChatColor.RED + "RED");
                            team2.setPrefix(ChatColor.BLUE + "BLUE");
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_prefix");
                            team1.setAllowFriendlyFire(false);
                            team2.setAllowFriendlyFire(false);
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_FF");
                            Objective objective = board.registerNewObjective("test", "dummy");
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_objective");
                            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_sidebar");
                            objective.setDisplayName("Display Name");
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_setdisplayname");
                            Score score1 = objective.getScore(ChatColor.GREEN + "Kills:");
                            score1.setScore(cerveny);
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_kills");
                            Score score2 = objective.getScore(ChatColor.GREEN + "Kills:");
                            score2.setScore(modry);
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_kills2");
                            for(Player pl : red){
                                Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_add");
                                pl.setScoreboard(board);
                            }
                            for(Player pl : blue){
                                pl.setScoreboard(board);
                            }
                            Bukkit.getPlayer("skales65").sendMessage(ChatColor.RED + "bruh_set_score");
    I have joined into red team and It send me this:
    bruh
    bruh
    bruh1
    bruh_manager
    bruh_board
    bruh_teams
    bruh_team_add
    bruh_team_add2
    bruh_prefix
    bruh_FF
    bruh_objective
    bruh_sidebar
    bruh_setdisplayname
    bruh_kills
    bruh_kills2
    bruh_add
    bruh_set_score

    BTW I saw this

    Code:
    [20:31:16 ERROR]: Could not pass event EntityDeathEvent to Apocalypse v1.0
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.craftbukkit.v1_11_R1.event.CraftEventFactory.callEntityDeathEvent(CraftEventFactory.java:394) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityLiving.die(EntityLiving.java:1079) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntitySkeletonAbstract.die(EntitySkeletonAbstract.java:120) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntitySkeleton.die(EntitySkeleton.java:46) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityLiving.damageEntity(EntityLiving.java:933) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityMonster.damageEntity(EntityMonster.java:44) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.Entity.U(Entity.java:431) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityLiving.U(EntityLiving.java:197) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityInsentient.U(EntityInsentient.java:184) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.Entity.A_(Entity.java:312) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityLiving.A_(EntityLiving.java:1820) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityInsentient.A_(EntityInsentient.java:244) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityMonster.A_(EntityMonster.java:28) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.World.entityJoinedWorld(World.java:1631) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.World.h(World.java:1606) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.World.tickEntities(World.java:1432) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.WorldServer.tickEntities(WorldServer.java:618) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:814) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_74]
    Caused by: java.lang.NullPointerException
    at com.javaminecraft.Apocalypse.entityDeathEvent(Apocalypse.java:374) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_74]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_74]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_74]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_74]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    ... 25 more
    and this

    Code:
    [20:31:20 WARN]: [Apocalypse] Task #103 for Apocalypse v1.0 generated an exception
    java.lang.ClassCastException: org.bukkit.material.Chest cannot be cast to org.bukkit.block.Chest
    at com.javaminecraft.Apocalypse$1.run(Apocalypse.java:193) ~[?:?]
    at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:738) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_74]
    [20:31:23 INFO]: skales65 issued server command: /c
    [20:31:25 INFO]: §c[TitleWelcomeMessage] You dont have Clip's PlaceholderAPI installed, if you want more than 1k placeholders, please install it.
    [20:32:19 ERROR]: Could not pass event EntityDeathEvent to Apocalypse v1.0
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.craftbukkit.v1_11_R1.event.CraftEventFactory.callEntityDeathEvent(CraftEventFactory.java:394) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityLiving.die(EntityLiving.java:1079) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityLiving.damageEntity(EntityLiving.java:933) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityBat.damageEntity(SourceFile:203) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.Entity.U(Entity.java:431) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityLiving.U(EntityLiving.java:197) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityInsentient.U(EntityInsentient.java:184) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.Entity.A_(Entity.java:312) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityLiving.A_(EntityLiving.java:1820) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityInsentient.A_(EntityInsentient.java:244) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityBat.A_(SourceFile:112) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.World.entityJoinedWorld(World.java:1631) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.World.h(World.java:1606) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.World.tickEntities(World.java:1432) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.WorldServer.tickEntities(WorldServer.java:618) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:814) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_74]
    Caused by: java.lang.NullPointerException
    at com.javaminecraft.Apocalypse.entityDeathEvent(Apocalypse.java:404) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_74]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_74]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_74]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_74]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    ... 23 more
     
    1. Something is null on line 374. What is that line?
    2. On line 193, you are casting a material Chest to a block Chest. You need to cast the block's state to a chest.
    3. Something on line 404 is null. Can you post that line?
     
  19. Offline

    skales65

    @Zombie_Striker
    1. if(e.getEntity().getKiller().equals(p)){
    2. getState().setData()?
    3. if(e.getEntity().getCustomName().equals("Alfa")){
     
  20. @skales65
    1. The killer can be null if the entity died of something other than a player (such as falling, hunger, or a creeper). Null check killer before you test if it is a player.
    2. Don't set the data. Just cast getState to a chest.
    3. The custom name can be null if the entity does not have a custom name. Null check the custom name before you check what is equal to.
     
  21. Offline

    skales65

    @Zombie_Striker
    1.
    if(e.getEntity().getKiller() != null){
    if(e.getEntity() instanceof Zombie){
    for(Player p : red){
    ... ?

    2. Chest chest = (Chest) chestloc1.getBlock().getState(); I have this. Anything more?
    3.
    if(e.getEntity().getCustomName() != null){
    if(e.getEntity().getCustomName().equals("Alfa")){
    ... ?
     
  22. @skales65
    1. Yes
    2. That should be enough
    3. And yes, that should work.
     
  23. Offline

    skales65

    @Zombie_Striker
    1.
    Code:
    [22:09:53 ERROR]: Could not pass event EntityDeathEvent to Apocalypse v1.0
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at org.bukkit.craftbukkit.v1_11_R1.event.CraftEventFactory.callEntityDeathEvent(CraftEventFactory.java:394) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityLiving.die(EntityLiving.java:1079) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityZombie.die(EntityZombie.java:429) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityLiving.damageEntity(EntityLiving.java:933) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityMonster.damageEntity(EntityMonster.java:44) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityZombie.damageEntity(EntityZombie.java:163) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityHuman.attack(EntityHuman.java:1023) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.EntityPlayer.attack(EntityPlayer.java:1158) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.PlayerConnection.a(PlayerConnection.java:1578) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.PacketPlayInUseEntity.a(SourceFile:69) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.PacketPlayInUseEntity.a(SourceFile:13) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.PlayerConnectionUtils$1.run(SourceFile:13) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_74]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_74]
    at net.minecraft.server.v1_11_R1.SystemUtils.a(SourceFile:46) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:747) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_74]
    Caused by: java.lang.NullPointerException
    at com.javaminecraft.Apocalypse.entityDeathEvent(Apocalypse.java:363) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_74]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_74]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_74]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_74]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[minecraft_server.jar:git-Spigot-3fb9445-6e3cec8]
    ... 23 more
    2. Umm is this Ok?
    https://ctrlv.cz/GoDz
    Edit: that must be chest. Behind is chest with working items
    https://ctrlv.cz/hEqP
    but not good too :p (bad loc)

    3. it is same event as 1.

    Btw I am going out and I will be back on friday
     
  24. @skales65
    1. Something is null on line 363. Can you post that line?
    2. Strange, but that just seems like a graphic glitch. Try relogging and see if the chest appears.
     
  25. Offline

    skales65

    @Zombie_Striker

    363 - I have there 2 lines in 1 is it big problem?
    Code:
     score1.setScore(cerveny);p.sendMessage(sys + ChatColor.RED + "K týmovému skóre byl přičten 1 bod. Současné skóre je " + cerveny);
    that "chest" is empty as I can see

    https://ctrlv.cz/wNCI

    some chests are normal.
     
  26. @skales65
    1. Don't stack lines. This is the reason why. I now have to check which line is null:
    2. Is score1 null?
    3. Is Cerveny null?
    4. Is sys null?
    5. Is p null?
    6. For the empty chest, is that image of what you see in the chest, because it does not look empty.
     
  27. Offline

    skales65

    @Zombie_Striker
    score1 can be null
    Code:
    int cerveny = 0;
        int modry = 0;
        Score score1;
        Score score2;
        String sys = ChatColor.GRAY + "[" + ChatColor.RED + "" + ChatColor.BOLD + "Apocalypse" + ChatColor.GRAY + "]";
    
    But how to make it "not null"?

    That chest was empty before.
     
  28. @skales65
    Set it equal to something. What is it supposed to be equal to? Whose score is it supposed to represent?
     
  29. Offline

    skales65

    @Zombie_Striker
    score1 should be red team and score2 blue team. cerveny is points for red team and modry for blue team, but i can't do Score score1 = cerveny;. Or equal to something else?
     

Share This Page