Development Assistance Im not sure where I've gone (Drop Party Plugin)

Discussion in 'Plugin Help/Development/Requests' started by Mee8a, Jul 24, 2015.

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

    Mee8a

    Im trying to make a Custom Drop party plugin, the plugin loads fine but whenever I do /dp I get an Internal error, This is a screenshot of the logs from the console, also the file containing the logs from the server

    Any help is really appreciated!
    Code:
    package me.bukkit.Mee8a;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class DropParty extends JavaPlugin{
       
        public static String TAG = "§9[§aDrop-Party§9]";
       
       
        @Override
        public void onEnable() {
            getLogger().info("Version 1.0 Enabled!");
        }
       
        @Override
        public void onDisable() {
            getLogger().info("Version 1.0 Disabled!");
        }
       
        @SuppressWarnings("deprecation")
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
           
           
            if (cmd.getName().equalsIgnoreCase("dp") && sender instanceof Player) {
                if (!sender.hasPermission("dropparty.start")) {
                    sender.sendMessage(DropParty.TAG + ChatColor.RED + " You are not allowed to start DropParties");
                    return true;               
                }
                if (sender.hasPermission("dropparty.start")) {
                    sender.sendMessage(DropParty.TAG + ChatColor.GREEN + " Starting Drop Party...");
                    Player members = (Player) (Bukkit.getServer().getOnlinePlayers());
                    PlayerInventory pi = members.getInventory();
                    members.sendMessage(DropParty.TAG + ChatColor.GOLD + " Drop Party Incomming!!!");
                    members.setLevel(10);
                    pi.addItem(new ItemStack(Material.COOKED_BEEF, 64));
                    pi.addItem(new ItemStack(Material.DIAMOND_BLOCK, 5));
                    pi.addItem(new ItemStack(Material.IRON_BLOCK, 10));
                    pi.addItem(new ItemStack(Material.EMERALD_BLOCK, 5));
                    pi.addItem(new ItemStack(Material.GOLD_BLOCK, 5));
                    pi.addItem(new ItemStack(Material.DIAMOND_CHESTPLATE, 1));
                    pi.addItem(new ItemStack(Material.IRON_BOOTS, 1));
                    members.setHealth(20);
                    getServer().getScheduler().scheduleAsyncDelayedTask(this, new Runnable() {
                       
                        public void run() {
                            members.sendMessage(DropParty.TAG + ChatColor.RED + " Drop party has ended!");
                        }
                    }, 3 * 20L);
                }
            }
            return true;
        }
    
    }
    
     
  2. Moved to Bukkit Alternates.
     
  3. Offline

    Mee8a

    bump
     
  4. Offline

    BizarrePlatinum

    @Mee8a from what I can gather, the error is occuring on DropParty line 41, and it is occurring due to you casting a list as a Player.

    Code:
    Player members =(Player)(Bukkit.getServer().getOnlinePlayers());
    
    Bukkit#getOnlinePlayers(); returns a list, to use this the way you want to, create a list of players and set it to that. Then iterate through it. Or, if you're only going to be using the list once, you can just iterate using Bukkit#getOnlinePlayers();
     
Thread Status:
Not open for further replies.

Share This Page