Linking between Public Void & boolean

Discussion in 'Plugin Development' started by malikdbuseck, Aug 6, 2014.

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

    malikdbuseck

    Okay So I have this plugin I am creating. Currently I need to have it linked so that my Custom Chest with the Item meta is the only block that triggers the hologram. But when i try to use the ID"chest" i gave it before i doesn't work. Would I need to create a new class or can I hard code it into this?

    Code:java
    1. package dynchestshop;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.List;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.ChatColor;
    8. import org.bukkit.Material;
    9. import org.bukkit.block.Block;
    10. import org.bukkit.command.Command;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.entity.Player;
    13. import org.bukkit.event.EventHandler;
    14. import org.bukkit.event.Listener;
    15. import org.bukkit.event.block.BlockPlaceEvent;
    16. import org.bukkit.inventory.ItemStack;
    17. import org.bukkit.inventory.PlayerInventory;
    18. import org.bukkit.inventory.meta.ItemMeta;
    19. import org.bukkit.plugin.java.JavaPlugin;
    20.  
    21. import com.gmail.filoghost.holograms.api.HolographicDisplaysAPI;
    22.  
    23. public class dynchestshop extends JavaPlugin implements Listener {
    24.  
    25. public void onEnable() {
    26. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    27. }
    28.  
    29. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    30. if (!(sender instanceof Player)){
    31. sender.sendMessage(ChatColor.RED + "Only players can use Dynamic Chest Shops!");
    32. return true;
    33. }
    34.  
    35. Player p = (Player) sender;
    36. PlayerInventory pi = p.getInventory();
    37.  
    38. if (cmd.getName().equalsIgnoreCase("dynchest")){
    39. ItemStack chest = new ItemStack(Material.CHEST, 1);
    40. ItemMeta chestmeta = chest.getItemMeta();
    41. chestmeta.setDisplayName(ChatColor.DARK_AQUA + p.getName() + "'s Chest Shop");
    42. List<String> lore = new ArrayList<String>();
    43. lore.add(ChatColor.WHITE + "Place to Open your");
    44. lore.add(ChatColor.WHITE + "Dynamic Chest Shop!");
    45. chestmeta.setLore(lore);
    46. chest.setItemMeta(chestmeta);
    47. pi.addItem(chest);
    48.  
    49. }
    50.  
    51. return true;
    52. }
    53.  
    54. public void onchestPlace(BlockPlaceEvent e){
    55. Block block = e.getBlockPlaced();
    56. e.getPlayer().sendMessage(block.getType().name());
    57. e.setCancelled(false);
    58.  
    59. if (e.getBlockPlaced().getType().equals(chest)) {
    60. e.getBlockPlaced().setType(chest);
    61. e.setCancelled(true);
    62.  
    63. HolographicDisplaysAPI.createHologram(
    64. this,
    65. e.getBlock().getLocation().add(.5, 1, .5) ,
    66. ChatColor.GREEN + e.getPlayer().getName() + "s Chest Shop");
    67. }
    68. }
     
  2. Offline

    pookeythekid

    No offense, but perhaps some real grammar would be helpful for people to find what you're looking for?
     
  3. Offline

    Not2EXceL

  4. Offline

    fireblast709

    malikdbuseck you forgot the EventHandler annotation as well. Also if I get your question properly, you are trying to compare a Material with an ItemStack, which won't work
     
Thread Status:
Not open for further replies.

Share This Page