From 7ae1f2c1e639dc64fa496843db3f7c05d19a7146 Mon Sep 17 00:00:00 2001 From: poopki Date: Sat, 7 Jan 2023 23:38:46 +0900 Subject: [PATCH] =?UTF-8?q?Group=20Event=20Handler=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DB/DBUpdate.java | 6 ++--- FarmEventHandler.java | 60 +++++++++++++++++++++++++++++++++++++++++ NationEventHandler.java | 60 +++++++++++++++++++++++++++++++++++++++++ SquadEventHandler.java | 60 +++++++++++++++++++++++++++++++++++++++++ User_DB.java | 9 ++++--- 5 files changed, 189 insertions(+), 6 deletions(-) create mode 100644 FarmEventHandler.java create mode 100644 NationEventHandler.java create mode 100644 SquadEventHandler.java diff --git a/DB/DBUpdate.java b/DB/DBUpdate.java index 195878f..fb37225 100644 --- a/DB/DBUpdate.java +++ b/DB/DBUpdate.java @@ -109,9 +109,9 @@ public class DBUpdate { pstmt = conn.prepareStatement(sql); pstmt.setString(1, String.valueOf(key.toString())); pstmt.setString(2, String.valueOf(m_InfoArrayInstance.getUserName(key))); - pstmt.setString(3, String.valueOf(11)); - pstmt.setString(4, String.valueOf(23)); - pstmt.setString(5, String.valueOf(56)); + pstmt.setString(3, String.valueOf(m_InfoArrayInstance.getUserGroupUUID(key, "Nation"))); + pstmt.setString(4, String.valueOf(m_InfoArrayInstance.getUserGroupUUID(key, "Squad"))); + pstmt.setString(5, String.valueOf(m_InfoArrayInstance.getUserGroupUUID(key, "Farm"))); pstmt.setString(6, String.valueOf(m_AccountArray.getAccountInfo(key))); int cnt = pstmt.executeUpdate(); if( cnt == 0 ){ diff --git a/FarmEventHandler.java b/FarmEventHandler.java new file mode 100644 index 0000000..db0b928 --- /dev/null +++ b/FarmEventHandler.java @@ -0,0 +1,60 @@ +package org.poopki.duckdns.user_db; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.UUID; + +public class FarmEventHandler implements CommandExecutor { + + GroupArray m_GroupArray; + UserInfoArray m_UserInfoArray; + + public FarmEventHandler(GroupArray GA, UserInfoArray UIA){ + m_GroupArray = GA; + m_UserInfoArray = UIA; + } + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + Player p = (Player) sender; + + if (args.length != 0) { + switch (args[0]) { + case "생성":{ + UUID tempUUID = UUID.randomUUID(); + m_GroupArray.CreateGroup(tempUUID, args[1], p.getUniqueId()); + m_UserInfoArray.setUserGroupUUID("Party",p.getUniqueId(), tempUUID); + p.sendMessage(args[1]+"농장이 생성되었습니다."); + p.sendMessage("농장 멤버 목록: "); + for (String Name: m_GroupArray.GetGroupMembersName(tempUUID)){ + p.sendMessage(Name); + } + p.sendMessage("농장 목록:"); + for (String Name: m_GroupArray.GetGroupNameList()){ + p.sendMessage(Name); + } + break; + } + case "가입":{ + p.sendMessage("가입 테스트"); + break; + } + case "초대":{ + p.sendMessage("초대 테스트"); + break; + } + case "강퇴":{ + p.sendMessage("강퇴 테스트"); + break; + } + case "이름":{ + p.sendMessage("현재 파티 이름"+m_GroupArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Party"))); + break; + } + } + } + return true; + } +} diff --git a/NationEventHandler.java b/NationEventHandler.java new file mode 100644 index 0000000..5308139 --- /dev/null +++ b/NationEventHandler.java @@ -0,0 +1,60 @@ +package org.poopki.duckdns.user_db; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.UUID; + +public class NationEventHandler implements CommandExecutor { + + GroupArray m_GroupArray; + UserInfoArray m_UserInfoArray; + + public NationEventHandler(GroupArray GA, UserInfoArray UIA){ + m_GroupArray = GA; + m_UserInfoArray = UIA; + } + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + Player p = (Player) sender; + + if (args.length != 0) { + switch (args[0]) { + case "생성":{ + UUID tempUUID = UUID.randomUUID(); + m_GroupArray.CreateGroup(tempUUID, args[1], p.getUniqueId()); + m_UserInfoArray.setUserGroupUUID("Party",p.getUniqueId(), tempUUID); + p.sendMessage(args[1]+"파티가 생성되었습니다."); + p.sendMessage("멤버 목록: "); + for (String Name: m_GroupArray.GetGroupMembersName(tempUUID)){ + p.sendMessage(Name); + } + p.sendMessage("파티 목록:"); + for (String Name: m_GroupArray.GetGroupNameList()){ + p.sendMessage(Name); + } + break; + } + case "가입":{ + p.sendMessage("가입 테스트"); + break; + } + case "초대":{ + p.sendMessage("초대 테스트"); + break; + } + case "강퇴":{ + p.sendMessage("강퇴 테스트"); + break; + } + case "이름":{ + p.sendMessage("현재 파티 이름"+m_GroupArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Party"))); + break; + } + } + } + return true; + } +} diff --git a/SquadEventHandler.java b/SquadEventHandler.java new file mode 100644 index 0000000..c2d4e04 --- /dev/null +++ b/SquadEventHandler.java @@ -0,0 +1,60 @@ +package org.poopki.duckdns.user_db; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.UUID; + +public class SquadEventHandler implements CommandExecutor { + + GroupArray m_GroupArray; + UserInfoArray m_UserInfoArray; + + public SquadEventHandler(GroupArray GA, UserInfoArray UIA){ + m_GroupArray = GA; + m_UserInfoArray = UIA; + } + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + Player p = (Player) sender; + + if (args.length != 0) { + switch (args[0]) { + case "생성":{ + UUID tempUUID = UUID.randomUUID(); + m_GroupArray.CreateGroup(tempUUID, args[1], p.getUniqueId()); + m_UserInfoArray.setUserGroupUUID("Party",p.getUniqueId(), tempUUID); + p.sendMessage(args[1]+"파티가 생성되었습니다."); + p.sendMessage("멤버 목록: "); + for (String Name: m_GroupArray.GetGroupMembersName(tempUUID)){ + p.sendMessage(Name); + } + p.sendMessage("파티 목록:"); + for (String Name: m_GroupArray.GetGroupNameList()){ + p.sendMessage(Name); + } + break; + } + case "가입":{ + p.sendMessage("가입 테스트"); + break; + } + case "초대":{ + p.sendMessage("초대 테스트"); + break; + } + case "강퇴":{ + p.sendMessage("강퇴 테스트"); + break; + } + case "이름":{ + p.sendMessage("현재 파티 이름"+m_GroupArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Party"))); + break; + } + } + } + return true; + } +} diff --git a/User_DB.java b/User_DB.java index 871eedc..d4a373b 100644 --- a/User_DB.java +++ b/User_DB.java @@ -11,8 +11,9 @@ public final class User_DB extends JavaPlugin implements Listener { AccountArray m_AccountArrayInstance = new AccountArray(); UserInfoArray m_InfoArrayInstance = new UserInfoArray(); // UserInfo 저장하는 Array instance 생성 - GroupArray m_GroupArrayInstance = new GroupArray(m_InfoArrayInstance); - + GroupArray m_FarmArrayInstance = new GroupArray(m_InfoArrayInstance); + GroupArray m_NationArrayInstance = new GroupArray(m_InfoArrayInstance); + GroupArray m_SquadArrayInstance = new GroupArray(m_InfoArrayInstance); DBUpdate Database_backup = new DBUpdate(m_InfoArrayInstance, m_AccountArrayInstance); @Override public void onEnable() { @@ -24,7 +25,9 @@ public final class User_DB extends JavaPlugin implements Listener { throw new RuntimeException(e); } getCommand("계좌").setExecutor(new AccountEventHandler(m_AccountArrayInstance)); - getCommand("그룹").setExecutor(new GroupEventHandler(m_GroupArrayInstance, m_InfoArrayInstance)); + getCommand("농장").setExecutor(new FarmEventHandler(m_FarmArrayInstance, m_InfoArrayInstance)); + getCommand("국가").setExecutor(new NationEventHandler(m_FarmArrayInstance, m_InfoArrayInstance)); + getCommand("분대").setExecutor(new SquadEventHandler(m_FarmArrayInstance, m_InfoArrayInstance)); getServer().getPluginManager().registerEvents(new UserJoin(m_InfoArrayInstance, m_AccountArrayInstance),this); }