Scoreboard help D:

Discussion in 'Plugin Development' started by Treeline1, Jan 25, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Treeline1

    ATM I have created this scoreboard... And I am trying to use it to tally kill count etc. But atm, I cant even display the scoreboard! And Im not sure why!!! Can someone help?
    Code:
    package me.liam.main;
    
    
    
    import java.util.ArrayList;
    
    import me.liam.commands.ArcherCommand;
    import me.liam.commands.ChestCommand;
    import me.liam.commands.FishermanCommand;
    import me.liam.commands.Flames;
    import me.liam.commands.GravitatorCommand;
    import me.liam.commands.Hearts;
    import me.liam.commands.HopperCommand;
    import me.liam.commands.JuggernautCommand;
    import me.liam.commands.KitCommand;
    import me.liam.commands.MarioCommand;
    import me.liam.commands.Menu;
    import me.liam.commands.PilotCommand;
    import me.liam.commands.RageCommand;
    import me.liam.commands.RemoverCommand;
    import me.liam.commands.ScoutCommand;
    import me.liam.commands.Smoke;
    import me.liam.commands.SniperCommand;
    import me.liam.commands.SoupCommand;
    import me.liam.commands.SpawnCommand;
    import me.liam.commands.SquashCommand;
    import me.liam.commands.SquidCommand;
    import me.liam.event.BlockListener;
    import me.liam.event.DamageListener;
    import me.liam.event.InventoryListener;
    import me.liam.event.KillstreakEvent;
    import me.liam.event.PlayerListener;
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    import net.milkbowl.vault.permission.Permission;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.RegisteredServiceProvider;
    import org.bukkit.plugin.java.JavaPlugin;
    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 Kitpvp extends JavaPlugin implements Listener{
    
        public static Economy econ = null;
        public static Kitpvp inst;
        public static Permission permission = null;
        private Menu menu;
    
    
        private boolean setupPermissions() {
            RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
            permission = rsp.getProvider();
            return permission != null;
        }
    
        private ArrayList<Player> vanished = new ArrayList<Player>();
        private PlayerListener Events = new PlayerListener(this);
        public ArrayList<String> KitCommand = new ArrayList<String>();
        public ArrayList<String> SniperCommand = new ArrayList<String>();
        public ArrayList<String> HopperCommand = new ArrayList<String>();
        public ArrayList<String> RageCommand = new ArrayList<String>();
        public ArrayList<String> FishermanCommand = new ArrayList<String>();
        public ArrayList<String> PilotCommand = new ArrayList<String>();
        public ArrayList<String> MarioCommand = new ArrayList<String>();
        public ArrayList<String> ScoutCommand = new ArrayList<String>();
        public ArrayList<String> ArcherCommand = new ArrayList<String>();
        public ArrayList<String> SquashCommand = new ArrayList<String>();
        public ArrayList<String> SoupCommand = new ArrayList<String>();
        public ArrayList<String> ChestCommand = new ArrayList<String>();
        public ArrayList<String> SquidCommand = new ArrayList<String>();
        public ArrayList<String> BatmanCommand = new ArrayList<String>();
        public ArrayList<String> JuggernautCommand = new ArrayList<String>();
        public ArrayList<String> GravitatorCommand = new ArrayList<String>();
        public ArrayList<String> RemoverCommand = new ArrayList<String>();
        public ArrayList<String> ParticleEffects = new ArrayList<String>();
        public ArrayList<String> kitused = new ArrayList<String>();
        public ArrayList<String> particleused = new ArrayList<String>();
    
        public ArrayList<String> Hearts = new ArrayList<String>();
        public ArrayList<String> Smoke = new ArrayList<String>();
        public ArrayList<String> Flames = new ArrayList<String>();
    
    
          public void showScoreboard(Player player) {
                ScoreboardManager manager = Bukkit.getScoreboardManager();
                Scoreboard board = manager.getNewScoreboard();
                player.setScoreboard(board);
        
                Objective objective = board.registerNewObjective("test", "dummy");
                objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                objective.setDisplayName("ScoreBoard");
                Score score = objective.getScore(ChatColor.GREEN + "Kills:");
                score.setScore(1);
            }
    
        @Override
        public void onEnable() {
            for(Player current : Bukkit.getOnlinePlayers()) {
                showScoreboard(current);
            }
    
    
            PluginManager pm = getServer().getPluginManager();
            setupPermissions();
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            inst = this;
            menu = new Menu(this);
            if (!setupEconomy() ) {
                getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
                getServer().getPluginManager().disablePlugin(this);
                return;
            }
    
            Bukkit.getServer().getPluginManager().registerEvents(menu, this);
            pm.registerEvents(new DamageListener(), this);
            pm.registerEvents(new BlockListener(), this);
            pm.registerEvents(new InventoryListener(), this);
            pm.registerEvents(new PlayerListener(this), this);
            pm.registerEvents(new HopperCommand(this), this);
            pm.registerEvents(new JuggernautCommand(this), this);
            pm.registerEvents(new RageCommand(this), this);
            pm.registerEvents(new MarioCommand(this), this);
            pm.registerEvents(new PilotCommand(this), this);
            pm.registerEvents(new SquidCommand(this), this);
            pm.registerEvents(new FishermanCommand(this), this);
            pm.registerEvents(new GravitatorCommand(this), this);
            pm.registerEvents(new RemoverCommand(this), this);
            pm.registerEvents(new SniperCommand(this), this);
            pm.registerEvents(new KillstreakEvent(this), this);
            pm.registerEvents(new Menu(this), this);
            pm.registerEvents(new SquashCommand(this), this);
            getCommand("archer").setExecutor(new ArcherCommand(this));
            getCommand("mario").setExecutor(new MarioCommand(this));
            getCommand("squash").setExecutor(new SquashCommand(this));
            getCommand("hopper").setExecutor(new HopperCommand(this));
            getCommand("pilot").setExecutor(new PilotCommand(this));
            getCommand("rage").setExecutor(new RageCommand(this));
            getCommand("pvp").setExecutor(new KitCommand(this));
            getCommand("scout").setExecutor(new ScoutCommand(this));
            getCommand("sniper").setExecutor(new SniperCommand(this));
            getCommand("squid").setExecutor(new SquidCommand(this));
            getCommand("fisherman").setExecutor(new FishermanCommand(this));
            getCommand("gravitator").setExecutor(new GravitatorCommand(this));
            getCommand("remover").setExecutor(new RemoverCommand(this));
    
            getCommand("flames").setExecutor(new Flames(this));
            getCommand("heart").setExecutor(new Hearts(this));
            getCommand("smoke").setExecutor(new Smoke(this));
    
            getCommand("vanish").setExecutor(this);
            getCommand("buyfisherman").setExecutor(this);
            getCommand("buyrage").setExecutor(this);
            getCommand("buyjuggernaut").setExecutor(this);
            getCommand("buysniper").setExecutor(this);
            getCommand("buysquash").setExecutor(this);
            getCommand("buyhopper").setExecutor(this);
            getCommand("buyremover").setExecutor(this);
            getCommand("buygravitator").setExecutor(this);
            getCommand("buysquid").setExecutor(this);
            getCommand("squid").setExecutor(this);
            getCommand("buyscout").setExecutor(this);
            getCommand("buypilot").setExecutor(this);
            getCommand("tphere").setExecutor(this);
            getCommand("tp").setExecutor(this);
            getCommand("juggernaut").setExecutor(new JuggernautCommand(this));
            getCommand("chest").setExecutor(new ChestCommand(this));
            getCommand("soup").setExecutor(new SoupCommand());
            getCommand("spawn").setExecutor(new SpawnCommand());
    
            System.out.println("KitPVP Enabled!");
        }
    
    
    
        public void onDisabled(){
            System.out.println("KitPVP Disabled!");
        }
        public void events() {
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents(this.Events, this);
        }
    
    
        private boolean setupEconomy() {
            if (getServer().getPluginManager().getPlugin("Vault") == null) {
                return false;
            }
            RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
            if (rsp == null) {
                return false;
            }
            econ = rsp.getProvider();
            return econ != null;
        }
    
    
    
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player player = null;
            if (sender instanceof Player){
                player = (Player) sender;
            }
    
            if (command.getName().equalsIgnoreCase("buyfisherman")){
                if (player != null){
                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                    if (r.transactionSuccess()) {
                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "fisherman.set");
                        player.sendMessage(ChatColor.RED + "You bought the Fisherman kit!");
                    }
    
                }
            }else
                if (command.getName().equalsIgnoreCase("buyscout")){
                    if (player != null){
                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                        if (r.transactionSuccess()) {
                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "scout.set");
                            player.sendMessage(ChatColor.RED + "You bought the Scout kit!");
                        }
                    }
                }else
                    if (command.getName().equalsIgnoreCase("buypilot")){
                        if (player != null){
                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                            if (r.transactionSuccess()) {
                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "pilot.set");
                                player.sendMessage(ChatColor.RED + "You bought the Pilot kit!");
                            }
                        }
                    }else
                        if (command.getName().equalsIgnoreCase("buyrage")){
                            if (player != null){
                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 3500);
                                if (r.transactionSuccess()) {
                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "rage.set");
                                    player.sendMessage(ChatColor.RED + "You bought the Rage kit!");
                                }
                            }
                        }else
                            if (command.getName().equalsIgnoreCase("buyjuggernaut")){
                                if (player != null){
                                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                    if (r.transactionSuccess()) {
                                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "juggernaut.set");
                                        player.sendMessage(ChatColor.RED + "You bought the Juggernaut kit!");
                                    }
                                }
                            }else
                                if (command.getName().equalsIgnoreCase("buymario")){
                                    if (player != null){
                                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 2000);
                                        if (r.transactionSuccess()) {
                                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "mario.set");
                                            player.sendMessage(ChatColor.RED + "You bought the Mario kit!");
                                        }
                                    }
                                }else
                                    if (command.getName().equalsIgnoreCase("buyhopper")){
                                        if (player != null){
                                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 2500);
                                            if (r.transactionSuccess()) {
                                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "hopper.set");
                                                player.sendMessage(ChatColor.RED + "You bought the Hopper kit!");
                                            }
                                        }
                                    }else
                                        if (command.getName().equalsIgnoreCase("buysquash")){
                                            if (player != null){
                                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 2500);
                                                if (r.transactionSuccess()) {
                                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "squash.set");
                                                    player.sendMessage(ChatColor.RED + "You bought the Squash kit!");
                                                }
                                            }
                                        }else
                                            if (command.getName().equalsIgnoreCase("buysnpier")){
                                                if (player != null){
                                                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 1750);
                                                    if (r.transactionSuccess()) {
                                                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "sniper.set");
                                                        player.sendMessage(ChatColor.RED + "You bought the Sni[er kit!");
                                                    }
                                                }
                                            }else
                                                if (command.getName().equalsIgnoreCase("buyremover")){
                                                    if (player != null){
                                                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 1000);
                                                        if (r.transactionSuccess()) {
                                                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "remover.set");
                                                            player.sendMessage(ChatColor.RED + "You bought the Remover kit!");
                                                        }
                                                    }
                                                }else
                                                    if (command.getName().equalsIgnoreCase("buygravitator")){
                                                        if (player != null){
                                                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                                            if (r.transactionSuccess()) {
                                                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "gravitator.set");
                                                                player.sendMessage(ChatColor.RED + "You bought the Gravitator kit!");
                                                            }
                                                        }
                                                    }else
                                                        if (command.getName().equalsIgnoreCase("buysquid")){
                                                            if (player != null){
                                                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                                                                if (r.transactionSuccess()) {
                                                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "squid.set");
                                                                    player.sendMessage(ChatColor.RED + "You bought the Squid kit!");
                                                                }
                                                            }
                                                        }
    
    
    
    
    
    
    
    
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "You cannot vanish!");
                return true;
            }
    
            //Someone teleport to you
            Player pla = (Player) sender;
    
            if(command.getName().equalsIgnoreCase("tphere")){
                if(pla.hasPermission("tphere.set")){
                    Player teleportTo = getServer().getPlayer(args[0]);
                    Location teleportToLoc = pla.getLocation();
                    teleportTo.teleport(teleportToLoc);
                    return true;
                }
            }
    
            //Teleport to someone
            if(command.getName().equalsIgnoreCase("tp")){
                if(pla.hasPermission("tp.set")){
                    if(args.length == 0){
                        player.sendMessage(ChatColor.RED + "Not enough arguments! /tp <player>");
                    }else if(args.length == 1){
                        Player targetPlayer = player.getServer().getPlayer(args[0]);
                        Location targetPlayerLocation = targetPlayer.getLocation();
                        player.teleport(targetPlayerLocation);
    
                        return true;
                    }
                }
            }
    
    
            //VanishCommand
            Player p = (Player) sender;
    
            if (command.getName().equalsIgnoreCase("vanish")) {
                if(sender.hasPermission("vanish.set")){
                    if (!vanished.contains(p)) {
                        for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                            pl.hidePlayer(p);
                        }
                        vanished.add(p);
                        p.sendMessage(ChatColor.GREEN + "You have been vanished!");
                        return true;
                    }
                    else {
                        for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                            pl.showPlayer(p);
                        }
                        vanished.remove(p);
                        p.sendMessage(ChatColor.GREEN + "You have been unvanished!");
                        return true;
                    }
                }
            }
    
    
            return true;
    
        }
    
    
        @EventHandler
        public void onPlayerDeath(PlayerDeathEvent event){
            if(event.getEntity() instanceof Player) {
                Player p = (Player) event.getEntity().getPlayer();
                if(event.getEntity().getKiller() instanceof Player) {
                    econ.depositPlayer(p.getKiller(), 15);
                }
    
            }
        }
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event)  {
            Player player = event.getPlayer();
            if (event.getAction() == Action.PHYSICAL) {
                Block block = event.getClickedBlock();
                if (block == null) return;
                if (block.getType() == Material.SOIL){
                    event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
                    event.setCancelled(true);
                    block.setTypeIdAndData(block.getType().getId(), block.getData(), true);
                }
            }
        }
    
    
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e) {
            for (Player p : vanished) {
                if(p.hasPermission("vanish.set")){
                    e.getPlayer().hidePlayer(p);
                }
            }
            showScoreboard(e.getPlayer());
        }
    
        @EventHandler
        public void onPlayerLeave(PlayerQuitEvent e) {
            vanished.remove(e.getPlayer());
        }
    
    }
    
    
    
     
  2. Offline

    567legodude

    I'm not sure if this would affect it at all but you could try not setting the players scoreboard until after you set the objective.
     
  3. Offline

    Treeline1

    No that doesnt do anything :(
     
  4. Offline

    567legodude

    Try defining the scoreboard manager with all your ArrayLists. And set the manager to Bukkit.getScoreboardManager() inside of the onEnable.

    After that, do your function again referencing the manager you defined.

    See if that works.
     
  5. Offline

    ColonelHedgehog

    You're not getting any errors, correct? You should be.

    Keep in mind, Scoreboard objectives stick with the runtime. Your showScoreboard() method creates a new objective each time you call it. Store the scoreboard and objective(s) in private variables, and don't re-initialize the Objective.

    Also, just so you know, "test" is a very common Scoreboard name. To avoid conflict with other plugins, come up with a unique name. In fact, this might be one of the contributing factors to your problem.
     
  6. Offline

    Treeline1

    Nope no errors :/
    And with storing them in private variables... How do i go about doin that. Do you mean like private scoreboard = score; or whatever?
     
  7. Offline

    ColonelHedgehog

    Well, you'd initialize "scoreboard" onEnable.
     
  8. Offline

    Treeline1

    for(Player current : Bukkit.getOnlinePlayers()) {
    showScoreboard(current);
    }

    Is my onEnable?
     
  9. Offline

    Permeer

    @Treeline1

    Code:
     ScoreboardManager manager = Bukkit.getScoreboardManager();
               Scoreboard board = manager.getNewScoreboard();
                player.setScoreboard(board);
     
                Objective objective = board.registerNewObjective("test", "dummy");
                objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                objective.setDisplayName("ScoreBoard");
                Score score = objective.getScore(ChatColor.GREEN + "Kills:");
                score.setScore(1);
    [/LIST]
    to

    Code:
     ScoreboardManager manager = Bukkit.getScoreboardManager();
                Scoreboard board = manager.getNewScoreboard();
     
                Objective objective = board.registerNewObjective("test", "dummy");
                objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                objective.setDisplayName("ScoreBoard");
                Score score = objective.getScore(ChatColor.GREEN + "Kills:");
                score.setScore(1);
    player.setScoreboard(board);
    on Enable create a schedule of 20 ticks then you set the scoreboard to the players
     
  10. @Treeline1 Instead of initializing it onEnable it would be a lot better (and smarter) to initialize it onPlayerJoin because if you're doing it onEnable, you're only getting the players that are already online (which would be none since you're just starting the server up...).
     
  11. Offline

    Treeline1

    @Permeer @CodePlaysMinecraft
    Ok, so I tried putting it to 20 ticks in the on enable, but that didn't seem to work. And I tried to set it for playerJoin but that doesnt work either :/
    Heres my updated code:
    Code:
    package me.liam.main;
    
    
    
    import java.util.ArrayList;
    
    import me.liam.commands.ArcherCommand;
    import me.liam.commands.ChestCommand;
    import me.liam.commands.FishermanCommand;
    import me.liam.commands.Flames;
    import me.liam.commands.GravitatorCommand;
    import me.liam.commands.Hearts;
    import me.liam.commands.HopperCommand;
    import me.liam.commands.JuggernautCommand;
    import me.liam.commands.KitCommand;
    import me.liam.commands.MarioCommand;
    import me.liam.commands.Menu;
    import me.liam.commands.PilotCommand;
    import me.liam.commands.RageCommand;
    import me.liam.commands.RemoverCommand;
    import me.liam.commands.ScoutCommand;
    import me.liam.commands.Smoke;
    import me.liam.commands.SniperCommand;
    import me.liam.commands.SoupCommand;
    import me.liam.commands.SpawnCommand;
    import me.liam.commands.SquashCommand;
    import me.liam.commands.SquidCommand;
    import me.liam.event.BlockListener;
    import me.liam.event.DamageListener;
    import me.liam.event.InventoryListener;
    import me.liam.event.KillstreakEvent;
    import me.liam.event.PlayerListener;
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    import net.milkbowl.vault.permission.Permission;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.RegisteredServiceProvider;
    import org.bukkit.plugin.java.JavaPlugin;
    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 Kitpvp extends JavaPlugin implements Listener{
    
        public static Economy econ = null;
        public static Kitpvp inst;
        public static Permission permission = null;
        private Menu menu;
    
    
        private boolean setupPermissions() {
            RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
            permission = rsp.getProvider();
            return permission != null;
        }
    
        private ArrayList<Player> vanished = new ArrayList<Player>();
        private PlayerListener Events = new PlayerListener(this);
        public ArrayList<String> KitCommand = new ArrayList<String>();
        public ArrayList<String> SniperCommand = new ArrayList<String>();
        public ArrayList<String> HopperCommand = new ArrayList<String>();
        public ArrayList<String> RageCommand = new ArrayList<String>();
        public ArrayList<String> FishermanCommand = new ArrayList<String>();
        public ArrayList<String> PilotCommand = new ArrayList<String>();
        public ArrayList<String> MarioCommand = new ArrayList<String>();
        public ArrayList<String> ScoutCommand = new ArrayList<String>();
        public ArrayList<String> ArcherCommand = new ArrayList<String>();
        public ArrayList<String> SquashCommand = new ArrayList<String>();
        public ArrayList<String> SoupCommand = new ArrayList<String>();
        public ArrayList<String> ChestCommand = new ArrayList<String>();
        public ArrayList<String> SquidCommand = new ArrayList<String>();
        public ArrayList<String> BatmanCommand = new ArrayList<String>();
        public ArrayList<String> JuggernautCommand = new ArrayList<String>();
        public ArrayList<String> GravitatorCommand = new ArrayList<String>();
        public ArrayList<String> RemoverCommand = new ArrayList<String>();
        public ArrayList<String> ParticleEffects = new ArrayList<String>();
        public ArrayList<String> kitused = new ArrayList<String>();
        public ArrayList<String> particleused = new ArrayList<String>();
    
        public ArrayList<String> Hearts = new ArrayList<String>();
        public ArrayList<String> Smoke = new ArrayList<String>();
        public ArrayList<String> Flames = new ArrayList<String>();
    
    
        public void showScoreboard(Player player) {
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
    
            Objective objective = board.registerNewObjective("test", "dummy");
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
            objective.setDisplayName("ScoreBoard");
            Score score = objective.getScore(ChatColor.GREEN + "Kills:");
            score.setScore(1);
            player.setScoreboard(board);
        }
    
        @Override
        public void onEnable() {
            for(final Player current : Bukkit.getOnlinePlayers()) {
                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                    public void run() {
                        showScoreboard(current);
                    }
                },20);
            }
    
    
                PluginManager pm = getServer().getPluginManager();
                setupPermissions();
                Bukkit.getServer().getPluginManager().registerEvents(this, this);
                inst = this;
                menu = new Menu(this);
                if (!setupEconomy() ) {
                    getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
                    getServer().getPluginManager().disablePlugin(this);
                    return;
                }
    
                Bukkit.getServer().getPluginManager().registerEvents(menu, this);
                pm.registerEvents(new DamageListener(), this);
                pm.registerEvents(new BlockListener(), this);
                pm.registerEvents(new InventoryListener(), this);
                pm.registerEvents(new PlayerListener(this), this);
                pm.registerEvents(new HopperCommand(this), this);
                pm.registerEvents(new JuggernautCommand(this), this);
                pm.registerEvents(new RageCommand(this), this);
                pm.registerEvents(new MarioCommand(this), this);
                pm.registerEvents(new PilotCommand(this), this);
                pm.registerEvents(new SquidCommand(this), this);
                pm.registerEvents(new FishermanCommand(this), this);
                pm.registerEvents(new GravitatorCommand(this), this);
                pm.registerEvents(new RemoverCommand(this), this);
                pm.registerEvents(new SniperCommand(this), this);
                pm.registerEvents(new KillstreakEvent(this), this);
                pm.registerEvents(new Menu(this), this);
                pm.registerEvents(new SquashCommand(this), this);
                getCommand("archer").setExecutor(new ArcherCommand(this));
                getCommand("mario").setExecutor(new MarioCommand(this));
                getCommand("squash").setExecutor(new SquashCommand(this));
                getCommand("hopper").setExecutor(new HopperCommand(this));
                getCommand("pilot").setExecutor(new PilotCommand(this));
                getCommand("rage").setExecutor(new RageCommand(this));
                getCommand("pvp").setExecutor(new KitCommand(this));
                getCommand("scout").setExecutor(new ScoutCommand(this));
                getCommand("sniper").setExecutor(new SniperCommand(this));
                getCommand("squid").setExecutor(new SquidCommand(this));
                getCommand("fisherman").setExecutor(new FishermanCommand(this));
                getCommand("gravitator").setExecutor(new GravitatorCommand(this));
                getCommand("remover").setExecutor(new RemoverCommand(this));
    
                getCommand("flames").setExecutor(new Flames(this));
                getCommand("heart").setExecutor(new Hearts(this));
                getCommand("smoke").setExecutor(new Smoke(this));
    
                getCommand("vanish").setExecutor(this);
                getCommand("buyfisherman").setExecutor(this);
                getCommand("buyrage").setExecutor(this);
                getCommand("buyjuggernaut").setExecutor(this);
                getCommand("buysniper").setExecutor(this);
                getCommand("buysquash").setExecutor(this);
                getCommand("buyhopper").setExecutor(this);
                getCommand("buyremover").setExecutor(this);
                getCommand("buygravitator").setExecutor(this);
                getCommand("buysquid").setExecutor(this);
                getCommand("squid").setExecutor(this);
                getCommand("buyscout").setExecutor(this);
                getCommand("buypilot").setExecutor(this);
                getCommand("tphere").setExecutor(this);
                getCommand("tp").setExecutor(this);
                getCommand("juggernaut").setExecutor(new JuggernautCommand(this));
                getCommand("chest").setExecutor(new ChestCommand(this));
                getCommand("soup").setExecutor(new SoupCommand());
                getCommand("spawn").setExecutor(new SpawnCommand());
    
                System.out.println("KitPVP Enabled!");
            }
    
    
    
            public void onDisabled(){
                System.out.println("KitPVP Disabled!");
            }
            public void events() {
                PluginManager pm = getServer().getPluginManager();
                pm.registerEvents(this.Events, this);
            }
    
    
            private boolean setupEconomy() {
                if (getServer().getPluginManager().getPlugin("Vault") == null) {
                    return false;
                }
                RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
                if (rsp == null) {
                    return false;
                }
                econ = rsp.getProvider();
                return econ != null;
            }
    
    
    
            public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
                Player player = null;
                if (sender instanceof Player){
                    player = (Player) sender;
                }
    
                if (command.getName().equalsIgnoreCase("buyfisherman")){
                    if (player != null){
                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                        if (r.transactionSuccess()) {
                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "fisherman.set");
                            player.sendMessage(ChatColor.RED + "You bought the Fisherman kit!");
                        }
    
                    }
                }else
                    if (command.getName().equalsIgnoreCase("buyscout")){
                        if (player != null){
                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                            if (r.transactionSuccess()) {
                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "scout.set");
                                player.sendMessage(ChatColor.RED + "You bought the Scout kit!");
                            }
                        }
                    }else
                        if (command.getName().equalsIgnoreCase("buypilot")){
                            if (player != null){
                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                if (r.transactionSuccess()) {
                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "pilot.set");
                                    player.sendMessage(ChatColor.RED + "You bought the Pilot kit!");
                                }
                            }
                        }else
                            if (command.getName().equalsIgnoreCase("buyrage")){
                                if (player != null){
                                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 3500);
                                    if (r.transactionSuccess()) {
                                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "rage.set");
                                        player.sendMessage(ChatColor.RED + "You bought the Rage kit!");
                                    }
                                }
                            }else
                                if (command.getName().equalsIgnoreCase("buyjuggernaut")){
                                    if (player != null){
                                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                        if (r.transactionSuccess()) {
                                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "juggernaut.set");
                                            player.sendMessage(ChatColor.RED + "You bought the Juggernaut kit!");
                                        }
                                    }
                                }else
                                    if (command.getName().equalsIgnoreCase("buymario")){
                                        if (player != null){
                                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 2000);
                                            if (r.transactionSuccess()) {
                                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "mario.set");
                                                player.sendMessage(ChatColor.RED + "You bought the Mario kit!");
                                            }
                                        }
                                    }else
                                        if (command.getName().equalsIgnoreCase("buyhopper")){
                                            if (player != null){
                                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 2500);
                                                if (r.transactionSuccess()) {
                                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "hopper.set");
                                                    player.sendMessage(ChatColor.RED + "You bought the Hopper kit!");
                                                }
                                            }
                                        }else
                                            if (command.getName().equalsIgnoreCase("buysquash")){
                                                if (player != null){
                                                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 2500);
                                                    if (r.transactionSuccess()) {
                                                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "squash.set");
                                                        player.sendMessage(ChatColor.RED + "You bought the Squash kit!");
                                                    }
                                                }
                                            }else
                                                if (command.getName().equalsIgnoreCase("buysnpier")){
                                                    if (player != null){
                                                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 1750);
                                                        if (r.transactionSuccess()) {
                                                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "sniper.set");
                                                            player.sendMessage(ChatColor.RED + "You bought the Sni[er kit!");
                                                        }
                                                    }
                                                }else
                                                    if (command.getName().equalsIgnoreCase("buyremover")){
                                                        if (player != null){
                                                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 1000);
                                                            if (r.transactionSuccess()) {
                                                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "remover.set");
                                                                player.sendMessage(ChatColor.RED + "You bought the Remover kit!");
                                                            }
                                                        }
                                                    }else
                                                        if (command.getName().equalsIgnoreCase("buygravitator")){
                                                            if (player != null){
                                                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                                                if (r.transactionSuccess()) {
                                                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "gravitator.set");
                                                                    player.sendMessage(ChatColor.RED + "You bought the Gravitator kit!");
                                                                }
                                                            }
                                                        }else
                                                            if (command.getName().equalsIgnoreCase("buysquid")){
                                                                if (player != null){
                                                                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                                                                    if (r.transactionSuccess()) {
                                                                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "squid.set");
                                                                        player.sendMessage(ChatColor.RED + "You bought the Squid kit!");
                                                                    }
                                                                }
                                                            }
    
    
    
    
    
    
    
    
                if (!(sender instanceof Player)) {
                    sender.sendMessage(ChatColor.RED + "You cannot vanish!");
                    return true;
                }
    
                //Someone teleport to you
                Player pla = (Player) sender;
    
                if(command.getName().equalsIgnoreCase("tphere")){
                    if(pla.hasPermission("tphere.set")){
                        Player teleportTo = getServer().getPlayer(args[0]);
                        Location teleportToLoc = pla.getLocation();
                        teleportTo.teleport(teleportToLoc);
                        return true;
                    }
                }
    
                //Teleport to someone
                if(command.getName().equalsIgnoreCase("tp")){
                    if(pla.hasPermission("tp.set")){
                        if(args.length == 0){
                            player.sendMessage(ChatColor.RED + "Not enough arguments! /tp <player>");
                        }else if(args.length == 1){
                            Player targetPlayer = player.getServer().getPlayer(args[0]);
                            Location targetPlayerLocation = targetPlayer.getLocation();
                            player.teleport(targetPlayerLocation);
    
                            return true;
                        }
                    }
                }
    
    
                //VanishCommand
                Player p = (Player) sender;
    
                if (command.getName().equalsIgnoreCase("vanish")) {
                    if(sender.hasPermission("vanish.set")){
                        if (!vanished.contains(p)) {
                            for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                                pl.hidePlayer(p);
                            }
                            vanished.add(p);
                            p.sendMessage(ChatColor.GREEN + "You have been vanished!");
                            return true;
                        }
                        else {
                            for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                                pl.showPlayer(p);
                            }
                            vanished.remove(p);
                            p.sendMessage(ChatColor.GREEN + "You have been unvanished!");
                            return true;
                        }
                    }
                }
    
    
                return true;
    
            }
    
    
            @EventHandler
            public void onPlayerDeath(PlayerDeathEvent event){
                if(event.getEntity() instanceof Player) {
                    Player p = (Player) event.getEntity().getPlayer();
                    if(event.getEntity().getKiller() instanceof Player) {
                        econ.depositPlayer(p.getKiller(), 15);
                    }
    
                }
            }
            @EventHandler
            public void onPlayerInteract(PlayerInteractEvent event)  {
                Player player = event.getPlayer();
                if (event.getAction() == Action.PHYSICAL) {
                    Block block = event.getClickedBlock();
                    if (block == null) return;
                    if (block.getType() == Material.SOIL){
                        event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
                        event.setCancelled(true);
                        block.setTypeIdAndData(block.getType().getId(), block.getData(), true);
                    }
                }
            }
    
    
            @EventHandler
            public void onPlayerJoin(PlayerJoinEvent e) {
                for (Player p : vanished) {
                    if(p.hasPermission("vanish.set")){
                        e.getPlayer().hidePlayer(p);
                    }
                }
                showScoreboard(e.getPlayer());
            }
    
            @EventHandler
            public void onPlayerLeave(PlayerQuitEvent e) {
                vanished.remove(e.getPlayer());
            }
    
        }
    
    
     
  12. Offline

    Permeer

    @Treeline1

    Code:
    for(final Player current : Bukkit.getOnlinePlayers()) {
                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                    public void run() {
                        showScoreboard(current);
                    }
                },20);
            }
    to

    Code:
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                    public void run() {
                   for(final Player current : Bukkit.getOnlinePlayers()) {
                        showScoreboard(current);
                      }
                    }
                },20);
            
    put in the final of onEnable() before the last } of onEnable()
     
  13. Offline

    Fuzzybear04

    Okay.
    store your Scoreboard, Objective and Score as private variables
    when a player joins the server show them the scoreboard
    on a player death update the killers scoreboard

    set the players scoreboard AFTER defining the Objective and Score
     
  14. @Treeline1 You don't need to have a bukkit runnable when making a scoreboard, that's completely useless. Like @Fuzzybear04 said, when a player joins, set their scoreboard to the scoreboard that you want, on the player's death update the killer's scoreboard, and set the scoreboard after defining the objective and score.
     
    Konato_K likes this.
  15. Offline

    Treeline1

    I have done that.... Still doesnt show :|....

    I have this in this in the loggin event:
    Code:
            @EventHandler
            public void onPlayerJoin(PlayerJoinEvent e) {
                for (Player p : vanished) {
                    if(p.hasPermission("vanish.set")){
                        e.getPlayer().hidePlayer(p);
                    }
                }
                showScoreboard(e.getPlayer());
            }
    showScoreboard is this:
    Code:
        private void showScoreboard(Player player) {
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
    
            Objective objective = board.registerNewObjective("test", "dummy");
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
            objective.setDisplayName("ScoreBoard");
            Score score = objective.getScore(ChatColor.GREEN + "Kills:");
            score.setScore(1);
            player.setScoreboard(board);
        }
    
    Isnt that basically what ur saying?
     
  16. Put your showScoreboard code in your onPlayerJoin method.
     
  17. Offline

    Treeline1

    it is, is it not?
    Code:
    @EventHandler
            public void onPlayerJoin(PlayerJoinEvent e) {
                showScoreboard(e.getPlayer());
                for (Player p : vanished) {
                    if(p.hasPermission("vanish.set")){
                        e.getPlayer().hidePlayer(p);
                    }
                }   
            }
     
  18. @Treeline1 that's not what I meant. Take all the code in your showScoreboard method and put it in you player join method.
     
  19. Offline

    Treeline1

    Ok so all of my code is now there.
    Code:
    package me.liam.main;
    
    
    
    import java.util.ArrayList;
    
    import me.liam.commands.ArcherCommand;
    import me.liam.commands.ChestCommand;
    import me.liam.commands.FishermanCommand;
    import me.liam.commands.Flames;
    import me.liam.commands.GravitatorCommand;
    import me.liam.commands.Hearts;
    import me.liam.commands.HopperCommand;
    import me.liam.commands.JuggernautCommand;
    import me.liam.commands.KitCommand;
    import me.liam.commands.MarioCommand;
    import me.liam.commands.Menu;
    import me.liam.commands.PilotCommand;
    import me.liam.commands.RageCommand;
    import me.liam.commands.RemoverCommand;
    import me.liam.commands.ScoutCommand;
    import me.liam.commands.Smoke;
    import me.liam.commands.SniperCommand;
    import me.liam.commands.SoupCommand;
    import me.liam.commands.SpawnCommand;
    import me.liam.commands.SquashCommand;
    import me.liam.commands.SquidCommand;
    import me.liam.event.BlockListener;
    import me.liam.event.DamageListener;
    import me.liam.event.InventoryListener;
    import me.liam.event.KillstreakEvent;
    import me.liam.event.PlayerListener;
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    import net.milkbowl.vault.permission.Permission;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.RegisteredServiceProvider;
    import org.bukkit.plugin.java.JavaPlugin;
    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 Kitpvp extends JavaPlugin implements Listener{
    
        public static Economy econ = null;
        public static Kitpvp inst;
        public static Permission permission = null;
        private Menu menu;
    
    
        private boolean setupPermissions() {
            RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
            permission = rsp.getProvider();
            return permission != null;
        }
    
        private ArrayList<Player> vanished = new ArrayList<Player>();
        private PlayerListener Events = new PlayerListener(this);
        public ArrayList<String> KitCommand = new ArrayList<String>();
        public ArrayList<String> SniperCommand = new ArrayList<String>();
        public ArrayList<String> HopperCommand = new ArrayList<String>();
        public ArrayList<String> RageCommand = new ArrayList<String>();
        public ArrayList<String> FishermanCommand = new ArrayList<String>();
        public ArrayList<String> PilotCommand = new ArrayList<String>();
        public ArrayList<String> MarioCommand = new ArrayList<String>();
        public ArrayList<String> ScoutCommand = new ArrayList<String>();
        public ArrayList<String> ArcherCommand = new ArrayList<String>();
        public ArrayList<String> SquashCommand = new ArrayList<String>();
        public ArrayList<String> SoupCommand = new ArrayList<String>();
        public ArrayList<String> ChestCommand = new ArrayList<String>();
        public ArrayList<String> SquidCommand = new ArrayList<String>();
        public ArrayList<String> BatmanCommand = new ArrayList<String>();
        public ArrayList<String> JuggernautCommand = new ArrayList<String>();
        public ArrayList<String> GravitatorCommand = new ArrayList<String>();
        public ArrayList<String> RemoverCommand = new ArrayList<String>();
        public ArrayList<String> ParticleEffects = new ArrayList<String>();
        public ArrayList<String> kitused = new ArrayList<String>();
        public ArrayList<String> particleused = new ArrayList<String>();
    
        public ArrayList<String> Hearts = new ArrayList<String>();
        public ArrayList<String> Smoke = new ArrayList<String>();
        public ArrayList<String> Flames = new ArrayList<String>();
    
    
    
        @Override
        public void onEnable() {
    
           
    
    
                PluginManager pm = getServer().getPluginManager();
                setupPermissions();
                Bukkit.getServer().getPluginManager().registerEvents(this, this);
                inst = this;
                menu = new Menu(this);
                if (!setupEconomy() ) {
                    getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
                    getServer().getPluginManager().disablePlugin(this);
                    return;
                }
    
                Bukkit.getServer().getPluginManager().registerEvents(menu, this);
                pm.registerEvents(new DamageListener(), this);
                pm.registerEvents(new BlockListener(), this);
                pm.registerEvents(new InventoryListener(), this);
                pm.registerEvents(new PlayerListener(this), this);
                pm.registerEvents(new HopperCommand(this), this);
                pm.registerEvents(new JuggernautCommand(this), this);
                pm.registerEvents(new RageCommand(this), this);
                pm.registerEvents(new MarioCommand(this), this);
                pm.registerEvents(new PilotCommand(this), this);
                pm.registerEvents(new SquidCommand(this), this);
                pm.registerEvents(new FishermanCommand(this), this);
                pm.registerEvents(new GravitatorCommand(this), this);
                pm.registerEvents(new RemoverCommand(this), this);
                pm.registerEvents(new SniperCommand(this), this);
                pm.registerEvents(new KillstreakEvent(this), this);
                pm.registerEvents(new Menu(this), this);
                pm.registerEvents(new SquashCommand(this), this);
                getCommand("archer").setExecutor(new ArcherCommand(this));
                getCommand("mario").setExecutor(new MarioCommand(this));
                getCommand("squash").setExecutor(new SquashCommand(this));
                getCommand("hopper").setExecutor(new HopperCommand(this));
                getCommand("pilot").setExecutor(new PilotCommand(this));
                getCommand("rage").setExecutor(new RageCommand(this));
                getCommand("pvp").setExecutor(new KitCommand(this));
                getCommand("scout").setExecutor(new ScoutCommand(this));
                getCommand("sniper").setExecutor(new SniperCommand(this));
                getCommand("squid").setExecutor(new SquidCommand(this));
                getCommand("fisherman").setExecutor(new FishermanCommand(this));
                getCommand("gravitator").setExecutor(new GravitatorCommand(this));
                getCommand("remover").setExecutor(new RemoverCommand(this));
    
                getCommand("flames").setExecutor(new Flames(this));
                getCommand("heart").setExecutor(new Hearts(this));
                getCommand("smoke").setExecutor(new Smoke(this));
    
                getCommand("vanish").setExecutor(this);
                getCommand("buyfisherman").setExecutor(this);
                getCommand("buyrage").setExecutor(this);
                getCommand("buyjuggernaut").setExecutor(this);
                getCommand("buysniper").setExecutor(this);
                getCommand("buysquash").setExecutor(this);
                getCommand("buyhopper").setExecutor(this);
                getCommand("buyremover").setExecutor(this);
                getCommand("buygravitator").setExecutor(this);
                getCommand("buysquid").setExecutor(this);
                getCommand("squid").setExecutor(this);
                getCommand("buyscout").setExecutor(this);
                getCommand("buypilot").setExecutor(this);
                getCommand("tphere").setExecutor(this);
                getCommand("tp").setExecutor(this);
                getCommand("juggernaut").setExecutor(new JuggernautCommand(this));
                getCommand("chest").setExecutor(new ChestCommand(this));
                getCommand("soup").setExecutor(new SoupCommand());
                getCommand("spawn").setExecutor(new SpawnCommand());
    
                System.out.println("KitPVP Enabled!");
           
        }
    
    
            public void onDisabled(){
                System.out.println("KitPVP Disabled!");
            }
            public void events() {
                PluginManager pm = getServer().getPluginManager();
                pm.registerEvents(this.Events, this);
            }
    
    
            private boolean setupEconomy() {
                if (getServer().getPluginManager().getPlugin("Vault") == null) {
                    return false;
                }
                RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
                if (rsp == null) {
                    return false;
                }
                econ = rsp.getProvider();
                return econ != null;
            }
    
    
    
            public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
                Player player = null;
                if (sender instanceof Player){
                    player = (Player) sender;
                }
    
                if (command.getName().equalsIgnoreCase("buyfisherman")){
                    if (player != null){
                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                        if (r.transactionSuccess()) {
                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "fisherman.set");
                            player.sendMessage(ChatColor.RED + "You bought the Fisherman kit!");
                        }
    
                    }
                }else
                    if (command.getName().equalsIgnoreCase("buyscout")){
                        if (player != null){
                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                            if (r.transactionSuccess()) {
                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "scout.set");
                                player.sendMessage(ChatColor.RED + "You bought the Scout kit!");
                            }
                        }
                    }else
                        if (command.getName().equalsIgnoreCase("buypilot")){
                            if (player != null){
                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                if (r.transactionSuccess()) {
                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "pilot.set");
                                    player.sendMessage(ChatColor.RED + "You bought the Pilot kit!");
                                }
                            }
                        }else
                            if (command.getName().equalsIgnoreCase("buyrage")){
                                if (player != null){
                                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 3500);
                                    if (r.transactionSuccess()) {
                                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "rage.set");
                                        player.sendMessage(ChatColor.RED + "You bought the Rage kit!");
                                    }
                                }
                            }else
                                if (command.getName().equalsIgnoreCase("buyjuggernaut")){
                                    if (player != null){
                                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                        if (r.transactionSuccess()) {
                                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "juggernaut.set");
                                            player.sendMessage(ChatColor.RED + "You bought the Juggernaut kit!");
                                        }
                                    }
                                }else
                                    if (command.getName().equalsIgnoreCase("buymario")){
                                        if (player != null){
                                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 2000);
                                            if (r.transactionSuccess()) {
                                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "mario.set");
                                                player.sendMessage(ChatColor.RED + "You bought the Mario kit!");
                                            }
                                        }
                                    }else
                                        if (command.getName().equalsIgnoreCase("buyhopper")){
                                            if (player != null){
                                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 2500);
                                                if (r.transactionSuccess()) {
                                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "hopper.set");
                                                    player.sendMessage(ChatColor.RED + "You bought the Hopper kit!");
                                                }
                                            }
                                        }else
                                            if (command.getName().equalsIgnoreCase("buysquash")){
                                                if (player != null){
                                                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 2500);
                                                    if (r.transactionSuccess()) {
                                                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "squash.set");
                                                        player.sendMessage(ChatColor.RED + "You bought the Squash kit!");
                                                    }
                                                }
                                            }else
                                                if (command.getName().equalsIgnoreCase("buysnpier")){
                                                    if (player != null){
                                                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 1750);
                                                        if (r.transactionSuccess()) {
                                                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "sniper.set");
                                                            player.sendMessage(ChatColor.RED + "You bought the Sni[er kit!");
                                                        }
                                                    }
                                                }else
                                                    if (command.getName().equalsIgnoreCase("buyremover")){
                                                        if (player != null){
                                                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 1000);
                                                            if (r.transactionSuccess()) {
                                                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "remover.set");
                                                                player.sendMessage(ChatColor.RED + "You bought the Remover kit!");
                                                            }
                                                        }
                                                    }else
                                                        if (command.getName().equalsIgnoreCase("buygravitator")){
                                                            if (player != null){
                                                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                                                if (r.transactionSuccess()) {
                                                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "gravitator.set");
                                                                    player.sendMessage(ChatColor.RED + "You bought the Gravitator kit!");
                                                                }
                                                            }
                                                        }else
                                                            if (command.getName().equalsIgnoreCase("buysquid")){
                                                                if (player != null){
                                                                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                                                                    if (r.transactionSuccess()) {
                                                                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "squid.set");
                                                                        player.sendMessage(ChatColor.RED + "You bought the Squid kit!");
                                                                    }
                                                                }
                                                            }
    
    
    
    
    
    
    
    
                if (!(sender instanceof Player)) {
                    sender.sendMessage(ChatColor.RED + "You cannot vanish!");
                    return true;
                }
    
                //Someone teleport to you
                Player pla = (Player) sender;
    
                if(command.getName().equalsIgnoreCase("tphere")){
                    if(pla.hasPermission("tphere.set")){
                        Player teleportTo = getServer().getPlayer(args[0]);
                        Location teleportToLoc = pla.getLocation();
                        teleportTo.teleport(teleportToLoc);
                        return true;
                    }
                }
    
                //Teleport to someone
                if(command.getName().equalsIgnoreCase("tp")){
                    if(pla.hasPermission("tp.set")){
                        if(args.length == 0){
                            player.sendMessage(ChatColor.RED + "Not enough arguments! /tp <player>");
                        }else if(args.length == 1){
                            Player targetPlayer = player.getServer().getPlayer(args[0]);
                            Location targetPlayerLocation = targetPlayer.getLocation();
                            player.teleport(targetPlayerLocation);
    
                            return true;
                        }
                    }
                }
    
    
                //VanishCommand
                Player p = (Player) sender;
    
                if (command.getName().equalsIgnoreCase("vanish")) {
                    if(sender.hasPermission("vanish.set")){
                        if (!vanished.contains(p)) {
                            for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                                pl.hidePlayer(p);
                            }
                            vanished.add(p);
                            p.sendMessage(ChatColor.GREEN + "You have been vanished!");
                            return true;
                        }
                        else {
                            for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                                pl.showPlayer(p);
                            }
                            vanished.remove(p);
                            p.sendMessage(ChatColor.GREEN + "You have been unvanished!");
                            return true;
                        }
                    }
                }
    
    
                return true;
    
            }
    
    
            @EventHandler
            public void onPlayerDeath(PlayerDeathEvent event){
                if(event.getEntity() instanceof Player) {
                    Player p = (Player) event.getEntity().getPlayer();
                    if(event.getEntity().getKiller() instanceof Player) {
                        econ.depositPlayer(p.getKiller(), 15);
                    }
    
                }
            }
            @EventHandler
            public void onPlayerInteract(PlayerInteractEvent event)  {
                Player player = event.getPlayer();
                if (event.getAction() == Action.PHYSICAL) {
                    Block block = event.getClickedBlock();
                    if (block == null) return;
                    if (block.getType() == Material.SOIL){
                        event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
                        event.setCancelled(true);
                        block.setTypeIdAndData(block.getType().getId(), block.getData(), true);
                    }
                }
            }
    
    
            @EventHandler
            public void onPlayerJoin(PlayerJoinEvent e) {
                Player player = e.getPlayer();
                ScoreboardManager manager = Bukkit.getScoreboardManager();
                Scoreboard board = manager.getNewScoreboard();
    
                Objective objective = board.registerNewObjective("test", "dummy");
                objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                objective.setDisplayName("ScoreBoard");
                Score score = objective.getScore(ChatColor.GREEN + "Kills:");
                score.setScore(1);
                player.setScoreboard(board);
                showScoreboard(e.getPlayer());
                for (Player p : vanished) {
                    if(p.hasPermission("vanish.set")){
                        e.getPlayer().hidePlayer(p);
                    }
                }   
            }
    
            @EventHandler
            public void onPlayerLeave(PlayerQuitEvent e) {
                vanished.remove(e.getPlayer());
            }
    
        }
    
    
    So what do I put for showScoreboard(e.getPlayer()); now?
     
  20. Offline

    Skionz

  21. Offline

    Treeline1

    What... Isn't invoking it what I started off with? just calling on it later?
     
  22. @Treeline1 You don't put anything for that line just put player.setScoreboard(Scoreboard); and that's what will put the scoreboard on there for players.
     
  23. Offline

    Treeline1

    Sweeeet it works now. Although theres 1 problem... If I wanna make it so the players score increases when they kill someone, I cant just use " p.getKiller().score.setScore(+1); " because "score" is in my onPlayerJoin. So then score cant see into my playerJoin
     
  24. @Treeline1 Make the scoreboard, objective, and score a variable and make an updateScoreboard() method. Then just put your PlayerDeathEvent in your scoreboard class. If you're still having trouble, maybe this will help:
    Code:
    Scoreboard sb;
    ScoreboardManager sbManager = Bukkit.getScoreboardManager();
    Score score;
    Objective obj;
    
    public void onPlayerJoin(PlayerJoinEvent event) {
    // Your scoreboard stuff here.
    }
    
    public static updateScoreboard(Player player) {
    // Make a new scoreboard, objective, score and get the scores.
    }
    
    public void onPlayerDeath(PlayerDeathEvent event) {
    // Update the killers score here.
    }
    Also, when you are adding 1 to the players score I think that you should do player.setScore(score.getScore("Kills:") + 1);
     
    Last edited: Jan 28, 2015
  25. Offline

    Treeline1

    Ok thanks so far. I think i've just about got it :D Now, the updating scoreboard.. How does that work? Do I need to create a whole new scoreboard or something? And how do I do it
    Code:
    package me.liam.main;
    
    
    
    import java.util.ArrayList;
    import java.util.HashMap;
    
    import me.liam.KOTH.Main;
    import me.liam.commands.ArcherCommand;
    import me.liam.commands.ChestCommand;
    import me.liam.commands.FishermanCommand;
    import me.liam.commands.Flames;
    import me.liam.commands.GravitatorCommand;
    import me.liam.commands.Hearts;
    import me.liam.commands.HopperCommand;
    import me.liam.commands.JuggernautCommand;
    import me.liam.commands.KitCommand;
    import me.liam.commands.MarioCommand;
    import me.liam.commands.Menu;
    import me.liam.commands.PilotCommand;
    import me.liam.commands.RageCommand;
    import me.liam.commands.RemoverCommand;
    import me.liam.commands.ScoutCommand;
    import me.liam.commands.Smoke;
    import me.liam.commands.SniperCommand;
    import me.liam.commands.SoupCommand;
    import me.liam.commands.SpawnCommand;
    import me.liam.commands.SquashCommand;
    import me.liam.commands.SquidCommand;
    import me.liam.event.BlockListener;
    import me.liam.event.DamageListener;
    import me.liam.event.InventoryListener;
    import me.liam.event.KillstreakEvent;
    import me.liam.event.PlayerListener;
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    import net.milkbowl.vault.permission.Permission;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.RegisteredServiceProvider;
    import org.bukkit.plugin.java.JavaPlugin;
    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 Kitpvp extends JavaPlugin implements Listener{
    
        public static Economy econ = null;
        public static Kitpvp inst;
        public static Permission permission = null;
        private Menu menu;
        public static HashMap<String, Integer> kills = new HashMap<String, Integer>();
    
        private boolean setupPermissions() {
            RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
            permission = rsp.getProvider();
            return permission != null;
        }
    
        ScoreboardManager sbManager = Bukkit.getScoreboardManager();
        Scoreboard sb = sbManager.getNewScoreboard();
        Objective obj = sb.registerNewObjective("kills", "dummy");
        Score score = obj.getScore(ChatColor.GREEN + "Kills:");
    
        private ArrayList<Player> vanished = new ArrayList<Player>();
        private PlayerListener Events = new PlayerListener(this);
        public ArrayList<String> KitCommand = new ArrayList<String>();
        public ArrayList<String> SniperCommand = new ArrayList<String>();
        public ArrayList<String> HopperCommand = new ArrayList<String>();
        public ArrayList<String> RageCommand = new ArrayList<String>();
        public ArrayList<String> FishermanCommand = new ArrayList<String>();
        public ArrayList<String> PilotCommand = new ArrayList<String>();
        public ArrayList<String> MarioCommand = new ArrayList<String>();
        public ArrayList<String> ScoutCommand = new ArrayList<String>();
        public ArrayList<String> ArcherCommand = new ArrayList<String>();
        public ArrayList<String> SquashCommand = new ArrayList<String>();
        public ArrayList<String> SoupCommand = new ArrayList<String>();
        public ArrayList<String> ChestCommand = new ArrayList<String>();
        public ArrayList<String> SquidCommand = new ArrayList<String>();
        public ArrayList<String> BatmanCommand = new ArrayList<String>();
        public ArrayList<String> JuggernautCommand = new ArrayList<String>();
        public ArrayList<String> GravitatorCommand = new ArrayList<String>();
        public ArrayList<String> RemoverCommand = new ArrayList<String>();
        public ArrayList<String> ParticleEffects = new ArrayList<String>();
        public ArrayList<String> kitused = new ArrayList<String>();
        public ArrayList<String> particleused = new ArrayList<String>();
    
        public ArrayList<String> Hearts = new ArrayList<String>();
        public ArrayList<String> Smoke = new ArrayList<String>();
        public ArrayList<String> Flames = new ArrayList<String>();
    
    
    
        @Override
        public void onEnable() {
    
    
    
    
            PluginManager pm = getServer().getPluginManager();
            setupPermissions();
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            inst = this;
            menu = new Menu(this);
            if (!setupEconomy() ) {
                getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
                getServer().getPluginManager().disablePlugin(this);
                return;
            }
    
            Bukkit.getServer().getPluginManager().registerEvents(menu, this);
            pm.registerEvents(new DamageListener(), this);
            pm.registerEvents(new BlockListener(), this);
            pm.registerEvents(new InventoryListener(), this);
            pm.registerEvents(new PlayerListener(this), this);
            pm.registerEvents(new HopperCommand(this), this);
            pm.registerEvents(new JuggernautCommand(this), this);
            pm.registerEvents(new RageCommand(this), this);
            pm.registerEvents(new MarioCommand(this), this);
            pm.registerEvents(new PilotCommand(this), this);
            pm.registerEvents(new SquidCommand(this), this);
            pm.registerEvents(new FishermanCommand(this), this);
            pm.registerEvents(new GravitatorCommand(this), this);
            pm.registerEvents(new RemoverCommand(this), this);
            pm.registerEvents(new SniperCommand(this), this);
            pm.registerEvents(new KillstreakEvent(this), this);
            pm.registerEvents(new Menu(this), this);
            pm.registerEvents(new SquashCommand(this), this);
            getCommand("archer").setExecutor(new ArcherCommand(this));
            getCommand("mario").setExecutor(new MarioCommand(this));
            getCommand("squash").setExecutor(new SquashCommand(this));
            getCommand("hopper").setExecutor(new HopperCommand(this));
            getCommand("pilot").setExecutor(new PilotCommand(this));
            getCommand("rage").setExecutor(new RageCommand(this));
            getCommand("pvp").setExecutor(new KitCommand(this));
            getCommand("scout").setExecutor(new ScoutCommand(this));
            getCommand("sniper").setExecutor(new SniperCommand(this));
            getCommand("squid").setExecutor(new SquidCommand(this));
            getCommand("fisherman").setExecutor(new FishermanCommand(this));
            getCommand("gravitator").setExecutor(new GravitatorCommand(this));
            getCommand("remover").setExecutor(new RemoverCommand(this));
    
            getCommand("flames").setExecutor(new Flames(this));
            getCommand("heart").setExecutor(new Hearts(this));
            getCommand("smoke").setExecutor(new Smoke(this));
    
            getCommand("vanish").setExecutor(this);
            getCommand("buyfisherman").setExecutor(this);
            getCommand("buyrage").setExecutor(this);
            getCommand("buyjuggernaut").setExecutor(this);
            getCommand("buysniper").setExecutor(this);
            getCommand("buysquash").setExecutor(this);
            getCommand("buyhopper").setExecutor(this);
            getCommand("buyremover").setExecutor(this);
            getCommand("buygravitator").setExecutor(this);
            getCommand("buysquid").setExecutor(this);
            getCommand("squid").setExecutor(this);
            getCommand("buyscout").setExecutor(this);
            getCommand("buypilot").setExecutor(this);
            getCommand("tphere").setExecutor(this);
            getCommand("tp").setExecutor(this);
            getCommand("juggernaut").setExecutor(new JuggernautCommand(this));
            getCommand("chest").setExecutor(new ChestCommand(this));
            getCommand("soup").setExecutor(new SoupCommand());
            getCommand("spawn").setExecutor(new SpawnCommand());
            getCommand("koth").setExecutor(new Main(this));
    
            System.out.println("KitPVP Enabled!");
    
        }
    
    
        public void onDisabled(){
            System.out.println("KitPVP Disabled!");
        }
        public void events() {
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents(this.Events, this);
        }
    
    
        private boolean setupEconomy() {
            if (getServer().getPluginManager().getPlugin("Vault") == null) {
                return false;
            }
            RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
            if (rsp == null) {
                return false;
            }
            econ = rsp.getProvider();
            return econ != null;
        }
    
    
    
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player player = null;
            if (sender instanceof Player){
                player = (Player) sender;
            }
    
            if (command.getName().equalsIgnoreCase("buyfisherman")){
                if (player != null){
                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                    if (r.transactionSuccess()) {
                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "fisherman.set");
                        player.sendMessage(ChatColor.RED + "You bought the Fisherman kit!");
                    }
    
                }
            }else
                if (command.getName().equalsIgnoreCase("buyscout")){
                    if (player != null){
                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                        if (r.transactionSuccess()) {
                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "scout.set");
                            player.sendMessage(ChatColor.RED + "You bought the Scout kit!");
                        }
                    }
                }else
                    if (command.getName().equalsIgnoreCase("buypilot")){
                        if (player != null){
                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                            if (r.transactionSuccess()) {
                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "pilot.set");
                                player.sendMessage(ChatColor.RED + "You bought the Pilot kit!");
                            }
                        }
                    }else
                        if (command.getName().equalsIgnoreCase("buyrage")){
                            if (player != null){
                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 3500);
                                if (r.transactionSuccess()) {
                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "rage.set");
                                    player.sendMessage(ChatColor.RED + "You bought the Rage kit!");
                                }
                            }
                        }else
                            if (command.getName().equalsIgnoreCase("buyjuggernaut")){
                                if (player != null){
                                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                    if (r.transactionSuccess()) {
                                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "juggernaut.set");
                                        player.sendMessage(ChatColor.RED + "You bought the Juggernaut kit!");
                                    }
                                }
                            }else
                                if (command.getName().equalsIgnoreCase("buymario")){
                                    if (player != null){
                                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 2000);
                                        if (r.transactionSuccess()) {
                                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "mario.set");
                                            player.sendMessage(ChatColor.RED + "You bought the Mario kit!");
                                        }
                                    }
                                }else
                                    if (command.getName().equalsIgnoreCase("buyhopper")){
                                        if (player != null){
                                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 2500);
                                            if (r.transactionSuccess()) {
                                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "hopper.set");
                                                player.sendMessage(ChatColor.RED + "You bought the Hopper kit!");
                                            }
                                        }
                                    }else
                                        if (command.getName().equalsIgnoreCase("buysquash")){
                                            if (player != null){
                                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 2500);
                                                if (r.transactionSuccess()) {
                                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "squash.set");
                                                    player.sendMessage(ChatColor.RED + "You bought the Squash kit!");
                                                }
                                            }
                                        }else
                                            if (command.getName().equalsIgnoreCase("buysnpier")){
                                                if (player != null){
                                                    EconomyResponse r = econ.withdrawPlayer(player.getName(), 1750);
                                                    if (r.transactionSuccess()) {
                                                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "sniper.set");
                                                        player.sendMessage(ChatColor.RED + "You bought the Sni[er kit!");
                                                    }
                                                }
                                            }else
                                                if (command.getName().equalsIgnoreCase("buyremover")){
                                                    if (player != null){
                                                        EconomyResponse r = econ.withdrawPlayer(player.getName(), 1000);
                                                        if (r.transactionSuccess()) {
                                                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "remover.set");
                                                            player.sendMessage(ChatColor.RED + "You bought the Remover kit!");
                                                        }
                                                    }
                                                }else
                                                    if (command.getName().equalsIgnoreCase("buygravitator")){
                                                        if (player != null){
                                                            EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                                            if (r.transactionSuccess()) {
                                                                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "gravitator.set");
                                                                player.sendMessage(ChatColor.RED + "You bought the Gravitator kit!");
                                                            }
                                                        }
                                                    }else
                                                        if (command.getName().equalsIgnoreCase("buysquid")){
                                                            if (player != null){
                                                                EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                                                                if (r.transactionSuccess()) {
                                                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "squid.set");
                                                                    player.sendMessage(ChatColor.RED + "You bought the Squid kit!");
                                                                }
                                                            }
                                                        }
    
    
    
    
    
    
    
    
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "You cannot vanish!");
                return true;
            }
    
            //Someone teleport to you
            Player pla = (Player) sender;
    
            if(command.getName().equalsIgnoreCase("tphere")){
                if(pla.hasPermission("tphere.set")){
                    Player teleportTo = getServer().getPlayer(args[0]);
                    Location teleportToLoc = pla.getLocation();
                    teleportTo.teleport(teleportToLoc);
                    return true;
                }
            }
    
            //Teleport to someone
            if(command.getName().equalsIgnoreCase("tp")){
                if(pla.hasPermission("tp.set")){
                    if(args.length == 0){
                        player.sendMessage(ChatColor.RED + "Not enough arguments! /tp <player>");
                    }else if(args.length == 1){
                        Player targetPlayer = player.getServer().getPlayer(args[0]);
                        Location targetPlayerLocation = targetPlayer.getLocation();
                        player.teleport(targetPlayerLocation);
    
                        return true;
                    }
                }
            }
    
    
            //VanishCommand
            Player p = (Player) sender;
    
            if (command.getName().equalsIgnoreCase("vanish")) {
                if(sender.hasPermission("vanish.set")){
                    if (!vanished.contains(p)) {
                        for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                            pl.hidePlayer(p);
                        }
                        vanished.add(p);
                        p.sendMessage(ChatColor.GREEN + "You have been vanished!");
                        return true;
                    }
                    else {
                        for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                            pl.showPlayer(p);
                        }
                        vanished.remove(p);
                        p.sendMessage(ChatColor.GREEN + "You have been unvanished!");
                        return true;
                    }
                }
            }
    
    
            return true;
    
        }
    
    
        @EventHandler
        public void onPlayerDeath(PlayerDeathEvent event){
            if(event.getEntity() instanceof Player) {
                Player p = (Player) event.getEntity().getPlayer();
                if(event.getEntity().getKiller() instanceof Player) {
                    econ.depositPlayer(p.getKiller(), 15);
                    kills.put(p.getName(), +1);
                }
    
            }
        }
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event)  {
            Player player = event.getPlayer();
            if (event.getAction() == Action.PHYSICAL) {
                Block block = event.getClickedBlock();
                if (block == null) return;
                if (block.getType() == Material.SOIL){
                    event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
                    event.setCancelled(true);
                    block.setTypeIdAndData(block.getType().getId(), block.getData(), true);
                }
            }
        }
    
    
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e) {
            Player player = e.getPlayer();
            obj.setDisplaySlot(DisplaySlot.SIDEBAR);
            obj.setDisplayName("Stats");
            score.setScore(0);
            player.setScoreboard(sb);
            for (Player p : vanished) {
                if(p.hasPermission("vanish.set")){
                    e.getPlayer().hidePlayer(p);
                }
            }   
        }
    
        @EventHandler
        public void onPlayerLeave(PlayerQuitEvent e) {
            vanished.remove(e.getPlayer());
        }
       
    
    }
    
    
     
  26. Offline

    caderape

    You should learn how to create class for save data. It will help you. ;)

    Just check and get the scorebaord of the player and set the new score. No need to create one.
     
  27. Offline

    Treeline1

    This is what I have.. Not really 100% sure on what else to do though :/
    Code:
    package me.liam.main;
    
    
    
    import java.util.ArrayList;
    import java.util.HashMap;
    
    import me.liam.KOTH.Main;
    import me.liam.commands.ArcherCommand;
    import me.liam.commands.ChestCommand;
    import me.liam.commands.FishermanCommand;
    import me.liam.commands.GravitatorCommand;
    import me.liam.commands.HopperCommand;
    import me.liam.commands.JuggernautCommand;
    import me.liam.commands.KitCommand;
    import me.liam.commands.MarioCommand;
    import me.liam.commands.Menu;
    import me.liam.commands.Particle;
    import me.liam.commands.PilotCommand;
    import me.liam.commands.RageCommand;
    import me.liam.commands.RemoverCommand;
    import me.liam.commands.ScoutCommand;
    import me.liam.commands.SniperCommand;
    import me.liam.commands.SoupCommand;
    import me.liam.commands.SpawnCommand;
    import me.liam.commands.SquashCommand;
    import me.liam.commands.SquidCommand;
    import me.liam.event.BlockListener;
    import me.liam.event.DamageListener;
    import me.liam.event.InventoryListener;
    import me.liam.event.KillstreakEvent;
    import me.liam.event.PlayerListener;
    import me.liam.particles.Crit;
    import me.liam.particles.Ender;
    import me.liam.particles.Firework;
    import me.liam.particles.Flames;
    import me.liam.particles.Hearts;
    import me.liam.particles.Potion;
    import me.liam.particles.Redstone;
    import me.liam.particles.Smoke;
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    import net.milkbowl.vault.permission.Permission;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.RegisteredServiceProvider;
    import org.bukkit.plugin.java.JavaPlugin;
    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 Kitpvp extends JavaPlugin implements Listener{
    
       public static Economy econ = null;
       public static Kitpvp inst;
       public static Permission permission = null;
       private Menu menu;
       private Particle particle;
       public HashMap<String, Integer> kills = new HashMap<String, Integer>();
    
       private boolean setupPermissions() {
         RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
         permission = rsp.getProvider();
         return permission != null;
       }
    
       ScoreboardManager sbManager = Bukkit.getScoreboardManager();
       Scoreboard sb = sbManager.getNewScoreboard();
       Objective obj = sb.registerNewObjective("kills", "dummy");
       Score score = obj.getScore(ChatColor.GREEN + "Kills:");
    
       private int kill = 0;
    
       private ArrayList<Player> vanished = new ArrayList<Player>();
       private PlayerListener Events = new PlayerListener(this);
       public ArrayList<String> KitCommand = new ArrayList<String>();
       public ArrayList<String> SniperCommand = new ArrayList<String>();
       public ArrayList<String> HopperCommand = new ArrayList<String>();
       public ArrayList<String> RageCommand = new ArrayList<String>();
       public ArrayList<String> FishermanCommand = new ArrayList<String>();
       public ArrayList<String> PilotCommand = new ArrayList<String>();
       public ArrayList<String> MarioCommand = new ArrayList<String>();
       public ArrayList<String> ScoutCommand = new ArrayList<String>();
       public ArrayList<String> ArcherCommand = new ArrayList<String>();
       public ArrayList<String> SquashCommand = new ArrayList<String>();
       public ArrayList<String> SoupCommand = new ArrayList<String>();
       public ArrayList<String> ChestCommand = new ArrayList<String>();
       public ArrayList<String> SquidCommand = new ArrayList<String>();
       public ArrayList<String> BatmanCommand = new ArrayList<String>();
       public ArrayList<String> JuggernautCommand = new ArrayList<String>();
       public ArrayList<String> GravitatorCommand = new ArrayList<String>();
       public ArrayList<String> RemoverCommand = new ArrayList<String>();
       public ArrayList<String> ParticleEffects = new ArrayList<String>();
       public ArrayList<String> kitused = new ArrayList<String>();
       public ArrayList<String> particleused = new ArrayList<String>();
    
       public ArrayList<String> Hearts = new ArrayList<String>();
       public ArrayList<String> Smoke = new ArrayList<String>();
       public ArrayList<String> Flames = new ArrayList<String>();
       public ArrayList<String> Ender = new ArrayList<String>();
       public ArrayList<String> Potion = new ArrayList<String>();
       public ArrayList<String> Crit = new ArrayList<String>();
       public ArrayList<String> Firework = new ArrayList<String>();
       public ArrayList<String> Redstone = new ArrayList<String>();
    
    
       @Override
       public void onEnable() {
         PluginManager pm = getServer().getPluginManager();
         setupPermissions();
         Bukkit.getServer().getPluginManager().registerEvents(this, this);
         inst = this;
         menu = new Menu(this);
         particle = new Particle(this);
         if (!setupEconomy() ) {
           getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
           getServer().getPluginManager().disablePlugin(this);
           return;
         }
    
         Bukkit.getServer().getPluginManager().registerEvents(menu, this);
         Bukkit.getServer().getPluginManager().registerEvents(particle, this);
         pm.registerEvents(new DamageListener(), this);
         pm.registerEvents(new BlockListener(), this);
         pm.registerEvents(new InventoryListener(), this);
         pm.registerEvents(new PlayerListener(this), this);
         pm.registerEvents(new HopperCommand(this), this);
         pm.registerEvents(new JuggernautCommand(this), this);
         pm.registerEvents(new RageCommand(this), this);
         pm.registerEvents(new MarioCommand(this), this);
         pm.registerEvents(new PilotCommand(this), this);
         pm.registerEvents(new SquidCommand(this), this);
         pm.registerEvents(new FishermanCommand(this), this);
         pm.registerEvents(new GravitatorCommand(this), this);
         pm.registerEvents(new RemoverCommand(this), this);
         pm.registerEvents(new SniperCommand(this), this);
         pm.registerEvents(new KillstreakEvent(this), this);
         pm.registerEvents(new Menu(this), this);
         pm.registerEvents(new SquashCommand(this), this);
         getCommand("archer").setExecutor(new ArcherCommand(this));
         getCommand("mario").setExecutor(new MarioCommand(this));
         getCommand("squash").setExecutor(new SquashCommand(this));
         getCommand("hopper").setExecutor(new HopperCommand(this));
         getCommand("pilot").setExecutor(new PilotCommand(this));
         getCommand("rage").setExecutor(new RageCommand(this));
         getCommand("pvp").setExecutor(new KitCommand(this));
         getCommand("scout").setExecutor(new ScoutCommand(this));
         getCommand("sniper").setExecutor(new SniperCommand(this));
         getCommand("squid").setExecutor(new SquidCommand(this));
         getCommand("fisherman").setExecutor(new FishermanCommand(this));
         getCommand("gravitator").setExecutor(new GravitatorCommand(this));
         getCommand("remover").setExecutor(new RemoverCommand(this));
    
         getCommand("flames").setExecutor(new Flames(this));
         getCommand("heart").setExecutor(new Hearts(this));
         getCommand("smoke").setExecutor(new Smoke(this));
         getCommand("ender").setExecutor(new Ender(this));
         getCommand("potion").setExecutor(new Potion(this));
         getCommand("crit").setExecutor(new Crit(this));
         getCommand("firework").setExecutor(new Firework(this));
         getCommand("redstone").setExecutor(new Redstone(this));
    
         getCommand("vanish").setExecutor(this);
         getCommand("buyfisherman").setExecutor(this);
         getCommand("buyrage").setExecutor(this);
         getCommand("buyjuggernaut").setExecutor(this);
         getCommand("buysniper").setExecutor(this);
         getCommand("buysquash").setExecutor(this);
         getCommand("buyhopper").setExecutor(this);
         getCommand("buyremover").setExecutor(this);
         getCommand("buygravitator").setExecutor(this);
         getCommand("buysquid").setExecutor(this);
         getCommand("squid").setExecutor(this);
         getCommand("buyscout").setExecutor(this);
         getCommand("buypilot").setExecutor(this);
         getCommand("tphere").setExecutor(this);
         getCommand("tp").setExecutor(this);
         getCommand("juggernaut").setExecutor(new JuggernautCommand(this));
         getCommand("chest").setExecutor(new ChestCommand(this));
         getCommand("soup").setExecutor(new SoupCommand());
         getCommand("spawn").setExecutor(new SpawnCommand());
         getCommand("koth").setExecutor(new Main(this));
    
         System.out.println("KitPVP Enabled!");
    
       }
    
    
       public void onDisabled(){
         System.out.println("KitPVP Disabled!");
       }
       public void events() {
         PluginManager pm = getServer().getPluginManager();
         pm.registerEvents(this.Events, this);
       }
    
    
       private boolean setupEconomy() {
         if (getServer().getPluginManager().getPlugin("Vault") == null) {
           return false;
         }
         RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
         if (rsp == null) {
           return false;
         }
         econ = rsp.getProvider();
         return econ != null;
       }
    
    
    
       public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
         Player player = null;
         if (sender instanceof Player){
           player = (Player) sender;
         }
    
         if (command.getName().equalsIgnoreCase("buyfisherman")){
           if (player != null){
             EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
             if (r.transactionSuccess()) {
               Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "fisherman.set");
               player.sendMessage(ChatColor.RED + "You bought the Fisherman kit!");
             }
    
           }
         }else
           if (command.getName().equalsIgnoreCase("buyscout")){
             if (player != null){
               EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
               if (r.transactionSuccess()) {
                 Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "scout.set");
                 player.sendMessage(ChatColor.RED + "You bought the Scout kit!");
               }
             }
           }else
             if (command.getName().equalsIgnoreCase("buypilot")){
               if (player != null){
                 EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                 if (r.transactionSuccess()) {
                   Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "pilot.set");
                   player.sendMessage(ChatColor.RED + "You bought the Pilot kit!");
                 }
               }
             }else
               if (command.getName().equalsIgnoreCase("buyrage")){
                 if (player != null){
                   EconomyResponse r = econ.withdrawPlayer(player.getName(), 3500);
                   if (r.transactionSuccess()) {
                     Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "rage.set");
                     player.sendMessage(ChatColor.RED + "You bought the Rage kit!");
                   }
                 }
               }else
                 if (command.getName().equalsIgnoreCase("buyjuggernaut")){
                   if (player != null){
                     EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                     if (r.transactionSuccess()) {
                       Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "juggernaut.set");
                       player.sendMessage(ChatColor.RED + "You bought the Juggernaut kit!");
                     }
                   }
                 }else
                   if (command.getName().equalsIgnoreCase("buymario")){
                     if (player != null){
                       EconomyResponse r = econ.withdrawPlayer(player.getName(), 2000);
                       if (r.transactionSuccess()) {
                         Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "mario.set");
                         player.sendMessage(ChatColor.RED + "You bought the Mario kit!");
                       }
                     }
                   }else
                     if (command.getName().equalsIgnoreCase("buyhopper")){
                       if (player != null){
                         EconomyResponse r = econ.withdrawPlayer(player.getName(), 2500);
                         if (r.transactionSuccess()) {
                           Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "hopper.set");
                           player.sendMessage(ChatColor.RED + "You bought the Hopper kit!");
                         }
                       }
                     }else
                       if (command.getName().equalsIgnoreCase("buysquash")){
                         if (player != null){
                           EconomyResponse r = econ.withdrawPlayer(player.getName(), 2500);
                           if (r.transactionSuccess()) {
                             Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "squash.set");
                             player.sendMessage(ChatColor.RED + "You bought the Squash kit!");
                           }
                         }
                       }else
                         if (command.getName().equalsIgnoreCase("buysnpier")){
                           if (player != null){
                             EconomyResponse r = econ.withdrawPlayer(player.getName(), 1750);
                             if (r.transactionSuccess()) {
                               Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "sniper.set");
                               player.sendMessage(ChatColor.RED + "You bought the Sni[er kit!");
                             }
                           }
                         }else
                           if (command.getName().equalsIgnoreCase("buyremover")){
                             if (player != null){
                               EconomyResponse r = econ.withdrawPlayer(player.getName(), 1000);
                               if (r.transactionSuccess()) {
                                 Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "remover.set");
                                 player.sendMessage(ChatColor.RED + "You bought the Remover kit!");
                               }
                             }
                           }else
                             if (command.getName().equalsIgnoreCase("buygravitator")){
                               if (player != null){
                                 EconomyResponse r = econ.withdrawPlayer(player.getName(), 3000);
                                 if (r.transactionSuccess()) {
                                   Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "gravitator.set");
                                   player.sendMessage(ChatColor.RED + "You bought the Gravitator kit!");
                                 }
                               }
                             }else
                               if (command.getName().equalsIgnoreCase("buysquid")){
                                 if (player != null){
                                   EconomyResponse r = econ.withdrawPlayer(player.getName(), 1500);
                                   if (r.transactionSuccess()) {
                                     Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() +" add " + "squid.set");
                                     player.sendMessage(ChatColor.RED + "You bought the Squid kit!");
                                   }
                                 }
                               }
    
    
    
    
    
    
    
    
         if (!(sender instanceof Player)) {
           sender.sendMessage(ChatColor.RED + "You cannot vanish!");
           return true;
         }
    
         //Someone teleport to you
         Player pla = (Player) sender;
    
         if(command.getName().equalsIgnoreCase("tphere")){
           if(pla.hasPermission("tphere.set")){
             Player teleportTo = getServer().getPlayer(args[0]);
             Location teleportToLoc = pla.getLocation();
             teleportTo.teleport(teleportToLoc);
             return true;
           }
         }
    
         //Teleport to someone
         if(command.getName().equalsIgnoreCase("tp")){
           if(pla.hasPermission("tp.set")){
             if(args.length == 0){
               player.sendMessage(ChatColor.RED + "Not enough arguments! /tp <player>");
             }else if(args.length == 1){
               Player targetPlayer = player.getServer().getPlayer(args[0]);
               Location targetPlayerLocation = targetPlayer.getLocation();
               player.teleport(targetPlayerLocation);
    
               return true;
             }
           }
         }
    
    
         //VanishCommand
         Player p = (Player) sender;
    
         if (command.getName().equalsIgnoreCase("vanish")) {
           if(sender.hasPermission("vanish.set")){
             if (!vanished.contains(p)) {
               for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                 pl.hidePlayer(p);
               }
               vanished.add(p);
               p.sendMessage(ChatColor.GREEN + "You have been vanished!");
               return true;
             }
             else {
               for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                 pl.showPlayer(p);
               }
               vanished.remove(p);
               p.sendMessage(ChatColor.GREEN + "You have been unvanished!");
               return true;
             }
           }
         }
    
    
         return true;
    
       }
    
    
       @EventHandler
       public void onPlayerDeath(PlayerDeathEvent event){
         if(event.getEntity() instanceof Player) {
           Player p = (Player) event.getEntity().getPlayer();
           if(event.getEntity().getKiller() instanceof Player) {
             econ.depositPlayer(p.getKiller(), 15);
             kills.put(p.getName(), +1);
           }
    
         }
       }
    
       public Scoreboard getBoard(Player player){
          if(sb.getObjective("kills") == null){
               ScoreboardManager sbManager = Bukkit.getScoreboardManager();
               Scoreboard sb = sbManager.getNewScoreboard();
               Objective obj = sb.registerNewObjective("kills", "dummy");
               Score score = obj.getScore(ChatColor.GREEN + "Kills:");
               score.setScore(kills);
          }
          return sb;
       }
       @EventHandler
       public void onPlayerInteract(PlayerInteractEvent event)  {
         Player player = event.getPlayer();
         if (event.getAction() == Action.PHYSICAL) {
           Block block = event.getClickedBlock();
           if (block == null) return;
           if (block.getType() == Material.SOIL){
             event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
             event.setCancelled(true);
             block.setTypeIdAndData(block.getType().getId(), block.getData(), true);
           }
         }
       }
    
    
       @EventHandler
       public void onPlayerJoin(PlayerJoinEvent e) {
         Player player = e.getPlayer();
         obj.setDisplaySlot(DisplaySlot.SIDEBAR);
         obj.setDisplayName("Stats");
         score.setScore(0);
         player.setScoreboard(sb);
         for (Player p : vanished) {
           if(p.hasPermission("vanish.set")){
             e.getPlayer().hidePlayer(p);
           }
         }  
       }
    
       @EventHandler
       public void onPlayerLeave(PlayerQuitEvent e) {
         vanished.remove(e.getPlayer());
       }
    
    
    }
    
     
    Last edited: Jan 30, 2015
Thread Status:
Not open for further replies.

Share This Page