Compare commits

..

19 Commits

Author SHA1 Message Date
Auxilor
c69bb6904f Minor fixes 2022-04-20 11:31:37 +01:00
Auxilor
9f193b7206 Fixed val using annotations 2022-04-20 11:28:55 +01:00
Auxilor
6fce2c13fe Updated to 6.34.0 2022-04-20 11:25:19 +01:00
Auxilor
02342c11a6 Added utility methods for base NBT 2022-04-20 11:25:00 +01:00
Auxilor
2fde56df0d Added ability to modify full item NBT via PersistentDataContainers and FastItemStack 2022-04-20 11:19:24 +01:00
Auxilor
cb64dedd74 Updated to kotlin 1.6.21 2022-04-20 10:57:27 +01:00
Auxilor
a7c489413e Moved IridiumSkyblock to use jar 2022-04-20 10:56:47 +01:00
Auxilor
f9ed174e31 Added PersistentDataHolder to FastItemStack 2022-04-13 13:21:37 +01:00
Auxilor
496d878a14 Added missing FIS method 2022-04-13 12:55:48 +01:00
Auxilor
00853d4a92 Fixed getSkullTexture 2022-04-13 12:39:32 +01:00
Auxilor
5eb0d2380a Updated to 6.33.0 2022-04-13 12:37:19 +01:00
Auxilor
d19cff9a42 Added component methods to FastItemStack 2022-04-13 12:36:49 +01:00
Auxilor
234b5fdd8e Fixed newbiehelper and bentobox 2022-04-11 15:02:29 +01:00
Auxilor
2dbe6c7fe4 Updated to 6.32.2 2022-04-11 14:55:48 +01:00
Auxilor
9d4d1ace08 Fixed use_spell and tempt 2022-04-11 14:55:35 +01:00
Auxilor
364550d228 Pain 2022-04-06 13:47:01 +01:00
Auxilor
d5e8cbaf33 Updated to 6.32.1 2022-04-06 13:35:34 +01:00
Auxilor
c4d532fda9 Removed MySQL relocation 2022-04-06 13:34:33 +01:00
Auxilor
aa097cf7e2 Fixed wrong MySQL driver class 2022-04-06 13:08:29 +01:00
24 changed files with 569 additions and 110 deletions

View File

@@ -4,7 +4,7 @@ buildscript {
} }
dependencies { dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
} }
} }
@@ -13,7 +13,7 @@ plugins {
id("com.github.johnrengelman.shadow") version "7.1.2" id("com.github.johnrengelman.shadow") version "7.1.2"
id("maven-publish") id("maven-publish")
id("java") id("java")
kotlin("jvm") version "1.6.10" kotlin("jvm") version "1.6.21"
} }
dependencies { dependencies {
@@ -71,9 +71,6 @@ allprojects {
// CombatLogX // CombatLogX
maven("https://nexus.sirblobman.xyz/repository/public/") maven("https://nexus.sirblobman.xyz/repository/public/")
// IridiumSkyblock
maven("https://nexus.iridiumdevelopment.net/repository/maven-releases/")
// MythicMobs // MythicMobs
maven("https://mvn.lumine.io/repository/maven-public/") maven("https://mvn.lumine.io/repository/maven-public/")
@@ -103,7 +100,7 @@ allprojects {
// Other // Other
implementation("com.github.ben-manes.caffeine:caffeine:3.0.6") implementation("com.github.ben-manes.caffeine:caffeine:3.0.6")
implementation("org.apache.maven:maven-artifact:3.8.4") implementation("org.apache.maven:maven-artifact:3.8.4")
implementation(kotlin("stdlib", version = "1.6.10")) implementation(kotlin("stdlib", version = "1.6.21"))
} }
tasks.withType<JavaCompile> { tasks.withType<JavaCompile> {
@@ -119,6 +116,7 @@ allprojects {
exclude(group = "com.darkblade12", module = "particleeffect") exclude(group = "com.darkblade12", module = "particleeffect")
exclude(group = "com.github.cryptomorin", module = "XSeries") exclude(group = "com.github.cryptomorin", module = "XSeries")
exclude(group = "net.wesjd", module = "anvilgui") exclude(group = "net.wesjd", module = "anvilgui")
exclude(group = "org.slf4j", module = "slf4j-api")
} }
configurations.testImplementation { configurations.testImplementation {
@@ -141,10 +139,10 @@ allprojects {
relocate("org.apache.maven", "com.willfp.eco.libs.maven") relocate("org.apache.maven", "com.willfp.eco.libs.maven")
relocate("org.checkerframework", "com.willfp.eco.libs.checkerframework") relocate("org.checkerframework", "com.willfp.eco.libs.checkerframework")
relocate("org.intellij", "com.willfp.eco.libs.intellij") relocate("org.intellij", "com.willfp.eco.libs.intellij")
relocate("org.jetbrains", "com.willfp.eco.libs.jetbrains") relocate("org.jetbrains.annotations", "com.willfp.eco.libs.jetbrains.annotations")
//relocate("org.jetbrains.exposed", "com.willfp.eco.libs.exposed")
relocate("org.objenesis", "com.willfp.eco.libs.objenesis") relocate("org.objenesis", "com.willfp.eco.libs.objenesis")
relocate("org.reflections", "com.willfp.eco.libs.reflections") relocate("org.reflections", "com.willfp.eco.libs.reflections")
relocate("org.slf4j", "com.willfp.eco.libs.slf4j")
relocate("javassist", "com.willfp.eco.libs.javassist") relocate("javassist", "com.willfp.eco.libs.javassist")
relocate("javax.annotation", "com.willfp.eco.libs.annotation") relocate("javax.annotation", "com.willfp.eco.libs.annotation")
relocate("com.google.errorprone", "com.willfp.eco.libs.errorprone") relocate("com.google.errorprone", "com.willfp.eco.libs.errorprone")
@@ -152,8 +150,8 @@ allprojects {
relocate("com.google.thirdparty", "com.willfp.eco.libs.google.thirdparty") relocate("com.google.thirdparty", "com.willfp.eco.libs.google.thirdparty")
relocate("com.google.protobuf", "com.willfp.eco.libs.google.protobuf") // No I don't know either relocate("com.google.protobuf", "com.willfp.eco.libs.google.protobuf") // No I don't know either
relocate("google.protobuf", "com.willfp.eco.libs.protobuf") // Still don't know relocate("google.protobuf", "com.willfp.eco.libs.protobuf") // Still don't know
relocate("com.mysql", "com.willfp.eco.libs.mysql")
relocate("com.zaxxer.hikari", "com.willfp.eco.libs.hikari") relocate("com.zaxxer.hikari", "com.willfp.eco.libs.hikari")
//relocate("com.mysql", "com.willfp.eco.libs.mysql")
/* /*
Kotlin and caffeine are not shaded so that they can be accessed directly by eco plugins. Kotlin and caffeine are not shaded so that they can be accessed directly by eco plugins.

View File

@@ -1,10 +1,13 @@
package com.willfp.eco.core.fast; package com.willfp.eco.core.fast;
import com.willfp.eco.core.Eco; import com.willfp.eco.core.Eco;
import net.kyori.adventure.text.Component;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataHolder;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -16,7 +19,7 @@ import java.util.Set;
/** /**
* FastItemStack contains methods to modify and read items faster than in default bukkit. * FastItemStack contains methods to modify and read items faster than in default bukkit.
*/ */
public interface FastItemStack { public interface FastItemStack extends PersistentDataHolder {
/** /**
* Get all enchantments on an item. * Get all enchantments on an item.
* *
@@ -45,17 +48,54 @@ public interface FastItemStack {
* @param checkStored If stored enchantments should be accounted for. * @param checkStored If stored enchantments should be accounted for.
* @return A map of all enchantments. * @return A map of all enchantments.
*/ */
@NotNull
Map<Enchantment, Integer> getEnchants(boolean checkStored); Map<Enchantment, Integer> getEnchants(boolean checkStored);
/**
* Get the level of an enchantment on an item.
*
* @param enchantment The enchantment.
* @return The enchantment level, or 0 if not found.
* @deprecated Poorly named method. Use getEnchantmentLevel instead.
*/
@Deprecated(since = "6.34.0", forRemoval = true)
default int getLevelOnItem(@NotNull Enchantment enchantment) {
return getEnchantmentLevel(enchantment, false);
}
/** /**
* Get the level of an enchantment on an item. * Get the level of an enchantment on an item.
* *
* @param enchantment The enchantment. * @param enchantment The enchantment.
* @param checkStored If the stored NBT should also be checked. * @param checkStored If the stored NBT should also be checked.
* @return The enchantment level, or 0 if not found. * @return The enchantment level, or 0 if not found.
* @deprecated Poorly named method. Use getEnchantmentLevel instead.
*/ */
int getLevelOnItem(@NotNull Enchantment enchantment, @Deprecated(since = "6.34.0", forRemoval = true)
boolean checkStored); default int getLevelOnItem(@NotNull Enchantment enchantment,
boolean checkStored) {
return getEnchantmentLevel(enchantment, checkStored);
}
/**
* Get the level of an enchantment.
*
* @param enchantment The enchantment.
* @return The enchantment level, or 0 if not found.
*/
default int getEnchantmentLevel(@NotNull Enchantment enchantment) {
return getLevelOnItem(enchantment, false);
}
/**
* Get the level of an enchantment.
*
* @param enchantment The enchantment.
* @param checkStored If the stored NBT should also be checked.
* @return The enchantment level, or 0 if not found.
*/
int getEnchantmentLevel(@NotNull Enchantment enchantment,
boolean checkStored);
/** /**
* Set the item lore. * Set the item lore.
@@ -64,6 +104,13 @@ public interface FastItemStack {
*/ */
void setLore(@Nullable List<String> lore); void setLore(@Nullable List<String> lore);
/**
* Set the item lore.
*
* @param lore The lore.
*/
void setLoreComponents(@Nullable List<Component> lore);
/** /**
* Get the item lore. * Get the item lore.
* *
@@ -71,6 +118,40 @@ public interface FastItemStack {
*/ */
List<String> getLore(); List<String> getLore();
/**
* Get the item lore.
*
* @return The lore.
*/
List<Component> getLoreComponents();
/**
* Set the item name.
*
* @param name The name.
*/
void setDisplayName(@Nullable Component name);
/**
* Set the item name.
*
* @param name The name.
*/
void setDisplayName(@Nullable String name);
/**
* Get the item display name.
*
* @return The display name.
*/
Component getDisplayNameComponent();
/**
* Get the item display name.
*
* @return The display name.
*/
String getDisplayName();
/** /**
* Set the rework penalty. * Set the rework penalty.
@@ -81,7 +162,6 @@ public interface FastItemStack {
/** /**
* Get the rework penalty. * Get the rework penalty.
* .
* *
* @return The rework penalty found on the item. * @return The rework penalty found on the item.
*/ */
@@ -116,11 +196,28 @@ public interface FastItemStack {
*/ */
boolean hasItemFlag(@NotNull ItemFlag flag); boolean hasItemFlag(@NotNull ItemFlag flag);
/**
* Get the base NBT tag (Not PublicBukkitValues, the base) as a PersistentDataContainer.
* <p>
* The returned PersistentDataContainer will not modify the item until the tag is set.
*
* @return The base NBT tag.
*/
PersistentDataContainer getBaseTag();
/**
* Set the base NBT tag (Not PublicBukkitValues, the base) from a PersistentDataContainer.
*
* @param container The PersistentDataContainer.
*/
void setBaseTag(@Nullable PersistentDataContainer container);
/** /**
* Get the Bukkit ItemStack again. * Get the Bukkit ItemStack again.
* *
* @return The ItemStack. * @return The ItemStack.
*/ */
@NotNull
ItemStack unwrap(); ItemStack unwrap();
/** /**

View File

@@ -2,6 +2,7 @@ package com.willfp.eco.core.items;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache; import com.github.benmanes.caffeine.cache.LoadingCache;
import com.willfp.eco.core.fast.FastItemStack;
import com.willfp.eco.core.items.args.LookupArgParser; import com.willfp.eco.core.items.args.LookupArgParser;
import com.willfp.eco.core.items.provider.ItemProvider; import com.willfp.eco.core.items.provider.ItemProvider;
import com.willfp.eco.core.recipe.parts.EmptyTestableItem; import com.willfp.eco.core.recipe.parts.EmptyTestableItem;
@@ -16,6 +17,7 @@ import org.bukkit.NamespacedKey;
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.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -489,6 +491,32 @@ public final class Items {
return to; return to;
} }
/**
* Get the base NBT tag on an item.
*
* @param itemStack The ItemStack.
* @return The base NBT.
*/
@NotNull
public static PersistentDataContainer getBaseNBT(@NotNull final ItemStack itemStack) {
return FastItemStack.wrap(itemStack).getBaseTag();
}
/**
* Set the base NBT tag on an item.
*
* @param itemStack The ItemStack.
* @param container The base NBT tag.
* @return The ItemStack, modified. Not required to use, as this modifies the instance.¬
*/
@NotNull
public static ItemStack setBaseNBT(@NotNull final ItemStack itemStack,
@Nullable final PersistentDataContainer container) {
FastItemStack fis = FastItemStack.wrap(itemStack);
fis.setBaseTag(container);
return fis.unwrap();
}
private Items() { private Items() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
} }

View File

@@ -1,5 +1,6 @@
package com.willfp.eco.util; package com.willfp.eco.util;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache; import com.github.benmanes.caffeine.cache.LoadingCache;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@@ -76,33 +77,37 @@ public final class StringUtils {
.build(StringUtils::processFormatting); .build(StringUtils::processFormatting);
/** /**
* Json -> Legacy Cache. * Json -> Component Cache.
*/ */
private static final LoadingCache<String, String> JSON_TO_LEGACY = Caffeine.newBuilder() private static final Cache<String, Component> JSON_TO_COMPONENT = Caffeine.newBuilder()
.expireAfterAccess(10, TimeUnit.SECONDS) .expireAfterAccess(10, TimeUnit.SECONDS)
.build( .build();
json -> {
try {
Component component = GSON_COMPONENT_SERIALIZER.deserialize(json);
return LEGACY_COMPONENT_SERIALIZER.serialize(component);
} catch (JsonSyntaxException e) {
return json;
}
}
);
/** /**
* Legacy -> Json Cache. * Component -> Json Cache.
*/ */
private static final LoadingCache<String, String> LEGACY_TO_JSON = Caffeine.newBuilder() private static final Cache<Component, String> COMPONENT_TO_JSON = Caffeine.newBuilder()
.expireAfterAccess(10, TimeUnit.SECONDS) .expireAfterAccess(10, TimeUnit.SECONDS)
.build( .build();
legacy -> GSON_COMPONENT_SERIALIZER.serialize(
Component.empty().decoration(TextDecoration.ITALIC, false).append( /**
LEGACY_COMPONENT_SERIALIZER.deserialize(legacy) * Legacy -> Component Cache.
) */
) private static final Cache<String, Component> LEGACY_TO_COMPONENT = Caffeine.newBuilder()
); .expireAfterAccess(10, TimeUnit.SECONDS)
.build();
/**
* Component -> Legacy Cache.
*/
private static final Cache<Component, String> COMPONENT_TO_LEGACY = Caffeine.newBuilder()
.expireAfterAccess(10, TimeUnit.SECONDS)
.build();
/**
* Empty JSON.
*/
private static final String EMPTY_JSON = GSON_COMPONENT_SERIALIZER.serialize(Component.empty());
/** /**
* Color map. * Color map.
@@ -483,12 +488,7 @@ public final class StringUtils {
*/ */
@NotNull @NotNull
public static String legacyToJson(@Nullable final String legacy) { public static String legacyToJson(@Nullable final String legacy) {
String processed = legacy; return componentToJson(toComponent(legacy));
if (legacy == null) {
processed = "";
}
return LEGACY_TO_JSON.get(processed);
} }
/** /**
@@ -499,11 +499,53 @@ public final class StringUtils {
*/ */
@NotNull @NotNull
public static String jsonToLegacy(@Nullable final String json) { public static String jsonToLegacy(@Nullable final String json) {
if (json == null || json.isEmpty()) { return toLegacy(jsonToComponent(json));
return ""; }
/**
* Convert Component to JSON String.
*
* @param component The Component.
* @return The JSON string.
*/
@NotNull
public static String componentToJson(@Nullable final Component component) {
if (component == null) {
return EMPTY_JSON;
} }
return JSON_TO_LEGACY.get(json); return COMPONENT_TO_JSON.get(component, it -> {
try {
return GSON_COMPONENT_SERIALIZER.serialize(
Component.empty().decoration(TextDecoration.ITALIC, false).append(
it
)
);
} catch (JsonSyntaxException e) {
return GSON_COMPONENT_SERIALIZER.serialize(Component.empty());
}
});
}
/**
* Convert JSON String to Component.
*
* @param json The JSON String.
* @return The component.
*/
@NotNull
public static Component jsonToComponent(@Nullable final String json) {
if (json == null || json.isEmpty()) {
return Component.empty();
}
return JSON_TO_COMPONENT.get(json, it -> {
try {
return GSON_COMPONENT_SERIALIZER.deserialize(it);
} catch (JsonSyntaxException e) {
return Component.empty();
}
});
} }
/** /**
@@ -514,12 +556,7 @@ public final class StringUtils {
*/ */
@NotNull @NotNull
public static Component toComponent(@Nullable final String legacy) { public static Component toComponent(@Nullable final String legacy) {
String processed = legacy; return LEGACY_TO_COMPONENT.get(legacy == null ? "" : legacy, LEGACY_COMPONENT_SERIALIZER::deserialize);
if (legacy == null) {
processed = "";
}
return LEGACY_COMPONENT_SERIALIZER.deserialize(processed);
} }
/** /**
@@ -530,7 +567,7 @@ public final class StringUtils {
*/ */
@NotNull @NotNull
public static String toLegacy(@NotNull final Component component) { public static String toLegacy(@NotNull final Component component) {
return LEGACY_COMPONENT_SERIALIZER.serialize(component); return COMPONENT_TO_LEGACY.get(component, LEGACY_COMPONENT_SERIALIZER::serialize);
} }
/** /**

View File

@@ -4,6 +4,7 @@ package com.willfp.eco.core.items
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.ItemMeta import org.bukkit.inventory.meta.ItemMeta
import org.bukkit.persistence.PersistentDataContainer
/** /**
* @see Items.toLookupString * @see Items.toLookupString
@@ -22,3 +23,19 @@ fun ItemStack.mergeFrom(other: ItemStack): ItemStack =
*/ */
fun ItemMeta.mergeFrom(other: ItemMeta): ItemMeta = fun ItemMeta.mergeFrom(other: ItemMeta): ItemMeta =
Items.mergeFrom(other, this) Items.mergeFrom(other, this)
/**
* @see Items.getBaseNBT
* @see Items.setBaseNBT
*/
var ItemStack.baseNBT: PersistentDataContainer
get() = Items.getBaseNBT(this)
set(value) {
Items.setBaseNBT(this, value)
}
/**
* @see Items.setBaseNBT
*/
fun ItemStack.clearNBT() =
Items.setBaseNBT(this, null)

View File

@@ -11,12 +11,24 @@ import org.bukkit.entity.Player
fun String.toComponent(): Component = fun String.toComponent(): Component =
StringUtils.toComponent(this) StringUtils.toComponent(this)
/**
* @see StringUtils.jsonToComponent
*/
fun String.jsonToComponent(): Component =
StringUtils.jsonToComponent(this)
/** /**
* @see StringUtils.toLegacy * @see StringUtils.toLegacy
*/ */
fun Component.toLegacy(): String = fun Component.toLegacy(): String =
StringUtils.toLegacy(this) StringUtils.toLegacy(this)
/**
* @see StringUtils.componentToJson
*/
fun Component.toJSON(): String =
StringUtils.componentToJson(this)
/** /**
* @see StringUtils.format * @see StringUtils.format
*/ */

View File

@@ -4,12 +4,17 @@ import com.willfp.eco.core.entities.ai.EntityGoal
import com.willfp.eco.core.entities.ai.TargetGoal import com.willfp.eco.core.entities.ai.TargetGoal
import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
import com.willfp.eco.internal.spigot.proxy.common.ai.TargetGoalFactory import com.willfp.eco.internal.spigot.proxy.common.ai.TargetGoalFactory
import net.minecraft.core.Registry
import net.minecraft.nbt.CompoundTag
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.PathfinderMob import net.minecraft.world.entity.PathfinderMob
import net.minecraft.world.item.Item
import org.bukkit.Material
import org.bukkit.NamespacedKey import org.bukkit.NamespacedKey
import org.bukkit.entity.Mob import org.bukkit.entity.Mob
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataContainer
private lateinit var impl: CommonsProvider private lateinit var impl: CommonsProvider
@@ -39,9 +44,27 @@ fun <T : EntityGoal<*>> T.getVersionSpecificEntityGoalFactory(): EntityGoalFacto
fun <T : TargetGoal<*>> T.getVersionSpecificEntityGoalFactory(): TargetGoalFactory<T>? = fun <T : TargetGoal<*>> T.getVersionSpecificEntityGoalFactory(): TargetGoalFactory<T>? =
impl.getVersionSpecificTargetGoalFactory(this) impl.getVersionSpecificTargetGoalFactory(this)
private val MATERIAL_TO_ITEM = mutableMapOf<Material, Item>()
fun Material.toItem(): Item =
MATERIAL_TO_ITEM.getOrPut(this) {
Registry.ITEM.getOptional(this.key.toResourceLocation())
.orElseThrow { IllegalArgumentException("Material is not item!") }
}
fun CompoundTag.makePdc(base: Boolean = false): PersistentDataContainer =
impl.makePdc(this, base)
fun CompoundTag.setPdc(pdc: PersistentDataContainer?, item: net.minecraft.world.item.ItemStack? = null) =
impl.setPdc(this, pdc, item)
interface CommonsProvider { interface CommonsProvider {
val nbtTagString: Int val nbtTagString: Int
fun makePdc(tag: CompoundTag, base: Boolean): PersistentDataContainer
fun setPdc(tag: CompoundTag, pdc: PersistentDataContainer?, item: net.minecraft.world.item.ItemStack? = null)
fun toPathfinderMob(mob: Mob): PathfinderMob? fun toPathfinderMob(mob: Mob): PathfinderMob?
fun toResourceLocation(namespacedKey: NamespacedKey): ResourceLocation fun toResourceLocation(namespacedKey: NamespacedKey): ResourceLocation

View File

@@ -10,9 +10,6 @@ import net.minecraft.world.entity.PathfinderMob
import net.minecraft.world.entity.ai.goal.Goal import net.minecraft.world.entity.ai.goal.Goal
import net.minecraft.world.entity.ai.goal.TemptGoal import net.minecraft.world.entity.ai.goal.TemptGoal
import net.minecraft.world.entity.ai.targeting.TargetingConditions import net.minecraft.world.entity.ai.targeting.TargetingConditions
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity
import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory
import org.bukkit.event.entity.EntityTargetEvent
import java.util.EnumSet import java.util.EnumSet
import kotlin.math.abs import kotlin.math.abs
@@ -57,19 +54,6 @@ class EnhancedTemptGoal(
false false
} else { } else {
player = mob.level.getNearestPlayer(targetingConditions, mob as LivingEntity) player = mob.level.getNearestPlayer(targetingConditions, mob as LivingEntity)
// CraftBukkit start
if (player != null) {
val event = CraftEventFactory.callEntityTargetLivingEvent(
mob,
player,
EntityTargetEvent.TargetReason.TEMPT
)
if (event.isCancelled) {
return false
}
player = if (event.target == null) null else (event.target as CraftLivingEntity?)!!.handle
}
// CraftBukkit end
player != null player != null
} }
} }

View File

@@ -5,7 +5,6 @@ import net.minecraft.world.entity.EntityType
import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.ai.goal.Goal import net.minecraft.world.entity.ai.goal.Goal
import net.minecraft.world.entity.monster.SpellcasterIllager import net.minecraft.world.entity.monster.SpellcasterIllager
import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
class DelegatedSpellcaster(private val handle: SpellcasterIllager) : SpellcasterIllager( class DelegatedSpellcaster(private val handle: SpellcasterIllager) : SpellcasterIllager(
@@ -66,15 +65,6 @@ abstract class OpenUseSpellGoal(
override fun tick() { override fun tick() {
--attackWarmupDelay --attackWarmupDelay
if (attackWarmupDelay == 0) { if (attackWarmupDelay == 0) {
// CraftBukkit start
if (!CraftEventFactory.handleEntitySpellCastEvent(
handle,
spell
)
) {
return
}
// CraftBukkit end
performSpellCasting() performSpellCasting()
handle.playSound(openHandle.openCastingSoundEvent, 1.0f, 1.0f) handle.playSound(openHandle.openCastingSoundEvent, 1.0f, 1.0f)
} }

View File

@@ -3,25 +3,34 @@ package com.willfp.eco.internal.spigot.proxy.common.fast
import com.willfp.eco.core.fast.FastItemStack import com.willfp.eco.core.fast.FastItemStack
import com.willfp.eco.internal.spigot.proxy.common.NBT_TAG_STRING import com.willfp.eco.internal.spigot.proxy.common.NBT_TAG_STRING
import com.willfp.eco.internal.spigot.proxy.common.asNMSStack import com.willfp.eco.internal.spigot.proxy.common.asNMSStack
import com.willfp.eco.internal.spigot.proxy.common.makePdc
import com.willfp.eco.internal.spigot.proxy.common.mergeIfNeeded import com.willfp.eco.internal.spigot.proxy.common.mergeIfNeeded
import com.willfp.eco.internal.spigot.proxy.common.setPdc
import com.willfp.eco.internal.spigot.proxy.common.toItem
import com.willfp.eco.util.NamespacedKeyUtils import com.willfp.eco.util.NamespacedKeyUtils
import com.willfp.eco.util.StringUtils import com.willfp.eco.util.StringUtils
import com.willfp.eco.util.toComponent
import com.willfp.eco.util.toLegacy
import net.kyori.adventure.text.Component
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.ListTag import net.minecraft.nbt.ListTag
import net.minecraft.nbt.StringTag import net.minecraft.nbt.StringTag
import net.minecraft.world.item.EnchantedBookItem import net.minecraft.world.item.EnchantedBookItem
import net.minecraft.world.item.Item import net.minecraft.world.item.Item
import net.minecraft.world.item.Items import net.minecraft.world.item.Items
import org.bukkit.NamespacedKey
import org.bukkit.enchantments.Enchantment import org.bukkit.enchantments.Enchantment
import org.bukkit.inventory.ItemFlag import org.bukkit.inventory.ItemFlag
import org.bukkit.persistence.PersistentDataContainer
import org.bukkit.persistence.PersistentDataType
import kotlin.experimental.and import kotlin.experimental.and
@Suppress("UsePropertyAccessSyntax") @Suppress("UsePropertyAccessSyntax")
class EcoFastItemStack( class EcoFastItemStack(
private val bukkit: org.bukkit.inventory.ItemStack private val bukkit: org.bukkit.inventory.ItemStack
) : FastItemStack { ) : FastItemStack {
private var loreCache: List<String>? = null
private val handle = bukkit.asNMSStack() private val handle = bukkit.asNMSStack()
private val pdc = (if (handle.hasTag()) handle.getTag()!! else CompoundTag()).makePdc()
override fun getEnchants(checkStored: Boolean): Map<Enchantment, Int> { override fun getEnchants(checkStored: Boolean): Map<Enchantment, Int> {
val enchantmentNBT = val enchantmentNBT =
@@ -41,7 +50,7 @@ class EcoFastItemStack(
return foundEnchantments return foundEnchantments
} }
override fun getLevelOnItem( override fun getEnchantmentLevel(
enchantment: Enchantment, enchantment: Enchantment,
checkStored: Boolean checkStored: Boolean
): Int { ): Int {
@@ -60,13 +69,14 @@ class EcoFastItemStack(
return 0 return 0
} }
override fun setLore(lore: List<String>?) { override fun setLore(lore: List<String>?) = setLoreComponents(lore?.map { it.toComponent() })
loreCache = null
val jsonLore: MutableList<String> = ArrayList() override fun setLoreComponents(lore: List<Component>?) {
val jsonLore = mutableListOf<String>()
if (lore != null) { if (lore != null) {
for (s in lore) { for (s in lore) {
jsonLore.add(StringUtils.legacyToJson(s)) jsonLore.add(StringUtils.componentToJson(s))
} }
} }
@@ -87,17 +97,7 @@ class EcoFastItemStack(
apply() apply()
} }
override fun getLore(): List<String> { override fun getLoreComponents(): List<Component> {
if (loreCache != null) {
return loreCache!!
}
val lore = this.getLoreJSON().map { StringUtils.jsonToLegacy(it) }
loreCache = lore
return lore
}
private fun getLoreJSON(): List<String> {
val displayTag = handle.getTagElement("display") ?: return emptyList() val displayTag = handle.getTagElement("display") ?: return emptyList()
if (!displayTag.contains("Lore")) { if (!displayTag.contains("Lore")) {
@@ -105,15 +105,47 @@ class EcoFastItemStack(
} }
val loreTag = displayTag.getList("Lore", NBT_TAG_STRING) val loreTag = displayTag.getList("Lore", NBT_TAG_STRING)
val lore = ArrayList<String>(loreTag.size) val jsonLore = mutableListOf<String>()
for (i in loreTag.indices) { for (i in loreTag.indices) {
lore.add(loreTag.getString(i)) jsonLore.add(loreTag.getString(i))
} }
return lore return jsonLore.map { StringUtils.jsonToComponent(it) }
} }
override fun getLore(): List<String> =
getLoreComponents().map { StringUtils.toLegacy(it) }
override fun setDisplayName(name: Component?) {
val displayTag = handle.getOrCreateTagElement("display")
displayTag.remove("Name")
if (name != null) {
displayTag.put("Name", StringTag.valueOf(StringUtils.componentToJson(name)))
}
apply()
}
override fun setDisplayName(name: String?) = setDisplayName(name?.toComponent())
override fun getDisplayNameComponent(): Component {
val displayTag =
handle.getTagElement("display") ?: return Component.translatable(bukkit.type.toItem().getDescriptionId())
if (!displayTag.contains("Name")) {
return Component.translatable(bukkit.type.toItem().getDescriptionId())
}
val nameTag = displayTag.getString("Name")
return StringUtils.jsonToComponent(nameTag)
}
override fun getDisplayName(): String = displayNameComponent.toLegacy()
override fun addItemFlags(vararg hideFlags: ItemFlag) { override fun addItemFlags(vararg hideFlags: ItemFlag) {
for (flag in hideFlags) { for (flag in hideFlags) {
this.flagBits = this.flagBits or getBitModifier(flag) this.flagBits = this.flagBits or getBitModifier(flag)
@@ -151,6 +183,14 @@ class EcoFastItemStack(
return this.flagBits and bitModifier == bitModifier return this.flagBits and bitModifier == bitModifier
} }
override fun getBaseTag(): PersistentDataContainer =
(if (handle.hasTag()) handle.getTag()!! else CompoundTag()).makePdc(base = true)
override fun setBaseTag(container: PersistentDataContainer?) {
(if (handle.hasTag()) handle.getTag()!! else CompoundTag()).setPdc(container, item = handle)
apply()
}
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION") @Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
private var flagBits: Int private var flagBits: Int
get() = get() =
@@ -170,6 +210,10 @@ class EcoFastItemStack(
handle.setRepairCost(cost) handle.setRepairCost(cost)
} }
override fun getPersistentDataContainer(): PersistentDataContainer {
return ContinuallyAppliedPersistentDataContainer(this.pdc, this)
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (other !is EcoFastItemStack) { if (other !is EcoFastItemStack) {
return false return false
@@ -183,7 +227,11 @@ class EcoFastItemStack(
return handle.getTag()?.hashCode() ?: (0b00010101 * 31 + Item.getId(handle.getItem())) return handle.getTag()?.hashCode() ?: (0b00010101 * 31 + Item.getId(handle.getItem()))
} }
private fun apply() { internal fun apply() {
if (handle.hasTag()) {
handle.getTag()?.setPdc(this.pdc)
}
bukkit.mergeIfNeeded(handle) bukkit.mergeIfNeeded(handle)
} }
@@ -195,3 +243,18 @@ class EcoFastItemStack(
return bukkit return bukkit
} }
} }
private class ContinuallyAppliedPersistentDataContainer(
val handle: PersistentDataContainer,
val fis: EcoFastItemStack
) : PersistentDataContainer by handle {
override fun <T : Any, Z : Any> set(key: NamespacedKey, type: PersistentDataType<T, Z>, value: Z) {
handle.set(key, type, value)
fis.apply()
}
override fun remove(key: NamespacedKey) {
handle.remove(key)
fis.apply()
}
}

View File

@@ -2,6 +2,8 @@ package com.willfp.eco.internal.spigot.proxy.v1_17_R1
import com.willfp.eco.internal.spigot.proxy.CommonsInitializerProxy import com.willfp.eco.internal.spigot.proxy.CommonsInitializerProxy
import com.willfp.eco.internal.spigot.proxy.common.CommonsProvider import com.willfp.eco.internal.spigot.proxy.common.CommonsProvider
import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.Tag
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.world.entity.PathfinderMob import net.minecraft.world.entity.PathfinderMob
import org.bukkit.Bukkit import org.bukkit.Bukkit
@@ -10,11 +12,14 @@ import org.bukkit.craftbukkit.v1_17_R1.CraftServer
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftMob import org.bukkit.craftbukkit.v1_17_R1.entity.CraftMob
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.persistence.CraftPersistentDataContainer
import org.bukkit.craftbukkit.v1_17_R1.persistence.CraftPersistentDataTypeRegistry
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.craftbukkit.v1_17_R1.util.CraftNamespacedKey
import org.bukkit.entity.LivingEntity import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Mob import org.bukkit.entity.Mob
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataContainer
import java.lang.reflect.Field import java.lang.reflect.Field
class CommonsInitializer : CommonsInitializerProxy { class CommonsInitializer : CommonsInitializerProxy {
@@ -27,6 +32,11 @@ class CommonsInitializer : CommonsInitializerProxy {
isAccessible = true isAccessible = true
} }
private val pdcRegsitry = Class.forName("org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMetaItem")
.getDeclaredField("DATA_TYPE_REGISTRY")
.apply { isAccessible = true }
.get(null) as CraftPersistentDataTypeRegistry
override val nbtTagString = CraftMagicNumbers.NBT.TAG_STRING override val nbtTagString = CraftMagicNumbers.NBT.TAG_STRING
override fun toPathfinderMob(mob: Mob): PathfinderMob? { override fun toPathfinderMob(mob: Mob): PathfinderMob? {
@@ -57,5 +67,66 @@ class CommonsInitializer : CommonsInitializerProxy {
override fun toBukkitEntity(entity: net.minecraft.world.entity.LivingEntity): LivingEntity? = override fun toBukkitEntity(entity: net.minecraft.world.entity.LivingEntity): LivingEntity? =
CraftEntity.getEntity(Bukkit.getServer() as CraftServer, entity) as? LivingEntity CraftEntity.getEntity(Bukkit.getServer() as CraftServer, entity) as? LivingEntity
override fun makePdc(tag: CompoundTag, base: Boolean): PersistentDataContainer {
fun emptyPdc(): CraftPersistentDataContainer = CraftPersistentDataContainer(pdcRegsitry)
fun CompoundTag?.toPdc(): PersistentDataContainer {
val pdc = emptyPdc()
this ?: return pdc
val keys = this.allKeys
for (key in keys) {
pdc.put(key, this[key])
}
return pdc
}
return if (base) {
tag.toPdc()
} else {
if (tag.contains("PublicBukkitValues")) {
tag.getCompound("PublicBukkitValues").toPdc()
} else {
emptyPdc()
}
}
}
override fun setPdc(
tag: CompoundTag,
pdc: PersistentDataContainer?,
item: net.minecraft.world.item.ItemStack?
) {
fun CraftPersistentDataContainer.toTag(): CompoundTag {
val compound = CompoundTag()
val rawPublicMap: Map<String, Tag> = this.raw
for ((key, value) in rawPublicMap) {
compound.put(key, value)
}
return compound
}
pdc as CraftPersistentDataContainer?
if (item != null) {
if (pdc != null && !pdc.isEmpty) {
for (key in tag.allKeys.toSet()) {
tag.remove(key)
}
tag.merge(pdc.toTag())
} else {
item.setTag(null)
}
} else {
if (pdc != null && !pdc.isEmpty) {
tag.put("PublicBukkitValues", pdc.toTag())
} else {
tag.remove("PublicBukkitValues")
}
}
}
} }
} }

View File

@@ -39,6 +39,6 @@ class Skull : SkullProxy {
val profile = profile[meta] as GameProfile? ?: return null val profile = profile[meta] as GameProfile? ?: return null
val properties = profile.properties ?: return null val properties = profile.properties ?: return null
val prop = properties["textures"] ?: return null val prop = properties["textures"] ?: return null
return prop.toMutableList().firstOrNull()?.name return prop.toMutableList().firstOrNull()?.value
} }
} }

View File

@@ -2,6 +2,8 @@ package com.willfp.eco.internal.spigot.proxy.v1_18_R1
import com.willfp.eco.internal.spigot.proxy.CommonsInitializerProxy import com.willfp.eco.internal.spigot.proxy.CommonsInitializerProxy
import com.willfp.eco.internal.spigot.proxy.common.CommonsProvider import com.willfp.eco.internal.spigot.proxy.common.CommonsProvider
import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.Tag
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.world.entity.PathfinderMob import net.minecraft.world.entity.PathfinderMob
import org.bukkit.Bukkit import org.bukkit.Bukkit
@@ -10,11 +12,14 @@ import org.bukkit.craftbukkit.v1_18_R1.CraftServer
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftMob import org.bukkit.craftbukkit.v1_18_R1.entity.CraftMob
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.persistence.CraftPersistentDataContainer
import org.bukkit.craftbukkit.v1_18_R1.persistence.CraftPersistentDataTypeRegistry
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.craftbukkit.v1_18_R1.util.CraftNamespacedKey
import org.bukkit.entity.LivingEntity import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Mob import org.bukkit.entity.Mob
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataContainer
import java.lang.reflect.Field import java.lang.reflect.Field
class CommonsInitializer : CommonsInitializerProxy { class CommonsInitializer : CommonsInitializerProxy {
@@ -27,6 +32,11 @@ class CommonsInitializer : CommonsInitializerProxy {
isAccessible = true isAccessible = true
} }
private val pdcRegsitry = Class.forName("org.bukkit.craftbukkit.v1_18_R1.inventory.CraftMetaItem")
.getDeclaredField("DATA_TYPE_REGISTRY")
.apply { isAccessible = true }
.get(null) as CraftPersistentDataTypeRegistry
override val nbtTagString = CraftMagicNumbers.NBT.TAG_STRING override val nbtTagString = CraftMagicNumbers.NBT.TAG_STRING
override fun toPathfinderMob(mob: Mob): PathfinderMob? { override fun toPathfinderMob(mob: Mob): PathfinderMob? {
@@ -57,5 +67,66 @@ class CommonsInitializer : CommonsInitializerProxy {
override fun toBukkitEntity(entity: net.minecraft.world.entity.LivingEntity): LivingEntity? = override fun toBukkitEntity(entity: net.minecraft.world.entity.LivingEntity): LivingEntity? =
CraftEntity.getEntity(Bukkit.getServer() as CraftServer, entity) as? LivingEntity CraftEntity.getEntity(Bukkit.getServer() as CraftServer, entity) as? LivingEntity
override fun makePdc(tag: CompoundTag, base: Boolean): PersistentDataContainer {
fun emptyPdc(): CraftPersistentDataContainer = CraftPersistentDataContainer(pdcRegsitry)
fun CompoundTag?.toPdc(): PersistentDataContainer {
val pdc = emptyPdc()
this ?: return pdc
val keys = this.allKeys
for (key in keys) {
pdc.put(key, this[key])
}
return pdc
}
return if (base) {
tag.toPdc()
} else {
if (tag.contains("PublicBukkitValues")) {
tag.getCompound("PublicBukkitValues").toPdc()
} else {
emptyPdc()
}
}
}
override fun setPdc(
tag: CompoundTag,
pdc: PersistentDataContainer?,
item: net.minecraft.world.item.ItemStack?
) {
fun CraftPersistentDataContainer.toTag(): CompoundTag {
val compound = CompoundTag()
val rawPublicMap: Map<String, Tag> = this.raw
for ((key, value) in rawPublicMap) {
compound.put(key, value)
}
return compound
}
pdc as CraftPersistentDataContainer?
if (item != null) {
if (pdc != null && !pdc.isEmpty) {
for (key in tag.allKeys.toSet()) {
tag.remove(key)
}
tag.merge(pdc.toTag())
} else {
item.setTag(null)
}
} else {
if (pdc != null && !pdc.isEmpty) {
tag.put("PublicBukkitValues", pdc.toTag())
} else {
tag.remove("PublicBukkitValues")
}
}
}
} }
} }

View File

@@ -39,6 +39,6 @@ class Skull : SkullProxy {
val profile = profile[meta] as GameProfile? ?: return null val profile = profile[meta] as GameProfile? ?: return null
val properties = profile.properties ?: return null val properties = profile.properties ?: return null
val prop = properties["textures"] ?: return null val prop = properties["textures"] ?: return null
return prop.toMutableList().firstOrNull()?.name return prop.toMutableList().firstOrNull()?.value
} }
} }

View File

@@ -2,6 +2,8 @@ package com.willfp.eco.internal.spigot.proxy.v1_18_R2
import com.willfp.eco.internal.spigot.proxy.CommonsInitializerProxy import com.willfp.eco.internal.spigot.proxy.CommonsInitializerProxy
import com.willfp.eco.internal.spigot.proxy.common.CommonsProvider import com.willfp.eco.internal.spigot.proxy.common.CommonsProvider
import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.Tag
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.world.entity.PathfinderMob import net.minecraft.world.entity.PathfinderMob
import org.bukkit.Bukkit import org.bukkit.Bukkit
@@ -10,11 +12,14 @@ import org.bukkit.craftbukkit.v1_18_R2.CraftServer
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftMob import org.bukkit.craftbukkit.v1_18_R2.entity.CraftMob
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataContainer
import org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataTypeRegistry
import org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers import org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers
import org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey import org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey
import org.bukkit.entity.LivingEntity import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Mob import org.bukkit.entity.Mob
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataContainer
import java.lang.reflect.Field import java.lang.reflect.Field
class CommonsInitializer : CommonsInitializerProxy { class CommonsInitializer : CommonsInitializerProxy {
@@ -27,6 +32,11 @@ class CommonsInitializer : CommonsInitializerProxy {
isAccessible = true isAccessible = true
} }
private val pdcRegsitry = Class.forName("org.bukkit.craftbukkit.v1_18_R2.inventory.CraftMetaItem")
.getDeclaredField("DATA_TYPE_REGISTRY")
.apply { isAccessible = true }
.get(null) as CraftPersistentDataTypeRegistry
override val nbtTagString = CraftMagicNumbers.NBT.TAG_STRING override val nbtTagString = CraftMagicNumbers.NBT.TAG_STRING
override fun toPathfinderMob(mob: Mob): PathfinderMob? { override fun toPathfinderMob(mob: Mob): PathfinderMob? {
@@ -57,5 +67,66 @@ class CommonsInitializer : CommonsInitializerProxy {
override fun toBukkitEntity(entity: net.minecraft.world.entity.LivingEntity): LivingEntity? = override fun toBukkitEntity(entity: net.minecraft.world.entity.LivingEntity): LivingEntity? =
CraftEntity.getEntity(Bukkit.getServer() as CraftServer, entity) as? LivingEntity CraftEntity.getEntity(Bukkit.getServer() as CraftServer, entity) as? LivingEntity
override fun makePdc(tag: CompoundTag, base: Boolean): PersistentDataContainer {
fun emptyPdc(): CraftPersistentDataContainer = CraftPersistentDataContainer(pdcRegsitry)
fun CompoundTag?.toPdc(): PersistentDataContainer {
val pdc = emptyPdc()
this ?: return pdc
val keys = this.allKeys
for (key in keys) {
pdc.put(key, this[key])
}
return pdc
}
return if (base) {
tag.toPdc()
} else {
if (tag.contains("PublicBukkitValues")) {
tag.getCompound("PublicBukkitValues").toPdc()
} else {
emptyPdc()
}
}
}
override fun setPdc(
tag: CompoundTag,
pdc: PersistentDataContainer?,
item: net.minecraft.world.item.ItemStack?
) {
fun CraftPersistentDataContainer.toTag(): CompoundTag {
val compound = CompoundTag()
val rawPublicMap: Map<String, Tag> = this.raw
for ((key, value) in rawPublicMap) {
compound.put(key, value)
}
return compound
}
pdc as CraftPersistentDataContainer?
if (item != null) {
if (pdc != null && !pdc.isEmpty) {
for (key in tag.allKeys.toSet()) {
tag.remove(key)
}
tag.merge(pdc.toTag())
} else {
item.setTag(null)
}
} else {
if (pdc != null && !pdc.isEmpty) {
tag.put("PublicBukkitValues", pdc.toTag())
} else {
tag.remove("PublicBukkitValues")
}
}
}
} }
} }

View File

@@ -39,6 +39,6 @@ class Skull : SkullProxy {
val profile = profile[meta] as GameProfile? ?: return null val profile = profile[meta] as GameProfile? ?: return null
val properties = profile.properties ?: return null val properties = profile.properties ?: return null
val prop = properties["textures"] ?: return null val prop = properties["textures"] ?: return null
return prop.toMutableList().firstOrNull()?.name return prop.toMutableList().firstOrNull()?.value
} }
} }

View File

@@ -40,8 +40,6 @@ dependencies {
compileOnly 'com.github.EssentialsX:Essentials:2.18.2' compileOnly 'com.github.EssentialsX:Essentials:2.18.2'
compileOnly 'com.bgsoftware:SuperiorSkyblockAPI:1.8.3' compileOnly 'com.bgsoftware:SuperiorSkyblockAPI:1.8.3'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7' compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
compileOnly 'world.bentobox:bentobox:1.17.3-SNAPSHOT'
compileOnly 'com.iridium:IridiumSkyblock:3.1.2'
compileOnly 'com.github.WhipDevelopment:CrashClaim:f9cd7d92eb' compileOnly 'com.github.WhipDevelopment:CrashClaim:f9cd7d92eb'
compileOnly 'com.wolfyscript.wolfyutilities:wolfyutilities:3.16.0.0' compileOnly 'com.wolfyscript.wolfyutilities:wolfyutilities:3.16.0.0'
compileOnly 'com.github.decentsoftware-eu:decentholograms:2.1.2' compileOnly 'com.github.decentsoftware-eu:decentholograms:2.1.2'
@@ -52,11 +50,9 @@ dependencies {
// CombatLogX V10 + NewbieHelper Expansion // CombatLogX V10 + NewbieHelper Expansion
compileOnly 'com.SirBlobman.combatlogx:CombatLogX-API:10.0.0.0-SNAPSHOT' compileOnly 'com.SirBlobman.combatlogx:CombatLogX-API:10.0.0.0-SNAPSHOT'
compileOnly 'com.SirBlobman.combatlogx.expansions:NewbieHelper:10.0.0.0-SNAPSHOT'
// CombatLogX V11 + NewbieHelper Expansion // CombatLogX V11 + NewbieHelper Expansion
compileOnly 'com.github.sirblobman.combatlogx:api:11.0.0.0-SNAPSHOT' compileOnly 'com.github.sirblobman.combatlogx:api:11.0.0.0-SNAPSHOT'
compileOnly 'com.github.sirblobman.combatlogx.expansion:newbie-helper:11.0.0.0-SNAPSHOT'
// LibsDisguises // LibsDisguises
compileOnly 'LibsDisguises:LibsDisguises:10.0.26' compileOnly 'LibsDisguises:LibsDisguises:10.0.26'

View File

@@ -45,6 +45,7 @@ class MySQLDataHandler(
private val serverHandler: ImplementedMySQLHandler private val serverHandler: ImplementedMySQLHandler
init { init {
val config = HikariConfig() val config = HikariConfig()
config.driverClassName = "com.mysql.cj.jdbc.Driver" config.driverClassName = "com.mysql.cj.jdbc.Driver"
config.username = plugin.configYml.getString("mysql.user") config.username = plugin.configYml.getString("mysql.user")

View File

@@ -13,7 +13,7 @@ class AntigriefIridiumSkyblock : AntigriefWrapper {
player: Player, player: Player,
block: Block block: Block
): Boolean { ): Boolean {
val api = IridiumSkyblockAPI.getInstance() ?: return true val api = IridiumSkyblockAPI.getInstance()
return api.getIslandPermission(api.getIslandViaLocation(block.location).orElse(null) ?: return true, api.getUser(player), PermissionType.BLOCK_BREAK) return api.getIslandPermission(api.getIslandViaLocation(block.location).orElse(null) ?: return true, api.getUser(player), PermissionType.BLOCK_BREAK)
} }
@@ -22,7 +22,7 @@ class AntigriefIridiumSkyblock : AntigriefWrapper {
player: Player, player: Player,
location: Location location: Location
): Boolean { ): Boolean {
val api = IridiumSkyblockAPI.getInstance() ?: return true val api = IridiumSkyblockAPI.getInstance()
return api.getIslandPermission(api.getIslandViaLocation(location).orElse(null) ?: return true, api.getUser(player), PermissionType.BLOCK_BREAK) return api.getIslandPermission(api.getIslandViaLocation(location).orElse(null) ?: return true, api.getUser(player), PermissionType.BLOCK_BREAK)
} }
@@ -31,7 +31,7 @@ class AntigriefIridiumSkyblock : AntigriefWrapper {
player: Player, player: Player,
block: Block block: Block
): Boolean { ): Boolean {
val api = IridiumSkyblockAPI.getInstance() ?: return true val api = IridiumSkyblockAPI.getInstance()
return api.getIslandPermission(api.getIslandViaLocation(block.location).orElse(null) ?: return true, api.getUser(player), PermissionType.BLOCK_PLACE) return api.getIslandPermission(api.getIslandViaLocation(block.location).orElse(null) ?: return true, api.getUser(player), PermissionType.BLOCK_PLACE)
} }
@@ -40,7 +40,7 @@ class AntigriefIridiumSkyblock : AntigriefWrapper {
player: Player, player: Player,
victim: LivingEntity victim: LivingEntity
): Boolean { ): Boolean {
val api = IridiumSkyblockAPI.getInstance() ?: return true val api = IridiumSkyblockAPI.getInstance()
return when (victim) { return when (victim) {
is Player -> api.getIslandViaLocation(victim.location).orElse(null) != null is Player -> api.getIslandViaLocation(victim.location).orElse(null) != null
@@ -49,7 +49,7 @@ class AntigriefIridiumSkyblock : AntigriefWrapper {
} }
override fun canPickupItem(player: Player, location: Location): Boolean { override fun canPickupItem(player: Player, location: Location): Boolean {
val api = IridiumSkyblockAPI.getInstance() ?: return true val api = IridiumSkyblockAPI.getInstance()
return api.getIslandPermission(api.getIslandViaLocation(location).orElse(null) ?: return true, api.getUser(player), PermissionType.PICKUP_ITEMS) return api.getIslandPermission(api.getIslandViaLocation(location).orElse(null) ?: return true, api.getUser(player), PermissionType.PICKUP_ITEMS)
} }

View File

@@ -1,3 +1,3 @@
version = 6.32.0 version = 6.34.0
plugin-name = eco plugin-name = eco
kotlin.code.style = official kotlin.code.style = official

BIN
lib/BentoBox-1.20.0.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.