/*
* Copyright (C) 2023 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
* NotEnoughUpdates is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* NotEnoughUpdates is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with NotEnoughUpdates. If not, see .
*/
package io.github.moulberry.notenoughupdates.miscfeatures;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe;
import io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent;
import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery;
import io.github.moulberry.notenoughupdates.util.Utils;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@NEUAutoSubscribe
public class GardenNpcPrices {
private final Pattern itemRegex = Pattern.compile("§5§o §.([a-zA-Z \\-]+)(?:§8x(\\d+))?");
private final Gson gson = new GsonBuilder().create();
@Data @NoArgsConstructor public class SkyMartItem {
String currency;
double price;
String display;
}
//§5§o §aEnchanted Cactus Green §8x421
//§5§o §aEnchanted Hay Bale §8x62
//§5§o §9Enchanted Cookie §8x4
//§5§o §9Tightly-Tied Hay Bale
private final Pattern copperRegex = Pattern.compile(".* §8\\+§c(\\d+) Copper.*");
//§5§o §8+§c24 Copper
//§5§o §8+§c69 Copper
//§5§o §8+§cNaN Copper
private Map, List> prices = new HashMap<>();
private Map skymart = null;
@SubscribeEvent
public void onRepoReload(RepositoryReloadEvent reload) {
skymart = gson.fromJson(
Utils.getConstant("skymart", NotEnoughUpdates.INSTANCE.manager.gson),
new TypeToken