From e49592666531ef09b64ee52d1768504b35adcec3 Mon Sep 17 00:00:00 2001 From: poopki Date: Mon, 23 Jan 2023 00:57:38 +0900 Subject: [PATCH] =?UTF-8?q?gui=20=EB=A6=AC=EC=86=8C=EC=8A=A4=ED=8C=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GUI/AccountGUI.java | 108 +++++++++++++++++++++++++++++++++++++++ GUI/AccountGUIEvent.java | 50 ++++++++++++++++++ GUI/Digit.java | 4 ++ User_DB.java | 1 + 4 files changed, 163 insertions(+) create mode 100644 GUI/AccountGUI.java create mode 100644 GUI/AccountGUIEvent.java create mode 100644 GUI/Digit.java diff --git a/GUI/AccountGUI.java b/GUI/AccountGUI.java new file mode 100644 index 0000000..8ba9110 --- /dev/null +++ b/GUI/AccountGUI.java @@ -0,0 +1,108 @@ +package org.poopki.duckdns.user_db.GUI; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.Inventory; +import org.poopki.duckdns.user_db.Array.AccountArray; +import org.poopki.duckdns.user_db.Array.FarmArray; +import org.poopki.duckdns.user_db.Array.NationArray; +import org.poopki.duckdns.user_db.Array.SquadArray; +import org.poopki.duckdns.user_db.UserInfoArray; + +import java.util.UUID; +import org.apache.commons.lang.StringEscapeUtils; + +public class AccountGUI implements Listener{ + private final Inventory inv; + UUID m_uuid; + ItemManager m_ItemManager = new ItemManager(); + AccountArray m_AA; + UserInfoArray m_UIA; + FarmArray m_FA; + NationArray m_NA; + SquadArray m_SA; + public AccountGUI(AccountArray AA, UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA, UUID uuid, InventoryClickEvent e) { + m_uuid=uuid; + this.inv = Bukkit.createInventory(null,54,ChatColor.WHITE+StringEscapeUtils.unescapeJava("\uE00A")+StringEscapeUtils.unescapeJava("\uE00B")); + m_AA = AA; + m_UIA = UIA; + m_FA = FA; + m_NA = NA; + m_SA = SA; + initItemSetting(); + } + + private void initItemSetting() { +/* + inv.setItem(0,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "User")); + inv.setItem(1,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "Nation")); + inv.setItem(2,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "Farm")); + + inv.setItem(9, m_ItemManager.btn1); + inv.setItem(18, m_ItemManager.btn2); + inv.setItem(10, m_ItemManager.btn3); + inv.setItem(19, m_ItemManager.btn4); + inv.setItem(11, m_ItemManager.btn5); + inv.setItem(20, m_ItemManager.btn6); + */ + } + + public void open(Player player){ + player.openInventory(inv); + } + + public void inven(InventoryClickEvent e){ + Player p = (Player) e.getWhoClicked(); + Inventory m_inv = e.getClickedInventory(); + + if (e.getInventory() != m_inv) return; + + switch(e.getCurrentItem().getType()){ + case CANDLE: + e.setCancelled(true); + p.sendMessage("10000원 증가"); + m_AA.setAccountInfo(p.getUniqueId(), (long)m_AA.getAccountInfo(p.getUniqueId())+10000); + initItemSetting(); + p.openInventory(inv); + break; + case BEEF: + e.setCancelled(true); + p.sendMessage("10000원 감소"); + m_AA.setAccountInfo(p.getUniqueId(), (long)m_AA.getAccountInfo(p.getUniqueId())-10000); + initItemSetting(); + p.openInventory(inv); + break; + case TORCH: + e.setCancelled(true); + p.sendMessage("국가 10000원 증가"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Nation"))); + m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"))+10000); + initItemSetting(); + p.openInventory(inv); + break; + case GRASS: + e.setCancelled(true); + p.sendMessage("국가 10000원 감소"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Nation"))); + m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"))-10000); + initItemSetting(); + p.openInventory(inv); + break; + case DIAMOND: + e.setCancelled(true); + p.sendMessage("농장 10000원 증가"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Farm"))); + m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"))+10000); + initItemSetting(); + p.openInventory(inv); + break; + case IRON_INGOT: + e.setCancelled(true); + p.sendMessage("농장 10000원 감소"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Farm"))); + m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"))-10000); + initItemSetting(); + p.openInventory(inv); + break; + } + } +} diff --git a/GUI/AccountGUIEvent.java b/GUI/AccountGUIEvent.java new file mode 100644 index 0000000..d063aef --- /dev/null +++ b/GUI/AccountGUIEvent.java @@ -0,0 +1,50 @@ +package org.poopki.duckdns.user_db.GUI; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.poopki.duckdns.user_db.Array.AccountArray; +import org.poopki.duckdns.user_db.Array.FarmArray; +import org.poopki.duckdns.user_db.Array.NationArray; +import org.poopki.duckdns.user_db.Array.SquadArray; +import org.poopki.duckdns.user_db.UserInfoArray; + +public class AccountGUIEvent implements Listener,CommandExecutor { + AccountArray m_AccountArray; + UserInfoArray m_UserInfoArray; + FarmArray m_FarmArray; + NationArray m_NationArray; + SquadArray m_SquadArray; + public AccountGUIEvent(UserInfoArray m_UIA, FarmArray FA, NationArray NA, SquadArray SA, AccountArray AA){ + m_UserInfoArray = m_UIA; + m_AccountArray = AA; + m_FarmArray = FA; + m_NationArray = NA; + m_SquadArray = SA; + } + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player){ + Player player = (Player) sender; + player.sendMessage("이벤트 발생"); + AccountGUI inv = new AccountGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray,((Player) sender).getUniqueId(), null); + inv.open(player); + } + return false; + } + @EventHandler + public void inven2(InventoryClickEvent e){ + Player player = (Player) e.getWhoClicked();; + player.sendMessage("이벤트 발생"); + AccountGUI inv = new AccountGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); + inv.inven(e); + + } + + + +} diff --git a/GUI/Digit.java b/GUI/Digit.java new file mode 100644 index 0000000..21c77f7 --- /dev/null +++ b/GUI/Digit.java @@ -0,0 +1,4 @@ +package org.poopki.duckdns.user_db.GUI; + +public class Digit { +} diff --git a/User_DB.java b/User_DB.java index ee4858e..713bf32 100644 --- a/User_DB.java +++ b/User_DB.java @@ -38,6 +38,7 @@ public final class User_DB extends JavaPlugin implements Listener { getCommand("국가").setExecutor(new NationEventHandler(m_InfoArrayInstance, m_NationArrayInstance, m_AccountArrayInstance)); getCommand("분대").setExecutor(new SquadEventHandler(m_InfoArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance)); getCommand("opitem").setExecutor(new OpenInv(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance)); + getCommand("은행").setExecutor(new AccountGUIEvent(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance)); getCommand("초대").setExecutor(new InviteMaster(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance)); getServer().getPluginManager().registerEvents(new UserJoin(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance, m_ScoreboardEventHandler),