Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 35 additions & 48 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
import org.apache.tools.ant.filters.ReplaceTokens

buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0'
}

/* dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:8.0.0'
}*/

}


plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

group 'me.realized'
version '3.2.8'

compileJava {
options.encoding = 'UTF-8'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
compileJava.options.encoding = 'UTF-8'

processResources {
def group = project.group.toString() + "." + project.name.toLowerCase() + ".shaded"

from(sourceSets.main.resources.srcDirs) {
include '**/*.yml'
/* from(sourceSets.main.resources.srcDirs) {
include '**.yml'
filter(ReplaceTokens, tokens: [NAME: project.name, VERSION: project.version, SHADED_GROUP: group])
}
}*/
}

repositories {
Expand All @@ -47,60 +44,64 @@ repositories {
name 'bungeecord-repo'
url 'https://oss.sonatype.org/content/repositories/snapshots'
}

maven {
maven { url 'https://jitpack.io' }
/* maven {
name 'mvdw-repo'
url 'http://repo.mvdw-software.be/content/groups/public/'
}
}*/

maven {
name 'clip-repo'
url 'http://repo.extendedclip.com/content/repositories/placeholderapi/'
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
}

maven {
name 'codemc-repo'
url 'https://repo.codemc.io/repository/maven-public/'
}


maven {
name 'inventive-repo'
url 'https://repo.inventivetalent.org/content/groups/public/'
}


flatDir {
dirs "$rootDir/libs/"
}
}

dependencies {
implementation 'org.projectlombok:lombok:1.18.22'
implementation 'org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT'
implementation (name: 'MVdWPlaceholderAPI-3.1.1') {
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'

compileOnly 'org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT'
compileOnly (name: 'MVdWPlaceholderAPI-3.1.1') {
transitive = false
}
implementation name: 'Vault-1.6.7'
implementation 'me.clip:placeholderapi:2.10.9'
compileOnly "com.github.MilkBowl:VaultAPI:1.7"
compileOnly 'me.clip:placeholderapi:2.10.9'

// shaded dependencies
implementation 'redis.clients:jedis:3.5.1'
implementation 'org.apache.commons:commons-pool2:2.4.2'
implementation 'com.zaxxer:HikariCP:4.0.2'
implementation 'org.slf4j:slf4j-nop:1.7.32'
implementation 'org.bstats:bstats-bukkit:1.7'
implementation 'redis.clients:jedis:5.1.2'
implementation 'org.apache.commons:commons-pool2:2.12.0'
implementation 'com.zaxxer:HikariCP:4.0.3'
implementation 'org.slf4j:slf4j-nop:2.0.13'
implementation 'org.bstats:bstats-bukkit:3.0.2'
}

clean.doFirst {
delete "$rootDir/out/"
}

shadowJar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
destinationDirectory = file("$rootDir/out/")
archiveBaseName.set('TokenManager')
archiveClassifier.set('')
//duplicatesStrategy = DuplicatesStrategy.EXCLUDE
setDestinationDirectory(file("$rootDir/out/"))
// destinationDir = file("$rootDir/out/")
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
// baseName = 'TokenManager'
// classifier = null

dependencies {
include(dependency('redis.clients:.*'))
Expand All @@ -119,18 +120,4 @@ shadowJar {
relocate 'org.bstats', group + 'bstats'
}

build.dependsOn(shadowJar)

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact shadowJar // Ensure the shadow jar is included in the publication
}
}
repositories {
maven {
url = uri("$buildDir/repo")
}
}
}
build.dependsOn(shadowJar)
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.realized.tokenmanager;

import com.google.common.collect.Lists;
//import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -139,7 +139,7 @@ private boolean load() {
* @return true if unload was successful, otherwise false
*/
private boolean unload() {
for (final Loadable loadable : Lists.reverse(loadables)) {
for (final Loadable loadable : loadables) {
try {
if (loadables.indexOf(loadable) > lastLoad) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.zaxxer.hikari.HikariDataSource;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down Expand Up @@ -69,6 +70,7 @@ public MySQLDatabase(final TokenManagerPlugin plugin) {
@Override
public void setup() throws Exception {
final Config config = plugin.getConfiguration();
this.createDatabase(config);
final HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(config.getMysqlUrl()
.replace("%hostname%", config.getMysqlHostname())
Expand Down Expand Up @@ -116,6 +118,19 @@ public void setup() throws Exception {
}
}
}
private void createDatabase(final Config config) {
String configUrl = config.getMysqlUrl()
.replace("%hostname%", config.getMysqlHostname())
.replace("%port%", config.getMysqlPort())
.replace("%database%", "");
try (Connection connection = DriverManager.getConnection(configUrl, config.getMysqlUsername(), config.getMysqlPassword());
Statement statement = connection.createStatement()) {
statement.executeUpdate("CREATE DATABASE IF NOT EXISTS " + config.getMysqlDatabase());
} catch (SQLException ex) {
Log.error("Failed to connect to create the database!");
Log.error("Cause of error: " + ex.getMessage());
}
}

@Override
public OptionalLong get(final Player player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public HookManager(final TokenManagerPlugin plugin) {

@Override
public void handleLoad() {
register("MVdWPlaceholderAPI", MVdWPlaceholderHook.class);
//register("MVdWPlaceholderAPI", MVdWPlaceholderHook.class);
register("PlaceholderAPI", PlaceholderHook.class);
register("Vault", VaultHook.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

public class MVdWPlaceholderHook extends PluginHook<TokenManagerPlugin> {

public MVdWPlaceholderHook(final TokenManagerPlugin plugin) {

public MVdWPlaceholderHook(final TokenManagerPlugin plugin) {
super(plugin, "MVdWPlaceholderAPI");

final Placeholders placeholders = new Placeholders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public final class CompatUtil {
private static final long SUB_VERSION;

static {
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
SUB_VERSION = NumberUtil.parseLong(packageName.substring(packageName.lastIndexOf('.') + 1).split("_")[1]).orElse(0);
final String packageName = Bukkit.getServer().getBukkitVersion().split("\\.")[1];
SUB_VERSION = NumberUtil.parseLong(packageName).orElse(0);
}

private CompatUtil() {}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: TokenManager
main: me.realized.tokenmanager.TokenManagerPlugin
version: @VERSION@
version: 3.2.8
softdepend: [MVdWPlaceholderAPI, PlaceholderAPI, Vault]
api-version: 1.14

Expand Down