mirror of
https://github.com/5vl/SkyblockRemake.git
synced 2025-05-24 06:47:01 +00:00
bonk
This commit is contained in:
parent
56159f1f98
commit
09e967962d
2
pom.xml
2
pom.xml
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<name>Sbr</name>
|
<name>Sbr</name>
|
||||||
|
|
||||||
<description>Hypxel Skyblock Remake</description>
|
<description>Hyipxel Skyblock Remake</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
63
src/main/java/sbr/sbr/commands/hub.java
Normal file
63
src/main/java/sbr/sbr/commands/hub.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package sbr.sbr.commands;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import sbr.sbr.main;
|
||||||
|
import sbr.sbr.utils.chatcolors;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class hub extends chatcolors implements CommandExecutor {
|
||||||
|
public static final String[] hubList = {"Hub1A", "Hub1B", "Hub1C", "Hub1D", "Hub1E", "Hub1F", "Hub2A", "Hub2B", "Hub2C", "Hub2D", "Hub2E", "Hub2F", "Hub3A", "Hub3B", "Hub3C", "Hub3D", "Hub3E", "Hub3F", "Hub4A", "Hub4B", "Hub4C", "Hub4D", "Hub4E", "Hub4F", "Hub5A", "Hub5B", "Hub5C", "Hub5D"};
|
||||||
|
public static final String hubs = "Hub1A Hub1B Hub1C Hub1D Hub1E Hub1F Hub2A Hub2B Hub2C Hub2D Hub2E Hub2F Hub3A Hub3B Hub3C Hub3D Hub3E Hub3F Hub4A Hub4B Hub4C Hub4D Hub4E Hub4F Hub5A Hub5B Hub5C Hub5D";
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
System.out.println("You can only run this command as a player!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (args.length == 0) {
|
||||||
|
Random r = new Random();
|
||||||
|
String randomHub = hubList[r.nextInt(hubList.length)];
|
||||||
|
if (!randomHub.equals(p.getWorld().getName())) {
|
||||||
|
Bukkit.createWorld(new WorldCreator(randomHub));
|
||||||
|
World setHub = Bukkit.getWorld(randomHub);
|
||||||
|
p.teleport(new Location(setHub, 0.5, 71, 0.5, 180, 0));
|
||||||
|
main.currentWorld.remove(p.getUniqueId());
|
||||||
|
main.currentWorld.put(p.getUniqueId(), randomHub);
|
||||||
|
p.sendMessage(color("&aSent you to hub &b" + randomHub + "&a!"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p.sendMessage(color("&cError: You are trying to go to the same hub."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length == 1) {
|
||||||
|
if (args[0].equalsIgnoreCase("rn")) {
|
||||||
|
p.sendMessage(color(("&aYou are currently in hub &b" + main.currentWorld.get(p.getUniqueId()) + "&a!")));
|
||||||
|
}
|
||||||
|
else if (hubs.contains(args[0]) && Bukkit.getWorld(args[0]) != null) {
|
||||||
|
Bukkit.createWorld(new WorldCreator(args[0]));
|
||||||
|
World setHub = Bukkit.getWorld(args[0]);
|
||||||
|
p.teleport(new Location(setHub, 0.5, 71, 0.5, 180, 0));
|
||||||
|
main.currentWorld.remove(p.getUniqueId());
|
||||||
|
main.currentWorld.put(p.getUniqueId(), args[0]);
|
||||||
|
p.sendMessage(color("&aSent you to hub &b" + args[0] + "&a!"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p.sendMessage(color("&4That is not a correct hub name!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p.sendMessage(color("&cCorrect command usage: &6/hub&c, &6/hub [hubname]"));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
import sbr.sbr.commands.banker;
|
import sbr.sbr.commands.banker;
|
||||||
import sbr.sbr.guis.banker.bankerDeposit;
|
import sbr.sbr.guis.banker.bankerDeposit;
|
||||||
import sbr.sbr.guis.banker.bankerWithdraw;
|
import sbr.sbr.guis.banker.bankerWithdraw;
|
||||||
@ -17,6 +18,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class InvClick extends chatcolors implements Listener {
|
public class InvClick extends chatcolors implements Listener {
|
||||||
public static final HashMap<UUID, String> currentGui = new HashMap<>();
|
public static final HashMap<UUID, String> currentGui = new HashMap<>();
|
||||||
|
final HashMap<UUID, String> newChat = new HashMap<>();
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void InventoryClick(InventoryClickEvent e) {
|
public void InventoryClick(InventoryClickEvent e) {
|
||||||
Player p = (Player) e.getWhoClicked();
|
Player p = (Player) e.getWhoClicked();
|
||||||
@ -32,7 +34,7 @@ public class InvClick extends chatcolors implements Listener {
|
|||||||
p.openInventory(bankerWithdraw.getGui());
|
p.openInventory(bankerWithdraw.getGui());
|
||||||
currentGui.put(p.getUniqueId(), "bankerWithdraw");
|
currentGui.put(p.getUniqueId(), "bankerWithdraw");
|
||||||
}
|
}
|
||||||
if (e.getRawSlot() == 32) {
|
if (e.getRawSlot() == 31) {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -77,7 +79,12 @@ public class InvClick extends chatcolors implements Listener {
|
|||||||
p.sendMessage(color("&4&lSomething went wrong, please report this to the devs ASAP."));
|
p.sendMessage(color("&4&lSomething went wrong, please report this to the devs ASAP."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.getRawSlot() == 32) {
|
if (e.getRawSlot() == 15) {
|
||||||
|
newChat.put(p.getUniqueId(), "bankerWithdraw");
|
||||||
|
p.closeInventory();
|
||||||
|
p.sendMessage(color("&7Put the amount you want to withdraw in the chat."));
|
||||||
|
}
|
||||||
|
if (e.getRawSlot() == 31) {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -123,7 +130,12 @@ public class InvClick extends chatcolors implements Listener {
|
|||||||
p.sendMessage(color("&4&lSomething went wrong, please report this to the devs ASAP."));
|
p.sendMessage(color("&4&lSomething went wrong, please report this to the devs ASAP."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.getRawSlot() == 32) {
|
if (e.getRawSlot() == 15) {
|
||||||
|
newChat.put(p.getUniqueId(), "bankerDeposit");
|
||||||
|
p.closeInventory();
|
||||||
|
p.sendMessage(color("&7Put the amount you want to deposit in the chat."));
|
||||||
|
}
|
||||||
|
if (e.getRawSlot() == 31) {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -135,4 +147,83 @@ public class InvClick extends chatcolors implements Listener {
|
|||||||
Player p = (Player) e.getPlayer();
|
Player p = (Player) e.getPlayer();
|
||||||
currentGui.remove(p.getUniqueId());
|
currentGui.remove(p.getUniqueId());
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@EventHandler
|
||||||
|
public void OnChat(PlayerChatEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
try {
|
||||||
|
if (newChat.get(p.getUniqueId()).equalsIgnoreCase("bankerWithdraw")) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
newChat.remove(p.getUniqueId());
|
||||||
|
try {
|
||||||
|
String msg = e.getMessage();
|
||||||
|
int number = Integer.parseInt(msg);
|
||||||
|
if (number < 1) {
|
||||||
|
p.sendMessage(color("&cAmount must be higher than 0!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ResultSet bank = main.prepareStatement("SELECT * FROM bank WHERE UUID = '" + banker.p.getUniqueId().toString() + "';").executeQuery();
|
||||||
|
ResultSet purse = main.prepareStatement("SELECT * FROM purse WHERE UUID = '" + banker.p.getUniqueId().toString() + "';").executeQuery();
|
||||||
|
bank.next();
|
||||||
|
purse.next();
|
||||||
|
int bankBal = bank.getInt("Balance");
|
||||||
|
int purseBal = purse.getInt("Balance");
|
||||||
|
int newBank = bankBal - number;
|
||||||
|
if (newBank < 0) {
|
||||||
|
p.sendMessage(color("&cYou do not have enough coins in your bank to do that!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int newPurse = purseBal + number;
|
||||||
|
main.prepareStatement("UPDATE bank SET Balance = '" + newBank + "' WHERE UUID = '" + p.getUniqueId().toString() + "';").executeUpdate();
|
||||||
|
main.prepareStatement("UPDATE purse SET Balance = '" + newPurse + "' WHERE UUID = '" + p.getUniqueId().toString() + "';").executeUpdate();
|
||||||
|
p.closeInventory();
|
||||||
|
p.sendMessage(color("&aWithdrew &6" + number + " &afrom your bank."));
|
||||||
|
p.sendMessage(color("&aYou now have &6" + newBank + " &ain your bank."));
|
||||||
|
} catch (SQLException x) {
|
||||||
|
x.printStackTrace();
|
||||||
|
p.sendMessage(color("&4&lSomething went wrong, please report this to the devs ASAP."));
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
p.sendMessage(color("&cYou have to put in a correct amount!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newChat.get(p.getUniqueId()).equalsIgnoreCase("bankerDeposit")) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
newChat.remove(p.getUniqueId());
|
||||||
|
try {
|
||||||
|
String msg = e.getMessage();
|
||||||
|
int number = Integer.parseInt(msg);
|
||||||
|
if (number < 1) {
|
||||||
|
p.sendMessage(color("&cAmount must be higher than 0!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ResultSet bank = main.prepareStatement("SELECT * FROM bank WHERE UUID = '" + banker.p.getUniqueId().toString() + "';").executeQuery();
|
||||||
|
ResultSet purse = main.prepareStatement("SELECT * FROM purse WHERE UUID = '" + banker.p.getUniqueId().toString() + "';").executeQuery();
|
||||||
|
bank.next();
|
||||||
|
purse.next();
|
||||||
|
int bankBal = bank.getInt("Balance");
|
||||||
|
int purseBal = purse.getInt("Balance");
|
||||||
|
int newBank = bankBal + number;
|
||||||
|
int newPurse = purseBal - number;
|
||||||
|
if (newPurse < 0) {
|
||||||
|
p.sendMessage(color("&cYou do not have enough coins in your purse to do that!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
main.prepareStatement("UPDATE bank SET Balance = '" + newBank + "' WHERE UUID = '" + p.getUniqueId().toString() + "';").executeUpdate();
|
||||||
|
main.prepareStatement("UPDATE purse SET Balance = '" + newPurse + "' WHERE UUID = '" + p.getUniqueId().toString() + "';").executeUpdate();
|
||||||
|
p.closeInventory();
|
||||||
|
p.sendMessage(color("&aDeposited &6" + number + " &ato your bank."));
|
||||||
|
p.sendMessage(color("&aYou now have &6" + newBank + " &ain your bank."));
|
||||||
|
} catch (SQLException x) {
|
||||||
|
x.printStackTrace();
|
||||||
|
p.sendMessage(color("&4&lSomething went wrong, please report this to the devs ASAP."));
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
p.sendMessage(color("&cYou have to put in a correct amount!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (NullPointerException ignored) {}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,18 +1,68 @@
|
|||||||
package sbr.sbr.events;
|
package sbr.sbr.events;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
import org.bukkit.scoreboard.*;
|
||||||
|
import sbr.sbr.commands.hub;
|
||||||
import sbr.sbr.main;
|
import sbr.sbr.main;
|
||||||
import sbr.sbr.utils.chatcolors;
|
import sbr.sbr.utils.chatcolors;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class onPlayerJoin extends chatcolors implements Listener {
|
public class onPlayerJoin extends chatcolors implements Listener {
|
||||||
|
Player p;
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
Player p = e.getPlayer();
|
p = e.getPlayer();
|
||||||
|
randomHub();
|
||||||
|
scoreboard();
|
||||||
|
data();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomHub() {
|
||||||
|
Random r = new Random();
|
||||||
|
String randomHub = hub.hubList[r.nextInt(hub.hubList.length)];
|
||||||
|
Bukkit.createWorld(new WorldCreator(randomHub));
|
||||||
|
World setHub = Bukkit.getWorld(randomHub);
|
||||||
|
p.teleport(new Location(setHub, 0.5, 71, 0.5, 180, 0));
|
||||||
|
main.currentWorld.put(p.getUniqueId(), randomHub);
|
||||||
|
p.sendMessage(color("&aYou are currently in hub &b" + randomHub + "&a!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public void scoreboard() {
|
||||||
|
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
|
||||||
|
scheduler.scheduleSyncRepeatingTask(main.instance, () -> {
|
||||||
|
ScoreboardManager manager = Bukkit.getScoreboardManager();
|
||||||
|
Scoreboard board = manager.getNewScoreboard();
|
||||||
|
Objective objective = board.registerNewObjective("sb", "dummy");
|
||||||
|
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
objective.setDisplayName(color("&e&lSkyblock"));
|
||||||
|
main.balance(p);
|
||||||
|
int bank = main.bankBal;
|
||||||
|
int purse = main.purseBal;
|
||||||
|
Score L1 = objective.getScore(color("&7" + main.currentWorld.get(p.getUniqueId())));
|
||||||
|
L1.setScore(15);
|
||||||
|
Score L2 = objective.getScore(color("&r "));
|
||||||
|
L2.setScore(14);
|
||||||
|
Score L3 = objective.getScore(color("&bBank: &6" + bank));
|
||||||
|
L3.setScore(13);
|
||||||
|
Score L4 = objective.getScore(color("&bPurse: &6" + purse));
|
||||||
|
L4.setScore(12);
|
||||||
|
p.setScoreboard(board);
|
||||||
|
}, 0L, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void data() {
|
||||||
if (!p.hasPlayedBefore()) {
|
if (!p.hasPlayedBefore()) {
|
||||||
try {
|
try {
|
||||||
main.prepareStatement("INSERT INTO bank(UUID, Balance) VALUES('" + p.getUniqueId().toString() + "', 0);").executeUpdate();
|
main.prepareStatement("INSERT INTO bank(UUID, Balance) VALUES('" + p.getUniqueId().toString() + "', 0);").executeUpdate();
|
||||||
|
@ -69,8 +69,8 @@ public class bankerWithdraw extends chatcolors {
|
|||||||
withdrawCustomMeta = withdrawCustom.getItemMeta();
|
withdrawCustomMeta = withdrawCustom.getItemMeta();
|
||||||
withdrawCustomMeta.setDisplayName(color("&bWithdraw a custom amount of coins."));
|
withdrawCustomMeta.setDisplayName(color("&bWithdraw a custom amount of coins."));
|
||||||
withdrawCustomLore.add(color("&7Total bank balance: &6" + totalBal));
|
withdrawCustomLore.add(color("&7Total bank balance: &6" + totalBal));
|
||||||
withdrawAllMeta.setLore(withdrawCustomLore);
|
withdrawCustomMeta.setLore(withdrawCustomLore);
|
||||||
withdrawAll.setItemMeta(withdrawAllMeta);
|
withdrawCustom.setItemMeta(withdrawCustomMeta);
|
||||||
|
|
||||||
// Close button
|
// Close button
|
||||||
close = new ItemStack(Material.BARRIER);
|
close = new ItemStack(Material.BARRIER);
|
||||||
|
7
src/main/java/sbr/sbr/guis/hubMenu.java
Normal file
7
src/main/java/sbr/sbr/guis/hubMenu.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package sbr.sbr.guis;
|
||||||
|
|
||||||
|
import sbr.sbr.utils.chatcolors;
|
||||||
|
|
||||||
|
public class hubMenu extends chatcolors {
|
||||||
|
|
||||||
|
}
|
@ -1,32 +1,41 @@
|
|||||||
package sbr.sbr;
|
package sbr.sbr;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import sbr.sbr.commands.balance;
|
import sbr.sbr.commands.balance;
|
||||||
import sbr.sbr.commands.banker;
|
import sbr.sbr.commands.banker;
|
||||||
|
import sbr.sbr.commands.hub;
|
||||||
import sbr.sbr.commands.npc;
|
import sbr.sbr.commands.npc;
|
||||||
import sbr.sbr.events.InvClick;
|
import sbr.sbr.events.InvClick;
|
||||||
import sbr.sbr.events.onPlayerJoin;
|
import sbr.sbr.events.onPlayerJoin;
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
import java.sql.*;
|
||||||
import java.sql.PreparedStatement;
|
import java.util.HashMap;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public final class main extends JavaPlugin {
|
public final class main extends JavaPlugin {
|
||||||
|
public static main instance;
|
||||||
private static Connection connection;
|
private static Connection connection;
|
||||||
private static String host, database, username, password;
|
private static String host, database, username, password;
|
||||||
private static int port;
|
private static int port;
|
||||||
|
public static final HashMap<UUID, String> currentWorld = new HashMap<>();
|
||||||
|
public static int bankBal;
|
||||||
|
public static int purseBal;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
instance = this;
|
||||||
PluginManager plm = Bukkit.getPluginManager();
|
PluginManager plm = Bukkit.getPluginManager();
|
||||||
host = "sql11.freemysqlhosting.net";
|
host = "localhost";
|
||||||
port = 3306;
|
port = 3306;
|
||||||
database = "sql11395031";
|
database = "sbr";
|
||||||
username = "sql11395031";
|
username = "admin";
|
||||||
password = "6VF5N7cZiG";
|
password = "fivevl";
|
||||||
try {
|
try {
|
||||||
openConnection();
|
openConnection();
|
||||||
System.out.println("MySQL Database Connected.");
|
System.out.println("MySQL Database Connected.");
|
||||||
@ -38,8 +47,9 @@ public final class main extends JavaPlugin {
|
|||||||
Objects.requireNonNull(getCommand("balance")).setExecutor(new balance());
|
Objects.requireNonNull(getCommand("balance")).setExecutor(new balance());
|
||||||
Objects.requireNonNull(getCommand("npc")).setExecutor(new npc());
|
Objects.requireNonNull(getCommand("npc")).setExecutor(new npc());
|
||||||
Objects.requireNonNull(getCommand("banker")).setExecutor(new banker());
|
Objects.requireNonNull(getCommand("banker")).setExecutor(new banker());
|
||||||
|
Objects.requireNonNull(getCommand("hub")).setExecutor(new hub());
|
||||||
|
loadWorlds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
try {
|
try {
|
||||||
@ -48,12 +58,11 @@ public final class main extends JavaPlugin {
|
|||||||
x.printStackTrace();
|
x.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openConnection() throws SQLException {
|
public static void openConnection() throws SQLException {
|
||||||
if (connection != null && !connection.isClosed()) {
|
if (connection != null && !connection.isClosed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
|
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true&useSSL=false", username, password);
|
||||||
}
|
}
|
||||||
public static PreparedStatement prepareStatement(String query) {
|
public static PreparedStatement prepareStatement(String query) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
@ -64,4 +73,22 @@ public final class main extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
public void loadWorlds() {
|
||||||
|
for (String world:hub.hubList) {
|
||||||
|
Bukkit.createWorld(new WorldCreator(world));
|
||||||
|
System.out.println("Loaded world " + world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void balance(Player player) {
|
||||||
|
try {
|
||||||
|
ResultSet bank = main.prepareStatement("SELECT * FROM bank WHERE UUID = '" + player.getUniqueId() + "';").executeQuery();
|
||||||
|
ResultSet purse = main.prepareStatement("SELECT * FROM purse WHERE UUID = '" + player.getUniqueId() + "';").executeQuery();
|
||||||
|
bank.next();
|
||||||
|
purse.next();
|
||||||
|
bankBal = bank.getInt("Balance");
|
||||||
|
purseBal = purse.getInt("Balance");
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -11,3 +11,5 @@ commands:
|
|||||||
description: 'none'
|
description: 'none'
|
||||||
banker:
|
banker:
|
||||||
description: 'none'
|
description: 'none'
|
||||||
|
hub:
|
||||||
|
description: 'none'
|
Loading…
x
Reference in New Issue
Block a user