Skip to content

Commit f87c49e

Browse files
committed
[1.3.1] Update
1 parent 3ff2cef commit f87c49e

20 files changed

Lines changed: 93 additions & 301 deletions

File tree

build.gradle.kts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ taboolib {
3232
install("platform-bukkit")
3333
install("expansion-command-helper", "expansion-javascript")
3434
classifier = null
35-
version = "6.0.12-35"
35+
version = "6.0.12-local"
3636
}
3737

3838
repositories {
@@ -48,11 +48,10 @@ dependencies {
4848
compileOnly("com.willfp:eco:6.35.1")
4949
compileOnly("com.github.LoneDev6:api-itemsadder:3.2.5")
5050
// compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
51-
compileOnly("me.casperge:realisticseasons:8.1.3")
5251
compileOnly("ink.ptms:Zaphkiel:2.0.14")
5352

54-
compileOnly("ink.ptms.core:v12002:12002:mapped")
55-
compileOnly("ink.ptms.core:v12002:12002:universal")
53+
compileOnly("ink.ptms.core:v12004:12004:mapped")
54+
compileOnly("ink.ptms.core:v12004:12004:universal")
5655
compileOnly("ink.ptms:nms-all:1.0.0")
5756

5857
compileOnly("com.electronwill.night-config:core:3.6.5")

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.itstools
2-
version=1.3.0
2+
version=1.3.1
-1.73 MB
Binary file not shown.

libs/Pouvoir-1.6.1-12-api.jar

-9.84 MB
Binary file not shown.

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ package io.github.itsflicker.itstools
22

33
import com.willfp.eco.core.items.Items
44
import ink.ptms.sandalphon.Sandalphon
5+
import io.github.itsflicker.itstools.module.feature.IPInfo
56
import io.github.itsflicker.itstools.module.feature.Void
67
import io.github.itsflicker.itstools.module.integration.itemsadder.ItemsAdderItemAPI
78
import io.github.itsflicker.itstools.module.integration.zaphkiel.ZaphkielItemProvider
8-
import io.github.itsflicker.itstools.util.*
9+
import io.github.itsflicker.itstools.util.isEcoHooked
10+
import io.github.itsflicker.itstools.util.isItemsAdderHooked
11+
import io.github.itsflicker.itstools.util.isSandalphonHooked
12+
import io.github.itsflicker.itstools.util.isZaphkielHooked
913
import org.bukkit.Bukkit
1014
import org.bukkit.generator.ChunkGenerator
1115
import taboolib.common.env.RuntimeDependencies
@@ -60,13 +64,10 @@ object ItsTools : Plugin(), BukkitWorldGenerator {
6064
Sandalphon.registerItemAPI(ItemsAdderItemAPI())
6165
}
6266

63-
// onlinePlayers.forEach { IPInfo.cacheFromCloud(it) }
67+
onlinePlayers.forEach { IPInfo.cacheFromCloud(it) }
6468
}
6569

6670
override fun onDisable() {
67-
onlinePlayers.forEach {
68-
nms.removeBossBar(it)
69-
}
7071
Bukkit.getMessenger().unregisterOutgoingPluginChannel(bukkitPlugin)
7172
}
7273

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
package io.github.itsflicker.itstools.api
22

3-
import org.bukkit.boss.BarColor
4-
import org.bukkit.boss.BarStyle
53
import org.bukkit.entity.LivingEntity
6-
import org.bukkit.entity.Player
7-
import taboolib.module.chat.ComponentText
84

95
/**
106
* NMS
@@ -28,16 +24,4 @@ abstract class NMS {
2824
followingTargetEvenIfNotSeen: Boolean = false
2925
)
3026

31-
abstract fun sendResourcePack(player: Player, url: String, hash: String)
32-
33-
abstract fun addBossBar(player: Player, name: ComponentText, color: BarColor, style: BarStyle)
34-
35-
abstract fun removeBossBar(player: Player)
36-
37-
abstract fun updateBossBar(player: Player, progress: Float)
38-
39-
abstract fun updateBossBar(player: Player, name: ComponentText)
40-
41-
abstract fun updateBossBar(player: Player, color: BarColor)
42-
4327
}
Lines changed: 20 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package io.github.itsflicker.itstools.api
22

33
import net.minecraft.network.chat.IChatBaseComponent
4-
import net.minecraft.network.protocol.game.PacketPlayOutBoss
5-
import net.minecraft.server.level.BossBattleServer
6-
import net.minecraft.world.BossBattle
74
import net.minecraft.world.entity.EntityCreature
85
import net.minecraft.world.entity.EntityInsentient
96
import net.minecraft.world.entity.EntityLiving
@@ -15,22 +12,17 @@ import net.minecraft.world.entity.ai.goal.PathfinderGoal
1512
import net.minecraft.world.entity.ai.goal.PathfinderGoalMeleeAttack
1613
import net.minecraft.world.entity.ai.goal.target.PathfinderGoalHurtByTarget
1714
import net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget
18-
import org.bukkit.boss.BarColor
19-
import org.bukkit.boss.BarStyle
20-
import org.bukkit.craftbukkit.v1_20_R2.CraftServer
21-
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftEntity
22-
import org.bukkit.craftbukkit.v1_20_R2.util.CraftChatMessage
15+
import org.bukkit.craftbukkit.v1_20_R3.CraftServer
16+
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity
17+
import org.bukkit.craftbukkit.v1_20_R3.util.CraftChatMessage
2318
import org.bukkit.entity.LivingEntity
24-
import org.bukkit.entity.Player
2519
import taboolib.common.platform.function.warning
2620
import taboolib.library.reflex.Reflex.Companion.getProperty
2721
import taboolib.library.reflex.Reflex.Companion.invokeMethod
2822
import taboolib.library.reflex.Reflex.Companion.setProperty
2923
import taboolib.module.ai.pathfinderExecutor
3024
import taboolib.module.chat.ComponentText
31-
import taboolib.module.nms.MinecraftVersion
3225
import taboolib.module.nms.nmsClass
33-
import taboolib.module.nms.sendPacket
3426

3527
/**
3628
* NMSImpl
@@ -42,7 +34,21 @@ import taboolib.module.nms.sendPacket
4234
@Suppress("unused")
4335
class NMSImpl : NMS() {
4436

45-
lateinit var bossBarCache: BossBattle
37+
private fun craftChatMessageFromComponent(component: ComponentText): IChatBaseComponent {
38+
return CraftChatMessage.fromJSON(component.toRawMessage())
39+
}
40+
41+
private fun LivingEntity.getEntityInsentient(): EntityInsentient? {
42+
return pathfinderExecutor.getEntityInsentient(this) as? EntityInsentient
43+
}
44+
45+
private fun addGoalAi(entity: LivingEntity, priority: Int, pathfinderGoal: Any) {
46+
entity.getEntityInsentient()?.goalSelector?.addGoal(priority, pathfinderGoal as PathfinderGoal)
47+
}
48+
49+
private fun addTargetAi(entity: LivingEntity, priority: Int, pathfinderGoal: Any) {
50+
entity.getEntityInsentient()?.targetSelector?.addGoal(priority, pathfinderGoal as PathfinderGoal)
51+
}
4652

4753
override fun getTargetEntity(entity: LivingEntity): LivingEntity? {
4854
val entityInsentient = entity.getEntityInsentient() ?: return null
@@ -57,7 +63,8 @@ class NMSImpl : NMS() {
5763
}
5864

5965
override fun makeMeleeHostile(entity: LivingEntity, damage: Double?, speed: Double, priority: Int, type: String, followingTargetEvenIfNotSeen: Boolean) {
60-
val entityInsentient = entity.getEntityInsentient() ?: return warning("${entity.type} is not EntityInsentient.")
66+
val entityInsentient = entity.getEntityInsentient()
67+
?: return warning("${entity.type} is not EntityInsentient.")
6168
if (damage != null) {
6269
val map = entityInsentient.invokeMethod<AttributeMapBase>("getAttributes")!!
6370
// add generic:attack_damage attribute
@@ -74,63 +81,4 @@ class NMSImpl : NMS() {
7481
addTargetAi(entity, 2, PathfinderGoalNearestAttackableTarget(entityInsentient, nmsClass(type).asSubclass(EntityLiving::class.java), true))
7582
}
7683

77-
override fun sendResourcePack(player: Player, url: String, hash: String) {
78-
if (MinecraftVersion.isUniversal) {
79-
// TODO
80-
// player.sendPacket(PacketPlayOutResourcePackSend(url, hash, false, null))
81-
} else {
82-
player.sendPacket(net.minecraft.server.v1_16_R3.PacketPlayOutResourcePackSend(url, hash))
83-
}
84-
}
85-
86-
override fun addBossBar(player: Player, name: ComponentText, color: BarColor, style: BarStyle) {
87-
if (!::bossBarCache.isInitialized) {
88-
bossBarCache = BossBattleServer(
89-
craftChatMessageFromComponent(name),
90-
BossBattle.BarColor.entries[color.ordinal],
91-
BossBattle.BarStyle.entries[style.ordinal]
92-
)
93-
}
94-
player.sendPacket(PacketPlayOutBoss.createAddPacket(bossBarCache))
95-
}
96-
97-
override fun removeBossBar(player: Player) {
98-
if (!::bossBarCache.isInitialized) return
99-
player.sendPacket(PacketPlayOutBoss.createRemovePacket(bossBarCache.id))
100-
}
101-
102-
override fun updateBossBar(player: Player, progress: Float) {
103-
if (!::bossBarCache.isInitialized) return
104-
bossBarCache.progress = progress
105-
player.sendPacket(PacketPlayOutBoss.createUpdateProgressPacket(bossBarCache))
106-
}
107-
108-
override fun updateBossBar(player: Player, name: ComponentText) {
109-
if (!::bossBarCache.isInitialized) return
110-
bossBarCache.setName(craftChatMessageFromComponent(name))
111-
player.sendPacket(PacketPlayOutBoss.createUpdateNamePacket(bossBarCache))
112-
}
113-
114-
override fun updateBossBar(player: Player, color: BarColor) {
115-
if (!::bossBarCache.isInitialized) return
116-
bossBarCache.setColor(BossBattle.BarColor.entries[color.ordinal])
117-
player.sendPacket(PacketPlayOutBoss.createUpdateStylePacket(bossBarCache))
118-
}
119-
120-
private fun craftChatMessageFromComponent(component: ComponentText): IChatBaseComponent {
121-
return CraftChatMessage.fromJSON(component.toRawMessage())
122-
}
123-
124-
private fun LivingEntity.getEntityInsentient(): EntityInsentient? {
125-
return pathfinderExecutor.getEntityInsentient(this) as? EntityInsentient
126-
}
127-
128-
private fun addGoalAi(entity: LivingEntity, priority: Int, pathfinderGoal: Any) {
129-
entity.getEntityInsentient()?.goalSelector?.addGoal(priority, pathfinderGoal as PathfinderGoal)
130-
}
131-
132-
private fun addTargetAi(entity: LivingEntity, priority: Int, pathfinderGoal: Any) {
133-
entity.getEntityInsentient()?.targetSelector?.addGoal(priority, pathfinderGoal as PathfinderGoal)
134-
}
135-
13684
}

src/main/kotlin/io/github/itsflicker/itstools/module/ai/BoatingAi.kt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package io.github.itsflicker.itstools.module.ai
22

33
import org.bukkit.entity.Boat
44
import org.bukkit.entity.LivingEntity
5-
import org.bukkit.entity.Minecart
65
import org.bukkit.util.Vector
76
import taboolib.library.reflex.Reflex.Companion.getProperty
87
import taboolib.module.ai.SimpleAi
@@ -11,21 +10,10 @@ import kotlin.properties.Delegates
1110

1211
class BoatingAi(val entity: LivingEntity) : SimpleAi() {
1312

14-
private val empty = Vector()
15-
1613
private var current: Vector? by Delegates.observable(null) { _, oldValue, newValue ->
17-
if (oldValue == newValue && entity.vehicle?.velocity != empty) {
14+
if (oldValue == newValue) {
1815
return@observable
1916
}
20-
// if (newValue != null) {
21-
// InstantVector.useToVanilla(
22-
// entity.vehicle!!,
23-
// newValue.x - entity.vehicle!!.location.x,
24-
// newValue.y - entity.vehicle!!.location.y + 0.5,
25-
// newValue.z - entity.vehicle!!.location.z,
26-
// (newValue.distance(entity.vehicle!!.location.toVector()) / 2 * 20).toLong()
27-
// )
28-
// }
2917
}
3018

3119
override fun startTask() {
@@ -37,7 +25,7 @@ class BoatingAi(val entity: LivingEntity) : SimpleAi() {
3725
}
3826

3927
override fun shouldExecute(): Boolean {
40-
return entity.vehicle is Boat || entity.vehicle is Minecart
28+
return entity.vehicle is Boat
4129
}
4230

4331
override fun continueExecute(): Boolean {

src/main/kotlin/io/github/itsflicker/itstools/module/ai/EncircleAi.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import kotlin.math.PI
88

99
class EncircleAi(
1010
val entity: LivingEntity,
11-
val distanceSqr: Double = 9.0,
11+
val distance: Double = 3.0,
1212
val speed: Double = 1.0
1313
) : SimpleAi() {
1414

1515
override fun shouldExecute(): Boolean {
1616
val target = nms.getTargetEntity(entity) ?: return false
17-
return entity.location.distanceSquared(target.location) <= distanceSqr
17+
return entity.location.distance(target.location) <= distance
1818
}
1919

2020
override fun startTask() {

src/main/kotlin/io/github/itsflicker/itstools/module/command/CommandOperation.kt

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.github.itsflicker.itstools.module.command
22

33
import com.google.common.cache.Cache
44
import com.google.common.cache.CacheBuilder
5+
import io.github.itsflicker.itstools.module.ai.EncircleAi
56
import io.github.itsflicker.itstools.module.feature.DebugItem
67
import io.github.itsflicker.itstools.util.nms
78
import org.bukkit.Bukkit
@@ -14,10 +15,7 @@ import taboolib.common.platform.command.*
1415
import taboolib.common5.Demand
1516
import taboolib.expansion.createHelper
1617
import taboolib.library.reflex.Reflex.Companion.invokeMethod
17-
import taboolib.module.ai.getGoalAi
18-
import taboolib.module.ai.getTargetAi
19-
import taboolib.module.ai.removeGoalAi
20-
import taboolib.module.ai.removeTargetAi
18+
import taboolib.module.ai.*
2119
import java.util.*
2220
import java.util.concurrent.TimeUnit
2321
import java.util.function.Consumer
@@ -121,6 +119,26 @@ object CommandOperation {
121119
}
122120
}
123121

122+
@CommandBody(permission = "itstools.command.cleargoal", optional = true)
123+
val cleargoal = subCommand {
124+
execute<Player> { sender, _, _ ->
125+
cacheOperations.put(sender.uniqueId) {
126+
it.clearGoalAi()
127+
}
128+
sender.sendMessage("§cClick an entity in the next 10 seconds.")
129+
}
130+
}
131+
132+
@CommandBody(permission = "itstools.command.cleartarget", optional = true)
133+
val cleartarget = subCommand {
134+
execute<Player> { sender, _, _ ->
135+
cacheOperations.put(sender.uniqueId) {
136+
it.clearTargetAi()
137+
}
138+
sender.sendMessage("§cClick an entity in the next 10 seconds.")
139+
}
140+
}
141+
124142
@CommandBody(permission = "itstools.command.getgoal", optional = true)
125143
val getgoal = subCommand {
126144
execute<Player> { sender, _, _ ->
@@ -178,15 +196,19 @@ object CommandOperation {
178196
// }
179197
// }
180198

181-
// @CommandBody(permission = "admin", optional = true)
182-
// val test = subCommand {
183-
// execute<Player> { sender, _, _ ->
184-
// cacheOperations.put(sender.uniqueId) {
185-
// it.addGoalAi(BoatingAi(it), 1)
186-
// }
187-
// sender.sendMessage("§cClick an entity in the next 10 seconds.")
188-
// }
189-
// }
199+
@CommandBody(permission = "admin", optional = true)
200+
val test = subCommand {
201+
dynamic("distance") {
202+
dynamic("speed") {
203+
execute<Player> { sender, ctx, _ ->
204+
cacheOperations.put(sender.uniqueId) {
205+
it.addGoalAi(EncircleAi(it, ctx.double("distance"), ctx.double("speed")), 1)
206+
}
207+
sender.sendMessage("§cClick an entity in the next 10 seconds.")
208+
}
209+
}
210+
}
211+
}
190212

191213
@CommandBody
192214
val main = mainCommand {

0 commit comments

Comments
 (0)