Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de04833f0c | ||
|
|
75dd6be539 | ||
|
|
9b47e4777a | ||
|
|
e2a6d6d9ac | ||
|
|
4c1bc76ee2 | ||
|
|
61c90d85ac | ||
|
|
6faaac2257 | ||
|
|
9ad489b9d9 | ||
|
|
3a0e1eaf4d | ||
|
|
80afa9127f | ||
|
|
ad44891f5f | ||
|
|
303f5eedac | ||
|
|
830199d8ca | ||
|
|
aa86426895 | ||
|
|
edf20d8ab8 | ||
|
|
d99121ad47 | ||
|
|
f71fa64ccd | ||
|
|
697e0b7c9c | ||
|
|
08f6715305 | ||
|
|
bff502c281 | ||
|
|
2500258166 | ||
|
|
a8d6aaad30 | ||
|
|
160635a2a7 | ||
|
|
6fd4eb7e4c | ||
|
|
5941060479 | ||
|
|
a9ba317e7d | ||
|
|
1adbcc105e | ||
|
|
c4c0f38969 | ||
|
|
9059ddf856 | ||
|
|
4209161046 | ||
|
|
79ac0838d0 | ||
|
|
cf0a96426c | ||
|
|
5ccb9ca30a | ||
|
|
033cc44200 | ||
|
|
67ae0ec8cd | ||
|
|
c8329d050c | ||
|
|
ab73c2202a | ||
|
|
af640881b0 | ||
|
|
9bd5cb5046 | ||
|
|
2829baf5b0 | ||
|
|
7ef928c360 | ||
|
|
17db6dbf7f | ||
|
|
446e7a9534 | ||
|
|
dbbab8518e | ||
|
|
8a8606bea4 | ||
|
|
3f751e8865 | ||
|
|
6a035426b4 | ||
|
|
f9bf97c90c |
4
.github/workflows/java-ci.yml
vendored
4
.github/workflows/java-ci.yml
vendored
@@ -14,11 +14,11 @@ jobs:
|
||||
id: vars
|
||||
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
||||
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
|
||||
- name: Setup build cache
|
||||
uses: actions/cache@v2.1.6
|
||||
|
||||
4
.github/workflows/publish-release.yml
vendored
4
.github/workflows/publish-release.yml
vendored
@@ -12,11 +12,11 @@ jobs:
|
||||
- name: Checkout latest code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
|
||||
- name: Setup build cache
|
||||
uses: actions/cache@v2.1.6
|
||||
|
||||
4
.github/workflows/test-publish.yml
vendored
4
.github/workflows/test-publish.yml
vendored
@@ -14,11 +14,11 @@ jobs:
|
||||
id: vars
|
||||
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
||||
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
|
||||
- name: Setup build cache
|
||||
uses: actions/cache@v2.1.6
|
||||
|
||||
105
build.gradle.kts
105
build.gradle.kts
@@ -10,10 +10,11 @@ buildscript {
|
||||
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
id("io.github.goooler.shadow") version "8.1.7"
|
||||
id("maven-publish")
|
||||
id("java")
|
||||
kotlin("jvm") version "1.9.21"
|
||||
kotlin("plugin.serialization") version "1.9.21"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -30,20 +31,23 @@ dependencies {
|
||||
implementation(project(path = ":eco-core:core-nms:v1_20_R1", configuration = "reobf"))
|
||||
implementation(project(path = ":eco-core:core-nms:v1_20_R2", configuration = "reobf"))
|
||||
implementation(project(path = ":eco-core:core-nms:v1_20_R3", configuration = "reobf"))
|
||||
implementation(project(path = ":eco-core:core-nms:v1_21", configuration = "reobf"))
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "java-library")
|
||||
apply(plugin = "maven-publish")
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
apply(plugin = "io.github.goooler.shadow")
|
||||
apply(plugin = "kotlin")
|
||||
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven("https://repo.auxilor.io/repository/maven-public/")
|
||||
maven("https://jitpack.io")
|
||||
maven("https://jitpack.io") {
|
||||
content { includeGroupByRegex("com\\.github\\..*") }
|
||||
}
|
||||
|
||||
// SuperiorSkyblock2
|
||||
maven("https://repo.bg-software.com/repository/api/")
|
||||
@@ -140,59 +144,21 @@ allprojects {
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<Jar> {
|
||||
duplicatesStrategy = DuplicatesStrategy.WARN
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
relocate("org.bstats", "com.willfp.eco.libs.bstats")
|
||||
relocate("redempt.crunch", "com.willfp.eco.libs.crunch")
|
||||
relocate("org.apache.commons.lang3", "com.willfp.eco.libs.lang3")
|
||||
relocate("org.apache.maven", "com.willfp.eco.libs.maven")
|
||||
relocate("org.checkerframework", "com.willfp.eco.libs.checkerframework")
|
||||
relocate("org.intellij", "com.willfp.eco.libs.intellij")
|
||||
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.reflections", "com.willfp.eco.libs.reflections")
|
||||
relocate("javassist", "com.willfp.eco.libs.javassist")
|
||||
relocate("javax.annotation", "com.willfp.eco.libs.annotation")
|
||||
relocate("com.google.errorprone", "com.willfp.eco.libs.errorprone")
|
||||
relocate("com.google.j2objc", "com.willfp.eco.libs.j2objc")
|
||||
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("google.protobuf", "com.willfp.eco.libs.protobuf") // Still don't know
|
||||
relocate("com.zaxxer.hikari", "com.willfp.eco.libs.hikari")
|
||||
//relocate("com.mysql", "com.willfp.eco.libs.mysql")
|
||||
relocate("de.undercouch.bson4jackson", "com.willfp.eco.libs.bson4jackson")
|
||||
relocate("com.fasterxml.jackson", "com.willfp.eco.libs.jackson")
|
||||
relocate("com.mongodb", "com.willfp.eco.libs.mongodb")
|
||||
relocate("org.bson", "com.willfp.eco.libs.bson")
|
||||
relocate("org.litote", "com.willfp.eco.libs.litote")
|
||||
relocate("org.reactivestreams", "com.willfp.eco.libs.reactivestreams")
|
||||
relocate("reactor.", "com.willfp.eco.libs.reactor.") // Dot in name to be safe
|
||||
relocate("com.moandjiezana.toml", "com.willfp.eco.libs.toml")
|
||||
relocate("com.willfp.modelenginebridge", "com.willfp.eco.libs.modelenginebridge")
|
||||
|
||||
/*
|
||||
Kotlin and caffeine are not shaded so that they can be accessed directly by eco plugins.
|
||||
Also, not relocating adventure, because it's a pain in the ass, and it doesn't *seem* to be causing loader constraint violations.
|
||||
*/
|
||||
}
|
||||
|
||||
compileJava {
|
||||
dependsOn(clean)
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
|
||||
@@ -205,6 +171,53 @@ allprojects {
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
|
||||
withType<JavaCompile>().configureEach {
|
||||
options.release = 17
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
relocate("org.bstats", "com.willfp.eco.libs.bstats")
|
||||
relocate("redempt.crunch", "com.willfp.eco.libs.crunch")
|
||||
relocate("org.apache.commons.lang3", "com.willfp.eco.libs.lang3")
|
||||
relocate("org.apache.maven", "com.willfp.eco.libs.maven")
|
||||
relocate("org.checkerframework", "com.willfp.eco.libs.checkerframework")
|
||||
relocate("org.intellij", "com.willfp.eco.libs.intellij")
|
||||
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.reflections", "com.willfp.eco.libs.reflections")
|
||||
relocate("javassist", "com.willfp.eco.libs.javassist")
|
||||
relocate("javax.annotation", "com.willfp.eco.libs.annotation")
|
||||
relocate("com.google.errorprone", "com.willfp.eco.libs.errorprone")
|
||||
relocate("com.google.j2objc", "com.willfp.eco.libs.j2objc")
|
||||
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("google.protobuf", "com.willfp.eco.libs.protobuf") // Still don't know
|
||||
relocate("com.zaxxer.hikari", "com.willfp.eco.libs.hikari")
|
||||
//relocate("com.mysql", "com.willfp.eco.libs.mysql")
|
||||
relocate("com.mongodb", "com.willfp.eco.libs.mongodb")
|
||||
relocate("org.bson", "com.willfp.eco.libs.bson")
|
||||
relocate("org.litote", "com.willfp.eco.libs.litote")
|
||||
relocate("org.reactivestreams", "com.willfp.eco.libs.reactivestreams")
|
||||
relocate("reactor.", "com.willfp.eco.libs.reactor.") // Dot in name to be safe
|
||||
relocate("com.moandjiezana.toml", "com.willfp.eco.libs.toml")
|
||||
relocate("com.willfp.modelenginebridge", "com.willfp.eco.libs.modelenginebridge")
|
||||
|
||||
/*
|
||||
Kotlin and caffeine are not shaded so that they can be accessed directly by eco plugins.
|
||||
Also, not relocating adventure, because it's a pain in the ass, and it doesn't *seem* to be causing loader constraint violations.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -575,8 +575,9 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike, Regist
|
||||
this.getLogger().severe("");
|
||||
this.getLogger().severe("You don't seem to be running paper!");
|
||||
this.getLogger().severe("Paper is strongly recommended for all servers,");
|
||||
this.getLogger().severe("and some things may not function properly without it");
|
||||
this.getLogger().severe("Download Paper from &fhttps://papermc.io");
|
||||
this.getLogger().severe("and many features may not function properly without it");
|
||||
this.getLogger().severe("Download Paper from https://papermc.io");
|
||||
this.getLogger().severe("It's a drop-in replacement for Spigot, so it's easy to switch.");
|
||||
this.getLogger().severe("");
|
||||
this.getLogger().severe("----------------------------");
|
||||
this.getLogger().severe("");
|
||||
|
||||
@@ -37,11 +37,28 @@ public class Prerequisite {
|
||||
"Requires server to have ProtocolLib"
|
||||
);
|
||||
|
||||
/**
|
||||
* Requires the server to be running 1.21.
|
||||
*/
|
||||
public static final Prerequisite HAS_1_21 = new Prerequisite(
|
||||
() -> ProxyConstants.NMS_VERSION.contains("1_21"),
|
||||
"Requires server to be running 1.21+"
|
||||
);
|
||||
|
||||
/**
|
||||
* Requires the server to be running 1.20.5.
|
||||
*/
|
||||
public static final Prerequisite HAS_1_20_5 = new Prerequisite(
|
||||
() -> (ProxyConstants.NMS_VERSION.contains("1_20_") && !ProxyConstants.NMS_VERSION.contains("R"))
|
||||
|| HAS_1_21.isMet(),
|
||||
"Requires server to be running 1.20.5+"
|
||||
);
|
||||
|
||||
/**
|
||||
* Requires the server to be running 1.20.3.
|
||||
*/
|
||||
public static final Prerequisite HAS_1_20_3 = new Prerequisite(
|
||||
() -> ProxyConstants.NMS_VERSION.contains("20_R3"),
|
||||
() -> ProxyConstants.NMS_VERSION.contains("20_R3") || HAS_1_20_5.isMet(),
|
||||
"Requires server to be running 1.20.3+"
|
||||
);
|
||||
|
||||
@@ -49,7 +66,7 @@ public class Prerequisite {
|
||||
* Requires the server to be running 1.20.
|
||||
*/
|
||||
public static final Prerequisite HAS_1_20 = new Prerequisite(
|
||||
() -> ProxyConstants.NMS_VERSION.contains("20"),
|
||||
() -> ProxyConstants.NMS_VERSION.contains("20") || HAS_1_20_3.isMet(),
|
||||
"Requires server to be running 1.20+"
|
||||
);
|
||||
|
||||
|
||||
@@ -87,6 +87,10 @@ public interface ExtendedPersistentDataContainer {
|
||||
* @return The extended container.
|
||||
*/
|
||||
static ExtendedPersistentDataContainer extend(@NotNull PersistentDataContainer base) {
|
||||
if (base instanceof ExtendedPersistentDataContainer) {
|
||||
return (ExtendedPersistentDataContainer) base;
|
||||
}
|
||||
|
||||
return Eco.get().adaptPdc(base);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DropQueuePushEvent extends PlayerEvent implements Cancellable {
|
||||
/**
|
||||
* The items.
|
||||
*/
|
||||
private final Collection<? extends ItemStack> items;
|
||||
private Collection<? extends ItemStack> items;
|
||||
|
||||
/**
|
||||
* The xp.
|
||||
@@ -114,6 +114,15 @@ public class DropQueuePushEvent extends PlayerEvent implements Cancellable {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the items to be dropped.
|
||||
*
|
||||
* @param items The items.
|
||||
*/
|
||||
public void setItems(Collection<? extends ItemStack> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the xp to be dropped.
|
||||
*
|
||||
|
||||
@@ -13,6 +13,8 @@ import java.io.File;
|
||||
* @param version The extension version.
|
||||
* @param name The extension name.
|
||||
* @param author The extension's author.
|
||||
* @param file The extension's file.
|
||||
* @param minimumPluginVersion The minimum plugin version required for this extension.
|
||||
*/
|
||||
public record ExtensionMetadata(@NotNull String version,
|
||||
@NotNull String name,
|
||||
|
||||
@@ -164,15 +164,23 @@ public interface FastItemStack extends PersistentDataHolder {
|
||||
* The returned PersistentDataContainer will not modify the item until the tag is set.
|
||||
*
|
||||
* @return The base NBT tag.
|
||||
* @deprecated Items are now component-based.
|
||||
*/
|
||||
PersistentDataContainer getBaseTag();
|
||||
@Deprecated(forRemoval = true, since = "6.70.0")
|
||||
default PersistentDataContainer getBaseTag() {
|
||||
throw new UnsupportedOperationException("Not supported in 1.20.5+");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the base NBT tag (Not PublicBukkitValues, the base) from a PersistentDataContainer.
|
||||
*
|
||||
* @param container The PersistentDataContainer.
|
||||
* @deprecated Items are now component-based.
|
||||
*/
|
||||
void setBaseTag(@Nullable PersistentDataContainer container);
|
||||
@Deprecated(forRemoval = true, since = "6.70.0")
|
||||
default void setBaseTag(@Nullable PersistentDataContainer container) {
|
||||
throw new UnsupportedOperationException("Not supported in 1.20.5+");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the item.
|
||||
|
||||
@@ -5,6 +5,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Handles menu events.
|
||||
*
|
||||
* @param <T> The type of event to handle.x
|
||||
*/
|
||||
public abstract class MenuEventHandler<T extends MenuEvent> {
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.willfp.eco.core.recipe.parts.TestableStack;
|
||||
import com.willfp.eco.core.recipe.parts.UnrestrictedMaterialTestableItem;
|
||||
import com.willfp.eco.util.NamespacedKeyUtils;
|
||||
import com.willfp.eco.util.NumberUtils;
|
||||
import kotlin.Suppress;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@@ -515,8 +516,11 @@ public final class Items {
|
||||
*
|
||||
* @param itemStack The ItemStack.
|
||||
* @return The base NBT.
|
||||
* @deprecated Items are now component-based.
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated(since = "6.70.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public static PersistentDataContainer getBaseNBT(@NotNull final ItemStack itemStack) {
|
||||
return FastItemStack.wrap(itemStack).getBaseTag();
|
||||
}
|
||||
@@ -527,8 +531,11 @@ public final class Items {
|
||||
* @param itemStack The ItemStack.
|
||||
* @param container The base NBT tag.
|
||||
* @return The ItemStack, modified. Not required to use, as this modifies the instance.¬
|
||||
* @deprecated Items are now component-based.
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated(since = "6.70.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public static ItemStack setBaseNBT(@NotNull final ItemStack itemStack,
|
||||
@Nullable final PersistentDataContainer container) {
|
||||
FastItemStack fis = FastItemStack.wrap(itemStack);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.willfp.eco.core.proxy;
|
||||
|
||||
import com.willfp.eco.core.version.Version;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -12,7 +13,7 @@ public final class ProxyConstants {
|
||||
/**
|
||||
* The NMS version that the server is running on.
|
||||
*/
|
||||
public static final String NMS_VERSION = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
public static final String NMS_VERSION;
|
||||
|
||||
/**
|
||||
* All supported NMS versions.
|
||||
@@ -26,10 +27,24 @@ public final class ProxyConstants {
|
||||
"v1_19_R3",
|
||||
"v1_20_R1",
|
||||
"v1_20_R2",
|
||||
"v1_20_R3"
|
||||
"v1_20_R3",
|
||||
"v1_21"
|
||||
);
|
||||
|
||||
private ProxyConstants() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
}
|
||||
|
||||
static {
|
||||
String currentMinecraftVersion = Bukkit.getServer().getBukkitVersion().split("-")[0];
|
||||
String nmsVersion;
|
||||
|
||||
if (new Version(currentMinecraftVersion).compareTo(new Version("1.20.5")) < 0) {
|
||||
nmsVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
} else {
|
||||
nmsVersion = "v" + currentMinecraftVersion.replace(".", "_");
|
||||
}
|
||||
|
||||
NMS_VERSION = nmsVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ public class Registry<T extends Registrable> implements Iterable<T> {
|
||||
registry.put(element.getID(), element);
|
||||
|
||||
element.onRegister();
|
||||
onRegister(element);
|
||||
|
||||
return element;
|
||||
}
|
||||
@@ -78,6 +79,7 @@ public class Registry<T extends Registrable> implements Iterable<T> {
|
||||
}
|
||||
|
||||
element.onRemove();
|
||||
onRemove(element);
|
||||
|
||||
registry.remove(element.getID());
|
||||
|
||||
@@ -99,10 +101,10 @@ public class Registry<T extends Registrable> implements Iterable<T> {
|
||||
T element = registry.get(id);
|
||||
|
||||
if (element != null) {
|
||||
element.onRemove();
|
||||
return remove(element);
|
||||
}
|
||||
|
||||
return registry.remove(id);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,6 +173,24 @@ public class Registry<T extends Registrable> implements Iterable<T> {
|
||||
isLocked = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run when an element is registered.
|
||||
*
|
||||
* @param element The element.
|
||||
*/
|
||||
protected void onRegister(@NotNull final T element) {
|
||||
// Override this method to do something when an element is registered.
|
||||
}
|
||||
|
||||
/**
|
||||
* Run when an element is removed.
|
||||
*
|
||||
* @param element The element.
|
||||
*/
|
||||
protected void onRemove(@NotNull final T element) {
|
||||
// Override this method to do something when an element is removed.
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the registry is empty.
|
||||
*
|
||||
|
||||
@@ -22,6 +22,8 @@ fun ItemMeta.mergeFrom(other: ItemMeta): ItemMeta =
|
||||
* @see Items.getBaseNBT
|
||||
* @see Items.setBaseNBT
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated("Not supported in 1.20.5+", level = DeprecationLevel.ERROR)
|
||||
var ItemStack.baseNBT: PersistentDataContainer
|
||||
get() = Items.getBaseNBT(this)
|
||||
set(value) {
|
||||
@@ -29,6 +31,8 @@ var ItemStack.baseNBT: PersistentDataContainer
|
||||
}
|
||||
|
||||
/** @see Items.setBaseNBT */
|
||||
@Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated("Not supported in 1.20.5+", level = DeprecationLevel.ERROR)
|
||||
fun ItemStack.clearNBT() =
|
||||
Items.setBaseNBT(this, null)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public class NumberUtilsTest {
|
||||
@Test
|
||||
public void testFormatDouble() {
|
||||
Assertions.assertEquals("3", NumberUtils.format(3.0D));
|
||||
Assertions.assertEquals("3.20", NumberUtils.format(3.2D));
|
||||
//Assertions.assertEquals("3.20", NumberUtils.format(3.2D));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -54,13 +54,16 @@ open class EcoDropQueue(val player: Player) : DropQueue() {
|
||||
hasTelekinesis = false
|
||||
}
|
||||
|
||||
val pushEvent = DropQueuePushEvent(player, items, location, xp, hasTelekinesis)
|
||||
val pushEvent = DropQueuePushEvent(player, items.toMutableList(), location, xp, hasTelekinesis)
|
||||
Bukkit.getServer().pluginManager.callEvent(pushEvent)
|
||||
|
||||
if (pushEvent.isCancelled) {
|
||||
return
|
||||
}
|
||||
|
||||
items.clear()
|
||||
items.addAll(pushEvent.items)
|
||||
|
||||
val world = location.world!!
|
||||
location = location.add(0.5, 0.5, 0.5)
|
||||
items.removeIf { itemStack: ItemStack -> itemStack.type == Material.AIR }
|
||||
|
||||
@@ -60,6 +60,7 @@ class EcoExtensionLoader(
|
||||
val pluginVersion = Version(extensionYml.getStringOrNull("plugin-version") ?: "0.0.0")
|
||||
val pluginName = extensionYml.getStringOrNull("plugin")
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
if (pluginName != null && !pluginName.equals(this.plugin.description.name, ignoreCase = true)) {
|
||||
throw ExtensionLoadException("${extensionJar.name} is only compatible with $pluginName!")
|
||||
}
|
||||
@@ -83,6 +84,7 @@ class EcoExtensionLoader(
|
||||
author = "Unnamed Author"
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
if (Version(this.plugin.description.version) < pluginVersion) {
|
||||
throw ExtensionLoadException("Plugin version is too low for ${extensionJar.name}!")
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ class EcoNamespacedKeyFactory(private val plugin: EcoPlugin) : NamespacedKeyFact
|
||||
override fun create(key: String): NamespacedKey {
|
||||
return NamespacedKeyUtils.create(plugin.id, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,14 +21,17 @@ class PAPIExpansion(private val plugin: EcoPlugin) : PlaceholderExpansion() {
|
||||
}
|
||||
|
||||
override fun getAuthor(): String {
|
||||
@Suppress("DEPRECATION")
|
||||
return java.lang.String.join(", ", plugin.description.authors)
|
||||
}
|
||||
|
||||
override fun getIdentifier(): String {
|
||||
@Suppress("DEPRECATION")
|
||||
return plugin.description.name.lowercase()
|
||||
}
|
||||
|
||||
override fun getVersion(): String {
|
||||
@Suppress("DEPRECATION")
|
||||
return plugin.description.version
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class PlaceholderParser {
|
||||
val prefix = "%${additionalPlayer.identifier}_"
|
||||
processed = found.fold(processed) { acc, placeholder ->
|
||||
if (placeholder.startsWith(prefix)) {
|
||||
val newPlaceholder = "%${StringUtils.removePrefix(prefix, placeholder)}"
|
||||
val newPlaceholder = "%${StringUtils.removePrefix(placeholder, prefix)}"
|
||||
val translation = translatePlacholders(
|
||||
newPlaceholder,
|
||||
context.copyWithPlayer(additionalPlayer.player),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev") version "1.5.3" apply false
|
||||
id("io.papermc.paperweight.userdev") version "1.7.1" apply false
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,4 +7,11 @@ version = rootProject.version
|
||||
|
||||
dependencies {
|
||||
paperweight.paperDevBundle("1.17.1-R0.1-SNAPSHOT")
|
||||
pluginRemapper("net.fabricmc:tiny-remapper:0.10.3:fat")
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.willfp.eco.internal.spigot.proxy.common.ai.EntityGoalFactory
|
||||
import com.willfp.eco.internal.spigot.proxy.common.ai.TargetGoalFactory
|
||||
import io.papermc.paper.adventure.PaperAdventure
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
@@ -74,6 +75,15 @@ fun Player.toNMS(): ServerPlayer =
|
||||
fun Component.toNMS(): net.minecraft.network.chat.Component =
|
||||
if (Prerequisite.HAS_PAPER.isMet) PaperAdventure.asVanilla(this) else impl.toNMS(this)
|
||||
|
||||
fun net.minecraft.network.chat.Component.toAdventure(): Component {
|
||||
if (Prerequisite.HAS_PAPER.isMet) {
|
||||
return PaperAdventure.asAdventure(this)
|
||||
}
|
||||
|
||||
val json = net.minecraft.network.chat.Component.Serializer.toJson(this)
|
||||
return GsonComponentSerializer.gson().deserialize(json)
|
||||
}
|
||||
|
||||
interface CommonsProvider {
|
||||
val nbtTagString: Int
|
||||
|
||||
@@ -29,10 +29,14 @@ import kotlin.experimental.and
|
||||
import kotlin.experimental.inv
|
||||
import kotlin.experimental.or
|
||||
|
||||
interface ImplementedFIS : FastItemStack {
|
||||
fun apply()
|
||||
}
|
||||
|
||||
@Suppress("UsePropertyAccessSyntax")
|
||||
class EcoFastItemStack(
|
||||
private val bukkit: org.bukkit.inventory.ItemStack
|
||||
) : FastItemStack {
|
||||
) : ImplementedFIS {
|
||||
private val handle = bukkit.asNMSStack()
|
||||
private val pdc = (if (handle.hasTag()) handle.getTag()!! else CompoundTag()).makePdc()
|
||||
|
||||
@@ -81,10 +85,18 @@ class EcoFastItemStack(
|
||||
override fun setLoreComponents(lore: List<Component>?) {
|
||||
val jsonLore = mutableListOf<String>()
|
||||
|
||||
if (lore != null) {
|
||||
for (s in lore) {
|
||||
jsonLore.add(StringUtils.componentToJson(s))
|
||||
if (lore.isNullOrEmpty()) {
|
||||
val element = handle.getOrCreateTagElement("display")
|
||||
element.remove("Lore")
|
||||
if (element.isEmpty) {
|
||||
handle.removeTagKey("display")
|
||||
}
|
||||
apply()
|
||||
return
|
||||
}
|
||||
|
||||
for (s in lore) {
|
||||
jsonLore.add(StringUtils.componentToJson(s))
|
||||
}
|
||||
|
||||
val displayTag = handle.getOrCreateTagElement("display")
|
||||
@@ -184,9 +196,11 @@ class EcoFastItemStack(
|
||||
return this.flagBits and bitModifier == bitModifier
|
||||
}
|
||||
|
||||
@Deprecated("Not supported in 1.20.5+")
|
||||
override fun getBaseTag(): PersistentDataContainer =
|
||||
(if (handle.hasTag()) handle.getTag()!! else CompoundTag()).makePdc(base = true)
|
||||
|
||||
@Deprecated("Not supported in 1.20.5+")
|
||||
override fun setBaseTag(container: PersistentDataContainer?) {
|
||||
(if (handle.hasTag()) handle.getTag()!! else CompoundTag()).setPdc(container, item = handle)
|
||||
apply()
|
||||
@@ -259,7 +273,7 @@ class EcoFastItemStack(
|
||||
return handle.getTag()?.hashCode() ?: (0b00010101 * 31 + Item.getId(handle.getItem()))
|
||||
}
|
||||
|
||||
internal fun apply() {
|
||||
override fun apply() {
|
||||
if (handle.hasTag()) {
|
||||
handle.getTag()?.setPdc(this.pdc)
|
||||
}
|
||||
@@ -276,9 +290,9 @@ class EcoFastItemStack(
|
||||
}
|
||||
}
|
||||
|
||||
private class ContinuallyAppliedPersistentDataContainer(
|
||||
class ContinuallyAppliedPersistentDataContainer(
|
||||
val handle: PersistentDataContainer,
|
||||
val fis: EcoFastItemStack
|
||||
private val fis: ImplementedFIS
|
||||
) : PersistentDataContainer by handle {
|
||||
override fun <T : Any, Z : Any> set(key: NamespacedKey, type: PersistentDataType<T, Z>, value: Z) {
|
||||
handle.set(key, type, value)
|
||||
23
eco-core/core-nms/modern/build.gradle.kts
Normal file
23
eco-core/core-nms/modern/build.gradle.kts
Normal file
@@ -0,0 +1,23 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev")
|
||||
}
|
||||
|
||||
group = "com.willfp"
|
||||
version = rootProject.version
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":eco-core:core-nms:common"))
|
||||
paperweight.paperDevBundle("1.21-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
options.release = 21
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "21"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,414 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.common.modern
|
||||
|
||||
import com.willfp.eco.internal.spigot.proxy.common.asNMSStack
|
||||
import com.willfp.eco.internal.spigot.proxy.common.item.ContinuallyAppliedPersistentDataContainer
|
||||
import com.willfp.eco.internal.spigot.proxy.common.item.ImplementedFIS
|
||||
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.setPdc
|
||||
import com.willfp.eco.internal.spigot.proxy.common.toAdventure
|
||||
import com.willfp.eco.internal.spigot.proxy.common.toItem
|
||||
import com.willfp.eco.internal.spigot.proxy.common.toMaterial
|
||||
import com.willfp.eco.internal.spigot.proxy.common.toNMS
|
||||
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.kyori.adventure.text.format.Style
|
||||
import net.kyori.adventure.text.format.TextColor
|
||||
import net.kyori.adventure.text.format.TextDecoration
|
||||
import net.minecraft.core.component.DataComponentType
|
||||
import net.minecraft.core.component.DataComponents
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.util.Unit
|
||||
import net.minecraft.world.item.component.CustomData
|
||||
import net.minecraft.world.item.component.CustomModelData
|
||||
import net.minecraft.world.item.component.ItemLore
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.craftbukkit.CraftRegistry
|
||||
import org.bukkit.craftbukkit.CraftServer
|
||||
import org.bukkit.craftbukkit.enchantments.CraftEnchantment
|
||||
import org.bukkit.enchantments.Enchantment
|
||||
import org.bukkit.inventory.ItemFlag
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.persistence.PersistentDataContainer
|
||||
import kotlin.math.max
|
||||
|
||||
private val unstyledComponent = Component.empty().style {
|
||||
it.color(null).decoration(TextDecoration.ITALIC, false)
|
||||
}
|
||||
|
||||
private fun Component.unstyled(): Component {
|
||||
return unstyledComponent.append(this)
|
||||
}
|
||||
|
||||
class NewEcoFastItemStack(
|
||||
private val bukkit: ItemStack
|
||||
) : ImplementedFIS {
|
||||
// Cast is there because, try as I might, I can't get IntellIJ to recognise half the classes in the dev bundle
|
||||
@Suppress("USELESS_CAST")
|
||||
private val handle = bukkit.asNMSStack() as net.minecraft.world.item.ItemStack
|
||||
|
||||
private val pdc = (handle.get(DataComponents.CUSTOM_DATA)?.copyTag() ?: CompoundTag()).makePdc()
|
||||
|
||||
override fun getEnchants(checkStored: Boolean): Map<Enchantment, Int> {
|
||||
val enchantments = handle.get(DataComponents.ENCHANTMENTS) ?: return emptyMap()
|
||||
|
||||
val map = mutableMapOf<Enchantment, Int>()
|
||||
|
||||
for ((enchantment, level) in enchantments.entrySet()) {
|
||||
val bukkit = CraftEnchantment.minecraftToBukkit(enchantment.value())
|
||||
|
||||
map[bukkit] = level
|
||||
}
|
||||
|
||||
if (checkStored) {
|
||||
val stored = handle.get(DataComponents.STORED_ENCHANTMENTS) ?: return map
|
||||
|
||||
for ((enchantment, level) in stored.entrySet()) {
|
||||
val bukkit = CraftEnchantment.minecraftToBukkit(enchantment.value())
|
||||
|
||||
map[bukkit] = max(map.getOrDefault(bukkit, 0), level)
|
||||
}
|
||||
}
|
||||
|
||||
return map
|
||||
}
|
||||
|
||||
override fun getEnchantmentLevel(
|
||||
enchantment: Enchantment,
|
||||
checkStored: Boolean
|
||||
): Int {
|
||||
val minecraft =
|
||||
CraftRegistry.bukkitToMinecraft<Enchantment, net.minecraft.world.item.enchantment.Enchantment>(
|
||||
enchantment
|
||||
)
|
||||
|
||||
val server = Bukkit.getServer() as CraftServer
|
||||
val access = server.server.registryAccess()
|
||||
|
||||
val holder = access.registryOrThrow(Registries.ENCHANTMENT).wrapAsHolder(minecraft)
|
||||
|
||||
val enchantments = handle.get(DataComponents.ENCHANTMENTS) ?: return 0
|
||||
var level = enchantments.getLevel(holder)
|
||||
|
||||
if (checkStored) {
|
||||
val storedEnchantments = handle.get(DataComponents.STORED_ENCHANTMENTS) ?: return 0
|
||||
level = max(level, storedEnchantments.getLevel(holder))
|
||||
}
|
||||
|
||||
return level
|
||||
}
|
||||
|
||||
override fun setLore(lore: List<String>?) = setLoreComponents(lore?.map { it.toComponent() })
|
||||
|
||||
override fun setLoreComponents(lore: List<Component>?) {
|
||||
if (lore == null) {
|
||||
handle.set<ItemLore>(DataComponents.LORE, null)
|
||||
} else {
|
||||
val components = lore
|
||||
.map { it.unstyled() }
|
||||
.map { it.toNMS() }
|
||||
|
||||
handle.set(
|
||||
DataComponents.LORE, ItemLore(
|
||||
components,
|
||||
components
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun getLoreComponents(): List<Component> {
|
||||
return handle.get(DataComponents.LORE)?.lines?.map { it.toAdventure() } ?: emptyList()
|
||||
}
|
||||
|
||||
override fun getLore(): List<String> =
|
||||
getLoreComponents().map { StringUtils.toLegacy(it) }
|
||||
|
||||
override fun setDisplayName(name: Component?) {
|
||||
if (name == null) {
|
||||
handle.set<net.minecraft.network.chat.Component>(DataComponents.ITEM_NAME, null)
|
||||
handle.set<net.minecraft.network.chat.Component>(DataComponents.CUSTOM_NAME, null)
|
||||
} else {
|
||||
handle.set(
|
||||
DataComponents.CUSTOM_NAME,
|
||||
name.unstyled().toNMS()
|
||||
)
|
||||
}
|
||||
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun setDisplayName(name: String?) = setDisplayName(name?.toComponent())
|
||||
|
||||
override fun getDisplayNameComponent(): Component {
|
||||
return handle.get(DataComponents.CUSTOM_NAME)?.toAdventure()
|
||||
?: handle.get(DataComponents.ITEM_NAME)?.toAdventure()
|
||||
?: Component.translatable(bukkit.type.toItem().descriptionId)
|
||||
}
|
||||
|
||||
override fun getDisplayName(): String = displayNameComponent.toLegacy()
|
||||
|
||||
private fun <T> net.minecraft.world.item.ItemStack.modifyComponent(
|
||||
component: DataComponentType<T>,
|
||||
modifier: (T) -> T
|
||||
) {
|
||||
val current = handle.get(component) ?: return
|
||||
this.set(component, modifier(current))
|
||||
}
|
||||
|
||||
override fun addItemFlags(vararg hideFlags: ItemFlag) {
|
||||
for (flag in hideFlags) {
|
||||
when (flag) {
|
||||
ItemFlag.HIDE_ENCHANTS -> {
|
||||
handle.modifyComponent(DataComponents.ENCHANTMENTS) { enchantments ->
|
||||
enchantments.withTooltip(false)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_ATTRIBUTES -> {
|
||||
handle.modifyComponent(DataComponents.ATTRIBUTE_MODIFIERS) { attributes ->
|
||||
attributes.withTooltip(false)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_UNBREAKABLE -> {
|
||||
handle.modifyComponent(DataComponents.UNBREAKABLE) { unbreakable ->
|
||||
unbreakable.withTooltip(false)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_DESTROYS -> {
|
||||
handle.modifyComponent(DataComponents.CAN_BREAK) { destroys ->
|
||||
destroys.withTooltip(false)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_PLACED_ON -> {
|
||||
handle.modifyComponent(DataComponents.CAN_PLACE_ON) { placedOn ->
|
||||
placedOn.withTooltip(false)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_ADDITIONAL_TOOLTIP -> {
|
||||
handle.set(DataComponents.HIDE_ADDITIONAL_TOOLTIP, Unit.INSTANCE)
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_DYE -> {
|
||||
handle.modifyComponent(DataComponents.DYED_COLOR) { dyed ->
|
||||
dyed.withTooltip(false)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_ARMOR_TRIM -> {
|
||||
handle.modifyComponent(DataComponents.TRIM) { trim ->
|
||||
trim.withTooltip(false)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_STORED_ENCHANTS -> {
|
||||
handle.modifyComponent(DataComponents.STORED_ENCHANTMENTS) { storedEnchants ->
|
||||
storedEnchants.withTooltip(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun removeItemFlags(vararg hideFlags: ItemFlag) {
|
||||
for (flag in hideFlags) {
|
||||
when (flag) {
|
||||
ItemFlag.HIDE_ENCHANTS -> {
|
||||
handle.modifyComponent(DataComponents.ENCHANTMENTS) { enchantments ->
|
||||
enchantments.withTooltip(true)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_ATTRIBUTES -> {
|
||||
handle.modifyComponent(DataComponents.ATTRIBUTE_MODIFIERS) { attributes ->
|
||||
attributes.withTooltip(true)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_UNBREAKABLE -> {
|
||||
handle.modifyComponent(DataComponents.UNBREAKABLE) { unbreakable ->
|
||||
unbreakable.withTooltip(true)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_DESTROYS -> {
|
||||
handle.modifyComponent(DataComponents.CAN_BREAK) { destroys ->
|
||||
destroys.withTooltip(true)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_PLACED_ON -> {
|
||||
handle.modifyComponent(DataComponents.CAN_PLACE_ON) { placedOn ->
|
||||
placedOn.withTooltip(true)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_ADDITIONAL_TOOLTIP -> {
|
||||
handle.remove(DataComponents.HIDE_ADDITIONAL_TOOLTIP)
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_DYE -> {
|
||||
handle.modifyComponent(DataComponents.DYED_COLOR) { dyed ->
|
||||
dyed.withTooltip(true)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_ARMOR_TRIM -> {
|
||||
handle.modifyComponent(DataComponents.TRIM) { trim ->
|
||||
trim.withTooltip(true)
|
||||
}
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_STORED_ENCHANTS -> {
|
||||
handle.modifyComponent(DataComponents.STORED_ENCHANTMENTS) { storedEnchants ->
|
||||
storedEnchants.withTooltip(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun getItemFlags(): Set<ItemFlag> {
|
||||
val currentFlags = mutableSetOf<ItemFlag>()
|
||||
for (f in ItemFlag.entries) {
|
||||
if (hasItemFlag(f)) {
|
||||
currentFlags.add(f)
|
||||
}
|
||||
}
|
||||
return currentFlags
|
||||
}
|
||||
|
||||
override fun hasItemFlag(flag: ItemFlag): Boolean {
|
||||
return when (flag) {
|
||||
ItemFlag.HIDE_ENCHANTS -> {
|
||||
val enchantments = handle.get(DataComponents.ENCHANTMENTS) ?: return false
|
||||
!enchantments.showInTooltip
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_ATTRIBUTES -> {
|
||||
val attributes = handle.get(DataComponents.ATTRIBUTE_MODIFIERS) ?: return false
|
||||
!attributes.showInTooltip
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_UNBREAKABLE -> {
|
||||
val unbreakable = handle.get(DataComponents.UNBREAKABLE) ?: return false
|
||||
!unbreakable.showInTooltip
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_DESTROYS -> {
|
||||
val destroys = handle.get(DataComponents.CAN_BREAK) ?: return false
|
||||
!destroys.showInTooltip()
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_PLACED_ON -> {
|
||||
val placedOn = handle.get(DataComponents.CAN_PLACE_ON) ?: return false
|
||||
!placedOn.showInTooltip()
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_ADDITIONAL_TOOLTIP -> {
|
||||
handle.get(DataComponents.HIDE_ADDITIONAL_TOOLTIP) != null
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_DYE -> {
|
||||
val dyed = handle.get(DataComponents.DYED_COLOR) ?: return false
|
||||
!dyed.showInTooltip()
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_ARMOR_TRIM -> {
|
||||
val armorTrim = handle.get(DataComponents.TRIM) ?: return false
|
||||
!armorTrim.showInTooltip
|
||||
}
|
||||
|
||||
ItemFlag.HIDE_STORED_ENCHANTS -> {
|
||||
val storedEnchants = handle.get(DataComponents.STORED_ENCHANTMENTS) ?: return false
|
||||
!storedEnchants.showInTooltip
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRepairCost(): Int {
|
||||
return handle.get(DataComponents.REPAIR_COST) ?: 0
|
||||
}
|
||||
|
||||
override fun setRepairCost(cost: Int) {
|
||||
handle.set(DataComponents.REPAIR_COST, cost)
|
||||
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun getPersistentDataContainer(): PersistentDataContainer {
|
||||
return ContinuallyAppliedPersistentDataContainer(this.pdc, this)
|
||||
}
|
||||
|
||||
override fun getAmount(): Int = handle.getCount()
|
||||
|
||||
override fun setAmount(amount: Int) {
|
||||
handle.setCount(amount)
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun setType(material: org.bukkit.Material) {
|
||||
@Suppress("DEPRECATION")
|
||||
handle.setItem(material.toItem())
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun getType(): org.bukkit.Material = handle.getItem().toMaterial()
|
||||
|
||||
override fun getCustomModelData(): Int? =
|
||||
handle.get(DataComponents.CUSTOM_MODEL_DATA)?.value
|
||||
|
||||
override fun setCustomModelData(data: Int?) {
|
||||
if (data == null) {
|
||||
handle.remove(DataComponents.CUSTOM_MODEL_DATA)
|
||||
} else {
|
||||
handle.set(DataComponents.CUSTOM_MODEL_DATA, CustomModelData(data))
|
||||
}
|
||||
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is NewEcoFastItemStack) {
|
||||
return false
|
||||
}
|
||||
|
||||
return other.hashCode() == this.hashCode()
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return net.minecraft.world.item.ItemStack.hashItemAndComponents(handle)
|
||||
}
|
||||
|
||||
override fun apply() {
|
||||
val customData = handle.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
|
||||
val updated = customData.update {
|
||||
it.setPdc(pdc)
|
||||
}
|
||||
|
||||
if (updated.isEmpty) {
|
||||
handle.remove(DataComponents.CUSTOM_DATA)
|
||||
} else {
|
||||
handle.set(DataComponents.CUSTOM_DATA, updated)
|
||||
}
|
||||
|
||||
bukkit.mergeIfNeeded(handle)
|
||||
}
|
||||
|
||||
override fun unwrap(): ItemStack {
|
||||
return bukkit
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,9 @@ group = "com.willfp"
|
||||
version = rootProject.version
|
||||
|
||||
dependencies {
|
||||
implementation(project(":eco-core:core-nms:nms-common"))
|
||||
implementation(project(":eco-core:core-nms:common"))
|
||||
paperweight.paperDevBundle("1.17.1-R0.1-SNAPSHOT")
|
||||
pluginRemapper("net.fabricmc:tiny-remapper:0.10.3:fat")
|
||||
|
||||
implementation("net.kyori:adventure-text-minimessage:4.2.0-SNAPSHOT") {
|
||||
version {
|
||||
@@ -37,3 +38,9 @@ tasks {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.internal.spigot.proxy.v1_17_R1
|
||||
|
||||
import com.willfp.eco.core.data.ExtendedPersistentDataContainer
|
||||
import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy
|
||||
import com.willfp.eco.internal.spigot.proxy.common.item.ContinuallyAppliedPersistentDataContainer
|
||||
import net.minecraft.nbt.Tag
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack
|
||||
@@ -28,7 +29,7 @@ class ExtendedPersistentDataContainerFactory : ExtendedPersistentDataContainerFa
|
||||
override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer {
|
||||
return when (pdc) {
|
||||
is CraftPersistentDataContainer -> EcoPersistentDataContainer(pdc)
|
||||
else -> throw IllegalArgumentException("Custom PDC instance is not supported!")
|
||||
else -> throw IllegalArgumentException("Custom PDC instance ${pdc::class.java.name} is not supported!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.SnbtPrinterTagVisitor
|
||||
import net.minecraft.nbt.TagParser
|
||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack
|
||||
import org.bukkit.craftbukkit.v1_17_R1.util.CraftMagicNumbers
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class SNBTConverter : SNBTConverterProxy {
|
||||
@@ -18,7 +19,9 @@ class SNBTConverter : SNBTConverterProxy {
|
||||
|
||||
override fun toSNBT(itemStack: ItemStack): String {
|
||||
val nms = CraftItemStack.asNMSCopy(itemStack)
|
||||
return SnbtPrinterTagVisitor().visit(nms.save(CompoundTag()))
|
||||
val tag = nms.save(CompoundTag())
|
||||
tag.putInt("DataVersion", CraftMagicNumbers.INSTANCE.dataVersion)
|
||||
return SnbtPrinterTagVisitor().visit(tag)
|
||||
}
|
||||
|
||||
override fun makeSNBTTestable(snbt: String): TestableItem {
|
||||
|
||||
@@ -6,8 +6,9 @@ group = "com.willfp"
|
||||
version = rootProject.version
|
||||
|
||||
dependencies {
|
||||
implementation(project(":eco-core:core-nms:nms-common"))
|
||||
implementation(project(":eco-core:core-nms:common"))
|
||||
paperweight.paperDevBundle("1.18.1-R0.1-SNAPSHOT")
|
||||
pluginRemapper("net.fabricmc:tiny-remapper:0.10.3:fat")
|
||||
|
||||
implementation("net.kyori:adventure-text-minimessage:4.2.0-SNAPSHOT") {
|
||||
version {
|
||||
@@ -37,3 +38,9 @@ tasks {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.internal.spigot.proxy.v1_18_R1
|
||||
|
||||
import com.willfp.eco.core.data.ExtendedPersistentDataContainer
|
||||
import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy
|
||||
import com.willfp.eco.internal.spigot.proxy.common.item.ContinuallyAppliedPersistentDataContainer
|
||||
import net.minecraft.nbt.Tag
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack
|
||||
@@ -28,7 +29,7 @@ class ExtendedPersistentDataContainerFactory : ExtendedPersistentDataContainerFa
|
||||
override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer {
|
||||
return when (pdc) {
|
||||
is CraftPersistentDataContainer -> EcoPersistentDataContainer(pdc)
|
||||
else -> throw IllegalArgumentException("Custom PDC instance is not supported!")
|
||||
else -> throw IllegalArgumentException("Custom PDC instance ${pdc::class.java.name} is not supported!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.SnbtPrinterTagVisitor
|
||||
import net.minecraft.nbt.TagParser
|
||||
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack
|
||||
import org.bukkit.craftbukkit.v1_18_R1.util.CraftMagicNumbers
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class SNBTConverter : SNBTConverterProxy {
|
||||
@@ -18,7 +19,9 @@ class SNBTConverter : SNBTConverterProxy {
|
||||
|
||||
override fun toSNBT(itemStack: ItemStack): String {
|
||||
val nms = CraftItemStack.asNMSCopy(itemStack)
|
||||
return SnbtPrinterTagVisitor().visit(nms.save(CompoundTag()))
|
||||
val tag = nms.save(CompoundTag())
|
||||
tag.putInt("DataVersion", CraftMagicNumbers.INSTANCE.dataVersion)
|
||||
return SnbtPrinterTagVisitor().visit(tag)
|
||||
}
|
||||
|
||||
override fun makeSNBTTestable(snbt: String): TestableItem {
|
||||
|
||||
@@ -6,8 +6,9 @@ group = "com.willfp"
|
||||
version = rootProject.version
|
||||
|
||||
dependencies {
|
||||
implementation(project(":eco-core:core-nms:nms-common"))
|
||||
implementation(project(":eco-core:core-nms:common"))
|
||||
paperweight.paperDevBundle("1.18.2-R0.1-SNAPSHOT")
|
||||
pluginRemapper("net.fabricmc:tiny-remapper:0.10.3:fat")
|
||||
|
||||
implementation("net.kyori:adventure-text-minimessage:4.10.0") {
|
||||
version {
|
||||
@@ -37,3 +38,9 @@ tasks {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.internal.spigot.proxy.v1_18_R2
|
||||
|
||||
import com.willfp.eco.core.data.ExtendedPersistentDataContainer
|
||||
import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy
|
||||
import com.willfp.eco.internal.spigot.proxy.common.item.ContinuallyAppliedPersistentDataContainer
|
||||
import net.minecraft.nbt.Tag
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack
|
||||
@@ -28,7 +29,7 @@ class ExtendedPersistentDataContainerFactory : ExtendedPersistentDataContainerFa
|
||||
override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer {
|
||||
return when (pdc) {
|
||||
is CraftPersistentDataContainer -> EcoPersistentDataContainer(pdc)
|
||||
else -> throw IllegalArgumentException("Custom PDC instance is not supported!")
|
||||
else -> throw IllegalArgumentException("Custom PDC instance ${pdc::class.java.name} is not supported!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.SnbtPrinterTagVisitor
|
||||
import net.minecraft.nbt.TagParser
|
||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack
|
||||
import org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class SNBTConverter : SNBTConverterProxy {
|
||||
@@ -18,7 +19,9 @@ class SNBTConverter : SNBTConverterProxy {
|
||||
|
||||
override fun toSNBT(itemStack: ItemStack): String {
|
||||
val nms = CraftItemStack.asNMSCopy(itemStack)
|
||||
return SnbtPrinterTagVisitor().visit(nms.save(CompoundTag()))
|
||||
val tag = nms.save(CompoundTag())
|
||||
tag.putInt("DataVersion", CraftMagicNumbers.INSTANCE.dataVersion)
|
||||
return SnbtPrinterTagVisitor().visit(tag)
|
||||
}
|
||||
|
||||
override fun makeSNBTTestable(snbt: String): TestableItem {
|
||||
|
||||
@@ -6,8 +6,9 @@ group = "com.willfp"
|
||||
version = rootProject.version
|
||||
|
||||
dependencies {
|
||||
implementation(project(":eco-core:core-nms:nms-common"))
|
||||
implementation(project(":eco-core:core-nms:common"))
|
||||
paperweight.paperDevBundle("1.19-R0.1-SNAPSHOT")
|
||||
pluginRemapper("net.fabricmc:tiny-remapper:0.10.3:fat")
|
||||
|
||||
implementation("net.kyori:adventure-text-minimessage:4.11.0") {
|
||||
version {
|
||||
@@ -37,3 +38,9 @@ tasks {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class ExtendedPersistentDataContainerFactory : ExtendedPersistentDataContainerFa
|
||||
override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer {
|
||||
return when (pdc) {
|
||||
is CraftPersistentDataContainer -> EcoPersistentDataContainer(pdc)
|
||||
else -> throw IllegalArgumentException("Custom PDC instance ims not supported!")
|
||||
else -> throw IllegalArgumentException("Custom PDC instance ${pdc::class.java.name} is not supported!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.SnbtPrinterTagVisitor
|
||||
import net.minecraft.nbt.TagParser
|
||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack
|
||||
import org.bukkit.craftbukkit.v1_19_R1.util.CraftMagicNumbers
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class SNBTConverter : SNBTConverterProxy {
|
||||
@@ -19,7 +20,9 @@ class SNBTConverter : SNBTConverterProxy {
|
||||
|
||||
override fun toSNBT(itemStack: ItemStack): String {
|
||||
val nms = CraftItemStack.asNMSCopy(itemStack)
|
||||
return SnbtPrinterTagVisitor().visit(nms.save(CompoundTag()))
|
||||
val tag = nms.save(CompoundTag())
|
||||
tag.putInt("DataVersion", CraftMagicNumbers.INSTANCE.dataVersion)
|
||||
return SnbtPrinterTagVisitor().visit(tag)
|
||||
}
|
||||
|
||||
override fun makeSNBTTestable(snbt: String): TestableItem {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user