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