Skip to content

Commit

Permalink
goat horn type
Browse files Browse the repository at this point in the history
  • Loading branch information
Brokkonaut committed Jul 30, 2022
1 parent 45f337c commit 5b31bd2
Showing 1 changed file with 24 additions and 0 deletions.
Expand Up @@ -7,10 +7,15 @@
import com.Acrobot.Breeze.Utils.EnchantmentNames;
import com.Acrobot.Breeze.Utils.FireworkEffectTypeNames;
import com.Acrobot.Breeze.Utils.PotionNames;
import com.Acrobot.Breeze.Utils.StringUtil;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Events.ItemInfoEvent;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.logging.Level;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.DyeColor;
Expand Down Expand Up @@ -255,6 +260,25 @@ public static void addInfo(ItemInfoEvent event) {
}
}

if (type == Material.GOAT_HORN) {
try {
// {instrument:"minecraft:ponder_goat_horn"}
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setLenient();
Gson gson = gsonBuilder.create();

Map<String, ?> hornJson = gson.fromJson(meta.getAsString(), Map.class);
String instrument = (String) hornJson.get("instrument");
if (instrument == null) {
instrument = "minecraft:ponder_goat_horn";
}
instrument = StringUtil.capitalizeFirstLetter(instrument.substring(instrument.indexOf(":") + 1).replace("_goat_horn", ""));
sender.sendMessage(" " + ChatColor.GRAY + "Instrument: " + instrument);
} catch (Exception e) {
ChestShop.getBukkitLogger().log(Level.WARNING, "Could not parse instrument item data for " + meta.getAsString(), e);
}
}

if (meta != null && meta.hasLore() && !(meta instanceof BookMeta)) {
List<String> lore = meta.getLore();
if (lore != null && lore.size() > 0) {
Expand Down

0 comments on commit 5b31bd2

Please sign in to comment.