Watch display name help!

Discussion in 'Plugin Development' started by VazorN, Aug 30, 2013.

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

    VazorN

    Hi guys.

    I'm working on a project for my server called NexVille, and im doin my plugin called NexClock. But i want to rename the Material - Watch.
    And i don't know how to do it, can someone help me please?
    Love.
     
  2. Offline

    StaticE

    Are you trying to make a custom watch or rename all watches?
     
  3. Offline

    etaxi341

    VazorN I think it is this:
    itemstack.getMetaData().setDisplayName("NAME");
     
  4. Offline

    VazorN

    getMetaData is just redlined :/

    Just one custom watch.

    Anyone please help?

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

    stirante

    VazorN It's getItemMeta()
     
  6. Offline

    VazorN

    Still redlined :/
     
  7. Offline

    stirante

    VazorN Just type dot after itemstack variable and find something with item meta.
     
  8. Offline

    VazorN

    Can you like type the whole variable/code that i should put in, i don't have any idea...
     
  9. Offline

    StaticE

    VazorN You have to make the custom itemstack, make the item meta for the itemstack, then save the meta to the item stack. Here's an example:

    Code:java
    1. ItemStack customWatch = new ItemStack(Material.WATCH, 1);
    2. ItemMeta customWatchMeta = customWatch.getItemMeta();
    3. customWatchMeta.setDisplayName("Custom Name");
    4. customWatch.setItemMeta(customWatchMeta);
     
  10. Offline

    VazorN

    I'm very, very shitty at this. but can you put the code in somewhere here?

    Code:java
    1. @EventHandler
    2. public void onInvclose(InventoryCloseEvent e)
    3. {
    4. Player p =(Player) e.getPlayer();
    5. list.remove(p.getName());
    6. }
    7. @EventHandler
    8. public void onClock(PlayerInteractEvent e)
    9. {
    10. Player p = e.getPlayer();
    11.  
    12. ItemStack customWatch = new ItemStack(Material.WATCH, 1);
    13. ItemMeta customWatchMeta = customWatch.getItemMeta();
    14. customWatchMeta.setDisplayName("Custom Name");
    15. customWatch.setItemMeta(customWatchMeta);
    16. ItemStack item = p.getItemInHand();
    17. if(item.getType() == Material.WATCH)
    18. {
    19. if (e.getAction() == Action.LEFT_CLICK_AIR | e.getAction() == Action.LEFT_CLICK_BLOCK) {
    20. p.performCommand("nexclock");
    21. }
    22. }
    23.  
    24. }
    25. }
     
  11. Offline

    StaticE

    VazorN You already have it in there! But I'd change line 17 to:
    Code:java
    1. if(item.getType() == customWatch {


    That way the event will only be triggered if the player is using the custom watch, not just any watch. If that doesn't work you can check for the item name instead.
     
  12. Offline

    VazorN

    That doesn't worked, it's redlined the whole: (item.getType() == customWatch {
    What the heck should i do?

    Please help!

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

    StaticE

    VazorN
    Code:java
    1. if(item.getType() == customWatch.getType() {
    or

    Code:java
    1. if(item.getType() == Material.WATCH && item.getItemMeta().getDisplayName() == customWatch.getItemMeta.getDisplayName(){
     
  14. Offline

    xTrollxDudex

  15. Offline

    StaticE

  16. Offline

    xTrollxDudex

    StaticE
    .equals() works better than ==
     
  17. Offline

    StaticE

    xTrollxDudex Why? Not arguing just want to know, because .equals() gets what it actually equals, while == checks if it is the same as something.
     
  18. Offline

    xTrollxDudex

Thread Status:
Not open for further replies.

Share This Page