Skip to content

Commit

Permalink
build: Improved build script
Browse files Browse the repository at this point in the history
Updated Paper repository link
  • Loading branch information
4drian3d committed May 25, 2022
1 parent 92f9aa7 commit c5bfede
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 25 deletions.
42 changes: 24 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {

repositories {
mavenLocal()
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.fvdh.dev/releases")
maven("https://jitpack.io")
maven("https://repo.alessiodp.com/releases/")
Expand All @@ -23,9 +23,15 @@ java {
withJavadocJar()
}

val url = property("url") as String ?: ""
val id = property("id") as String ?: "chatregulator"
val configurate = property("configurate-version") as String
val geantyref = property("geantyref-version") as String
val caffeine = property("caffeine-version") as String

dependencies {
compileOnly("org.spongepowered:configurate-hocon:4.1.2")
compileOnly("com.github.ben-manes.caffeine:caffeine:3.0.6")
compileOnly("org.spongepowered:configurate-hocon:$configurate")
compileOnly("com.github.ben-manes.caffeine:caffeine:$caffeine")
shadow("org.jetbrains:annotations:23.0.0")
shadow("net.byteflux:libby-velocity:1.1.5")

Expand All @@ -35,19 +41,16 @@ dependencies {
annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")

testImplementation("org.slf4j:slf4j-api:1.7.32")
testImplementation("org.spongepowered:configurate-hocon:4.1.2")
testImplementation("org.spongepowered:configurate-hocon:$configurate")
testImplementation(platform("org.junit:junit-bom:5.8.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.mockito:mockito-core:4.1.0")
testImplementation("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
testImplementation("com.github.ben-manes.caffeine:caffeine:3.0.6")
testImplementation("com.github.ben-manes.caffeine:caffeine:$caffeine")
}

group = "me.dreamerzero.chatregulator"
version = "3.0.1-SNAPSHOT"
description = "A global chat regulator for you Velocity network"
val url: String = "https://forums.velocitypowered.com/t/chatregulator-a-global-chat-regulator-for-velocity/962"
val id: String = "chatregulator"



publishing {
publications {
Expand All @@ -64,17 +67,20 @@ tasks.withType<Javadoc> {
(options as StandardJavadocDocletOptions).links(
"https://jd.adventure.kyori.net/api/4.10.1/",
"https://jd.adventure.kyori.net/text-minimessage/4.10.1/",
"https://jd.velocitypowered.com/3.0.0/"
"https://jd.papermc.io/velocity/3.0.0/"
)
}

blossom{
val constants: String = "src/main/java/me/dreamerzero/chatregulator/utils/Constants.java"
replaceToken("{name}", rootProject.name, constants)
replaceToken("{id}", id, constants)
replaceToken("{version}", version, constants)
replaceToken("{description}", description, constants)
replaceToken("{url}", url, constants)
blossom {
replaceTokenIn("src/main/java/me/dreamerzero/chatregulator/utils/Constants.java")
replaceToken("{name}", rootProject.name)
replaceToken("{id}", id)
replaceToken("{version}", version)
replaceToken("{description}", description)
replaceToken("{url}", url)
replaceToken("{configurate}", configurate)
replaceToken("{geantyref}", geantyref)
replaceToken("{caffeine}", caffeine)
}

tasks {
Expand Down
9 changes: 9 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
group = me.dreamerzero.chatregulator
version = 3.0.1-SNAPSHOT
description = A global chat regulator for you Velocity network
url = https://forums.velocitypowered.com/t/chatregulator-a-global-chat-regulator-for-velocity/962
id = chatregulator

caffeine-version = 3.0.6
configurate-version = 4.1.2
geantyref-version = 1.3.13
8 changes: 4 additions & 4 deletions src/main/java/me/dreamerzero/chatregulator/ChatRegulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,25 @@ private void loadDependencies() {
final Library hocon = Library.builder()
.groupId("org{}spongepowered")
.artifactId("configurate-hocon")
.version("4.1.2")
.version(Constants.CONFIGURATE)
.id("configurate-hocon")
.build();
final Library confCore = Library.builder()
.groupId("org{}spongepowered")
.artifactId("configurate-core")
.version("4.1.2")
.version(Constants.CONFIGURATE)
.id("configurate-core")
.build();
final Library geantyref = Library.builder()
.groupId("io{}leangen{}geantyref")
.artifactId("geantyref")
.version("1.3.13")
.version(Constants.GEANTYREF)
.id("geantyref")
.build();
final Library caffeine = Library.builder()
.groupId("com{}github{}ben-manes{}caffeine")
.artifactId("caffeine")
.version("3.0.6")
.version(Constants.CAFFEINE)
.id("caffeine")
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class InfractionPlayer implements ForwardingAudience.Single {
private String lastMessage;
private String preLastCommand;
private String lastCommand;
private ViolationCount violationsCount;
private final ViolationCount violationsCount = new ViolationCount();
private boolean isOnline;
private final String username;
private Instant timeSinceLastMessage;
Expand All @@ -46,7 +46,6 @@ public final class InfractionPlayer implements ForwardingAudience.Single {
this.lastCommand = " .";
this.timeSinceLastMessage = Instant.now();
this.timeSinceLastCommand = Instant.now();
this.violationsCount = new ViolationCount();
this.isOnline = true;
this.username = player.getUsername();
}
Expand Down Expand Up @@ -173,7 +172,7 @@ public long getTimeSinceLastCommand(){
public static @Nullable InfractionPlayer get(final @NotNull UUID uuid, @NotNull ProxyServer proxy) throws PlayerNotAvailableException{
return ChatRegulator.infractionPlayers
.get(Objects.requireNonNull(uuid),
(id) -> new InfractionPlayer(
id -> new InfractionPlayer(
proxy.getPlayer(id)
.orElseThrow(() -> new PlayerNotAvailableException(id))
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public final class Constants {
public static final String URL = "{url}";
/**Plugin ID */
public static final String ID = "{id}";
public static final String CAFFEINE = "{caffeine}";
public static final String CONFIGURATE = "{configurate}";
public static final String GEANTYREF = "{geantyref}";

private Constants(){}
}

0 comments on commit c5bfede

Please sign in to comment.