Reformat and clean up "client" package
This commit is contained in:
@@ -40,31 +40,32 @@ public class BuddyList {
|
||||
public enum BuddyAddResult {
|
||||
BUDDYLIST_FULL, ALREADY_ON_LIST, OK
|
||||
}
|
||||
private Map<Integer, BuddylistEntry> buddies = new LinkedHashMap<>();
|
||||
|
||||
private final Map<Integer, BuddylistEntry> buddies = new LinkedHashMap<>();
|
||||
private int capacity;
|
||||
private Deque<CharacterNameAndId> pendingRequests = new LinkedList<>();
|
||||
private final Deque<CharacterNameAndId> pendingRequests = new LinkedList<>();
|
||||
|
||||
public BuddyList(int capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public boolean contains(int characterId) {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
return buddies.containsKey(characterId);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsVisible(int characterId) {
|
||||
BuddylistEntry ble;
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
ble = buddies.get(characterId);
|
||||
}
|
||||
|
||||
|
||||
if (ble == null) {
|
||||
return false;
|
||||
}
|
||||
return ble.isVisible();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
@@ -76,7 +77,7 @@ public class BuddyList {
|
||||
}
|
||||
|
||||
public BuddylistEntry get(int characterId) {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
return buddies.get(characterId);
|
||||
}
|
||||
}
|
||||
@@ -88,36 +89,36 @@ public class BuddyList {
|
||||
return ble;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void put(BuddylistEntry entry) {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
buddies.put(entry.getCharacterId(), entry);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(int characterId) {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
buddies.remove(characterId);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<BuddylistEntry> getBuddies() {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
return Collections.unmodifiableCollection(buddies.values());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
return buddies.size() >= capacity;
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getBuddyIds() {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
int[] buddyIds = new int[buddies.size()];
|
||||
int i = 0;
|
||||
for (BuddylistEntry ble : buddies.values()) {
|
||||
@@ -126,12 +127,12 @@ public class BuddyList {
|
||||
return buddyIds;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void broadcast(Packet packet, PlayerStorage pstorage) {
|
||||
for(int bid : getBuddyIds()) {
|
||||
for (int bid : getBuddyIds()) {
|
||||
Character chr = pstorage.getCharacterById(bid);
|
||||
|
||||
if(chr != null && chr.isLoggedinWorld()) {
|
||||
|
||||
if (chr != null && chr.isLoggedinWorld()) {
|
||||
chr.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user