package me.StevenLawson.TotalFreedomMod.Commands; import java.util.Random; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, ignore_permissions = false) public class Command_cake extends TFM_Command { @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { StringBuilder output = new StringBuilder(); Random randomGenerator = new Random(); String[] words = TotalFreedomMod.CAKE_LYRICS.split(" "); for (String word : words) { String color_code = Integer.toHexString(1 + randomGenerator.nextInt(14)); output.append(ChatColor.COLOR_CHAR).append(color_code).append(word).append(" "); } for (Player p : server.getOnlinePlayers()) { ItemStack heldItem = new ItemStack(Material.CAKE, 1); p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem); } TFM_Util.bcastMsg(output.toString()); return true; } }