2018-05-26 06:11:55 +00:00
package me.totalfreedom.totalfreedommod.command ;
import me.totalfreedom.totalfreedommod.rank.Rank ;
2018-07-27 21:54:37 +00:00
import me.totalfreedom.totalfreedommod.util.FUtil ;
2018-07-27 08:19:56 +00:00
import org.bukkit.ChatColor ;
2018-05-26 06:11:55 +00:00
import org.bukkit.Material ;
import org.bukkit.command.Command ;
import org.bukkit.command.CommandSender ;
import org.bukkit.entity.Player ;
import org.bukkit.inventory.ItemStack ;
2018-07-27 08:19:56 +00:00
import org.bukkit.inventory.meta.ItemMeta ;
2018-07-27 21:54:37 +00:00
2018-07-27 08:19:56 +00:00
import java.util.Arrays ;
2018-05-26 06:11:55 +00:00
@CommandPermissions ( level = Rank . SUPER_ADMIN , source = SourceType . BOTH )
2018-07-27 21:54:37 +00:00
@CommandParameters ( description = " For those who have no friends " , usage = " /<command> " )
2018-05-26 06:11:55 +00:00
public class Command_cookie extends FreedomCommand
{
2018-07-27 21:54:37 +00:00
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. " ;
2018-07-27 08:19:56 +00:00
public static final String LORE = " But, you can have a cookie anyways, \ nsince you are sad you are have no friends. " ;
2018-05-26 06:11:55 +00:00
@Override
public boolean run ( CommandSender sender , Player sender_p , Command cmd , String commandLabel , String [ ] args , boolean senderIsConsole )
{
final StringBuilder output = new StringBuilder ( ) ;
2018-05-26 08:56:19 +00:00
for ( final String word : COOKIE_LYRICS . split ( " " ) )
{
2018-05-26 06:11:55 +00:00
output . append ( FUtil . randomChatColor ( ) ) . append ( word ) . append ( " " ) ;
}
2018-07-27 08:19:56 +00:00
final StringBuilder name = new StringBuilder ( ) ;
name . append ( ChatColor . DARK_RED ) . append ( " C " )
. append ( ChatColor . GOLD ) . append ( " o " )
. append ( ChatColor . YELLOW ) . append ( " o " )
. append ( ChatColor . DARK_GREEN ) . append ( " k " )
. append ( ChatColor . DARK_BLUE ) . append ( " i " )
. append ( ChatColor . DARK_PURPLE ) . append ( " e " ) ;
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 ( ) ;
heldItemMeta . setDisplayName ( name . toString ( ) ) ;
heldItemMeta . setLore ( Arrays . asList ( lore . toString ( ) . split ( " \ n " ) ) ) ;
heldItem . setItemMeta ( heldItemMeta ) ;
2018-05-26 08:56:19 +00:00
for ( final Player player : server . getOnlinePlayers ( ) )
2018-05-26 06:11:55 +00:00
{
final int firstEmpty = player . getInventory ( ) . firstEmpty ( ) ;
2018-05-26 08:56:19 +00:00
if ( firstEmpty > = 0 )
{
2018-05-26 06:11:55 +00:00
player . getInventory ( ) . setItem ( firstEmpty , heldItem ) ;
}
}
FUtil . bcastMsg ( output . toString ( ) ) ;
return true ;
}
}