Skip to content

Commit

Permalink
Add spotless for codestyle (#410)
Browse files Browse the repository at this point in the history
* Add spotless for codestyle

* Fix license header file

* Bump Gradle from 8.10.2 to 8.11
  • Loading branch information
jonesdevelopment authored Nov 11, 2024
1 parent 43a1aa2 commit ff9216c
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 64 deletions.
3 changes: 2 additions & 1 deletion HEADER
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) ${YEAR} Sonar Contributors
* Copyright (C) 2024 Sonar Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -14,3 +14,4 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

3 changes: 0 additions & 3 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@ tasks {
archiveFileName = "sonar-api-${rootProject.version}.jar"
}
}

java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11
15 changes: 5 additions & 10 deletions api/src/main/java/xyz/jonesdev/sonar/api/Sonar.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,23 @@ public interface Sonar {

void reload();

@NotNull
default SonarVersion getVersion() {
@NotNull default SonarVersion getVersion() {
return SonarVersion.INSTANCE;
}

@NotNull
default SonarEventManager getEventManager() {
@NotNull default SonarEventManager getEventManager() {
return SonarEventManager.INSTANCE;
}

@NotNull
default AttackTracker getAttackTracker() {
@NotNull default AttackTracker getAttackTracker() {
return AttackTracker.INSTANCE;
}

@NotNull
default Fallback getFallback() {
@NotNull default Fallback getFallback() {
return Fallback.INSTANCE;
}

@NotNull
static Sonar get() {
@NotNull static Sonar get() {
return SonarSupplier.sonar;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,17 @@
import java.net.InetAddress;

public interface FallbackUser {
@NotNull
Channel channel();
@NotNull Channel channel();

@NotNull
InetAddress getInetAddress();
@NotNull InetAddress getInetAddress();

@NotNull
ProtocolVersion getProtocolVersion();
@NotNull ProtocolVersion getProtocolVersion();

@NotNull
SystemTimer getLoginTimer();
@NotNull SystemTimer getLoginTimer();

@NotNull
String getFingerprint();
@NotNull String getFingerprint();

@NotNull
String getUsername();
@NotNull String getUsername();

boolean isForceCaptcha();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023-2024 Sonar Contributors
* Copyright (C) 2024 Sonar Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
20 changes: 18 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import net.kyori.indra.git.IndraGitExtension
plugins {
java
alias(libs.plugins.shadow)
alias(libs.plugins.indra.git) apply true
alias(libs.plugins.indra.git)
alias(libs.plugins.spotless)
}

allprojects {
Expand All @@ -15,6 +16,7 @@ allprojects {

apply(plugin = "java")
apply(plugin = "com.gradleup.shadow")
apply(plugin = "com.diffplug.spotless")

dependencies {
compileOnly(rootProject.libs.lombok)
Expand All @@ -31,6 +33,17 @@ allprojects {
compileOnly(rootProject.libs.libby.core)
}

spotless {
java {
endWithNewline()
formatAnnotations()
removeUnusedImports()
trimTrailingWhitespace()
indentWithSpaces(2)
licenseHeaderFile("../HEADER")
}
}

tasks {
shadowJar {
// Set the file name of the shadowed jar
Expand Down Expand Up @@ -80,14 +93,17 @@ allprojects {
attributes["Git-Commit"] = gitCommit
}
}

java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11
}
}

tasks {
// This is a small wrapper tasks to simplify the building process
register("build-sonar") {
val subprojects = listOf("api", "captcha", "common", "bukkit", "bungeecord", "velocity")
val buildTasks = subprojects.flatMap { listOf("$it:clean", "$it:shadowJar") }
val buildTasks = subprojects.flatMap { listOf("$it:clean", "$it:spotlessApply", "$it:shadowJar") }
dependsOn(buildTasks)
}
}
3 changes: 0 additions & 3 deletions bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,3 @@ tasks {
relocate("net.kyori", "xyz.jonesdev.sonar.libs.kyori")
}
}

java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11
3 changes: 0 additions & 3 deletions bungeecord/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,3 @@ tasks {
archiveFileName = "Sonar-Bungee.jar" // Hardcode a shortened version of the name
}
}

java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11
3 changes: 0 additions & 3 deletions captcha/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ dependencies {
testCompileOnly(project(":api"))
testCompileOnly(rootProject.libs.imagefilters)
}

java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023-2024 Sonar Contributors
* Copyright (C) 2024 Sonar Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
3 changes: 0 additions & 3 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ dependencies {
implementation(project(":captcha"))
compileOnly(rootProject.libs.adventure.nbt)
}

java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/*
* Copyright 2021 Andrew Steinborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies
* or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package xyz.jonesdev.sonar.common.util;

import io.netty.buffer.ByteBuf;
Expand Down Expand Up @@ -102,6 +81,27 @@ public static int readVarInt(final @NotNull ByteBuf byteBuf) {
throw DEBUG ? new DecoderException("Bad VarInt") : QuietDecoderException.INSTANCE;
}

/*
* Copyright 2021 Andrew Steinborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies
* or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

public static void writeVarInt(final @NotNull ByteBuf byteBuf, final int value) {
// Peel the one and two byte count cases explicitly as they are the most common VarInt sizes
// that the proxy will write, to improve inlining.
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pluginyml = "0.6.0"
[plugins]
indra-git = "net.kyori.indra.git:3.1.3"
shadow = "com.gradleup.shadow:8.3.5"
spotless = "com.diffplug.spotless:7.0.0.BETA4"
pluginyml-bungee = { id = "net.minecrell.plugin-yml.bungee", version.ref = "pluginyml" }
pluginyml-bukkit = { id = "net.minecrell.plugin-yml.bukkit", version.ref = "pluginyml" }

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Empty file modified gradlew.bat
100755 → 100644
Empty file.

0 comments on commit ff9216c

Please sign in to comment.