2.5.13
This commit is contained in:
parent
6b6ebbcd18
commit
e0da2cd88d
@ -3,6 +3,8 @@ package de.jatitv.commandguiv2.Bungee;
|
|||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
import net.md_5.bungee.config.ConfigurationProvider;
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
import net.md_5.bungee.config.YamlConfiguration;
|
import net.md_5.bungee.config.YamlConfiguration;
|
||||||
|
import net.t2code.lib.Bungee.Lib.messages.Bsend;
|
||||||
|
import net.t2code.lib.Util;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -26,17 +28,30 @@ public class BConfig {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Configuration configuration;
|
||||||
try {
|
try {
|
||||||
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(BMain.plugin.getDataFolder(), "config.yml"));
|
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(BMain.plugin.getDataFolder(), "config.yml"));
|
||||||
|
BMySQL.Enable = configuration.getBoolean("MySQL.Enable");
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bsend.console(Util.Prefix + " Please replace the config: MySQL.Enable: [false,true]");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(BMain.plugin.getDataFolder(), "config.yml"));
|
||||||
BMySQL.ip = configuration.getString("MySQL.IP");
|
BMySQL.ip = configuration.getString("MySQL.IP");
|
||||||
BMySQL.port = configuration.getInt("MySQL.Port");
|
BMySQL.port = configuration.getInt("MySQL.Port");
|
||||||
BMySQL.database = configuration.getString("MySQL.Database");
|
BMySQL.database = configuration.getString("MySQL.Database");
|
||||||
BMySQL.user = configuration.getString("MySQL.User");
|
BMySQL.user = configuration.getString("MySQL.User");
|
||||||
BMySQL.password = configuration.getString("MySQL.Password");
|
BMySQL.password = configuration.getString("MySQL.Password");
|
||||||
BMySQL.SSL = configuration.getBoolean("MySQL.SSL");
|
BMySQL.SSL = configuration.getBoolean("MySQL.SSL");
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package de.jatitv.commandguiv2.Bungee;
|
package de.jatitv.commandguiv2.Bungee;
|
||||||
|
|
||||||
import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig;
|
|
||||||
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
|
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
@ -13,7 +10,6 @@ import net.md_5.bungee.event.EventHandler;
|
|||||||
import net.t2code.lib.Bungee.Lib.messages.Bsend;
|
import net.t2code.lib.Bungee.Lib.messages.Bsend;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class BListener implements Listener {
|
public class BListener implements Listener {
|
||||||
@ -25,8 +21,6 @@ public class BListener implements Listener {
|
|||||||
String channel = stream.readUTF();
|
String channel = stream.readUTF();
|
||||||
String input = stream.readUTF();
|
String input = stream.readUTF();
|
||||||
ProxiedPlayer player = BungeeCord.getInstance().getPlayer(channel);
|
ProxiedPlayer player = BungeeCord.getInstance().getPlayer(channel);
|
||||||
|
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
BungeeCord.getInstance().getPluginManager().dispatchCommand(player, input);
|
BungeeCord.getInstance().getPluginManager().dispatchCommand(player, input);
|
||||||
}
|
}
|
||||||
@ -40,18 +34,23 @@ public class BListener implements Listener {
|
|||||||
public void onJoin(PostLoginEvent e) {
|
public void onJoin(PostLoginEvent e) {
|
||||||
ProxiedPlayer player = e.getPlayer();
|
ProxiedPlayer player = e.getPlayer();
|
||||||
sendToSpigotPlayer(player.getName(), true);
|
sendToSpigotPlayer(player.getName(), true);
|
||||||
|
if (BMySQL.Enable) {
|
||||||
BMySQL.query("INSERT INTO `gui-bungeeplayer` (`UUID`, `Name`, `Online`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
BMySQL.query("INSERT INTO `gui-bungeeplayer` (`UUID`, `Name`, `Online`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||||
+ "', 'true') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Online` = 'true';");
|
+ "', 'true') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Online` = 'true';");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDisconnect(PlayerDisconnectEvent e) {
|
public void onDisconnect(PlayerDisconnectEvent e) {
|
||||||
ProxiedPlayer player = e.getPlayer();
|
ProxiedPlayer player = e.getPlayer();
|
||||||
sendToSpigotPlayer(e.getPlayer().getName(), false);
|
sendToSpigotPlayer(e.getPlayer().getName(), false);
|
||||||
|
if (BMySQL.Enable) {
|
||||||
BMySQL.query("INSERT INTO `gui-bungeeplayer` (`UUID`, `Name`, `Online`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
BMySQL.query("INSERT INTO `gui-bungeeplayer` (`UUID`, `Name`, `Online`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||||
+ "', 'true') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Online` = 'false';");
|
+ "', 'true') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Online` = 'false';");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendToSpigotPlayer(String name, Boolean join) {
|
public static void sendToSpigotPlayer(String name, Boolean join) {
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
DataOutputStream output = new DataOutputStream(stream);
|
DataOutputStream output = new DataOutputStream(stream);
|
||||||
|
@ -49,6 +49,7 @@ public final class BMain extends Plugin {
|
|||||||
BListener.sendToSpigotDeleteAll();
|
BListener.sendToSpigotDeleteAll();
|
||||||
BMetrics metrics = new BMetrics(this, bstatsID);
|
BMetrics metrics = new BMetrics(this, bstatsID);
|
||||||
|
|
||||||
|
if (BMySQL.Enable){
|
||||||
BMySQL.main();
|
BMySQL.main();
|
||||||
BMySQL.query("CREATE TABLE IF NOT EXISTS `gui-bungeeplayer` (" +
|
BMySQL.query("CREATE TABLE IF NOT EXISTS `gui-bungeeplayer` (" +
|
||||||
" `UUID` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_general_ci'," +
|
" `UUID` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_general_ci'," +
|
||||||
@ -60,6 +61,8 @@ public final class BMain extends Plugin {
|
|||||||
"ENGINE=InnoDB" +
|
"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==============================================================================");
|
||||||
BUpdateChecker.onUpdateCheck();
|
BUpdateChecker.onUpdateCheck();
|
||||||
|
@ -12,6 +12,8 @@ import java.util.Calendar;
|
|||||||
|
|
||||||
public class BMySQL {
|
public class BMySQL {
|
||||||
private static Plugin plugin = BMain.plugin;
|
private static Plugin plugin = BMain.plugin;
|
||||||
|
protected static Boolean Enable = false;
|
||||||
|
|
||||||
protected static String ip = "localhost";
|
protected static String ip = "localhost";
|
||||||
protected static Integer port = 3306;
|
protected static Integer port = 3306;
|
||||||
protected static String database;
|
protected static String database;
|
||||||
|
@ -2,10 +2,8 @@ package de.jatitv.commandguiv2.Spigot.system;
|
|||||||
|
|
||||||
import de.jatitv.commandguiv2.Spigot.Main;
|
import de.jatitv.commandguiv2.Spigot.Main;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user