9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-25 18:09:28 +00:00
This commit is contained in:
XiaoMoMi
2024-05-07 22:08:57 +08:00
parent 28cb26845b
commit e390976cb7
14 changed files with 204 additions and 63 deletions

View File

@@ -1,4 +1,17 @@
dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
implementation("com.flowpowered:flow-nbt:2.0.2")
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

View File

@@ -8,7 +8,7 @@ plugins {
allprojects {
project.group = "net.momirealms"
project.version = "3.4.7"
project.version = "3.4.8"
apply<JavaPlugin>()
apply(plugin = "java")
@@ -58,13 +58,10 @@ subprojects {
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}
tasks.shadowJar {
destinationDirectory.set(file("$rootDir/target"))
if (arrayListOf("plugin", "api").contains(project.name)) {
destinationDirectory.set(file("$rootDir/target"))
}
archiveClassifier.set("")
archiveFileName.set("CustomCrops-" + project.name + "-" + project.version + ".jar")
}
@@ -81,5 +78,4 @@ subprojects {
}
}
}
}
}

View File

@@ -1,3 +1,16 @@
dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

42
oraxen-j21/.gitignore vendored Normal file
View File

@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@@ -0,0 +1,18 @@
dependencies {
compileOnly(project(":api"))
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("io.th0rgal:oraxen:2.0-SNAPSHOT")
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

View File

@@ -24,14 +24,14 @@ import io.th0rgal.oraxen.api.events.custom_block.stringblock.OraxenStringBlockPl
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureBreakEvent;
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureInteractEvent;
import io.th0rgal.oraxen.api.events.furniture.OraxenFurniturePlaceEvent;
import net.momirealms.customcrops.api.manager.ItemManager;
import net.momirealms.customcrops.api.mechanic.item.custom.AbstractCustomListener;
import net.momirealms.customcrops.api.util.LocationUtils;
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
import org.bukkit.event.EventHandler;
public class OraxenListener extends AbstractCustomListener {
public OraxenListener(ItemManagerImpl itemManager) {
public OraxenListener(ItemManager itemManager) {
super(itemManager);
}

View File

@@ -1,5 +1,18 @@
dependencies {
compileOnly(project(":api"))
compileOnly("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("com.github.oraxen:oraxen:1.172.0")
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

View File

@@ -30,7 +30,6 @@ dependencies {
// Items
compileOnly("com.github.LoneDev6:api-itemsadder:3.6.2-beta-r3-b")
compileOnly("io.th0rgal:oraxen:2.0-SNAPSHOT")
compileOnly("pers.neige.neigeitems:NeigeItems:1.16.24")
compileOnly("net.Indyuce:MMOItems-API:6.9.2-SNAPSHOT")
compileOnly("io.lumine:MythicLib-dist:1.6-SNAPSHOT")
@@ -49,15 +48,16 @@ dependencies {
implementation(project(":api"))
implementation(project(":oraxen-legacy"))
implementation(project(":oraxen-j21"))
implementation(project(":legacy-api"))
compileOnly("net.kyori:adventure-api:4.16.0")
compileOnly("net.kyori:adventure-platform-bukkit:4.3.2")
compileOnly("com.github.Xiao-MoMi:AntiGriefLib:0.11")
compileOnly("com.github.Xiao-MoMi:BiomeAPI:0.3")
compileOnly("com.github.Xiao-MoMi:BiomeAPI:0.6")
compileOnly("net.kyori:adventure-text-minimessage:4.16.0")
compileOnly("net.kyori:adventure-text-serializer-legacy:4.16.0")
compileOnly("de.tr7zw:item-nbt-api:2.12.3")
compileOnly("de.tr7zw:item-nbt-api:2.12.4")
compileOnly("org.bstats:bstats-bukkit:3.0.2")
implementation("com.flowpowered:flow-nbt:2.0.2")
implementation("com.github.luben:zstd-jni:1.5.6-2")
@@ -74,4 +74,17 @@ tasks {
relocate ("net.momirealms.biomeapi", "net.momirealms.customcrops.libraries.biomeapi")
relocate ("net.momirealms.antigrieflib", "net.momirealms.customcrops.libraries.antigrieflib")
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

View File

@@ -17,8 +17,6 @@
package net.momirealms.customcrops;
import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion;
import de.tr7zw.changeme.nbtapi.utils.VersionChecker;
import net.momirealms.antigrieflib.AntiGriefLib;
import net.momirealms.customcrops.api.CustomCropsPlugin;
import net.momirealms.customcrops.api.event.CustomCropsReloadEvent;
@@ -39,10 +37,10 @@ import net.momirealms.customcrops.mechanic.misc.migrator.Migration;
import net.momirealms.customcrops.mechanic.requirement.RequirementManagerImpl;
import net.momirealms.customcrops.mechanic.world.WorldManagerImpl;
import net.momirealms.customcrops.scheduler.SchedulerImpl;
import net.momirealms.customcrops.util.NBTUtils;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@@ -99,7 +97,7 @@ public class CustomCropsPluginImpl extends CustomCropsPlugin {
this.hologramManager = new HologramManager(this);
this.commandManager.init();
this.integrationManager.init();
this.disableNBTAPILogs();
NBTUtils.disableNBTAPILogs();
Migration.tryUpdating();
this.reload();
if (ConfigManager.metrics()) new Metrics(this, 16593);
@@ -142,42 +140,6 @@ public class CustomCropsPluginImpl extends CustomCropsPlugin {
EventUtils.fireAndForget(new CustomCropsReloadEvent(this));
}
/**
* Disable NBT API logs
*/
private void disableNBTAPILogs() {
MinecraftVersion.disableBStats();
MinecraftVersion.disableUpdateCheck();
VersionChecker.hideOk = true;
try {
Field field = MinecraftVersion.class.getDeclaredField("version");
field.setAccessible(true);
MinecraftVersion minecraftVersion;
try {
minecraftVersion = MinecraftVersion.valueOf(getVersionManager().getServerVersion().replace("v", "MC"));
} catch (IllegalArgumentException ex) {
minecraftVersion = MinecraftVersion.UNKNOWN;
}
field.set(MinecraftVersion.class, minecraftVersion);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
boolean hasGsonSupport;
try {
Class.forName("com.google.gson.Gson");
hasGsonSupport = true;
} catch (Exception ex) {
hasGsonSupport = false;
}
try {
Field field= MinecraftVersion.class.getDeclaredField("hasGsonSupport");
field.setAccessible(true);
field.set(Boolean.class, hasGsonSupport);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
@Override
public void debug(String debug) {
if (ConfigManager.debug()) {

View File

@@ -42,14 +42,14 @@ public enum Dependency {
ASM(
"org.ow2.asm",
"asm",
"9.1",
"9.7",
null,
"asm"
),
ASM_COMMONS(
"org.ow2.asm",
"asm-commons",
"9.1",
"9.7",
null,
"asm-commons"
),
@@ -118,7 +118,7 @@ public enum Dependency {
NBT_API(
"de{}tr7zw",
"item-nbt-api",
"2.12.3",
"2.12.4",
"codemc",
"item-nbt-api",
Relocation.of("changeme", "de{}tr7zw{}changeme")
@@ -134,7 +134,7 @@ public enum Dependency {
BIOME_API(
"com{}github{}Xiao-MoMi",
"BiomeAPI",
"0.3",
"0.6",
"jitpack",
"biome-api",
Relocation.of("biomeapi", "net{}momirealms{}biomeapi")

View File

@@ -45,8 +45,6 @@ import net.momirealms.customcrops.api.util.LocationUtils;
import net.momirealms.customcrops.api.util.LogUtils;
import net.momirealms.customcrops.mechanic.item.custom.itemsadder.ItemsAdderListener;
import net.momirealms.customcrops.mechanic.item.custom.itemsadder.ItemsAdderProvider;
import net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenListener;
import net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenProvider;
import net.momirealms.customcrops.mechanic.item.custom.oraxenlegacy.LegacyOraxenListener;
import net.momirealms.customcrops.mechanic.item.custom.oraxenlegacy.LegacyOraxenProvider;
import net.momirealms.customcrops.mechanic.item.function.CFunction;
@@ -81,6 +79,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.lang.reflect.Constructor;
import java.util.*;
public class ItemManagerImpl implements ItemManager {
@@ -128,8 +127,18 @@ public class ItemManagerImpl implements ItemManager {
this.deadCrops = new HashSet<>();
if (Bukkit.getPluginManager().getPlugin("Oraxen") != null) {
if (Bukkit.getPluginManager().getPlugin("Oraxen").getDescription().getVersion().startsWith("2")) {
listener = new OraxenListener(this);
customProvider = new OraxenProvider();
try {
Class<?> oraxenListenerClass = Class.forName("net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenListener");
Constructor<?> oraxenListenerConstructor = oraxenListenerClass.getDeclaredConstructor(ItemManager.class);
oraxenListenerConstructor.setAccessible(true);
this.listener = (AbstractCustomListener) oraxenListenerConstructor.newInstance(this);
Class<?> oraxenProviderClass = Class.forName("net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenProvider");
Constructor<?> oraxenProviderConstructor = oraxenProviderClass.getDeclaredConstructor(ItemManager.class);
oraxenProviderConstructor.setAccessible(true);
this.customProvider = (CustomProvider) oraxenProviderConstructor.newInstance();
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}
} else {
listener = new LegacyOraxenListener(this);
customProvider = new LegacyOraxenProvider();

View File

@@ -0,0 +1,61 @@
package net.momirealms.customcrops.util;
import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion;
import de.tr7zw.changeme.nbtapi.utils.VersionChecker;
import net.momirealms.customcrops.api.CustomCropsPlugin;
import org.bukkit.Bukkit;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
public class NBTUtils {
private NBTUtils() {}
public static void disableNBTAPILogs() {
MinecraftVersion.disableBStats();
MinecraftVersion.disableUpdateCheck();
VersionChecker.hideOk = true;
try {
Field field = MinecraftVersion.class.getDeclaredField("version");
field.setAccessible(true);
MinecraftVersion minecraftVersion;
try {
minecraftVersion = MinecraftVersion.valueOf(CustomCropsPlugin.get().getVersionManager().getServerVersion().replace("v", "MC"));
} catch (Exception ex) {
minecraftVersion = VERSION_TO_REVISION.getOrDefault(Bukkit.getServer().getBukkitVersion().split("-")[0],
MinecraftVersion.UNKNOWN);
}
field.set(MinecraftVersion.class, minecraftVersion);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
boolean hasGsonSupport;
try {
Class.forName("com.google.gson.Gson");
hasGsonSupport = true;
} catch (Exception ex) {
hasGsonSupport = false;
}
try {
Field field= MinecraftVersion.class.getDeclaredField("hasGsonSupport");
field.setAccessible(true);
field.set(Boolean.class, hasGsonSupport);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
private static final Map<String, MinecraftVersion> VERSION_TO_REVISION = new HashMap<>() {
{
this.put("1.20", MinecraftVersion.MC1_20_R1);
this.put("1.20.1", MinecraftVersion.MC1_20_R1);
this.put("1.20.2", MinecraftVersion.MC1_20_R2);
this.put("1.20.3", MinecraftVersion.MC1_20_R3);
this.put("1.20.4", MinecraftVersion.MC1_20_R3);
this.put("1.20.5", MinecraftVersion.MC1_20_R4);
this.put("1.20.6", MinecraftVersion.MC1_20_R4);
}
};
}

View File

@@ -3,4 +3,5 @@ include(":plugin")
include(":api")
include(":legacy-api")
include("oraxen-legacy")
include(":oraxen-j21")