From 66c746a7060cb19cbb74f36fb2e8a004dc94c23e Mon Sep 17 00:00:00 2001 From: Drex Date: Sun, 22 Mar 2026 12:05:40 +0100 Subject: [PATCH 1/2] Update to 26.1 [skip ci] blocked by permission api --- .github/workflows/build.yml | 4 +- .github/workflows/release.yml | 4 +- build.gradle.kts | 23 +- detekt.yml | 1137 ++++++++++++----- gradle/wrapper/gradle-wrapper.properties | 2 +- libs.versions.toml | 22 +- .../mixin/AbstractContainerMenuMixin.java | 6 +- .../ledger/mixin/AnvilMenuMixin.java | 4 +- .../mixin/BucketDispenserBehaviorMixin.java | 2 +- .../ledger/mixin/HoeItemMixin.java | 4 +- .../ledger/mixin/HoneycombItemMixin.java | 2 +- ...BlockMixin.java => LilyPadBlockMixin.java} | 6 +- .../ledger/mixin/PortalShapeMixin.java | 2 +- ...lockMixin.java => FarmlandBlockMixin.java} | 6 +- .../ledger/mixin/blocks/SpongeBlockMixin.java | 4 +- ...xin.java => SpreadingSnowyBlockMixin.java} | 6 +- ...in.java => CauldronInteractionsMixin.java} | 10 +- .../cauldron/LayeredCauldronBlockMixin.java | 2 +- .../mixin/blocks/sign/SignBlockMixin.java | 8 +- .../ledger/mixin/entities/ItemFrameMixin.java | 7 +- .../preview/ServerPlayerEntityMixin.java | 4 +- .../github/quiltservertools/ledger/Ledger.kt | 12 +- .../ledger/actions/AbstractActionType.kt | 22 +- .../ledger/actions/ActionType.kt | 10 +- .../ledger/actions/BlockBreakActionType.kt | 8 +- .../ledger/actions/BlockChangeActionType.kt | 50 +- .../ledger/actions/BlockPlaceActionType.kt | 12 +- .../ledger/actions/EntityChangeActionType.kt | 23 +- .../ledger/actions/EntityKillActionType.kt | 2 +- .../ledger/actions/ItemChangeActionType.kt | 9 +- .../ledger/actions/ItemDropActionType.kt | 9 +- .../ledger/actions/ItemPickUpActionType.kt | 9 +- .../ledger/actionutils/ActionFactory.kt | 64 +- .../ledger/actionutils/ActionSearchParams.kt | 6 +- .../ledger/actionutils/Preview.kt | 10 +- .../ledger/actionutils/SearchResults.kt | 2 +- .../ledger/callbacks/BlockBreakCallback.kt | 2 +- .../ledger/callbacks/BlockChangeCallback.kt | 14 +- .../ledger/callbacks/BlockPlaceCallback.kt | 9 +- .../ledger/callbacks/EntityModifyCallback.kt | 2 +- .../ledger/commands/LedgerCommand.kt | 2 +- .../commands/arguments/SearchParamArgument.kt | 27 +- .../commands/parameters/ActionParameter.kt | 4 +- .../commands/parameters/DimensionParameter.kt | 2 +- .../commands/parameters/ObjectParameter.kt | 40 +- .../commands/parameters/RangeParameter.kt | 2 +- .../parameters/RollbackStatusParameter.kt | 2 +- .../commands/parameters/SourceParameter.kt | 4 +- .../commands/parameters/TimeParameter.kt | 2 +- .../commands/subcommands/InspectCommand.kt | 33 +- .../commands/subcommands/PageCommand.kt | 17 +- .../commands/subcommands/PlayerCommand.kt | 6 +- .../commands/subcommands/PreviewCommand.kt | 36 +- .../commands/subcommands/PurgeCommand.kt | 20 +- .../commands/subcommands/RestoreCommand.kt | 28 +- .../commands/subcommands/RollbackCommand.kt | 28 +- .../commands/subcommands/SearchCommand.kt | 20 +- .../commands/subcommands/StatusCommand.kt | 41 +- .../commands/subcommands/TeleportCommand.kt | 35 +- .../config/util/IdentifierSerialization.kt | 6 +- .../ledger/database/DatabaseManager.kt | 184 ++- .../ledger/listeners/BlockEventListener.kt | 12 +- .../listeners/EntityCallbackListener.kt | 22 +- .../ledger/listeners/PlayerEventListener.kt | 42 +- .../ledger/listeners/WorldEventListener.kt | 28 +- .../ledger/network/Networking.kt | 10 +- .../ledger/network/packet/Receiver.kt | 2 +- .../network/packet/action/ActionS2CPacket.kt | 2 +- .../packet/handshake/HandshakeS2CPacket.kt | 2 +- .../packet/receiver/HandshakeC2SPacket.kt | 20 +- .../packet/receiver/InspectC2SPacket.kt | 8 +- .../network/packet/receiver/PurgeC2SPacket.kt | 8 +- .../packet/receiver/RollbackC2SPacket.kt | 6 +- .../packet/receiver/SearchC2SPacket.kt | 14 +- .../network/packet/response/ResponseCodes.kt | 2 +- .../packet/response/ResponseS2CPacket.kt | 2 +- .../ledger/utility/Extensions.kt | 2 +- .../ledger/utility/InspectionManager.kt | 14 +- .../ledger/utility/MessageUtils.kt | 24 +- .../ledger/utility/NbtUtils.kt | 10 +- .../ledger/utility/Negatable.kt | 2 +- .../ledger/utility/PlayerResult.kt | 16 +- .../ledger/utility/TextColorPallet.kt | 8 +- src/main/resources/fabric.mod.json | 3 +- src/main/resources/ledger.mixins.json | 8 +- 85 files changed, 1390 insertions(+), 956 deletions(-) rename src/main/java/com/github/quiltservertools/ledger/mixin/{WaterlilyBlockMixin.java => LilyPadBlockMixin.java} (91%) rename src/main/java/com/github/quiltservertools/ledger/mixin/blocks/{FarmBlockMixin.java => FarmlandBlockMixin.java} (90%) rename src/main/java/com/github/quiltservertools/ledger/mixin/blocks/{SpreadingSnowyDirtBlockMixin.java => SpreadingSnowyBlockMixin.java} (89%) rename src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/{CauldronInteractionMixin.java => CauldronInteractionsMixin.java} (93%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad3b177c..d18fe9fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 21 + - name: Set up JDK 25 uses: actions/setup-java@v4 with: - java-version: 21 + java-version: 25 distribution: 'temurin' - name: Build artifacts run: ./gradlew build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 504dce9e..3d1eec17 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 21 + - name: Set up JDK 25 uses: actions/setup-java@v4 with: - java-version: 21 + java-version: 25 distribution: 'temurin' - name: Build release diff --git a/build.gradle.kts b/build.gradle.kts index 95be69bf..af75bff1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,8 +37,8 @@ loom { } } -fun DependencyHandlerScope.modImplementationAndInclude(dep: Any) { - modImplementation(dep) +fun DependencyHandlerScope.implementationAndInclude(dep: Any) { + implementation(dep) include(dep) } @@ -60,20 +60,19 @@ dependencies { // Fabric minecraft(libs.minecraft) - mappings(loom.officialMojangMappings()) - modImplementation(libs.fabric.loader) + implementation(libs.fabric.loader) // Fabric API - modImplementation(libs.fabric.api) + implementation(libs.fabric.api) // Permissions - modImplementationAndInclude(libs.fabric.permissions) + implementationAndInclude(libs.fabric.permissions) // Translations - modImplementationAndInclude(libs.translations) + implementationAndInclude(libs.translations) // Kotlin - modImplementation(libs.fabric.kotlin) + implementation(libs.fabric.kotlin) // Database includeImplementation(libs.exposed.core) @@ -116,14 +115,14 @@ tasks { } java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 withSourcesJar() } kotlin { compilerOptions { - jvmTarget.set(JvmTarget.JVM_21) + jvmTarget.set(JvmTarget.JVM_25) } } @@ -204,7 +203,7 @@ fun DependencyHandlerScope.handleIncludes(configuration: Configuration) { includeTransitive( configuration.resolvedConfiguration.firstLevelModuleDependencies, configurations.minecraftLibraries.get().resolvedConfiguration.firstLevelModuleDependencies, - configurations.modImplementation.get().resolvedConfiguration.firstLevelModuleDependencies + configurations.runtimeClasspath.get().resolvedConfiguration.firstLevelModuleDependencies .first { it.moduleGroup == "net.fabricmc" && it.moduleName == "fabric-language-kotlin" }, ) } diff --git a/detekt.yml b/detekt.yml index 7834e88d..310cf5ee 100644 --- a/detekt.yml +++ b/detekt.yml @@ -1,131 +1,192 @@ -build: - maxIssues: 0 - excludeCorrectable: true - weights: - # complexity: 2 - # LongParameterList: 1 - # style: 1 - # comments: 1 - config: validation: true - # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' - excludes: '' + warningsAsErrors: false + checkExhaustiveness: false + # when writing own rules with new properties, exclude the property path e.g.: ['my_rule_set', '.*>.*>[my_property]'] + excludes: [] processors: active: true exclude: - 'DetektProgressListener' - - 'FunctionCountProcessor' - - 'PropertyCountProcessor' - - 'ClassCountProcessor' - - 'PackageCountProcessor' - - 'KtFileCountProcessor' + # - 'KtFileCountProcessor' + # - 'PackageCountProcessor' + # - 'ClassCountProcessor' + # - 'FunctionCountProcessor' + # - 'PropertyCountProcessor' + # - 'ProjectComplexityProcessor' + # - 'ProjectCognitiveComplexityProcessor' + # - 'ProjectLLOCProcessor' + # - 'ProjectCLOCProcessor' + # - 'ProjectLOCProcessor' + # - 'ProjectSLOCProcessor' + # - 'LicenseHeaderLoaderExtension' console-reports: active: true exclude: - - 'ProjectStatisticsReport' - - 'NotificationReport' - - 'FileBasedFindingsReport' - -output-reports: - active: true - exclude: - # - 'HtmlOutputReport' - - 'TxtOutputReport' - # - 'XmlOutputReport' + - 'ProjectStatisticsReport' + - 'ComplexityReport' + - 'NotificationReport' + - 'IssuesReport' + - 'FileBasedIssuesReport' + # - 'LiteIssuesReport' comments: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] AbsentOrWrongFileLicense: active: false - licenseTemplateFile: 'license.template' - CommentOverPrivateFunction: + licenseTemplateIsRegex: false + licenseTemplate: '' + DeprecatedBlockTag: active: false - CommentOverPrivateProperty: + DocumentationOverPrivateFunction: + active: false + DocumentationOverPrivateProperty: active: false EndOfSentenceFormat: - active: true + active: false endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' + KDocReferencesNonPublicProperty: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + OutdatedDocumentation: + active: false + matchTypeParameters: true + matchDeclarationsOrder: true + allowParamOnConstructorProperties: false UndocumentedPublicClass: active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] searchInNestedClass: true searchInInnerClass: true searchInInnerObject: true searchInInnerInterface: true + searchInProtectedClass: false + ignoreDefaultCompanionObject: false UndocumentedPublicFunction: active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + searchProtectedFunction: false UndocumentedPublicProperty: active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + searchProtectedProperty: false + ignoreEnumEntries: false complexity: active: true + CognitiveComplexMethod: + active: false + allowedComplexity: 15 ComplexCondition: active: true - threshold: 10 + allowedConditions: 10 ComplexInterface: active: false - threshold: 10 + allowedDefinitions: 10 includeStaticDeclarations: false includePrivateDeclarations: false + ignoreOverloaded: false CyclomaticComplexMethod: active: false - threshold: 15 + allowedComplexity: 14 ignoreSingleWhenExpression: false ignoreSimpleWhenEntries: false ignoreNestingFunctions: false - nestingFunctions: [run, let, apply, with, also, use, forEach, isNotNull, ifNull] + ignoreLocalFunctions: false + nestingFunctions: + - 'also' + - 'apply' + - 'forEach' + - 'isNotNull' + - 'ifNull' + - 'let' + - 'run' + - 'use' + - 'with' LabeledExpression: active: false ignoredLabels: [] LargeClass: - active: false - threshold: 600 + active: true + allowedLines: 600 LongMethod: active: false - threshold: 60 + allowedLines: 60 LongParameterList: - active: false - functionThreshold: 6 - constructorThreshold: 7 + active: true + allowedFunctionParameters: 5 + allowedConstructorParameters: 6 ignoreDefaultParameters: false ignoreDataClasses: true - ignoreAnnotated: [] + ignoreAnnotatedParameter: [] MethodOverloading: active: false - threshold: 6 + allowedOverloads: 6 + NamedArguments: + active: false + allowedArguments: 3 + ignoreMethods: [] + ignoreArgumentsMatchingNames: false NestedBlockDepth: active: false - threshold: 4 + allowedDepth: 4 + NestedScopeFunctions: + active: false + allowedDepth: 1 + functions: + - 'kotlin.apply' + - 'kotlin.run' + - 'kotlin.with' + - 'kotlin.let' + - 'kotlin.also' ReplaceSafeCallChainWithRun: - active: true + active: false StringLiteralDuplication: - active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] - threshold: 5 + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + allowedDuplications: 2 ignoreAnnotation: true - excludeStringsWithLessThan5Characters: true + allowedWithLengthLessThan: 5 ignoreStringsRegex: '$^' TooManyFunctions: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] - thresholdInFiles: 11 - thresholdInClasses: 11 - thresholdInInterfaces: 11 - thresholdInObjects: 11 - thresholdInEnums: 11 + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + allowedFunctionsPerFile: 11 + allowedFunctionsPerClass: 11 + allowedFunctionsPerInterface: 11 + allowedFunctionsPerObject: 11 + allowedFunctionsPerEnum: 11 ignoreDeprecated: false ignorePrivate: false + ignoreInternal: false ignoreOverridden: false + ignoreAnnotatedFunctions: [] coroutines: active: true + CoroutineLaunchedInTestWithoutRunTest: + active: false GlobalCoroutineUsage: + active: false + InjectDispatcher: active: true + dispatcherNames: + - 'IO' + - 'Default' + - 'Unconfined' RedundantSuspendModifier: active: true + SleepInsteadOfDelay: + active: true + SuspendFunInFinallySection: + active: false + SuspendFunSwallowedCancellation: + active: false + SuspendFunWithCoroutineScopeReceiver: + active: false + aliases: ['SuspendFunctionOnCoroutineScope'] SuspendFunWithFlowReturnType: active: true @@ -133,7 +194,7 @@ empty-blocks: active: true EmptyCatchBlock: active: true - allowedExceptionNameRegex: '^(_|(ignore|expected).*)' + allowedExceptionNameRegex: '_|(ignore|expected).*' EmptyClassBlock: active: true EmptyDefaultConstructor: @@ -153,7 +214,7 @@ empty-blocks: active: true EmptyInitBlock: active: true - EmptyKtFile: + EmptyKotlinFile: active: true EmptySecondaryConstructor: active: true @@ -166,14 +227,22 @@ empty-blocks: exceptions: active: true + ErrorUsageWithThrowable: + active: false ExceptionRaisedInUnexpectedLocation: active: true - methodNames: [toString, hashCode, equals, finalize] + methodNames: + - 'equals' + - 'finalize' + - 'hashCode' + - 'toString' InstanceOfCheckForException: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] NotImplementedDeclaration: active: false + ObjectExtendsThrowable: + active: false PrintStackTrace: active: true RethrowCaughtException: @@ -184,244 +253,143 @@ exceptions: SwallowedException: active: false ignoredExceptionTypes: - - InterruptedException - - NumberFormatException - - ParseException - - MalformedURLException - allowedExceptionNameRegex: '^(_|(ignore|expected).*)' + - 'InterruptedException' + - 'MalformedURLException' + - 'NumberFormatException' + - 'ParseException' + allowedExceptionNameRegex: '_|(ignore|expected).*' ThrowingExceptionFromFinally: active: true ThrowingExceptionInMain: - active: true + active: false ThrowingExceptionsWithoutMessageOrCause: active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] exceptions: - - IllegalArgumentException - - IllegalStateException - - IOException + - 'ArrayIndexOutOfBoundsException' + - 'Exception' + - 'IllegalArgumentException' + - 'IllegalMonitorStateException' + - 'IllegalStateException' + - 'IndexOutOfBoundsException' + - 'NullPointerException' + - 'RuntimeException' + - 'Throwable' ThrowingNewInstanceOfSameException: active: true TooGenericExceptionCaught: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] exceptionNames: - - ArrayIndexOutOfBoundsException - - Error - - Exception - - IllegalMonitorStateException - - NullPointerException - - IndexOutOfBoundsException - - RuntimeException - - Throwable - allowedExceptionNameRegex: '^(_|(ignore|expected).*)' + - 'ArrayIndexOutOfBoundsException' + - 'Error' + - 'Exception' + - 'IllegalMonitorStateException' + - 'IndexOutOfBoundsException' + - 'NullPointerException' + - 'RuntimeException' + - 'Throwable' + allowedExceptionNameRegex: '_|(ignore|expected).*' TooGenericExceptionThrown: active: true exceptionNames: - - Error - - Exception - - Throwable - - RuntimeException - -formatting: - active: true - android: false - autoCorrect: true - AnnotationOnSeparateLine: - active: true - autoCorrect: true - AnnotationSpacing: - active: true - autoCorrect: true - ArgumentListWrapping: - active: true - autoCorrect: true - ChainWrapping: - active: true - autoCorrect: true - CommentSpacing: - active: true - autoCorrect: true - EnumEntryNameCase: - active: true - autoCorrect: true - Filename: - active: true - FinalNewline: - active: true - autoCorrect: true - insertFinalNewLine: true - ImportOrdering: - active: true - autoCorrect: true - layout: idea - Indentation: - active: false - autoCorrect: false - indentSize: 4 - MaximumLineLength: - active: true - maxLineLength: 120 - ModifierOrdering: - active: true - autoCorrect: true - MultiLineIfElse: - active: true - autoCorrect: true - NoBlankLineBeforeRbrace: - active: true - autoCorrect: true - NoConsecutiveBlankLines: - active: true - autoCorrect: true - NoEmptyClassBody: - active: true - autoCorrect: true - NoEmptyFirstLineInMethodBlock: - active: true - autoCorrect: true - NoLineBreakAfterElse: - active: true - autoCorrect: true - NoLineBreakBeforeAssignment: - active: true - autoCorrect: true - NoMultipleSpaces: - active: false - autoCorrect: false - NoSemicolons: - active: true - autoCorrect: true - NoTrailingSpaces: - active: true - autoCorrect: true - NoUnitReturn: - active: true - autoCorrect: true - NoUnusedImports: - active: true - autoCorrect: true - NoWildcardImports: - active: false - PackageName: - active: true - autoCorrect: true - ParameterListWrapping: - active: true - autoCorrect: true - indentSize: 4 - SpacingAroundColon: - active: true - autoCorrect: true - SpacingAroundComma: - active: true - autoCorrect: true - SpacingAroundCurly: - active: true - autoCorrect: true - SpacingAroundDot: - active: true - autoCorrect: true - SpacingAroundDoubleColon: - active: true - autoCorrect: true - SpacingAroundKeyword: - active: true - autoCorrect: true - SpacingAroundOperators: - active: true - autoCorrect: true - SpacingAroundParens: - active: true - autoCorrect: true - SpacingAroundRangeOperator: - active: true - autoCorrect: true - SpacingBetweenDeclarationsWithAnnotations: - active: true - autoCorrect: true - SpacingBetweenDeclarationsWithComments: - active: true - autoCorrect: true - StringTemplate: - active: true - autoCorrect: true + - 'Error' + - 'Exception' + - 'RuntimeException' + - 'Throwable' naming: active: true + BooleanPropertyNaming: + active: false + allowedPattern: '^(is|has|are)' ClassNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] - classPattern: '[A-Z$][a-zA-Z0-9$]*' + aliases: ['ClassName'] + classPattern: '[A-Z][a-zA-Z0-9]*' ConstructorParameterNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] parameterPattern: '[a-z][A-Za-z0-9]*' privateParameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' EnumNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] - enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*' + aliases: ['EnumEntryName'] + enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' ForbiddenClassName: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] forbiddenName: [] - FunctionMaxLength: + FunctionNameMaxLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] + aliases: ['FunctionMaxNameLength'] maximumFunctionNameLength: 30 - FunctionMinLength: + FunctionNameMinLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] + aliases: ['FunctionMinNameLength'] minimumFunctionNameLength: 3 FunctionNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] - functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$' + aliases: ['FunctionName'] + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + functionPattern: '[a-z][a-zA-Z0-9]*' excludeClassPattern: '$^' FunctionParameterNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] parameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' - InvalidPackageDeclaration: # If you want to use this, set the root package and enable it + InvalidPackageDeclaration: + active: true + aliases: ['PackageDirectoryMismatch'] + rootPackage: '' + requireRootInDeclaration: false + LambdaParameterNaming: active: false - rootPackage: 'template' + parameterPattern: '[a-z][A-Za-z0-9]*|_' MatchingDeclarationName: active: true mustBeFirst: true + multiplatformTargets: + - 'ios' + - 'android' + - 'js' + - 'jvm' + - 'native' + - 'iosArm64' + - 'iosX64' + - 'macosX64' + - 'mingwX64' + - 'linuxX64' MemberNameEqualsClassName: active: true ignoreOverridden: true - NonBooleanPropertyPrefixedWithIs: + NoNameShadowing: active: true + NonBooleanPropertyPrefixedWithIs: + active: false ObjectPropertyNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] + aliases: ['ObjectPropertyName'] constantPattern: '[A-Za-z][_A-Za-z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' PackageNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] - packagePattern: '^[a-z]+(\.[a-z][A-Za-z0-9]*)*$' + aliases: ['PackageName'] + packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' TopLevelPropertyNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] constantPattern: '[A-Z][_A-Z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' VariableMaxLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] maximumVariableNameLength: 64 VariableMinLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] minimumVariableNameLength: 1 VariableNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] + aliases: ['PropertyName'] variablePattern: '[a-z][A-Za-z0-9]*' privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' @@ -430,33 +398,89 @@ performance: active: true ArrayPrimitive: active: true + CouldBeSequence: + active: false + allowedOperations: 2 ForEachOnRange: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] SpreadOperator: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + UnnecessaryInitOnArray: + active: false + UnnecessaryPartOfBinaryExpression: + active: false UnnecessaryTemporaryInstantiation: active: true + UnnecessaryTypeCasting: + active: false potential-bugs: active: true - Deprecation: + AvoidReferentialEquality: active: true + forbiddenTypePatterns: + - 'kotlin.String' + CastNullableToNonNullableType: + active: false + ignorePlatformTypes: true + CastToNullableType: + active: false + CharArrayToStringCall: + active: false + Deprecation: + active: false + aliases: ['DEPRECATION'] + excludeImportStatements: false + DontDowncastCollectionTypes: + active: false + DoubleMutabilityForCollection: + active: true + aliases: ['DoubleMutability'] + mutableTypes: + - 'kotlin.collections.MutableList' + - 'kotlin.collections.MutableMap' + - 'kotlin.collections.MutableSet' + - 'java.util.ArrayList' + - 'java.util.LinkedHashSet' + - 'java.util.HashSet' + - 'java.util.LinkedHashMap' + - 'java.util.HashMap' + ElseCaseInsteadOfExhaustiveWhen: + active: false + ignoredSubjectTypes: [] EqualsAlwaysReturnsTrueOrFalse: active: true EqualsWithHashCodeExist: active: true + ExitOutsideMain: + active: false ExplicitGarbageCollectionCall: active: true HasPlatformType: active: true IgnoredReturnValue: active: true + restrictToConfig: true + returnValueAnnotations: + - 'CheckResult' + - '*.CheckResult' + - 'CheckReturnValue' + - '*.CheckReturnValue' + ignoreReturnValueAnnotations: + - 'CanIgnoreReturnValue' + - '*.CanIgnoreReturnValue' + returnValueTypes: + - 'kotlin.Function*' + - 'kotlin.sequences.Sequence' + - 'kotlinx.coroutines.flow.*Flow' + - 'java.util.stream.*Stream' + ignoreFunctionCall: [] ImplicitDefaultLocale: - active: false - ImplicitUnitReturnType: active: true + ImplicitUnitReturnType: + active: false allowExplicitReturnType: true InvalidRange: active: true @@ -466,25 +490,52 @@ potential-bugs: active: true LateinitUsage: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] - ignoreAnnotated: [] + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] ignoreOnClassesPattern: '' MapGetWithNotNullAssertionOperator: active: true + MissingPackageDeclaration: + active: false + excludes: ['**/*.kts'] + MissingSuperCall: + active: false + mustInvokeSuperAnnotations: + - 'androidx.annotation.CallSuper' + - 'javax.annotation.OverridingMethodsMustInvokeSuper' + MissingUseCall: + active: false + NullCheckOnMutableProperty: + active: false NullableToStringCall: - active: true + active: false + PropertyUsedBeforeDeclaration: + active: false UnconditionalJumpStatementInLoop: - active: true + active: false + UnnamedParameterUse: + active: false + allowAdjacentDifferentTypeParams: true + allowSingleParamUse: true + ignoreArgumentsMatchingNames: true + ignoreFunctionCall: [] + UnnecessaryNotNullCheck: + active: false UnnecessaryNotNullOperator: active: true UnnecessarySafeCall: active: true + UnreachableCatchBlock: + active: true UnreachableCode: active: true UnsafeCallOnNullableType: active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] UnsafeCast: active: true + aliases: ['UNCHECKED_CAST'] + UnusedUnaryOperator: + active: true UselessPostfixExpression: active: true WrongEqualsTypeParameter: @@ -492,59 +543,137 @@ potential-bugs: style: active: true + AbstractClassCanBeConcreteClass: + active: true + AbstractClassCanBeInterface: + active: true + AlsoCouldBeApply: + active: false + BracesOnIfStatements: + active: false + singleLine: 'never' + multiLine: 'always' BracesOnWhenStatements: - active: true + active: false + singleLine: 'necessary' + multiLine: 'consistent' + CanBeNonNullable: + active: false + CascadingCallWrapping: + active: false + includeElvis: true ClassOrdering: - active: true + active: false CollapsibleIfStatements: - active: true + active: false DataClassContainsFunctions: active: false - conversionFunctionPrefix: ['to'] + conversionFunctionPrefix: + - 'to' + allowOperators: false DataClassShouldBeImmutable: active: false + DestructuringDeclarationWithTooManyEntries: + active: true + maxDestructuringEntries: 3 + DoubleNegativeExpression: + active: false + DoubleNegativeLambda: + active: false + negativeFunctions: + - reason: 'Use `takeIf` instead.' + value: 'takeUnless' + - reason: 'Use `all` instead.' + value: 'none' + negativeFunctionNameParts: + - 'not' + - 'non' EqualsNullCall: active: true EqualsOnSignatureLine: - active: true + active: false ExplicitCollectionElementAccessMethod: + active: false + ExplicitItLambdaMultipleParameters: active: true ExplicitItLambdaParameter: active: true ExpressionBodySyntax: - active: true + active: false includeLineWrapping: false - ForbiddenComment: + ForbiddenAnnotation: active: false - comments: ['TODO:', 'FIXME:', 'STOPSHIP:'] + annotations: + - reason: 'it is a java annotation. Use `Suppress` instead.' + value: 'java.lang.SuppressWarnings' + - reason: 'it is a java annotation. Use `kotlin.Deprecated` instead.' + value: 'java.lang.Deprecated' + - reason: 'it is a java annotation. Use `kotlin.annotation.MustBeDocumented` instead.' + value: 'java.lang.annotation.Documented' + - reason: 'it is a java annotation. Use `kotlin.annotation.Target` instead.' + value: 'java.lang.annotation.Target' + - reason: 'it is a java annotation. Use `kotlin.annotation.Retention` instead.' + value: 'java.lang.annotation.Retention' + - reason: 'it is a java annotation. Use `kotlin.annotation.Repeatable` instead.' + value: 'java.lang.annotation.Repeatable' + - reason: 'Kotlin does not support @Inherited annotation, see https://youtrack.jetbrains.com/issue/KT-22265' + value: 'java.lang.annotation.Inherited' + ForbiddenComment: + active: true + comments: + - reason: 'Forbidden FIXME todo marker in comment, please fix the problem.' + value: 'FIXME:' + - reason: 'Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code.' + value: 'STOPSHIP:' + - reason: 'Forbidden TODO todo marker in comment, please do the changes.' + value: 'TODO:' allowedPatterns: '' ForbiddenImport: active: false - imports: [] - forbiddenPatterns: '' + forbiddenImports: [] + allowedImports: [] ForbiddenMethodCall: + active: false + methods: + - reason: 'print does not allow you to configure the output stream. Use a logger instead.' + value: 'kotlin.io.print' + - reason: 'println does not allow you to configure the output stream. Use a logger instead.' + value: 'kotlin.io.println' + - reason: 'using `BigDecimal(Double)` can result in unexpected floating point precision behavior. Use `BigDecimal.valueOf(Double)` or `String.toBigDecimalOrNull()` instead.' + value: 'java.math.BigDecimal.(kotlin.Double)' + - reason: 'using `BigDecimal(String)` can result in a `NumberFormatException`. Use `String.toBigDecimalOrNull()`' + value: 'java.math.BigDecimal.(kotlin.String)' + - reason: 'It is marked as obsolete. Use `kotlin.time.measureTime` instead.' + value: 'kotlin.system.measureTimeMillis' + ForbiddenNamedParam: active: false methods: [] + ForbiddenOptIn: + active: false + markerClasses: [] + ForbiddenSuppress: + active: false + rules: [] ForbiddenVoid: active: true - ignoreOverridden: true + ignoreOverridden: false ignoreUsageInGenerics: false FunctionOnlyReturningConstant: active: true ignoreOverridableFunction: true - excludedFunctions: ['describeContents'] - ignoreAnnotated: ['dagger.Provides'] - LibraryCodeMustSpecifyReturnType: - active: true - LibraryEntitiesShouldNotBePublic: - active: true + ignoreActualFunction: true + excludedFunctions: [] LoopWithTooManyJumpStatements: active: true - maxJumpCount: 3 + maxJumpCount: 1 MagicNumber: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] - ignoreNumbers: ['-1', '0', '1', '2'] + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts'] + ignoreNumbers: + - '-1' + - '0' + - '1' + - '2' ignoreHashCodeFunction: true ignorePropertyDeclaration: false ignoreLocalVariableDeclaration: false @@ -554,42 +683,62 @@ style: ignoreNamedArgument: true ignoreEnums: true ignoreRanges: false - BracesOnIfStatements: - active: true + ignoreExtensionFunctions: true MandatoryBracesLoops: - active: true + active: false + MaxChainedCallsOnSameLine: + active: false + maxChainedCalls: 5 MaxLineLength: active: true - maxLineLength: 180 + maxLineLength: 120 excludePackageStatements: true excludeImportStatements: true excludeCommentStatements: false - MayBeConst: + excludeRawStrings: true + MayBeConstant: active: true ModifierOrder: active: true + MultilineLambdaItParameter: + active: false + MultilineRawStringIndentation: + active: false + indentSize: 4 + trimmingMethods: + - 'trimIndent' + - 'trimMargin' NestedClassesVisibility: active: true NewLineAtEndOfFile: active: true NoTabs: + active: false + NullableBooleanCheck: + active: false + ObjectLiteralToLambda: active: true OptionalAbstractKeyword: active: true OptionalUnit: active: false - PreferToOverPairSyntax: - active: true ProtectedMemberInFinalClass: active: true + RangeUntilInsteadOfRangeTo: + active: false + RedundantConstructorKeyword: + active: false RedundantExplicitType: + active: false + RedundantHigherOrderMapUsage: active: true - RedundantVisibilityModifierRule: + RedundantVisibilityModifier: active: false ReturnCount: active: false max: 2 - excludedFunctions: ['equals'] + excludedFunctions: + - 'equals' excludeLabeled: false excludeReturnFromLambda: true excludeGuardClauses: false @@ -597,65 +746,469 @@ style: active: true SerialVersionUIDInSerializableClass: active: true - SpacingBetweenPackageAndImports: - active: true + SpacingAfterPackageDeclaration: + active: false + StringShouldBeRawString: + active: false + maxEscapedCharacterCount: 2 + ignoredCharacters: [] ThrowsCount: active: false max: 2 + excludeGuardClauses: false TrailingWhitespace: - active: true + active: false + TrimMultilineRawString: + active: false + trimmingMethods: + - 'trimIndent' + - 'trimMargin' UnderscoresInNumericLiterals: - active: true - acceptableLength: 5 - UnnecessaryAbstractClass: - active: true - ignoreAnnotated: ['dagger.Module'] - UnnecessaryAnnotationUseSiteTarget: - active: true + active: false + acceptableLength: 4 + allowNonStandardGrouping: false + UnnecessaryAny: + active: false UnnecessaryApply: active: true + UnnecessaryBackticks: + active: false + UnnecessaryBracesAroundTrailingLambda: + active: false + UnnecessaryFilter: + active: true + UnnecessaryFullyQualifiedName: + active: false UnnecessaryInheritance: active: true + UnnecessaryInnerClass: + active: false UnnecessaryLet: - active: true + active: false UnnecessaryParentheses: - active: true - UntilInsteadOfRangeTo: - active: true - UnusedImports: - active: true + active: false + allowForUnclearPrecedence: false + UnnecessaryReversed: + active: false + UnusedImport: + active: false + additionalOperatorSet: [] UnusedParameter: active: false + aliases: ['UNUSED_PARAMETER', 'unused'] + allowedNames: 'ignored|expected' UnusedPrivateClass: active: true - UnusedPrivateMember: - active: false - allowedNames: '(_|ignored|expected|serialVersionUID)' - UseArrayLiteralsInAnnotations: + aliases: ['unused'] + UnusedPrivateFunction: + active: true + aliases: ['unused'] + allowedNames: '' + UnusedPrivateProperty: + active: true + aliases: ['unused'] + allowedNames: 'ignored|expected|serialVersionUID' + UnusedVariable: + active: true + aliases: ['UNUSED_VARIABLE', 'unused'] + allowedNames: 'ignored|_' + UseAnyOrNoneInsteadOfFind: + active: true + UseArrayLiteralsInAnnotations: active: true UseCheckNotNull: active: true UseCheckOrError: active: true UseDataClass: - active: true - ignoreAnnotated: [] + active: false allowVars: false UseEmptyCounterpart: - active: true + active: false + UseIfEmptyOrIfBlank: + active: false UseIfInsteadOfWhen: + active: false + ignoreWhenContainingVariableDeclaration: false + UseIsNullOrEmpty: + active: true + UseLet: + active: false + UseOrEmpty: active: true UseRequire: active: true UseRequireNotNull: active: true + UseSumOfInsteadOfFlatMapSize: + active: false UselessCallOnNotNull: active: true UtilityClassWithPublicConstructor: active: true VarCouldBeVal: active: true + aliases: ['CanBeVal'] + ignoreLateinitVar: false WildcardImport: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] - excludeImports: ['java.util.*', 'kotlinx.android.synthetic.*'] + excludeImports: + - 'java.util.*' + +ktlint: + active: true + code_style: 'intellij_idea' + autoCorrect: true + AnnotationOnSeparateLine: + active: true + autoCorrect: true + indentSize: 4 + AnnotationSpacing: + active: true + autoCorrect: true + ArgumentListWrapping: + active: true + autoCorrect: true + indentSize: 4 + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + ignoreRuleParameterThreshold: 8 + BackingPropertyNaming: + active: true + BinaryExpressionWrapping: + active: true + autoCorrect: true + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + indentSize: 4 + BlankLineBeforeDeclaration: + active: false + autoCorrect: true + BlankLineBetweenWhenConditions: + active: true + autoCorrect: true + lineBreakAfterWhenEntries: true + BlockCommentInitialStarAlignment: + active: true + autoCorrect: true + ChainMethodContinuation: + active: false + autoCorrect: true + indentSize: 4 + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + forceMultilineWhenChainOperatorCountGreaterOrEqualThan: 4 + ChainWrapping: + active: true + autoCorrect: true + indentSize: 4 + ClassName: + active: false + ClassSignature: + active: true + autoCorrect: true + indentSize: 4 + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + CommentSpacing: + active: true + autoCorrect: true + CommentWrapping: + active: true + autoCorrect: true + indentSize: 4 + ConditionWrapping: + active: true + autoCorrect: true + indentSize: 4 + ContextReceiverListWrapping: + active: true + autoCorrect: true + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + indentSize: 4 + ContextReceiverMapping: + active: true + autoCorrect: true + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + indentSize: 4 + EnumEntryNameCase: + active: true + aliases: ['EnumEntryName'] + autoCorrect: true + enumEntryNameCasing: 'upper_or_camel_cases' + EnumWrapping: + active: true + autoCorrect: true + indentSize: 4 + ExpressionOperandWrapping: + active: false + autoCorrect: true + indentSize: 4 + Filename: + active: true + FinalNewline: + active: true + autoCorrect: true + insertFinalNewLine: true + FunKeywordSpacing: + active: true + autoCorrect: true + FunctionExpressionBody: + active: true + autoCorrect: true + indentSize: 4 + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + FunctionLiteral: + active: true + autoCorrect: true + indentSize: 4 + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + FunctionName: + active: false + FunctionReturnTypeSpacing: + active: true + autoCorrect: true + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + FunctionSignature: + active: true + autoCorrect: true + forceMultilineWhenParameterCountGreaterOrEqualThan: 2147483647 + functionBodyExpressionWrapping: 'default' + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + indentSize: 4 + FunctionStartOfBodySpacing: + active: true + autoCorrect: true + FunctionTypeModifierSpacing: + active: true + autoCorrect: true + FunctionTypeReferenceSpacing: + active: true + autoCorrect: true + IfElseBracing: + active: false + autoCorrect: true + indentSize: 4 + IfElseWrapping: + active: false + autoCorrect: true + indentSize: 4 + ImportOrdering: + active: true + autoCorrect: true + # layout: If the 'code_style' ruleset property is set to 'android', the default is '*', otherwise '*,java.**,javax.**,kotlin.**,^'. + Indentation: + active: true + autoCorrect: true + indentSize: 4 + indentWhenArrowOnNewLine: false + Kdoc: + active: true + KdocWrapping: + active: true + autoCorrect: true + indentSize: 4 + MaximumLineLength: + active: true + aliases: ['MaxLineLength'] + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + ignoreBackTickedIdentifier: false + MixedConditionOperators: + active: true + ModifierListSpacing: + active: true + autoCorrect: true + indentSize: 4 + ModifierOrdering: + active: true + autoCorrect: true + MultiLineIfElse: + active: true + autoCorrect: true + indentSize: 4 + MultilineExpressionWrapping: + active: false + autoCorrect: true + indentSize: 4 + functionBodyExpressionWrapping: 'multiline' + MultilineLoop: + active: true + autoCorrect: true + indentSize: 4 + NoBlankLineBeforeRbrace: + active: true + autoCorrect: true + NoBlankLineInList: + active: false + autoCorrect: true + NoBlankLinesInChainedMethodCalls: + active: true + autoCorrect: true + NoConsecutiveBlankLines: + active: true + autoCorrect: true + NoConsecutiveComments: + active: false + NoEmptyClassBody: + active: true + autoCorrect: true + NoEmptyFile: + active: true + NoEmptyFirstLineInClassBody: + active: false + autoCorrect: true + indentSize: 4 + NoEmptyFirstLineInMethodBlock: + active: true + autoCorrect: true + NoLineBreakAfterElse: + active: true + autoCorrect: true + NoLineBreakBeforeAssignment: + active: true + autoCorrect: true + NoMultipleSpaces: + active: true + autoCorrect: true + NoSemicolons: + active: true + autoCorrect: true + NoSingleLineBlockComment: + active: false + autoCorrect: true + indentSize: 4 + NoTrailingSpaces: + active: true + autoCorrect: true + NoUnitReturn: + active: true + autoCorrect: true + NoUnusedImports: + active: true + autoCorrect: true + NoWildcardImports: + active: false + packagesToUseImportOnDemandProperty: 'java.util.*,kotlinx.android.synthetic.**' + NullableTypeSpacing: + active: true + autoCorrect: true + PackageName: + active: true + ParameterListSpacing: + active: true + autoCorrect: true + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + ParameterListWrapping: + active: true + autoCorrect: true + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + indentSize: 4 + ParameterWrapping: + active: true + autoCorrect: true + indentSize: 4 + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + PropertyName: + active: true + constantNamingStyle: 'screaming_snake_case' + PropertyWrapping: + active: true + autoCorrect: true + indentSize: 4 + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. + SpacingAroundAngleBrackets: + active: true + autoCorrect: true + SpacingAroundColon: + active: true + autoCorrect: true + SpacingAroundComma: + active: true + autoCorrect: true + SpacingAroundCurly: + active: true + autoCorrect: true + indentSize: 4 + SpacingAroundDot: + active: true + autoCorrect: true + SpacingAroundDoubleColon: + active: true + autoCorrect: true + SpacingAroundKeyword: + active: true + autoCorrect: true + SpacingAroundOperators: + active: true + autoCorrect: true + SpacingAroundParens: + active: true + autoCorrect: true + SpacingAroundRangeOperator: + active: true + autoCorrect: true + SpacingAroundSquareBrackets: + active: true + autoCorrect: true + SpacingAroundUnaryOperator: + active: true + autoCorrect: true + SpacingBetweenDeclarationsWithAnnotations: + active: true + autoCorrect: true + SpacingBetweenDeclarationsWithComments: + active: true + autoCorrect: true + SpacingBetweenFunctionNameAndOpeningParenthesis: + active: true + autoCorrect: true + StatementWrapping: + active: true + autoCorrect: true + indentSize: 4 + StringTemplate: + active: true + autoCorrect: true + StringTemplateIndent: + active: false + autoCorrect: true + indentSize: 4 + ThenSpacing: + active: true + autoCorrect: true + TrailingCommaOnCallSite: + active: true + autoCorrect: true + # useTrailingCommaOnCallSite: If the 'code_style' ruleset property is set to 'android', the default is 'false', otherwise 'true'. + TrailingCommaOnDeclarationSite: + active: true + autoCorrect: true + # useTrailingCommaOnDeclarationSite: If the 'code_style' ruleset property is set to 'android', the default is 'false', otherwise 'true'. + TryCatchFinallySpacing: + active: false + autoCorrect: true + indentSize: 4 + TypeArgumentComment: + active: true + TypeArgumentListSpacing: + active: true + autoCorrect: true + indentSize: 4 + TypeParameterComment: + active: true + TypeParameterListSpacing: + active: true + autoCorrect: true + indentSize: 4 + UnnecessaryParenthesesBeforeTrailingLambda: + active: true + autoCorrect: true + ValueArgumentComment: + active: true + ValueParameterComment: + active: true + WhenEntryBracing: + active: false + autoCorrect: true + indentSize: 4 + Wrapping: + active: true + autoCorrect: true + indentSize: 4 + # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 23449a2b..c61a118f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/libs.versions.toml b/libs.versions.toml index 97e256c1..32c7b34b 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -1,23 +1,23 @@ [versions] -minecraft = "1.21.11" -fabric-loader = "0.18.1" +minecraft = "26.1-rc-2" +fabric-loader = "0.18.4" -fabric-api = "0.139.4+1.21.11" +fabric-api = "0.143.15+26.1" # Kotlin -kotlin = "2.2.0" +kotlin = "2.3.10" # Also modrinth version in gradle.properties -fabric-kotlin = "1.13.4+kotlin.2.2.0" +fabric-kotlin = "1.13.9+kotlin.2.3.10" -fabric-permissions = "0.6.1" -translations = "2.5.2+1.21.9-pre3" +fabric-permissions = "0.6.3-SNAPSHOT" +translations = "3.0.0+26.1-pre-3" exposed = "1.0.0-rc-2" sqlite-jdbc = "3.50.3.0" konf = "1.1.2" -detekt = "1.23.8" +detekt = "2.0.0-alpha.2" [libraries] minecraft = { module = "net.minecraft:minecraft", version.ref = "minecraft" } @@ -38,10 +38,10 @@ sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "sqlite-jdbc" } konf-core = { module = "com.uchuhimo:konf-core", version.ref = "konf"} konf-toml = { module = "com.uchuhimo:konf-toml", version.ref = "konf"} -detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" } +detekt-formatting = { module = "dev.detekt:detekt-rules-ktlint-wrapper", version.ref = "detekt" } [plugins] kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } -loom = { id = "fabric-loom", version = "1.14.+" } +detekt = { id = "dev.detekt", version.ref = "detekt" } +loom = { id = "net.fabricmc.fabric-loom", version = "1.15.+" } git_hooks = { id = "com.github.jakemarsden.git-hooks", version = "0.0.2" } diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/AbstractContainerMenuMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/AbstractContainerMenuMixin.java index 700fbc2b..10873e8b 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/AbstractContainerMenuMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/AbstractContainerMenuMixin.java @@ -12,11 +12,11 @@ import java.util.Map; import net.minecraft.world.entity.player.Player; import net.minecraft.world.Container; +import net.minecraft.world.inventory.ContainerInput; import net.minecraft.world.item.ItemStack; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.Slot; -import net.minecraft.world.inventory.ClickType; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerLevel; import net.minecraft.core.BlockPos; @@ -50,12 +50,12 @@ private void ledgerButtonClickGetPlayer(Player player, int id, CallbackInfoRetur } @Inject(method = "doClick", at = @At(value = "HEAD")) - private void internalOnSlotClickGetPlayer(int slotIndex, int button, ClickType actionType, Player player, CallbackInfo ci) { + private void internalOnSlotClickGetPlayer(int slotIndex, int button, ContainerInput containerInput, Player player, CallbackInfo ci) { this.player = (ServerPlayer) player; } @Inject(method = "clicked", at = @At(value = "HEAD")) - private void ledgerSlotClickGetPlayer(int slotIndex, int button, ClickType actionType, Player player, CallbackInfo ci) { + private void ledgerSlotClickGetPlayer(int slotIndex, int button, ContainerInput containerInput, Player player, CallbackInfo ci) { this.player = (ServerPlayer) player; } diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/AnvilMenuMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/AnvilMenuMixin.java index 8bd9ad1d..6678db98 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/AnvilMenuMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/AnvilMenuMixin.java @@ -18,7 +18,7 @@ @Mixin(AnvilMenu.class) public abstract class AnvilMenuMixin { - @Inject(method = "method_24922", + @Inject(method = "lambda$onTake$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;removeBlock(Lnet/minecraft/core/BlockPos;Z)Z")) private static void ledgerLogAnvilBreak(Player player, Level world, BlockPos pos, CallbackInfo ci) { @@ -31,7 +31,7 @@ private static void ledgerLogAnvilBreak(Player player, Level world, BlockPos pos player); } - @ModifyArgs(method = "method_24922", + @ModifyArgs(method = "lambda$onTake$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) private static void ledgerLogAnvilChange(Args args, Player player, Level world, BlockPos pos) { diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/BucketDispenserBehaviorMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/BucketDispenserBehaviorMixin.java index c6548a85..179b331f 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/BucketDispenserBehaviorMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/BucketDispenserBehaviorMixin.java @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(targets = "net.minecraft.core.dispenser.DispenseItemBehavior$5") +@Mixin(targets = "net.minecraft.core.dispenser.DispenseItemBehavior$4") public abstract class BucketDispenserBehaviorMixin extends DefaultDispenseItemBehavior { @Inject( diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/HoeItemMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/HoeItemMixin.java index efaba6da..e0caf510 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/HoeItemMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/HoeItemMixin.java @@ -15,12 +15,12 @@ @Mixin(HoeItem.class) public abstract class HoeItemMixin { // These unmapped methods are lambda expressions used by the game for hoe uses - @Inject(method = "method_36984", at = @At("HEAD")) + @Inject(method = "lambda$changeIntoState$0", at = @At("HEAD")) private static void logHoeInteraction(BlockState state, UseOnContext context, CallbackInfo ci) { log(state, context); } - @Inject(method = "method_36986", at = @At("HEAD")) + @Inject(method = "lambda$changeIntoStateAndDropItem$0", at = @At("HEAD")) private static void logHoeInteraction(BlockState state, ItemLike itemConvertible, UseOnContext context, CallbackInfo ci) { log(state, context); } diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/HoneycombItemMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/HoneycombItemMixin.java index 18d1ca81..a405605e 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/HoneycombItemMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/HoneycombItemMixin.java @@ -16,7 +16,7 @@ @Mixin(HoneycombItem.class) public abstract class HoneycombItemMixin { - @ModifyArgs(method = "method_34719", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) + @ModifyArgs(method = "lambda$useOn$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) private static void logCopperWaxing(Args args, @Local Level world, @Local Player player) { BlockPos pos = args.get(0); BlockState oldState = world.getBlockState(pos); diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/WaterlilyBlockMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBlockMixin.java similarity index 91% rename from src/main/java/com/github/quiltservertools/ledger/mixin/WaterlilyBlockMixin.java rename to src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBlockMixin.java index 64e3e0cd..96e13e18 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/WaterlilyBlockMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBlockMixin.java @@ -2,8 +2,8 @@ import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback; import com.github.quiltservertools.ledger.utility.Sources; +import net.minecraft.world.level.block.LilyPadBlock; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.WaterlilyBlock; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.InsideBlockEffectApplier; import net.minecraft.world.entity.player.Player; @@ -14,8 +14,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(WaterlilyBlock.class) -public abstract class WaterlilyBlockMixin { +@Mixin(LilyPadBlock.class) +public abstract class LilyPadBlockMixin { @Inject(method = "entityInside", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;destroyBlock(Lnet/minecraft/core/BlockPos;ZLnet/minecraft/world/entity/Entity;)Z")) private void ledgerLogLilyPadBreak(BlockState state, Level world, BlockPos pos, Entity entity, InsideBlockEffectApplier handler, boolean bl, CallbackInfo ci) { if (entity.getFirstPassenger() instanceof Player player) { diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/PortalShapeMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/PortalShapeMixin.java index 6afd3967..3d2118b1 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/PortalShapeMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/PortalShapeMixin.java @@ -17,7 +17,7 @@ @Mixin(PortalShape.class) public abstract class PortalShapeMixin { - @Inject(method = "method_64315", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelAccessor;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) + @Inject(method = "lambda$createPortalBlocks$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelAccessor;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) private static void logPortalPlacement(LevelAccessor worldAccess, BlockState state, BlockPos pos, CallbackInfo ci) { if (worldAccess instanceof ServerLevel world) { BlockPlaceCallback.EVENT.invoker().place(world, pos.immutable(), state, null, Sources.PORTAL); diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/FarmBlockMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/FarmlandBlockMixin.java similarity index 90% rename from src/main/java/com/github/quiltservertools/ledger/mixin/blocks/FarmBlockMixin.java rename to src/main/java/com/github/quiltservertools/ledger/mixin/blocks/FarmlandBlockMixin.java index 1cc2825d..8c755cfe 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/FarmBlockMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/FarmlandBlockMixin.java @@ -2,9 +2,9 @@ import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback; import com.github.quiltservertools.ledger.utility.Sources; +import net.minecraft.world.level.block.FarmlandBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.FarmBlock; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.core.BlockPos; @@ -14,8 +14,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(FarmBlock.class) -public abstract class FarmBlockMixin { +@Mixin(FarmlandBlock.class) +public abstract class FarmlandBlockMixin { @Inject(method = "turnToDirt", at = @At("HEAD")) private static void logSetToDirt(Entity entity, BlockState blockState, Level world, BlockPos pos, CallbackInfo ci) { diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/SpongeBlockMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/SpongeBlockMixin.java index 7beee6b4..5986bdc5 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/SpongeBlockMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/SpongeBlockMixin.java @@ -20,14 +20,14 @@ public abstract class SpongeBlockMixin { @Unique private BlockState oldBlockState; - @Inject(method = "method_49829", at = @At(value = "INVOKE", + @Inject(method = "lambda$removeWaterBreadthFirstSearch$1", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) private static void logWaterDrainNonSource(BlockPos actorBlockPos, Level world, BlockPos pos, CallbackInfoReturnable cir) { // pos is the blockpos for affected water BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, world.getBlockState(pos), null, Sources.SPONGE); } - @Inject(method = "method_49829", at = @At(value = "INVOKE", + @Inject(method = "lambda$removeWaterBreadthFirstSearch$1", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/BucketPickup;pickupBlock(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack;")) private static void logWaterDrainSource(BlockPos actorBlockPos, Level world, BlockPos pos, CallbackInfoReturnable cir) { BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, world.getBlockState(pos), null, Sources.SPONGE); diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/SpreadingSnowyDirtBlockMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/SpreadingSnowyBlockMixin.java similarity index 89% rename from src/main/java/com/github/quiltservertools/ledger/mixin/blocks/SpreadingSnowyDirtBlockMixin.java rename to src/main/java/com/github/quiltservertools/ledger/mixin/blocks/SpreadingSnowyBlockMixin.java index 50c752a0..d2fe2094 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/SpreadingSnowyDirtBlockMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/SpreadingSnowyBlockMixin.java @@ -2,8 +2,8 @@ import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback; import com.github.quiltservertools.ledger.utility.Sources; +import net.minecraft.world.level.block.SpreadingSnowyBlock; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.SpreadingSnowyDirtBlock; import net.minecraft.server.level.ServerLevel; import net.minecraft.core.BlockPos; import net.minecraft.util.RandomSource; @@ -12,8 +12,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(SpreadingSnowyDirtBlock.class) -public abstract class SpreadingSnowyDirtBlockMixin { +@Mixin(SpreadingSnowyBlock.class) +public abstract class SpreadingSnowyBlockMixin { @Inject(method = "randomTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z", diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/CauldronInteractionMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/CauldronInteractionsMixin.java similarity index 93% rename from src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/CauldronInteractionMixin.java rename to src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/CauldronInteractionsMixin.java index 724c35e1..65252421 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/CauldronInteractionMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/CauldronInteractionsMixin.java @@ -2,9 +2,9 @@ import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback; import com.github.quiltservertools.ledger.utility.Sources; +import net.minecraft.core.cauldron.CauldronInteractions; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.Blocks; -import net.minecraft.core.cauldron.CauldronInteraction; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.sounds.SoundEvent; @@ -20,8 +20,8 @@ import java.util.function.Predicate; -@Mixin(CauldronInteraction.class) -public interface CauldronInteractionMixin { +@Mixin(CauldronInteractions.class) +public abstract class CauldronInteractionsMixin { @Inject(method = "fillBucket", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getItem()Lnet/minecraft/world/item/Item;")) private static void ledgerLogFullDrainCauldron(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, ItemStack stack, ItemStack output, @@ -35,7 +35,7 @@ private static void ledgerLogFillCauldron(Level world, BlockPos pos, Player play ledgerLogFillCauldron(world, pos, world.getBlockState(pos), state, player); } - @Inject(method = "method_32219", at = @At(value = "INVOKE", + @Inject(method = "lambda$bootStrap$4", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z", shift = At.Shift.AFTER)) private static void ledgerLogBottleFillWaterCauldron(BlockState state, Level world, BlockPos pos, @@ -43,7 +43,7 @@ private static void ledgerLogBottleFillWaterCauldron(BlockState state, Level wor ledgerLogFillCauldron(world, pos, state, world.getBlockState(pos), player); } - @Inject(method = "method_32222", at = @At(value = "INVOKE", + @Inject(method = "lambda$bootStrap$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z", shift = At.Shift.AFTER)) private static void ledgerLogBottleFillEmptyCauldron(BlockState state, Level world, BlockPos pos, diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/LayeredCauldronBlockMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/LayeredCauldronBlockMixin.java index c589ad17..da79a1ca 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/LayeredCauldronBlockMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/cauldron/LayeredCauldronBlockMixin.java @@ -52,7 +52,7 @@ private static void ledgerLogDecrementLevelCauldron(BlockState state, Level worl } } - @Inject(method = "method_71627", at = @At(value = "INVOKE", + @Inject(method = "lambda$entityInside$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/LayeredCauldronBlock;handleEntityOnFireInside(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)V")) private void ledgerLogPlayerExtinguish(ServerLevel serverWorld, BlockPos blockPos, BlockState blockState, Level world, Entity collidedEntity, CallbackInfo ci) { if (collidedEntity instanceof Player) { diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/sign/SignBlockMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/sign/SignBlockMixin.java index 2bda5907..69be67c0 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/sign/SignBlockMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/blocks/sign/SignBlockMixin.java @@ -4,6 +4,7 @@ import com.github.quiltservertools.ledger.utility.NbtUtils; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.SignBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.entity.BlockEntity; @@ -33,7 +34,7 @@ public class SignBlockMixin { * @param signBlockEntity The sign block entity being interacted with * @param front Whether the interaction is happening on the front of the sign * @param player The player interacting with the sign - * @param original The original {@link SignApplicator#tryApplyToSign(Level, SignBlockEntity, boolean, Player)} + * @param original The original {@link SignApplicator#tryApplyToSign(Level, SignBlockEntity, boolean, ItemStack, Player)} * operation that this mixin wraps. * @return Returns the result of calling {@code original} with this method's parameters. */ @@ -41,7 +42,7 @@ public class SignBlockMixin { method = "useItemOn", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/item/SignApplicator;tryApplyToSign(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/block/entity/SignBlockEntity;ZLnet/minecraft/world/entity/player/Player;)Z" + target = "Lnet/minecraft/world/item/SignApplicator;tryApplyToSign(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/block/entity/SignBlockEntity;ZLnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/player/Player;)Z" ) ) private boolean logSignItemInteraction( @@ -49,6 +50,7 @@ private boolean logSignItemInteraction( Level world, SignBlockEntity signBlockEntity, boolean front, + ItemStack itemStack, Player player, Operation original ) { @@ -60,7 +62,7 @@ private boolean logSignItemInteraction( // a bad hack to copy the old sign block entity for rollbacks @Nullable BlockEntity oldSignEntity = BlockEntity.loadStatic(pos, state, NbtUtils.INSTANCE.createNbt(signBlockEntity, registryManager), registryManager); - boolean result = original.call(instance, world, signBlockEntity, front, player); + boolean result = original.call(instance, world, signBlockEntity, front, itemStack, player); if (result && oldSignEntity != null) { BlockChangeCallback.EVENT.invoker() .changeBlock( diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/entities/ItemFrameMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/entities/ItemFrameMixin.java index becb340f..6c61c4bf 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/entities/ItemFrameMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/entities/ItemFrameMixin.java @@ -13,6 +13,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -30,7 +31,7 @@ public abstract class ItemFrameMixin { private CompoundTag oldEntityTags; @Inject(method = "interact", at = @At(value = "HEAD")) - private void ledgerLogOldEntity(Player player, InteractionHand hand, CallbackInfoReturnable cir) { + private void ledgerLogOldEntity(Player player, InteractionHand hand, Vec3 location, CallbackInfoReturnable cir) { Entity entity = (Entity) (Object) this; oldEntityTags = NbtUtils.INSTANCE.createNbt(entity); } @@ -45,7 +46,7 @@ private void ledgerLogOldEntity2(ServerLevel world, Entity entityActor, boolean } @Inject(method = "interact", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/decoration/ItemFrame;setItem(Lnet/minecraft/world/item/ItemStack;)V", shift = At.Shift.AFTER)) - private void ledgerItemFrameEquip(Player player, InteractionHand hand, CallbackInfoReturnable cir) { + private void ledgerItemFrameEquip(Player player, InteractionHand hand, Vec3 location, CallbackInfoReturnable cir) { ItemStack playerStack = player.getItemInHand(hand); Entity entity = (Entity) (Object) this; EntityModifyCallback.EVENT.invoker().modify(player.level(), entity.blockPosition(), oldEntityTags, entity, playerStack, player, Sources.EQUIP); @@ -62,7 +63,7 @@ private void ledgerItemFrameRemove(ServerLevel world, Entity entityActor, boolea } @Inject(method = "interact", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/decoration/ItemFrame;setRotation(I)V", shift = At.Shift.AFTER)) - private void ledgerItemFrameRotate(Player player, InteractionHand hand, CallbackInfoReturnable cir) { + private void ledgerItemFrameRotate(Player player, InteractionHand hand, Vec3 location, CallbackInfoReturnable cir) { Entity entity = (Entity) (Object) this; EntityModifyCallback.EVENT.invoker().modify(player.level(), entity.blockPosition(), oldEntityTags, entity, null, player, Sources.ROTATE); } diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/preview/ServerPlayerEntityMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/preview/ServerPlayerEntityMixin.java index 376f2dc4..b2d3ed99 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/preview/ServerPlayerEntityMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/preview/ServerPlayerEntityMixin.java @@ -27,7 +27,7 @@ public abstract class ServerPlayerEntityMixin { // synthetic field ServerPlayerEntity from the outer class @Final @Shadow - ServerPlayer field_58075; + ServerPlayer this$0; @ModifyArg( method = "sendInitialData", @@ -39,7 +39,7 @@ public abstract class ServerPlayerEntityMixin { private List modifyStacks(List stacks, @Local(argsOnly = true) AbstractContainerMenu handler) { BlockPos pos = ((HandlerWithContext) handler).getPos(); if (pos == null) return stacks; - Preview preview = Ledger.previewCache.get(field_58075.getUUID()); + Preview preview = Ledger.previewCache.get(this$0.getUUID()); if (preview == null) return stacks; List> modifiedItems = preview.getModifiedItems().get(pos); if (modifiedItems == null) return stacks; diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/Ledger.kt b/src/main/kotlin/com/github/quiltservertools/ledger/Ledger.kt index e9b6781c..2912e7df 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/Ledger.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/Ledger.kt @@ -72,7 +72,7 @@ object Ledger : DedicatedServerModInitializer, CoroutineScope { logInfo("No config file, Creating") Files.copy( FabricLoader.getInstance().getModContainer(MOD_ID).get().findPath(CONFIG_PATH).get(), - FabricLoader.getInstance().configDir.resolve(CONFIG_PATH) + FabricLoader.getInstance().configDir.resolve(CONFIG_PATH), ) } realConfig.validateRequired() @@ -81,9 +81,9 @@ object Ledger : DedicatedServerModInitializer, CoroutineScope { ServerLifecycleEvents.SERVER_STARTING.register(::serverStarting) ServerLifecycleEvents.SERVER_STOPPED.register(::serverStopped) CommandRegistrationCallback.EVENT.register { dispatcher, _, _ -> registerCommands(dispatcher) } - PayloadTypeRegistry.playS2C().register(ActionS2CPacket.ID, ActionS2CPacket.CODEC) - PayloadTypeRegistry.playS2C().register(HandshakeS2CPacket.ID, HandshakeS2CPacket.CODEC) - PayloadTypeRegistry.playS2C().register(ResponseS2CPacket.ID, ResponseS2CPacket.CODEC) + PayloadTypeRegistry.clientboundPlay().register(ActionS2CPacket.ID, ActionS2CPacket.CODEC) + PayloadTypeRegistry.clientboundPlay().register(HandshakeS2CPacket.ID, HandshakeS2CPacket.CODEC) + PayloadTypeRegistry.clientboundPlay().register(ResponseS2CPacket.ID, ResponseS2CPacket.CODEC) } private fun serverStarting(server: MinecraftServer) { @@ -121,7 +121,7 @@ object Ledger : DedicatedServerModInitializer, CoroutineScope { while (ActionQueueService.size > 0) { logInfo( "Database is still busy. If you exit now data WILL be lost. " + - "Actions in queue: ${ActionQueueService.size}" + "Actions in queue: ${ActionQueueService.size}", ) delay(config[DatabaseSpec.queueCheckDelaySec].seconds) @@ -132,7 +132,7 @@ object Ledger : DedicatedServerModInitializer, CoroutineScope { } } catch (e: TimeoutCancellationException) { logWarn( - "Database drain timed out. ${ActionQueueService.size} actions still in queue. Data may be lost." + "Database drain timed out. ${ActionQueueService.size} actions still in queue. Data may be lost.", ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actions/AbstractActionType.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actions/AbstractActionType.kt index 876cc638..e056046d 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actions/AbstractActionType.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actions/AbstractActionType.kt @@ -47,7 +47,7 @@ abstract class AbstractActionType : ActionType { getSourceMessage(), getActionMessage(), getObjectMessage(source), - getLocationMessage() + getLocationMessage(), ) message.style = TextColorPallet.light @@ -77,21 +77,21 @@ abstract class AbstractActionType : ActionType { .withStyle { it.withHoverEvent( HoverEvent.ShowText( - identifier.literal() - ) + identifier.literal(), + ), ) } open fun getObjectMessage(source: CommandSourceStack): Component = Component.translatable( Util.makeDescriptionId( this.getTranslationType(), - objectIdentifier - ) + objectIdentifier, + ), ).setStyle(TextColorPallet.secondaryVariant).withStyle { it.withHoverEvent( HoverEvent.ShowText( - objectIdentifier.toString().literal() - ) + objectIdentifier.toString().literal(), + ), ) } @@ -101,12 +101,12 @@ abstract class AbstractActionType : ActionType { it.withHoverEvent( HoverEvent.ShowText( Component.literal(world?.let { "$it\n" } ?: "") - .append(Component.translatable("text.ledger.action_message.location.hover")) - ) + .append(Component.translatable("text.ledger.action_message.location.hover")), + ), ).withClickEvent( ClickEvent.RunCommand( - "/lg tp ${world ?: Level.OVERWORLD.identifier()} ${pos.x} ${pos.y} ${pos.z}" - ) + "/lg tp ${world ?: Level.OVERWORLD.identifier()} ${pos.x} ${pos.y} ${pos.z}", + ), ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actions/ActionType.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actions/ActionType.kt index 7773200d..e6eabf66 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actions/ActionType.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actions/ActionType.kt @@ -38,9 +38,9 @@ interface ActionType { fun getMessage(source: CommandSourceStack): Component fun isBlacklisted() = config[ActionsSpec.typeBlacklist].contains(identifier) || - config[ActionsSpec.objectBlacklist].contains(objectIdentifier) || - config[ActionsSpec.objectBlacklist].contains(oldObjectIdentifier) || - config[ActionsSpec.sourceBlacklist].contains(sourceName) || - config[ActionsSpec.sourceBlacklist].contains("@${sourceProfile?.name}") || - config[ActionsSpec.worldBlacklist].contains(world) + config[ActionsSpec.objectBlacklist].contains(objectIdentifier) || + config[ActionsSpec.objectBlacklist].contains(oldObjectIdentifier) || + config[ActionsSpec.sourceBlacklist].contains(sourceName) || + config[ActionsSpec.sourceBlacklist].contains("@${sourceProfile?.name}") || + config[ActionsSpec.worldBlacklist].contains(world) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockBreakActionType.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockBreakActionType.kt index 8913fd33..a3b37d69 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockBreakActionType.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockBreakActionType.kt @@ -13,13 +13,13 @@ class BlockBreakActionType : BlockChangeActionType() { override fun getObjectMessage(source: CommandSourceStack): Component = Component.translatable( Util.makeDescriptionId( this.getTranslationType(), - oldObjectIdentifier - ) + oldObjectIdentifier, + ), ).setStyle(TextColorPallet.secondaryVariant).withStyle { it.withHoverEvent( HoverEvent.ShowText( - oldObjectIdentifier.toString().literal() - ) + oldObjectIdentifier.toString().literal(), + ), ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockChangeActionType.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockChangeActionType.kt index 646e051b..a531b2f7 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockChangeActionType.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockChangeActionType.kt @@ -36,8 +36,8 @@ open class BlockChangeActionType : AbstractActionType() { TagValueInput.create( it, server.registryAccess(), - TagParser.parseCompoundFully(extraData!!) - ) + TagParser.parseCompoundFully(extraData!!), + ), ) } world?.chunkSource?.blockChanged(pos) @@ -50,8 +50,8 @@ open class BlockChangeActionType : AbstractActionType() { player.connection.send( ClientboundBlockUpdatePacket( pos, - oldBlockState(player.level().holderLookup(Registries.BLOCK)) - ) + oldBlockState(player.level().holderLookup(Registries.BLOCK)), + ), ) preview.positions.add(pos) } @@ -70,8 +70,8 @@ open class BlockChangeActionType : AbstractActionType() { player.connection.send( ClientboundBlockUpdatePacket( pos, - newBlockState(player.level().holderLookup(Registries.BLOCK)) - ) + newBlockState(player.level().holderLookup(Registries.BLOCK)), + ), ) preview.positions.add(pos) } @@ -83,17 +83,17 @@ open class BlockChangeActionType : AbstractActionType() { val text = Component.literal("") text.append( Component.translatable( - Util.makeDescriptionId( - this.getTranslationType(), - oldObjectIdentifier - ) - ).setStyle(TextColorPallet.secondaryVariant).withStyle { - it.withHoverEvent( - HoverEvent.ShowText( - oldObjectIdentifier.toString().literal() + Util.makeDescriptionId( + this.getTranslationType(), + oldObjectIdentifier, + ), + ).setStyle(TextColorPallet.secondaryVariant).withStyle { + it.withHoverEvent( + HoverEvent.ShowText( + oldObjectIdentifier.toString().literal(), + ), ) - ) - } + }, ) if (oldObjectIdentifier != objectIdentifier) { text.append(" → ".literal()) @@ -101,15 +101,15 @@ open class BlockChangeActionType : AbstractActionType() { Component.translatable( Util.makeDescriptionId( this.getTranslationType(), - objectIdentifier - ) + objectIdentifier, + ), ).setStyle(TextColorPallet.secondaryVariant).withStyle { it.withHoverEvent( HoverEvent.ShowText( - objectIdentifier.toString().literal() - ) + objectIdentifier.toString().literal(), + ), ) - } + }, ) } return text @@ -121,9 +121,9 @@ open class BlockChangeActionType : AbstractActionType() { NbtUtils.blockStateFromProperties( TagParser.parseCompoundFully(it), oldObjectIdentifier, - blockLookup + blockLookup, ) - } + }, ) fun newBlockState(blockLookup: HolderGetter) = checkForBlockState( @@ -132,9 +132,9 @@ open class BlockChangeActionType : AbstractActionType() { NbtUtils.blockStateFromProperties( TagParser.parseCompoundFully(it), objectIdentifier, - blockLookup + blockLookup, ) - } + }, ) private fun checkForBlockState(identifier: Identifier, checkState: BlockState?): BlockState { diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockPlaceActionType.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockPlaceActionType.kt index 3268d119..e2d12636 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockPlaceActionType.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actions/BlockPlaceActionType.kt @@ -36,8 +36,8 @@ class BlockPlaceActionType : BlockChangeActionType() { TagValueInput.create( it, server.registryAccess(), - TagParser.parseCompoundFully(extraData!!) - ) + TagParser.parseCompoundFully(extraData!!), + ), ) } } @@ -49,13 +49,13 @@ class BlockPlaceActionType : BlockChangeActionType() { override fun getObjectMessage(source: CommandSourceStack): Component = Component.translatable( Util.makeDescriptionId( this.getTranslationType(), - objectIdentifier - ) + objectIdentifier, + ), ).setStyle(TextColorPallet.secondaryVariant).withStyle { it.withHoverEvent( HoverEvent.ShowText( - objectIdentifier.toString().literal() - ) + objectIdentifier.toString().literal(), + ), ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actions/EntityChangeActionType.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actions/EntityChangeActionType.kt index 64357c94..1e93389a 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actions/EntityChangeActionType.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actions/EntityChangeActionType.kt @@ -22,6 +22,7 @@ import net.minecraft.world.entity.decoration.HangingEntity import net.minecraft.world.entity.decoration.ItemFrame import net.minecraft.world.item.BlockItem import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.ItemStackTemplate import net.minecraft.world.level.storage.TagValueInput class EntityChangeActionType : AbstractActionType() { @@ -42,7 +43,7 @@ class EntityChangeActionType : AbstractActionType() { val readView = TagValueInput.create( ProblemReporter.DISCARDING, registryManager, - TagParser.parseCompoundFully(extraData!!) + TagParser.parseCompoundFully(extraData!!), ) return readView.read(ItemStack.MAP_CODEC).orElse(ItemStack.EMPTY) } catch (_: CommandSyntaxException) { @@ -58,32 +59,32 @@ class EntityChangeActionType : AbstractActionType() { Component.translatable( Util.makeDescriptionId( "entity", - objectIdentifier - ) + objectIdentifier, + ), ).setStyle(TextColorPallet.secondaryVariant).withStyle { it.withHoverEvent( HoverEvent.ShowText( - objectIdentifier.toString().literal() - ) + objectIdentifier.toString().literal(), + ), ) - } + }, ) val stack = getStack(source.registryAccess()) if (!stack.isEmpty) { text.append( - Component.literal(" ").append(Component.translatable("text.ledger.action_message.with")).append(" ") + Component.literal(" ").append(Component.translatable("text.ledger.action_message.with")).append(" "), ) text.append( Component.translatable( - stack.item.descriptionId + stack.item.descriptionId, ).setStyle(TextColorPallet.secondaryVariant).withStyle { it.withHoverEvent( HoverEvent.ShowItem( - stack - ) + ItemStackTemplate(stack.item, stack.componentsPatch), + ), ) - } + }, ) } return text diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actions/EntityKillActionType.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actions/EntityKillActionType.kt index 811e8d8e..9b7e85a3 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actions/EntityKillActionType.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actions/EntityKillActionType.kt @@ -29,7 +29,7 @@ class EntityKillActionType : AbstractActionType() { override fun sendToTrackingPlayersAndSelf(packet: Packet) = Unit override fun sendToTrackingPlayersFiltered( packet: Packet, - predicate: Predicate + predicate: Predicate, ) = Unit } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemChangeActionType.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemChangeActionType.kt index d099ee12..25b2e59a 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemChangeActionType.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemChangeActionType.kt @@ -18,6 +18,7 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container import net.minecraft.world.WorldlyContainerHolder import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.ItemStackTemplate import net.minecraft.world.item.Items import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.ChestBlock @@ -32,19 +33,19 @@ abstract class ItemChangeActionType : AbstractActionType() { private fun getStack(server: MinecraftServer) = NbtUtils.itemFromProperties( extraData, objectIdentifier, - server.registryAccess() + server.registryAccess(), ) override fun getObjectMessage(source: CommandSourceStack): Component { val stack = getStack(source.server) return "${stack.count} ".literal().append( - stack.itemName + stack.itemName, ).setStyle(TextColorPallet.secondaryVariant).withStyle { it.withHoverEvent( HoverEvent.ShowItem( - stack - ) + ItemStackTemplate(stack.item, stack.componentsPatch), + ), ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemDropActionType.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemDropActionType.kt index 89a58be6..65b31c0e 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemDropActionType.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemDropActionType.kt @@ -16,6 +16,7 @@ import net.minecraft.util.ProblemReporter import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.item.ItemEntity +import net.minecraft.world.item.ItemStackTemplate import net.minecraft.world.level.storage.TagValueInput // TODO remove duplication from ItemPickUpActionType and ItemDropActionType @@ -28,19 +29,19 @@ open class ItemDropActionType : AbstractActionType() { private fun getStack(server: MinecraftServer) = NbtUtils.itemFromProperties( extraData, objectIdentifier, - server.registryAccess() + server.registryAccess(), ) override fun getObjectMessage(source: CommandSourceStack): Component { val stack = getStack(source.server) return "${stack.count} ".literal().append( - stack.itemName + stack.itemName, ).setStyle(TextColorPallet.secondaryVariant).withStyle { it.withHoverEvent( HoverEvent.ShowItem( - stack - ) + ItemStackTemplate(stack.item, stack.componentsPatch), + ), ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemPickUpActionType.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemPickUpActionType.kt index 551486e1..f4ba8dd4 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemPickUpActionType.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actions/ItemPickUpActionType.kt @@ -16,6 +16,7 @@ import net.minecraft.util.ProblemReporter import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.item.ItemEntity +import net.minecraft.world.item.ItemStackTemplate import net.minecraft.world.level.storage.TagValueInput open class ItemPickUpActionType : AbstractActionType() { @@ -27,19 +28,19 @@ open class ItemPickUpActionType : AbstractActionType() { private fun getStack(server: MinecraftServer) = NbtUtils.itemFromProperties( extraData, objectIdentifier, - server.registryAccess() + server.registryAccess(), ) override fun getObjectMessage(source: CommandSourceStack): Component { val stack = getStack(source.server) return "${stack.count} ".literal().append( - stack.itemName + stack.itemName, ).setStyle(TextColorPallet.secondaryVariant).withStyle { it.withHoverEvent( HoverEvent.ShowItem( - stack - ) + ItemStackTemplate(stack.item, stack.componentsPatch), + ), ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/ActionFactory.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/ActionFactory.kt index 42fad3af..5c9cbc8d 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/ActionFactory.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/ActionFactory.kt @@ -36,7 +36,7 @@ object ActionFactory { pos: BlockPos, state: BlockState, source: String, - entity: BlockEntity? = null + entity: BlockEntity? = null, ): BlockBreakActionType { val action = BlockBreakActionType() setBlockData(action, pos, world, Blocks.AIR.defaultBlockState(), state, source, entity) @@ -50,7 +50,7 @@ object ActionFactory { state: BlockState, player: Player, entity: BlockEntity? = null, - source: String = Sources.PLAYER + source: String = Sources.PLAYER, ): BlockChangeActionType { val action = blockBreakAction(world, pos, state, source, entity) action.sourceProfile = player.nameAndId() @@ -63,7 +63,7 @@ object ActionFactory { pos: BlockPos, state: BlockState, source: String, - entity: BlockEntity? = null + entity: BlockEntity? = null, ): BlockChangeActionType { val action = BlockPlaceActionType() setBlockData(action, pos, world, state, Blocks.AIR.defaultBlockState(), source, entity) @@ -77,7 +77,7 @@ object ActionFactory { state: BlockState, player: Player, entity: BlockEntity? = null, - source: String = Sources.PLAYER + source: String = Sources.PLAYER, ): BlockChangeActionType { val action = blockPlaceAction(world, pos, state, source, entity) action.sourceProfile = player.nameAndId() @@ -92,7 +92,7 @@ object ActionFactory { state: BlockState, oldState: BlockState, source: String, - entity: BlockEntity? = null + entity: BlockEntity? = null, ) { action.pos = pos action.world = world.dimension().identifier() @@ -111,12 +111,7 @@ object ActionFactory { return action } - fun itemInsertAction( - world: Level, - stack: ItemStack, - pos: BlockPos, - source: LivingEntity - ): ItemInsertActionType { + fun itemInsertAction(world: Level, stack: ItemStack, pos: BlockPos, source: LivingEntity): ItemInsertActionType { val action = ItemInsertActionType() var sourceType = Sources.UNKNOWN if (source is Player) { @@ -138,12 +133,7 @@ object ActionFactory { return action } - fun itemRemoveAction( - world: Level, - stack: ItemStack, - pos: BlockPos, - source: LivingEntity - ): ItemRemoveActionType { + fun itemRemoveAction(world: Level, stack: ItemStack, pos: BlockPos, source: LivingEntity): ItemRemoveActionType { val action = ItemRemoveActionType() var sourceType = Sources.UNKNOWN if (source is Player) { @@ -158,10 +148,7 @@ object ActionFactory { return action } - fun itemPickUpAction( - entity: ItemEntity, - source: Player - ): ItemPickUpActionType { + fun itemPickUpAction(entity: ItemEntity, source: Player): ItemPickUpActionType { val action = ItemPickUpActionType() setItemData(action, entity.blockPosition(), entity.level(), entity.item, Sources.PLAYER) @@ -172,10 +159,7 @@ object ActionFactory { return action } - fun itemDropAction( - entity: ItemEntity, - source: LivingEntity - ): ItemDropActionType { + fun itemDropAction(entity: ItemEntity, source: LivingEntity): ItemDropActionType { val action = ItemDropActionType() setItemData(action, entity.blockPosition(), entity.level(), entity.item, Sources.PLAYER) @@ -197,7 +181,7 @@ object ActionFactory { newState: BlockState, oldBlockEntity: BlockEntity?, source: String, - player: Player? + player: Player?, ): ActionType { val action = BlockChangeActionType() setBlockData(action, pos, world, newState, oldState, source, oldBlockEntity) @@ -205,13 +189,7 @@ object ActionFactory { return action } - private fun setItemData( - action: ActionType, - pos: BlockPos, - world: Level, - stack: ItemStack, - source: String - ) { + private fun setItemData(action: ActionType, pos: BlockPos, world: Level, stack: ItemStack, source: String) { action.pos = pos action.world = world.dimension().identifier() action.objectIdentifier = BuiltInRegistries.ITEM.getKey(stack.item) @@ -250,13 +228,7 @@ object ActionFactory { return action } - private fun setEntityData( - action: ActionType, - pos: BlockPos, - world: Level, - entity: Entity, - source: String - ) { + private fun setEntityData(action: ActionType, pos: BlockPos, world: Level, entity: Entity, source: String) { action.pos = pos action.world = world.dimension().identifier() action.objectIdentifier = BuiltInRegistries.ENTITY_TYPE.getKey(entity.type) @@ -271,7 +243,7 @@ object ActionFactory { entity: Entity, itemStack: ItemStack?, entityActor: Entity?, - sourceType: String + sourceType: String, ): EntityChangeActionType { val action = EntityChangeActionType() @@ -294,10 +266,7 @@ object ActionFactory { return action } - fun entityMountAction( - entity: Entity, - player: Player, - ): EntityMountActionType { + fun entityMountAction(entity: Entity, player: Player): EntityMountActionType { val world = entity.level() val action = EntityMountActionType() @@ -315,10 +284,7 @@ object ActionFactory { return action } - fun entityDismountAction( - entity: Entity, - player: Player, - ): EntityDismountActionType { + fun entityDismountAction(entity: Entity, player: Player): EntityDismountActionType { val world = entity.level() val action = EntityDismountActionType() diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/ActionSearchParams.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/ActionSearchParams.kt index 7ef4b8ef..d76184f5 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/ActionSearchParams.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/ActionSearchParams.kt @@ -20,7 +20,7 @@ data class ActionSearchParams( var objects: MutableSet>?, var sourceNames: MutableSet>?, var sourcePlayerIds: MutableSet>?, - var worlds: MutableSet>? + var worlds: MutableSet>?, ) { private constructor(builder: Builder) : this( builder.bounds, @@ -31,7 +31,7 @@ data class ActionSearchParams( builder.objects, builder.sourceNames, builder.sourcePlayerIds, - builder.worlds + builder.worlds, ) fun ensureSpecific() { @@ -41,7 +41,7 @@ data class ActionSearchParams( val range = (max(bounds.xSpan, max(bounds.ySpan, bounds.zSpan)) + 1) / 2 if (range > Ledger.config[SearchSpec.maxRange] && bounds != GLOBAL) { throw SimpleCommandExceptionType( - Component.translatable("error.ledger.unspecific.range_to_big", Ledger.config[SearchSpec.maxRange]) + Component.translatable("error.ledger.unspecific.range_to_big", Ledger.config[SearchSpec.maxRange]), ).create() } if (sourceNames == null && sourcePlayerIds == null && after == null && before == null) { diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/Preview.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/Preview.kt index d75cb00c..744177e9 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/Preview.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/Preview.kt @@ -17,7 +17,7 @@ class Preview( private val params: ActionSearchParams, actions: List, player: ServerPlayer, - private val type: Type + private val type: Type, ) { val positions = mutableSetOf() @@ -31,12 +31,12 @@ class Preview( val modifiedItems = mutableMapOf>>() init { - player.displayClientMessage( + player.sendSystemMessage( Component.translatable( "text.ledger.preview.start", - actions.size + actions.size, ).setStyle(TextColorPallet.primary), - false + false, ) for (action in actions) { @@ -83,6 +83,6 @@ class Preview( enum class Type { ROLLBACK, - RESTORE + RESTORE, } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/SearchResults.kt b/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/SearchResults.kt index fbd6a9ea..1e7065a6 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/SearchResults.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/actionutils/SearchResults.kt @@ -6,5 +6,5 @@ data class SearchResults( val actions: List, val searchParams: ActionSearchParams, val page: Int, - val pages: Int + val pages: Int, ) diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockBreakCallback.kt b/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockBreakCallback.kt index 0f37563b..d594e2e8 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockBreakCallback.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockBreakCallback.kt @@ -16,7 +16,7 @@ fun interface BlockBreakCallback { state: BlockState, entity: BlockEntity?, source: String, - player: Player? + player: Player?, ) fun breakBlock(world: Level, pos: BlockPos, state: BlockState, entity: BlockEntity?, player: Player) = diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockChangeCallback.kt b/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockChangeCallback.kt index eeb49861..2fbd2f9a 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockChangeCallback.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockChangeCallback.kt @@ -18,7 +18,7 @@ fun interface BlockChangeCallback { oldBlockEntity: BlockEntity?, newBlockEntity: BlockEntity?, source: String, - player: Player? + player: Player?, ) fun changeBlock( @@ -28,9 +28,8 @@ fun interface BlockChangeCallback { newState: BlockState, oldBlockEntity: BlockEntity?, newBlockEntity: BlockEntity?, - player: Player - ) = - changeBlock(world, pos, oldState, newState, oldBlockEntity, newBlockEntity, Sources.PLAYER, player) + player: Player, + ) = changeBlock(world, pos, oldState, newState, oldBlockEntity, newBlockEntity, Sources.PLAYER, player) fun changeBlock( world: Level, @@ -39,9 +38,8 @@ fun interface BlockChangeCallback { newState: BlockState, oldBlockEntity: BlockEntity?, newBlockEntity: BlockEntity?, - source: String - ) = - changeBlock(world, pos, oldState, newState, oldBlockEntity, newBlockEntity, source, null) + source: String, + ) = changeBlock(world, pos, oldState, newState, oldBlockEntity, newBlockEntity, source, null) companion object { @JvmField @@ -57,7 +55,7 @@ fun interface BlockChangeCallback { oldBlockEntity, newBlockEntity, source, - player + player, ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockPlaceCallback.kt b/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockPlaceCallback.kt index 5898a60d..46ba9aa0 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockPlaceCallback.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/BlockPlaceCallback.kt @@ -10,14 +10,7 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState fun interface BlockPlaceCallback { - fun place( - world: Level, - pos: BlockPos, - state: BlockState, - entity: BlockEntity?, - source: String, - player: Player? - ) + fun place(world: Level, pos: BlockPos, state: BlockState, entity: BlockEntity?, source: String, player: Player?) fun place(world: Level, pos: BlockPos, state: BlockState, entity: BlockEntity?, player: Player) = place(world, pos, state, entity, Sources.PLAYER, player) diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/EntityModifyCallback.kt b/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/EntityModifyCallback.kt index aae69a44..f6910ac1 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/EntityModifyCallback.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/callbacks/EntityModifyCallback.kt @@ -16,7 +16,7 @@ fun interface EntityModifyCallback { newEntity: Entity, itemStack: ItemStack?, entityActor: Entity?, - sourceType: String + sourceType: String, ) companion object { diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/LedgerCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/LedgerCommand.kt index cb5f84c1..4abc30c9 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/LedgerCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/LedgerCommand.kt @@ -25,7 +25,7 @@ fun registerCommands(dispatcher: Dispatcher) { dispatcher.root.addChild( literal("lg") .requires(Permissions.require("ledger.commands.root", CommandConsts.PERMISSION_LEVEL)).redirect(rootNode) - .build() + .build(), ) rootNode.addChild(InspectCommand.build()) diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/arguments/SearchParamArgument.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/arguments/SearchParamArgument.kt index 8d43d744..c8a390f1 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/arguments/SearchParamArgument.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/arguments/SearchParamArgument.kt @@ -112,24 +112,26 @@ object SearchParamArgument { val range = range - 1 builder.bounds = BoundingBox.fromCorners( BlockPos.containing(source.position).subtract(Vec3i(range, range, range)), - BlockPos.containing(source.position).offset(Vec3i(range, range, range)) + BlockPos.containing(source.position).offset(Vec3i(range, range, range)), ) val world = Negatable.allow(source.level.dimension().identifier()) if (builder.worlds == null) { builder.worlds = mutableSetOf(world) } else { builder.worlds!!.add( - world - ) + world, + ) } } else { builder.bounds = ActionSearchParams.GLOBAL } } + "world" -> { val world = value as Negatable if (builder.worlds == null) builder.worlds = mutableSetOf(world) else builder.worlds!!.add(world) } + "object" -> { val objectIds = (value as Negatable>).property.map { if (value.allowed) Negatable.allow(it) else Negatable.deny(it) @@ -141,6 +143,7 @@ object SearchParamArgument { builder.objects!!.addAll(objectIds) } } + "source" -> { val sourceInput = value as Negatable if (sourceInput.property.startsWith('@')) { @@ -167,6 +170,7 @@ object SearchParamArgument { } } } + "action" -> { val action = value as Negatable if (builder.actions == null) { @@ -175,14 +179,17 @@ object SearchParamArgument { builder.actions!!.add(action) } } + "before" -> { val time = value as Instant builder.before = time } + "after" -> { val time = value as Instant builder.after = time } + "rolledback" -> { val rolledBack = value as Boolean builder.rolledBack = rolledBack @@ -212,13 +219,11 @@ object SearchParamArgument { open fun listSuggestions( context: CommandContext, - builder: SuggestionsBuilder - ): CompletableFuture { - return try { - parameter.getSuggestions(context, builder) - } catch (e: CommandSyntaxException) { - builder.buildFuture() - } + builder: SuggestionsBuilder, + ): CompletableFuture = try { + parameter.getSuggestions(context, builder) + } catch (e: CommandSyntaxException) { + builder.buildFuture() } open fun getRemaining(s: String): Int { @@ -238,7 +243,7 @@ object SearchParamArgument { private class NegatableParameter(parameter: SimpleParameter) : Parameter(parameter) { override fun listSuggestions( context: CommandContext, - builder: SuggestionsBuilder + builder: SuggestionsBuilder, ): CompletableFuture { val builder = if (builder.remaining.startsWith("!")) builder.createOffset(builder.start + 1) else builder return super.listSuggestions(context, builder) diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/ActionParameter.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/ActionParameter.kt index 49f392b3..8d5ce15f 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/ActionParameter.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/ActionParameter.kt @@ -13,13 +13,13 @@ import java.util.concurrent.CompletableFuture class ActionParameter : SimpleParameter() { override fun getSuggestions( context: CommandContext, - builder: SuggestionsBuilder + builder: SuggestionsBuilder, ): CompletableFuture { val types = ActionRegistry.getTypes() // Need to check equality to catch null return SharedSuggestionProvider.suggest( types, - builder + builder, ) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/DimensionParameter.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/DimensionParameter.kt index 7150b56a..859a7416 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/DimensionParameter.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/DimensionParameter.kt @@ -14,6 +14,6 @@ class DimensionParameter : SimpleParameter() { override fun getSuggestions( context: CommandContext, - builder: SuggestionsBuilder + builder: SuggestionsBuilder, ): CompletableFuture = DimensionArgument.dimension().listSuggestions(context, builder) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/ObjectParameter.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/ObjectParameter.kt index 45a0e621..b439e699 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/ObjectParameter.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/ObjectParameter.kt @@ -29,22 +29,22 @@ class ObjectParameter : SimpleParameter>() { val blockTag = TagKey.create(Registries.BLOCK, tagId) if (blockTag != null) { return BuiltInRegistries.BLOCK.getTagOrEmpty( - blockTag + blockTag, ).map { BuiltInRegistries.BLOCK.getKey(it.value()) } } val itemTag = TagKey.create(Registries.ITEM, tagId) if (itemTag != null) { BuiltInRegistries.ITEM.getTagOrEmpty( - itemTag + itemTag, ).map { BuiltInRegistries.ITEM.getKey(it.value()) } } val entityTag = TagKey.create(Registries.ENTITY_TYPE, tagId) if (entityTag != null) { return BuiltInRegistries.ENTITY_TYPE.getTagOrEmpty(entityTag).map { - BuiltInRegistries.ENTITY_TYPE.getKey(it.value()) - } + BuiltInRegistries.ENTITY_TYPE.getKey(it.value()) + } } } @@ -53,22 +53,20 @@ class ObjectParameter : SimpleParameter>() { override fun getSuggestions( context: CommandContext, - builder: SuggestionsBuilder - ): CompletableFuture { - return if (builder.remaining.startsWith("#")) { - SharedSuggestionProvider.suggestResource( - mutableListOf().apply { - addAll(BuiltInRegistries.BLOCK.tags.map { it.key().location }.toList()) - addAll(BuiltInRegistries.ITEM.tags.map { it.key().location }.toList()) - addAll(BuiltInRegistries.ENTITY_TYPE.tags.map { it.key().location }.toList()) - }, - builder.createOffset(builder.start + 1) - ) - } else { - SharedSuggestionProvider.suggestResource( - identifiers, - builder - ) - } + builder: SuggestionsBuilder, + ): CompletableFuture = if (builder.remaining.startsWith("#")) { + SharedSuggestionProvider.suggestResource( + mutableListOf().apply { + addAll(BuiltInRegistries.BLOCK.tags.map { it.key().location }.toList()) + addAll(BuiltInRegistries.ITEM.tags.map { it.key().location }.toList()) + addAll(BuiltInRegistries.ENTITY_TYPE.tags.map { it.key().location }.toList()) + }, + builder.createOffset(builder.start + 1), + ) + } else { + SharedSuggestionProvider.suggestResource( + identifiers, + builder, + ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/RangeParameter.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/RangeParameter.kt index 775371ab..c76c6110 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/RangeParameter.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/RangeParameter.kt @@ -32,7 +32,7 @@ class RangeParameter : SimpleParameter() { override fun getSuggestions( context: CommandContext, - builder: SuggestionsBuilder + builder: SuggestionsBuilder, ): CompletableFuture { val remaining = builder.remaining.lowercase() val reader = StringReader(remaining) diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/RollbackStatusParameter.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/RollbackStatusParameter.kt index 9dbb2b03..2b3a724e 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/RollbackStatusParameter.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/RollbackStatusParameter.kt @@ -13,6 +13,6 @@ class RollbackStatusParameter : SimpleParameter() { override fun getSuggestions( context: CommandContext, - builder: SuggestionsBuilder + builder: SuggestionsBuilder, ): CompletableFuture = BoolArgumentType.bool().listSuggestions(context, builder) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/SourceParameter.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/SourceParameter.kt index 8fbb4abf..464a50d2 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/SourceParameter.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/SourceParameter.kt @@ -22,7 +22,7 @@ class SourceParameter : SimpleParameter() { override fun getSuggestions( context: CommandContext, - builder: SuggestionsBuilder + builder: SuggestionsBuilder, ): CompletableFuture { val stringReader = StringReader(builder.input) stringReader.cursor = builder.start @@ -33,7 +33,7 @@ class SourceParameter : SimpleParameter() { } return SharedSuggestionProvider.suggest( sources, - builder + builder, ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/TimeParameter.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/TimeParameter.kt index d14efef7..9b976fc3 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/TimeParameter.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/parameters/TimeParameter.kt @@ -50,7 +50,7 @@ class TimeParameter : SimpleParameter() { override fun getSuggestions( context: CommandContext, - builder: SuggestionsBuilder + builder: SuggestionsBuilder, ): CompletableFuture { val remaining = builder.remaining.lowercase() for (unit in units) { diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/InspectCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/InspectCommand.kt index c4745f0d..3933ece7 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/InspectCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/InspectCommand.kt @@ -15,23 +15,22 @@ import net.minecraft.commands.arguments.coordinates.BlockPosArgument import net.minecraft.core.BlockPos object InspectCommand : BuildableCommand { - override fun build(): LiteralNode = - literal("inspect") - .requires(Permissions.require("ledger.commands.inspect", CommandConsts.PERMISSION_LEVEL)) - .executes { toggleInspect(it) } - .then( - literal("on") - .executes { it.source.playerOrException.inspectOn() } - ) - .then( - literal("off") - .executes { it.source.playerOrException.inspectOff() } - ) - .then( - argument("pos", BlockPosArgument.blockPos()) - .executes { inspectBlock(it, BlockPosArgument.getBlockPos(it, "pos")) } - ) - .build() + override fun build(): LiteralNode = literal("inspect") + .requires(Permissions.require("ledger.commands.inspect", CommandConsts.PERMISSION_LEVEL)) + .executes { toggleInspect(it) } + .then( + literal("on") + .executes { it.source.playerOrException.inspectOn() }, + ) + .then( + literal("off") + .executes { it.source.playerOrException.inspectOff() }, + ) + .then( + argument("pos", BlockPosArgument.blockPos()) + .executes { inspectBlock(it, BlockPosArgument.getBlockPos(it, "pos")) }, + ) + .build() private fun toggleInspect(context: Context): Int { val source = context.source diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PageCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PageCommand.kt index 67bc9c4b..5e29712a 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PageCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PageCommand.kt @@ -14,13 +14,12 @@ import net.minecraft.commands.Commands.literal import net.minecraft.network.chat.Component object PageCommand : BuildableCommand { - override fun build(): LiteralNode = - literal("page") - .then( - argument("page", IntegerArgumentType.integer(1)) - .executes { page(it, IntegerArgumentType.getInteger(it, "page")) } - ) - .build() + override fun build(): LiteralNode = literal("page") + .then( + argument("page", IntegerArgumentType.integer(1)) + .executes { page(it, IntegerArgumentType.getInteger(it, "page")) }, + ) + .build() private fun page(context: Context, page: Int): Int { val source = context.source @@ -40,8 +39,8 @@ object PageCommand : BuildableCommand { source, results, Component.translatable( - "text.ledger.header.search" - ).setStyle(TextColorPallet.primary) + "text.ledger.header.search", + ).setStyle(TextColorPallet.primary), ) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PlayerCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PlayerCommand.kt index aa65ff5d..a4e25ab3 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PlayerCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PlayerCommand.kt @@ -20,9 +20,9 @@ object PlayerCommand : BuildableCommand { .requires(Permissions.require("ledger.commands.player", CommandConsts.PERMISSION_LEVEL)) .then( argument("player", GameProfileArgument.gameProfile()) - .executes { - return@executes lookupPlayer(GameProfileArgument.getGameProfiles(it, "player"), it.source) - } + .executes { + return@executes lookupPlayer(GameProfileArgument.getGameProfiles(it, "player"), it.source) + }, ) .build() } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PreviewCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PreviewCommand.kt index 56f86239..9f73b09c 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PreviewCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PreviewCommand.kt @@ -16,39 +16,37 @@ import net.minecraft.commands.Commands import net.minecraft.network.chat.Component object PreviewCommand : BuildableCommand { - override fun build(): LiteralNode { - return Commands.literal("preview") - .requires(Permissions.require("ledger.commands.preview", CommandConsts.PERMISSION_LEVEL)) - .then( - Commands.literal("rollback") + override fun build(): LiteralNode = Commands.literal("preview") + .requires(Permissions.require("ledger.commands.preview", CommandConsts.PERMISSION_LEVEL)) + .then( + Commands.literal("rollback") .then( SearchParamArgument.argument(CommandConsts.PARAMS) .executes { preview( it, SearchParamArgument.get(it, CommandConsts.PARAMS), - Preview.Type.ROLLBACK + Preview.Type.ROLLBACK, ) - } - ) - ) - .then( - Commands.literal("restore") + }, + ), + ) + .then( + Commands.literal("restore") .then( SearchParamArgument.argument(CommandConsts.PARAMS) .executes { preview( it, SearchParamArgument.get(it, CommandConsts.PARAMS), - Preview.Type.RESTORE + Preview.Type.RESTORE, ) - } - ) - ) - .then(Commands.literal("apply").executes { apply(it) }) - .then(Commands.literal("cancel").executes { cancel(it) }) - .build() - } + }, + ), + ) + .then(Commands.literal("apply").executes { apply(it) }) + .then(Commands.literal("cancel").executes { cancel(it) }) + .build() private fun preview(context: Context, params: ActionSearchParams, type: Preview.Type): Int { val source = context.source diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PurgeCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PurgeCommand.kt index 80dd33f3..7308c683 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PurgeCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/PurgeCommand.kt @@ -17,28 +17,26 @@ import net.minecraft.commands.Commands.literal import net.minecraft.network.chat.Component object PurgeCommand : BuildableCommand { - override fun build(): LiteralNode { - return literal("purge") - .requires(Permissions.require("ledger.commands.purge", config[SearchSpec.purgePermissionLevel])) - .then( - SearchParamArgument.argument(CommandConsts.PARAMS).executes { + override fun build(): LiteralNode = literal("purge") + .requires(Permissions.require("ledger.commands.purge", config[SearchSpec.purgePermissionLevel])) + .then( + SearchParamArgument.argument(CommandConsts.PARAMS).executes { runPurge(it, SearchParamArgument.get(it, CommandConsts.PARAMS)) - } - ) - .build() - } + }, + ) + .build() private fun runPurge(ctx: Context, params: ActionSearchParams): Int { val source = ctx.source source.sendSuccess( { Component.translatable("text.ledger.purge.starting").setStyle(TextColorPallet.secondary) }, - true + true, ) Ledger.launch { DatabaseManager.purgeActions(params) source.sendSuccess( { Component.translatable("text.ledger.purge.complete").setStyle(TextColorPallet.secondary) }, - true + true, ) } return 1 diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/RestoreCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/RestoreCommand.kt index f2c55023..b165dbed 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/RestoreCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/RestoreCommand.kt @@ -18,15 +18,13 @@ import net.minecraft.commands.Commands import net.minecraft.network.chat.Component object RestoreCommand : BuildableCommand { - override fun build(): LiteralNode { - return Commands.literal("restore") - .requires(Permissions.require("ledger.commands.rollback", CommandConsts.PERMISSION_LEVEL)) - .then( - SearchParamArgument.argument("params") - .executes { restore(it, SearchParamArgument.get(it, "params")) } - ) - .build() - } + override fun build(): LiteralNode = Commands.literal("restore") + .requires(Permissions.require("ledger.commands.rollback", CommandConsts.PERMISSION_LEVEL)) + .then( + SearchParamArgument.argument("params") + .executes { restore(it, SearchParamArgument.get(it, "params")) }, + ) + .build() fun restore(context: Context, params: ActionSearchParams): Int { val source = context.source @@ -44,10 +42,10 @@ object RestoreCommand : BuildableCommand { { Component.translatable( "text.ledger.restore.start", - actions.size.toString().literal().setStyle(TextColorPallet.secondary) + actions.size.toString().literal().setStyle(TextColorPallet.secondary), ).setStyle(TextColorPallet.primary) }, - true + true, ) context.source.level.launchMain { @@ -68,10 +66,10 @@ object RestoreCommand : BuildableCommand { source.sendSuccess( { Component.translatable("text.ledger.restore.fail", entry.key, entry.value).setStyle( - TextColorPallet.secondary + TextColorPallet.secondary, ) }, - true + true, ) } @@ -79,10 +77,10 @@ object RestoreCommand : BuildableCommand { { Component.translatable( "text.ledger.restore.finish", - actions.size + actions.size, ).setStyle(TextColorPallet.primary) }, - true + true, ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/RollbackCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/RollbackCommand.kt index 6a55bac7..cf69d8c2 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/RollbackCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/RollbackCommand.kt @@ -18,15 +18,13 @@ import net.minecraft.commands.Commands import net.minecraft.network.chat.Component object RollbackCommand : BuildableCommand { - override fun build(): LiteralNode { - return Commands.literal("rollback") - .requires(Permissions.require("ledger.commands.rollback", CommandConsts.PERMISSION_LEVEL)) - .then( - SearchParamArgument.argument("params") - .executes { rollback(it, SearchParamArgument.get(it, "params")) } - ) - .build() - } + override fun build(): LiteralNode = Commands.literal("rollback") + .requires(Permissions.require("ledger.commands.rollback", CommandConsts.PERMISSION_LEVEL)) + .then( + SearchParamArgument.argument("params") + .executes { rollback(it, SearchParamArgument.get(it, "params")) }, + ) + .build() fun rollback(context: Context, params: ActionSearchParams): Int { val source = context.source @@ -44,10 +42,10 @@ object RollbackCommand : BuildableCommand { { Component.translatable( "text.ledger.rollback.start", - actions.size.toString().literal().setStyle(TextColorPallet.secondary) + actions.size.toString().literal().setStyle(TextColorPallet.secondary), ).setStyle(TextColorPallet.primary) }, - true + true, ) context.source.level.launchMain { @@ -68,10 +66,10 @@ object RollbackCommand : BuildableCommand { source.sendSuccess( { Component.translatable("text.ledger.rollback.fail", entry.key, entry.value).setStyle( - TextColorPallet.secondary + TextColorPallet.secondary, ) }, - true + true, ) } @@ -79,10 +77,10 @@ object RollbackCommand : BuildableCommand { { Component.translatable( "text.ledger.rollback.finish", - actions.size + actions.size, ).setStyle(TextColorPallet.primary) }, - true + true, ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/SearchCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/SearchCommand.kt index b8983793..2d65a848 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/SearchCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/SearchCommand.kt @@ -16,15 +16,13 @@ import net.minecraft.commands.Commands.literal import net.minecraft.network.chat.Component object SearchCommand : BuildableCommand { - override fun build(): LiteralNode { - return literal("search") - .requires(Permissions.require("ledger.commands.search", CommandConsts.PERMISSION_LEVEL)) - .then( - SearchParamArgument.argument("params") - .executes { search(it, SearchParamArgument.get(it, "params")) } - ) - .build() - } + override fun build(): LiteralNode = literal("search") + .requires(Permissions.require("ledger.commands.search", CommandConsts.PERMISSION_LEVEL)) + .then( + SearchParamArgument.argument("params") + .executes { search(it, SearchParamArgument.get(it, "params")) }, + ) + .build() private fun search(context: Context, params: ActionSearchParams): Int { val source = context.source @@ -44,8 +42,8 @@ object SearchCommand : BuildableCommand { source, results, Component.translatable( - "text.ledger.header.search" - ).setStyle(TextColorPallet.primary) + "text.ledger.header.search", + ).setStyle(TextColorPallet.primary), ) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/StatusCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/StatusCommand.kt index 52745ca4..9daf0acb 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/StatusCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/StatusCommand.kt @@ -20,39 +20,38 @@ import net.minecraft.network.chat.Component import java.net.URI object StatusCommand : BuildableCommand { - override fun build(): LiteralNode = - Commands.literal("status") - .requires(Permissions.require("ledger.commands.status", CommandConsts.PERMISSION_LEVEL)) - .executes { status(it) } - .build() + override fun build(): LiteralNode = Commands.literal("status") + .requires(Permissions.require("ledger.commands.status", CommandConsts.PERMISSION_LEVEL)) + .executes { status(it) } + .build() private fun status(context: Context): Int { Ledger.launch { val source = context.source source.sendSystemMessage( Component.translatable("text.ledger.header.status") - .setStyle(TextColorPallet.primary) + .setStyle(TextColorPallet.primary), ) source.sendSystemMessage( Component.translatable( "text.ledger.status.queue", ActionQueueService.size.toString().literal() - .setStyle(TextColorPallet.secondaryVariant) - ).setStyle(TextColorPallet.secondary) + .setStyle(TextColorPallet.secondaryVariant), + ).setStyle(TextColorPallet.secondary), ) source.sendSystemMessage( Component.translatable( "text.ledger.status.version", getVersion().friendlyString.literal() - .setStyle(TextColorPallet.secondaryVariant) - ).setStyle(TextColorPallet.secondary) + .setStyle(TextColorPallet.secondaryVariant), + ).setStyle(TextColorPallet.secondary), ) source.sendSystemMessage( Component.translatable( "text.ledger.status.db_type", DatabaseManager.databaseType.literal() - .setStyle(TextColorPallet.secondaryVariant) - ).setStyle(TextColorPallet.secondary) + .setStyle(TextColorPallet.secondaryVariant), + ).setStyle(TextColorPallet.secondary), ) source.sendSystemMessage( Component.translatable( @@ -62,11 +61,11 @@ object StatusCommand : BuildableCommand { .withStyle { it.withClickEvent( ClickEvent.OpenUrl( - URI("https://discord.gg/FpRNYrQaGP") - ) + URI("https://discord.gg/FpRNYrQaGP"), + ), ) - } - ).setStyle(TextColorPallet.secondary) + }, + ).setStyle(TextColorPallet.secondary), ) source.sendSystemMessage( Component.translatable( @@ -76,11 +75,11 @@ object StatusCommand : BuildableCommand { .withStyle { it.withClickEvent( ClickEvent.OpenUrl( - URI("https://www.quiltservertools.net/Ledger/${getVersion().friendlyString}/") - ) + URI("https://www.quiltservertools.net/Ledger/${getVersion().friendlyString}/"), + ), ) - } - ).setStyle(TextColorPallet.secondary) + }, + ).setStyle(TextColorPallet.secondary), ) } @@ -88,6 +87,6 @@ object StatusCommand : BuildableCommand { } private fun getVersion() = SemanticVersion.parse( - FabricLoader.getInstance().getModContainer(Ledger.MOD_ID).get().metadata.version.friendlyString + FabricLoader.getInstance().getModContainer(Ledger.MOD_ID).get().metadata.version.friendlyString, ) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/TeleportCommand.kt b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/TeleportCommand.kt index 23a933a6..d77bfc2a 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/TeleportCommand.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/commands/subcommands/TeleportCommand.kt @@ -13,23 +13,22 @@ import net.minecraft.server.level.ServerLevel object TeleportCommand : BuildableCommand { private const val BLOCK_CENTER_OFFSET = 0.5 - override fun build(): LiteralNode = - Commands.literal("tp") - .requires(Permissions.require("ledger.commands.tp", CommandConsts.PERMISSION_LEVEL)) - .then( - Commands.argument("world", DimensionArgument.dimension()) - .then( - Commands.argument("location", Vec3Argument.vec3()) - .executes { - teleport( - it, - DimensionArgument.getDimension(it, "world"), - Vec3Argument.getCoordinates(it, "location") - ) - } - ) - ) - .build() + override fun build(): LiteralNode = Commands.literal("tp") + .requires(Permissions.require("ledger.commands.tp", CommandConsts.PERMISSION_LEVEL)) + .then( + Commands.argument("world", DimensionArgument.dimension()) + .then( + Commands.argument("location", Vec3Argument.vec3()) + .executes { + teleport( + it, + DimensionArgument.getDimension(it, "world"), + Vec3Argument.getCoordinates(it, "location"), + ) + }, + ), + ) + .build() private fun teleport(context: Context, world: ServerLevel, posArg: Coordinates): Int { val player = context.source.playerOrException @@ -46,7 +45,7 @@ object TeleportCommand : BuildableCommand { emptySet(), player.yRot, player.xRot, - true + true, ) return 1 diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/config/util/IdentifierSerialization.kt b/src/main/kotlin/com/github/quiltservertools/ledger/config/util/IdentifierSerialization.kt index f691772a..1f3ffb11 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/config/util/IdentifierSerialization.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/config/util/IdentifierSerialization.kt @@ -17,10 +17,8 @@ object IdentifierSerializer : JsonSerializer() { } object IdentifierDeserializer : JsonDeserializer() { - override fun deserialize( - p: JsonParser, - ctxt: DeserializationContext - ): Identifier = Identifier.parse(p.valueAsString) + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Identifier = + Identifier.parse(p.valueAsString) } @JsonSerialize(using = IdentifierSerializer::class) diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/database/DatabaseManager.kt b/src/main/kotlin/com/github/quiltservertools/ledger/database/DatabaseManager.kt index d99f66c7..987d5c11 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/database/DatabaseManager.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/database/DatabaseManager.kt @@ -105,7 +105,7 @@ object DatabaseManager { return SQLiteDataSource( SQLiteConfig().apply { setJournalMode(SQLiteConfig.JournalMode.WAL) - } + }, ).apply { url = "jdbc:sqlite:$dbFilepath" } @@ -203,10 +203,7 @@ object DatabaseManager { return@execute getActionsFromQuery(query) } - suspend fun previewActions( - params: ActionSearchParams, - type: Preview.Type - ): List = execute { + suspend fun previewActions(params: ActionSearchParams, type: Preview.Type): List = execute { when (type) { Preview.Type.ROLLBACK -> return@execute selectRollback(params) Preview.Type.RESTORE -> return@execute selectRestore(params) @@ -225,7 +222,7 @@ object DatabaseManager { for (action in query) { val typeSupplier = ActionRegistry.getType( - actionIdentifierCache[action[Tables.Actions.actionIdentifier].value]!! + actionIdentifierCache[action[Tables.Actions.actionIdentifier].value]!!, ) if (typeSupplier == null) { logWarn("Unknown action type ${actionIdentifierCache[action[Tables.Actions.actionIdentifier].value]}") @@ -281,21 +278,21 @@ object DatabaseManager { op, params.sourceNames, DatabaseManager::getSourceId, - Tables.Actions.sourceName + Tables.Actions.sourceName, ) op = addParameters( op, params.actions, DatabaseManager::getActionId, - Tables.Actions.actionIdentifier + Tables.Actions.actionIdentifier, ) op = addParameters( op, params.worlds, DatabaseManager::getWorldId, - Tables.Actions.world + Tables.Actions.world, ) op = addParameters( @@ -303,14 +300,14 @@ object DatabaseManager { params.objects, DatabaseManager::getRegistryKeyId, Tables.Actions.objectId, - Tables.Actions.oldObjectId + Tables.Actions.oldObjectId, ) op = addParameters( op, params.sourcePlayerIds, DatabaseManager::getPlayerId, - Tables.Actions.sourcePlayer + Tables.Actions.sourcePlayer, ) return op @@ -342,10 +339,7 @@ object DatabaseManager { column: Column, orColumn: Column? = null, ): Op { - fun addAllowedParameters( - allowed: Collection, - op: Op - ): Op { + fun addAllowedParameters(allowed: Collection, op: Op): Op { if (allowed.isEmpty()) return op var operator = if (orColumn != null) { @@ -365,10 +359,7 @@ object DatabaseManager { return op.and { operator } } - fun addDeniedParameters( - denied: Collection, - op: Op - ): Op { + fun addDeniedParameters(denied: Collection, op: Op): Op { if (denied.isEmpty()) return op var operator = if (orColumn != null) { @@ -403,25 +394,21 @@ object DatabaseManager { } } - suspend fun registerWorld(identifier: Identifier) = - execute { - insertWorld(identifier) - } + suspend fun registerWorld(identifier: Identifier) = execute { + insertWorld(identifier) + } - suspend fun registerActionType(id: String) = - execute { - insertActionType(id) - } + suspend fun registerActionType(id: String) = execute { + insertActionType(id) + } - suspend fun logPlayer(uuid: UUID, name: String) = - execute { - insertOrUpdatePlayer(uuid, name) - } + suspend fun logPlayer(uuid: UUID, name: String) = execute { + insertOrUpdatePlayer(uuid, name) + } - suspend fun insertIdentifiers(identifiers: Collection) = - execute { - insertRegKeys(identifiers) - } + suspend fun insertIdentifiers(identifiers: Collection) = execute { + insertRegKeys(identifiers) + } private suspend fun execute(body: suspend Transaction.() -> T): T { while (Ledger.server.overworld()?.noSave != false) { @@ -446,10 +433,9 @@ object DatabaseManager { } } - suspend fun searchPlayers(players: Set): List = - execute { - return@execute selectPlayers(players) - } + suspend fun searchPlayers(players: Set): List = execute { + return@execute selectPlayers(players) + } private fun Transaction.insertActionType(id: String) { Tables.ActionIdentifiers.insertIgnore { @@ -480,7 +466,7 @@ object DatabaseManager { this[Tables.Actions.oldObjectId] = getOrCreateRegistryKeyId(action.oldObjectIdentifier) this[Tables.Actions.world] = getOrCreateWorldId( action.world ?: Ledger.server.overworld().dimension() - .identifier() + .identifier(), ) this[Tables.Actions.blockState] = action.objectState this[Tables.Actions.oldBlockState] = action.oldObjectState @@ -519,7 +505,7 @@ object DatabaseManager { query = query.orderBy(Tables.Actions.id, SortOrder.DESC) query = query.limit(config[SearchSpec.pageSize]).offset( - (config[SearchSpec.pageSize] * (page - 1)).toLong() + (config[SearchSpec.pageSize] * (page - 1)).toLong(), ) // TODO better pagination without offset - probably doesn't matter as most people stay on first few pages actions.addAll(getActionsFromQuery(query)) @@ -548,14 +534,13 @@ object DatabaseManager { } } - fun getKnownSources() = - cache.sourceKeys.keys + fun getKnownSources() = cache.sourceKeys.keys private fun getObjectId( obj: T, cache: BiMap, table: EntityClass>, - column: Column + column: Column, ): Int? = getObjectId(obj, Function.identity(), cache, table, column) private fun getObjectId( @@ -563,7 +548,7 @@ object DatabaseManager { mapper: Function, cache: BiMap, table: EntityClass>, - column: Column + column: Column, ): Int? { if (cache.containsKey(obj)) { return cache[obj] @@ -578,9 +563,8 @@ object DatabaseManager { cache: BiMap, entity: IntEntityClass<*>, table: IntIdTable, - column: Column - ): Int = - getOrCreateObjectId(obj, Function.identity(), cache, entity, table, column) + column: Column, + ): Int = getOrCreateObjectId(obj, Function.identity(), cache, entity, table, column) private fun getOrCreateObjectId( obj: T, @@ -588,14 +572,14 @@ object DatabaseManager { cache: BiMap, entity: IntEntityClass<*>, table: IntIdTable, - column: Column + column: Column, ): Int { getObjectId(obj, mapper, cache, entity, column)?.let { return it } return entity[ table.insertAndGetId { it[column] = mapper.apply(obj) - } + }, ].id.value.also { cache.put(obj!!, it) } } @@ -605,34 +589,31 @@ object DatabaseManager { private fun getOrCreateSourceId(source: String): Int = getOrCreateObjectId(source, cache.sourceKeys, Tables.Source, Tables.Sources, Tables.Sources.name) - private fun getOrCreateActionId(actionTypeId: String): Int = - getOrCreateObjectId( - actionTypeId, - cache.actionIdentifierKeys, - Tables.ActionIdentifier, - Tables.ActionIdentifiers, - Tables.ActionIdentifiers.actionIdentifier - ) - - private fun getOrCreateRegistryKeyId(identifier: Identifier): Int = - getOrCreateObjectId( - identifier, - Identifier::toString, - cache.objectIdentifierKeys, - Tables.ObjectIdentifier, - Tables.ObjectIdentifiers, - Tables.ObjectIdentifiers.identifier - ) - - private fun getOrCreateWorldId(identifier: Identifier): Int = - getOrCreateObjectId( - identifier, - Identifier::toString, - cache.worldIdentifierKeys, - Tables.World, - Tables.Worlds, - Tables.Worlds.identifier - ) + private fun getOrCreateActionId(actionTypeId: String): Int = getOrCreateObjectId( + actionTypeId, + cache.actionIdentifierKeys, + Tables.ActionIdentifier, + Tables.ActionIdentifiers, + Tables.ActionIdentifiers.actionIdentifier, + ) + + private fun getOrCreateRegistryKeyId(identifier: Identifier): Int = getOrCreateObjectId( + identifier, + Identifier::toString, + cache.objectIdentifierKeys, + Tables.ObjectIdentifier, + Tables.ObjectIdentifiers, + Tables.ObjectIdentifiers.identifier, + ) + + private fun getOrCreateWorldId(identifier: Identifier): Int = getOrCreateObjectId( + identifier, + Identifier::toString, + cache.worldIdentifierKeys, + Tables.World, + Tables.Worlds, + Tables.Worlds.identifier, + ) private fun getPlayerId(playerId: UUID): Int? = getObjectId(playerId, cache.playerKeys, Tables.Player, Tables.Players.playerId) @@ -640,31 +621,28 @@ object DatabaseManager { private fun getSourceId(source: String): Int? = getObjectId(source, cache.sourceKeys, Tables.Source, Tables.Sources.name) - private fun getActionId(actionTypeId: String): Int? = - getObjectId( - actionTypeId, - cache.actionIdentifierKeys, - Tables.ActionIdentifier, - Tables.ActionIdentifiers.actionIdentifier - ) - - private fun getRegistryKeyId(identifier: Identifier): Int? = - getObjectId( - identifier, - Identifier::toString, - cache.objectIdentifierKeys, - Tables.ObjectIdentifier, - Tables.ObjectIdentifiers.identifier - ) - - private fun getWorldId(identifier: Identifier): Int? = - getObjectId( - identifier, - Identifier::toString, - cache.worldIdentifierKeys, - Tables.World, - Tables.Worlds.identifier - ) + private fun getActionId(actionTypeId: String): Int? = getObjectId( + actionTypeId, + cache.actionIdentifierKeys, + Tables.ActionIdentifier, + Tables.ActionIdentifiers.actionIdentifier, + ) + + private fun getRegistryKeyId(identifier: Identifier): Int? = getObjectId( + identifier, + Identifier::toString, + cache.objectIdentifierKeys, + Tables.ObjectIdentifier, + Tables.ObjectIdentifiers.identifier, + ) + + private fun getWorldId(identifier: Identifier): Int? = getObjectId( + identifier, + Identifier::toString, + cache.worldIdentifierKeys, + Tables.World, + Tables.Worlds.identifier, + ) // Workaround because can't delete from a join in exposed https://kotlinlang.slack.com/archives/C0CG7E0A1/p1605866974117400 private fun Transaction.purgeActions(params: ActionSearchParams) = Tables.Actions diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/listeners/BlockEventListener.kt b/src/main/kotlin/com/github/quiltservertools/ledger/listeners/BlockEventListener.kt index d8eba1e6..48800fca 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/listeners/BlockEventListener.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/listeners/BlockEventListener.kt @@ -28,7 +28,7 @@ fun onBlockPlace( state: BlockState, entity: BlockEntity?, source: String, - player: Player? + player: Player?, ) { val action: ActionType = if (player != null) { ActionFactory.blockPlaceAction(world, pos, state, player, entity, source) @@ -44,7 +44,7 @@ fun onBlockBreak( state: BlockState, entity: BlockEntity?, source: String, - player: Player? + player: Player?, ) { val action: ActionType = if (player != null) { ActionFactory.blockBreakAction(world, pos, state, player, entity, source) @@ -63,20 +63,20 @@ fun onBlockChange( oldBlockEntity: BlockEntity?, newBlockEntity: BlockEntity?, source: String, - player: Player? + player: Player?, ) { ActionQueueService.addToQueue( - ActionFactory.blockChangeAction(world, pos, oldState, newState, oldBlockEntity, source, player) + ActionFactory.blockChangeAction(world, pos, oldState, newState, oldBlockEntity, source, player), ) } fun onMelt(world: Level, pos: BlockPos, oldState: BlockState, newState: BlockState, entity: BlockEntity?) { ActionQueueService.addToQueue( - ActionFactory.blockBreakAction(world, pos, oldState, Sources.MELT, entity) + ActionFactory.blockBreakAction(world, pos, oldState, Sources.MELT, entity), ) if (newState.block !is AirBlock) { ActionQueueService.addToQueue( - ActionFactory.blockPlaceAction(world, pos, newState, Sources.MELT, entity) + ActionFactory.blockPlaceAction(world, pos, newState, Sources.MELT, entity), ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/listeners/EntityCallbackListener.kt b/src/main/kotlin/com/github/quiltservertools/ledger/listeners/EntityCallbackListener.kt index db686342..6c1f3c71 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/listeners/EntityCallbackListener.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/listeners/EntityCallbackListener.kt @@ -16,25 +16,15 @@ fun registerEntityListeners() { EntityModifyCallback.EVENT.register(::onModify) } -private fun onKill( - world: Level, - pos: BlockPos, - entity: Entity, - source: DamageSource -) { +private fun onKill(world: Level, pos: BlockPos, entity: Entity, source: DamageSource) { ActionQueueService.addToQueue( - ActionFactory.entityKillAction(world, pos, entity, source) + ActionFactory.entityKillAction(world, pos, entity, source), ) } -fun onKill( - world: Level, - pos: BlockPos, - entity: Entity, - source: String -) { +fun onKill(world: Level, pos: BlockPos, entity: Entity, source: String) { ActionQueueService.addToQueue( - ActionFactory.entityKillAction(world, pos, entity, source) + ActionFactory.entityKillAction(world, pos, entity, source), ) } @@ -45,9 +35,9 @@ private fun onModify( entity: Entity, itemStack: ItemStack?, entityActor: Entity?, - sourceType: String + sourceType: String, ) { ActionQueueService.addToQueue( - ActionFactory.entityChangeAction(world, pos, oldEntityTags, entity, itemStack, entityActor, sourceType) + ActionFactory.entityChangeAction(world, pos, oldEntityTags, entity, itemStack, entityActor, sourceType), ) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/listeners/PlayerEventListener.kt b/src/main/kotlin/com/github/quiltservertools/ledger/listeners/PlayerEventListener.kt index a1a8c72c..414ae4d7 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/listeners/PlayerEventListener.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/listeners/PlayerEventListener.kt @@ -54,7 +54,7 @@ private fun onUseBlock( player: Player, world: Level, hand: InteractionHand, - blockHitResult: BlockHitResult + blockHitResult: BlockHitResult, ): InteractionResult { if (player is ServerPlayer && player.isInspecting() && hand == InteractionHand.MAIN_HAND) { player.createCommandSourceStack().inspectBlock(blockHitResult.blockPos.relative(blockHitResult.direction)) @@ -68,7 +68,7 @@ private fun onBlockAttack( world: Level, hand: InteractionHand, pos: BlockPos, - direction: Direction + direction: Direction, ): InteractionResult { if (player is ServerPlayer && player.isInspecting()) { player.createCommandSourceStack().inspectBlock(pos) @@ -89,7 +89,7 @@ private fun onBlockPlace( pos: BlockPos, state: BlockState, context: BlockPlaceContext?, - blockEntity: BlockEntity? + blockEntity: BlockEntity?, ) { ActionQueueService.addToQueue( ActionFactory.blockPlaceAction( @@ -97,53 +97,35 @@ private fun onBlockPlace( pos, state, player, - blockEntity - ) + blockEntity, + ), ) } -private fun onBlockBreak( - world: Level, - player: Player, - pos: BlockPos, - state: BlockState, - blockEntity: BlockEntity? -) { +private fun onBlockBreak(world: Level, player: Player, pos: BlockPos, state: BlockState, blockEntity: BlockEntity?) { ActionQueueService.addToQueue( ActionFactory.blockBreakAction( world, pos, state, player, - blockEntity - ) + blockEntity, + ), ) } -private fun onItemPickUp( - entity: ItemEntity, - player: Player -) { +private fun onItemPickUp(entity: ItemEntity, player: Player) { ActionQueueService.addToQueue(ActionFactory.itemPickUpAction(entity, player)) } -private fun onItemDrop( - entity: ItemEntity, - playerOrGolem: LivingEntity -) { +private fun onItemDrop(entity: ItemEntity, playerOrGolem: LivingEntity) { ActionQueueService.addToQueue(ActionFactory.itemDropAction(entity, playerOrGolem)) } -private fun onEntityMount( - entity: Entity, - playerEntity: Player, -) { +private fun onEntityMount(entity: Entity, playerEntity: Player) { ActionQueueService.addToQueue(ActionFactory.entityMountAction(entity, playerEntity)) } -private fun onEntityDismount( - entity: Entity, - playerEntity: Player, -) { +private fun onEntityDismount(entity: Entity, playerEntity: Player) { ActionQueueService.addToQueue(ActionFactory.entityDismountAction(entity, playerEntity)) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/listeners/WorldEventListener.kt b/src/main/kotlin/com/github/quiltservertools/ledger/listeners/WorldEventListener.kt index 5f4aaa02..94796579 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/listeners/WorldEventListener.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/listeners/WorldEventListener.kt @@ -7,7 +7,7 @@ import com.github.quiltservertools.ledger.callbacks.ItemRemoveCallback import com.github.quiltservertools.ledger.database.ActionQueueService import com.github.quiltservertools.ledger.database.DatabaseManager import kotlinx.coroutines.launch -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLevelEvents import net.minecraft.core.BlockPos import net.minecraft.server.MinecraftServer import net.minecraft.server.level.ServerLevel @@ -17,7 +17,7 @@ import net.minecraft.world.item.ItemStack fun registerWorldEventListeners() { ItemInsertCallback.EVENT.register(::onItemInsert) ItemRemoveCallback.EVENT.register(::onItemRemove) - ServerWorldEvents.LOAD.register(::onWorldLoad) + ServerLevelEvents.LOAD.register(::onWorldLoad) } fun onWorldLoad(server: MinecraftServer, world: ServerLevel) { @@ -26,38 +26,26 @@ fun onWorldLoad(server: MinecraftServer, world: ServerLevel) { } } -private fun onItemRemove( - stack: ItemStack, - pos: BlockPos, - world: ServerLevel, - source: String, - entity: LivingEntity? -) { +private fun onItemRemove(stack: ItemStack, pos: BlockPos, world: ServerLevel, source: String, entity: LivingEntity?) { if (entity != null) { ActionQueueService.addToQueue( - ActionFactory.itemRemoveAction(world, stack, pos, entity) + ActionFactory.itemRemoveAction(world, stack, pos, entity), ) } else { ActionQueueService.addToQueue( - ActionFactory.itemRemoveAction(world, stack, pos, source) + ActionFactory.itemRemoveAction(world, stack, pos, source), ) } } -private fun onItemInsert( - stack: ItemStack, - pos: BlockPos, - world: ServerLevel, - source: String, - entity: LivingEntity? -) { +private fun onItemInsert(stack: ItemStack, pos: BlockPos, world: ServerLevel, source: String, entity: LivingEntity?) { if (entity != null) { ActionQueueService.addToQueue( - ActionFactory.itemInsertAction(world, stack, pos, entity) + ActionFactory.itemInsertAction(world, stack, pos, entity), ) } else { ActionQueueService.addToQueue( - ActionFactory.itemInsertAction(world, stack, pos, source) + ActionFactory.itemInsertAction(world, stack, pos, source), ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/Networking.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/Networking.kt index 1606582a..36017d4f 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/Networking.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/Networking.kt @@ -18,19 +18,19 @@ object Networking { init { if (config[NetworkingSpec.networking]) { - PayloadTypeRegistry.playC2S().register(InspectC2SPacket.ID, InspectC2SPacket.CODEC) + PayloadTypeRegistry.serverboundPlay().register(InspectC2SPacket.ID, InspectC2SPacket.CODEC) ServerPlayNetworking.registerGlobalReceiver(InspectC2SPacket.ID, InspectC2SPacket) - PayloadTypeRegistry.playC2S().register(SearchC2SPacket.ID, SearchC2SPacket.CODEC) + PayloadTypeRegistry.serverboundPlay().register(SearchC2SPacket.ID, SearchC2SPacket.CODEC) ServerPlayNetworking.registerGlobalReceiver(SearchC2SPacket.ID, SearchC2SPacket) - PayloadTypeRegistry.playC2S().register(HandshakeC2SPacket.ID, HandshakeC2SPacket.CODEC) + PayloadTypeRegistry.serverboundPlay().register(HandshakeC2SPacket.ID, HandshakeC2SPacket.CODEC) ServerPlayNetworking.registerGlobalReceiver(HandshakeC2SPacket.ID, HandshakeC2SPacket) - PayloadTypeRegistry.playC2S().register(RollbackC2SPacket.ID, RollbackC2SPacket.CODEC) + PayloadTypeRegistry.serverboundPlay().register(RollbackC2SPacket.ID, RollbackC2SPacket.CODEC) ServerPlayNetworking.registerGlobalReceiver(RollbackC2SPacket.ID, RollbackC2SPacket) - PayloadTypeRegistry.playC2S().register(PurgeC2SPacket.ID, PurgeC2SPacket.CODEC) + PayloadTypeRegistry.serverboundPlay().register(PurgeC2SPacket.ID, PurgeC2SPacket.CODEC) ServerPlayNetworking.registerGlobalReceiver(PurgeC2SPacket.ID, PurgeC2SPacket) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/Receiver.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/Receiver.kt index 276b636d..c3c33201 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/Receiver.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/Receiver.kt @@ -12,6 +12,6 @@ interface Receiver { player: ServerPlayer, handler: ServerGamePacketListenerImpl, buf: FriendlyByteBuf, - sender: PacketSender + sender: PacketSender, ) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/action/ActionS2CPacket.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/action/ActionS2CPacket.kt index 75e306ae..24764a3a 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/action/ActionS2CPacket.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/action/ActionS2CPacket.kt @@ -33,7 +33,7 @@ data class ActionS2CPacket(val content: ActionType) : CustomPacketPayload { companion object { val ID: Type = Type(LedgerPacketTypes.ACTION.id) val CODEC: StreamCodec = CustomPacketPayload.codec( - ActionS2CPacket::write + ActionS2CPacket::write, ) { _: FriendlyByteBuf? -> TODO() } } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/handshake/HandshakeS2CPacket.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/handshake/HandshakeS2CPacket.kt index 15de4505..d7d75fcd 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/handshake/HandshakeS2CPacket.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/handshake/HandshakeS2CPacket.kt @@ -27,7 +27,7 @@ data class HandshakeS2CPacket(val content: HandshakeContent) : CustomPacketPaylo companion object { val ID: CustomPacketPayload.Type = CustomPacketPayload.Type(LedgerPacketTypes.HANDSHAKE.id) val CODEC: StreamCodec = CustomPacketPayload.codec( - HandshakeS2CPacket::write + HandshakeS2CPacket::write, ) { _: FriendlyByteBuf? -> TODO() } } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/HandshakeC2SPacket.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/HandshakeC2SPacket.kt index 93d6f19f..3990cf65 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/HandshakeC2SPacket.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/HandshakeC2SPacket.kt @@ -39,7 +39,7 @@ data class HandshakeC2SPacket(val nbt: CompoundTag?) : CustomPacketPayload { val modid = info.get().modid val modVersion = info.get().version val ledgerVersion = FabricLoader.getInstance().getModContainer( - Ledger.MOD_ID + Ledger.MOD_ID, ).get().metadata.version.friendlyString if (Networking.PROTOCOL_VERSION == info.get().protocolVersion) { logInfo("${player.name.string} joined the server with a Ledger compatible client mod") @@ -50,28 +50,28 @@ data class HandshakeC2SPacket(val nbt: CompoundTag?) : CustomPacketPayload { HandshakeContent( Networking.PROTOCOL_VERSION, ledgerVersion, - ActionRegistry.getTypes().toList() - ) + ActionRegistry.getTypes().toList(), + ), ) ServerPlayNetworking.send(player, packet) player.enableNetworking() } else { - player.displayClientMessage( + player.sendSystemMessage( Component.translatable( "text.ledger.network.protocols_mismatched", Networking.PROTOCOL_VERSION, - info.get().protocolVersion + info.get().protocolVersion, ), - false + false, ) logInfo( "${player.name.string} joined the server with a Ledger compatible client mod, " + "but has a mismatched protocol: Ledger protocol version: ${Networking.PROTOCOL_VERSION}" + - ", Client mod protocol version ${info.get().protocolVersion}" + ", Client mod protocol version ${info.get().protocolVersion}", ) } } else { - player.displayClientMessage(Component.translatable("text.ledger.network.no_mod_info"), false) + player.sendSystemMessage(Component.translatable("text.ledger.network.no_mod_info"), false) } } private fun readInfo(nbt: CompoundTag?): Optional { @@ -83,8 +83,8 @@ data class HandshakeC2SPacket(val nbt: CompoundTag?) : CustomPacketPayload { ModInfo( nbt.getString("modid").orElseThrow(), nbt.getString("version").orElseThrow(), - nbt.getInt("protocol_version").orElseThrow() - ) + nbt.getInt("protocol_version").orElseThrow(), + ), ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/InspectC2SPacket.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/InspectC2SPacket.kt index 059ea03e..2a7edc27 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/InspectC2SPacket.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/InspectC2SPacket.kt @@ -36,15 +36,15 @@ data class InspectC2SPacket(val pos: BlockPos, val pages: Int) : CustomPacketPay ResponseS2CPacket.sendResponse( ResponseContent( LedgerPacketTypes.INSPECT_POS.id, - ResponseCodes.NO_PERMISSION.code + ResponseCodes.NO_PERMISSION.code, ), - sender + sender, ) return } ResponseS2CPacket.sendResponse( ResponseContent(LedgerPacketTypes.INSPECT_POS.id, ResponseCodes.EXECUTING.code), - sender + sender, ) Ledger.launch { @@ -57,7 +57,7 @@ data class InspectC2SPacket(val pos: BlockPos, val pages: Int) : CustomPacketPay } ResponseS2CPacket.sendResponse( ResponseContent(LedgerPacketTypes.INSPECT_POS.id, ResponseCodes.COMPLETED.code), - sender + sender, ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/PurgeC2SPacket.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/PurgeC2SPacket.kt index d855bf58..7bd45e56 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/PurgeC2SPacket.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/PurgeC2SPacket.kt @@ -36,15 +36,15 @@ data class PurgeC2SPacket(val pos: BlockPos, val pages: Int) : CustomPacketPaylo ResponseS2CPacket.sendResponse( ResponseContent( LedgerPacketTypes.INSPECT_POS.id, - ResponseCodes.NO_PERMISSION.code + ResponseCodes.NO_PERMISSION.code, ), - sender + sender, ) return } ResponseS2CPacket.sendResponse( ResponseContent(LedgerPacketTypes.INSPECT_POS.id, ResponseCodes.EXECUTING.code), - sender + sender, ) Ledger.launch { @@ -57,7 +57,7 @@ data class PurgeC2SPacket(val pos: BlockPos, val pages: Int) : CustomPacketPaylo } ResponseS2CPacket.sendResponse( ResponseContent(LedgerPacketTypes.INSPECT_POS.id, ResponseCodes.COMPLETED.code), - sender + sender, ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/RollbackC2SPacket.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/RollbackC2SPacket.kt index 51f1825c..a328a790 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/RollbackC2SPacket.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/RollbackC2SPacket.kt @@ -33,7 +33,7 @@ data class RollbackC2SPacket(val input: String) : CustomPacketPayload { ) { ResponseS2CPacket.sendResponse( ResponseContent(LedgerPacketTypes.PURGE.id, ResponseCodes.NO_PERMISSION.code), - sender + sender, ) return } @@ -42,7 +42,7 @@ data class RollbackC2SPacket(val input: String) : CustomPacketPayload { ResponseS2CPacket.sendResponse( ResponseContent(LedgerPacketTypes.PURGE.id, ResponseCodes.EXECUTING.code), - sender + sender, ) Ledger.launch { @@ -50,7 +50,7 @@ data class RollbackC2SPacket(val input: String) : CustomPacketPayload { ResponseS2CPacket.sendResponse( ResponseContent(LedgerPacketTypes.PURGE.id, ResponseCodes.COMPLETED.code), - sender + sender, ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/SearchC2SPacket.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/SearchC2SPacket.kt index c85877ff..86d69f31 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/SearchC2SPacket.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/receiver/SearchC2SPacket.kt @@ -37,9 +37,9 @@ data class SearchC2SPacket(val args: String, val pages: Int) : CustomPacketPaylo ResponseS2CPacket.sendResponse( ResponseContent( LedgerPacketTypes.SEARCH.id, - ResponseCodes.NO_PERMISSION.code + ResponseCodes.NO_PERMISSION.code, ), - sender + sender, ) return } @@ -50,7 +50,7 @@ data class SearchC2SPacket(val args: String, val pages: Int) : CustomPacketPaylo ResponseS2CPacket.sendResponse( ResponseContent(LedgerPacketTypes.SEARCH.id, ResponseCodes.EXECUTING.code), - sender + sender, ) Ledger.launch { @@ -65,17 +65,17 @@ data class SearchC2SPacket(val args: String, val pages: Int) : CustomPacketPaylo source, page, Component.translatable( - "text.ledger.header.search" - ).setStyle(TextColorPallet.primary) + "text.ledger.header.search", + ).setStyle(TextColorPallet.primary), ) } ResponseS2CPacket.sendResponse( ResponseContent( LedgerPacketTypes.SEARCH.id, - ResponseCodes.COMPLETED.code + ResponseCodes.COMPLETED.code, ), - sender + sender, ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/response/ResponseCodes.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/response/ResponseCodes.kt index b4840a37..bb975762 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/response/ResponseCodes.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/response/ResponseCodes.kt @@ -5,5 +5,5 @@ enum class ResponseCodes(val code: Int) { EXECUTING(1), COMPLETED(2), ERROR(3), - BUSY(4) + BUSY(4), } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/response/ResponseS2CPacket.kt b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/response/ResponseS2CPacket.kt index b619144d..258cb652 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/response/ResponseS2CPacket.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/network/packet/response/ResponseS2CPacket.kt @@ -19,7 +19,7 @@ data class ResponseS2CPacket(val content: ResponseContent) : CustomPacketPayload companion object { val ID: CustomPacketPayload.Type = CustomPacketPayload.Type(LedgerPacketTypes.RESPONSE.id) val CODEC: StreamCodec = CustomPacketPayload.codec( - ResponseS2CPacket::write + ResponseS2CPacket::write, ) { _: FriendlyByteBuf? -> TODO() } fun sendResponse(content: ResponseContent, sender: PacketSender) { diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/utility/Extensions.kt b/src/main/kotlin/com/github/quiltservertools/ledger/utility/Extensions.kt index db5fdaf9..10da505c 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/utility/Extensions.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/utility/Extensions.kt @@ -25,7 +25,7 @@ fun CommandSourceStack.hasPlayer() = this.entity is ServerPlayer fun MinecraftServer.getWorld(identifier: Identifier?) = identifier?.let { getLevel( - ResourceKey.create(Registries.DIMENSION, identifier) + ResourceKey.create(Registries.DIMENSION, identifier), ) } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/utility/InspectionManager.kt b/src/main/kotlin/com/github/quiltservertools/ledger/utility/InspectionManager.kt index fcce5fb2..4a8b1146 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/utility/InspectionManager.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/utility/InspectionManager.kt @@ -28,12 +28,11 @@ fun Player.isInspecting() = inspectingUsers.contains(this.uuid) fun Player.inspectOn(): Int { inspectingUsers.add(this.uuid) - this.displayClientMessage( + this.sendSystemMessage( Component.translatable( "text.ledger.inspect.toggle", - "text.ledger.inspect.on".translate().withStyle(ChatFormatting.GREEN) + "text.ledger.inspect.on".translate().withStyle(ChatFormatting.GREEN), ).setStyle(TextColorPallet.secondary), - false ) return 1 @@ -41,12 +40,11 @@ fun Player.inspectOn(): Int { fun Player.inspectOff(): Int { inspectingUsers.remove(this.uuid) - this.displayClientMessage( + this.sendSystemMessage( Component.translatable( "text.ledger.inspect.toggle", - "text.ledger.inspect.off".translate().withStyle(ChatFormatting.RED) + "text.ledger.inspect.off".translate().withStyle(ChatFormatting.RED), ).setStyle(TextColorPallet.secondary), - false ) return 1 @@ -93,8 +91,8 @@ fun CommandSourceStack.inspectBlock(pos: BlockPos) { results, Component.translatable( "text.ledger.header.search.pos", - "${pos.x} ${pos.y} ${pos.z}".literal() - ).setStyle(TextColorPallet.primary) + "${pos.x} ${pos.y} ${pos.z}".literal(), + ).setStyle(TextColorPallet.primary), ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/utility/MessageUtils.kt b/src/main/kotlin/com/github/quiltservertools/ledger/utility/MessageUtils.kt index 875b2617..35483399 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/utility/MessageUtils.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/utility/MessageUtils.kt @@ -44,15 +44,15 @@ object MessageUtils { Component.translatable( "text.ledger.footer.search", Component.translatable( - "text.ledger.footer.page_backward" + "text.ledger.footer.page_backward", ).setStyle(TextColorPallet.primaryVariant).withStyle { if (results.page > 1) { it.withHoverEvent( HoverEvent.ShowText( - Component.translatable("text.ledger.footer.page_backward.hover") - ) + Component.translatable("text.ledger.footer.page_backward.hover"), + ), ).withClickEvent( - ClickEvent.RunCommand("/lg pg ${results.page - 1}") + ClickEvent.RunCommand("/lg pg ${results.page - 1}"), ) } else { Style.EMPTY @@ -61,21 +61,21 @@ object MessageUtils { results.page.toString().literal().setStyle(TextColorPallet.primaryVariant), results.pages.toString().literal().setStyle(TextColorPallet.primaryVariant), Component.translatable( - "text.ledger.footer.page_forward" + "text.ledger.footer.page_forward", ).setStyle(TextColorPallet.primaryVariant).withStyle { if (results.page < results.pages) { it.withHoverEvent( HoverEvent.ShowText( - Component.translatable("text.ledger.footer.page_forward.hover") - ) + Component.translatable("text.ledger.footer.page_forward.hover"), + ), ).withClickEvent( - ClickEvent.RunCommand("/lg pg ${results.page + 1}") + ClickEvent.RunCommand("/lg pg ${results.page + 1}"), ) } else { Style.EMPTY } - } - ).setStyle(TextColorPallet.primary) + }, + ).setStyle(TextColorPallet.primary), ) } @@ -125,8 +125,8 @@ object MessageUtils { message.withStyle { it.withHoverEvent( HoverEvent.ShowText( - timeMessage - ) + timeMessage, + ), ) } return message diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/utility/NbtUtils.kt b/src/main/kotlin/com/github/quiltservertools/ledger/utility/NbtUtils.kt index b3c91393..970e0fd9 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/utility/NbtUtils.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/utility/NbtUtils.kt @@ -37,11 +37,7 @@ object NbtUtils { return stateTag.getCompound(PROPERTIES).orElse(null) } - fun blockStateFromProperties( - tag: CompoundTag, - name: Identifier, - blockLookup: HolderGetter - ): BlockState { + fun blockStateFromProperties(tag: CompoundTag, name: Identifier, blockLookup: HolderGetter): BlockState { val stateTag = CompoundTag() stateTag.putString("Name", name.toString()) stateTag.put(PROPERTIES, tag) @@ -60,7 +56,9 @@ object NbtUtils { } itemTag = DataFixers.getDataFixer().update( References.ITEM_STACK, - Dynamic(NbtOps.INSTANCE, itemTag), ITEM_NBT_DATA_VERSION, ITEM_COMPONENTS_DATA_VERSION + Dynamic(NbtOps.INSTANCE, itemTag), + ITEM_NBT_DATA_VERSION, + ITEM_COMPONENTS_DATA_VERSION, ).cast(NbtOps.INSTANCE) as CompoundTag } ProblemReporter.ScopedCollector({ "ledger:itemstack@$name" }, LOGGER).use { diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/utility/Negatable.kt b/src/main/kotlin/com/github/quiltservertools/ledger/utility/Negatable.kt index 73a9af6f..95c6792f 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/utility/Negatable.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/utility/Negatable.kt @@ -1,6 +1,6 @@ package com.github.quiltservertools.ledger.utility -data class Negatable (val property: T, val allowed: Boolean) { +data class Negatable(val property: T, val allowed: Boolean) { companion object { @JvmStatic fun allow(value: U) = Negatable(value, true) diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/utility/PlayerResult.kt b/src/main/kotlin/com/github/quiltservertools/ledger/utility/PlayerResult.kt index cf435862..a7e7278b 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/utility/PlayerResult.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/utility/PlayerResult.kt @@ -7,21 +7,19 @@ import java.util.* data class PlayerResult(val uuid: UUID, val name: String, val firstJoin: Instant, val lastJoin: Instant) { - fun toText(): Component { - return Component.translatable( - "text.ledger.player.result", - name.literal().setStyle(TextColorPallet.light), - MessageUtils.instantToText(firstJoin).setStyle(TextColorPallet.primaryVariant), - MessageUtils.instantToText(lastJoin).setStyle(TextColorPallet.primaryVariant) - ).setStyle(TextColorPallet.secondary) - } + fun toText(): Component = Component.translatable( + "text.ledger.player.result", + name.literal().setStyle(TextColorPallet.light), + MessageUtils.instantToText(firstJoin).setStyle(TextColorPallet.primaryVariant), + MessageUtils.instantToText(lastJoin).setStyle(TextColorPallet.primaryVariant), + ).setStyle(TextColorPallet.secondary) companion object { fun fromRow(row: Tables.Player): PlayerResult = PlayerResult( row.playerId, row.playerName, row.firstJoin, - row.lastJoin + row.lastJoin, ) } } diff --git a/src/main/kotlin/com/github/quiltservertools/ledger/utility/TextColorPallet.kt b/src/main/kotlin/com/github/quiltservertools/ledger/utility/TextColorPallet.kt index 1735d694..60ca42ab 100644 --- a/src/main/kotlin/com/github/quiltservertools/ledger/utility/TextColorPallet.kt +++ b/src/main/kotlin/com/github/quiltservertools/ledger/utility/TextColorPallet.kt @@ -13,13 +13,13 @@ object TextColorPallet { val primaryVariant: Style get() = Style.EMPTY.withColor( - TextColor.parseColor(config[ColorSpec.primaryVariant]).getOrNull() - ) + TextColor.parseColor(config[ColorSpec.primaryVariant]).getOrNull(), + ) val secondary: Style get() = Style.EMPTY.withColor(TextColor.parseColor(config[ColorSpec.secondary]).getOrNull()) val secondaryVariant: Style get() = Style.EMPTY.withColor( - TextColor.parseColor(config[ColorSpec.secondaryVariant]).getOrNull() - ) + TextColor.parseColor(config[ColorSpec.secondaryVariant]).getOrNull(), + ) val light: Style get() = Style.EMPTY.withColor(TextColor.parseColor(config[ColorSpec.light]).getOrNull()) } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ba0fcf15..70da0486 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,8 +26,7 @@ "ledger.mixins.json" ], "depends": { - "fabricloader": ">=0.16.2", - "fabric": ">=0.133.13+1.21.9", + "fabricloader": ">=0.18.4", "fabric-language-kotlin": ">=${fabricKotlin}", "minecraft": ">=1.21.11" }, diff --git a/src/main/resources/ledger.mixins.json b/src/main/resources/ledger.mixins.json index e2e1d398..20888faa 100644 --- a/src/main/resources/ledger.mixins.json +++ b/src/main/resources/ledger.mixins.json @@ -22,7 +22,7 @@ "HoneycombItemMixin", "ContainersMixin", "JukeboxPlayableMixin", - "WaterlilyBlockMixin", + "LilyPadBlockMixin", "BaseContainerBlockEntityMixin", "TransportItemsBetweenContainersMixin", "PortalShapeMixin", @@ -48,7 +48,7 @@ "blocks.DaylightDetectorBlockMixin", "blocks.DecoratedPotBlockMixin", "blocks.DoorBlockMixin", - "blocks.FarmBlockMixin", + "blocks.FarmlandBlockMixin", "blocks.FenceGateBlockMixin", "blocks.FireBlockMixin", "blocks.FlowerPotBlockMixin", @@ -65,11 +65,11 @@ "blocks.ScaffoldingBlockMixin", "blocks.ShelfBlockMixin", "blocks.SpongeBlockMixin", - "blocks.SpreadingSnowyDirtBlockMixin", + "blocks.SpreadingSnowyBlockMixin", "blocks.SugarCaneBlockMixin", "blocks.TrapDoorBlockMixin", "blocks.WetSpongeBlockMixin", - "blocks.cauldron.CauldronInteractionMixin", + "blocks.cauldron.CauldronInteractionsMixin", "blocks.cauldron.CauldronBlockMixin", "blocks.cauldron.LayeredCauldronBlockMixin", "blocks.coral.CoralPlantBlockMixin", From 6395993a00f0ebc7c108ccc479162457687004c0 Mon Sep 17 00:00:00 2001 From: Drex Date: Wed, 25 Mar 2026 13:14:45 +0100 Subject: [PATCH 2/2] Update dependencies --- build.gradle.kts | 1 - libs.versions.toml | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index af75bff1..5f2d37d8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,7 +48,6 @@ repositories { maven("https://jitpack.io") maven("https://oss.sonatype.org/content/repositories/snapshots") mavenCentral() - mavenLocal() } val includeImplementation: Configuration by configurations.creating { diff --git a/libs.versions.toml b/libs.versions.toml index 32c7b34b..fb318d88 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -1,15 +1,15 @@ [versions] -minecraft = "26.1-rc-2" +minecraft = "26.1" fabric-loader = "0.18.4" -fabric-api = "0.143.15+26.1" +fabric-api = "0.144.1+26.1" # Kotlin kotlin = "2.3.10" # Also modrinth version in gradle.properties fabric-kotlin = "1.13.9+kotlin.2.3.10" -fabric-permissions = "0.6.3-SNAPSHOT" +fabric-permissions = "0.7.0" translations = "3.0.0+26.1-pre-3" exposed = "1.0.0-rc-2"