Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SGameProfile and SProperty to represent the different classes that each implementation use (Mojang GameProfile, Velocity GameProfile, etc). Moved SkinHandler_ to SkinHandler_Unsupported Updated Velocity to 3.2.0 Added PlayerObject#internalGameProfile Changed SkinHandler#getGameProfile0 from private to public abstract
- Loading branch information
1 parent
3a68882
commit 06d9a67
Showing
24 changed files
with
662 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
bungee/src/main/java/com/georgev22/skinoverlay/handler/profile/SGameProfileBungee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.georgev22.skinoverlay.handler.profile; | ||
|
||
import com.georgev22.library.maps.HashObjectMap; | ||
import com.georgev22.library.maps.ObjectMap; | ||
import com.georgev22.skinoverlay.SkinOverlay; | ||
import com.georgev22.skinoverlay.handler.SGameProfile; | ||
import com.georgev22.skinoverlay.handler.SProperty; | ||
import com.georgev22.skinoverlay.utilities.player.PlayerObject; | ||
import net.md_5.bungee.api.connection.ProxiedPlayer; | ||
import net.md_5.bungee.connection.InitialHandler; | ||
import net.md_5.bungee.connection.LoginResult; | ||
import net.md_5.bungee.protocol.Property; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public class SGameProfileBungee extends SGameProfile { | ||
|
||
private final String name; | ||
private final UUID uuid; | ||
private final ObjectMap<String, SProperty> properties; | ||
private final SkinOverlay skinOverlay = SkinOverlay.getInstance(); | ||
|
||
public SGameProfileBungee(String name, UUID uuid) { | ||
super(name, uuid); | ||
this.name = name; | ||
this.uuid = uuid; | ||
this.properties = new HashObjectMap<>(); | ||
} | ||
|
||
public SGameProfileBungee(String name, UUID uuid, ObjectMap<String, SProperty> properties) { | ||
super(name, uuid, properties); | ||
this.name = name; | ||
this.uuid = uuid; | ||
this.properties = properties; | ||
} | ||
|
||
@Override | ||
public void apply() { | ||
PlayerObject playerObject = skinOverlay.getPlayer(uuid).orElseThrow(); | ||
LoginResult initialHandler = ((InitialHandler) ((ProxiedPlayer) playerObject.player()).getPendingConnection()).getLoginProfile(); | ||
List<Property> bungeeProperties = new ArrayList<>(); | ||
this.properties.forEach((s, sProperty) -> bungeeProperties.add(new Property(sProperty.name(), sProperty.value(), sProperty.value()))); | ||
initialHandler.setProperties(bungeeProperties.toArray(Property[]::new)); | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
core/src/main/java/com/georgev22/skinoverlay/handler/SGameProfile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package com.georgev22.skinoverlay.handler; | ||
|
||
import com.georgev22.library.maps.HashObjectMap; | ||
import com.georgev22.library.maps.ObjectMap; | ||
import com.georgev22.library.maps.UnmodifiableObjectMap; | ||
import org.jetbrains.annotations.UnmodifiableView; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* The SGameProfile class represents a simplified version of a GameProfile, containing a player's name, UUID, and properties. | ||
*/ | ||
public abstract class SGameProfile { | ||
|
||
/** | ||
* The player's name. | ||
*/ | ||
private final String name; | ||
|
||
/** | ||
* The player's UUID. | ||
*/ | ||
private final UUID uuid; | ||
|
||
/** | ||
* The player's properties. | ||
*/ | ||
private final ObjectMap<String, SProperty> properties; | ||
|
||
/** | ||
* Constructs an {@link SGameProfile} object with the specified name and UUID, and an empty properties map. | ||
* | ||
* @param name the player's name | ||
* @param uuid the player's UUID | ||
*/ | ||
public SGameProfile(String name, UUID uuid) { | ||
this.name = name; | ||
this.uuid = uuid; | ||
this.properties = new HashObjectMap<>(); | ||
} | ||
|
||
/** | ||
* Constructs an {@link SGameProfile} object with the specified name, UUID, and properties map. | ||
* | ||
* @param name the player's name | ||
* @param uuid the player's UUID | ||
* @param properties the player's properties map | ||
*/ | ||
public SGameProfile(String name, UUID uuid, ObjectMap<String, SProperty> properties) { | ||
this.name = name; | ||
this.uuid = uuid; | ||
this.properties = properties; | ||
} | ||
|
||
/** | ||
* Returns the player's name. | ||
* | ||
* @return the player's name | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* Returns the player's UUID. | ||
* | ||
* @return the player's UUID | ||
*/ | ||
public UUID getUUID() { | ||
return uuid; | ||
} | ||
|
||
/** | ||
* Returns an unmodifiable view of the player's properties map. | ||
* | ||
* @return an unmodifiable view of the player's properties map | ||
*/ | ||
@UnmodifiableView | ||
public UnmodifiableObjectMap<String, SProperty> getProperties() { | ||
return new UnmodifiableObjectMap<>(properties); | ||
} | ||
|
||
/** | ||
* Adds a property to the player's properties map. | ||
* | ||
* @param propertyName the name of the property to add | ||
* @param sProperty the {@link SProperty} object representing the property to add | ||
* @return this {@link SGameProfile} object | ||
*/ | ||
public SGameProfile addProperty(String propertyName, SProperty sProperty) { | ||
this.properties.append(propertyName, sProperty); | ||
this.apply(); | ||
return this; | ||
} | ||
|
||
/** | ||
* Removes a property from the player's properties map. | ||
* | ||
* @param propertyName the name of the property to remove | ||
* @return this {@link SGameProfile} object | ||
*/ | ||
public SGameProfile removeProperty(String propertyName) { | ||
this.properties.remove(propertyName); | ||
this.apply(); | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the {@link SProperty} associated with the specified property name. | ||
* | ||
* @param propertyName the name of the property to retrieve | ||
* @return the {@code SProperty} object associated with the given property name | ||
*/ | ||
public SProperty getProperty(String propertyName) { | ||
return this.properties.get(propertyName); | ||
} | ||
|
||
public abstract void apply(); | ||
} |
5 changes: 5 additions & 0 deletions
5
core/src/main/java/com/georgev22/skinoverlay/handler/SProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.georgev22.skinoverlay.handler; | ||
|
||
public record SProperty(String name, String value, String signature) { | ||
|
||
} |
Oops, something went wrong.