Guest User

Untitled

a guest
Nov 26th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.38 KB | None | 0 0
  1. Type: MESSAGE
  2. Key: "item"
  3. Value: |-
  4.   // A valid JavaScript code follows below. You can use the "player" variable to get
  5.   // Bukkit's player instance.
  6.  
  7.   // Call the function
  8.   displayName();
  9.  
  10.   function displayName() {
  11.     var item = player.getItemInHand();
  12.  
  13.     if (item == null)
  14.       return "Air";
  15.      
  16.     // JavaScript has to wrap all Java classes using Java.type, see
  17.     // https://winterbe.com/posts/2014/04/05/java8-nashorn-tutorial/#invoking-java-methods-from-javascript
  18.     var stone = Java.type("org.bukkit.Material").STONE;
  19.      
  20.     // You can, for example, print custom names for certain materials
  21.     if (item.getType() == stone)
  22.       return "My Shiny Little Stone";
  23.  
  24.     var metadata = item.getItemMeta();
  25.    
  26.     // If the item has meta data and a custom name, show that name instead
  27.     if (metadata != null && metadata.hasDisplayName())
  28.       return metadata.getDisplayName();
  29.  
  30.     var wordUtils = Java.type("org.apache.commons.lang.WordUtils");
  31.     var name = item.getType().name().toLowerCase().replace('_', ' ').replace('_', ' ');
  32.  
  33.     // Return the item name deducted from item's type, capitalized
  34.     return wordUtils.capitalize(name);
  35.   }
  36.  
  37. Hover_Item: "player.getItemInHand()"
  38. Hover: []
  39. Open_Url: ""
  40. Suggest_Command: ""
  41. Run_Command: ""
  42. Sender_Condition: ""
  43. Receiver_Condition: ""
  44. Sender_Permission: ""
  45. Receiver_Permission: ""
Advertisement
Add Comment
Please, Sign In to add comment