Skip to content

Commit ef3f2cd

Browse files
committed
[1.3.3] Update
1 parent 22c4b92 commit ef3f2cd

File tree

9 files changed

+128
-93
lines changed

9 files changed

+128
-93
lines changed

build.gradle.kts

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import io.izzel.taboolib.gradle.*
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
24

35
plugins {
46
`java-library`
5-
id("io.izzel.taboolib") version "2.0.13"
6-
id("org.jetbrains.kotlin.jvm") version "1.9.22"
7+
id("io.izzel.taboolib") version "2.0.23"
8+
id("org.jetbrains.kotlin.jvm") version "2.2.0"
79
}
810

911
taboolib {
@@ -12,6 +14,7 @@ taboolib {
1214
name("ItsFlicker")
1315
}
1416
dependencies {
17+
name("CraftEngine").optional(true)
1518
name("eco").optional(true)
1619
name("ItemsAdder").optional(true)
1720
name("Oraxen").optional(true)
@@ -22,18 +25,41 @@ taboolib {
2225
load("STARTUP")
2326
}
2427
env {
25-
install(UNIVERSAL, AI, NMS_UTIL, KETHER, METRICS, BUKKIT_ALL, EXPANSION_JAVASCRIPT)
28+
install("basic-configuration")
29+
install(BukkitHook, BukkitUtil, BukkitNMSEntityAI)
30+
install(
31+
"bukkit-nms-legacy",
32+
"bukkit-nms-stable",
33+
"bukkit-nms-tag",
34+
"bukkit-nms-tag-12005",
35+
"bukkit-nms-tag-12105",
36+
"bukkit-nms-tag-12106",
37+
"bukkit-nms-tag-legacy",
38+
"bukkit-nms"
39+
)
40+
install(
41+
"minecraft-chat",
42+
"minecraft-command-helper",
43+
// "minecraft-i18n",
44+
"minecraft-kether",
45+
"minecraft-metrics"
46+
)
47+
install(JavaScript)
48+
install(Bukkit)
49+
// repoTabooLib = "http://mcitd.cn:8081/repository/releases"
2650
}
2751
version {
28-
taboolib = "6.1.2-beta10"
52+
taboolib = "6.2.3-7105e58f"
2953
coroutines = null
3054
}
3155
}
3256

3357
repositories {
3458
mavenLocal()
3559
mavenCentral()
60+
// maven("http://mcitd.cn:8081/repository/releases") { isAllowInsecureProtocol = true }
3661
maven("https://jitpack.io")
62+
maven("https://repo.momirealms.net/releases/")
3763
maven("https://repo.papermc.io/repository/maven-public/")
3864
maven("https://repo.rosewooddev.io/repository/public/")
3965
}
@@ -42,14 +68,16 @@ dependencies {
4268
// compileOnly("public:ModelEngine:3.0.0")
4369
compileOnly("com.willfp:eco:6.35.1")
4470
compileOnly("com.github.LoneDev6:api-itemsadder:3.2.5")
71+
compileOnly("net.momirealms:craft-engine-core:0.0.59")
72+
compileOnly("net.momirealms:craft-engine-bukkit:0.0.59")
4573
// compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
4674
compileOnly("ink.ptms:Zaphkiel:2.0.14")
4775

48-
compileOnly("ink.ptms.core:v12004:12004:mapped")
49-
compileOnly("ink.ptms.core:v12004:12004:universal")
50-
compileOnly("ink.ptms:nms-all:1.0.0")
76+
compileOnly("ink.ptms.core:v12107:12107:mapped")
77+
compileOnly("ink.ptms.core:v12107:12107:universal")
78+
// compileOnly("ink.ptms:nms-all:1.0.0")
5179

52-
compileOnly("com.electronwill.night-config:core:3.6.7")
80+
// compileOnly("com.electronwill.night-config:core:3.6.7")
5381
compileOnly("com.google.code.gson:gson:2.9.0")
5482
compileOnly("com.google.guava:guava:31.1-jre")
5583
compileOnly(kotlin("stdlib"))
@@ -61,14 +89,14 @@ tasks.withType<JavaCompile> {
6189
options.encoding = "UTF-8"
6290
}
6391

64-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
65-
kotlinOptions {
66-
jvmTarget = "1.8"
92+
tasks.withType<KotlinCompile> {
93+
compilerOptions {
94+
jvmTarget = JvmTarget.JVM_21
6795
freeCompilerArgs = listOf("-Xjvm-default=all")
6896
}
6997
}
7098

71-
configure<JavaPluginConvention> {
72-
sourceCompatibility = JavaVersion.VERSION_1_8
73-
targetCompatibility = JavaVersion.VERSION_1_8
99+
configure<JavaPluginExtension> {
100+
sourceCompatibility = JavaVersion.VERSION_21
101+
targetCompatibility = JavaVersion.VERSION_21
74102
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
group=io.github.itsflicker.tools
2-
version=1.3.2
2+
version=1.3.3
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.14.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/kotlin/io/github/itsflicker/tools/ItsTools.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import taboolib.common.env.RuntimeDependency
1717
import taboolib.common.platform.Platform
1818
import taboolib.common.platform.Plugin
1919
import taboolib.common.platform.function.pluginVersion
20+
import taboolib.module.configuration.Config
2021
import taboolib.module.configuration.Configuration
2122
import taboolib.module.configuration.Configuration.Companion.toObject
2223
import taboolib.module.metrics.Metrics
@@ -38,7 +39,7 @@ import taboolib.platform.util.onlinePlayers
3839
)
3940
object ItsTools : Plugin(), BukkitWorldGenerator {
4041

41-
@Config(autoReload = true)
42+
@Config
4243
lateinit var config: Configuration
4344
private set
4445

src/main/kotlin/io/github/itsflicker/tools/api/NMSImpl.kt

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,19 @@ import net.minecraft.network.chat.IChatBaseComponent
44
import net.minecraft.world.entity.EntityCreature
55
import net.minecraft.world.entity.EntityInsentient
66
import net.minecraft.world.entity.EntityLiving
7-
import net.minecraft.world.entity.ai.attributes.AttributeBase
8-
import net.minecraft.world.entity.ai.attributes.AttributeMapBase
9-
import net.minecraft.world.entity.ai.attributes.AttributeModifiable
107
import net.minecraft.world.entity.ai.attributes.GenericAttributes
118
import net.minecraft.world.entity.ai.goal.PathfinderGoal
129
import net.minecraft.world.entity.ai.goal.PathfinderGoalMeleeAttack
1310
import net.minecraft.world.entity.ai.goal.target.PathfinderGoalHurtByTarget
1411
import net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget
15-
import net.minecraft.world.entity.ai.navigation.NavigationAbstract
1612
import org.bukkit.Location
17-
import org.bukkit.craftbukkit.v1_20_R3.CraftServer
18-
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity
19-
import org.bukkit.craftbukkit.v1_20_R3.util.CraftChatMessage
13+
import org.bukkit.craftbukkit.v1_21_R5.CraftServer
14+
import org.bukkit.craftbukkit.v1_21_R5.entity.CraftEntity
15+
import org.bukkit.craftbukkit.v1_21_R5.util.CraftChatMessage
2016
import org.bukkit.entity.LivingEntity
2117
import taboolib.common.platform.function.warning
22-
import taboolib.library.reflex.Reflex.Companion.getProperty
2318
import taboolib.library.reflex.Reflex.Companion.invokeMethod
2419
import taboolib.library.reflex.Reflex.Companion.setProperty
25-
import taboolib.module.ai.pathfinderExecutor
2620
import taboolib.module.chat.ComponentText
2721
import taboolib.module.nms.nmsClass
2822

@@ -40,8 +34,16 @@ class NMSImpl : NMS() {
4034
return CraftChatMessage.fromJSON(component.toRawMessage())
4135
}
4236

37+
private fun LivingEntity.getEntityLiving(): EntityLiving? {
38+
return (this as CraftEntity).handle as? EntityLiving
39+
}
40+
4341
private fun LivingEntity.getEntityInsentient(): EntityInsentient? {
44-
return pathfinderExecutor.getEntityInsentient(this) as? EntityInsentient
42+
return (this as CraftEntity).handle as? EntityInsentient
43+
}
44+
45+
private fun LivingEntity.getEntityCreature(): EntityCreature? {
46+
return (this as CraftEntity).handle as? EntityCreature
4547
}
4648

4749
private fun addGoalAi(entity: LivingEntity, priority: Int, pathfinderGoal: Any) {
@@ -59,37 +61,33 @@ class NMSImpl : NMS() {
5961
}
6062

6163
override fun setTargetEntity(entity: LivingEntity, target: LivingEntity?) {
62-
val entityInsentient = entity.getEntityInsentient() ?: return
63-
// Unknown target reason, please report on the issue tracker
64-
entityInsentient.setProperty("target", target?.getEntityInsentient())
64+
val entityInsentient = entity.getEntityInsentient()
65+
?: return warning("${entity.type} is not EntityInsentient.")
66+
// setTarget -> Unknown target reason, please report on the issue tracker
67+
entityInsentient.setProperty("target", target?.getEntityLiving())
6568
}
6669

6770
override fun getSpeed(entity: LivingEntity): Double {
6871
return entity.getEntityInsentient()!!.speed.toDouble()
6972
}
7073

7174
override fun getTargetLocation(entity: LivingEntity): Location? {
72-
val navigation = entity.getEntityInsentient()!!.getProperty<NavigationAbstract>("navigation")!!
75+
val navigation = entity.getEntityInsentient()!!.navigation
7376
return navigation.path?.endNode?.let { Location(entity.world, it.x.toDouble(), it.y.toDouble(), it.z.toDouble()) }
7477
}
7578

7679
override fun makeMeleeHostile(entity: LivingEntity, damage: Double?, speed: Double, priority: Int, type: String, followingTargetEvenIfNotSeen: Boolean) {
77-
val entityInsentient = entity.getEntityInsentient()
78-
?: return warning("${entity.type} is not EntityInsentient.")
80+
val entityCreature = entity.getEntityCreature()
81+
?: return warning("${entity.type} is not EntityCreature.")
7982
if (damage != null) {
80-
val map = entityInsentient.invokeMethod<AttributeMapBase>("getAttributes")!!
81-
// add generic:attack_damage attribute
82-
map.getProperty<HashMap<AttributeBase, AttributeModifiable>>("b")!![GenericAttributes.ATTACK_DAMAGE] =
83-
AttributeModifiable(GenericAttributes.ATTACK_DAMAGE) { map.invokeMethod<Void>("a", it) }
84-
// set entity damage
85-
entityInsentient.invokeMethod<AttributeModifiable>("getAttribute", GenericAttributes.ATTACK_DAMAGE)!!
86-
.invokeMethod<Void>("a", damage)
83+
entityCreature.attributes.invokeMethod<Void>("registerAttribute", GenericAttributes.ATTACK_DAMAGE)
84+
entityCreature.getAttribute(GenericAttributes.ATTACK_DAMAGE)!!.baseValue = damage
8785
}
8886
// add goal selector
89-
addGoalAi(entity, priority, PathfinderGoalMeleeAttack(entityInsentient as EntityCreature, speed, followingTargetEvenIfNotSeen))
87+
addGoalAi(entity, priority, PathfinderGoalMeleeAttack(entityCreature, speed, followingTargetEvenIfNotSeen))
9088
// add target selector
91-
addTargetAi(entity, 1, PathfinderGoalHurtByTarget(entityInsentient))
92-
addTargetAi(entity, 2, PathfinderGoalNearestAttackableTarget(entityInsentient, nmsClass(type).asSubclass(EntityLiving::class.java), true))
89+
addTargetAi(entity, 1, PathfinderGoalHurtByTarget(entityCreature))
90+
addTargetAi(entity, 2, PathfinderGoalNearestAttackableTarget(entityCreature, nmsClass(type).asSubclass(EntityLiving::class.java), true))
9391
}
9492

9593
}

src/main/kotlin/io/github/itsflicker/tools/module/feature/DebugItem.kt

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import io.github.itsflicker.tools.module.feature.DebugItem.Mode.*
55
import org.bukkit.Bukkit
66
import org.bukkit.entity.EntityType
77
import org.bukkit.entity.LivingEntity
8+
import org.bukkit.entity.Player
89
import org.bukkit.event.block.Action
910
import org.bukkit.event.player.PlayerInteractEntityEvent
1011
import org.bukkit.event.player.PlayerInteractEvent
@@ -78,35 +79,72 @@ object DebugItem {
7879
component.saveTo(item)
7980
}
8081

81-
@SubscribeEvent
82-
fun e(e: PlayerInteractEntityEvent) {
82+
@SubscribeEvent(priority = EventPriority.LOWEST)
83+
fun onOperation(e: PlayerInteractEntityEvent) {
8384
val entity = e.rightClicked as? LivingEntity ?: return
8485
val player = e.player
8586
val operation = CommandOperation.cacheOperations.getIfPresent(player.uniqueId)
8687
if (operation != null) {
8788
operation.accept(entity)
8889
CommandOperation.cacheOperations.invalidate(player.uniqueId)
89-
return
90+
e.isCancelled = true
91+
}
92+
}
93+
94+
@SubscribeEvent(priority = EventPriority.LOW, ignoreCancelled = true)
95+
fun onInteract(e: PlayerInteractEvent) {
96+
val player = e.player
97+
val item = player.inventory.itemInMainHand
98+
if (isDebugItem(item)) {
99+
when (getMode(item)) {
100+
NAVIGATE -> {
101+
if (e.action == Action.RIGHT_CLICK_BLOCK) {
102+
val entityUUID = cache[player.name] ?: return
103+
val entity = Bukkit.getEntity(entityUUID) as? LivingEntity ?: return
104+
entity.navigationMove(e.clickedBlock?.location ?: player.location, 1.0)
105+
e.isCancelled = true
106+
}
107+
}
108+
REMOVE_ARMOR_STAND -> {
109+
if (e.action == Action.RIGHT_CLICK_BLOCK) {
110+
val block = e.clickedBlock ?: return
111+
block.world.getNearbyEntities(block.location, 3.0, 3.0, 3.0) {
112+
it.type == EntityType.ARMOR_STAND
113+
}.forEach {
114+
it.remove()
115+
}
116+
e.isCancelled = true
117+
}
118+
}
119+
else -> {}
120+
}
90121
}
122+
}
123+
124+
@SubscribeEvent(priority = EventPriority.NORMAL, ignoreCancelled = true)
125+
fun onInteractEntity(e: PlayerInteractEntityEvent) {
126+
val entity = e.rightClicked as? LivingEntity ?: return
127+
val player = e.player
91128
val item = player.inventory.itemInMainHand
92129
if (isDebugItem(item) && cooldown.hasNext(player.name)) {
130+
e.isCancelled = true
93131
when (getMode(item)) {
94132
GET_ENTITY_UUID -> {
95133
cache[player.name] = entity.uniqueId
96134
player.sendMessage("&cUUID: &f${entity.uniqueId}".colored())
97135
}
98136
NAVIGATE -> {
137+
if (entity is Player) return
99138
cache[player.name] = entity.uniqueId
100139
player.sendMessage("&f${entity.uniqueId} &cCached.".colored())
101140
}
102-
else -> Unit
141+
else -> {}
103142
}
104-
e.isCancelled = true
105143
}
106144
}
107145

108146
@SubscribeEvent
109-
fun e(e: PlayerSwapHandItemsEvent) {
147+
fun onSwapHand(e: PlayerSwapHandItemsEvent) {
110148
val player = e.player
111149
val item = player.inventory.itemInMainHand.also { if (it.isAir()) return }
112150
if (isDebugItem(item)) {
@@ -122,34 +160,4 @@ object DebugItem {
122160
}
123161
}
124162

125-
@SubscribeEvent(priority = EventPriority.LOWEST)
126-
fun e(e: PlayerInteractEvent) {
127-
val player = e.player
128-
val item = player.inventory.itemInMainHand
129-
if (isDebugItem(item)) {
130-
when (getMode(item)) {
131-
NAVIGATE -> {
132-
if (e.action == Action.RIGHT_CLICK_BLOCK) {
133-
val entityUUID = cache[player.name] ?: return
134-
val entity = Bukkit.getEntity(entityUUID) as? LivingEntity ?: return
135-
entity.navigationMove(e.clickedBlock?.location ?: player.location, 1.0)
136-
e.isCancelled = true
137-
}
138-
}
139-
REMOVE_ARMOR_STAND -> {
140-
if (e.action == Action.RIGHT_CLICK_BLOCK) {
141-
val block = e.clickedBlock ?: return
142-
block.world.getNearbyEntities(block.location, 3.0, 3.0, 3.0) {
143-
it.type == EntityType.ARMOR_STAND
144-
}.forEach {
145-
it.remove()
146-
}
147-
e.isCancelled = true
148-
}
149-
}
150-
else -> Unit
151-
}
152-
}
153-
}
154-
155163
}

0 commit comments

Comments
 (0)