geforkt von Mirrors/Velocity
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.player.TabList;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.api.util.Identifiable;
|
|
||||||
import com.velocitypowered.api.util.MessagePosition;
|
import com.velocitypowered.api.util.MessagePosition;
|
||||||
import com.velocitypowered.api.util.ModInfo;
|
import com.velocitypowered.api.util.ModInfo;
|
||||||
import com.velocitypowered.api.util.title.Title;
|
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.
|
* Represents a player who is connected to the proxy.
|
||||||
*/
|
*/
|
||||||
public interface Player extends CommandSource, InboundConnection, ChannelMessageSource,
|
public interface Player extends CommandSource, InboundConnection, ChannelMessageSource,
|
||||||
ChannelMessageSink, Identifiable {
|
ChannelMessageSink {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player's current username.
|
* Returns the player's current username.
|
||||||
@ -29,6 +28,14 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage
|
|||||||
*/
|
*/
|
||||||
String getUsername();
|
String getUsername();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the player's UUID.
|
||||||
|
*
|
||||||
|
* @return the UUID
|
||||||
|
*/
|
||||||
|
UUID getUniqueId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the server that the player is currently connected to.
|
* 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.
|
* 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 UUID id;
|
||||||
private final String undashedId, name;
|
private final String undashedId, name;
|
||||||
@ -31,13 +31,12 @@ public final class GameProfile implements Identifiable {
|
|||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getId() {
|
||||||
public UUID getUniqueId() {
|
return undashedId;
|
||||||
return this.id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUndashedId() {
|
public UUID idAsUuid() {
|
||||||
return this.undashedId;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -54,7 +53,7 @@ public final class GameProfile implements Identifiable {
|
|||||||
* @param id the new unique id
|
* @param id the new unique id
|
||||||
* @return the new {@code GameProfile}
|
* @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),
|
return new GameProfile(Preconditions.checkNotNull(id, "id"), UuidUtils.toUndashed(id),
|
||||||
this.name, this.properties);
|
this.name, this.properties);
|
||||||
}
|
}
|
||||||
@ -65,7 +64,7 @@ public final class GameProfile implements Identifiable {
|
|||||||
* @param undashedId the new undashed id
|
* @param undashedId the new undashed id
|
||||||
* @return the new {@code GameProfile}
|
* @return the new {@code GameProfile}
|
||||||
*/
|
*/
|
||||||
public GameProfile withUndashedId(String undashedId) {
|
public GameProfile withId(String undashedId) {
|
||||||
return new GameProfile(
|
return new GameProfile(
|
||||||
UuidUtils.fromUndashed(Preconditions.checkNotNull(undashedId, "undashedId")), undashedId,
|
UuidUtils.fromUndashed(Preconditions.checkNotNull(undashedId, "undashedId")), undashedId,
|
||||||
this.name, this.properties);
|
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 {
|
try {
|
||||||
ProtocolUtils.writeVarInt(dataToForward, VelocityConstants.FORWARDING_VERSION);
|
ProtocolUtils.writeVarInt(dataToForward, VelocityConstants.FORWARDING_VERSION);
|
||||||
ProtocolUtils.writeString(dataToForward, address);
|
ProtocolUtils.writeString(dataToForward, address);
|
||||||
ProtocolUtils.writeUuid(dataToForward, profile.getUniqueId());
|
ProtocolUtils.writeUuid(dataToForward, profile.idAsUuid());
|
||||||
ProtocolUtils.writeString(dataToForward, profile.getName());
|
ProtocolUtils.writeString(dataToForward, profile.getName());
|
||||||
ProtocolUtils.writeProperties(dataToForward, profile.getProperties());
|
ProtocolUtils.writeProperties(dataToForward, profile.getProperties());
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
.append('\0')
|
.append('\0')
|
||||||
.append(proxyPlayer.getRemoteAddress().getHostString())
|
.append(proxyPlayer.getRemoteAddress().getHostString())
|
||||||
.append('\0')
|
.append('\0')
|
||||||
.append(proxyPlayer.getProfile().getUndashedId())
|
.append(proxyPlayer.getProfile().getId())
|
||||||
.append('\0');
|
.append('\0');
|
||||||
GSON.toJson(proxyPlayer.getProfile().getProperties(), data);
|
GSON.toJson(proxyPlayer.getProfile().getProperties(), data);
|
||||||
return data.toString();
|
return data.toString();
|
||||||
|
@ -100,7 +100,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getUniqueId() {
|
public UUID getUniqueId() {
|
||||||
return profile.getUniqueId();
|
return profile.idAsUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,7 +142,7 @@ public class PlayerListItem implements MinecraftPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Item from(TabListEntry entry) {
|
public static Item from(TabListEntry entry) {
|
||||||
return new Item(entry.getProfile().getUniqueId())
|
return new Item(entry.getProfile().idAsUuid())
|
||||||
.setName(entry.getProfile().getName())
|
.setName(entry.getProfile().getName())
|
||||||
.setProperties(entry.getProfile().getProperties())
|
.setProperties(entry.getProfile().getProperties())
|
||||||
.setLatency(entry.getLatency())
|
.setLatency(entry.getLatency())
|
||||||
|
@ -29,7 +29,7 @@ public class GameProfileSerializer implements JsonSerializer<GameProfile>,
|
|||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(GameProfile src, Type typeOfSrc, JsonSerializationContext context) {
|
public JsonElement serialize(GameProfile src, Type typeOfSrc, JsonSerializationContext context) {
|
||||||
JsonObject obj = new JsonObject();
|
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("name", new JsonPrimitive(src.getName()));
|
||||||
obj.add("properties", context.serialize(src.getProperties(), propertyList));
|
obj.add("properties", context.serialize(src.getProperties(), propertyList));
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -45,13 +45,13 @@ public class VelocityTabList implements TabList {
|
|||||||
Preconditions.checkNotNull(entry, "entry");
|
Preconditions.checkNotNull(entry, "entry");
|
||||||
Preconditions.checkArgument(entry.getTabList().equals(this),
|
Preconditions.checkArgument(entry.getTabList().equals(this),
|
||||||
"The provided entry was not created by this tab list");
|
"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");
|
"this TabList already contains an entry with the same uuid");
|
||||||
|
|
||||||
PlayerListItem.Item packetItem = PlayerListItem.Item.from(entry);
|
PlayerListItem.Item packetItem = PlayerListItem.Item.from(entry);
|
||||||
connection.write(
|
connection.write(
|
||||||
new PlayerListItem(PlayerListItem.ADD_PLAYER, Collections.singletonList(packetItem)));
|
new PlayerListItem(PlayerListItem.ADD_PLAYER, Collections.singletonList(packetItem)));
|
||||||
entries.put(entry.getProfile().getUniqueId(), entry);
|
entries.put(entry.getProfile().idAsUuid(), entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -141,7 +141,7 @@ public class VelocityTabList implements TabList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateEntry(int action, TabListEntry entry) {
|
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);
|
PlayerListItem.Item packetItem = PlayerListItem.Item.from(entry);
|
||||||
connection.write(new PlayerListItem(action, Collections.singletonList(packetItem)));
|
connection.write(new PlayerListItem(action, Collections.singletonList(packetItem)));
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren