Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.elitios.elitiosplugins.commands;
- import com.elitios.elitiosplugins.ElitiosEssentials;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.command.TabCompleter;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.util.StringUtil;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Collections;
- import java.util.List;
- public class CommandGiveAll implements CommandExecutor, TabCompleter {
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (!(sender instanceof Player)) return true;
- final Player player = (Player) sender;
- final ItemStack item = player.getInventory().getItemInMainHand();
- if (player.hasPermission("me.giveall")) {
- if (args.length == 0) {
- if (item.getType() == Material.AIR) {
- player.sendMessage(ElitiosEssentials.matouland + "§cVous n'avez aucun item dans votre main !");
- return false;
- }
- if (item.getType() == Material.COMMAND_BLOCK || item.getType() == Material.COMMAND_BLOCK_MINECART || item.getType() == Material.BARRIER || item.getType() == Material.LEGACY_BARRIER || item.getType() == Material.DEBUG_STICK || item.getType() == Material.STRUCTURE_BLOCK || item.getType() == Material.CHAIN_COMMAND_BLOCK || item.getType() == Material.REPEATING_COMMAND_BLOCK) {
- player.sendMessage(ElitiosEssentials.matouland + "§cVous ne pouvez pas giveall des commandes blocks !");
- return false;
- }
- for (Player all : Bukkit.getOnlinePlayers()) {
- final ItemStack all2 = player.getInventory().getItemInMainHand();
- all.getInventory().addItem(all2);
- all.sendMessage(ElitiosEssentials.matouland + "§aVous venez de recevoir §6" + player.getInventory().getItemInMainHand().getType().toString() + " §aen quantité §6" + player.getInventory().getItemInMainHand().getAmount());
- }
- for (Player staff : Bukkit.getOnlinePlayers()) {
- if (staff.hasPermission("me.giveall.alert")) {
- staff.sendMessage("§7[" + ChatColor.DARK_GRAY + player.getName() + " §7a donné §8" + player.getInventory().getItemInMainHand().getType().toString() + " §7en quantité §8" + player.getInventory().getItemInMainHand().getAmount() + "§7]");
- }
- }
- }
- if (args.length == 1) {
- if (args[0].equalsIgnoreCase("info")) {
- player.sendMessage(ElitiosEssentials.matouland + "§6Vous permet de faire un giveall d'un item à tous les joueurs présent sur le serveur évent");
- }
- }
- } else {
- player.sendMessage(ElitiosEssentials.matouland + "§cL'accès à la commande vous a été refusé !");
- }
- return true;
- }
- @Override
- public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
- if (args.length == 1) {
- return StringUtil.copyPartialMatches(args[0], Arrays.asList("info"), new ArrayList<>());
- } else if (args.length == 2) {
- return null;
- }
- return Collections.emptyList();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement