Skip to content

Commit 85be2d2

Browse files
committed
Migrate UtilCommandsModule to EssentialCommandsModule
1 parent 9ed8c4d commit 85be2d2

File tree

10 files changed

+366
-262
lines changed

10 files changed

+366
-262
lines changed

bukkit/src/main/kotlin/io/github/rothes/esu/bukkit/EsuPluginBukkit.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ class EsuPluginBukkit(
115115
ModuleManager.addModule(NewsModule)
116116
ModuleManager.addModule(OptimizationsModule)
117117
ModuleManager.addModule(SpoofServerSettingsModule)
118-
ModuleManager.addModule(UtilCommandsModule)
119118
ModuleManager.addModule(AutoReloadExtensionPluginsModule)
120119

121120
// Register commands

bukkit/src/main/kotlin/io/github/rothes/esu/bukkit/module/EssentialCommandsModule.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package io.github.rothes.esu.bukkit.module
22

3-
import io.github.rothes.esu.bukkit.module.essencialcommands.Heal
3+
import io.github.rothes.esu.bukkit.module.essencialcommands.*
44
import io.github.rothes.esu.core.configuration.ConfigurationPart
55
import io.github.rothes.esu.core.module.configuration.BaseModuleConfiguration
66

77
object EssentialCommandsModule: BukkitModule<BaseModuleConfiguration, EssentialCommandsModule.ModuleLang>() {
88

99
init {
10-
registerFeature(Heal)
10+
listOf(
11+
ClientLocale, Heal, Ip, IpGroup, Ping, PlayerChunkTickets, TpChunk
12+
).forEach { cmd -> registerFeature(cmd) }
1113
}
1214

1315
override fun onEnable() {}

bukkit/src/main/kotlin/io/github/rothes/esu/bukkit/module/UtilCommandsModule.kt

Lines changed: 0 additions & 257 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.github.rothes.esu.bukkit.module.essencialcommands
2+
3+
import io.github.rothes.esu.bukkit.util.ComponentBukkitUtils.user
4+
import io.github.rothes.esu.core.command.annotation.ShortPerm
5+
import io.github.rothes.esu.core.configuration.data.MessageData
6+
import io.github.rothes.esu.core.configuration.data.MessageData.Companion.message
7+
import io.github.rothes.esu.core.module.CommonFeature
8+
import io.github.rothes.esu.core.module.configuration.FeatureToggle
9+
import io.github.rothes.esu.core.user.User
10+
import io.github.rothes.esu.core.util.ComponentUtils.unparsed
11+
import org.incendo.cloud.annotations.Command
12+
13+
object ClientLocale : CommonFeature<FeatureToggle.DefaultTrue, ClientLocale.Lang>() {
14+
15+
override fun onEnable() {
16+
registerCommands(object {
17+
@Command("clientLocale [player]")
18+
@ShortPerm
19+
fun clientLocale(sender: User, player: User = sender) {
20+
sender.message(lang, { message }, user(player), unparsed("locale", player.clientLocale))
21+
}
22+
})
23+
}
24+
25+
data class Lang(
26+
val message: MessageData = "<pdc><player><pc>'s client locale is <sdc><locale>".message,
27+
)
28+
29+
}

bukkit/src/main/kotlin/io/github/rothes/esu/bukkit/module/essencialcommands/Heal.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ object Heal : CommonFeature<FeatureToggle.DefaultTrue, Heal.Lang>() {
3131
player.heal(player.getAttribute(AttributeAdapter.MAX_HEALTH)!!.value)
3232
sender.message(lang, { healedPlayer }, player(player))
3333
if (!silent) {
34-
player.user.message(lang, { healed })
34+
player.user.message(lang, { healedSelf })
3535
}
3636
}
3737
})
3838
}
3939

4040
data class Lang(
41-
val healed: MessageData = "<pc>You have been healed.".message,
41+
val healedSelf: MessageData = "<pc>You have been healed.".message,
4242
val healedPlayer: MessageData = "<pc>Healed <pdc><player></pc>.".message,
4343
)
4444
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package io.github.rothes.esu.bukkit.module.essencialcommands
2+
3+
import io.github.rothes.esu.bukkit.user.PlayerUser
4+
import io.github.rothes.esu.bukkit.util.ComponentBukkitUtils.player
5+
import io.github.rothes.esu.core.command.annotation.ShortPerm
6+
import io.github.rothes.esu.core.configuration.data.MessageData
7+
import io.github.rothes.esu.core.configuration.data.MessageData.Companion.message
8+
import io.github.rothes.esu.core.module.CommonFeature
9+
import io.github.rothes.esu.core.module.configuration.FeatureToggle
10+
import io.github.rothes.esu.core.user.User
11+
import io.github.rothes.esu.core.util.ComponentUtils.unparsed
12+
import org.bukkit.entity.Player
13+
import org.incendo.cloud.annotations.Command
14+
15+
object Ip : CommonFeature<FeatureToggle.DefaultTrue, Ip.Lang>() {
16+
17+
override fun onEnable() {
18+
registerCommands(object {
19+
@Command("ip [player]")
20+
@ShortPerm
21+
fun ip(sender: User, player: Player = (sender as PlayerUser).player) {
22+
sender.message(lang, { message }, player(player), unparsed("address", player.address!!.hostString))
23+
}
24+
})
25+
}
26+
27+
data class Lang(
28+
val message: MessageData = "<pdc><player><pc>'s ip is <sdc><address>".message,
29+
)
30+
31+
}

0 commit comments

Comments
 (0)