Skip to content

Commit

Permalink
feat: Sub modules project setup and Sponge7 support
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Maven/Gradle artifacts changed
  • Loading branch information
GeorgeV220 committed Jan 21, 2023
1 parent 6956918 commit be752de
Show file tree
Hide file tree
Showing 127 changed files with 859 additions and 194 deletions.
113 changes: 52 additions & 61 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,9 @@ plugins {
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'io.freefair.lombok' version '6.6.1'
id 'java'
id 'jacoco'
id 'idea'
}

apply from: "$rootDir/gradle/jacoco.gradle"
apply from: "$rootDir/gradle/publish.gradle"

if (project.hasProperty("local_script")) {
apply from: file(local_script + "/build.local.gradle")
}

ext {
mcVersion = project.property("mcVersion")
}

group project.property("group")

compileJava {
options.encoding = 'UTF-8'
options.compilerArgs += ["-parameters"]
Expand All @@ -33,44 +19,64 @@ compileJava {
}

archivesBaseName = project.property("libName")
group project.property("group")

repositories {
mavenLocal()
mavenCentral()
maven { url = 'https://repo.codemc.org/repository/maven-public/' }
maven { url = 'https://jitpack.io' }
maven { url = 'https://repo.aikar.co/content/groups/aikar/' }
maven { url = 'https://repo.dmulloy2.net/repository/public/' }
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/public/' }
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url = 'https://nexus.velocitypowered.com/repository/maven-public/' }
maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
}
allprojects {

dependencies {
compileOnly "io.papermc.paper:paper-api:${mcVersion}-R0.1-SNAPSHOT"
compileOnly 'net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT'
compileOnly 'com.velocitypowered:velocity-api:3.1.1'
compileOnly 'org.spongepowered:spongeapi:9.0.0'
ext {
mcVersion = project.property("mcVersion")
}

compileOnly 'org.jetbrains:annotations:23.1.0'
compileOnly 'commons-codec:commons-codec:1.15'
compileOnly 'commons-io:commons-io:2.11.0'
compileOnly 'commons-lang:commons-lang:2.6'
compileOnly 'org.mongodb:mongodb-driver:3.12.11'
compileOnly 'com.mojang:authlib:1.11'
compileOnly 'me.clip:placeholderapi:2.11.2'
implementation 'de.tr7zw:item-nbt-api-plugin:2.11.1'
implementation 'com.github.cryptomorin:XSeries:9.2.0'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'io.freefair.lombok'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'maven-publish'

testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1'
testImplementation 'org.mockito:mockito-core:4.11.0'
testImplementation 'com.github.seeseemelk:MockBukkit-v1.17:1.13.0'
testImplementation 'org.assertj:assertj-core:3.23.1'
}
processResources {
project.properties.put("version", this.version)
expand project.properties
}

java {
repositories {
mavenLocal()
mavenCentral()
maven { url = 'https://repo.codemc.io/repository/maven-public/' }
maven { url = 'https://jitpack.io' }
maven { url = 'https://repo.aikar.co/content/groups/aikar/' }
maven { url = 'https://repo.dmulloy2.net/repository/public/' }
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/public/' }
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url = 'https://nexus.velocitypowered.com/repository/maven-public/' }
maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
}

dependencies {
compileOnly "io.papermc.paper:paper-api:${mcVersion}-R0.1-SNAPSHOT"
compileOnly 'net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT'
compileOnly 'com.velocitypowered:velocity-api:3.1.1'

compileOnly 'org.jetbrains:annotations:23.1.0'
compileOnly 'commons-codec:commons-codec:1.15'
compileOnly 'commons-io:commons-io:2.11.0'
compileOnly 'commons-lang:commons-lang:2.6'
compileOnly 'org.mongodb:mongodb-driver:3.12.11'
compileOnly 'com.mojang:authlib:1.11'
compileOnly 'me.clip:placeholderapi:2.11.2'
}
}

dependencies {
implementation project(path: ':database')
implementation project(path: ':extensions')
implementation project(path: ':maps')
implementation project(path: ':scheduler')
implementation project(path: ':yaml')
implementation project(path: ':utilities')
implementation project(path: ':minecraft:bukkit')
implementation project(path: ':minecraft:bungee')
implementation project(path: ':minecraft:velocity')
implementation project(path: ':minecraft:sponge8')
}

shadowJar {
Expand All @@ -81,20 +87,5 @@ shadowJar {
relocate 'com.cryptomorin.xseries', 'com.georgev22.library.minecraft.xseries'
}

tasks.build.dependsOn(shadowJar)
tasks.publish.dependsOn(shadowJar)

test {
useJUnitPlatform()
testLogging {
events "skipped", "failed"
}
ignoreFailures = false
}

processResources {
project.properties.put("version", this.version)
expand project.properties
}

defaultTasks 'build'
11 changes: 11 additions & 0 deletions database/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apply from: "$rootDir/gradle/publish.gradle"

group 'com.georgev22.library'

dependencies {
compileOnly project(path: ':utilities')
compileOnly project(path: ':maps')
}

tasks.build.dependsOn(shadowJar)
tasks.publish.dependsOn(shadowJar)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.georgev22.library.exceptions.DatabaseException;
import com.georgev22.library.maps.ObjectMap;
import com.mongodb.BasicDBObject;
import com.mongodb.Block;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoCollection;
Expand All @@ -23,6 +22,7 @@
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.*;
import java.util.function.Consumer;

import static com.georgev22.library.utilities.Utils.Assertions.notNull;

Expand Down Expand Up @@ -103,7 +103,7 @@ public DatabaseWrapper connect() {
public boolean isConnected() {
if (!type.equals(DatabaseType.MONGO))
try {
return connection != null & !connection.isClosed();
return connection != null & !Objects.requireNonNull(connection).isClosed();
} catch (SQLException ignored) {
return false;
}
Expand Down Expand Up @@ -246,7 +246,7 @@ private ResultSet resultSet(String query) {
* @return an {@link ObjectMap.PairDocument} with the retrieved data.
*/
public ObjectMap.PairDocument selectData(ObjectMap.Pair<String, ObjectMap.Pair<String, Object>> select) {
List<ObjectMap.Pair> pairList = new ArrayList<>();
List<ObjectMap.Pair<String, Object>> pairList = new ArrayList<>();
if (!type.equals(DatabaseType.MONGO)) {
try {
if (!select.value().value().getClass().equals(String.class))
Expand All @@ -263,7 +263,7 @@ public ObjectMap.PairDocument selectData(ObjectMap.Pair<String, ObjectMap.Pair<S
}
} else {
Document document = getDocument(select);
for (Map.Entry<String, Object> entry : document.entrySet()) {
for (Map.Entry<String, Object> entry : Objects.requireNonNull(document).entrySet()) {
pairList.add(ObjectMap.Pair.create(entry.getKey(), entry.getValue()));
}
}
Expand Down Expand Up @@ -297,7 +297,7 @@ public List<ObjectMap.PairDocument> selectAllData(ObjectMap.Pair<String, ObjectM
} else {
FindIterable<Document> findIterable = getAllDocuments(select);
List<ObjectMap.Pair<String, Object>> pairList = new ArrayList<>();
findIterable.forEach((Block<? super Document>) document -> {
findIterable.forEach((Consumer<? super Document>) document -> {
for (Map.Entry<String, Object> entry : document.entrySet()) {
pairList.add(ObjectMap.Pair.create(entry.getKey(), entry.getValue()));
}
Expand Down Expand Up @@ -352,6 +352,6 @@ public Database getSQLDatabase() {
* @see com.mongodb.MongoNamespace#checkCollectionNameValidity(String)
*/
public MongoCollection<Document> getCollection(String collectionName) {
return mongoDatabase.getCollection(collectionName);
return Objects.requireNonNull(mongoDatabase).getCollection(collectionName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public MySQL(String hostname, int port, String username, String password) {
public MySQL(String hostname, int port, String username, String password, @NotNull Optional<String> database) {
this.hostname = hostname;
this.port = port;
this.database = database.isEmpty() ? null : database.get();
this.database = database.orElse(null);
this.user = username;
this.password = password;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public PostgreSQL(String hostname, int port, String username, String password) {
public PostgreSQL(String hostname, int port, String username, String password, @NotNull Optional<String> database) {
this.hostname = hostname;
this.port = port;
this.database = database.isEmpty() ? null : database.get();
this.database = database.orElse(null);
this.user = username;
this.password = password;
}
Expand Down
12 changes: 12 additions & 0 deletions extensions/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apply from: "$rootDir/gradle/publish.gradle"

group 'com.georgev22.library'

dependencies {
compileOnly project(path: ':utilities')
compileOnly project(path: ':maps')
compileOnly project(path: ':yaml')
}

tasks.build.dependsOn(shadowJar)
tasks.publish.dependsOn(shadowJar)
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public Extension[] loadExtensions(@NotNull File directory) {
Map<String, Collection<String>> softDependencies = new HashMap<>();

// This is where it figures out all possible extensions
for (File file : directory.listFiles()) {
for (File file : Objects.requireNonNull(directory.listFiles())) {
ExtensionLoader loader = null;
for (Pattern filter : filters) {
Matcher match = filter.matcher(file.getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.georgev22.library.extensions.java;

import com.georgev22.library.exceptions.InvalidExtensionException;
import com.georgev22.library.extensions.ExtensionBase;
import com.georgev22.library.extensions.ExtensionDescriptionFile;
import com.georgev22.library.extensions.ExtensionLoader;
import com.georgev22.library.extensions.ExtensionsImpl;
import com.georgev22.library.extensions.*;
import com.georgev22.library.maps.HashObjectMap;
import com.georgev22.library.maps.ObjectMap;
import com.georgev22.library.maps.UnmodifiableObjectMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public boolean isSync() {
public void run() {
final Thread thread = Thread.currentThread();
synchronized (workers) {
if (getPeriod() == Task.CANCEL) {
if (getPeriod() == CANCEL) {
// Never continue running after cancelled.
// Checking this with the lock is important!
return;
Expand Down Expand Up @@ -104,7 +104,7 @@ LinkedList<ExtensionWorker> getWorkers() {
boolean cancel0() {
synchronized (workers) {
// Synchronizing here prevents race condition for a completing task
setPeriod(Task.CANCEL);
setPeriod(CANCEL);
if (workers.isEmpty()) {
runners.remove(getTaskId());
}
Expand Down
10 changes: 0 additions & 10 deletions gradle/jacoco.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ publishing {
publications {
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
group = ((String) project.getGroup()).toLowerCase()
artifactId = project.getName().toLowerCase()
groupId = ((String) project.getGroup()).toLowerCase()
artifact sourcesJar
artifact javadocJar
}
Expand Down
4 changes: 4 additions & 0 deletions maps/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apply from: "$rootDir/gradle/publish.gradle"
group 'com.georgev22.library'
tasks.build.dependsOn(shadowJar)
tasks.publish.dependsOn(shadowJar)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.georgev22.library.maps;

import com.georgev22.library.utilities.Utils;
import org.jetbrains.annotations.NotNull;

import java.util.Date;
Expand Down Expand Up @@ -351,7 +350,6 @@ public <T> List<T> getList(Object key, Class<T> clazz) {
* @throws ClassCastException if the value of the given key is not of type T
*/
public <T> List<T> getList(final Object key, final Class<T> clazz, final List<T> defaultValue) {
Utils.Assertions.notNull("clazz", clazz);
List<T> value = get(key, List.class);
if (value == null) {
return defaultValue;
Expand All @@ -377,7 +375,6 @@ public <T> List<T> getList(final Object key, final Class<T> clazz, final List<T>
* @throws ClassCastException if the value of the given key is not of type T
*/
public <T> T get(final Object key, final Class<T> clazz) {
Utils.Assertions.notNull("clazz", clazz);
return clazz.cast(get(key));
}

Expand All @@ -392,7 +389,6 @@ public <T> T get(final Object key, final Class<T> clazz) {
* @throws ClassCastException if the value of the given key is not of type T
*/
public <T> T get(final Object key, final T defaultValue) {
Utils.Assertions.notNull("defaultValue", defaultValue);
Object value = get(key);
return value == null ? defaultValue : (T) value;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.georgev22.library.maps;

import com.georgev22.library.utilities.Utils;
import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
Expand Down Expand Up @@ -352,7 +351,6 @@ public <T> List<T> getList(Object key, Class<T> clazz) {
* @throws ClassCastException if the value of the given key is not of type T
*/
public <T> List<T> getList(final Object key, final Class<T> clazz, final List<T> defaultValue) {
Utils.Assertions.notNull("clazz", clazz);
List<T> value = get(key, List.class);
if (value == null) {
return defaultValue;
Expand All @@ -378,7 +376,6 @@ public <T> List<T> getList(final Object key, final Class<T> clazz, final List<T>
* @throws ClassCastException if the value of the given key is not of type T
*/
public <T> T get(final Object key, final Class<T> clazz) {
Utils.Assertions.notNull("clazz", clazz);
return clazz.cast(get(key));
}

Expand All @@ -393,7 +390,6 @@ public <T> T get(final Object key, final Class<T> clazz) {
* @throws ClassCastException if the value of the given key is not of type T
*/
public <T> T get(final Object key, final T defaultValue) {
Utils.Assertions.notNull("defaultValue", defaultValue);
Object value = get(key);
return value == null ? defaultValue : (T) value;
}
Expand Down
Loading

0 comments on commit be752de

Please sign in to comment.