Advertisement
Askingg

Untitled

Apr 17th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. package me.Askingg.Reflex;
  2.  
  3. import java.io.File;
  4.  
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.entity.LivingEntity;
  7. import org.bukkit.plugin.Plugin;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9. import org.bukkit.scheduler.BukkitRunnable;
  10.  
  11.  
  12. public class Main extends JavaPlugin {
  13.  
  14. public String prefix = (ChatColor.RED + "Reflex " + ChatColor.DARK_GRAY + "- " + ChatColor.WHITE);
  15. private FileControl fc;
  16. private Commands commands;
  17.  
  18. public void onEnable() {
  19. fc = new FileControl(new File(getDataFolder(), "config.yml"));
  20. getServer().getConsoleSender().sendMessage(prefix + "Plugin Successfully Enabled");
  21. getServer().getPluginManager().registerEvents(new Monsters(), this);
  22. commands = new Commands(this);
  23. getCommand(commands.cmd1).setExecutor(commands);
  24. getCommand(commands.cmd2).setExecutor(commands);
  25. getCommand(commands.cmd3).setExecutor(commands);
  26. getCommand(commands.cmd4).setExecutor(commands);
  27.  
  28. runnable();
  29. registerConfig();
  30. saveDefaultConfig();
  31. }
  32.  
  33. public void onDisable() {
  34. getServer().getConsoleSender().sendMessage(prefix + "Plugin Successfully Disabled");
  35. }
  36. public FileControl getFileControl() {
  37. return this.fc;
  38. }
  39.  
  40. public void runnable() {
  41. new BukkitRunnable() {
  42.  
  43. @SuppressWarnings("deprecation")
  44. @Override
  45. public void run() {
  46. for (LivingEntity e : getServer().getWorld("world").getLivingEntities()) {
  47.  
  48. e.setCustomName(e.getType() + "" + ChatColor.DARK_GRAY + " (" + ChatColor.RED + e.getHealth()
  49. + ChatColor.DARK_GRAY + " / " + ChatColor.RED + e.getMaxHealth() + ChatColor.DARK_GRAY
  50. + ")");
  51. e.setCustomNameVisible(true);
  52. }
  53. }
  54.  
  55. }.runTaskTimerAsynchronously((Plugin) this, 0, 10);
  56. }
  57.  
  58. private void registerConfig() {
  59. getConfig().options().copyDefaults(true);
  60. saveConfig();
  61. }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement