mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-16 20:36:12 +00:00
6edb6be7d9
Improved admin system Improved Rank system Implemented config converter Improved command handling Updated Aero
55 lines
2.0 KiB
Java
55 lines
2.0 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import java.util.Random;
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import org.bukkit.Achievement;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
|
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
|
|
public class Command_cake extends FreedomCommand
|
|
{
|
|
|
|
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();
|
|
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
final StringBuilder output = new StringBuilder();
|
|
|
|
final String[] words = CAKE_LYRICS.split(" ");
|
|
for (final String word : words)
|
|
{
|
|
output.append(ChatColor.COLOR_CHAR).append(Integer.toHexString(1 + random.nextInt(14))).append(word).append(" ");
|
|
}
|
|
|
|
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());
|
|
heldItem.setItemMeta(heldItemMeta);
|
|
|
|
for (final Player player : server.getOnlinePlayers())
|
|
{
|
|
final int firstEmpty = player.getInventory().firstEmpty();
|
|
if (firstEmpty >= 0)
|
|
{
|
|
player.getInventory().setItem(firstEmpty, heldItem);
|
|
}
|
|
|
|
player.awardAchievement(Achievement.BAKE_CAKE);
|
|
}
|
|
|
|
FUtil.bcastMsg(output.toString());
|
|
|
|
return true;
|
|
}
|
|
}
|