Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 15:00:11 +01:00
Removed var usage for primitives and String, removed star imports
Dieser Commit ist enthalten in:
Ursprung
6470f25d9a
Commit
3c296a598f
@ -25,6 +25,12 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -35,7 +41,12 @@ import org.cloudburstmc.math.vector.Vector3f;
|
|||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.*;
|
import org.cloudburstmc.protocol.bedrock.packet.AddEntityPacket;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityDeltaPacket;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.packet.RemoveEntityPacket;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket;
|
||||||
import org.geysermc.geyser.api.entity.type.GeyserEntity;
|
import org.geysermc.geyser.api.entity.type.GeyserEntity;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.GeyserDirtyMetadata;
|
import org.geysermc.geyser.entity.GeyserDirtyMetadata;
|
||||||
@ -56,8 +67,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEnt
|
|||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class Entity implements GeyserEntity {
|
public class Entity implements GeyserEntity {
|
||||||
@ -427,7 +436,7 @@ public class Entity implements GeyserEntity {
|
|||||||
// Displayname is ignored for players, and is always their username.
|
// Displayname is ignored for players, and is always their username.
|
||||||
Optional<Component> name = entityMetadata.getValue();
|
Optional<Component> name = entityMetadata.getValue();
|
||||||
if (name.isPresent()) {
|
if (name.isPresent()) {
|
||||||
var displayName = MessageTranslator.convertMessage(name.get(), session.locale());
|
String displayName = MessageTranslator.convertMessage(name.get(), session.locale());
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
setNametag(displayName, true);
|
setNametag(displayName, true);
|
||||||
return;
|
return;
|
||||||
@ -456,7 +465,7 @@ public class Entity implements GeyserEntity {
|
|||||||
if (nametag == null) {
|
if (nametag == null) {
|
||||||
nametag = "";
|
nametag = "";
|
||||||
}
|
}
|
||||||
var changed = !Objects.equals(this.nametag, nametag);
|
boolean changed = !Objects.equals(this.nametag, nametag);
|
||||||
this.nametag = nametag;
|
this.nametag = nametag;
|
||||||
// we only update metadata if the value has changed
|
// we only update metadata if the value has changed
|
||||||
if (!changed) {
|
if (!changed) {
|
||||||
|
@ -25,7 +25,12 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.player;
|
package org.geysermc.geyser.entity.type.player;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -45,7 +50,6 @@ import org.cloudburstmc.protocol.bedrock.data.entity.EntityLinkData;
|
|||||||
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.AddPlayerPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.AddPlayerPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.MovePlayerPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.MovePlayerPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket;
|
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.SetEntityLinkPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.SetEntityLinkPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.UpdateAttributesPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.UpdateAttributesPacket;
|
||||||
import org.geysermc.geyser.api.entity.type.player.GeyserPlayerEntity;
|
import org.geysermc.geyser.api.entity.type.player.GeyserPlayerEntity;
|
||||||
@ -62,12 +66,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
|
|||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType;
|
||||||
|
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
@ -430,7 +428,7 @@ public class PlayerEntity extends LivingEntity implements GeyserPlayerEntity {
|
|||||||
text = "";
|
text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
var changed = !Objects.equals(cachedScore, text);
|
boolean changed = !Objects.equals(cachedScore, text);
|
||||||
cachedScore = text;
|
cachedScore = text;
|
||||||
if (isScoreVisible() && changed) {
|
if (isScoreVisible() && changed) {
|
||||||
dirtyMetadata.put(EntityDataTypes.SCORE, text);
|
dirtyMetadata.put(EntityDataTypes.SCORE, text);
|
||||||
@ -439,7 +437,7 @@ public class PlayerEntity extends LivingEntity implements GeyserPlayerEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void scoreVisibility(boolean show) {
|
protected void scoreVisibility(boolean show) {
|
||||||
var visibilityChanged = scoreVisible != show;
|
boolean visibilityChanged = scoreVisible != show;
|
||||||
scoreVisible = show;
|
scoreVisible = show;
|
||||||
if (!visibilityChanged) {
|
if (!visibilityChanged) {
|
||||||
return;
|
return;
|
||||||
|
@ -83,8 +83,8 @@ public final class Objective {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateProperties(Component displayNameComponent, ScoreType type, NumberFormat format) {
|
public void updateProperties(Component displayNameComponent, ScoreType type, NumberFormat format) {
|
||||||
var displayName = MessageTranslator.convertMessageRaw(displayNameComponent, scoreboard.session().locale());
|
String displayName = MessageTranslator.convertMessageRaw(displayNameComponent, scoreboard.session().locale());
|
||||||
var changed = !Objects.equals(this.displayName, displayName) || this.type != type;
|
boolean changed = !Objects.equals(this.displayName, displayName) || this.type != type;
|
||||||
|
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -86,7 +86,7 @@ public final class ScoreReference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void score(int score) {
|
private void score(int score) {
|
||||||
var changed = this.score != score;
|
boolean changed = this.score != score;
|
||||||
this.score = score;
|
this.score = score;
|
||||||
if (changed) {
|
if (changed) {
|
||||||
markChanged();
|
markChanged();
|
||||||
|
@ -25,8 +25,23 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.scoreboard;
|
package org.geysermc.geyser.scoreboard;
|
||||||
|
|
||||||
|
import static org.geysermc.geyser.scoreboard.UpdateType.REMOVE;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -48,14 +63,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.ScoreboardPositi
|
|||||||
import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.TeamColor;
|
import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.TeamColor;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static org.geysermc.geyser.scoreboard.UpdateType.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Here follows some information about how scoreboards work in Java Edition, that is related to the workings of this
|
* Here follows some information about how scoreboards work in Java Edition, that is related to the workings of this
|
||||||
* class:
|
* class:
|
||||||
|
@ -120,7 +120,7 @@ public final class Team {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String displayName(String score) {
|
public String displayName(String score) {
|
||||||
var chatColor = ChatColor.chatColorFor(color);
|
String chatColor = ChatColor.chatColorFor(color);
|
||||||
// most sidebar plugins will use the reset color, because they don't want color
|
// most sidebar plugins will use the reset color, because they don't want color
|
||||||
// skip the unneeded double reset color in that case
|
// skip the unneeded double reset color in that case
|
||||||
if (ChatColor.RESET.equals(chatColor)) {
|
if (ChatColor.RESET.equals(chatColor)) {
|
||||||
@ -149,10 +149,10 @@ public final class Team {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldName = this.name;
|
String oldName = this.name;
|
||||||
var oldPrefix = this.prefix;
|
String oldPrefix = this.prefix;
|
||||||
var oldSuffix = this.suffix;
|
String oldSuffix = this.suffix;
|
||||||
var oldVisible = isVisibleFor(playerName());
|
boolean oldVisible = isVisibleFor(playerName());
|
||||||
var oldColor = this.color;
|
var oldColor = this.color;
|
||||||
|
|
||||||
this.name = MessageTranslator.convertMessageRaw(name, session().locale());
|
this.name = MessageTranslator.convertMessageRaw(name, session().locale());
|
||||||
@ -245,7 +245,7 @@ public final class Team {
|
|||||||
if (names.isEmpty()) {
|
if (names.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var containsSelf = names.contains(playerName());
|
boolean containsSelf = names.contains(playerName());
|
||||||
|
|
||||||
for (Entity entity : session().getEntityCache().getEntities().values()) {
|
for (Entity entity : session().getEntityCache().getEntities().values()) {
|
||||||
if (names.contains(entity.teamIdentifier())) {
|
if (names.contains(entity.teamIdentifier())) {
|
||||||
@ -263,7 +263,7 @@ public final class Team {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeRemovedEntities(Set<String> names) {
|
private void removeRemovedEntities(Set<String> names) {
|
||||||
var containsSelf = names.contains(playerName());
|
boolean containsSelf = names.contains(playerName());
|
||||||
|
|
||||||
var iterator = managedEntities.iterator();
|
var iterator = managedEntities.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
@ -60,8 +60,8 @@ public final class SidebarDisplayScore extends DisplayScore {
|
|||||||
public void update(Objective objective) {
|
public void update(Objective objective) {
|
||||||
markUpdated();
|
markUpdated();
|
||||||
|
|
||||||
var finalName = reference.name();
|
String finalName = reference.name();
|
||||||
var displayName = reference.displayName();
|
String displayName = reference.displayName();
|
||||||
|
|
||||||
if (displayName != null) {
|
if (displayName != null) {
|
||||||
finalName = displayName;
|
finalName = displayName;
|
||||||
|
@ -31,15 +31,18 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
|||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
import org.geysermc.geyser.entity.type.Entity;
|
||||||
import org.geysermc.geyser.entity.type.Tickable;
|
import org.geysermc.geyser.entity.type.Tickable;
|
||||||
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each session has its own EntityCache in the occasion that an entity packet is sent specifically
|
* Each session has its own EntityCache in the occasion that an entity packet is sent specifically
|
||||||
* for that player (e.g. seeing vanished players from /vanish)
|
* for that player (e.g. seeing vanished players from /vanish)
|
||||||
@ -133,7 +136,7 @@ public class EntityCache {
|
|||||||
|
|
||||||
public void addPlayerEntity(PlayerEntity entity) {
|
public void addPlayerEntity(PlayerEntity entity) {
|
||||||
// putIfAbsent matches the behavior of playerInfoMap in Java as of 1.19.3
|
// putIfAbsent matches the behavior of playerInfoMap in Java as of 1.19.3
|
||||||
var exists = playerEntities.putIfAbsent(entity.getUuid(), entity) != null;
|
boolean exists = playerEntities.putIfAbsent(entity.getUuid(), entity) != null;
|
||||||
if (exists) {
|
if (exists) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren