2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2018-07-31 07:01:29 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
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;
|
2017-10-13 18:35:11 +00:00
|
|
|
import org.bukkit.command.CommandSender;
|
2018-07-31 07:01:29 +00:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_cake extends FreedomCommand
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2017-12-23 04:07:36 +00:00
|
|
|
|
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.";
|
2017-12-23 04:07:36 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
|
|
|
{
|
2014-08-23 17:52:26 +00:00
|
|
|
final StringBuilder output = new StringBuilder();
|
2017-12-23 04:07:36 +00:00
|
|
|
|
|
|
|
for (final String word : CAKE_LYRICS.split(" "))
|
|
|
|
{
|
|
|
|
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2017-12-23 04:07:36 +00:00
|
|
|
|
2014-08-23 17:52:26 +00:00
|
|
|
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
|
|
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
2017-10-13 18:35:11 +00:00
|
|
|
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
2014-03-22 03:25:32 +00:00
|
|
|
heldItem.setItemMeta(heldItemMeta);
|
2017-12-23 04:07:36 +00:00
|
|
|
|
|
|
|
for (final Player player : this.server.getOnlinePlayers())
|
|
|
|
{
|
2014-08-23 17:52:26 +00:00
|
|
|
final int firstEmpty = player.getInventory().firstEmpty();
|
2017-12-23 04:07:36 +00:00
|
|
|
if (firstEmpty >= 0)
|
|
|
|
{
|
2014-08-23 17:52:26 +00:00
|
|
|
player.getInventory().setItem(firstEmpty, heldItem);
|
|
|
|
}
|
2012-12-06 01:54:38 +00:00
|
|
|
}
|
2017-12-23 04:07:36 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.bcastMsg(output.toString());
|
2011-10-19 00:37:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-12-08 18:28:40 +00:00
|
|
|
}
|