Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
732aaa3bf1 | ||
|
|
a38387be33 | ||
|
|
582f9b08f3 | ||
|
|
638367cbb2 | ||
|
|
ec35e7d779 | ||
|
|
1cc2a585d6 | ||
|
|
aa553b96d6 | ||
|
|
feb7ecee48 | ||
|
|
c0be6a12ff | ||
|
|
1dc6b651a0 | ||
|
|
3c26c02642 |
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: Auxilor Community Discord
|
||||||
|
url: https://discord.gg/ZcwpSsE/
|
||||||
|
about: Join the Auxilor discord to get help from support staff and the general community!
|
||||||
|
- name: The most common issues people have
|
||||||
|
url: https://github.com/Auxilor/eco/issues/78
|
||||||
|
about: Check the list of known common issues to see if your issue has already been solved
|
||||||
31
.github/ISSUE_TEMPLATE/report-a-bug.md
vendored
Normal file
31
.github/ISSUE_TEMPLATE/report-a-bug.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
name: Report a Bug
|
||||||
|
about: Report an issue with the plugin
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Server Information (please complete the following information):**
|
||||||
|
- Version: (output of `/ver` command)
|
||||||
|
- Version of plugin and eco (`/ver eco`, `/ver <plugin>`)
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
20
.github/ISSUE_TEMPLATE/request-a-feature.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/request-a-feature.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Request a Feature
|
||||||
|
about: Suggest an idea for this plugin
|
||||||
|
title: ''
|
||||||
|
labels: enhancement
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
@@ -19,6 +19,7 @@ import com.willfp.eco.core.requirement.RequirementFactory;
|
|||||||
import com.willfp.eco.core.scheduling.Scheduler;
|
import com.willfp.eco.core.scheduling.Scheduler;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
@@ -243,4 +244,19 @@ public interface Handler {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
Entity createDummyEntity(@NotNull Location location);
|
Entity createDummyEntity(@NotNull Location location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link NamespacedKey} quickly
|
||||||
|
* <p>
|
||||||
|
* Bypasses the constructor, allowing for the creation of invalid keys,
|
||||||
|
* therefore this is considered unsafe and should only be called after
|
||||||
|
* the key has been confirmed to be valid.
|
||||||
|
*
|
||||||
|
* @param namespace The namespace.
|
||||||
|
* @param key The key.
|
||||||
|
* @return The key.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
NamespacedKey createNamespacedKey(@NotNull String namespace,
|
||||||
|
@NotNull String key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class PersistentDataKey<T> {
|
|||||||
/**
|
/**
|
||||||
* The persistent data key type.
|
* The persistent data key type.
|
||||||
*/
|
*/
|
||||||
private final PersistentDataKeyType type;
|
private final PersistentDataKeyType<T> type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Persistent Data Key.
|
* Create a new Persistent Data Key.
|
||||||
@@ -35,7 +35,7 @@ public class PersistentDataKey<T> {
|
|||||||
* @param defaultValue The default value.
|
* @param defaultValue The default value.
|
||||||
*/
|
*/
|
||||||
public PersistentDataKey(@NotNull final NamespacedKey key,
|
public PersistentDataKey(@NotNull final NamespacedKey key,
|
||||||
@NotNull final PersistentDataKeyType type,
|
@NotNull final PersistentDataKeyType<T> type,
|
||||||
@NotNull final T defaultValue) {
|
@NotNull final T defaultValue) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
@@ -76,7 +76,7 @@ public class PersistentDataKey<T> {
|
|||||||
*
|
*
|
||||||
* @return The key type.
|
* @return The key type.
|
||||||
*/
|
*/
|
||||||
public PersistentDataKeyType getType() {
|
public PersistentDataKeyType<T> getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,108 @@
|
|||||||
package com.willfp.eco.core.data.keys;
|
package com.willfp.eco.core.data.keys;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All storable data key types.
|
* All storable data key types.
|
||||||
|
*
|
||||||
|
* @param <T> The type.
|
||||||
*/
|
*/
|
||||||
public enum PersistentDataKeyType {
|
public final class PersistentDataKeyType<T> {
|
||||||
|
/**
|
||||||
|
* The registered key types.
|
||||||
|
*/
|
||||||
|
private static final List<PersistentDataKeyType<?>> VALUES = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String.
|
* String.
|
||||||
*/
|
*/
|
||||||
STRING,
|
public static final PersistentDataKeyType<String> STRING = new PersistentDataKeyType<>(String.class, "STRING");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boolean.
|
* Boolean.
|
||||||
*/
|
*/
|
||||||
BOOLEAN,
|
public static final PersistentDataKeyType<Boolean> BOOLEAN = new PersistentDataKeyType<>(Boolean.class, "BOOLEAN");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integer.
|
* Int.
|
||||||
*/
|
*/
|
||||||
INT,
|
public static final PersistentDataKeyType<Integer> INT = new PersistentDataKeyType<>(Integer.class, "INT");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Double.
|
* Double.
|
||||||
*/
|
*/
|
||||||
DOUBLE
|
public static final PersistentDataKeyType<Double> DOUBLE = new PersistentDataKeyType<>(Double.class, "DOUBLE");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class of the type.
|
||||||
|
*/
|
||||||
|
private final Class<T> typeClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the key type.
|
||||||
|
*/
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the class of the type.
|
||||||
|
*
|
||||||
|
* @return The class.
|
||||||
|
*/
|
||||||
|
public Class<T> getTypeClass() {
|
||||||
|
return typeClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the key type.
|
||||||
|
*
|
||||||
|
* @return The name.
|
||||||
|
*/
|
||||||
|
public String name() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new PersistentDataKeyType.
|
||||||
|
*
|
||||||
|
* @param typeClass The type class.
|
||||||
|
* @param name The name.
|
||||||
|
*/
|
||||||
|
private PersistentDataKeyType(@NotNull final Class<T> typeClass,
|
||||||
|
@NotNull final String name) {
|
||||||
|
VALUES.add(this);
|
||||||
|
|
||||||
|
this.typeClass = typeClass;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all registered {@link PersistentDataKeyType}s.
|
||||||
|
*
|
||||||
|
* @return The registered types.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static PersistentDataKeyType<?>[] values() {
|
||||||
|
return VALUES.toArray(new PersistentDataKeyType[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a key type from a name.
|
||||||
|
*
|
||||||
|
* @param name The name.
|
||||||
|
* @return The type, or null if not found.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static PersistentDataKeyType<?> valueOf(@NotNull final String name) {
|
||||||
|
for (PersistentDataKeyType<?> type : VALUES) {
|
||||||
|
if (type.name.equalsIgnoreCase(name)) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.willfp.eco.core.EcoPlugin;
|
|||||||
import com.willfp.eco.core.items.Items;
|
import com.willfp.eco.core.items.Items;
|
||||||
import com.willfp.eco.core.recipe.recipes.CraftingRecipe;
|
import com.willfp.eco.core.recipe.recipes.CraftingRecipe;
|
||||||
import com.willfp.eco.core.recipe.recipes.ShapedCraftingRecipe;
|
import com.willfp.eco.core.recipe.recipes.ShapedCraftingRecipe;
|
||||||
|
import com.willfp.eco.util.NamespacedKeyUtils;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -58,7 +59,10 @@ public final class Recipes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (key.getKey().contains("_displayed")) {
|
if (key.getKey().contains("_displayed")) {
|
||||||
NamespacedKey otherKey = new NamespacedKey(key.getNamespace(), key.getKey().replace("_displayed", ""));
|
NamespacedKey otherKey = NamespacedKeyUtils.create(
|
||||||
|
key.getNamespace(),
|
||||||
|
key.getKey().replace("_displayed", "")
|
||||||
|
);
|
||||||
|
|
||||||
return RECIPES.get(otherKey);
|
return RECIPES.get(otherKey);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.willfp.eco.util;
|
package com.willfp.eco.util;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.Eco;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities / API methods for {@link NamespacedKey}s.
|
* Utilities / API methods for {@link NamespacedKey}s.
|
||||||
*/
|
*/
|
||||||
@@ -17,7 +16,7 @@ public final class NamespacedKeyUtils {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static NamespacedKey createEcoKey(@NotNull final String string) {
|
public static NamespacedKey createEcoKey(@NotNull final String string) {
|
||||||
return Objects.requireNonNull(NamespacedKey.fromString("eco:" + string));
|
return NamespacedKeyUtils.create("eco", string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,7 +29,28 @@ public final class NamespacedKeyUtils {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public static NamespacedKey create(@NotNull final String namespace,
|
public static NamespacedKey create(@NotNull final String namespace,
|
||||||
@NotNull final String key) {
|
@NotNull final String key) {
|
||||||
return Objects.requireNonNull(NamespacedKey.fromString(namespace + ":" + key));
|
return Eco.getHandler().createNamespacedKey(
|
||||||
|
namespace,
|
||||||
|
key
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a NamespacedKey from a string.
|
||||||
|
* <p>
|
||||||
|
* Preferred over {@link NamespacedKey#fromString(String)} for performance reasons.
|
||||||
|
*
|
||||||
|
* @param string The string.
|
||||||
|
* @return The key.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static NamespacedKey fromString(@NotNull final String string) {
|
||||||
|
int index = string.indexOf(":");
|
||||||
|
|
||||||
|
return NamespacedKeyUtils.create(
|
||||||
|
string.substring(0, index),
|
||||||
|
string.substring(index + 1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private NamespacedKeyUtils() {
|
private NamespacedKeyUtils() {
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ dependencies {
|
|||||||
compileOnly 'net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT'
|
compileOnly 'net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT'
|
||||||
compileOnly 'net.kyori:adventure-platform-bukkit:4.0.0'
|
compileOnly 'net.kyori:adventure-platform-bukkit:4.0.0'
|
||||||
compileOnly 'com.google.guava:guava:31.0.1-jre'
|
compileOnly 'com.google.guava:guava:31.0.1-jre'
|
||||||
|
compileOnly 'org.objenesis:objenesis:3.2'
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,11 @@ package com.willfp.eco.internal.factory
|
|||||||
|
|
||||||
import com.willfp.eco.core.EcoPlugin
|
import com.willfp.eco.core.EcoPlugin
|
||||||
import com.willfp.eco.core.factory.NamespacedKeyFactory
|
import com.willfp.eco.core.factory.NamespacedKeyFactory
|
||||||
|
import com.willfp.eco.util.NamespacedKeyUtils
|
||||||
import org.bukkit.NamespacedKey
|
import org.bukkit.NamespacedKey
|
||||||
|
|
||||||
class EcoNamespacedKeyFactory(private val plugin: EcoPlugin) : NamespacedKeyFactory {
|
class EcoNamespacedKeyFactory(private val plugin: EcoPlugin) : NamespacedKeyFactory {
|
||||||
override fun create(key: String): NamespacedKey {
|
override fun create(key: String): NamespacedKey {
|
||||||
return NamespacedKey(plugin, key)
|
return NamespacedKeyUtils.create(plugin.name, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.willfp.eco.internal.fast
|
||||||
|
|
||||||
|
import org.bukkit.NamespacedKey
|
||||||
|
import org.objenesis.ObjenesisStd
|
||||||
|
|
||||||
|
interface InternalNamespacedKeyFactory {
|
||||||
|
fun create(namespace: String, key: String): NamespacedKey
|
||||||
|
}
|
||||||
|
|
||||||
|
class FastInternalNamespacedKeyFactory : InternalNamespacedKeyFactory {
|
||||||
|
private val creator = ObjenesisStd().getInstantiatorOf(NamespacedKey::class.java)
|
||||||
|
private val namespaceField = NamespacedKey::class.java.getDeclaredField("namespace")
|
||||||
|
.apply { isAccessible = true }
|
||||||
|
private val keyField = NamespacedKey::class.java.getDeclaredField("key")
|
||||||
|
.apply { isAccessible = true }
|
||||||
|
|
||||||
|
|
||||||
|
override fun create(namespace: String, key: String): NamespacedKey {
|
||||||
|
val namespacedKey = creator.newInstance()
|
||||||
|
keyField.set(namespacedKey, key.lowercase())
|
||||||
|
namespaceField.set(namespacedKey, namespace.lowercase())
|
||||||
|
return namespacedKey
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SafeInternalNamespacedKeyFactory : InternalNamespacedKeyFactory {
|
||||||
|
override fun create(namespace: String, key: String): NamespacedKey {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
return NamespacedKey(namespace, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package com.willfp.eco.internal.items
|
|||||||
|
|
||||||
import com.willfp.eco.core.fast.FastItemStack
|
import com.willfp.eco.core.fast.FastItemStack
|
||||||
import com.willfp.eco.core.items.args.LookupArgParser
|
import com.willfp.eco.core.items.args.LookupArgParser
|
||||||
import org.bukkit.NamespacedKey
|
import com.willfp.eco.util.NamespacedKeyUtils
|
||||||
import org.bukkit.enchantments.Enchantment
|
import org.bukkit.enchantments.Enchantment
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta
|
||||||
@@ -20,7 +20,7 @@ class ArgParserEnchantment : LookupArgParser {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
val enchant = Enchantment.getByKey(NamespacedKey.minecraft(argSplit[0].lowercase()))
|
val enchant = Enchantment.getByKey(NamespacedKeyUtils.create("minecraft", argSplit[0]))
|
||||||
val level = argSplit[1].toIntOrNull()
|
val level = argSplit[1].toIntOrNull()
|
||||||
|
|
||||||
if (enchant != null && level != null) {
|
if (enchant != null && level != null) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3.fast
|
package com.willfp.eco.internal.spigot.proxy.v1_16_R3.fast
|
||||||
|
|
||||||
import com.willfp.eco.internal.fast.EcoFastItemStack
|
import com.willfp.eco.internal.fast.EcoFastItemStack
|
||||||
|
import com.willfp.eco.util.NamespacedKeyUtils
|
||||||
import com.willfp.eco.util.StringUtils
|
import com.willfp.eco.util.StringUtils
|
||||||
import net.minecraft.server.v1_16_R3.Item
|
import net.minecraft.server.v1_16_R3.Item
|
||||||
import net.minecraft.server.v1_16_R3.ItemEnchantedBook
|
import net.minecraft.server.v1_16_R3.ItemEnchantedBook
|
||||||
@@ -11,7 +12,6 @@ import net.minecraft.server.v1_16_R3.NBTTagList
|
|||||||
import net.minecraft.server.v1_16_R3.NBTTagString
|
import net.minecraft.server.v1_16_R3.NBTTagString
|
||||||
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack
|
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack
|
||||||
import org.bukkit.craftbukkit.v1_16_R3.util.CraftMagicNumbers
|
import org.bukkit.craftbukkit.v1_16_R3.util.CraftMagicNumbers
|
||||||
import org.bukkit.craftbukkit.v1_16_R3.util.CraftNamespacedKey
|
|
||||||
import org.bukkit.enchantments.Enchantment
|
import org.bukkit.enchantments.Enchantment
|
||||||
import org.bukkit.inventory.ItemFlag
|
import org.bukkit.inventory.ItemFlag
|
||||||
import kotlin.experimental.and
|
import kotlin.experimental.and
|
||||||
@@ -29,7 +29,7 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS
|
|||||||
val compound = base as NBTTagCompound
|
val compound = base as NBTTagCompound
|
||||||
val key = compound.getString("id")
|
val key = compound.getString("id")
|
||||||
val level: Int = ('\uffff'.code.toShort() and compound.getShort("lvl")).toInt()
|
val level: Int = ('\uffff'.code.toShort() and compound.getShort("lvl")).toInt()
|
||||||
val found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key))
|
val found = Enchantment.getByKey(NamespacedKeyUtils.fromString(key))
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
foundEnchantments[found] = level
|
foundEnchantments[found] = level
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.willfp.eco.internal.spigot.proxy.v1_17_R1.fast
|
package com.willfp.eco.internal.spigot.proxy.v1_17_R1.fast
|
||||||
|
|
||||||
import com.willfp.eco.internal.fast.EcoFastItemStack
|
import com.willfp.eco.internal.fast.EcoFastItemStack
|
||||||
|
import com.willfp.eco.util.NamespacedKeyUtils
|
||||||
import com.willfp.eco.util.StringUtils
|
import com.willfp.eco.util.StringUtils
|
||||||
import net.minecraft.nbt.CompoundTag
|
import net.minecraft.nbt.CompoundTag
|
||||||
import net.minecraft.nbt.ListTag
|
import net.minecraft.nbt.ListTag
|
||||||
@@ -11,7 +12,6 @@ import net.minecraft.world.item.ItemStack
|
|||||||
import net.minecraft.world.item.Items
|
import net.minecraft.world.item.Items
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack
|
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.util.CraftMagicNumbers
|
import org.bukkit.craftbukkit.v1_17_R1.util.CraftMagicNumbers
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.util.CraftNamespacedKey
|
|
||||||
import org.bukkit.enchantments.Enchantment
|
import org.bukkit.enchantments.Enchantment
|
||||||
import org.bukkit.inventory.ItemFlag
|
import org.bukkit.inventory.ItemFlag
|
||||||
import kotlin.experimental.and
|
import kotlin.experimental.and
|
||||||
@@ -31,7 +31,7 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS
|
|||||||
val compound = base as CompoundTag
|
val compound = base as CompoundTag
|
||||||
val key = compound.getString("id")
|
val key = compound.getString("id")
|
||||||
val level = ('\uffff'.code.toShort() and compound.getShort("lvl")).toInt()
|
val level = ('\uffff'.code.toShort() and compound.getShort("lvl")).toInt()
|
||||||
val found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key))
|
val found = Enchantment.getByKey(NamespacedKeyUtils.fromString(key))
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
foundEnchantments[found] = level
|
foundEnchantments[found] = level
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.willfp.eco.internal.spigot.proxy.v1_18_R1.fast
|
package com.willfp.eco.internal.spigot.proxy.v1_18_R1.fast
|
||||||
|
|
||||||
import com.willfp.eco.internal.fast.EcoFastItemStack
|
import com.willfp.eco.internal.fast.EcoFastItemStack
|
||||||
|
import com.willfp.eco.util.NamespacedKeyUtils
|
||||||
import com.willfp.eco.util.StringUtils
|
import com.willfp.eco.util.StringUtils
|
||||||
import net.minecraft.nbt.CompoundTag
|
import net.minecraft.nbt.CompoundTag
|
||||||
import net.minecraft.nbt.ListTag
|
import net.minecraft.nbt.ListTag
|
||||||
@@ -11,7 +12,6 @@ import net.minecraft.world.item.ItemStack
|
|||||||
import net.minecraft.world.item.Items
|
import net.minecraft.world.item.Items
|
||||||
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack
|
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack
|
||||||
import org.bukkit.craftbukkit.v1_18_R1.util.CraftMagicNumbers
|
import org.bukkit.craftbukkit.v1_18_R1.util.CraftMagicNumbers
|
||||||
import org.bukkit.craftbukkit.v1_18_R1.util.CraftNamespacedKey
|
|
||||||
import org.bukkit.enchantments.Enchantment
|
import org.bukkit.enchantments.Enchantment
|
||||||
import org.bukkit.inventory.ItemFlag
|
import org.bukkit.inventory.ItemFlag
|
||||||
import kotlin.experimental.and
|
import kotlin.experimental.and
|
||||||
@@ -32,7 +32,7 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS
|
|||||||
val compound = base as CompoundTag
|
val compound = base as CompoundTag
|
||||||
val key = compound.getString("id")
|
val key = compound.getString("id")
|
||||||
val level = ('\uffff'.code.toShort() and compound.getShort("lvl")).toInt()
|
val level = ('\uffff'.code.toShort() and compound.getShort("lvl")).toInt()
|
||||||
val found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key))
|
val found = Enchantment.getByKey(NamespacedKeyUtils.fromString(key))
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
foundEnchantments[found] = level
|
foundEnchantments[found] = level
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ import com.willfp.eco.internal.extensions.EcoExtensionLoader
|
|||||||
import com.willfp.eco.internal.factory.EcoMetadataValueFactory
|
import com.willfp.eco.internal.factory.EcoMetadataValueFactory
|
||||||
import com.willfp.eco.internal.factory.EcoNamespacedKeyFactory
|
import com.willfp.eco.internal.factory.EcoNamespacedKeyFactory
|
||||||
import com.willfp.eco.internal.factory.EcoRunnableFactory
|
import com.willfp.eco.internal.factory.EcoRunnableFactory
|
||||||
|
import com.willfp.eco.internal.fast.FastInternalNamespacedKeyFactory
|
||||||
|
import com.willfp.eco.internal.fast.InternalNamespacedKeyFactory
|
||||||
|
import com.willfp.eco.internal.fast.SafeInternalNamespacedKeyFactory
|
||||||
import com.willfp.eco.internal.gui.EcoGUIFactory
|
import com.willfp.eco.internal.gui.EcoGUIFactory
|
||||||
import com.willfp.eco.internal.integrations.PlaceholderIntegrationPAPI
|
import com.willfp.eco.internal.integrations.PlaceholderIntegrationPAPI
|
||||||
import com.willfp.eco.internal.logging.EcoLogger
|
import com.willfp.eco.internal.logging.EcoLogger
|
||||||
@@ -29,6 +32,7 @@ import com.willfp.eco.internal.spigot.proxy.DummyEntityProxy
|
|||||||
import com.willfp.eco.internal.spigot.proxy.FastItemStackFactoryProxy
|
import com.willfp.eco.internal.spigot.proxy.FastItemStackFactoryProxy
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences
|
||||||
import org.bukkit.Location
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.NamespacedKey
|
||||||
import org.bukkit.entity.Entity
|
import org.bukkit.entity.Entity
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import java.util.logging.Logger
|
import java.util.logging.Logger
|
||||||
@@ -43,6 +47,9 @@ class EcoHandler : EcoSpigotPlugin(), Handler {
|
|||||||
if (this.configYml.getBool("mysql.enabled"))
|
if (this.configYml.getBool("mysql.enabled"))
|
||||||
MySQLDataHandler(this) else YamlDataHandler(this)
|
MySQLDataHandler(this) else YamlDataHandler(this)
|
||||||
)
|
)
|
||||||
|
private val keyFactory: InternalNamespacedKeyFactory? =
|
||||||
|
if (this.configYml.getBool("use-safer-namespacedkey-creation"))
|
||||||
|
SafeInternalNamespacedKeyFactory() else FastInternalNamespacedKeyFactory()
|
||||||
|
|
||||||
override fun createScheduler(plugin: EcoPlugin): EcoScheduler {
|
override fun createScheduler(plugin: EcoPlugin): EcoScheduler {
|
||||||
return EcoScheduler(plugin)
|
return EcoScheduler(plugin)
|
||||||
@@ -147,4 +154,9 @@ class EcoHandler : EcoSpigotPlugin(), Handler {
|
|||||||
override fun createDummyEntity(location: Location): Entity {
|
override fun createDummyEntity(location: Location): Entity {
|
||||||
return getProxy(DummyEntityProxy::class.java).createDummyEntity(location)
|
return getProxy(DummyEntityProxy::class.java).createDummyEntity(location)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun createNamespacedKey(namespace: String, key: String): NamespacedKey {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
return keyFactory?.create(namespace, key) ?: NamespacedKey(namespace, key)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,13 @@ display-frame-ttl: 17
|
|||||||
# memory use.
|
# memory use.
|
||||||
item-cache-ttl: 6000
|
item-cache-ttl: 6000
|
||||||
|
|
||||||
|
# The default bukkit NamespacedKey creation can cause decent amounts of lag under
|
||||||
|
# load due to the use of regex validation in the constructor. eco has its own system
|
||||||
|
# to create NamespacedKeys, however it can be unsafe as it skips most validation checks.
|
||||||
|
# If you encounter any bugs with this, then enable this option - however it will come
|
||||||
|
# at a performance penalty.
|
||||||
|
use-safer-namespacedkey-creation: false
|
||||||
|
|
||||||
# Window items packets have the option to be run asynchronously. This may cause
|
# Window items packets have the option to be run asynchronously. This may cause
|
||||||
# some bugs and is considered experimental, however it has been tested without
|
# some bugs and is considered experimental, however it has been tested without
|
||||||
# any apparent issues. Enable this if performance is absolutely crucial or if you
|
# any apparent issues. Enable this if performance is absolutely crucial or if you
|
||||||
|
|||||||
@@ -56,4 +56,5 @@ libraries:
|
|||||||
- 'mysql:mysql-connector-java:8.0.25'
|
- 'mysql:mysql-connector-java:8.0.25'
|
||||||
- 'com.google.guava:guava:31.0.1-jre'
|
- 'com.google.guava:guava:31.0.1-jre'
|
||||||
- 'com.zaxxer:HikariCP:5.0.0'
|
- 'com.zaxxer:HikariCP:5.0.0'
|
||||||
- 'org.apache.commons:commons-lang3:3.0'
|
- 'org.apache.commons:commons-lang3:3.0'
|
||||||
|
- 'org.objenesis:objenesis:3.2'
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
version = 6.20.4
|
version = 6.21.0
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
Reference in New Issue
Block a user