diff --git a/src/main/java/xd/arkosammy/publicenderchest/mixin/ServerPlayerEntityMixin.java b/src/main/java/xd/arkosammy/publicenderchest/mixin/ServerPlayerEntityMixin.java index 53d6774..1456464 100644 --- a/src/main/java/xd/arkosammy/publicenderchest/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/xd/arkosammy/publicenderchest/mixin/ServerPlayerEntityMixin.java @@ -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); diff --git a/src/main/kotlin/xd/arkosammy/publicenderchest/commands/DatabaseCommands.kt b/src/main/kotlin/xd/arkosammy/publicenderchest/commands/DatabaseCommands.kt index 4da7752..569f013 100644 --- a/src/main/kotlin/xd/arkosammy/publicenderchest/commands/DatabaseCommands.kt +++ b/src/main/kotlin/xd/arkosammy/publicenderchest/commands/DatabaseCommands.kt @@ -43,6 +43,20 @@ object DatabaseCommands { } .build() + val purgeDaysArgumentNode: ArgumentCommandNode = 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 = CommandManager .literal("page") .requires { src -> src.hasPermissionLevel(4) } @@ -153,6 +167,7 @@ object DatabaseCommands { rootNode.addChild(databaseNode) databaseNode.addChild(purgeNode) + purgeNode.addChild(purgeDaysArgumentNode) databaseNode.addChild(queryNode)