TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cookie.java

40 lines
1.4 KiB
Java
Raw Normal View History

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();
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);
for (final Player player : server.getOnlinePlayers())
2018-05-26 06:11:55 +00:00
{
final int firstEmpty = player.getInventory().firstEmpty();
if (firstEmpty >= 0)
{
2018-05-26 06:11:55 +00:00
player.getInventory().setItem(firstEmpty, heldItem);
}
}
FUtil.bcastMsg(output.toString());
return true;
}
}