Compare commits
No commits in common. "87d0f75a4c24d2bb0db7b4b528aab565d94dd41f" and "80255a60eb8c42ae51f342352f7c8707489d0682" have entirely different histories.
87d0f75a4c
...
80255a60eb
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>CommandGUI_V2</artifactId>
|
||||
<version>2.7.7</version>
|
||||
<version>2.7.6</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>CommandGUI</name>
|
||||
|
@ -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");
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -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.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) {
|
||||
Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
|
||||
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ 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 {
|
||||
@ -41,11 +42,31 @@ 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.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 + "§4==============================================================================");
|
||||
|
@ -28,6 +28,7 @@ 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;
|
||||
@ -36,11 +37,6 @@ 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;
|
||||
@ -298,6 +294,7 @@ 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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
|
@ -86,7 +86,7 @@ public class Obj_Select {
|
||||
yamlConfiguration_gui.save(config_gui);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
|
||||
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ public class Load {
|
||||
"ENGINE=InnoDB" +
|
||||
";");
|
||||
} catch (Exception e) {
|
||||
Main.sendTryCatch(Load.class, e.getStackTrace()[0]);
|
||||
Util.sendTryCatch(Load.class, e.getStackTrace()[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
|
@ -28,7 +28,7 @@ public class SelectDatabase {
|
||||
try {
|
||||
MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';");
|
||||
} catch (SQLException e) {
|
||||
Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
|
||||
Util.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) {
|
||||
Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
|
||||
Util.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) {
|
||||
Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
|
||||
Util.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) {
|
||||
Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
|
||||
Util.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
|
@ -47,7 +47,7 @@ public class YML {
|
||||
try {
|
||||
yamlConfigurationStorage.save(storage);
|
||||
} catch (IOException e) {
|
||||
Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
|
||||
Util.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.jatitv.commandguiv2;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
|
||||
public class Util {
|
||||
@ -38,4 +39,8 @@ 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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user