Compare commits

..

No commits in common. "87d0f75a4c24d2bb0db7b4b528aab565d94dd41f" and "80255a60eb8c42ae51f342352f7c8707489d0682" have entirely different histories.

12 changed files with 187 additions and 21 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId> <artifactId>CommandGUI_V2</artifactId>
<version>2.7.7</version> <version>2.7.6</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CommandGUI</name> <name>CommandGUI</name>

View File

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

View File

@ -5,6 +5,7 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.lib.Bungee.Lib.messages.Bsend; import net.t2code.lib.Bungee.Lib.messages.Bsend;
import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
public final class BMain extends Plugin { public final class BMain extends Plugin {
@ -41,11 +42,31 @@ public final class BMain extends Plugin {
Bsend.console(prefix + " §2Version: §6" + version); Bsend.console(prefix + " §2Version: §6" + version);
Bsend.console(prefix + " §2Spigot: §6" + spigot); Bsend.console(prefix + " §2Spigot: §6" + spigot);
Bsend.console(prefix + " §2Discord: §6" + discord); Bsend.console(prefix + " §2Discord: §6" + discord);
/* try {
BConfig.create();
} catch (IOException e) {
e.printStackTrace();
}
*/
plugin.getProxy().registerChannel("cgui:bungee"); plugin.getProxy().registerChannel("cgui:bungee");
plugin.getProxy().getPluginManager().registerListener(plugin, new BListener()); plugin.getProxy().getPluginManager().registerListener(plugin, new BListener());
BListener.sendToSpigotDeleteAll(); BListener.sendToSpigotDeleteAll();
BMetrics.Bstats(); 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" +
";");
}
*/
Bsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); Bsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
Bsend.console(prefix + "§4=============================================================================="); Bsend.console(prefix + "§4==============================================================================");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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