Added /cookie

This commit is contained in:
Jerom van der Sar 2012-12-04 08:32:54 +01:00
parent 63b80d0d69
commit cd6251d07d
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,37 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Random;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
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;
@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.BOTH, ignore_permissions = true)
public class Command_cookie extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
StringBuilder output = new StringBuilder();
Random randomGenerator = new Random();
for (String word : TotalFreedomMod.COOKIE_LYRICS.split(" "))
{
String color_code = Integer.toHexString(1 + randomGenerator.nextInt(14));
output.append("§").append(color_code).append(word).append(" ");
}
for (Player p : server.getOnlinePlayers())
{
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);
}
TFM_Util.bcastMsg(output.toString());
return true;
}
}

View File

@ -41,6 +41,7 @@ public class TotalFreedomMod extends JavaPlugin
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
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.";
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.";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
public static boolean allPlayersFrozen = false;

View File

@ -22,6 +22,9 @@ commands:
cmdlist:
description: Show all commands for all server plugins.
usage: /<command>
cookie:
description: Superadmin command - cookies :)
usage: /<command>
creative:
description: Quickly change your own gamemode to creative, or define someone's username to change theirs.
usage: /<command> [partialname]