mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-28 03:19:14 +00:00
refactor(user): 重命名方法和字段
This commit is contained in:
@@ -1240,17 +1240,17 @@ public class PacketConsumers {
|
||||
try {
|
||||
BukkitServerPlayer player = (BukkitServerPlayer) user;
|
||||
String name = (String) NetworkReflections.methodHandle$ServerboundHelloPacket$nameGetter.invokeExact(packet);
|
||||
player.setUnverifiedName(name);
|
||||
player.setNameUnverified(name);
|
||||
if (VersionHelper.isOrAbove1_20_2()) {
|
||||
UUID uuid = (UUID) NetworkReflections.methodHandle$ServerboundHelloPacket$uuidGetter.invokeExact(packet);
|
||||
player.setUnverifiedUUID(uuid);
|
||||
player.setUUIDUnverified(uuid);
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
Optional<UUID> uuid = (Optional<UUID>) NetworkReflections.methodHandle$ServerboundHelloPacket$uuidGetter.invokeExact(packet);
|
||||
if (uuid.isPresent()) {
|
||||
player.setUnverifiedUUID(uuid.get());
|
||||
player.setUUIDUnverified(uuid.get());
|
||||
} else {
|
||||
player.setUnverifiedUUID(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)));
|
||||
player.setUUIDUnverified(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@@ -2501,7 +2501,7 @@ public class PacketConsumers {
|
||||
user.setShouldProcessFinishConfiguration(false);
|
||||
|
||||
// 检查用户UUID是否已经校验
|
||||
if (!user.isVerifiedUUID()) {
|
||||
if (!user.isUUIDVerified()) {
|
||||
if (Config.strictPlayerUuidValidation()) {
|
||||
TranslationManager.instance().log("warning.network.resource_pack.unverified_uuid", user.name(), user.uuid().toString());
|
||||
user.kick(Component.translatable("disconnect.loginFailed"));
|
||||
@@ -2561,8 +2561,8 @@ public class PacketConsumers {
|
||||
public static final TriConsumer<NetWorkUser, NMSPacketEvent, Object> LOGIN_FINISHED = (user, event, packet) -> {
|
||||
try {
|
||||
GameProfile gameProfile = FastNMS.INSTANCE.field$ClientboundLoginFinishedPacket$gameProfile(packet);
|
||||
user.setVerifiedName(gameProfile.getName());
|
||||
user.setVerifiedUUID(gameProfile.getId());
|
||||
user.setNameVerified(gameProfile.getName());
|
||||
user.setUUIDVerified(gameProfile.getId());
|
||||
} catch (Exception e) {
|
||||
CraftEngine.instance().logger().warn("Failed to handle ClientboundLoginFinishedPacket", e);
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ public class BukkitServerPlayer extends Player {
|
||||
private ChannelHandler connection;
|
||||
private String name;
|
||||
private UUID uuid;
|
||||
private boolean isVerifiedName;
|
||||
private boolean isVerifiedUUID;
|
||||
private boolean isNameVerified;
|
||||
private boolean isUUIDVerified;
|
||||
private ConnectionState decoderState;
|
||||
private ConnectionState encoderState;
|
||||
private boolean shouldProcessFinishConfiguration = true;
|
||||
@@ -142,9 +142,9 @@ public class BukkitServerPlayer extends Player {
|
||||
this.playerRef = new WeakReference<>(player);
|
||||
this.serverPlayerRef = new WeakReference<>(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player));
|
||||
this.uuid = player.getUniqueId();
|
||||
this.isVerifiedUUID = true;
|
||||
this.isUUIDVerified = true;
|
||||
this.name = player.getName();
|
||||
this.isVerifiedName = true;
|
||||
this.isNameVerified = true;
|
||||
byte[] bytes = player.getPersistentDataContainer().get(KeyUtils.toNamespacedKey(CooldownData.COOLDOWN_KEY), PersistentDataType.BYTE_ARRAY);
|
||||
this.trackedChunks = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(768, 0.5f);
|
||||
this.entityTypeView = new ConcurrentHashMap<>(256);
|
||||
@@ -325,21 +325,21 @@ public class BukkitServerPlayer extends Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVerifiedName() {
|
||||
return this.isVerifiedName;
|
||||
public boolean isNameVerified() {
|
||||
return this.isNameVerified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnverifiedName(String name) {
|
||||
if (this.isVerifiedName) return;
|
||||
public void setNameUnverified(String name) {
|
||||
if (this.isNameVerified) return;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVerifiedName(String name) {
|
||||
if (this.isVerifiedName) return;
|
||||
public void setNameVerified(String name) {
|
||||
if (this.isNameVerified) return;
|
||||
this.name = name;
|
||||
this.isVerifiedName = true;
|
||||
this.isNameVerified = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -348,21 +348,21 @@ public class BukkitServerPlayer extends Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVerifiedUUID() {
|
||||
return this.isVerifiedUUID;
|
||||
public boolean isUUIDVerified() {
|
||||
return this.isUUIDVerified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnverifiedUUID(UUID uuid) {
|
||||
if (this.isVerifiedUUID) return;
|
||||
public void setUUIDUnverified(UUID uuid) {
|
||||
if (this.isUUIDVerified) return;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVerifiedUUID(UUID uuid) {
|
||||
if (this.isVerifiedUUID) return;
|
||||
public void setUUIDVerified(UUID uuid) {
|
||||
if (this.isUUIDVerified) return;
|
||||
this.uuid = uuid;
|
||||
this.isVerifiedUUID = true;
|
||||
this.isUUIDVerified = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,19 +31,19 @@ public interface NetWorkUser {
|
||||
|
||||
String name();
|
||||
|
||||
boolean isVerifiedName();
|
||||
boolean isNameVerified();
|
||||
|
||||
void setUnverifiedName(String name);
|
||||
void setNameUnverified(String name);
|
||||
|
||||
void setVerifiedName(String name);
|
||||
void setNameVerified(String name);
|
||||
|
||||
UUID uuid();
|
||||
|
||||
boolean isVerifiedUUID();
|
||||
boolean isUUIDVerified();
|
||||
|
||||
void setUnverifiedUUID(UUID uuid);
|
||||
void setUUIDUnverified(UUID uuid);
|
||||
|
||||
void setVerifiedUUID(UUID uuid);
|
||||
void setUUIDVerified(UUID uuid);
|
||||
|
||||
void sendPacket(Object packet, boolean immediately);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user