2022-03-20 12:35:43 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.commands;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2022-03-20 12:35:43 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
2013-07-04 16:10:08 +00:00
|
|
|
import org.bukkit.Achievement;
|
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;
|
2014-02-15 12:44:20 +00:00
|
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2022-03-20 12:35:43 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
2013-03-19 22:05:20 +00:00
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
2022-03-20 12:35:43 +00:00
|
|
|
public class Command_cake extends FreedomCommand {
|
2014-08-23 17:52:26 +00:00
|
|
|
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
|
|
|
private final Random random = new Random();
|
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
@Override
|
2022-03-20 12:35:43 +00:00
|
|
|
public boolean run(CommandSender sender, org.bukkit.entity.Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
2014-08-23 17:52:26 +00:00
|
|
|
final StringBuilder output = new StringBuilder();
|
2014-04-11 15:24:44 +00:00
|
|
|
|
2014-08-23 17:52:26 +00:00
|
|
|
final String[] words = CAKE_LYRICS.split(" ");
|
2022-03-20 12:35:43 +00:00
|
|
|
for (final String word : words) {
|
2014-08-23 17:52:26 +00:00
|
|
|
output.append(ChatColor.COLOR_CHAR).append(Integer.toHexString(1 + random.nextInt(14))).append(word).append(" ");
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2014-08-23 17:52:26 +00:00
|
|
|
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
|
|
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
|
|
|
heldItemMeta.setDisplayName((new StringBuilder()).append(ChatColor.WHITE).append("The ").append(ChatColor.DARK_GRAY).append("Lie").toString());
|
2014-03-22 03:25:32 +00:00
|
|
|
heldItem.setItemMeta(heldItemMeta);
|
|
|
|
|
2014-08-23 17:52:26 +00:00
|
|
|
for (final Player player : server.getOnlinePlayers())
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2014-08-23 17:52:26 +00:00
|
|
|
final int firstEmpty = player.getInventory().firstEmpty();
|
|
|
|
if (firstEmpty >= 0)
|
|
|
|
{
|
|
|
|
player.getInventory().setItem(firstEmpty, heldItem);
|
|
|
|
}
|
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
player.awardAchievement(Achievement.BAKE_CAKE);
|
2012-12-06 01:54:38 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2022-03-20 12:35:43 +00:00
|
|
|
Utilities.bcastMsg(output.toString());
|
2014-08-23 17:52:26 +00:00
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-12-08 18:28:40 +00:00
|
|
|
}
|