2018-05-26 06:11:55 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
|
|
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 = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
|
|
|
public class Command_cookie extends FreedomCommand
|
|
|
|
{
|
|
|
|
public static final String COOKIE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cookies.";
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
|
|
|
final StringBuilder output = new StringBuilder();
|
|
|
|
|
2018-05-26 08:56:19 +00:00
|
|
|
for (final String word : COOKIE_LYRICS.split(" "))
|
|
|
|
{
|
2018-05-26 06:11:55 +00:00
|
|
|
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
|
|
|
}
|
|
|
|
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
|
|
|
|
|
2018-05-26 08:56:19 +00:00
|
|
|
for (final Player player : server.getOnlinePlayers())
|
2018-05-26 06:11:55 +00:00
|
|
|
{
|
|
|
|
final int firstEmpty = player.getInventory().firstEmpty();
|
2018-05-26 08:56:19 +00:00
|
|
|
if (firstEmpty >= 0)
|
|
|
|
{
|
2018-05-26 06:11:55 +00:00
|
|
|
player.getInventory().setItem(firstEmpty, heldItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FUtil.bcastMsg(output.toString());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|