Advertisement
JakeDGator

Untitled

Aug 13th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.40 KB | None | 0 0
  1. package me.JakeDGator.RcSlap;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13. //###Developer Notes##
  14. //RcPing is a custom made plugin to test lag for REALMCRAFT Revised (http://www.mcrealm.net)
  15. //How versions work: Each change to a plugin that is small, counts as + 0.0.1, which I start out with 1.0.0
  16. //Example: If I want to fix a error message, that would count as one. Also if I changed a permission node, that would be one.
  17. //So the version would be 1.0.2, and the scale goes up to 10, so it would not be 1.0.10, but 1.1.0
  18.  
  19.  
  20. public class Main extends JavaPlugin{
  21.     List<String> cooldown = new ArrayList<String>();
  22.    
  23.     public void onEnable(){
  24.         getLogger().info("RcSlap V.1.0.0 has been Enabled");
  25.     }
  26.    
  27.     public void onDisable(){
  28.         getLogger().info("RcSlap V.1.0.0 has been Disabled");
  29.     }
  30.    
  31.     public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
  32.         final Player player = (Player) sender;
  33.         if (alias.equalsIgnoreCase("slap")){
  34.             //We need 1 argument for the player
  35.             if (args.length < 1){
  36.                 sender.sendMessage(ChatColor.RED + "Error: " + ChatColor.DARK_RED + "Missing args: Player");
  37.             }      
  38.             if (!cooldown.contains(player.getName())){
  39.                 cooldown.add(player.getName());
  40.                 Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
  41.                 public void run() {
  42.                 cooldown.remove(player.getName());
  43.                                                 }
  44.                                         }, 200);
  45.                
  46.             }
  47.             else{
  48.               sender.sendMessage(ChatColor.RED + "You must wait before you can slap again!");
  49.             }
  50.                 return false;
  51.                
  52.            
  53.         }
  54.        
  55.        
  56.     Player target = Bukkit.getPlayer(args[0]);
  57.     if (target == null){
  58.         //Player is not online
  59.         sender.sendMessage(ChatColor.RED + "Error: " + ChatColor.DARK_RED + "Player not found. Must be online");
  60.         return false;
  61.         }
  62.     sender.sendMessage(ChatColor.AQUA + "You have slapped " + ChatColor.DARK_AQUA + target.getName() + ChatColor.AQUA + " and they enjoyed it! Ohhhhh!" );
  63.     target.sendMessage(ChatColor.YELLOW + "You were slapped by " + sender.getName() + ChatColor.YELLOW + " and ENJOYED IT! >:)");
  64.     target.damage(0);
  65.    
  66.    
  67.     return true;
  68.    
  69.    
  70.     }
  71.  
  72.  
  73.    
  74.  
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement