SHARE
TWEET

Untitled

a guest Jan 12th, 2019 172 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.foreslash.autobroadcaster;
  2.  
  3. import net.minecraft.server.v1_8_R3.CommandExecute;
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.Material;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandExecutor;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.inventory.Inventory;
  13. import org.bukkit.inventory.ItemStack;
  14.  
  15. public class Commands extends CommandExecute implements Listener, CommandExecutor {
  16.  
  17.     private Autobroadcaster main;
  18.     public Commands(Autobroadcaster main) {this.main = main;}
  19.  
  20.     @Override
  21.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  22.         Player p = (Player) sender;
  23.         Player target = Bukkit.getPlayer(args[0]);
  24.         Inventory inv = p.getInventory();
  25.  
  26.         if (cmd.getName().equalsIgnoreCase("stav")) {
  27.             if (args.length != 0){
  28.                 if (target == null) {
  29.                     // If player is invalid
  30.                     sender.sendMessage(ChatColor.RED + "Ukendt spiller!");
  31.                     return true;
  32.                 }
  33.                     // Creating Items
  34.                     ItemStack item1 = new ItemStack(Material.BLAZE_ROD);
  35.  
  36.                     // Adding items to inventory of the player
  37.                     inv.addItem(item1);
  38.  
  39.                     // Updates players inventory
  40.                     p.updateInventory();
  41.  
  42.             } else {
  43.                 sender.sendMessage(ChatColor.RED + "For lidt argumenter! /stav (spiller)");
  44.             }
  45.         }
  46.         return true;
  47.     }
  48.     }
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