TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cookie.java
Paldiu 5c0f77c7c5 Removal of Lombok
Lombok implementation removal.

I have also gone through and replaced things with inline methods and variables, lambdas, and simplified loops down, removed unnecessary guard clauses, and overall cleaned up every single class. This took a long time, please do remember to follow proper naming conventions, don't include unnecessary guard clauses, follow exception rules and comment rules, and please PLEASE remember to use the DIAMOND OPERATOR rather than just inferring RAW TYPES!!!

Thank you!!
2020-12-25 14:46:43 -05:00

64 lines
2.6 KiB
Java

package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
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.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "For those who have no friends - gives a cookie to everyone on the server.", usage = "/<command>")
public class Command_cookie extends FreedomCommand
{
public static final String COOKIE_LYRICS = "Imagine that you have zero cookies and you split them evenly among zero friends. How many cookies does each person get? See? It doesn't make sense. And Cookie Monster is sad that there are no cookies, and you are sad that you have no friends.";
public static final String LORE = "But, you can have a cookie anyways,\nsince you are sad you are have no friends.";
@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(" ");
}
final StringBuilder lore = new StringBuilder();
for (final String word : LORE.split(" "))
{
lore.append(FUtil.randomChatColor()).append(word).append(" ");
}
final ItemStack heldItem = new ItemStack(Material.COOKIE);
final ItemMeta heldItemMeta = heldItem.getItemMeta();
String name = ChatColor.DARK_RED + "C" +
ChatColor.GOLD + "o" +
ChatColor.YELLOW + "o" +
ChatColor.DARK_GREEN + "k" +
ChatColor.DARK_BLUE + "i" +
ChatColor.DARK_PURPLE + "e";
assert heldItemMeta != null;
heldItemMeta.setDisplayName(name);
heldItemMeta.setLore(Arrays.asList(lore.toString().split("\n")));
heldItem.setItemMeta(heldItemMeta);
for (final Player player : server.getOnlinePlayers())
{
final int firstEmpty = player.getInventory().firstEmpty();
if (firstEmpty >= 0)
{
player.getInventory().setItem(firstEmpty, heldItem);
}
}
FUtil.bcastMsg(output.toString());
return true;
}
}