methods

<< back to the main page

MyPluginWiki has two .class files:

myPluginWiki.class

and

myPluginUtils.class

MyPluginWiki.class contains all the block information and information-managing methods; myPluginUtils.class has a few useful other miscellaneous methods. All the methods in both .classes are static, so you can use them in your code by preceding the method's name with "myPluginWiki." or "myPluginUtils." as appropriate.

myPluginWiki.class

Integer[] getItemIdAndData(String[] item_name, Boolean item_ID)

  • This method returns the I.D. and data values of the item specified.
  • item_name is the name of the item or block type that was specified split into separate words.
  • item_ID is true if this method should only return item I.D.s and not block type I.D.s, false if this method should only return block type I.D.s and not item I.D.s, or null if it should return either item I.D.s or block type I.D.s, in which case it will give item I.D.s priority over block type I.D.s.
  • Returns a two-item Integer array or null.
    • [0] is the I.D. of the item given by item_name.
    • [1] is the data value of the item given, e.g. 2 for birch wood (because all logs have the I.D. 17, but a data value of 2 refers to birch wood specifically).
    • If item_name specifies a general item name such as "logs", the data value returned will be -1.
    • This method will return null if 1) the item specified does not exist or 2) the object specified is an item, not a block type, and it was specified in item_ID that this method should only return block types or vice versa.
  • See also:
    • getItemIdAndData(String, Boolean)
      
      • This method works the same as the one above, but the input can be one String. This method will simply split the String input into separate words and use the method above.
    • getItemIdAndDataString(String[], Boolean)
      
    • getItemIdAndDataString(String, Boolean)
      
  • NOTE: This method returns both the I.D. and the data value of an item based on the item's name because it encourages the programmer to only use this method once as necessary, not once to get the I.D. and again to get the data. It is a long, somewhat complex method and it must search through hundreds and hundreds of Strings in the item_IDs array to find a match. This method should only be called when necessary and results returned by this method should be stored in a variable if needed more than once; do not simply call this method a second time.

String getItemName(int id, int data, boolean give_data_suffix, boolean singular, boolean without_article)

  • This method returns the name of the item specified by the item or block type I.D. and data given.
  • id is the item or block type I.D.
  • data is the numerical data value for the item or block.
  • give_data_suffix specifies whether or not the name of the item should include the numerical data value at the end of the item name in parentheses (e.g. "a trapdoor (16)"). These data suffixes can be easily read by the getItemIdAndData methods.
  • singular specifies whether the item name returned should be returned in the singular form (e.g. "a lever") or in the plural form (e.g. "levers"). Non-countable items like grass are the same as their plural forms, but with "some" at the beginning ("grass" >> "some grass").
  • See also:
    • getItemName(Block, boolean, boolean)
      
    • getItemName(ItemStack, boolean, boolean)
      

String getItemIdAndDataString(String[] item_name, Boolean item_ID)

  • This method returns a String describing the id and data of the item specified or null.
  • item_name is the name of the item or block type that was specified split into separate words.
  • item_ID is true if this method should only return item I.D.s and not block type I.D.s, false if this method should only return block type I.D.s and not item I.D.s, or null if it should return either item I.D.s or block type I.D.s, in which case it will give item I.D.s priority over block type I.D.s.
  • Returns the I.D. and numerical data value for the item given by name in item_name in a two-item Integer array or null if 1) the item specified does not exist or 2) the object specified is an item, not a block type, and it was specified in item_ID that this method should only return block types or vice versa.
  • NOTE: This method returns both the I.D. and the data value of an item based on the item's name because it encourages the programmer to only use this method once as necessary, not once to get the I.D. and again to get the data. It is a long, somewhat complex method and it must search through hundreds and hundreds of Strings in the item_IDs array to find a match. This method should only be called when necessary and results returned by this method should be stored in a variable if needed more than once; do not simply call this method a second time.

Integer[] getEntityIdAndData(String[] entity_name)

  • This method returns the I.D. and data values of the entity specified.
  • entity_name is the name of the entity type that was specified split into separate words.
  • Returns a two-item Integer array or null.
    • [0] is the I.D. of the entity given by item_name.
    • [1] is the data value of the entity given, e.g. 2 for birch wood (because all logs have the I.D. 17, but a data value of 2 refers to birch wood specifically).
    • If item_name specifies a general entity name such as "logs", the data value returned will be -1.
    • This method will return null if the entity specified does not exist.
  • See also:
    • getEntityIdAndData(String, Boolean)
      
    • [LINK]
      getEntityIdAndDataString(String[], Boolean)
      
      [/LINK]
    • getEntityIdAndDataString(String, Boolean)
      
  • NOTE: This method returns both the I.D. and the data value of an item based on the item's name because it encourages the programmer to only use this method once as necessary, not once to get the I.D. and again to get the data. It is a long, somewhat complex method and it must search through hundreds and hundreds of Strings in the item_IDs array to find a match. This method should only be called when necessary and results returned by this method should be stored in a variable if needed more than once; do not simply call this method a second time.

<< back to the main page


Comments

Posts Quoted:
Reply
Clear All Quotes