Skip to content

Commit

Permalink
support Arclight
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Oct 5, 2023
1 parent bcc72aa commit a66ac65
Show file tree
Hide file tree
Showing 67 changed files with 491 additions and 272 deletions.
3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension

dependencies {
compileOnly("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT")
}

afterEvaluate {
publishing {
publications {
Expand All @@ -10,4 +14,4 @@ afterEvaluate {
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kor.toxicity.questadder.api.event;

import io.th0rgal.oraxen.shaded.jetbrains.annotations.NotNull;
import kor.toxicity.questadder.api.mechanic.IAction;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public interface ActionEvent {
@NotNull IAction getAction();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package kor.toxicity.questadder.api.event;

import io.th0rgal.oraxen.shaded.jetbrains.annotations.NotNull;
import kor.toxicity.questadder.api.mechanic.IAction;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class ActionInvokeEvent extends QuestAdderPlayerEvent implements Cancellable, ActionEvent {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Map;

public interface IGui {
@NotNull GuiHolder open(@NotNull Player player, @NotNull GuiExecutor executor);
@NotNull IGuiHolder open(@NotNull Player player, @NotNull GuiExecutor executor);
@NotNull
Component getGuiName();
@NotNull
Expand Down
12 changes: 12 additions & 0 deletions api/src/main/java/kor/toxicity/questadder/api/gui/IGuiHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package kor.toxicity.questadder.api.gui;

import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;

public interface IGuiHolder extends InventoryHolder {
@NotNull GuiData getData();

@Override
@NotNull Inventory getInventory();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import kor.toxicity.questadder.api.QuestAdder;
import kor.toxicity.questadder.api.event.ActionInvokeEvent;
import kor.toxicity.questadder.api.util.DataObject;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -20,7 +21,8 @@ public AbstractAction(@NotNull QuestAdder adder) {
@NotNull
public ActionResult apply(@NotNull Player player, @NotNull String... args) {
var event = new ActionInvokeEvent(this,player,args);
return event.callEvent() ? invoke(player,event) : ActionResult.CANCELLED;
Bukkit.getPluginManager().callEvent(event);
return !event.isCancelled() ? invoke(player,event) : ActionResult.CANCELLED;
}
@Override
public void initialize() {
Expand Down
33 changes: 15 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask

plugins {
`java-library`
id("org.jetbrains.kotlin.jvm") version("1.9.10")
Expand All @@ -11,6 +9,9 @@ plugins {
val questAdderGroup = "kor.toxicity.questadder"
val questAdderVersion = "1.1.4"

val adventureVersion = "4.14.0"
val platformVersion = "4.3.1"

allprojects {
apply(plugin = "java")
apply(plugin = "org.jetbrains.kotlin.jvm")
Expand Down Expand Up @@ -53,26 +54,20 @@ allprojects {
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
testImplementation("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")

compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")

compileOnly("net.kyori:adventure-api:${adventureVersion}")
compileOnly("net.kyori:adventure-text-serializer-legacy:${adventureVersion}")
compileOnly("net.kyori:adventure-text-serializer-gson:${adventureVersion}")
compileOnly("net.kyori:adventure-text-serializer-plain:${adventureVersion}")
compileOnly("net.kyori:adventure-platform-bukkit:${platformVersion}")

compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
compileOnly("net.byteflux:libby-bukkit:1.1.5")
compileOnly("com.github.oraxen:oraxen:1.158.0")
compileOnly("com.github.LoneDev6:api-itemsadder:3.5.0b")
compileOnly("net.citizensnpcs:citizens-main:2.0.32-SNAPSHOT")
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
compileOnly("com.mojang:brigadier:1.1.8")
compileOnly("com.mojang:datafixerupper:6.0.8")
compileOnly("com.comphenix.protocol:ProtocolLib:4.8.0")
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
compileOnly(fileTree("libs"))
compileOnly("io.lumine:Mythic-Dist:5.3.5")
compileOnly("com.bgsoftware:SuperiorSkyblockAPI:2023.2")
compileOnly("net.Indyuce:MMOCore-API:1.12-SNAPSHOT")
compileOnly("net.Indyuce:MMOItems-API:6.9.5-SNAPSHOT")
compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT")
compileOnly("com.github.BeYkeRYkt.LightAPI:lightapi-bukkit-common:5.3.0-Bukkit")
}
}
subprojects {
Expand Down Expand Up @@ -105,7 +100,9 @@ tasks {
processResources {
filteringCharset = Charsets.UTF_8.name()
val props = mapOf(
"version" to version
"version" to version,
"adventureVersion" to adventureVersion,
"platformVersion" to platformVersion
)
inputs.properties(props)
filesMatching("plugin.yml") {
Expand Down
3 changes: 2 additions & 1 deletion expansion/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.jetbrains.dokka.gradle.DokkaTaskPartial

dependencies {
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
compileOnly("com.github.PlaceholderAPI:PlaceholderAPI:master-SNAPSHOT")
compileOnly(project(":plugin"))
compileOnly(project(":api"))
Expand All @@ -13,4 +14,4 @@ tasks {
archiveBaseName.set("Expansion-questadder")
archiveExtension.set("patch")
}
}
}
2 changes: 1 addition & 1 deletion nms/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ subprojects {
compileOnly(project(":plugin"))
compileOnly(project(":api"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.mojang.datafixers.util.Pair
import kor.toxicity.questadder.QuestAdderBukkit
import kor.toxicity.questadder.nms.*
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
import net.minecraft.network.protocol.game.*
import net.minecraft.network.syncher.DataWatcherObject
import net.minecraft.network.syncher.DataWatcherRegistry
Expand All @@ -23,7 +24,7 @@ import org.bukkit.craftbukkit.v1_17_R1.CraftServer
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack
import org.bukkit.entity.ArmorStand
import org.bukkit.craftbukkit.v1_17_R1.util.CraftChatMessage
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack

Expand Down Expand Up @@ -91,7 +92,7 @@ class NMSImpl: NMS {
}

override fun setText(text: Component) {
(display.bukkitEntity as ArmorStand).customName(text)
display.customName = CraftChatMessage.fromJSON(GsonComponentSerializer.gson().serialize(text))
connection.sendPacket(PacketPlayOutEntityMetadata(display.id, display.dataWatcher,true))
}

Expand Down Expand Up @@ -161,4 +162,4 @@ class NMSImpl: NMS {
override fun getProperties(gameProfile: GameProfile): PropertyMap {
return gameProfile.properties
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import org.bukkit.Location
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.command.SimpleCommandMap
import org.bukkit.craftbukkit.v1_18_R1.CraftServer
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_18_R1.util.CraftChatMessage
import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack

Expand Down Expand Up @@ -70,8 +70,12 @@ class NMSImpl: NMS {
if (!map.register("questadder",obj)) QuestAdderBukkit.warn("unable to register command: $name")
return object: RuntimeCommand {
override fun unregister() {
map.knownCommands.remove("questadder:$name")
map.knownCommands.remove(name)
val field = SimpleCommandMap::class.java.getDeclaredField("knownCommands")
field.isAccessible = true
val getMap = field.get(map) as MutableMap<*,*>
getMap.remove("questadder:$name")
getMap.remove(name)
field.isAccessible = false
}
}
}
Expand All @@ -97,7 +101,7 @@ class NMSImpl: NMS {
connection.a(PacketPlayOutEntityMetadata(entity.ae(),entity.ai(),true))
}
override fun setText(text: Component) {
(entity.bukkitEntity as ArmorStand).customName(text)
entity.a(CraftChatMessage.fromJSON(GsonComponentSerializer.gson().serialize(text)))
connection.a(PacketPlayOutEntityMetadata(entity.ae(),entity.ai(),true))
}
override fun setItem(itemStack: ItemStack) {
Expand Down Expand Up @@ -175,4 +179,4 @@ class NMSImpl: NMS {
override fun getProperties(gameProfile: GameProfile): PropertyMap {
return gameProfile.properties
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import org.bukkit.Location
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.command.SimpleCommandMap
import org.bukkit.craftbukkit.v1_18_R2.CraftServer
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage
import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack

Expand Down Expand Up @@ -70,8 +70,12 @@ class NMSImpl: NMS {
if (!map.register("questadder",obj)) QuestAdderBukkit.warn("unable to register command: $name")
return object: RuntimeCommand {
override fun unregister() {
map.knownCommands.remove("questadder:$name")
map.knownCommands.remove(name)
val field = SimpleCommandMap::class.java.getDeclaredField("knownCommands")
field.isAccessible = true
val getMap = field.get(map) as MutableMap<*,*>
getMap.remove("questadder:$name")
getMap.remove(name)
field.isAccessible = false
}
}
}
Expand All @@ -97,7 +101,7 @@ class NMSImpl: NMS {
connection.a(PacketPlayOutEntityMetadata(entity.ae(),entity.ai(),true))
}
override fun setText(text: Component) {
(entity.bukkitEntity as ArmorStand).customName(text)
entity.a(CraftChatMessage.fromJSON(GsonComponentSerializer.gson().serialize(text)))
connection.a(PacketPlayOutEntityMetadata(entity.ae(),entity.ai(),true))
}
override fun setItem(itemStack: ItemStack) {
Expand Down Expand Up @@ -174,4 +178,4 @@ class NMSImpl: NMS {
override fun getProperties(gameProfile: GameProfile): PropertyMap {
return gameProfile.properties
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ import org.bukkit.Location
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.command.SimpleCommandMap
import org.bukkit.craftbukkit.v1_19_R1.CraftServer
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage
import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import java.util.*

class NMSImpl: NMS {

Expand Down Expand Up @@ -71,8 +70,12 @@ class NMSImpl: NMS {
if (!map.register("questadder",obj)) QuestAdderBukkit.warn("unable to register command: $name")
return object: RuntimeCommand {
override fun unregister() {
map.knownCommands.remove("questadder:$name")
map.knownCommands.remove(name)
val field = SimpleCommandMap::class.java.getDeclaredField("knownCommands")
field.isAccessible = true
val getMap = field.get(map) as MutableMap<*,*>
getMap.remove("questadder:$name")
getMap.remove(name)
field.isAccessible = false
}
}
}
Expand All @@ -98,7 +101,7 @@ class NMSImpl: NMS {
connection.a(PacketPlayOutEntityMetadata(entity.ae(),entity.ai(),true))
}
override fun setText(text: Component) {
(entity.bukkitEntity as ArmorStand).customName(text)
entity.b(CraftChatMessage.fromJSON(GsonComponentSerializer.gson().serialize(text)))
connection.a(PacketPlayOutEntityMetadata(entity.ae(),entity.ai(),true))
}
override fun setItem(itemStack: ItemStack) {
Expand Down Expand Up @@ -176,4 +179,4 @@ class NMSImpl: NMS {
override fun getProperties(gameProfile: GameProfile): PropertyMap {
return gameProfile.properties
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import org.bukkit.Location
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.command.SimpleCommandMap
import org.bukkit.craftbukkit.v1_19_R2.CraftServer
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_19_R2.util.CraftChatMessage
import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import java.util.*
Expand Down Expand Up @@ -71,8 +71,12 @@ class NMSImpl: NMS {
if (!map.register("questadder",obj)) QuestAdderBukkit.warn("unable to register command: $name")
return object: RuntimeCommand {
override fun unregister() {
map.knownCommands.remove("questadder:$name")
map.knownCommands.remove(name)
val field = SimpleCommandMap::class.java.getDeclaredField("knownCommands")
field.isAccessible = true
val getMap = field.get(map) as MutableMap<*,*>
getMap.remove("questadder:$name")
getMap.remove(name)
field.isAccessible = false
}
}
}
Expand All @@ -98,7 +102,7 @@ class NMSImpl: NMS {
connection.a(PacketPlayOutEntityMetadata(entity.ah(),entity.al().c()))
}
override fun setText(text: Component) {
(entity.bukkitEntity as ArmorStand).customName(text)
entity.b(CraftChatMessage.fromJSON(GsonComponentSerializer.gson().serialize(text)))
connection.a(PacketPlayOutEntityMetadata(entity.ah(),entity.al().c()))
}
override fun setItem(itemStack: ItemStack) {
Expand Down Expand Up @@ -175,4 +179,4 @@ class NMSImpl: NMS {
override fun getProperties(gameProfile: GameProfile): PropertyMap {
return gameProfile.properties
}
}
}
Loading

0 comments on commit a66ac65

Please sign in to comment.