Group Base System

Group_System
poopki 3 years ago
parent fb2661d9f8
commit 71a5aa8e8c
  1. 38
      Group.java
  2. 11
      Party.java
  3. 46
      PartyArray.java
  4. 59
      PartyEventHandler.java
  5. 2
      Status.java
  6. 5
      UserInfo.java
  7. 8
      UserInfoArray.java
  8. 2
      User_DB.java

@ -0,0 +1,38 @@
package org.poopki.duckdns.user_db;
import java.util.List;
import java.util.ArrayList;
import java.util.UUID;
public class Group {
private String m_Name;
private List<UUID> m_MemberList = new ArrayList<>();
public Group(String Name, UUID uuid){
m_MemberList.add(0, uuid);
m_Name = Name;
}
public void SignUp(UUID uuid){
m_MemberList.add(uuid);
}
public void Expulsion(UUID uuid){
m_MemberList.remove(uuid);
}
public boolean isMember(UUID uuid){
return m_MemberList.contains(uuid);
}
public List<UUID> getGroupMembers(){ return m_MemberList;}
public String getGroupName(){ return m_Name; }
public boolean isOwner(UUID uuid){
if(m_MemberList.get(0)==uuid){
return true;
}else{
return false;
}
}
}

@ -0,0 +1,11 @@
package org.poopki.duckdns.user_db;
import java.util.UUID;
public class Party extends Group{
public Party(String Name, UUID uuid) {
super(Name, uuid);
}
}

@ -0,0 +1,46 @@
package org.poopki.duckdns.user_db;
import org.bukkit.Bukkit;
import java.util.*;
public class PartyArray {
private static Map<UUID, Party> m_PartyArray = new HashMap<UUID, Party>();
private static Map<String, UUID> m_PartyNameList = new HashMap<String, UUID>();
public void CreateParty(UUID PartyUUID, String Name, UUID PlayerUUID){
m_PartyArray.put(PartyUUID, new Party(Name, PlayerUUID));
m_PartyNameList.put(Name, PartyUUID);
}
public void SignUpParty(UUID PartyUUID, UUID PlayerUUID){
Party m_Party = m_PartyArray.get(PartyUUID);
m_Party.SignUp(PlayerUUID);
}
public void ExpulsionParty(UUID PartyUUID, UUID PlayerUUID){
Party m_Party = m_PartyArray.get(PartyUUID);
m_Party.Expulsion(PlayerUUID);
}
public List<String> GetPartyMembers(UUID PartyUUID){
List<String> MembersName = new ArrayList<>();
for (UUID key : m_PartyArray.get(PartyUUID).getGroupMembers()){
MembersName.add(Bukkit.getPlayer(key).getDisplayName());
}
return MembersName;
}
public boolean isPartyMember(UUID PartyUUID, UUID PlayerUUID){
Party m_Party = m_PartyArray.get(PartyUUID);
return m_Party.isMember(PlayerUUID);
}
public Set<String> GetPartyNameList(){
return m_PartyNameList.keySet();
}
public String GetPartyName(UUID PartyUUID){
Party m_Party = m_PartyArray.get(PartyUUID);
return m_Party.getGroupName();
}
}

@ -0,0 +1,59 @@
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 PartyEventHandler implements CommandExecutor {
PartyArray m_PartyArray;
UserInfoArray m_UserInfoArray;
public PartyEventHandler(PartyArray PA, UserInfoArray UIA){
m_PartyArray = PA;
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_PartyArray.CreateParty(tempUUID, args[1], p.getUniqueId());
m_UserInfoArray.setUserPartyUUID(p.getUniqueId(), tempUUID);
p.sendMessage(args[1]+"파티가 생성되었습니다.");
p.sendMessage("멤버 목록: ");
for (String Name: m_PartyArray.GetPartyMembers(tempUUID)){
p.sendMessage(Name);
}
p.sendMessage("파티 목록:");
for (String Name: m_PartyArray.GetPartyNameList()){
p.sendMessage(Name);
}
break;
}
/* case "가입":{
break;
}
case "초대":{
break;
}
case "강퇴":{
break;
}
*/ case "이름":{
p.sendMessage("현재 파티 이름"+m_PartyArray.GetPartyName(m_UserInfoArray.getUserPartyUUID(p.getUniqueId())));
break;
}
}
}
return true;
}
}

@ -26,4 +26,6 @@ public class Status {
m_INT = INT;
m_LUK = LUK;
}
public int GetHP(){return m_HP;}
}

@ -14,6 +14,8 @@ public class UserInfo extends Status {
private int m_Squad;
private int m_Farm;
private UUID m_Party;
public UserInfo(UUID uuid, String Name, int Nation, int Squad, int Farm){ //UserInfo 초기화
super(100,100,1,10,10,10,10);
m_UUID = uuid;
@ -32,6 +34,7 @@ public class UserInfo extends Status {
}
public UUID getUserUUID(){ return m_UUID; }
public UUID getPartyUUID(){ return m_Party; }
public void setPartyUUID(UUID uuid){ m_Party = uuid; }
}

@ -17,7 +17,15 @@ public class UserInfoArray {
public Set<UUID> getKeySet(){ // 유저 목록 return
return m_UserInfoArray.keySet();
}
public UUID getUserPartyUUID(UUID uuid){
return m_UserInfoArray.get(uuid).getPartyUUID();
}
public void setUserPartyUUID(UUID PlayerUUID, UUID PartyUUID){
m_UserInfoArray.get(PlayerUUID).setPartyUUID(PartyUUID);
}
public void putUserInfo(UUID uuid,String Name, int Nation, int Squad, int Farm) { // UserInfoArray entry 입력
m_UserInfoArray.put(uuid, new UserInfo(uuid,Name, Nation, Squad, Farm));
}
}

@ -11,6 +11,7 @@ import java.sql.Statement;
public final class User_DB extends JavaPlugin implements Listener {
AccountArray m_AccountArrayInstance = new AccountArray();
PartyArray m_PartyArrayInstance = new PartyArray();
UserInfoArray m_InfoArrayInstance = new UserInfoArray(); // UserInfo저장하는 Array instance 생성
@ -25,6 +26,7 @@ public final class User_DB extends JavaPlugin implements Listener {
throw new RuntimeException(e);
}
getCommand("계좌").setExecutor(new AccountEventHandler(m_AccountArrayInstance));
getCommand("파티").setExecutor(new PartyEventHandler(m_PartyArrayInstance, m_InfoArrayInstance));
getServer().getPluginManager().registerEvents(new UserJoin(m_InfoArrayInstance, m_AccountArrayInstance),this);
}

Loading…
Cancel
Save