Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. package com.timer.test;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Material;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.inventory.ItemStack;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11. import org.bukkit.scheduler.BukkitRunnable;
  12.  
  13. public class Timer extends JavaPlugin{
  14.  
  15. public void onEnable(){
  16. loadConfiguration();
  17. reloadConfig();
  18.  
  19. }
  20.  
  21. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  22.  
  23. if(command.getName().equalsIgnoreCase("timer")){
  24.  
  25. if(!(sender instanceof Player)){
  26. sender.sendMessage("You must be a player to use this command");
  27. }else{
  28.  
  29. Player player = (Player) sender;
  30. Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("Hidden-Message")));
  31.  
  32. pickLater(player);
  33.  
  34. }
  35. }
  36.  
  37. return false;
  38. }
  39.  
  40.  
  41. public void pickLater(Player p) {
  42. new BukkitRunnable() {
  43.  
  44. @Override
  45. public void run() {
  46.  
  47. p.getInventory().addItem(new ItemStack(Material.WOOD_PICKAXE, 1));
  48.  
  49. }
  50. }.runTaskLater(this, 6000L);
  51.  
  52. public void loadConfiguration(){
  53. getConfig().options().copyDefaults(true);
  54. saveConfig();
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement