Address review

This commit is contained in:
AlexProgrammerDE 2024-02-28 10:00:25 +01:00
parent b9c7e4b9d6
commit c7d443faeb
4 changed files with 11 additions and 11 deletions
protocol/src/main/java/org/geysermc/mcprotocollib/network

View file

@ -1,7 +1,7 @@
package org.geysermc.mcprotocollib.network;
public record Flag<T>(String key, Class<T> clazz) {
public record Flag<T>(String key, Class<T> type) {
public T cast(Object obj) {
return clazz.cast(obj);
return type.cast(obj);
}
}

View file

@ -58,7 +58,7 @@ public interface Server {
* Gets the value of the given flag as an instance of the given type.
*
* @param <T> Type of the flag.
* @param flag Key of the flag.
* @param flag Flag to check for.
* @return Value of the flag.
* @throws IllegalStateException If the flag's value isn't of the required type.
*/
@ -69,7 +69,7 @@ public interface Server {
* If the flag is not set, the specified default value will be returned.
*
* @param <T> Type of the flag.
* @param flag Key of the flag.
* @param flag Flag to check for.
* @param def Default value of the flag.
* @return Value of the flag.
* @throws IllegalStateException If the flag's value isn't of the required type.
@ -80,7 +80,7 @@ public interface Server {
* Sets the value of a flag. The flag will be used in sessions if a session does
* not contain a value for the flag.
*
* @param flag Key of the flag.
* @param flag Flag to check for.
* @param value Value to set the flag to.
*/
<T> void setGlobalFlag(Flag<T> flag, T value);

View file

@ -95,7 +95,7 @@ public interface Session {
* as well.
*
* @param <T> Type of the flag.
* @param flag Key of the flag.
* @param flag Flag to check for.
* @return Value of the flag.
* @throws IllegalStateException If the flag's value isn't of the required type.
*/
@ -107,7 +107,7 @@ public interface Session {
* as well. If the flag is not set, the specified default value will be returned.
*
* @param <T> Type of the flag.
* @param flag Key of the flag.
* @param flag Flag to check for.
* @param def Default value of the flag.
* @return Value of the flag.
* @throws IllegalStateException If the flag's value isn't of the required type.
@ -118,7 +118,7 @@ public interface Session {
* Sets the value of a flag. This does not change a server's flags if this session
* belongs to a server.
*
* @param flag Key of the flag.
* @param flag Flag to check for.
* @param value Value to set the flag to.
*/
<T> void setFlag(Flag<T> flag, T value);

View file

@ -32,12 +32,12 @@ public class TcpServerSession extends TcpSession {
}
@Override
public boolean hasFlag(Flag<?> definition) {
if(super.hasFlag(definition)) {
public boolean hasFlag(Flag<?> flag) {
if(super.hasFlag(flag)) {
return true;
}
return this.server.hasGlobalFlag(definition);
return this.server.hasGlobalFlag(flag);
}
@Override