diff --git a/.idea/TFGuilds.iml b/.idea/TFGuilds.iml
index 163e931..e5665da 100644
--- a/.idea/TFGuilds.iml
+++ b/.idea/TFGuilds.iml
@@ -1,20 +1,15 @@
-
-
-
- SPIGOT
+ PAPER
-
+
@@ -24,81 +19,33 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index ec2a0b4..b9600f9 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -11,7 +11,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index b008060..e89a848 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -11,6 +11,11 @@
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index d2b0ede..c01a206 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -16,5 +16,5 @@
-
+
\ No newline at end of file
diff --git a/nb-configuration.xml b/nb-configuration.xml
index 5616f15..a5e2dc0 100644
--- a/nb-configuration.xml
+++ b/nb-configuration.xml
@@ -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).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
- JDK_11
+ JDK_17
true
diff --git a/pom.xml b/pom.xml
index 4658cc1..5a8e966 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.github.AtlasMediaGroup
TFGuilds
- 2021.06-RC3
+ 2022.01
jar
TFGuilds
@@ -25,8 +25,8 @@
maven-compiler-plugin
3.8.1
-
- 11
+
+ 17
@@ -60,16 +60,16 @@
https://jitpack.io
- spigotmc-repo
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+ papermc
+ https://papermc.io/repo/repository/maven-public/
- org.spigotmc
- spigot-api
- 1.16.5-R0.1-SNAPSHOT
+ io.papermc.paper
+ paper-api
+ 1.18.1-R0.1-SNAPSHOT
provided
diff --git a/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java b/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java
index 8ae4e12..2436829 100644
--- a/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java
+++ b/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java
@@ -14,6 +14,7 @@ import me.totalfreedom.tfguilds.listener.ChatListener;
import me.totalfreedom.tfguilds.listener.JoinListener;
import me.totalfreedom.tfguilds.sql.SQLDatabase;
import org.bukkit.plugin.java.JavaPlugin;
+import org.jetbrains.annotations.NotNull;
public class TFGuilds extends JavaPlugin
{
@@ -54,13 +55,13 @@ public class TFGuilds extends JavaPlugin
{
getSQL().getConnection().close();
}
- catch (SQLException throwables)
+ catch (SQLException ignored)
{
}
config.save();
}
- public Config getConfig()
+ public @NotNull Config getConfig()
{
return config;
}
diff --git a/src/main/java/me/totalfreedom/tfguilds/TFMBridge.java b/src/main/java/me/totalfreedom/tfguilds/TFMBridge.java
index 775d1b2..1a148f8 100644
--- a/src/main/java/me/totalfreedom/tfguilds/TFMBridge.java
+++ b/src/main/java/me/totalfreedom/tfguilds/TFMBridge.java
@@ -41,7 +41,7 @@ public class TFMBridge
Bukkit.getLogger().warning("TotalFreedomMod not detected, checking operator status instead.");
return player.isOp();
}
- Object al = ReflectionsHelper.getField(getTfm(), "al");
+ Object al = ReflectionsHelper.getField(getTfm(), "adminList");
Method isAdmin = ReflectionsHelper.getMethod(al, "isAdmin", Player.class);
try
{
@@ -61,7 +61,7 @@ public class TFMBridge
Bukkit.getLogger().warning("TotalFreedomMod not detected, checking operator status instead.");
return sender.isOp();
}
- Object al = ReflectionsHelper.getField(getTfm(), "al");
+ Object al = ReflectionsHelper.getField(getTfm(), "adminList");
Method isAdmin = ReflectionsHelper.getMethod(al, "isAdmin", CommandSender.class);
try
{
@@ -81,7 +81,7 @@ public class TFMBridge
Bukkit.getLogger().warning("TotalFreedomMod not detected, vanish will return false.");
return false;
}
- Object al = ReflectionsHelper.getField(getTfm(), "al");
+ Object al = ReflectionsHelper.getField(getTfm(), "adminList");
Method isVanished = ReflectionsHelper.getMethod(al, "isVanished", String.class);
try
{
@@ -101,7 +101,7 @@ public class TFMBridge
return null;
}
- Object pl = ReflectionsHelper.getField(getTfm(), "pl");
+ Object pl = ReflectionsHelper.getField(getTfm(), "playerList");
Method getPlayer = ReflectionsHelper.getMethod(pl, "getPlayer", Player.class);
try
{
@@ -125,7 +125,7 @@ public class TFMBridge
return;
}
// getTfm().pl.getPlayer(player).setTag(null);
- Object pl = ReflectionsHelper.getField(getTfm(), "pl");
+ Object pl = ReflectionsHelper.getField(getTfm(), "playerList");
Method getPlayer = ReflectionsHelper.getMethod(pl, "getPlayer", Player.class);
try
{
diff --git a/src/main/java/me/totalfreedom/tfguilds/config/Config.java b/src/main/java/me/totalfreedom/tfguilds/config/Config.java
index 636179e..79194c1 100644
--- a/src/main/java/me/totalfreedom/tfguilds/config/Config.java
+++ b/src/main/java/me/totalfreedom/tfguilds/config/Config.java
@@ -1,20 +1,27 @@
package me.totalfreedom.tfguilds.config;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
import me.totalfreedom.tfguilds.TFGuilds;
+import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
public class Config extends YamlConfiguration
{
- private final TFGuilds plugin;
private final File file;
public Config(String fileName)
{
- this.plugin = TFGuilds.getPlugin();
+ TFGuilds plugin = TFGuilds.getPlugin();
this.file = new File(plugin.getDataFolder(), fileName);
if (!file.exists())
@@ -22,6 +29,8 @@ public class Config extends YamlConfiguration
plugin.saveResource(fileName, false);
}
+ checkForFields();
+
load();
}
@@ -48,4 +57,50 @@ public class Config extends YamlConfiguration
ex.printStackTrace();
}
}
+
+ public void checkForFields()
+ {
+ if (!file.exists())
+ {
+ return;
+ }
+
+ Arrays.stream(ConfigEntry.values()).forEach(entry -> {
+ if (entry.getString().isBlank() || entry.getString().isEmpty() || entry.getString() == null)
+ {
+ try
+ {
+ String[] split = entry.getName().split("\\.");
+ String key = split[0];
+ String subKey = split[1];
+ String value = "REPLACE_ME";
+ FileWriter writer = new FileWriter(file, true);
+ InputStream is = TFGuilds.getPlugin().getResource("config.yml");
+ if (is == null) {
+ Bukkit.getServer().getLogger().severe("Unable to read from resource! Things may not work correctly!");
+ return;
+ }
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ while (reader.ready()) {
+ if (!reader.readLine().trim().startsWith(subKey)) {
+ continue;
+ }
+ value = reader.readLine().trim().split(":")[1].trim();
+ break;
+ }
+ writer.write("\n"
+ + key
+ + ": "
+ + "\n"
+ + subKey.indent(2)
+ + ": "
+ + value);
+ }
+ catch (IOException ignored)
+ {
+ Bukkit.getServer().getLogger().severe("The FileWriter could not add the necessary configuration options to the yaml file! Things may not work correctly!");
+ }
+ }
+ });
+ }
}
diff --git a/src/main/java/me/totalfreedom/tfguilds/config/ConfigEntry.java b/src/main/java/me/totalfreedom/tfguilds/config/ConfigEntry.java
index 2889c02..9777e02 100644
--- a/src/main/java/me/totalfreedom/tfguilds/config/ConfigEntry.java
+++ b/src/main/java/me/totalfreedom/tfguilds/config/ConfigEntry.java
@@ -45,4 +45,8 @@ public enum ConfigEntry
{
return config.getString(path);
}
+
+ public String getName() {
+ return path;
+ }
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index cae444f..6e0a911 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -4,7 +4,7 @@
settings:
# Types: mysql, sqlite
- connection: sqlite
+ connection: mysql
server:
# Log guild chat to console?
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 6174e6a..81f0a04 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,7 +1,7 @@
name: TFGuilds
version: ${project.version}
main: me.totalfreedom.tfguilds.TFGuilds
-api-version: 1.16
+api-version: 1.17
authors: [ Fleek, super, speed ]
description: A guilds plugin for the TotalFreedom server.
softdepend: