Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Remove Identifiable
Dieser Commit ist enthalten in:
Ursprung
da259951c7
Commit
3cba196ba7
@ -7,7 +7,6 @@ import com.velocitypowered.api.proxy.player.PlayerSettings;
|
||||
import com.velocitypowered.api.proxy.player.TabList;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
import com.velocitypowered.api.util.Identifiable;
|
||||
import com.velocitypowered.api.util.MessagePosition;
|
||||
import com.velocitypowered.api.util.ModInfo;
|
||||
import com.velocitypowered.api.util.title.Title;
|
||||
@ -20,7 +19,7 @@ import net.kyori.text.Component;
|
||||
* Represents a player who is connected to the proxy.
|
||||
*/
|
||||
public interface Player extends CommandSource, InboundConnection, ChannelMessageSource,
|
||||
ChannelMessageSink, Identifiable {
|
||||
ChannelMessageSink {
|
||||
|
||||
/**
|
||||
* Returns the player's current username.
|
||||
@ -29,6 +28,14 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage
|
||||
*/
|
||||
String getUsername();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the player's UUID.
|
||||
*
|
||||
* @return the UUID
|
||||
*/
|
||||
UUID getUniqueId();
|
||||
|
||||
/**
|
||||
* Returns the server that the player is currently connected to.
|
||||
*
|
||||
|
@ -8,7 +8,7 @@ import java.util.UUID;
|
||||
/**
|
||||
* Represents a Mojang game profile. This class is immutable.
|
||||
*/
|
||||
public final class GameProfile implements Identifiable {
|
||||
public final class GameProfile {
|
||||
|
||||
private final UUID id;
|
||||
private final String undashedId, name;
|
||||
@ -31,13 +31,12 @@ public final class GameProfile implements Identifiable {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return this.id;
|
||||
public String getId() {
|
||||
return undashedId;
|
||||
}
|
||||
|
||||
public String getUndashedId() {
|
||||
return this.undashedId;
|
||||
public UUID idAsUuid() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -54,7 +53,7 @@ public final class GameProfile implements Identifiable {
|
||||
* @param id the new unique id
|
||||
* @return the new {@code GameProfile}
|
||||
*/
|
||||
public GameProfile withUniqueId(UUID id) {
|
||||
public GameProfile withUuid(UUID id) {
|
||||
return new GameProfile(Preconditions.checkNotNull(id, "id"), UuidUtils.toUndashed(id),
|
||||
this.name, this.properties);
|
||||
}
|
||||
@ -65,7 +64,7 @@ public final class GameProfile implements Identifiable {
|
||||
* @param undashedId the new undashed id
|
||||
* @return the new {@code GameProfile}
|
||||
*/
|
||||
public GameProfile withUndashedId(String undashedId) {
|
||||
public GameProfile withId(String undashedId) {
|
||||
return new GameProfile(
|
||||
UuidUtils.fromUndashed(Preconditions.checkNotNull(undashedId, "undashedId")), undashedId,
|
||||
this.name, this.properties);
|
||||
|
@ -1,16 +0,0 @@
|
||||
package com.velocitypowered.api.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents an object that can be identified by its UUID
|
||||
*/
|
||||
public interface Identifiable {
|
||||
|
||||
/**
|
||||
* Returns the {@code UUID} attached to this object.
|
||||
*
|
||||
* @return the UUID
|
||||
*/
|
||||
UUID getUniqueId();
|
||||
}
|
@ -157,7 +157,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
try {
|
||||
ProtocolUtils.writeVarInt(dataToForward, VelocityConstants.FORWARDING_VERSION);
|
||||
ProtocolUtils.writeString(dataToForward, address);
|
||||
ProtocolUtils.writeUuid(dataToForward, profile.getUniqueId());
|
||||
ProtocolUtils.writeUuid(dataToForward, profile.idAsUuid());
|
||||
ProtocolUtils.writeString(dataToForward, profile.getName());
|
||||
ProtocolUtils.writeProperties(dataToForward, profile.getProperties());
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
.append('\0')
|
||||
.append(proxyPlayer.getRemoteAddress().getHostString())
|
||||
.append('\0')
|
||||
.append(proxyPlayer.getProfile().getUndashedId())
|
||||
.append(proxyPlayer.getProfile().getId())
|
||||
.append('\0');
|
||||
GSON.toJson(proxyPlayer.getProfile().getProperties(), data);
|
||||
return data.toString();
|
||||
|
@ -100,7 +100,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return profile.getUniqueId();
|
||||
return profile.idAsUuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -142,7 +142,7 @@ public class PlayerListItem implements MinecraftPacket {
|
||||
}
|
||||
|
||||
public static Item from(TabListEntry entry) {
|
||||
return new Item(entry.getProfile().getUniqueId())
|
||||
return new Item(entry.getProfile().idAsUuid())
|
||||
.setName(entry.getProfile().getName())
|
||||
.setProperties(entry.getProfile().getProperties())
|
||||
.setLatency(entry.getLatency())
|
||||
|
@ -29,7 +29,7 @@ public class GameProfileSerializer implements JsonSerializer<GameProfile>,
|
||||
@Override
|
||||
public JsonElement serialize(GameProfile src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject obj = new JsonObject();
|
||||
obj.add("id", new JsonPrimitive(src.getUndashedId()));
|
||||
obj.add("id", new JsonPrimitive(src.getId()));
|
||||
obj.add("name", new JsonPrimitive(src.getName()));
|
||||
obj.add("properties", context.serialize(src.getProperties(), propertyList));
|
||||
return obj;
|
||||
|
@ -45,13 +45,13 @@ public class VelocityTabList implements TabList {
|
||||
Preconditions.checkNotNull(entry, "entry");
|
||||
Preconditions.checkArgument(entry.getTabList().equals(this),
|
||||
"The provided entry was not created by this tab list");
|
||||
Preconditions.checkArgument(!entries.containsKey(entry.getProfile().getUniqueId()),
|
||||
Preconditions.checkArgument(!entries.containsKey(entry.getProfile().idAsUuid()),
|
||||
"this TabList already contains an entry with the same uuid");
|
||||
|
||||
PlayerListItem.Item packetItem = PlayerListItem.Item.from(entry);
|
||||
connection.write(
|
||||
new PlayerListItem(PlayerListItem.ADD_PLAYER, Collections.singletonList(packetItem)));
|
||||
entries.put(entry.getProfile().getUniqueId(), entry);
|
||||
entries.put(entry.getProfile().idAsUuid(), entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -141,7 +141,7 @@ public class VelocityTabList implements TabList {
|
||||
}
|
||||
|
||||
void updateEntry(int action, TabListEntry entry) {
|
||||
if (entries.containsKey(entry.getProfile().getUniqueId())) {
|
||||
if (entries.containsKey(entry.getProfile().idAsUuid())) {
|
||||
PlayerListItem.Item packetItem = PlayerListItem.Item.from(entry);
|
||||
connection.write(new PlayerListItem(action, Collections.singletonList(packetItem)));
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren