Advertisement
Askingg

Untitled

Apr 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.23 KB | None | 0 0
  1. MAIN:
  2. package me.Askingg.Reflex;
  3.  
  4. import org.bukkit.entity.LivingEntity;
  5. import org.bukkit.plugin.Plugin;
  6. import org.bukkit.plugin.java.JavaPlugin;
  7. import org.bukkit.scheduler.BukkitRunnable;
  8.  
  9. import net.md_5.bungee.api.ChatColor;
  10.  
  11. public class Main extends JavaPlugin {
  12.  
  13. public String prefix = (ChatColor.RED + "Reflex " + ChatColor.DARK_GRAY + "- " + ChatColor.WHITE);
  14.  
  15. public void onEnable() {
  16. getServer().getConsoleSender().sendMessage(prefix + "Plugin successfully enabled.");
  17. getServer().getPluginManager().registerEvents(new Monsters(), this);
  18. Commands commands = new Commands();
  19. getCommand(commands.cmd1).setExecutor(commands);
  20. getCommand(commands.cmd2).setExecutor(commands);
  21. getCommand(commands.cmd3).setExecutor(commands);
  22. getCommand(commands.cmd4).setExecutor(commands);
  23.  
  24. runnable();
  25. registerConfig();
  26. saveDefaultConfig();
  27. }
  28.  
  29. public void onDisable() {
  30. getServer().getConsoleSender().sendMessage(prefix + "Plugin Successfully Disabled");
  31. }
  32.  
  33. public void runnable() {
  34. new BukkitRunnable() {
  35.  
  36. @SuppressWarnings("deprecation")
  37. @Override
  38. public void run() {
  39. for (LivingEntity e : getServer().getWorld("world").getLivingEntities()) {
  40.  
  41. e.setCustomName(e.getType() + "" + ChatColor.DARK_GRAY + " (" + ChatColor.RED + e.getHealth()
  42. + ChatColor.DARK_GRAY + " / " + ChatColor.RED + e.getMaxHealth() + ChatColor.DARK_GRAY
  43. + ")");
  44. e.setCustomNameVisible(true);
  45. }
  46. }
  47.  
  48. }.runTaskTimerAsynchronously((Plugin) this, 0, 10);
  49. }
  50.  
  51. private void registerConfig() {
  52. getConfig().options().copyDefaults(true);
  53. saveConfig();
  54. }
  55.  
  56. }
  57.  
  58.  
  59.  
  60.  
  61. COMMANDS:
  62. package me.Askingg.Reflex;
  63.  
  64. import org.bukkit.Material;
  65. import org.bukkit.command.Command;
  66. import org.bukkit.command.CommandExecutor;
  67. import org.bukkit.command.CommandSender;
  68. import org.bukkit.entity.Player;
  69. import org.bukkit.inventory.Inventory;
  70. import org.bukkit.inventory.ItemStack;
  71.  
  72. import net.md_5.bungee.api.ChatColor;
  73.  
  74. public class Commands implements CommandExecutor {
  75.  
  76. public String cmd1 = "giveitem";
  77. public String cmd2 = "prefix";
  78. public String cmd3 = "discord";
  79. public String cmd4 = "config";
  80. public String prefix = (ChatColor.RED + "Reflex " + ChatColor.DARK_GRAY + "- " + ChatColor.WHITE);
  81.  
  82. @Override
  83. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  84. if (sender instanceof Player) {
  85. if (cmd.getName().equalsIgnoreCase(cmd1)) {
  86. if (args.length != 0) {
  87. Material item = Material.getMaterial(args[0].toUpperCase());
  88. if (item != null) {
  89. Inventory inv = ((Player) sender).getInventory();
  90. inv.addItem(new ItemStack(item, 1));
  91. sender.sendMessage(ChatColor.AQUA + "You were given one " + ChatColor.DARK_AQUA + args[0]);
  92. return true;
  93. } else {
  94. sender.sendMessage(ChatColor.RED + args[0] + ChatColor.WHITE + " is not a valid item.");
  95. return true;
  96. }
  97. } else {
  98. sender.sendMessage(ChatColor.RED + "Not enough arguements.");
  99. return true;
  100. }
  101. }
  102.  
  103. if (cmd.getName().equalsIgnoreCase(cmd2)) {
  104. sender.sendMessage(prefix + "Prefix test command");
  105. return true;
  106. }
  107.  
  108. if (cmd.getName().equalsIgnoreCase(cmd3)) {
  109. sender.sendMessage(ChatColor.WHITE + "Join the discord at " + ChatColor.RED + "discord.gg/AW8U7pF"
  110. + ChatColor.WHITE + " !");
  111. return true;
  112. }
  113.  
  114. if (cmd.getName().equalsIgnoreCase(cmd4)) {
  115. sender.sendMessage(ChatColor.RED + "Hi");
  116. }
  117.  
  118. } else {
  119. sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
  120. return true;
  121. }
  122. return false;
  123. }
  124.  
  125. }
  126.  
  127.  
  128.  
  129.  
  130. COMMANDS:
  131. package me.Askingg.Reflex;
  132.  
  133. import org.bukkit.Material;
  134. import org.bukkit.command.Command;
  135. import org.bukkit.command.CommandExecutor;
  136. import org.bukkit.command.CommandSender;
  137. import org.bukkit.entity.Player;
  138. import org.bukkit.inventory.Inventory;
  139. import org.bukkit.inventory.ItemStack;
  140.  
  141. import net.md_5.bungee.api.ChatColor;
  142.  
  143. public class Commands implements CommandExecutor {
  144.  
  145. public String cmd1 = "giveitem";
  146. public String cmd2 = "prefix";
  147. public String cmd3 = "discord";
  148. public String cmd4 = "config";
  149. public String prefix = (ChatColor.RED + "Reflex " + ChatColor.DARK_GRAY + "- " + ChatColor.WHITE);
  150.  
  151. @Override
  152. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  153. if (sender instanceof Player) {
  154. if (cmd.getName().equalsIgnoreCase(cmd1)) {
  155. if (args.length != 0) {
  156. Material item = Material.getMaterial(args[0].toUpperCase());
  157. if (item != null) {
  158. Inventory inv = ((Player) sender).getInventory();
  159. inv.addItem(new ItemStack(item, 1));
  160. sender.sendMessage(ChatColor.AQUA + "You were given one " + ChatColor.DARK_AQUA + args[0]);
  161. return true;
  162. } else {
  163. sender.sendMessage(ChatColor.RED + args[0] + ChatColor.WHITE + " is not a valid item.");
  164. return true;
  165. }
  166. } else {
  167. sender.sendMessage(ChatColor.RED + "Not enough arguements.");
  168. return true;
  169. }
  170. }
  171.  
  172. if (cmd.getName().equalsIgnoreCase(cmd2)) {
  173. sender.sendMessage(prefix + "Prefix test command");
  174. return true;
  175. }
  176.  
  177. if (cmd.getName().equalsIgnoreCase(cmd3)) {
  178. sender.sendMessage(ChatColor.WHITE + "Join the discord at " + ChatColor.RED + "discord.gg/AW8U7pF"
  179. + ChatColor.WHITE + " !");
  180. return true;
  181. }
  182.  
  183. if (cmd.getName().equalsIgnoreCase(cmd4)) {
  184. sender.sendMessage(ChatColor.RED + "Hi");
  185. }
  186.  
  187. } else {
  188. sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
  189. return true;
  190. }
  191. return false;
  192. }
  193.  
  194. }
  195.  
  196.  
  197.  
  198.  
  199. PLUGIN.YML:
  200. name: Reflex
  201. author: Askingg
  202. version: "1.0"
  203. main: me.Askingg.Reflex.Main
  204. description: Custom plugin for Reflex SMP
  205. commands:
  206. giveitem:
  207. usage: /<command>
  208. description: Get any minecraft item.
  209. prefix:
  210. usage: /<command>
  211. description: String test command.
  212. discord:
  213. usage: /<command>
  214. description: View the discord invitation link.
  215. config:
  216. usage: /<command>
  217. description: Test configureable command.
  218.  
  219.  
  220.  
  221.  
  222. CONFIG.YML:
  223. # Change the custom message, this is my first configureable message.
  224. Custom Message: '&fConfigurable custom message of &cReflex&f. Hello %p!'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement