Skip to content
Open
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
63 changes: 35 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import org.apache.tools.ant.filters.ReplaceTokens

buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}

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

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

}


plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

group 'me.realized'
Expand All @@ -24,10 +26,10 @@ 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 @@ -42,59 +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 {
compile 'org.projectlombok:lombok:1.18.22'
compile 'org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT'
compile (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
}
compile name: 'Vault-1.6.7'
compile 'me.clip:placeholderapi:2.10.9'
compileOnly "com.github.MilkBowl:VaultAPI:1.7"
compileOnly 'me.clip:placeholderapi:2.10.9'

// shaded dependencies
compile 'redis.clients:jedis:3.5.1'
compile 'org.apache.commons:commons-pool2:2.4.2'
compile 'com.zaxxer:HikariCP:4.0.2'
compile 'org.slf4j:slf4j-nop:1.7.32'
compile '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
destinationDir = file("$rootDir/out/")
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
baseName = 'TokenManager'
classifier = null
//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 Down
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,12 +8,14 @@ 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.replace("-R0", "")).orElse(0);
}

private CompatUtil() {}

public static boolean isAfter1_20() {
return SUB_VERSION > 20;
}
public static boolean isPre1_17() {
return SUB_VERSION < 17;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public static ItemStack loadFromString(final String line) {

if (materialData.length > 1) {
// Handle potions and spawn eggs switching to NBT in 1.9+
if (!CompatUtil.isPre1_9()) {
if (!CompatUtil.isPre1_9() && !CompatUtil.isAfter1_20()) {
if (material.name().contains("POTION")) {
final List<String> values = Arrays.asList(materialData[1].split("-"));
final PotionType type;
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