Skip to content

Commit

Permalink
Add extra argument node for the purge command to specify an older tha…
Browse files Browse the repository at this point in the history
…n days parameter
  • Loading branch information
ArkoSammy12 committed Jul 25, 2024
1 parent dcba4fc commit 1cb4db6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Se

@Shadow public abstract OptionalInt openHandledScreen(@Nullable NamedScreenHandlerFactory factory);

@Shadow public abstract boolean shouldDamagePlayer(PlayerEntity player);

@Shadow @Final public MinecraftServer server;

@Shadow public abstract void sendMessage(Text message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ object DatabaseCommands {
}
.build()

val purgeDaysArgumentNode: ArgumentCommandNode<ServerCommandSource, Int> = CommandManager
.argument("entriesOlderThanDays", IntegerArgumentType.integer(1))
.requires { src -> src.hasPermissionLevel(4) }
.executes { ctx ->
val player: ServerPlayerEntity = ctx.source.playerOrThrow
val olderThanDaysValue: Int = IntegerArgumentType.getInteger(ctx, "entriesOlderThanDays")
player.sendMessage(Text.literal("Initiating purge...").formatted(Formatting.GRAY))
val deletedRows: Int = PublicEnderChest.DATABASE_MANAGER.purge(player.server, olderThanDaysValue)
val deletedRowsText: MutableText = Text.literal("$deletedRows").formatted(Formatting.AQUA)
player.sendMessage(Text.empty().append(Text.literal("Purged ")).append(deletedRowsText).append(Text.literal(" entries from the Public Ender Chest inventory database.")))
Command.SINGLE_SUCCESS
}
.build()

val pageNode: LiteralCommandNode<ServerCommandSource> = CommandManager
.literal("page")
.requires { src -> src.hasPermissionLevel(4) }
Expand Down Expand Up @@ -153,6 +167,7 @@ object DatabaseCommands {
rootNode.addChild(databaseNode)

databaseNode.addChild(purgeNode)
purgeNode.addChild(purgeDaysArgumentNode)

databaseNode.addChild(queryNode)

Expand Down

0 comments on commit 1cb4db6

Please sign in to comment.