This commit is contained in:
Telesphoreo 2022-03-25 16:25:01 -05:00
commit 4b6fb1ead4
14 changed files with 156 additions and 133 deletions

View file

@ -1,20 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="CheckStyle-IDEA-Module">
<option name="configuration">
<map />
</option>
</component>
<component name="FacetManager"> <component name="FacetManager">
<facet type="minecraft" name="Minecraft"> <facet type="minecraft" name="Minecraft">
<configuration> <configuration>
<autoDetectTypes> <autoDetectTypes>
<platformType>SPIGOT</platformType> <platformType>PAPER</platformType>
</autoDetectTypes> </autoDetectTypes>
</configuration> </configuration>
</facet> </facet>
</component> </component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_17">
<output url="file://$MODULE_DIR$/target/classes" /> <output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" /> <output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
@ -24,81 +19,33 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:31.0.1-jre" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.AtlasMediaGroup:TotalFreedomMod:development-0be2aa718f-1" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.errorprone:error_prone_annotations:2.7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.plugins:maven-checkstyle-plugin:3.1.1" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven:maven-artifact:3.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven:maven-core:3.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven:maven-settings:3.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.30" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven:maven-settings-builder:3.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven:maven-repository-metadata:3.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.5.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven:maven-model-builder:3.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.17.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven:maven-aether-provider:3.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.8.0-beta4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.sonatype.aether:aether-impl:1.7" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-api:4.9.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.sonatype.aether:aether-spi:1.7" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-key:4.9.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.sonatype.aether:aether-api:1.7" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:examination-api:1.3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.sonatype.aether:aether-util:1.7" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:examination-string:1.3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.sonatype.sisu:sisu-inject-plexus:1.4.2" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:22.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.sonatype.sisu:sisu-inject-bean:1.4.2" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-gson:4.9.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.sonatype.sisu:sisu-guice:noaop:2.1.7" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-legacy:4.9.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.plexus:plexus-classworlds:2.2.3" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-plain:4.9.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.sonatype.plexus:plexus-sec-dispatcher:1.3" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.checkerframework:checker-qual:3.21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.sonatype.plexus:plexus-cipher:1.4" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm:9.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven:maven-model:3.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:9.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven:maven-plugin-api:3.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:9.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.reporting:maven-reporting-api:3.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:9.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.reporting:maven-reporting-impl:2.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.shared:maven-shared-utils:0.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:2.0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.doxia:doxia-core:1.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: xerces:xercesImpl:2.9.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: xml-apis:xml-apis:1.3.04" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-validator:commons-validator:1.3.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-digester:commons-digester:1.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.doxia:doxia-sink-api:1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.doxia:doxia-logging-api:1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.doxia:doxia-decoration-model:1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.doxia:doxia-site-renderer:1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.doxia:doxia-module-xhtml:1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.doxia:doxia-module-fml:1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.plexus:plexus-i18n:1.0-beta-7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.velocity:velocity-tools:2.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-chain:commons-chain:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: dom4j:dom4j:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: oro:oro:2.0.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: sslext:sslext:1.2-0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.struts:struts-core:1.3.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.struts:struts-taglib:1.3.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.struts:struts-tiles:1.3.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.doxia:doxia-integration-tools:1.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.plexus:plexus-container-default:1.0-alpha-9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:3.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: classworlds:classworlds:1.1-alpha-2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.plexus:plexus-component-annotations:2.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.plexus:plexus-resources:1.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.plexus:plexus-utils:3.3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.plexus:plexus-interpolation:1.26" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.plexus:plexus-velocity:1.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.puppycrawl.tools:checkstyle:8.29" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: info.picocli:picocli:4.1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.8-1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-beanutils:commons-beanutils:1.9.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.saxon:Saxon-HE:9.9.1-6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.velocity:velocity:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.16" level="project" />
</component> </component>
</module> </module>

View file

@ -2,6 +2,7 @@
<project version="4"> <project version="4">
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<annotationProcessing> <annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true"> <profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" /> <sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
@ -10,7 +11,7 @@
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel> <bytecodeTargetLevel>
<module name="TFGuilds" target="11" /> <module name="TFGuilds" target="17" />
</bytecodeTargetLevel> </bytecodeTargetLevel>
</component> </component>
</project> </project>

View file

@ -11,6 +11,11 @@
<option name="name" value="jitpack.io" /> <option name="name" value="jitpack.io" />
<option name="url" value="https://jitpack.io" /> <option name="url" value="https://jitpack.io" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="papermc" />
<option name="name" value="papermc" />
<option name="url" value="https://papermc.io/repo/repository/maven-public/" />
</remote-repository>
<remote-repository> <remote-repository>
<option name="id" value="sonatype" /> <option name="id" value="sonatype" />
<option name="name" value="sonatype" /> <option name="name" value="sonatype" />

View file

@ -16,5 +16,5 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="11" project-jdk-type="JavaSDK" /> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK" />
</project> </project>

View file

@ -13,7 +13,7 @@ You can copy and paste the single properties, into the pom.xml file and the IDE
That way multiple projects can share the same settings (useful for formatting rules for example). That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project. Any value defined here will override the pom.xml file value but is only applicable to the current project.
--> -->
<netbeans.hint.jdkPlatform>JDK_11</netbeans.hint.jdkPlatform> <netbeans.hint.jdkPlatform>JDK_17</netbeans.hint.jdkPlatform>
<org-netbeans-modules-javascript2-requirejs.enabled>true</org-netbeans-modules-javascript2-requirejs.enabled> <org-netbeans-modules-javascript2-requirejs.enabled>true</org-netbeans-modules-javascript2-requirejs.enabled>
</properties> </properties>
</project-shared-configuration> </project-shared-configuration>

22
pom.xml
View file

@ -4,9 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>me.totalfreedom</groupId> <groupId>com.github.AtlasMediaGroup</groupId>
<artifactId>TFGuilds</artifactId> <artifactId>TFGuilds</artifactId>
<version>2021.06-RC3</version> <version>2022.01</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>TFGuilds</name> <name>TFGuilds</name>
@ -25,8 +25,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.8.1</version>
<configuration> <configuration>
<source>11</source> <source>17</source>
<target>11</target> <target>17</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -56,16 +56,20 @@
<repositories> <repositories>
<repository> <repository>
<id>spigotmc-repo</id> <id>jitpack.io</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://jitpack.io</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>io.papermc.paper</groupId>
<artifactId>spigot-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version> <version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -6,6 +6,11 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import me.totalfreedom.tfguilds.command.*; import me.totalfreedom.tfguilds.command.*;
import me.totalfreedom.tfguilds.config.Config; import me.totalfreedom.tfguilds.config.Config;
import me.totalfreedom.tfguilds.guild.Guild; import me.totalfreedom.tfguilds.guild.Guild;
@ -14,6 +19,7 @@ import me.totalfreedom.tfguilds.listener.ChatListener;
import me.totalfreedom.tfguilds.listener.JoinListener; import me.totalfreedom.tfguilds.listener.JoinListener;
import me.totalfreedom.tfguilds.sql.SQLDatabase; import me.totalfreedom.tfguilds.sql.SQLDatabase;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
public class TFGuilds extends JavaPlugin public class TFGuilds extends JavaPlugin
{ {
@ -33,7 +39,7 @@ public class TFGuilds extends JavaPlugin
public void onEnable() public void onEnable()
{ {
plugin = this; plugin = this;
config = new Config("config.yml"); config = new Config(this,"config.yml");
sqlDatabase = new SQLDatabase(this); sqlDatabase = new SQLDatabase(this);
User.loadAll(); User.loadAll();
Guild.loadAll(); Guild.loadAll();
@ -54,13 +60,13 @@ public class TFGuilds extends JavaPlugin
{ {
getSQL().getConnection().close(); getSQL().getConnection().close();
} }
catch (SQLException throwables) catch (SQLException ignored)
{ {
} }
config.save(); config.save();
} }
public Config getConfig() public @NotNull Config getConfig()
{ {
return config; return config;
} }
@ -87,6 +93,19 @@ public class TFGuilds extends JavaPlugin
return commands; return commands;
} }
private void forcedSQLPostLoad() {
ExecutorService ex = Executors.newCachedThreadPool();
Future<SQLDatabase> future = ex.submit(() -> new SQLDatabase(getPlugin()));
try
{
sqlDatabase = future.get();
}
catch (InterruptedException | ExecutionException e)
{
e.printStackTrace();
}
}
private void loadSubCommands() private void loadSubCommands()
{ {
subCommands.put("create", new CreateSubCommand()); subCommands.put("create", new CreateSubCommand());

View file

@ -10,10 +10,11 @@ import org.bukkit.plugin.Plugin;
public class TFMBridge public class TFMBridge
{ {
private final TFGuilds plugin = TFGuilds.getPlugin(); private final TFGuilds plugin = TFGuilds.getPlugin();
private /*TotalFreedomMod*/ Plugin tfm = null; private /*TotalFreedomMod*/ Plugin tfm = null;
public /*TotalFreedomMod*/ Plugin getTFM() public /*TotalFreedomMod*/ Plugin getTfm()
{ {
if (tfm == null) if (tfm == null)
{ {
@ -35,16 +36,16 @@ public class TFMBridge
public boolean isAdmin(Player player) public boolean isAdmin(Player player)
{ {
if (getTFM() == null) if (getTfm() == null)
{ {
Bukkit.getLogger().warning("TotalFreedomMod not detected, checking operator status instead."); Bukkit.getLogger().warning("TotalFreedomMod not detected, checking operator status instead.");
return player.isOp(); return player.isOp();
} }
Object adminList = ReflectionsHelper.getField(getTFM(), "adminList"); Object adminList = ReflectionsHelper.getField(getTfm(), "adminList");
Method isAdmin = ReflectionsHelper.getMethod(adminList, "isAdmin", Player.class); Method isAdmin = ReflectionsHelper.getMethod(adminList, "isAdmin", Player.class);
try try
{ {
return (boolean)isAdmin.invoke(adminList, player) /*getTfm().al.isAdmin(player)*/; return (boolean)isAdmin.invoke(adminList, player) /*getTfm().adminList.isAdmin(player)*/;
} }
catch (IllegalAccessException | InvocationTargetException e) catch (IllegalAccessException | InvocationTargetException e)
{ {
@ -55,16 +56,16 @@ public class TFMBridge
public boolean isAdmin(CommandSender sender) public boolean isAdmin(CommandSender sender)
{ {
if (getTFM() == null) if (getTfm() == null)
{ {
Bukkit.getLogger().warning("TotalFreedomMod not detected, checking operator status instead."); Bukkit.getLogger().warning("TotalFreedomMod not detected, checking operator status instead.");
return sender.isOp(); return sender.isOp();
} }
Object adminList = ReflectionsHelper.getField(getTFM(), "adminList"); Object adminList = ReflectionsHelper.getField(getTfm(), "adminList");
Method isAdmin = ReflectionsHelper.getMethod(adminList, "isAdmin", CommandSender.class); Method isAdmin = ReflectionsHelper.getMethod(adminList, "isAdmin", CommandSender.class);
try try
{ {
return (boolean)isAdmin.invoke(adminList, sender) /*getTfm().al.isAdmin(player)*/; return (boolean)isAdmin.invoke(adminList, sender) /*getTfm().adminList.isAdmin(player)*/;
} }
catch (IllegalAccessException | InvocationTargetException e) catch (IllegalAccessException | InvocationTargetException e)
{ {
@ -75,12 +76,12 @@ public class TFMBridge
public boolean isVanished(Player player) public boolean isVanished(Player player)
{ {
if (getTFM() == null) if (getTfm() == null)
{ {
Bukkit.getLogger().warning("TotalFreedomMod not detected, vanish will return false."); Bukkit.getLogger().warning("TotalFreedomMod not detected, vanish will return false.");
return false; return false;
} }
Object adminList = ReflectionsHelper.getField(getTFM(), "adminList"); Object adminList = ReflectionsHelper.getField(getTfm(), "adminList");
Method isVanished = ReflectionsHelper.getMethod(adminList, "isVanished", String.class); Method isVanished = ReflectionsHelper.getMethod(adminList, "isVanished", String.class);
try try
{ {
@ -95,12 +96,12 @@ public class TFMBridge
public String getTag(Player player) public String getTag(Player player)
{ {
if (getTFM() == null) if (getTfm() == null)
{ {
return null; return null;
} }
Object playerList = ReflectionsHelper.getField(getTFM(), "playerList"); Object playerList = ReflectionsHelper.getField(getTfm(), "playerList");
Method getPlayer = ReflectionsHelper.getMethod(playerList, "getPlayer", Player.class); Method getPlayer = ReflectionsHelper.getMethod(playerList, "getPlayer", Player.class);
try try
{ {
@ -119,12 +120,12 @@ public class TFMBridge
public void clearTag(Player player) public void clearTag(Player player)
{ {
if (getTFM() == null) if (getTfm() == null)
{ {
return; return;
} }
// getTfm().playerList.getPlayer(player).setTag(null); // getTfm().playerList.getPlayer(player).setTag(null);
Object playerList = ReflectionsHelper.getField(getTFM(), "playerList"); Object playerList = ReflectionsHelper.getField(getTfm(), "playerList");
Method getPlayer = ReflectionsHelper.getMethod(playerList, "getPlayer", Player.class); Method getPlayer = ReflectionsHelper.getMethod(playerList, "getPlayer", Player.class);
try try
{ {

View file

@ -1,20 +1,32 @@
package me.totalfreedom.tfguilds.config; package me.totalfreedom.tfguilds.config;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicBoolean;
import me.totalfreedom.tfguilds.TFGuilds; import me.totalfreedom.tfguilds.TFGuilds;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
public class Config extends YamlConfiguration public class Config extends YamlConfiguration
{ {
private final TFGuilds plugin;
private final File file; private final File file;
private final TFGuilds plugin;
private final String fileName;
public Config(String fileName) public Config(TFGuilds plugin, String fileName)
{ {
this.plugin = TFGuilds.getPlugin();
this.fileName = fileName;
this.plugin = plugin;
this.file = new File(plugin.getDataFolder(), fileName); this.file = new File(plugin.getDataFolder(), fileName);
if (!file.exists()) if (!file.exists())
@ -22,6 +34,8 @@ public class Config extends YamlConfiguration
plugin.saveResource(fileName, false); plugin.saveResource(fileName, false);
} }
verifyConfiguration();
load(); load();
} }
@ -48,4 +62,29 @@ public class Config extends YamlConfiguration
ex.printStackTrace(); ex.printStackTrace();
} }
} }
public void verifyConfiguration() {
InputStreamReader stream = new InputStreamReader(plugin.getResource(fileName));
YamlConfiguration reader = YamlConfiguration.loadConfiguration(stream);
YamlConfiguration writer = YamlConfiguration.loadConfiguration(file);
AtomicBoolean shouldSave = new AtomicBoolean(false);
try {
reader.getKeys(true).forEach(key -> {
if (!writer.contains(key)) writer.set(key, reader.get(key));
if (!shouldSave.get()) shouldSave.set(true);
});
if (shouldSave.get()) {
writer.save(file);
}
} catch (IOException ex) {
TFGuilds.getPlugin()
.getLogger()
.severe("Error attempting to verify configuration: \n"
+ ex.getMessage()
+ "\nCaused by: "
+ ex.getCause());
}
}
} }

View file

@ -45,4 +45,8 @@ public enum ConfigEntry
{ {
return config.getString(path); return config.getString(path);
} }
public String getName() {
return path;
}
} }

View file

@ -43,13 +43,19 @@ public class JoinListener implements Listener
int maxLength = ConfigEntry.GLOBAL_TAG_MAX_LENGTH.getInteger(); int maxLength = ConfigEntry.GLOBAL_TAG_MAX_LENGTH.getInteger();
String tfmTag = TFGuilds.getPlugin().getTfmBridge().getTag(player); String tfmTag = TFGuilds.getPlugin().getTfmBridge().getTag(player);
if (user.displayTag() && tfmTag != null && guild.getTag() != null && maxLength > 0) if (user != null && user.displayTag() && tfmTag != null && guild.getTag() != null && maxLength > 0)
{ {
int length = GUtil.removeColorCodes(tfmTag).length() + GUtil.removeColorCodes(guild.getTag()).length(); String tfmTagStripped = GUtil.removeColorCodes(tfmTag);
if (length > maxLength) String guildTagStripped = GUtil.removeColorCodes(guild.getTag());
if (tfmTagStripped != null && guildTagStripped != null)
{ {
TFGuilds.getPlugin().getTfmBridge().clearTag(player); int length = tfmTagStripped.length() + guildTagStripped.length();
if (length > maxLength)
{
TFGuilds.getPlugin().getTfmBridge().clearTag(player);
}
} }
} }
} }
} }

View file

@ -22,21 +22,18 @@ public class SQLDatabase
} }
try try
{ {
switch (ConfigEntry.CONNECTION_TYPE.getString().toLowerCase()) if ("mysql".equals(ConfigEntry.CONNECTION_TYPE.getString().toLowerCase()))
{ {
case "sqlite": connection = DriverManager.getConnection(String.format("jdbc:mysql://%s:%d/%s",
connection = DriverManager.getConnection("jdbc:sqlite:" + createDBFile(plugin).getAbsolutePath().replace("%20", " ")); ConfigEntry.MYSQL_HOST.getString(),
break; ConfigEntry.MYSQL_PORT.getInteger(),
case "mysql": ConfigEntry.MYSQL_DATABASE.getString()),
connection = DriverManager.getConnection(String.format("jdbc:mysql://%s:%d/%s", ConfigEntry.MYSQL_USERNAME.getString(),
ConfigEntry.MYSQL_HOST.getString(), password);
ConfigEntry.MYSQL_PORT.getInteger(), }
ConfigEntry.MYSQL_DATABASE.getString()), else
ConfigEntry.MYSQL_USERNAME.getString(), {
password); connection = DriverManager.getConnection("jdbc:sqlite:" + createDBFile(plugin).getAbsolutePath().replace("%20", " "));
break;
default:
connection = DriverManager.getConnection("jdbc:sqlite:" + createDBFile(plugin).getAbsolutePath().replace("%20", " "));
} }
createTables(); createTables();

View file

@ -4,7 +4,7 @@
settings: settings:
# Types: mysql, sqlite # Types: mysql, sqlite
connection: sqlite connection: mysql
server: server:
# Log guild chat to console? # Log guild chat to console?

View file

@ -1,7 +1,7 @@
name: TFGuilds name: TFGuilds
version: ${project.version} version: ${project.version}
main: me.totalfreedom.tfguilds.TFGuilds main: me.totalfreedom.tfguilds.TFGuilds
api-version: 1.16 api-version: 1.17
authors: [ Fleek, super, speed ] authors: [ Fleek, super, speed ]
description: A guilds plugin for the TotalFreedom server. description: A guilds plugin for the TotalFreedom server.
softdepend: softdepend: