Advertisement
Guest User

Untitled

a guest
May 28th, 2020
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. package net.encryptedmc.****;
  2.  
  3. import me.clip.placeholderapi.expansion.PlaceholderExpansion;
  4. import org.bukkit.OfflinePlayer;
  5.  
  6. public class LeaderboardsPlaceholders extends PlaceholderExpansion {
  7. private **** plugin;
  8.  
  9. /**
  10. * Since we register the expansion inside our own plugin, we
  11. * can simply use this method here to get an instance of our
  12. * plugin.
  13. *
  14. * @param plugin
  15. * The instance of our plugin.
  16. */
  17. public LeaderboardsPlaceholders(** plugin){
  18. this.plugin = plugin;
  19. }
  20.  
  21. /**
  22. * Because this is an internal class,
  23. * you must override this method to let PlaceholderAPI know to not unregister your expansion class when
  24. * PlaceholderAPI is reloaded
  25. *
  26. * @return true to persist through reloads
  27. */
  28. @Override
  29. public boolean persist(){
  30. return true;
  31. }
  32.  
  33. /**
  34. * Because this is a internal class, this check is not needed
  35. * and we can simply return {@code true}
  36. *
  37. * @return Always true since it's an internal class.
  38. */
  39. @Override
  40. public boolean canRegister(){
  41. return true;
  42. }
  43.  
  44. /**
  45. * The name of the person who created this expansion should go here.
  46. * <br>For convienience do we return the author from the plugin.yml
  47. *
  48. * @return The name of the author as a String.
  49. */
  50. @Override
  51. public String getAuthor(){
  52. return plugin.getDescription().getAuthors().toString();
  53. }
  54.  
  55. /**
  56. * The placeholder identifier should go here.
  57. * <br>This is what tells PlaceholderAPI to call our onRequest
  58. * method to obtain a value if a placeholder starts with our
  59. * identifier.
  60. * <br>This must be unique and can not contain % or _
  61. *
  62. * @return The identifier in {@code %<identifier>_<value>%} as String.
  63. */
  64. @Override
  65. public String getIdentifier(){
  66. return "someplugin";
  67. }
  68.  
  69. /**
  70. * This is the version of the expansion.
  71. * <br>You don't have to use numbers, since it is set as a String.
  72. *
  73. * For convienience do we return the version from the plugin.yml
  74. *
  75. * @return The version as a String.
  76. */
  77. @Override
  78. public String getVersion(){
  79. return plugin.getDescription().getVersion();
  80. }
  81.  
  82. /**
  83. * This is the method called when a placeholder with our identifier
  84. * is found and needs a value.
  85. * <br>We specify the value identifier in this method.
  86. * <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
  87. *
  88. * @param player
  89. * A {@link org.bukkit.OfflinePlayer OfflinePlayer}.
  90. * @param identifier
  91. * A String containing the identifier/value.
  92. *
  93. * @return Possibly-null String of the requested identifier.
  94. */
  95. @Override
  96. public String onRequest(OfflinePlayer player, String identifier){
  97.  
  98. // %example_placeholder1%
  99. if(identifier.equals("leaderboardranked#1")){
  100. return "Premiering";
  101. }
  102.  
  103. // %example_placeholder2%
  104. if(identifier.equals("leaderboardranked#2")){
  105. return "Instxnt";
  106. }
  107.  
  108. // We return null if an invalid placeholder (f.e. %example_placeholder3%)
  109. // was provided
  110. return null;
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement