mirror of
https://github.com/5vl/SkyblockRemake.git
synced 2025-05-24 06:47:01 +00:00
more shit
This commit is contained in:
parent
af949eb8e5
commit
56159f1f98
@ -4,6 +4,7 @@ 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.sql.ResultSet;
|
||||
@ -11,7 +12,7 @@ import java.sql.SQLException;
|
||||
|
||||
public class balance extends chatcolors implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
Player p = (Player) sender;
|
||||
try {
|
||||
ResultSet rs = main.prepareStatement("SELECT * FROM purse WHERE UUID = '" + p.getUniqueId().toString() + "';").executeQuery();
|
||||
|
@ -6,52 +6,128 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import sbr.sbr.commands.banker;
|
||||
import sbr.sbr.guis.banker.bankerDeposit;
|
||||
import sbr.sbr.guis.banker.bankerWithdraw;
|
||||
import sbr.sbr.main;
|
||||
import sbr.sbr.utils.chatcolors;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class InvClick extends chatcolors implements Listener {
|
||||
public static HashMap<UUID, String> currentGui = new HashMap<>();
|
||||
public static final HashMap<UUID, String> currentGui = new HashMap<>();
|
||||
@EventHandler
|
||||
public void InventoryClick(InventoryClickEvent e) {
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
if (currentGui.get(p.getUniqueId()) != null) {
|
||||
if (currentGui.get(p.getUniqueId()).equalsIgnoreCase("bankerMain")) {
|
||||
if (e.getSlot() == 11) {
|
||||
if (e.getRawSlot() == 11) {
|
||||
p.closeInventory();
|
||||
p.openInventory(bankerDeposit.getGui());
|
||||
currentGui.put(p.getUniqueId(), "bankerDeposit");
|
||||
}
|
||||
if (e.getSlot() == 13) {
|
||||
currentGui.remove(p.getUniqueId());
|
||||
if (e.getRawSlot() == 13) {
|
||||
p.closeInventory();
|
||||
p.openInventory(bankerWithdraw.getGui());
|
||||
currentGui.put(p.getUniqueId(), "bankerWithdraw");
|
||||
}
|
||||
if (e.getRawSlot() == 32) {
|
||||
p.closeInventory();
|
||||
}
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (currentGui.get(p.getUniqueId()).equalsIgnoreCase("bankerWithdraw")) {
|
||||
if (e.getSlot() == 13) {
|
||||
int bankBal;
|
||||
int purseBal;
|
||||
if (e.getRawSlot() == 11) {
|
||||
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();
|
||||
bankBal = bank.getInt("Balance");
|
||||
purseBal = purse.getInt("Balance");
|
||||
int bankBal = bank.getInt("Balance");
|
||||
int purseBal = purse.getInt("Balance");
|
||||
int bankHalf = bankBal / 2;
|
||||
int newPurse = purseBal + bankHalf;
|
||||
main.prepareStatement("UPDATE bank SET Balance = '" + bankHalf + "' 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" + bankHalf + " &afrom your bank."));
|
||||
} catch (SQLException x) {
|
||||
x.printStackTrace();
|
||||
p.sendMessage(color("&4&lSomething went wrong, please report this to the devs ASAP."));
|
||||
}
|
||||
}
|
||||
if (e.getRawSlot() == 13) {
|
||||
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 newPurse = purseBal + bankBal;
|
||||
main.prepareStatement("UPDATE bank SET Balance = '0' 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" + bankBal + " &afrom your bank."));
|
||||
p.sendMessage(color("&aYou now have &60 &ain your bank."));
|
||||
} catch (SQLException x) {
|
||||
x.printStackTrace();
|
||||
p.sendMessage(color("&4&lSomething went wrong, please report this to the devs ASAP."));
|
||||
}
|
||||
}
|
||||
if (e.getRawSlot() == 32) {
|
||||
p.closeInventory();
|
||||
}
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (currentGui.get(p.getUniqueId()).equalsIgnoreCase("bankerDeposit")) {
|
||||
if (e.getRawSlot() == 11) {
|
||||
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 purseHalf = purseBal / 2;
|
||||
int newBank = bankBal + purseHalf;
|
||||
main.prepareStatement("UPDATE bank SET Balance = '" + newBank + "' WHERE UUID = '" + p.getUniqueId().toString() + "';").executeUpdate();
|
||||
main.prepareStatement("UPDATE purse SET Balance = '" + purseHalf + "' WHERE UUID = '" + p.getUniqueId().toString() + "';").executeUpdate();
|
||||
p.closeInventory();
|
||||
p.sendMessage(color("&aDeposited &6" + purseHalf + " &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."));
|
||||
}
|
||||
}
|
||||
if (e.getRawSlot() == 13) {
|
||||
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 + purseBal;
|
||||
main.prepareStatement("UPDATE bank SET Balance = '" + newBank + "' WHERE UUID = '" + p.getUniqueId().toString() + "';").executeUpdate();
|
||||
main.prepareStatement("UPDATE purse SET Balance = '0' WHERE UUID = '" + p.getUniqueId().toString() + "';").executeUpdate();
|
||||
p.closeInventory();
|
||||
p.sendMessage(color("&aDeposited &6" + purseBal + " &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."));
|
||||
}
|
||||
}
|
||||
if (e.getRawSlot() == 32) {
|
||||
p.closeInventory();
|
||||
}
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
|
@ -1,4 +1,129 @@
|
||||
package sbr.sbr.guis.banker;
|
||||
|
||||
public class bankerDeposit {
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import sbr.sbr.commands.banker;
|
||||
import sbr.sbr.main;
|
||||
import sbr.sbr.utils.chatcolors;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class bankerDeposit extends chatcolors {
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Inventory getGui() {
|
||||
int totalBal = 0;
|
||||
try {
|
||||
ResultSet rs = main.prepareStatement("SELECT * FROM purse WHERE UUID = '" + banker.p.getUniqueId().toString() + "';").executeQuery();
|
||||
rs.next();
|
||||
totalBal = rs.getInt("Balance");
|
||||
} catch (SQLException x) {
|
||||
x.printStackTrace();
|
||||
}
|
||||
Inventory gui = Bukkit.createInventory(null, 36, ChatColor.AQUA + "Deposit");
|
||||
|
||||
// Items
|
||||
ItemStack depositHalf;
|
||||
ItemMeta depositHalfMeta;
|
||||
List<String> depositHalfLore = new ArrayList<>();
|
||||
|
||||
ItemStack depositAll;
|
||||
ItemMeta depositAllMeta;
|
||||
List<String> depositAllLore = new ArrayList<>();
|
||||
|
||||
ItemStack depositCustom;
|
||||
ItemMeta depositCustomMeta;
|
||||
List<String> depositCustomLore = new ArrayList<>();
|
||||
|
||||
ItemStack close;
|
||||
ItemMeta closeMeta;
|
||||
List<String> closeLore = new ArrayList<>();
|
||||
|
||||
ItemStack glass;
|
||||
ItemMeta glassMeta;
|
||||
|
||||
// Deposit half
|
||||
depositHalf = new ItemStack(Material.CHEST);
|
||||
depositHalfMeta = depositHalf.getItemMeta();
|
||||
int half = totalBal / 2;
|
||||
depositHalfMeta.setDisplayName(color("&bDeposit &6" + half + " &bcoins."));
|
||||
depositHalfLore.add(color("&7Total bank balance: &6" + totalBal));
|
||||
depositHalfMeta.setLore(depositHalfLore);
|
||||
depositHalf.setItemMeta(depositHalfMeta);
|
||||
|
||||
// Deposit all
|
||||
depositAll = new ItemStack(Material.CHEST);
|
||||
depositAllMeta = depositAll.getItemMeta();
|
||||
depositAllMeta.setDisplayName(color("&bDeposit all coins (&6" + totalBal + "&b)"));
|
||||
depositAllLore.add(color("&7Total bank balance: &6" + totalBal));
|
||||
depositAllMeta.setLore(depositAllLore);
|
||||
depositAll.setItemMeta(depositAllMeta);
|
||||
|
||||
// Deposit custom
|
||||
depositCustom = new ItemStack(Material.OAK_SIGN);
|
||||
depositCustomMeta = depositCustom.getItemMeta();
|
||||
depositCustomMeta.setDisplayName(color("&bDeposit a custom amount of coins."));
|
||||
depositCustomLore.add(color("&7Total bank balance: &6" + totalBal));
|
||||
depositCustomMeta.setLore(depositCustomLore);
|
||||
depositCustom.setItemMeta(depositCustomMeta);
|
||||
|
||||
// Close button
|
||||
close = new ItemStack(Material.BARRIER);
|
||||
closeMeta = close.getItemMeta();
|
||||
closeMeta.setDisplayName(color("&cClose"));
|
||||
closeLore.add(color("&7Closes this GUI."));
|
||||
closeMeta.setLore(closeLore);
|
||||
close.setItemMeta(closeMeta);
|
||||
|
||||
// Glass panes
|
||||
glass = new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE);
|
||||
glassMeta = glass.getItemMeta();
|
||||
glassMeta.setDisplayName(" ");
|
||||
glass.setItemMeta(glassMeta);
|
||||
|
||||
// Set items
|
||||
gui.setItem(0, glass);
|
||||
gui.setItem(1, glass);
|
||||
gui.setItem(2, glass);
|
||||
gui.setItem(3, glass);
|
||||
gui.setItem(4, glass);
|
||||
gui.setItem(5, glass);
|
||||
gui.setItem(6, glass);
|
||||
gui.setItem(7, glass);
|
||||
gui.setItem(8, glass);
|
||||
gui.setItem(9, glass);
|
||||
gui.setItem(10, glass);
|
||||
gui.setItem(11, depositHalf);
|
||||
gui.setItem(12, glass);
|
||||
gui.setItem(13, depositAll);
|
||||
gui.setItem(14, glass);
|
||||
gui.setItem(15, depositCustom);
|
||||
gui.setItem(16, glass);
|
||||
gui.setItem(17, glass);
|
||||
gui.setItem(18, glass);
|
||||
gui.setItem(19, glass);
|
||||
gui.setItem(20, glass);
|
||||
gui.setItem(21, glass);
|
||||
gui.setItem(22, glass);
|
||||
gui.setItem(23, glass);
|
||||
gui.setItem(24, glass);
|
||||
gui.setItem(25, glass);
|
||||
gui.setItem(26, glass);
|
||||
gui.setItem(27, glass);
|
||||
gui.setItem(28, glass);
|
||||
gui.setItem(29, glass);
|
||||
gui.setItem(30, glass);
|
||||
gui.setItem(31, close);
|
||||
gui.setItem(32, glass);
|
||||
gui.setItem(33, glass);
|
||||
gui.setItem(34, glass);
|
||||
gui.setItem(35, glass);
|
||||
|
||||
return gui;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class bankerMain extends chatcolors {
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Inventory getGui() {
|
||||
int totalBal = 0;
|
||||
try {
|
||||
@ -35,6 +36,10 @@ public class bankerMain extends chatcolors {
|
||||
ItemMeta depositMeta;
|
||||
List<String> depositLore = new ArrayList<>();
|
||||
|
||||
ItemStack close;
|
||||
ItemMeta closeMeta;
|
||||
List<String> closeLore = new ArrayList<>();
|
||||
|
||||
ItemStack glass;
|
||||
ItemMeta glassMeta;
|
||||
|
||||
@ -54,6 +59,14 @@ public class bankerMain extends chatcolors {
|
||||
depositMeta.setLore(depositLore);
|
||||
deposit.setItemMeta(depositMeta);
|
||||
|
||||
// Close button
|
||||
close = new ItemStack(Material.BARRIER);
|
||||
closeMeta = close.getItemMeta();
|
||||
closeMeta.setDisplayName(color("&cClose"));
|
||||
closeLore.add(color("&7Closes this GUI."));
|
||||
closeMeta.setLore(closeLore);
|
||||
close.setItemMeta(closeMeta);
|
||||
|
||||
// Glass panes
|
||||
glass = new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE);
|
||||
glassMeta = glass.getItemMeta();
|
||||
@ -92,7 +105,7 @@ public class bankerMain extends chatcolors {
|
||||
gui.setItem(28, glass);
|
||||
gui.setItem(29, glass);
|
||||
gui.setItem(30, glass);
|
||||
gui.setItem(31, glass);
|
||||
gui.setItem(31, close);
|
||||
gui.setItem(32, glass);
|
||||
gui.setItem(33, glass);
|
||||
gui.setItem(34, glass);
|
||||
|
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class bankerWithdraw extends chatcolors {
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Inventory getGui() {
|
||||
int totalBal = 0;
|
||||
try {
|
||||
@ -27,26 +28,62 @@ public class bankerWithdraw extends chatcolors {
|
||||
Inventory gui = Bukkit.createInventory(null, 36, ChatColor.AQUA + "Withdraw");
|
||||
|
||||
// Items
|
||||
ItemStack withdraw;
|
||||
ItemMeta withdrawMeta;
|
||||
List<String> withdrawLore = new ArrayList<>();
|
||||
ItemStack withdrawHalf;
|
||||
ItemMeta withdrawHalfMeta;
|
||||
List<String> withdrawHalfLore = new ArrayList<>();
|
||||
|
||||
ItemStack withdrawAll;
|
||||
ItemMeta withdrawAllMeta;
|
||||
List<String> withdrawAllLore = new ArrayList<>();
|
||||
|
||||
ItemStack withdrawCustom;
|
||||
ItemMeta withdrawCustomMeta;
|
||||
List<String> withdrawCustomLore = new ArrayList<>();
|
||||
|
||||
ItemStack close;
|
||||
ItemMeta closeMeta;
|
||||
List<String> closeLore = new ArrayList<>();
|
||||
|
||||
ItemStack glass;
|
||||
ItemMeta glassMeta;
|
||||
|
||||
// Withdraw button
|
||||
withdraw = new ItemStack(Material.DISPENSER);
|
||||
withdrawMeta = withdraw.getItemMeta();
|
||||
// Withdraw half
|
||||
withdrawHalf = new ItemStack(Material.DISPENSER);
|
||||
withdrawHalfMeta = withdrawHalf.getItemMeta();
|
||||
int half = totalBal / 2;
|
||||
withdrawMeta.setDisplayName(color("&bWithdraw &6" + half + "&bcoins."));
|
||||
withdrawLore.add(color("&7Total money: &6" + totalBal));
|
||||
withdrawMeta.setLore(withdrawLore);
|
||||
withdraw.setItemMeta(withdrawMeta);
|
||||
withdrawHalfMeta.setDisplayName(color("&bWithdraw &6" + half + " &bcoins."));
|
||||
withdrawHalfLore.add(color("&7Total bank balance: &6" + totalBal));
|
||||
withdrawHalfMeta.setLore(withdrawHalfLore);
|
||||
withdrawHalf.setItemMeta(withdrawHalfMeta);
|
||||
|
||||
// Withdraw all
|
||||
withdrawAll = new ItemStack(Material.DROPPER);
|
||||
withdrawAllMeta = withdrawAll.getItemMeta();
|
||||
withdrawAllMeta.setDisplayName(color("&bWithdraw all coins (&6" + totalBal + "&b)"));
|
||||
withdrawAllLore.add(color("&7Total bank balance: &6" + totalBal));
|
||||
withdrawAllMeta.setLore(withdrawAllLore);
|
||||
withdrawAll.setItemMeta(withdrawAllMeta);
|
||||
|
||||
// Withdraw custom
|
||||
withdrawCustom = new ItemStack(Material.OAK_SIGN);
|
||||
withdrawCustomMeta = withdrawCustom.getItemMeta();
|
||||
withdrawCustomMeta.setDisplayName(color("&bWithdraw a custom amount of coins."));
|
||||
withdrawCustomLore.add(color("&7Total bank balance: &6" + totalBal));
|
||||
withdrawAllMeta.setLore(withdrawCustomLore);
|
||||
withdrawAll.setItemMeta(withdrawAllMeta);
|
||||
|
||||
// Close button
|
||||
close = new ItemStack(Material.BARRIER);
|
||||
closeMeta = close.getItemMeta();
|
||||
closeMeta.setDisplayName(color("&cClose"));
|
||||
closeLore.add(color("&7Closes this GUI."));
|
||||
closeMeta.setLore(closeLore);
|
||||
close.setItemMeta(closeMeta);
|
||||
|
||||
// Glass panes
|
||||
glass = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
|
||||
glass = new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE);
|
||||
glassMeta = glass.getItemMeta();
|
||||
glassMeta.setDisplayName("");
|
||||
glassMeta.setDisplayName(" ");
|
||||
glass.setItemMeta(glassMeta);
|
||||
|
||||
// Set items
|
||||
@ -61,11 +98,11 @@ public class bankerWithdraw extends chatcolors {
|
||||
gui.setItem(8, glass);
|
||||
gui.setItem(9, glass);
|
||||
gui.setItem(10, glass);
|
||||
gui.setItem(11, glass);
|
||||
gui.setItem(11, withdrawHalf);
|
||||
gui.setItem(12, glass);
|
||||
gui.setItem(13, withdraw);
|
||||
gui.setItem(13, withdrawAll);
|
||||
gui.setItem(14, glass);
|
||||
gui.setItem(15, glass);
|
||||
gui.setItem(15, withdrawCustom);
|
||||
gui.setItem(16, glass);
|
||||
gui.setItem(17, glass);
|
||||
gui.setItem(18, glass);
|
||||
@ -81,7 +118,7 @@ public class bankerWithdraw extends chatcolors {
|
||||
gui.setItem(28, glass);
|
||||
gui.setItem(29, glass);
|
||||
gui.setItem(30, glass);
|
||||
gui.setItem(31, glass);
|
||||
gui.setItem(31, close);
|
||||
gui.setItem(32, glass);
|
||||
gui.setItem(33, glass);
|
||||
gui.setItem(34, glass);
|
||||
|
@ -1,4 +1,14 @@
|
||||
package sbr.sbr.guis.sbmenu;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class sbmenuMain {
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Inventory getGui() {
|
||||
Inventory gui = Bukkit.createInventory(null, 54, ChatColor.WHITE + "Skyblock Menu");
|
||||
|
||||
return gui;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user