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

38 lines
1.4 KiB
Plaintext
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(" ")) {
output.append(FUtil.randomChatColor()).append(word).append(" ");
}
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
for (final Player player : this.server.getOnlinePlayers())
{
final int firstEmpty = player.getInventory().firstEmpty();
if (firstEmpty >= 0) {
player.getInventory().setItem(firstEmpty, heldItem);
}
}
FUtil.bcastMsg(output.toString());
return true;
}
}