Solved Problem with a PlayerInteractEvent

Discussion in 'Spigot Plugin Development' started by Th3Wh1teG0d, Jan 7, 2020.

Thread Status:
Not open for further replies.
  1. Im using the Version 1.12.2
  2. The player has 2 hands since I believe 1.9. This means Player#getItemInHand() does not return a sensible value and is therefore deprecated.

    Side note: if the player has 2 hands since 1.9, why is Player#getItemInHand() still implemented?
  3. design policy of spigot is the deprecate everything for a few years to allow older plugins to still work.
  4. The current Error that i have says me that there is a error on line 40

    Line 40:
    Code (Java):
     if (meta.getDisplayName().equals("§8P99")) {
  5. you should really read the description of methods and what other people have said.

    getDisplayName can be null too. use #hasDisplayName
  6. If i use -> if (meta.hasDisplayName("§8P99")) { it get underlined red and when i hover on it it shows me this:
    The method hasDisplayName() in the type ItemMeta is not applicable for the arguments (String)
  7. .
    Especially the first part
  8. ItemMeta#hasDisplayName() returns a boolean and takes no arguments
  9. But i need to set a name, i want that only the item with the colored name can be used
  10. Code (Text):
    if (meta.hasDisplayName()) {
        final String displayName = meta.getDisplayName();
        if (displayName.equals("something")) {
  11. Thanks, it now works perfectly.

    but let me give you a tip for the future,
    some people like it very much if you can derect the code that the other person can use.
Thread Status:
Not open for further replies.