mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Tweak /cake. Fixes #295.
This commit is contained in:
parent
d0a435a5d6
commit
0f764b976b
@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
|
||||||
import org.bukkit.Achievement;
|
import org.bukkit.Achievement;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -16,35 +15,39 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
|
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
|
||||||
public class Command_cake extends TFM_Command
|
public class Command_cake extends TFM_Command
|
||||||
{
|
{
|
||||||
|
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
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
final StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
StringBuilder output = new StringBuilder();
|
final String[] words = CAKE_LYRICS.split(" ");
|
||||||
Random randomGenerator = new Random();
|
for (final String word : words)
|
||||||
|
|
||||||
String[] words = TotalFreedomMod.CAKE_LYRICS.split(" ");
|
|
||||||
for (String word : words)
|
|
||||||
{
|
{
|
||||||
String color_code = Integer.toHexString(1 + randomGenerator.nextInt(14));
|
output.append(ChatColor.COLOR_CHAR).append(Integer.toHexString(1 + random.nextInt(14))).append(word).append(" ");
|
||||||
output.append(ChatColor.COLOR_CHAR).append(color_code).append(word).append(" ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack heldItem = new ItemStack(Material.CAKE);
|
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
||||||
ItemMeta heldItemMeta = heldItem.getItemMeta();
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||||
heldItemMeta.setDisplayName((new StringBuilder()).append(ChatColor.WHITE).append("The ").append(ChatColor.BLACK).append("Lie").toString());
|
heldItemMeta.setDisplayName((new StringBuilder()).append(ChatColor.WHITE).append("The ").append(ChatColor.DARK_GRAY).append("Lie").toString());
|
||||||
heldItem.setItemMeta(heldItemMeta);
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (final Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().firstEmpty(), heldItem);
|
final int firstEmpty = player.getInventory().firstEmpty();
|
||||||
player.awardAchievement(Achievement.MINE_WOOD);
|
if (firstEmpty >= 0)
|
||||||
player.awardAchievement(Achievement.BUILD_WORKBENCH);
|
{
|
||||||
player.awardAchievement(Achievement.BUILD_HOE);
|
player.getInventory().setItem(firstEmpty, heldItem);
|
||||||
|
}
|
||||||
|
|
||||||
player.awardAchievement(Achievement.BAKE_CAKE);
|
player.awardAchievement(Achievement.BAKE_CAKE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_Util.bcastMsg(output.toString());
|
TFM_Util.bcastMsg(output.toString());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import me.StevenLawson.TotalFreedomMod.World.TFM_Flatlands;
|
|||||||
import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
|
import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
|
||||||
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
|
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -15,7 +14,6 @@ import java.util.Properties;
|
|||||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||||
import me.StevenLawson.TotalFreedomMod.HTTPD.TFM_HTTPD_Manager;
|
import me.StevenLawson.TotalFreedomMod.HTTPD.TFM_HTTPD_Manager;
|
||||||
import me.StevenLawson.TotalFreedomMod.Listener.*;
|
import me.StevenLawson.TotalFreedomMod.Listener.*;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -41,7 +39,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
|
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
|
||||||
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
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 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 NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
||||||
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
|
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user