GUI Help!

Discussion in 'Plugin Development' started by ComputerTurtle, Sep 15, 2013.

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

    ComputerTurtle

    Hey guys! it's me once again with another problem, I am developing a hats plugin, and..
    I want to add a gui, so when a player steps on a pressure plate <on a given block> it opens up, and the player can choose the hat they want, and when they choose it, the gui closes.
    thanks

    My Main Class:

    Code:java
    1. package me.ComputerTurtle.Hats;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.inventory.ItemStack;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class Hats extends JavaPlugin {
    14. public final Logger logger = Logger.getLogger("minecraft");
    15. public static Hats plugin;
    16.  
    17. @Override
    18. public void onEnable(){
    19.  
    20. }
    21.  
    22. @Override
    23. public void onDisable(){
    24.  
    25. }
    26.  
    27. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    28. Player player = (Player) sender;
    29. if (cmd.getName().equalsIgnoreCase("Hats")){
    30. player.sendMessage("-----" + ChatColor.BLUE + " A List Of Hats " + ChatColor.WHITE + "-----");
    31. player.sendMessage("-----" + ChatColor.BLUE + " Blocks" + ChatColor.WHITE + "-----");
    32. player.sendMessage(ChatColor.RED + "grass");
    33. player.sendMessage(ChatColor.RED + "dirt");
    34. player.sendMessage(ChatColor.RED + "leaves");
    35. player.sendMessage(ChatColor.RED + "plank");
    36. player.sendMessage(ChatColor.RED + "wood");
    37. player.sendMessage(ChatColor.RED + "sand");
    38. player.sendMessage(ChatColor.RED + "gravel");
    39. player.sendMessage(ChatColor.RED + "snow");
    40. player.sendMessage(ChatColor.RED + "ice");
    41. player.sendMessage(ChatColor.RED + "stone");
    42. player.sendMessage(ChatColor.RED + "cobble");
    43. player.sendMessage(ChatColor.RED + "obsidian");
    44. player.sendMessage("-----" + ChatColor.BLUE + " Ores " + ChatColor.WHITE + "-----");
    45. player.sendMessage(ChatColor.RED + "iron");
    46. player.sendMessage(ChatColor.RED + "coal");
    47. player.sendMessage(ChatColor.RED + "redstone");
    48. player.sendMessage(ChatColor.RED + "lapis");
    49. player.sendMessage(ChatColor.RED + "gold");
    50. player.sendMessage(ChatColor.RED + "diamond");
    51. player.sendMessage(ChatColor.RED + "emerald");
    52. player.sendMessage("-----" + ChatColor.BLUE + " Other " + ChatColor.WHITE + "-----");
    53. player.sendMessage(ChatColor.RED + "workbench");
    54. player.sendMessage(ChatColor.RED + "netherportal");
    55. player.sendMessage(ChatColor.RED + "enderportal");
    56. player.sendMessage(ChatColor.RED + "portalframe");
    57. player.sendMessage(ChatColor.RED + "pumpkin");
    58. player.sendMessage(ChatColor.RED + "dispenser");
    59. player.sendMessage(ChatColor.RED + "furnace");
    60. player.sendMessage(ChatColor.RED + "lava");
    61. player.sendMessage(ChatColor.RED + "water");
    62. player.sendMessage(ChatColor.BLUE + "Scroll UP For More!");
    63. player.sendMessage(ChatColor.BLUE + "To Remove Hats Do /Hats Clear");
    64. player.sendMessage(ChatColor.RED + "Hats Plugin Inspired By: Shaz");
    65. player.sendMessage("WORKING ON INTERNAL ERROR FIX!");
    66. }
    67. if (args[0].equalsIgnoreCase("clear")){
    68. player.sendMessage(ChatColor.RED + "[Hats] " + ChatColor.WHITE +"Hat Cleared");
    69. player.getInventory().setHelmet(new ItemStack(Material.AIR));
    70. }
    71. return false;
    72. }
    73.  
    74. }
    75.  


    Assist would you be able to help with this and another problem of mine?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  2. Offline

    Retherz_

    What is the problem?
     
  3. Offline

    ComputerTurtle

    1. I am trying to make it to when a player steps on a pressure plate it opens a GUI, and inside the gui are different blocks, so when a player chooses a block it puts it on the players head, and it closes the GUI
     
  4. Offline

    repsor

    I assume that with GUI you mean like an inventory GUI? As used in here?
     
  5. Offline

    ComputerTurtle

    Yes, something like that
     
  6. Offline

    monkeymanboy

  7. Offline

    repsor

    monkeymanboy ComputerTurtle That's not really the way to check if a player is on a pressure plate, it would be laggy and irreliable. Use a PlayerInteractEvent and check for Action.PHYSICAL, I believe that's how a pressure plate is triggered.
     
Thread Status:
Not open for further replies.

Share This Page