SHARE
TWEET

Untitled

a guest Oct 15th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package de.Tommunity.Commands;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import org.bukkit.Material;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.inventory.ItemStack;
  12. import org.bukkit.inventory.meta.SkullMeta;
  13.  
  14. import de.Tommunity.Main.Main;
  15.  
  16. public class Kopf implements CommandExecutor, Listener{
  17.  
  18.    
  19.     private HashMap<String, Long> cooldowns = new HashMap<String, Long>();
  20.    
  21.  
  22.  
  23.  
  24.     @Override
  25.     public  boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  26.         if(!(sender instanceof Player)) {
  27.             sender.sendMessage(Main.pre + " §cDazu musst du ein Spieler sein!");
  28.         }
  29.         Player p = (Player) sender;
  30.         if(!p.hasPermission("Tom.Kopf")) {
  31.             p.sendMessage(Main.pre + " §cDazu hast du keine Rechte!");
  32.             return true;
  33.         }
  34.        
  35.        
  36.         if(args.length == 1) {
  37.             Long time = System.currentTimeMillis();
  38.             if(this.cooldowns.containsKey(p.getName())) {
  39.                 Long lastUsage = this.cooldowns.get(p.getName());
  40.                 if (lastUsage + 604800*1000 > time) {
  41.                     p.sendMessage(Main.pre + " §cDu musst dich noch ein bisschen gedulden, um dir den Nächsten Kopf zu abzuholen");
  42.                     return true;
  43.                    
  44.                 }
  45.             }
  46.             ItemStack is = new ItemStack(Material.SKULL_ITEM, 1 , (short) 3);
  47.             SkullMeta im = (SkullMeta)is.getItemMeta();
  48.             im.setOwner(args[0]);
  49.             im.setDisplayName(args[0]);
  50.             is.setItemMeta(im);
  51.             p.getInventory().addItem(new ItemStack[] {is});
  52.             p.updateInventory();
  53.             p.sendMessage(Main.pre + " §3Du hast den Kopf von §6" + im.getDisplayName() + " §3 bekommen, in 7 Tagen kannst du dir weider einen Kopf abholen");
  54.             this.cooldowns.put(p.getName(), time);
  55.             }else {
  56.  
  57.                 p.sendMessage(Main.pre + " §cBitte benutze §6/kopf <Spieler>");
  58.             }
  59.    
  60.         return false;
  61.     }
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top