2011-10-19 00:37:00 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
2012-12-06 01:54:38 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2011-10-19 00:37:00 +00:00
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
2013-03-19 22:05:20 +00:00
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
2011-10-19 00:37:00 +00:00
|
|
|
public class Command_cake extends TFM_Command
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
StringBuilder output = new StringBuilder();
|
2012-12-08 18:28:40 +00:00
|
|
|
Random randomGenerator = new Random();
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-12-08 18:28:40 +00:00
|
|
|
String[] words = TotalFreedomMod.CAKE_LYRICS.split(" ");
|
2012-12-06 01:54:38 +00:00
|
|
|
for (String word : words)
|
2012-11-24 01:22:52 +00:00
|
|
|
{
|
2012-12-08 18:28:40 +00:00
|
|
|
String color_code = Integer.toHexString(1 + randomGenerator.nextInt(14));
|
2012-12-06 01:54:38 +00:00
|
|
|
output.append(ChatColor.COLOR_CHAR).append(color_code).append(word).append(" ");
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2012-12-08 18:28:40 +00:00
|
|
|
for (Player p : server.getOnlinePlayers())
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
ItemStack heldItem = new ItemStack(Material.CAKE, 1);
|
|
|
|
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);
|
2012-12-06 01:54:38 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2012-12-08 18:28:40 +00:00
|
|
|
TFM_Util.bcastMsg(output.toString());
|
2011-10-19 00:37:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-12-08 18:28:40 +00:00
|
|
|
}
|