mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Added Player properties, started working on Bungee skins, fixed errors
This commit is contained in:
@@ -97,6 +97,11 @@ public interface FloodgatePlayer {
|
||||
*/
|
||||
InputMode getInputMode();
|
||||
|
||||
/**
|
||||
* Returns if the Floodgate player is connected through a proxy
|
||||
*/
|
||||
boolean isFromProxy();
|
||||
|
||||
/**
|
||||
* Returns the LinkedPlayer object if the player is linked to a Java account.
|
||||
*/
|
||||
@@ -115,6 +120,18 @@ public interface FloodgatePlayer {
|
||||
return sendForm(formBuilder.build());
|
||||
}
|
||||
|
||||
<T> T getProperty(PropertyKey key);
|
||||
|
||||
<T> T getProperty(String key);
|
||||
|
||||
<T> T removeProperty(PropertyKey key);
|
||||
|
||||
<T> T removeProperty(String key);
|
||||
|
||||
<T> T addProperty(PropertyKey key, Object value);
|
||||
|
||||
<T> T addProperty(String key, Object value);
|
||||
|
||||
/**
|
||||
* Casts the FloodgatePlayer instance to a class that extends FloodgatePlayer.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.api.player;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class PropertyKey {
|
||||
/**
|
||||
* Socket Address returns the InetSocketAddress of the Bedrock player
|
||||
*/
|
||||
public static final PropertyKey SOCKET_ADDRESS =
|
||||
new PropertyKey("socket_address", false, false);
|
||||
|
||||
/**
|
||||
* Skin Uploaded returns a JsonObject containing the value and signature of the Skin
|
||||
*/
|
||||
public static final PropertyKey SKIN_UPLOADED =
|
||||
new PropertyKey("skin_uploaded", false, false);
|
||||
|
||||
private final String key;
|
||||
private final boolean changeable;
|
||||
private final boolean removeable;
|
||||
|
||||
public PropertyKey(String key, boolean changeable, boolean removeable) {
|
||||
this.key = key;
|
||||
this.changeable = changeable;
|
||||
this.removeable = removeable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof PropertyKey) {
|
||||
return key.equals(((PropertyKey) obj).key);
|
||||
}
|
||||
|
||||
if (obj instanceof String) {
|
||||
return key.equals(obj);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public AllowedResult isAddAllowed(Object obj) {
|
||||
if (obj instanceof PropertyKey) {
|
||||
PropertyKey propertyKey = (PropertyKey) obj;
|
||||
|
||||
if (key.equals(propertyKey.key)) {
|
||||
if ((propertyKey.changeable == changeable || propertyKey.changeable) &&
|
||||
(propertyKey.removeable == removeable || propertyKey.removeable)) {
|
||||
return AllowedResult.CORRECT;
|
||||
}
|
||||
return AllowedResult.INVALID_TAGS;
|
||||
}
|
||||
return AllowedResult.NOT_EQUALS;
|
||||
}
|
||||
|
||||
if (obj instanceof String) {
|
||||
if (changeable) {
|
||||
return AllowedResult.CORRECT;
|
||||
}
|
||||
return AllowedResult.INVALID_TAGS;
|
||||
}
|
||||
return AllowedResult.NOT_EQUALS;
|
||||
}
|
||||
|
||||
public enum AllowedResult {
|
||||
NOT_EQUALS,
|
||||
INVALID_TAGS,
|
||||
CORRECT
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user