parent
414c0e1a3e
commit
3d39a8f389
7 changed files with 63 additions and 94 deletions
@ -1,37 +1,27 @@ |
||||
package org.poopki.duckdns.user_db; |
||||
|
||||
import org.bukkit.entity.Player; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.UUID; |
||||
|
||||
public class AccountArray { |
||||
public static Map<UUID, Account> m_AccountArray = new HashMap<UUID, Account>(); |
||||
private static Map<UUID, Account> m_AccountArray = new HashMap<UUID, Account>(); |
||||
|
||||
public void transfer(UUID Src, UUID Des, int Amount){ |
||||
public void transfer(UUID Src, UUID Des, int Amount){ // 송금 method
|
||||
Account m_Src = m_AccountArray.get(Src); |
||||
Account m_Des = m_AccountArray.get(Des); |
||||
|
||||
if(m_Src.getBalance()-Amount>0){ |
||||
m_Src.withdraw(Amount); |
||||
if(m_Src.withdraw(Amount)){ //인출 성공시 입금
|
||||
m_Des.credit(Amount); |
||||
} |
||||
} |
||||
|
||||
public int getAccountInfo(UUID uuid) { |
||||
public int getAccountInfo(UUID uuid) { // DB backup시 account 정보 접근 method
|
||||
Account m_Account = m_AccountArray.get(uuid); |
||||
return m_Account.getBalance(); |
||||
} |
||||
|
||||
public Account putAccountInfo(UUID uuid) { |
||||
m_AccountArray.put(uuid, new Account()); |
||||
Account m_Account = m_AccountArray.get(uuid); |
||||
return m_Account; |
||||
} |
||||
public Account putAccountInfo(UUID uuid, int Amount) { |
||||
public void putAccountInfo(UUID uuid, int Amount) { //AccountArray 생성
|
||||
m_AccountArray.put(uuid, new Account(Amount)); |
||||
Account m_Account = m_AccountArray.get(uuid); |
||||
return m_Account; |
||||
} |
||||
} |
||||
|
@ -1,35 +1,35 @@ |
||||
package org.poopki.duckdns.user_db; |
||||
|
||||
import org.bukkit.entity.Player; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.UUID; |
||||
|
||||
public class UserInfo { |
||||
private UUID m_UUID; |
||||
private String m_Name; |
||||
|
||||
private static Map<String, Integer> m_status = new HashMap<String, Integer>(); |
||||
|
||||
private int m_Nation; |
||||
private int m_Squad; |
||||
private int m_Farm; |
||||
private Account m_Account; |
||||
|
||||
public UserInfo(UUID uuid, int Nation, int Squad, int Farm, Account Instance){ |
||||
public UserInfo(UUID uuid, String Name, int Nation, int Squad, int Farm){ //UserInfo 초기화
|
||||
m_UUID = uuid; |
||||
m_Name = Name; |
||||
m_Nation = Nation; |
||||
m_Squad = Squad; |
||||
m_Account = Instance; |
||||
m_Farm = Farm; |
||||
} |
||||
public void JoinNation(int Nation) { m_Nation = Nation; } |
||||
public void JoinSquad(int Squad) { m_Squad = Squad; } |
||||
public void JoinFarm(int Farm) { m_Farm = Farm; } |
||||
|
||||
public int getBalance(){ return m_Account.getBalance();} |
||||
public String getUserName(){ |
||||
return m_Name; |
||||
} |
||||
|
||||
public UUID getUserUUID(){ |
||||
return m_UUID; |
||||
} |
||||
public UUID getUserUUID(){ return m_UUID; } |
||||
|
||||
|
||||
} |
||||
|
@ -1,29 +1,23 @@ |
||||
package org.poopki.duckdns.user_db; |
||||
|
||||
import org.bukkit.entity.Player; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
import java.util.UUID; |
||||
|
||||
public class UserInfoArray { |
||||
private AccountArray m_AccountArrayInstance; |
||||
public static Map<UUID, UserInfo> m_UserInfoArray = new HashMap<UUID, UserInfo>(); |
||||
private static Map<UUID, UserInfo> m_UserInfoArray = new HashMap<UUID, UserInfo>(); |
||||
|
||||
UserInfoArray(AccountArray Instance){ |
||||
m_AccountArrayInstance = Instance; |
||||
public String getUserName(UUID uuid){ // 유저 이름 return
|
||||
return m_UserInfoArray.get(uuid).getUserName(); |
||||
} |
||||
|
||||
public void getUserInfo(Player p) { |
||||
UserInfo m_UserInfo = m_UserInfoArray.get(p.getUniqueId()); |
||||
p.sendMessage(m_UserInfo.getUserName() + m_UserInfo.getUserUUID() + ("중복 입장")); |
||||
p.sendMessage(m_UserInfo.getUserUUID() +("Balance ")+m_AccountArrayInstance.getAccountInfo(p.getUniqueId())); |
||||
public boolean checkNewUser(UUID uuid){ // 유저 목록 check
|
||||
return m_UserInfoArray.containsKey(uuid); |
||||
} |
||||
|
||||
public void NewUserInfo(Player p) { |
||||
m_UserInfoArray.put(p.getUniqueId(), new UserInfo(p.getUniqueId(), 0, 0, 0, m_AccountArrayInstance.putAccountInfo(p.getUniqueId()))); |
||||
UserInfo m_UserInfo = m_UserInfoArray.get(p.getUniqueId()); |
||||
p.sendMessage(m_UserInfo.getUserName() + m_UserInfo.getUserUUID() + ("초기 입장")); |
||||
p.sendMessage(m_UserInfo.getUserUUID() +("Balance ")+m_AccountArrayInstance.getAccountInfo(p.getUniqueId())); |
||||
public Set<UUID> getKeySet(){ // 유저 목록 return
|
||||
return m_UserInfoArray.keySet(); |
||||
} |
||||
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)); |
||||
} |
||||
} |
Loading…
Reference in new issue