Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
109347a601 | ||
|
|
43bef762bf | ||
|
|
69a2e0e247 | ||
|
|
874a9b4f32 | ||
|
|
5690221c27 | ||
|
|
f19b143804 | ||
|
|
bbbf19c041 |
@@ -1,6 +1,9 @@
|
||||
package com.willfp.eco.core.items;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -47,6 +50,12 @@ public class CustomItem implements TestableItem {
|
||||
this.key = key;
|
||||
this.test = test;
|
||||
this.item = item;
|
||||
|
||||
Eco.getHandler().getEcoPlugin().getScheduler().runLater(() -> {
|
||||
if (!matches(getItem())) {
|
||||
Bukkit.getLogger().severe("Item with key " + key + " is invalid!");
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -178,7 +178,10 @@ public final class Items {
|
||||
List<Predicate<ItemStack>> predicates = new ArrayList<>();
|
||||
|
||||
for (LookupArgParser argParser : ARG_PARSERS) {
|
||||
predicates.add(argParser.parseArguments(modifierArgs, meta));
|
||||
Predicate<ItemStack> predicate = argParser.parseArguments(modifierArgs, meta);
|
||||
if (predicate != null) {
|
||||
predicates.add(argParser.parseArguments(modifierArgs, meta));
|
||||
}
|
||||
}
|
||||
|
||||
example.setItemMeta(meta);
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -16,8 +17,8 @@ import java.util.function.Predicate;
|
||||
*/
|
||||
public class EnchantmentArgParser implements LookupArgParser {
|
||||
@Override
|
||||
public Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||
@NotNull final ItemMeta meta) {
|
||||
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||
@NotNull final ItemMeta meta) {
|
||||
Map<Enchantment, Integer> requiredEnchantments = new HashMap<>();
|
||||
|
||||
for (String enchantArg : args) {
|
||||
@@ -37,6 +38,10 @@ public class EnchantmentArgParser implements LookupArgParser {
|
||||
requiredEnchantments.put(enchantment, level);
|
||||
}
|
||||
|
||||
if (requiredEnchantments.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (meta instanceof EnchantmentStorageMeta storageMeta) {
|
||||
requiredEnchantments.forEach((enchantment, integer) -> storageMeta.addStoredEnchant(enchantment, integer, true));
|
||||
} else {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.willfp.eco.core.items.TestableItem;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -19,6 +20,6 @@ public interface LookupArgParser {
|
||||
* @param meta The ItemMeta to modify.
|
||||
* @return The predicate test to apply to the modified item.
|
||||
*/
|
||||
Predicate<ItemStack> parseArguments(@NotNull String[] args,
|
||||
@NotNull ItemMeta meta);
|
||||
@Nullable Predicate<ItemStack> parseArguments(@NotNull String[] args,
|
||||
@NotNull ItemMeta meta);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -13,8 +14,8 @@ import java.util.function.Predicate;
|
||||
*/
|
||||
public class TextureArgParser implements LookupArgParser {
|
||||
@Override
|
||||
public Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||
@NotNull final ItemMeta meta) {
|
||||
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||
@NotNull final ItemMeta meta) {
|
||||
String skullTexture = null;
|
||||
|
||||
for (String arg : args) {
|
||||
@@ -34,6 +35,10 @@ public class TextureArgParser implements LookupArgParser {
|
||||
SkullUtils.setSkullTexture(skullMeta, skullTexture);
|
||||
}
|
||||
|
||||
if (skullTexture == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String finalSkullTexture = skullTexture;
|
||||
return test -> {
|
||||
if (!test.hasItemMeta()) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.core.recipe.parts;
|
||||
|
||||
import com.willfp.eco.core.items.TestableItem;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -82,6 +82,10 @@ public final class ShapedCraftingRecipe extends PluginDependent<EcoPlugin> imple
|
||||
ShapedRecipe shapedRecipe = new ShapedRecipe(this.getKey(), this.getOutput());
|
||||
shapedRecipe.shape("012", "345", "678");
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (parts.get(i) instanceof EmptyTestableItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
char character = String.valueOf(i).toCharArray()[0];
|
||||
shapedRecipe.setIngredient(character, parts.get(i).getItem().getType());
|
||||
}
|
||||
@@ -89,6 +93,10 @@ public final class ShapedCraftingRecipe extends PluginDependent<EcoPlugin> imple
|
||||
ShapedRecipe displayedRecipe = new ShapedRecipe(this.getDisplayedKey(), this.getOutput());
|
||||
displayedRecipe.shape("012", "345", "678");
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (parts.get(i) instanceof EmptyTestableItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
char character = String.valueOf(i).toCharArray()[0];
|
||||
ItemStack item = parts.get(i).getItem();
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.willfp.eco.spigot.eventlisteners.*
|
||||
import com.willfp.eco.spigot.gui.GUIListener
|
||||
import com.willfp.eco.spigot.integrations.anticheat.*
|
||||
import com.willfp.eco.spigot.integrations.antigrief.*
|
||||
import com.willfp.eco.spigot.integrations.customitems.CustomItemsHeadDatabase
|
||||
import com.willfp.eco.spigot.integrations.customitems.CustomItemsItemsAdder
|
||||
import com.willfp.eco.spigot.integrations.customitems.CustomItemsOraxen
|
||||
import com.willfp.eco.spigot.integrations.mcmmo.McmmoIntegrationImpl
|
||||
@@ -123,7 +122,6 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
// Custom Items
|
||||
IntegrationLoader("Oraxen") { CustomItemsManager.register(CustomItemsOraxen()) },
|
||||
IntegrationLoader("ItemsAdder") { CustomItemsManager.register(CustomItemsItemsAdder(this)) },
|
||||
IntegrationLoader("HeadDatabase") { CustomItemsManager.register(CustomItemsHeadDatabase()) },
|
||||
|
||||
// Shop
|
||||
IntegrationLoader("ShopGuiPlus") { ShopManager.register(ShopShopGuiPlus()) },
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.willfp.eco.spigot.integrations.customitems
|
||||
|
||||
import com.willfp.eco.core.integrations.customitems.CustomItemsWrapper
|
||||
import com.willfp.eco.core.items.CustomItem
|
||||
import com.willfp.eco.util.NamespacedKeyUtils
|
||||
import me.arcaniax.hdb.api.HeadDatabaseAPI
|
||||
import me.arcaniax.hdb.enums.CategoryEnum
|
||||
import java.util.function.Predicate
|
||||
|
||||
class CustomItemsHeadDatabase : CustomItemsWrapper {
|
||||
private val api = HeadDatabaseAPI()
|
||||
|
||||
override fun registerAllItems() {
|
||||
for (categoryEnum in CategoryEnum.values()) {
|
||||
for (head in api.getHeads(categoryEnum).toList()) {
|
||||
val stack = head.head
|
||||
val id = head.id
|
||||
val key = NamespacedKeyUtils.create("headdb", id.lowercase());
|
||||
CustomItem(
|
||||
key,
|
||||
Predicate { test ->
|
||||
val headId = api.getItemID(test) ?: return@Predicate false
|
||||
headId.equals(id, ignoreCase = true)
|
||||
},
|
||||
stack
|
||||
).register()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "HeadDatabase"
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 6.7.1
|
||||
version = 6.7.3
|
||||
plugin-name = eco
|
||||
Reference in New Issue
Block a user