Solved SignGUI

Discussion in 'Plugin Development' started by Schaakmatth, May 18, 2014.

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

    Schaakmatth

    hello guys!
    my goal:
    when a player right click on a sign with [KitSelector] on 1st line they will get a inventory!
    but it doesnt work in eclipse:
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent e){
    3. Player p = e.getPlayer();
    4. if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR){
    5. if(e.getClickedBlock().getType() == Material.WALL_SIGN || e.getClickedBlock().getType() == Material.SIGN_POST) {
    6. Sign s = (Sign) e.getClickedBlock().getState();
    7. if(s.getLine(0).equals("[KitSelector]")) { //s.getLine there i get a red line under getLine
    8.  
    9. inv = p.getServer().createInventory(null, 9, ChatColor.RED + "Craviant Selector");
    10. p.openInventory(inv);
    11.  
    12. ArrayList<String> wswordl = new ArrayList<String>();
    13.  
    14. ItemStack wsword = new ItemStack(Material.WOOD_SWORD);
    15. ItemMeta m1 = wsword.getItemMeta();
    16. m1.setDisplayName(ChatColor.GREEN + "Wood Sword");
    17. wswordl.add(ChatColor.GRAY + "This do nothing XD");
    18. m1.setLore(wswordl);
    19. wsword.setItemMeta(m1);
    20. inv.setItem(1, wsword);

    i got an red line under s.getLine:
    The method getLine(int) is undefined for the type Sign
     
  2. Offline

    chingo247

    Did you use the right Sign?

    org.bukkit.material.Sign doesn't have a method called getLine()
    org.bukkit.block.Sign does
     
  3. Schaakmatth dude, dude, look at your threads, all of them are things that alredy have been asnwered here 9999 times, google your problem before asking here. also, do you simply ask us to code you a plugin? cause from your threads its really looks like.
     
  4. Offline

    Schaakmatth

  5. Offline

    AstramG

    We just answered it three posts up from this one.
     
  6. AstramG I dont think he cares. he probably want help coding, not learning
     
  7. Offline

    Konkz

    Do you even read what is replied to you? We spend our time here trying to help you because we can and you just ignore us...
     
    Code0 likes this.
  8. Offline

    AstramG

    Okay guys, calm down. Let's not bombard this guy because of his actions. He just won't receive help in the future if he does this, not trying to start a war here, please.
     
  9. Offline

    Schaakmatth

    sorry that i bumped the code works with right click on a sign but when i right click on the sign there is nothing in the Inventory
    code:
    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerInteract(PlayerInteractEvent e){
    4. Player p = e.getPlayer();
    5. if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR){
    6. if(e.getClickedBlock().getType() == Material.WALL_SIGN || e.getClickedBlock().getType() == Material.SIGN_POST || e.getClickedBlock().getType() == Material.SIGN) {
    7. Sign sign = (Sign) e.getClickedBlock().getState();
    8. if(sign.getLine(0).equalsIgnoreCase(ChatColor.AQUA + "[KitSelector]")){
    9. inv = p.getServer().createInventory(null, 9, ChatColor.RED + "Craviant Selector");
    10.  
    11. ItemStack wsword = new ItemStack(Material.WOOD_SWORD);
    12. ItemMeta m1 = wsword.getItemMeta();
    13.  
    14.  
    15. m1.setDisplayName(ChatColor.GREEN + "Wood Sword");
    16. wsword.setItemMeta(m1);
    17. p.openInventory(inv);
    18. inv.setItem(5, wsword);
    19.  
    20. }
    21.  
    22. }
    23. }
    24. }
    25.  
    26. @EventHandler
    27. public void onInvClick(InventoryClickEvent ev) {
    28. Player player = (Player) ev.getWhoClicked();
    29. if(ev.getInventory().getName().equalsIgnoreCase(ChatColor.RED + "Craviant Selector")) {
    30. if (ev.getCurrentItem().getType() == Material.WOOD_SWORD) {
    31. player.sendMessage(ChatColor.GRAY + "You have used the basic kit!");
    32. player.closeInventory();
    33. }


    AstramG Konkz Someone_Like_You AstramG comment above forget to tahg you!

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

    Code0

    Schaakmatth you can't call p.openInventory() before adding something to it...

    do it like this:
    Code:java
    1. inv.setItem(5,wSword);
    2. p.openInventory(inv);
     
  11. Offline

    Schaakmatth

  12. Offline

    Code0

    Does it throw any errors or something?

    Please post your current code for me to edit.
     
  13. Offline

    Schaakmatth

    got no errors it just doesnt work
    my code:
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent e){
    3. Player p = e.getPlayer();
    4. if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR){
    5. if(e.getClickedBlock().getType() == Material.WALL_SIGN || e.getClickedBlock().getType() == Material.SIGN_POST || e.getClickedBlock().getType() == Material.SIGN) {
    6. Sign sign = (Sign) e.getClickedBlock().getState();
    7. if(sign.getLine(0).equalsIgnoreCase(ChatColor.AQUA + "[KitSelector]")){
    8. inv = p.getServer().createInventory(null, 9, ChatColor.RED + "Craviant Selector");
    9.  
    10. ItemStack wsword = new ItemStack(Material.WOOD_SWORD);
    11. ItemMeta m1 = wsword.getItemMeta();
    12.  
    13.  
    14. m1.setDisplayName(ChatColor.GREEN + "Wood Sword");
    15. wsword.setItemMeta(m1);
    16. inv.setItem(5, wsword);
    17. p.openInventory(inv);


    Code0 forget to tahg

    Bump

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

    sickray34s

    did you regester your event
    Code:java
    1. getServer().getPluginManager().registerEvents(this, this);
     
  15. Offline

    RainoBoy97

  16. Offline

    Schaakmatth

    Yeah i did sickray34s

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  17. Schaakmatth you can edit your posts if youre forgetting to tag, are you sure you any errors?..
    how come youre checking for RIGHT_CLICK_AIR if youre looking for block?...
     
  18. Offline

    Schaakmatth

  19. Schaakmatth do you really read only the first words of what everyone comment you? dont you?
     
    SuppaTim and TGRHavoc like this.
  20. Offline

    ImPhantom


    You bump too often... Just like RainoBoy97 said... You are only allowed to bump once per 24 hours.
     
  21. Offline

    chasertw123

    Schaakmatth
    Try adding some debug messages and see where the area that the message doesn't get sent. This will allow you to pin point the area that has the problem.
     
  22. Offline

    Schaakmatth

    its weird but it works XD
     
  23. Offline

    chasertw123

    Schaakmatth
    Can you share what you did to fix it so others who have the same problem can find this forum easier.
     
  24. Offline

    Schaakmatth

Thread Status:
Not open for further replies.

Share This Page