diff --git a/pom.xml b/pom.xml
index df04948..170aab5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,7 +34,7 @@
loot
- 1.3.5
+ 1.3.7
jar
loot
diff --git a/src/main/java/info/faceland/loot/data/LootResponse.java b/src/main/java/info/faceland/loot/data/LootResponse.java
new file mode 100644
index 0000000..ef74dd0
--- /dev/null
+++ b/src/main/java/info/faceland/loot/data/LootResponse.java
@@ -0,0 +1,22 @@
+package info.faceland.loot.data;
+
+import org.bukkit.inventory.ItemStack;
+
+public class LootResponse {
+
+ private final ItemStack itemStack;
+ private final boolean valuable;
+
+ public LootResponse(ItemStack itemStack, boolean valuable) {
+ this.valuable = valuable;
+ this.itemStack = itemStack;
+ }
+
+ public ItemStack getItemStack() {
+ return itemStack;
+ }
+
+ public boolean isValuable() {
+ return valuable;
+ }
+}
diff --git a/src/main/java/info/faceland/loot/managers/SocketGemManager.java b/src/main/java/info/faceland/loot/managers/SocketGemManager.java
index c7deadd..f261774 100644
--- a/src/main/java/info/faceland/loot/managers/SocketGemManager.java
+++ b/src/main/java/info/faceland/loot/managers/SocketGemManager.java
@@ -23,12 +23,17 @@
import info.faceland.loot.api.sockets.SocketGem;
import info.faceland.loot.math.LootRandom;
import io.pixeloutlaw.minecraft.spigot.hilt.ItemStackExtensionsKt;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
-import java.util.*;
-
public final class SocketGemManager {
private static final double DISTANCE = 1000;
@@ -79,7 +84,7 @@ public SocketGem getSocketGem(ItemStack stack) {
if (StringUtils.isBlank(name)) {
return null;
}
- return getSocketGem(ChatColor.stripColor(name));
+ return getSocketGem(ChatColor.stripColor(name.replace("Socket Gem - ", "")));
}
public void addSocketGem(SocketGem gem) {
diff --git a/src/main/java/info/faceland/loot/utils/LootUtil.java b/src/main/java/info/faceland/loot/utils/LootUtil.java
new file mode 100644
index 0000000..cfb62c9
--- /dev/null
+++ b/src/main/java/info/faceland/loot/utils/LootUtil.java
@@ -0,0 +1,75 @@
+package info.faceland.loot.utils;
+
+import info.faceland.loot.LootPlugin;
+import info.faceland.loot.api.items.CustomItem;
+import info.faceland.loot.api.items.ItemGenerationReason;
+import info.faceland.loot.api.sockets.SocketGem;
+import info.faceland.loot.data.BuiltItem;
+import info.faceland.loot.data.ItemRarity;
+import info.faceland.loot.data.LootResponse;
+import info.faceland.loot.data.UpgradeScroll;
+import info.faceland.loot.enchantments.EnchantmentTome;
+import info.faceland.loot.items.prefabs.ArcaneEnhancer;
+import info.faceland.loot.items.prefabs.PurifyingScroll;
+import info.faceland.loot.items.prefabs.SocketExtender;
+import info.faceland.loot.tier.Tier;
+import org.bukkit.inventory.ItemStack;
+
+public class LootUtil {
+
+ public static LootResponse getRandomItem(ItemType itemType) {
+ return getRandomItem(itemType, 1, 1);
+ }
+
+ public static LootResponse getRandomItem(ItemType itemType, int itemLevel) {
+ return getRandomItem(itemType, itemLevel, 1);
+ }
+
+ public static LootResponse getRandomItem(ItemType itemType, int itemLevel, float rarityMultiplier) {
+ switch (itemType) {
+ case TIER_ITEM:
+ Tier tier = LootPlugin.getInstance().getTierManager().getRandomTier();
+ ItemRarity rarity = LootPlugin.getInstance().getRarityManager().getRandomRarityWithBonus(1 - rarityMultiplier);
+ BuiltItem builtItem = LootPlugin.getInstance().getNewItemBuilder()
+ .withTier(tier)
+ .withRarity(rarity)
+ .withLevel(Math.max(1, Math.min(itemLevel, 100)))
+ .withItemGenerationReason(ItemGenerationReason.EXTERNAL)
+ .withSpecialStat(false)
+ .build();
+ return new LootResponse(builtItem.getStack(), rarity.isBroadcast());
+ case SOCKET_GEM:
+ SocketGem gem = LootPlugin.getInstance().getSocketGemManager().getRandomSocketGemByLevel(itemLevel);
+ return new LootResponse(gem.toItemStack(1), gem.isBroadcast());
+ case CUSTOM_ITEM:
+ CustomItem ci = LootPlugin.getInstance().getCustomItemManager().getRandomCustomItemByLevel(itemLevel);
+ return new LootResponse(ci.toItemStack(1), ci.isBroadcast());
+ case PURITY_SCROLL:
+ return new LootResponse(PurifyingScroll.get(), false);
+ case UPGRADE_SCROLL:
+ UpgradeScroll us = LootPlugin.getInstance().getScrollManager().getRandomScroll();
+ ItemStack scrollStack = LootPlugin.getInstance().getScrollManager().buildItemStack(us);
+ return new LootResponse(scrollStack, us.isBroadcast());
+ case ARCANE_ENHANCER:
+ return new LootResponse(ArcaneEnhancer.get(), true);
+ case SOCKET_EXTENDER:
+ return new LootResponse(SocketExtender.EXTENDER, true);
+ case ENCHANTMENT_TOME:
+ EnchantmentTome e = LootPlugin.getInstance().getEnchantTomeManager().getRandomEnchantTome(rarityMultiplier);
+ return new LootResponse(e.toItemStack(1), e.isBroadcast());
+ }
+ return null;
+ }
+
+ public enum ItemType {
+ TIER_ITEM,
+ SOCKET_GEM,
+ UPGRADE_SCROLL,
+ PURITY_SCROLL,
+ CUSTOM_ITEM,
+ SOCKET_EXTENDER,
+ ENCHANTMENT_TOME,
+ ARCANE_ENHANCER
+ }
+
+}
diff --git a/src/main/java/info/faceland/loot/utils/MaterialUtil.java b/src/main/java/info/faceland/loot/utils/MaterialUtil.java
index a30df79..22b9c37 100644
--- a/src/main/java/info/faceland/loot/utils/MaterialUtil.java
+++ b/src/main/java/info/faceland/loot/utils/MaterialUtil.java
@@ -327,19 +327,13 @@ public static boolean canBeUpgraded(ItemStack scrollStack, ItemStack stack) {
if (scroll == null) {
return false;
}
- if (!meetsUpgradeRange(scroll, getUpgradeLevel(ItemStackExtensionsKt.getDisplayName(stack)))) {
- return false;
- }
- return true;
+ return meetsUpgradeRange(scroll, getUpgradeLevel(ItemStackExtensionsKt.getDisplayName(stack)));
}
public static boolean hasEnchantmentTag(ItemStack stack) {
List lore = new ArrayList<>(ItemStackExtensionsKt.getLore(stack));
List strippedLore = InventoryUtil.stripColor(lore);
- if (!strippedLore.contains("(Enchantable)")) {
- return false;
- }
- return true;
+ return strippedLore.contains("(Enchantable)");
}
public static boolean isMatchingGroup(EnchantmentTome tome, Material material) {