Fixed a bug that prevented the plugin from loading on the bungee.
This commit is contained in:
JaTiTV 2022-06-02 12:29:53 +02:00
parent 5674b54593
commit 6f3da3e3f4
12 changed files with 24 additions and 186 deletions

View File

@ -6,7 +6,11 @@
<groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId>
<<<<<<< Updated upstream
<version>2.7.5</version>
=======
<version>2.7.7</version>
>>>>>>> Stashed changes
<packaging>jar</packaging>
<name>CommandGUI</name>

View File

@ -1,40 +0,0 @@
package de.jatitv.commandguiv2.Bungee;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class BConfig {
public static void create() throws IOException {
File config = new File(BMain.plugin.getDataFolder(), "config.yml");
if (!BMain.plugin.getDataFolder().exists()) BMain.plugin.getDataFolder().mkdir();
if (!config.exists()) {
config.createNewFile();
}
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config);
configuration.set("MySQL.Enable", false);
configuration.set("MySQL.IP", "localhost");
configuration.set("MySQL.Port", 3306);
configuration.set("MySQL.Database", "database");
configuration.set("MySQL.User", "user");
configuration.set("MySQL.Password", "");
configuration.set("MySQL.SSL", false);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, config);
BMySQL.Enable = configuration.getBoolean("MySQL.Enable");
BMySQL.ip = configuration.getString("MySQL.IP");
BMySQL.port = configuration.getInt("MySQL.Port");
BMySQL.database = configuration.getString("MySQL.Database");
BMySQL.user = configuration.getString("MySQL.User");
BMySQL.password = configuration.getString("MySQL.Password");
BMySQL.SSL = configuration.getBoolean("MySQL.SSL");
}
}

View File

@ -1,5 +1,6 @@
package de.jatitv.commandguiv2.Bungee;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
import de.jatitv.commandguiv2.Util;
import net.md_5.bungee.BungeeCord;
@ -10,7 +11,6 @@ import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import java.io.*;
import java.util.logging.Logger;
@ -35,7 +35,7 @@ public class BListener implements Listener {
}
}
} catch (IOException e) {
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
e.printStackTrace();
}
}

View File

@ -5,7 +5,6 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import java.io.IOException;
import java.util.logging.Level;
public final class BMain extends Plugin {
@ -42,31 +41,11 @@ public final class BMain extends Plugin {
Bsend.console(prefix + " §2Version: §6" + version);
Bsend.console(prefix + " §2Spigot: §6" + spigot);
Bsend.console(prefix + " §2Discord: §6" + discord);
/* try {
BConfig.create();
} catch (IOException e) {
e.printStackTrace();
}
*/
plugin.getProxy().registerChannel("cgui:bungee");
plugin.getProxy().getPluginManager().registerListener(plugin, new BListener());
BListener.sendToSpigotDeleteAll();
BMetrics metrics = new BMetrics(this, bstatsID);
/*
if (BMySQL.Enable){
BMySQL.main();
BMySQL.query("CREATE TABLE IF NOT EXISTS `gui-bungeeplayer` (" +
" `UUID` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_general_ci'," +
" `Name` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci'," +
" `Online` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci'," +
" UNIQUE INDEX `UUID` (`UUID`)" +
")" +
"COLLATE='utf8mb4_general_ci'" +
"ENGINE=InnoDB" +
";");
}
*/
BMetrics.Bstats();
Bsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
Bsend.console(prefix + "§4==============================================================================");

View File

@ -28,7 +28,6 @@ import java.util.stream.Collectors;
import java.util.zip.GZIPOutputStream;
import javax.net.ssl.HttpsURLConnection;
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
import de.jatitv.commandguiv2.Util;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
@ -37,6 +36,11 @@ import net.md_5.bungee.config.YamlConfiguration;
public class BMetrics {
public static void Bstats() {
int pluginId = Util.getBstatsID(); // <-- Replace with the id of your plugin!
BMetrics metrics = new BMetrics(BMain.plugin, pluginId);
}
private final Plugin plugin;
private final MetricsBase metricsBase;
@ -294,7 +298,6 @@ public class BMetrics {
// Send the data
sendData(data);
} catch (Exception e) {
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
// Something went wrong! :(
if (logErrors) {
errorLogger.accept("Could not submit bStats metrics data", e);

View File

@ -1,107 +0,0 @@
package de.jatitv.commandguiv2.Bungee;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import java.sql.*;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Calendar;
public class BMySQL {
private static Plugin plugin = BMain.plugin;
protected static Boolean Enable = false;
protected static String ip = "localhost";
protected static Integer port = 3306;
protected static String database;
protected static String user = "root";
protected static String password = "";
protected static String url;
protected static Boolean SSL;
public static void main() {
Long long_ = Long.valueOf(System.currentTimeMillis());
Calendar now = Calendar.getInstance();
ZoneId timeZone = now.getTimeZone().toZoneId();
Bsend.debug(plugin, "Server TimeZone is : " + timeZone);
url = "jdbc:mysql://" + ip + ":" + port + "/" + database + "?useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=" + timeZone;
// Europe/Berlin
if (SSL) {
url = url + "&useSSL=true";
} else url = url + "&useSSL=false";
Bsend.debug(plugin, url);
try (Connection con = DriverManager.getConnection(url, user, password)) {
Statement stmt = con.createStatement();
stmt.close();
Bsend.console(BMain.prefix + " §2MySQL successfully connected." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} catch (SQLException ex) {
Bsend.console(BMain.prefix + " §4MySQL not connected." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
Bsend.error(plugin, ex.getMessage() + " --- " + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
}
public static void query(String query) {
try (Connection con = DriverManager.getConnection(url, user, password)) {
Statement stmt = con.createStatement();
stmt.execute(query);
stmt.close();
} catch (SQLException ex) {
System.err.println(ex.getMessage());
}
}
public static ArrayList<String> selectAll(String query) {
ArrayList<String> Result = new ArrayList<>();
try (Connection con = DriverManager.getConnection(url, user, password)) {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
int columns = rs.getMetaData().getColumnCount();
while (rs.next()) {
Result.add(rs.getString(1));
}
rs.close();
stmt.close();
} catch (SQLException ex) {
System.err.println(ex.getMessage());
}
return Result;
}
public static String select(String query) {
String Ausgabe = "";
try (Connection con = DriverManager.getConnection(url, user, password)) {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
int columns = rs.getMetaData().getColumnCount();
while (rs.next()) {
Ausgabe = String.valueOf(rs.getString(1));
}
rs.close();
stmt.close();
} catch (SQLException ex) {
System.err.println(ex.getMessage());
}
return Ausgabe;
}
public static int count(String query) {
Integer count = 0;
try (Connection con = DriverManager.getConnection(url, user, password)) {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
int columns = rs.getMetaData().getColumnCount();
while (rs.next()) {
count++;
}
rs.close();
stmt.close();
} catch (SQLException ex) {
System.err.println(ex.getMessage());
}
return count;
}
}

View File

@ -119,6 +119,10 @@ public final class Main extends JavaPlugin {
}
}
public static void sendTryCatch(Class c, StackTraceElement line){
send.error(plugin, c.getName() + " Line: " + line.getLineNumber());
}
@Override
public void onDisable() {
// Plugin shutdown logic

View File

@ -86,7 +86,7 @@ public class Obj_Select {
yamlConfiguration_gui.save(config_gui);
}
} catch (Exception e) {
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
e.printStackTrace();
}
}

View File

@ -184,7 +184,7 @@ public class Load {
"ENGINE=InnoDB" +
";");
} catch (Exception e) {
Util.sendTryCatch(Load.class, e.getStackTrace()[0]);
Main.sendTryCatch(Load.class, e.getStackTrace()[0]);
e.printStackTrace();
}
try {

View File

@ -28,7 +28,7 @@ public class SelectDatabase {
try {
MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';");
} catch (SQLException e) {
Util.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
e.printStackTrace();
}
break;
@ -49,7 +49,7 @@ public class SelectDatabase {
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Slot`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
+ "','" + slot + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Slot` = '" + slot + "';");
} catch (SQLException e) {
Util.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
e.printStackTrace();
}
break;
@ -72,7 +72,7 @@ public class SelectDatabase {
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
+ "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '1';");
} catch (SQLException e) {
Util.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
e.printStackTrace();
}
break;
@ -95,7 +95,7 @@ public class SelectDatabase {
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
+ "', '0') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '0';");
} catch (SQLException e) {
Util.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
e.printStackTrace();
}
break;

View File

@ -47,7 +47,7 @@ public class YML {
try {
yamlConfigurationStorage.save(storage);
} catch (IOException e) {
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
e.printStackTrace();
}
}

View File

@ -1,6 +1,5 @@
package de.jatitv.commandguiv2;
import de.jatitv.commandguiv2.Spigot.Main;
import net.t2code.lib.Spigot.Lib.messages.send;
public class Util {
@ -39,8 +38,4 @@ public class Util {
public static Integer getConfigVersion() {
return configVersion;
}
public static void sendTryCatch(Class c, StackTraceElement line){
send.error(Main.plugin, c.getName() + " Line: " + line.getLineNumber());
}
}