Skip to content

Commit 2fe0db7

Browse files
committed
Sorted methods in PermissionsCommands.
1 parent 76ef4fe commit 2fe0db7

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

src/main/kotlin/com/mairwunnx/projectessentialspermissions/commands/PermissionsCommand.kt

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,56 @@ internal object PermissionsCommand {
158158
)
159159
}
160160

161+
private fun groupCommandExecute(c: CommandContext<CommandSource>): Int {
162+
if (c.isPlayerSender() &&
163+
!PermissionsAPI.hasPermission(c.playerName(), "ess.perm.group")
164+
) {
165+
sendMsg(c.source, "perm.group.restricted")
166+
return 0
167+
}
168+
when {
169+
c.isPlayerSender() -> sendMsg(c.source, "perm.group.example")
170+
else -> logger.info("Usage example: /ess permissions group <group> [set|remove] <node>")
171+
}
172+
return 0
173+
}
174+
175+
private fun groupCommandSetExecute(c: CommandContext<CommandSource>): Int {
176+
if (c.isPlayerSender() &&
177+
!PermissionsAPI.hasPermission(c.playerName(), "ess.perm.group")
178+
) {
179+
sendMsg(c.source, "perm.group.restricted")
180+
return 0
181+
}
182+
val targetGroup = StringArgumentType.getString(c, "name")
183+
val targetNode = StringArgumentType.getString(c, "node")
184+
PermissionsAPI.setGroupPermissionNode(targetGroup, targetNode)
185+
if (c.isPlayerSender()) {
186+
sendMsg(c.source, "perm.group.success", targetNode, targetGroup)
187+
} else {
188+
logger.info("Permission $targetNode added to group $targetGroup.")
189+
}
190+
return 0
191+
}
192+
193+
private fun groupCommandRemoveExecute(c: CommandContext<CommandSource>): Int {
194+
if (c.isPlayerSender() &&
195+
!PermissionsAPI.hasPermission(c.playerName(), "ess.perm.group")
196+
) {
197+
sendMsg(c.source, "perm.group.restricted")
198+
return 0
199+
}
200+
val targetGroup = StringArgumentType.getString(c, "name")
201+
val targetNode = StringArgumentType.getString(c, "node")
202+
PermissionsAPI.removeGroupPermission(targetGroup, targetNode)
203+
if (c.isPlayerSender()) {
204+
sendMsg(c.source, "perm.group.remove.success", targetNode, targetGroup)
205+
} else {
206+
logger.info("Permission $targetNode removed from group $targetGroup.")
207+
}
208+
return 0
209+
}
210+
161211
private fun buildUserCommand(): LiteralArgumentBuilder<CommandSource> {
162212
return Commands.literal("user").executes {
163213
return@executes userCommandExecute(it)
@@ -203,20 +253,6 @@ internal object PermissionsCommand {
203253
)
204254
}
205255

206-
private fun groupCommandExecute(c: CommandContext<CommandSource>): Int {
207-
if (c.isPlayerSender() &&
208-
!PermissionsAPI.hasPermission(c.playerName(), "ess.perm.group")
209-
) {
210-
sendMsg(c.source, "perm.group.restricted")
211-
return 0
212-
}
213-
when {
214-
c.isPlayerSender() -> sendMsg(c.source, "perm.group.example")
215-
else -> logger.info("Usage example: /ess permissions group <group> [set|remove] <node>")
216-
}
217-
return 0
218-
}
219-
220256
private fun userCommandExecute(c: CommandContext<CommandSource>): Int {
221257
if (c.isPlayerSender() &&
222258
!PermissionsAPI.hasPermission(c.playerName(), "ess.perm.user")
@@ -233,24 +269,6 @@ internal object PermissionsCommand {
233269
return 0
234270
}
235271

236-
private fun groupCommandSetExecute(c: CommandContext<CommandSource>): Int {
237-
if (c.isPlayerSender() &&
238-
!PermissionsAPI.hasPermission(c.playerName(), "ess.perm.group")
239-
) {
240-
sendMsg(c.source, "perm.group.restricted")
241-
return 0
242-
}
243-
val targetGroup = StringArgumentType.getString(c, "name")
244-
val targetNode = StringArgumentType.getString(c, "node")
245-
PermissionsAPI.setGroupPermissionNode(targetGroup, targetNode)
246-
if (c.isPlayerSender()) {
247-
sendMsg(c.source, "perm.group.success", targetNode, targetGroup)
248-
} else {
249-
logger.info("Permission $targetNode added to group $targetGroup.")
250-
}
251-
return 0
252-
}
253-
254272
private fun userCommandSetExecute(c: CommandContext<CommandSource>): Int {
255273
if (c.isPlayerSender() &&
256274
!PermissionsAPI.hasPermission(c.playerName(), "ess.perm.user")
@@ -296,24 +314,6 @@ internal object PermissionsCommand {
296314
return 0
297315
}
298316

299-
private fun groupCommandRemoveExecute(c: CommandContext<CommandSource>): Int {
300-
if (c.isPlayerSender() &&
301-
!PermissionsAPI.hasPermission(c.playerName(), "ess.perm.group")
302-
) {
303-
sendMsg(c.source, "perm.group.restricted")
304-
return 0
305-
}
306-
val targetGroup = StringArgumentType.getString(c, "name")
307-
val targetNode = StringArgumentType.getString(c, "node")
308-
PermissionsAPI.removeGroupPermission(targetGroup, targetNode)
309-
if (c.isPlayerSender()) {
310-
sendMsg(c.source, "perm.group.remove.success", targetNode, targetGroup)
311-
} else {
312-
logger.info("Permission $targetNode removed from group $targetGroup.")
313-
}
314-
return 0
315-
}
316-
317317
private fun userCommandRemoveExecute(c: CommandContext<CommandSource>): Int {
318318
if (c.isPlayerSender() &&
319319
!PermissionsAPI.hasPermission(c.playerName(), "ess.perm.user")

0 commit comments

Comments
 (0)