Configurable ItemStacks don't work?

Discussion in 'Plugin Development' started by bramhaag, Dec 18, 2013.

Thread Status:
Not open for further replies.
  1. Hey all,
    Like the title says, it's not working :/
    Sorry for not using spoilers! I'm on Ipad right now

    Source code of command class:
    package me.bramhaag.hidehub.HideHub;
    import java.util.ArrayList;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.Server;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.inventory.meta.ItemMeta;
    public class Commands implements CommandExecutor {
    public HideHub plugin;

    //commands
    @Override
    public boolean onCommand(CommandSender sender, Command cmd,
    String args2, String[] args) {

    //Vanish item command
    if (sender instanceof Player) {
    Player p = (Player) sender;
    if (cmd.getName().equalsIgnoreCase("clock")) {
    if (p.hasPermission("hh.give.vi")) {

    //Itemstack Vanish item
    ItemStack vanish = new ItemStack(Material.getMaterial(plugin.getConfig().getString("vanish-item")));
    ItemMeta vanishmeta = vanish.getItemMeta();

    //Name and Lore
    ArrayList<String> lore = new ArrayList<String>();
    vanishmeta.setDisplayName(ChatColor.GREEN + " ---Vanish Clock---");
    lore.add(ChatColor.STRIKETHROUGH + "------------------");
    lore.add(ChatColor.WHITE + " Right click to vanish");
    lore.add(ChatColor.WHITE + " all the players");
    lore.add(ChatColor.STRIKETHROUGH + "------------------");
    vanishmeta.setLore(lore);
    vanish.setItemMeta(vanishmeta);

    //Add To Inventory
    p.getInventory().addItem(new ItemStack(vanish));

    //Messages
    String message = plugin.getConfig().getString("give-vanish-item");
    message.replace("{player}",p.getName());
    p.sendMessage(message);



    }
    }
    }
    return false;
    }
    }

    Error if run the command:
    [20:31:11 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'cloc
    k' in plugin HideHub v1.0.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spi
    got.jar:git-Spigot-1202]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:19
    6) ~[spigot.jar:git-Spigot-1202]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServe
    r.java:546) ~[spigot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerCon
    nection.java:937) [spigot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :812) [spigot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java
    :28) [spigot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat
    .java:65) [spigot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:147
    ) [spigot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [spig
    ot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    57) [spigot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    59) [spigot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    40) [spigot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :446) [spigot.jar:git-Spigot-1202]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [spigot.jar:git-Spigot-1202]
    Caused by: java.lang.NullPointerException
    at me.bramhaag.hidehub.HideHub.Commands.onCommand(Commands.java:33) ~[?:
    ?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spi
    got.jar:git-Spigot-1202]
    ... 13 more

    Hope you guys can figure it out



    Thanks,
    Bramhaag
     
  2. Offline

    AoH_Ruthless

    bramhaag
    Learn to read stacktraces, as the error points to line 33 of your class. We need to see code tags not spoilers.... How did you even paste the code and error from ipad?
     
  3. Offline

    sgavster

    You can not use unsupported builds here.. I think you should be on the Spigot forum, not here.
    But the problem is that the item is not a real item.
     
  4. Offline

    Necrodoom

    Locked. Unofficial builds are not supported here.
     
Thread Status:
Not open for further replies.

Share This Page