Guest User

Miner (Main)

a guest
Apr 30th, 2017
27
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.yhl;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.command.Command;
  5. import org.bukkit.command.CommandSender;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.Listener;
  8. import org.bukkit.plugin.Plugin;
  9. import org.bukkit.plugin.java.JavaPlugin;
  10.  
  11. import net.md_5.bungee.api.ChatColor;
  12.  
  13. public class Miner extends JavaPlugin {
  14.  
  15. public static Plugin plugin;
  16. public static Miner instance;
  17. AnimationTimer at = new AnimationTimer(this);
  18. public MyConfig messages;
  19. public MyConfigManager man;
  20.  
  21. public void onEnable(){
  22.  
  23. man = new MyConfigManager(this);
  24. messages = man.getNewConfig("Miner.yml", new String[] {"Main Config for >Miner<", "Creds to dNiym for helping me out"});
  25.  
  26. plugin = this;
  27. instance = this;
  28. registerEvents(this, new ListenerClass());
  29. this.getServer().getScheduler().scheduleSyncRepeatingTask(this, at, 0L, 20L);
  30. }
  31.  
  32. public static void registerEvents(org.bukkit.plugin.Plugin plugin, Listener... listeners) {
  33. for (Listener listener : listeners) {
  34. Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
  35. }
  36. }
  37.  
  38. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  39.  
  40. if (!(sender instanceof Player)) {
  41. sender.sendMessage(ChatColor.AQUA + "");
  42. return true;
  43. }
  44.  
  45. Player player = (Player) sender;
  46.  
  47. if (cmd.getName().equalsIgnoreCase("Miner")) {
  48. if(player.hasPermission("Miner.miner")){
  49. at.setup(player);
  50.  
  51. } else{
  52. player.sendMessage(ChatColor.DARK_RED + "You do not have permission to do this.");
  53. return false;
  54. }
  55.  
  56. }
  57. return true;
  58. }
  59.  
  60. public static Plugin getPlugin() {
  61. return plugin;
  62. }
  63.  
  64. public static Miner getInstance() {
  65. return instance;
  66. }
  67. }
RAW Paste Data Copied