Skip to content

Commit d3eb2eb

Browse files
committed
Add feed command
1 parent bbdf030 commit d3eb2eb

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object EssentialCommandsModule: BukkitModule<BaseModuleConfiguration, EssentialC
1010

1111
init {
1212
listOf(
13-
ClientLocale, DimensionTravel, Heal, Ip, IpGroup, Ping, PlayerChunkTickets, Suicide, TpChunk
13+
ClientLocale, DimensionTravel, Feed, Heal, Ip, IpGroup, Ping, PlayerChunkTickets, Suicide, TpChunk
1414
).forEach { cmd -> registerFeature(cmd) }
1515
}
1616

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package io.github.rothes.esu.bukkit.module.essentialcommands
2+
3+
import io.github.rothes.esu.bukkit.user
4+
import io.github.rothes.esu.bukkit.user.PlayerUser
5+
import io.github.rothes.esu.bukkit.util.ComponentBukkitUtils.player
6+
import io.github.rothes.esu.core.command.annotation.ShortPerm
7+
import io.github.rothes.esu.core.configuration.data.MessageData
8+
import io.github.rothes.esu.core.configuration.data.MessageData.Companion.message
9+
import io.github.rothes.esu.core.module.configuration.FeatureToggle
10+
import io.github.rothes.esu.core.user.User
11+
import org.bukkit.entity.Player
12+
import org.incendo.cloud.annotations.Command
13+
import org.incendo.cloud.annotations.Flag
14+
15+
object Feed : BaseCommand<FeatureToggle.DefaultTrue, Feed.Lang>() {
16+
17+
override fun onEnable() {
18+
registerCommands(object {
19+
@Command("feed")
20+
@ShortPerm
21+
fun feed(sender: User) {
22+
val user = sender as PlayerUser
23+
feed(sender, user.player, true)
24+
}
25+
26+
@Command("feed <player>")
27+
@ShortPerm("others")
28+
fun feed(sender: User, player: Player, @Flag("silent") silent: Boolean = sender.uuid != player.uniqueId) {
29+
player.foodLevel = 20
30+
player.saturation = 20.0f // 5.0f on respawn
31+
player.exhaustion = 0.0f
32+
sender.message(lang, { fedPlayer }, player(player))
33+
if (!silent) {
34+
player.user.message(lang, { fed })
35+
}
36+
}
37+
})
38+
}
39+
40+
data class Lang(
41+
val fed: MessageData = "<pc>You have been fed.".message,
42+
val fedPlayer: MessageData = "<pc>Fed <pdc><player></pc>.".message,
43+
)
44+
}

bukkit/src/main/resources/lang/modules/EssentialCommands/lang/zh_cn.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ dimension-travel:
77
heal:
88
healed: <pc>你已被治愈.
99
healed-player: <pc>已治愈 <pdc><player></pc>.
10+
feed:
11+
fed: <pc>你已被喂饱.
12+
fed-player: <pc>已喂饱 <pdc><player></pc>.
1013
ip:
1114
message: <pdc><player><pc> 的IP地址为 <sdc><address>
1215
ip-group:

bukkit/src/main/resources/plugin.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ permissions:
4141
'esu.essentialCommands.dimensionTravel.command.others': true
4242
'esu.essentialCommands.heal.command': true
4343
'esu.essentialCommands.heal.command.others': true
44+
'esu.essentialCommands.feed.command': true
45+
'esu.essentialCommands.feed.command.others': true
4446
'esu.essentialCommands.ip.command': true
4547
'esu.essentialCommands.ipGroup.command': true
4648
'esu.essentialCommands.ping.command': true

0 commit comments

Comments
 (0)