Farm 이벤트 헨들러 구현

Group_System
poopki 2 years ago
parent 7ae1f2c1e6
commit 6037d17087
  1. 66
      FarmEventHandler.java
  2. 2
      Group.java
  3. 26
      GroupArray.java

@ -11,7 +11,7 @@ public class FarmEventHandler implements CommandExecutor {
GroupArray m_GroupArray;
UserInfoArray m_UserInfoArray;
UUID ZERO_UUID = new UUID(0,0);
public FarmEventHandler(GroupArray GA, UserInfoArray UIA){
m_GroupArray = GA;
m_UserInfoArray = UIA;
@ -24,21 +24,46 @@ public class FarmEventHandler implements CommandExecutor {
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);
if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm").equals(ZERO_UUID)){
if(m_GroupArray.CreateGroup(tempUUID, args[1], p.getUniqueId())){
m_UserInfoArray.setUserGroupUUID("Farm",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);
}
}
else{
p.sendMessage("이미 존재하는 농장 이름");
}
}
p.sendMessage("농장 목록:");
for (String Name: m_GroupArray.GetGroupNameList()){
p.sendMessage(Name);
else{
p.sendMessage("이미 농장을 소유중"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm"));
}
break;
}
case "가입":{
p.sendMessage("가입 테스트");
p.sendMessage("플레이어 UUID:"+p.getUniqueId()+" 농장 UUID:"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm"));
p.sendMessage("ZERO UUID:"+ZERO_UUID);
if(!m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm").equals(ZERO_UUID)){
p.sendMessage("이미 가입한 농장이 존재");
}
else{
p.sendMessage("가입 완료");
m_GroupArray.SignUpGroup("Farm",m_GroupArray.m_GroupNameList.get(args[1]),p.getUniqueId());
p.sendMessage("농장 멤버 목록: ");
for (String Name: m_GroupArray.GetGroupMembersName(m_GroupArray.m_GroupNameList.get(args[1]))){
p.sendMessage(Name);
}
p.sendMessage("농장 목록:");
for (String Name: m_GroupArray.GetGroupNameList()){
p.sendMessage(Name);
}
}
break;
}
case "초대":{
@ -49,10 +74,29 @@ public class FarmEventHandler implements CommandExecutor {
p.sendMessage("강퇴 테스트");
break;
}
case "탈퇴": {
if(!m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm").equals(ZERO_UUID)){
m_GroupArray.ExpulsionGroupPlayer("Farm",m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Farm"),p.getUniqueId());
}
else{
p.sendMessage("가입한 농장이 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm"));
}
break;
}
case "이름":{
p.sendMessage("현재 파티 이름"+m_GroupArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Party")));
break;
}
case "정보": {
for (String Name: m_GroupArray.GetGroupNameList()){
p.sendMessage("농장 이름:");
p.sendMessage(Name);
p.sendMessage("인원 목록");
for (String Name2: m_GroupArray.GetGroupMembersName(m_GroupArray.m_GroupNameList.get(Name))) {
p.sendMessage(Name2);
}
}
}
}
}
return true;

@ -27,7 +27,7 @@ public class Group {
public List<UUID> getGroupMembers(){ return m_MemberList;}
public String getGroupName(){ return m_Name; }
public int isEmpty(){return m_MemberList.size();}
public boolean isOwner(UUID uuid){
if(m_MemberList.get(0)==uuid){
return true;

@ -5,12 +5,12 @@ import org.bukkit.Bukkit;
import java.util.*;
public class GroupArray {
private static Map<UUID, Group> m_GroupArray = new HashMap<UUID, Group>();
public static Map<UUID, Group> m_GroupArray = new HashMap<UUID, Group>();
private static Map<String, UUID> m_GroupNameList = new HashMap<String, UUID>();
public static Map<String, UUID> m_GroupNameList = new HashMap<String, UUID>();
UserInfoArray m_UserInfoArray;
UUID ZERO_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
public GroupArray(UserInfoArray m_UIA){
m_UserInfoArray = m_UIA;
}
@ -23,7 +23,18 @@ public class GroupArray {
return true;
}
}
public boolean CheckGroup(String GroupType, String Name){
return m_GroupArray.containsKey(m_GroupNameList.get(Name));
}
public static <K, V> K getKey(Map<K, V> map, V value) {
for (K key : map.keySet()) {
if (value.equals(map.get(key))) {
return key;
}
}
return null;
}
public boolean DeleteGroup(UUID GroupUUID, String GroupType){
if(m_GroupArray.containsKey(GroupUUID)){
for(UUID key: GetGroupMembersUUID(GroupUUID)){
@ -55,10 +66,15 @@ public class GroupArray {
}
}
public boolean ExpulsionGroupPlayer(UUID GroupUUID, UUID PlayerUUID){
if(GetGroupMembersName(GroupUUID).contains(PlayerUUID)) {
public boolean ExpulsionGroupPlayer(String GroupType, UUID GroupUUID, UUID PlayerUUID){
if(m_GroupArray.get(GroupUUID).isMember(PlayerUUID)) {
Group m_Group = m_GroupArray.get(GroupUUID);
m_Group.Expulsion(PlayerUUID);
m_UserInfoArray.setUserGroupUUID(GroupType,PlayerUUID,ZERO_UUID);
if(m_Group.isEmpty()==0){
m_GroupArray.remove(GroupUUID);
m_GroupNameList.remove(getKey(m_GroupNameList,GroupUUID));
}
return true;
} else{
return false; // Wrong Player Name. FIXME{Need Checking function for a validate user name's }

Loading…
Cancel
Save