// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java
// @Mod(SOLCarrot.MOD_ID)
// @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD)
// public final class SOLCarrot {
// 	public static final String MOD_ID = "solcarrot";
// 	
// 	public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
// 	
// 	private static final String PROTOCOL_VERSION = "1.0";
// 	public static SimpleChannel channel = NetworkRegistry.ChannelBuilder
// 		.named(resourceLocation("main"))
// 		.clientAcceptedVersions(PROTOCOL_VERSION::equals)
// 		.serverAcceptedVersions(PROTOCOL_VERSION::equals)
// 		.networkProtocolVersion(() -> PROTOCOL_VERSION)
// 		.simpleChannel();
// 	
// 	public static ResourceLocation resourceLocation(String path) {
// 		return new ResourceLocation(MOD_ID, path);
// 	}
// 	
// 	// TODO: not sure if this is even implemented anymore
// 	@SubscribeEvent
// 	public static void onFingerprintViolation(FMLFingerprintViolationEvent event) {
// 		// This complains if jar not signed, even if certificateFingerprint is blank
// 		LOGGER.warn("Invalid Fingerprint!");
// 	}
// 	
// 	@SubscribeEvent
// 	public static void setUp(FMLCommonSetupEvent event) {
// 		channel.messageBuilder(FoodListMessage.class, 0)
// 			.encoder(FoodListMessage::write)
// 			.decoder(FoodListMessage::new)
// 			.consumer(FoodListMessage::handle)
// 			.add();
// 	}
// 	
// 	public SOLCarrot() {
// 		SOLCarrotConfig.setUp();
// 	}
// }
// 
// Path: src/main/java/com/cazsius/solcarrot/lib/Localization.java
// public final class Localization {
// 	public static String keyString(String domain, IForgeRegistryEntry entry, String path) {
// 		final ResourceLocation location = entry.getRegistryName();
// 		assert location != null;
// 		return keyString(domain, location.getPath() + "." + path);
// 	}
// 	
// 	/** e.g. keyString("tooltip", "eaten_status.not_eaten_1") -> "tooltip.solcarrot.eatenStatus.not_eaten_1") */
// 	public static String keyString(String domain, String path) {
// 		return domain + "." + SOLCarrot.MOD_ID + "." + path;
// 	}
// 	
// 	@OnlyIn(Dist.CLIENT)
// 	public static String localized(String domain, IForgeRegistryEntry entry, String path, Object... args) {
// 		return I18n.format(keyString(domain, entry, path), args);
// 	}
// 	
// 	public static ITextComponent localizedComponent(String domain, IForgeRegistryEntry entry, String path, Object... args) {
// 		return new TranslationTextComponent(keyString(domain, entry, path), args);
// 	}
// 	
// 	@OnlyIn(Dist.CLIENT)
// 	public static String localized(String domain, String path, Object... args) {
// 		return I18n.format(keyString(domain, path), args);
// 	}
// 	
// 	public static ITextComponent localizedComponent(String domain, String path, Object... args) {
// 		return new TranslationTextComponent(keyString(domain, path), args);
// 	}
// 	
// 	@OnlyIn(Dist.CLIENT)
// 	public static String localizedQuantity(String domain, String path, int number) {
// 		return number == 1
// 			? I18n.format(keyString(domain, path + ".singular"))
// 			: I18n.format(keyString(domain, path + ".plural"), number);
// 	}
// 	
// 	public static ITextComponent localizedQuantityComponent(String domain, String path, int number) {
// 		return number == 1
// 			? new TranslationTextComponent(keyString(domain, path + ".singular"))
// 			: new TranslationTextComponent(keyString(domain, path + ".plural"), number);
// 	}
// 	
// 	public static String formatBigNumber(int number) {
// 		if (number < 1000) {
// 			return "" + number;
// 		} else if (number < 10_000) {
// 			return Math.round(number / 1000F) + "." + Math.round((number % 1000) / 100F) + "k";
// 		} else {
// 			return Math.round(number / 1000F) + "k";
// 		}
// 	}
// 	
// 	private Localization() {}
// }


import com.cazsius.solcarrot.SOLCarrot;
import com.cazsius.solcarrot.lib.Localization;
import com.cazsius.solcarrot.tracking.*;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.CommandException;
import net.minecraft.command.CommandSource;
import net.minecraft.command.arguments.EntityArgument;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.*;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import static net.minecraft.command.Commands.argument;
import static net.minecraft.command.Commands.literal;
		return Command.SINGLE_SUCCESS;
	}
	
	static int clearFoodList(CommandContext<CommandSource> context, PlayerEntity target) {
		boolean isOp = context.getSource().hasPermissionLevel(2);
		boolean isTargetingSelf = isTargetingSelf(context, target);
		if (!isOp && isTargetingSelf)
			throw new CommandException(localizedComponent("no_permissions"));
		
		FoodList.get(target).clearFood();
		CapabilityHandler.syncFoodList(target);
		
		ITextComponent feedback = localizedComponent("clear.success");
		sendFeedback(context.getSource(), feedback);
		if (!isTargetingSelf) {
			target.sendMessage(feedback.setStyle(feedbackStyle));
		}
		
		return Command.SINGLE_SUCCESS;
	}
	
	static void sendFeedback(CommandSource source, ITextComponent message) {
		source.sendFeedback(message.setStyle(feedbackStyle), true);
	}
	
	static boolean isTargetingSelf(CommandContext<CommandSource> context, PlayerEntity target) {
		return target.isEntityEqual(context.getSource().getEntity());
	}
	
	static ITextComponent localizedComponent(String path, Object... args) {
// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java
// @Mod(SOLCarrot.MOD_ID)
// @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD)
// public final class SOLCarrot {
// 	public static final String MOD_ID = "solcarrot";
// 	
// 	public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
// 	
// 	private static final String PROTOCOL_VERSION = "1.0";
// 	public static SimpleChannel channel = NetworkRegistry.ChannelBuilder
// 		.named(resourceLocation("main"))
// 		.clientAcceptedVersions(PROTOCOL_VERSION::equals)
// 		.serverAcceptedVersions(PROTOCOL_VERSION::equals)
// 		.networkProtocolVersion(() -> PROTOCOL_VERSION)
// 		.simpleChannel();
// 	
// 	public static ResourceLocation resourceLocation(String path) {
// 		return new ResourceLocation(MOD_ID, path);
// 	}
// 	
// 	// TODO: not sure if this is even implemented anymore
// 	@SubscribeEvent
// 	public static void onFingerprintViolation(FMLFingerprintViolationEvent event) {
// 		// This complains if jar not signed, even if certificateFingerprint is blank
// 		LOGGER.warn("Invalid Fingerprint!");
// 	}
// 	
// 	@SubscribeEvent
// 	public static void setUp(FMLCommonSetupEvent event) {
// 		channel.messageBuilder(FoodListMessage.class, 0)
// 			.encoder(FoodListMessage::write)
// 			.decoder(FoodListMessage::new)
// 			.consumer(FoodListMessage::handle)
// 			.add();
// 	}
// 	
// 	public SOLCarrot() {
// 		SOLCarrotConfig.setUp();
// 	}
// }
// 
// Path: src/main/java/com/cazsius/solcarrot/lib/Localization.java
// public final class Localization {
// 	public static String keyString(String domain, IForgeRegistryEntry entry, String path) {
// 		final ResourceLocation location = entry.getRegistryName();
// 		assert location != null;
// 		return keyString(domain, location.getPath() + "." + path);
// 	}
// 	
// 	/** e.g. keyString("tooltip", "eaten_status.not_eaten_1") -> "tooltip.solcarrot.eatenStatus.not_eaten_1") */
// 	public static String keyString(String domain, String path) {
// 		return domain + "." + SOLCarrot.MOD_ID + "." + path;
// 	}
// 	
// 	@OnlyIn(Dist.CLIENT)
// 	public static String localized(String domain, IForgeRegistryEntry entry, String path, Object... args) {
// 		return I18n.format(keyString(domain, entry, path), args);
// 	}
// 	
// 	public static ITextComponent localizedComponent(String domain, IForgeRegistryEntry entry, String path, Object... args) {
// 		return new TranslationTextComponent(keyString(domain, entry, path), args);
// 	}
// 	
// 	@OnlyIn(Dist.CLIENT)
// 	public static String localized(String domain, String path, Object... args) {
// 		return I18n.format(keyString(domain, path), args);
// 	}
// 	
// 	public static ITextComponent localizedComponent(String domain, String path, Object... args) {
// 		return new TranslationTextComponent(keyString(domain, path), args);
// 	}
// 	
// 	@OnlyIn(Dist.CLIENT)
// 	public static String localizedQuantity(String domain, String path, int number) {
// 		return number == 1
// 			? I18n.format(keyString(domain, path + ".singular"))
// 			: I18n.format(keyString(domain, path + ".plural"), number);
// 	}
// 	
// 	public static ITextComponent localizedQuantityComponent(String domain, String path, int number) {
// 		return number == 1
// 			? new TranslationTextComponent(keyString(domain, path + ".singular"))
// 			: new TranslationTextComponent(keyString(domain, path + ".plural"), number);
// 	}
// 	
// 	public static String formatBigNumber(int number) {
// 		if (number < 1000) {
// 			return "" + number;
// 		} else if (number < 10_000) {
// 			return Math.round(number / 1000F) + "." + Math.round((number % 1000) / 100F) + "k";
// 		} else {
// 			return Math.round(number / 1000F) + "k";
// 		}
// 	}
// 	
// 	private Localization() {}
// }


// Path: src/main/java/com/cazsius/solcarrot/command/FoodListCommand.java
import com.cazsius.solcarrot.SOLCarrot;
import com.cazsius.solcarrot.lib.Localization;
import com.cazsius.solcarrot.tracking.*;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.CommandException;
import net.minecraft.command.CommandSource;
import net.minecraft.command.arguments.EntityArgument;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.*;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import static net.minecraft.command.Commands.argument;
import static net.minecraft.command.Commands.literal;

		return Command.SINGLE_SUCCESS;
	}
	
	static int clearFoodList(CommandContext<CommandSource> context, PlayerEntity target) {
		boolean isOp = context.getSource().hasPermissionLevel(2);
		boolean isTargetingSelf = isTargetingSelf(context, target);
		if (!isOp && isTargetingSelf)
			throw new CommandException(localizedComponent("no_permissions"));
		
		FoodList.get(target).clearFood();
		CapabilityHandler.syncFoodList(target);
		
		ITextComponent feedback = localizedComponent("clear.success");
		sendFeedback(context.getSource(), feedback);
		if (!isTargetingSelf) {
			target.sendMessage(feedback.setStyle(feedbackStyle));
		}
		
		return Command.SINGLE_SUCCESS;
	}
	
	static void sendFeedback(CommandSource source, ITextComponent message) {
		source.sendFeedback(message.setStyle(feedbackStyle), true);
	}
	
	static boolean isTargetingSelf(CommandContext<CommandSource> context, PlayerEntity target) {
		return target.isEntityEqual(context.getSource().getEntity());
	}
	
	static ITextComponent localizedComponent(String path, Object... args) {
		return Localization.localizedComponent("command", localizationPath(path), args);