Skip to content

Commit 46ea82b

Browse files
committed
[1.2.3] Update
1 parent 60d63d6 commit 46ea82b

1 file changed

Lines changed: 26 additions & 28 deletions

File tree

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

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ 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.BoatingAi
65
import io.github.itsflicker.itstools.module.feature.DebugItem
76
import io.github.itsflicker.itstools.util.nms
87
import org.bukkit.Bukkit
9-
import org.bukkit.NamespacedKey
108
import org.bukkit.entity.LivingEntity
119
import org.bukkit.entity.Player
1210
import org.bukkit.potion.PotionEffect
@@ -15,7 +13,10 @@ import taboolib.common.platform.command.*
1513
import taboolib.common5.Demand
1614
import taboolib.expansion.createHelper
1715
import taboolib.library.reflex.Reflex.Companion.invokeMethod
18-
import taboolib.module.ai.*
16+
import taboolib.module.ai.getGoalAi
17+
import taboolib.module.ai.getTargetAi
18+
import taboolib.module.ai.removeGoalAi
19+
import taboolib.module.ai.removeTargetAi
1920
import java.util.*
2021
import java.util.concurrent.TimeUnit
2122
import java.util.function.Consumer
@@ -34,17 +35,15 @@ object CommandOperation {
3435
.expireAfterWrite(10, TimeUnit.SECONDS)
3536
.build()
3637

37-
@Suppress("Deprecation")
3838
@CommandBody(permission = "itstools.command.addpotion", optional = true)
3939
val addpotion = subCommand {
4040
dynamic("potion") {
4141
suggest {
42-
PotionEffectType.values().map { it.key.toString() }
42+
PotionEffectType.values().map { it.name }
4343
}
4444
execute<Player> { sender, _, argument ->
45-
val key = argument.split(':').let { NamespacedKey(it[0], it[1]) }
4645
cacheOperations.put(sender.uniqueId) {
47-
it.addPotionEffect(PotionEffect(PotionEffectType.getByKey(key)!!, 30 * 20, 0))
46+
it.addPotionEffect(PotionEffect(PotionEffectType.getByName(argument)!!, 30 * 20, 0))
4847
}
4948
sender.sendMessage("§cClick an entity in the next 10 seconds.")
5049
}
@@ -53,15 +52,14 @@ object CommandOperation {
5352
listOf("-d", "-a", "--ambient", "--p", "--i")
5453
}
5554
execute<Player> { sender, context, argument ->
56-
val key = context.argument(-1).split(':').let { NamespacedKey(it[0], it[1]) }
5755
val de = Demand("potion $argument")
5856
val duration = de.get(listOf("duration", "d"), "30")!!.toInt() * 20
5957
val amplifier = de.get(listOf("amplifier", "a"), "1")!!.toInt().minus(1)
6058
val ambient = de.tags.contains("ambient")
6159
val particles = de.tags.contains("p")
6260
val icon = de.tags.contains("i")
6361
cacheOperations.put(sender.uniqueId) {
64-
it.addPotionEffect(PotionEffect(PotionEffectType.getByKey(key)!!, duration, amplifier, ambient, particles, icon))
62+
it.addPotionEffect(PotionEffect(PotionEffectType.getByName(context.argument(-1))!!, duration, amplifier, ambient, particles, icon))
6563
}
6664
sender.sendMessage("§cClick an entity in the next 10 seconds.")
6765
}
@@ -157,6 +155,16 @@ object CommandOperation {
157155
}
158156
}
159157

158+
@CommandBody(permission = "itstools.command.togglegravity", optional = true)
159+
val togglegravity = subCommand {
160+
execute<Player> { sender, _, _ ->
161+
cacheOperations.put(sender.uniqueId) {
162+
it.setGravity(!it.hasGravity())
163+
}
164+
sender.sendMessage("§cClick an entity in the next 10 seconds.")
165+
}
166+
}
167+
160168
// @CommandBody(permission = "itstools.command.getentityuuid", optional = true)
161169
// val getentityuuid = subCommand {
162170
// execute<Player> { sender, _, _ ->
@@ -167,25 +175,15 @@ object CommandOperation {
167175
// }
168176
// }
169177

170-
@CommandBody(permission = "admin", optional = true)
171-
val test = subCommand {
172-
execute<Player> { sender, _, _ ->
173-
cacheOperations.put(sender.uniqueId) {
174-
it.addGoalAi(BoatingAi(it), 1)
175-
}
176-
sender.sendMessage("§cClick an entity in the next 10 seconds.")
177-
}
178-
}
179-
180-
@CommandBody(permission = "admin", optional = true)
181-
val test2 = subCommand {
182-
execute<Player> { sender, _, _ ->
183-
cacheOperations.put(sender.uniqueId) {
184-
it.setGravity(!it.hasGravity())
185-
}
186-
sender.sendMessage("§cClick an entity in the next 10 seconds.")
187-
}
188-
}
178+
// @CommandBody(permission = "admin", optional = true)
179+
// val test = subCommand {
180+
// execute<Player> { sender, _, _ ->
181+
// cacheOperations.put(sender.uniqueId) {
182+
// it.addGoalAi(BoatingAi(it), 1)
183+
// }
184+
// sender.sendMessage("§cClick an entity in the next 10 seconds.")
185+
// }
186+
// }
189187

190188
@CommandBody
191189
val main = mainCommand {

0 commit comments

Comments
 (0)