mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Improve implementation of flag methods.
This commit is contained in:
parent
5291bea6a0
commit
fd7772a9b0
1 changed files with 4 additions and 3 deletions
|
@ -25,6 +25,7 @@ import io.netty.handler.timeout.WriteTimeoutHandler;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -93,12 +94,12 @@ public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> imp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getFlags() {
|
public Map<String, Object> getFlags() {
|
||||||
return new HashMap<String, Object>(this.flags);
|
return Collections.unmodifiableMap(this.flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasFlag(String key) {
|
public boolean hasFlag(String key) {
|
||||||
return this.getFlags().containsKey(key);
|
return this.flags.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -109,7 +110,7 @@ public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> imp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T getFlag(String key, T def) {
|
public <T> T getFlag(String key, T def) {
|
||||||
Object value = this.getFlags().get(key);
|
Object value = this.flags.get(key);
|
||||||
if(value == null) {
|
if(value == null) {
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue