|
1 | 1 | package com.mairwunnx.projectessentials.projectessentialsspawn.commands |
2 | 2 |
|
| 3 | +import com.mairwunnx.projectessentials.projectessentialsspawn.* |
3 | 4 | import com.mairwunnx.projectessentials.projectessentialsspawn.extensions.isPlayerSender |
4 | 5 | import com.mairwunnx.projectessentials.projectessentialsspawn.extensions.sendMsg |
5 | 6 | import com.mairwunnx.projectessentials.projectessentialsspawn.models.SpawnModelBase |
@@ -31,6 +32,10 @@ object SpawnCommand { |
31 | 32 | Commands.literal("save").executes { |
32 | 33 | return@executes save(it) |
33 | 34 | } |
| 35 | + ).then( |
| 36 | + Commands.literal("version").executes { |
| 37 | + return@executes version(it) |
| 38 | + } |
34 | 39 | ) |
35 | 40 | ) |
36 | 41 | } |
@@ -89,19 +94,53 @@ object SpawnCommand { |
89 | 94 | private fun save(c: CommandContext<CommandSource>): Int { |
90 | 95 | if (c.isPlayerSender()) { |
91 | 96 | val playerName = c.source.asPlayer().name.string |
92 | | - if (!PermissionsAPI.hasPermission(playerName, "ess.spawn.reload")) { |
93 | | - sendMsg(c.source, "spawn.reload.restricted") |
| 97 | + if (!PermissionsAPI.hasPermission(playerName, "ess.spawn.save")) { |
| 98 | + sendMsg(c.source, "spawn.save.restricted") |
94 | 99 | return 0 |
95 | 100 | } |
96 | 101 | } |
97 | 102 | SpawnModelBase.saveData() |
98 | 103 | if (c.isPlayerSender()) { |
99 | 104 | val playerName = c.source.asPlayer().name.string |
100 | 105 | logger.info("Executed command \"/${c.input}\" from $playerName") |
101 | | - sendMsg(c.source, "spawn.reload.success") |
| 106 | + sendMsg(c.source, "spawn.save.success") |
102 | 107 | } else { |
103 | 108 | logger.info("World spawn configuration saved.") |
104 | 109 | } |
105 | 110 | return 0 |
106 | 111 | } |
| 112 | + |
| 113 | + private fun version(c: CommandContext<CommandSource>): Int { |
| 114 | + if (c.isPlayerSender()) { |
| 115 | + val playerName = c.source.asPlayer().name.string |
| 116 | + if (!PermissionsAPI.hasPermission(playerName, "ess.spawn.version")) { |
| 117 | + sendMsg(c.source, "spawn.version.restricted") |
| 118 | + return 0 |
| 119 | + } |
| 120 | + } |
| 121 | + if (c.isPlayerSender()) { |
| 122 | + val playerName = c.source.asPlayer().name.string |
| 123 | + sendMsg( |
| 124 | + c.source, |
| 125 | + "spawn.version.success", |
| 126 | + MOD_NAME, |
| 127 | + MOD_VERSION, |
| 128 | + MOD_MAINTAINER, |
| 129 | + MOD_TARGET_FORGE, |
| 130 | + MOD_TARGET_MC, |
| 131 | + MOD_SOURCES_LINK, |
| 132 | + MOD_TELEGRAM_LINK |
| 133 | + ) |
| 134 | + logger.info("Executed command \"/${c.input}\" from $playerName") |
| 135 | + } else { |
| 136 | + logger.info(" $MOD_NAME") |
| 137 | + logger.info("Version: $MOD_VERSION") |
| 138 | + logger.info("Maintainer: $MOD_MAINTAINER") |
| 139 | + logger.info("Target Forge version: $MOD_TARGET_FORGE") |
| 140 | + logger.info("Target Minecraft version: $MOD_TARGET_MC") |
| 141 | + logger.info("Source code: $MOD_SOURCES_LINK") |
| 142 | + logger.info("Telegram chat: $MOD_TELEGRAM_LINK") |
| 143 | + } |
| 144 | + return 0 |
| 145 | + } |
107 | 146 | } |
0 commit comments