mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
Create common nms module.
This commit is contained in:
parent
056892ee1e
commit
7d20ea83c3
13 changed files with 108 additions and 70 deletions
|
|
@ -15,34 +15,16 @@ plugins {
|
|||
group = "xyz.alexcrea"
|
||||
version = "1.5.4-fix"
|
||||
|
||||
java {
|
||||
disableAutoTargetJvm()
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(20))
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
|
||||
// ProtocoLib
|
||||
maven (url = "https://repo.dmulloy2.net/repository/public/" )
|
||||
|
||||
// EcoEnchants
|
||||
maven(url = "https://repo.auxilor.io/repository/maven-public/")
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
compileOnly(kotlin("stdlib"))
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
|
||||
|
||||
// Gui library
|
||||
implementation("com.github.stefvanschie.inventoryframework:IF:0.10.14")
|
||||
|
||||
// Protocolib
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
||||
|
||||
// EnchantsSquaredRewritten
|
||||
compileOnly(files("libs/EnchantsSquared.jar"))
|
||||
|
||||
|
|
@ -50,29 +32,58 @@ dependencies {
|
|||
compileOnly("com.willfp:EcoEnchants:12.5.1")
|
||||
compileOnly("com.willfp:eco:6.70.1")
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
|
||||
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
||||
// Include nms
|
||||
implementation(project(":nms:nms-common"))
|
||||
|
||||
}
|
||||
|
||||
tasks.getByName<Test>("test") {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "kotlin")
|
||||
|
||||
// Set target version
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
sourceCompatibility = "16" // We aim for java 16 for minecraft 1.16.5. even if it not really suported.
|
||||
targetCompatibility = "16"
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
|
||||
jvmTarget.set(JvmTarget.JVM_16)
|
||||
// Spigot repository
|
||||
maven(url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(kotlin("stdlib"))
|
||||
|
||||
// We assume nms part will not require version specific api.
|
||||
// If any issue occur because of this assumption. please fell free to edit.
|
||||
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
|
||||
|
||||
// Currently not used. but it would be useful to test.
|
||||
testImplementation(platform("org.junit:junit-bom:5.9.1"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
}
|
||||
|
||||
// Configure used version of kotlin and java
|
||||
java {
|
||||
disableAutoTargetJvm()
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(20))
|
||||
}
|
||||
|
||||
tasks.getByName<Test>("test") {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
// Set target version
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
sourceCompatibility = "16" // We aim for java 16 for minecraft 1.16.5. even if it not really suported.
|
||||
targetCompatibility = "16"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
|
||||
jvmTarget.set(JvmTarget.JVM_16)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Fat-jar builder
|
||||
val fatJar = tasks.register<Jar>("fatJar") {
|
||||
|
|
|
|||
14
nms/nms-common/build.gradle.kts
Normal file
14
nms/nms-common/build.gradle.kts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
group = rootProject.group
|
||||
version = rootProject.version
|
||||
|
||||
repositories {
|
||||
// ProtocoLib
|
||||
maven (url = "https://repo.dmulloy2.net/repository/public/" )
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Protocolib
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.packet
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
abstract class AbstractPacketManager : PacketManager {
|
||||
override val canSetInstantBuild: Boolean
|
||||
get() = false
|
||||
|
||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
||||
// Default empty.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.packet
|
||||
|
||||
// ProtocoLib not installed and not in a supported version: We do nothing
|
||||
class NoPacketManager: AbstractPacketManager()
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.packet
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
interface PacketManager {
|
||||
|
||||
/**
|
||||
* If the provided packet manager if able to set instant build.
|
||||
*/
|
||||
val canSetInstantBuild: Boolean
|
||||
|
||||
/**
|
||||
* Try to set instant build properties
|
||||
*/
|
||||
fun setInstantBuild(player: Player, instantBuild: Boolean)
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.protocolib
|
||||
package xyz.alexcrea.cuanvil.dependency.packet
|
||||
|
||||
import com.comphenix.protocol.PacketType
|
||||
import com.comphenix.protocol.ProtocolLibrary
|
||||
|
|
@ -11,7 +11,7 @@ class ProtocoLibWrapper: PacketManager {
|
|||
|
||||
private val protocolManager: ProtocolManager = ProtocolLibrary.getProtocolManager();
|
||||
|
||||
override val isProtocoLibInstalled: Boolean
|
||||
override val canSetInstantBuild: Boolean
|
||||
get() = true
|
||||
|
||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
||||
|
|
@ -1,2 +1,4 @@
|
|||
rootProject.name = "CustomAnvil"
|
||||
|
||||
include("nms:nms-common")
|
||||
findProject(":nms:nms-common")?.name = "nms-common"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import io.delilaheve.CustomAnvil;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.PacketManager;
|
||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager;
|
||||
import xyz.alexcrea.cuanvil.gui.config.global.*;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.PacketManager;
|
||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager;
|
||||
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui;
|
||||
import xyz.alexcrea.cuanvil.gui.config.settings.BoolSettingsGui;
|
||||
|
|
@ -280,9 +280,10 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
|
|||
lore.add("\u00A77Even if cost is displayed as \u00A7aGreen\u00A77:");
|
||||
lore.add("\u00A77If the player do not have the required xp level, the action will not be completable.");
|
||||
|
||||
if(!this.packetManager.isProtocoLibInstalled()){
|
||||
if(!this.packetManager.getCanSetInstantBuild()){
|
||||
lore.add("");
|
||||
lore.add("\u00A74/!\\\u00A7cCaution/!\\ \u00A7cYou need ProtocoLib installed for this to work.");
|
||||
lore.add("\u00A74/!\\\u00A7cCaution\u00A74/!\\ \u00A7cYou need ProtocoLib installed and working or a newer version of this plugin for this to work.");
|
||||
lore.add("\u00A7cCurrently ProtocoLib is not detected.");
|
||||
}
|
||||
|
||||
String[] loreAsArray = new String[lore.size()];
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.bukkit.inventory.InventoryView.Property.REPAIR_COST
|
|||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.inventory.meta.Repairable
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.PacketManager
|
||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
|
||||
import xyz.alexcrea.cuanvil.group.ConflictType
|
||||
import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe
|
||||
import xyz.alexcrea.cuanvil.util.UnitRepairUtil.getRepair
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package xyz.alexcrea.cuanvil.dependency
|
||||
|
||||
import org.bukkit.Bukkit
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.NoProtocoLib
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.PacketManager
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.ProtocoLibWrapper
|
||||
import xyz.alexcrea.cuanvil.dependency.packet.NoPacketManager
|
||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
|
||||
import xyz.alexcrea.cuanvil.dependency.packet.ProtocoLibWrapper
|
||||
|
||||
object DependencyManager {
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ object DependencyManager {
|
|||
// ProtocolLib dependency
|
||||
packetManager =
|
||||
if(pluginManager.isPluginEnabled("ProtocolLib")) ProtocoLibWrapper()
|
||||
else NoProtocoLib()
|
||||
else NoPacketManager()
|
||||
|
||||
// Enchantment Squared dependency
|
||||
if(pluginManager.isPluginEnabled("EnchantsSquared")){
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.protocolib
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class NoProtocoLib: PacketManager {
|
||||
override val isProtocoLibInstalled: Boolean
|
||||
get() = false
|
||||
|
||||
// ProtocoLib not installed: We do nothing
|
||||
|
||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {}
|
||||
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package xyz.alexcrea.cuanvil.dependency.protocolib
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
interface PacketManager {
|
||||
|
||||
val isProtocoLibInstalled: Boolean
|
||||
|
||||
fun setInstantBuild(player: Player, instantBuild: Boolean)
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue