Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +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;
|
||||
|
||||
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.Getter;
|
||||
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.EntityEventType;
|
||||
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.entity.EntityDefinition;
|
||||
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.type.EntityType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Entity implements GeyserEntity {
|
||||
@ -427,7 +436,7 @@ public class Entity implements GeyserEntity {
|
||||
// Displayname is ignored for players, and is always their username.
|
||||
Optional<Component> name = entityMetadata.getValue();
|
||||
if (name.isPresent()) {
|
||||
var displayName = MessageTranslator.convertMessage(name.get(), session.locale());
|
||||
String displayName = MessageTranslator.convertMessage(name.get(), session.locale());
|
||||
this.displayName = displayName;
|
||||
setNametag(displayName, true);
|
||||
return;
|
||||
@ -456,7 +465,7 @@ public class Entity implements GeyserEntity {
|
||||
if (nametag == null) {
|
||||
nametag = "";
|
||||
}
|
||||
var changed = !Objects.equals(this.nametag, nametag);
|
||||
boolean changed = !Objects.equals(this.nametag, nametag);
|
||||
this.nametag = nametag;
|
||||
// we only update metadata if the value has changed
|
||||
if (!changed) {
|
||||
|
@ -25,7 +25,12 @@
|
||||
|
||||
package org.geysermc.geyser.entity.type.player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
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.packet.AddPlayerPacket;
|
||||
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.UpdateAttributesPacket;
|
||||
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.ByteEntityMetadata;
|
||||
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;
|
||||
|
||||
@Getter @Setter
|
||||
@ -430,7 +428,7 @@ public class PlayerEntity extends LivingEntity implements GeyserPlayerEntity {
|
||||
text = "";
|
||||
}
|
||||
|
||||
var changed = !Objects.equals(cachedScore, text);
|
||||
boolean changed = !Objects.equals(cachedScore, text);
|
||||
cachedScore = text;
|
||||
if (isScoreVisible() && changed) {
|
||||
dirtyMetadata.put(EntityDataTypes.SCORE, text);
|
||||
@ -439,7 +437,7 @@ public class PlayerEntity extends LivingEntity implements GeyserPlayerEntity {
|
||||
|
||||
@Override
|
||||
protected void scoreVisibility(boolean show) {
|
||||
var visibilityChanged = scoreVisible != show;
|
||||
boolean visibilityChanged = scoreVisible != show;
|
||||
scoreVisible = show;
|
||||
if (!visibilityChanged) {
|
||||
return;
|
||||
|
@ -83,8 +83,8 @@ public final class Objective {
|
||||
}
|
||||
|
||||
public void updateProperties(Component displayNameComponent, ScoreType type, NumberFormat format) {
|
||||
var displayName = MessageTranslator.convertMessageRaw(displayNameComponent, scoreboard.session().locale());
|
||||
var changed = !Objects.equals(this.displayName, displayName) || this.type != type;
|
||||
String displayName = MessageTranslator.convertMessageRaw(displayNameComponent, scoreboard.session().locale());
|
||||
boolean changed = !Objects.equals(this.displayName, displayName) || this.type != type;
|
||||
|
||||
this.displayName = displayName;
|
||||
this.type = type;
|
||||
|
@ -86,7 +86,7 @@ public final class ScoreReference {
|
||||
}
|
||||
|
||||
private void score(int score) {
|
||||
var changed = this.score != score;
|
||||
boolean changed = this.score != score;
|
||||
this.score = score;
|
||||
if (changed) {
|
||||
markChanged();
|
||||
|
@ -25,8 +25,23 @@
|
||||
|
||||
package org.geysermc.geyser.scoreboard;
|
||||
|
||||
import static org.geysermc.geyser.scoreboard.UpdateType.REMOVE;
|
||||
|
||||
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.AtomicLong;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
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.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
|
||||
* class:
|
||||
|
@ -120,7 +120,7 @@ public final class Team {
|
||||
}
|
||||
|
||||
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
|
||||
// skip the unneeded double reset color in that case
|
||||
if (ChatColor.RESET.equals(chatColor)) {
|
||||
@ -149,10 +149,10 @@ public final class Team {
|
||||
return;
|
||||
}
|
||||
|
||||
var oldName = this.name;
|
||||
var oldPrefix = this.prefix;
|
||||
var oldSuffix = this.suffix;
|
||||
var oldVisible = isVisibleFor(playerName());
|
||||
String oldName = this.name;
|
||||
String oldPrefix = this.prefix;
|
||||
String oldSuffix = this.suffix;
|
||||
boolean oldVisible = isVisibleFor(playerName());
|
||||
var oldColor = this.color;
|
||||
|
||||
this.name = MessageTranslator.convertMessageRaw(name, session().locale());
|
||||
@ -245,7 +245,7 @@ public final class Team {
|
||||
if (names.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
var containsSelf = names.contains(playerName());
|
||||
boolean containsSelf = names.contains(playerName());
|
||||
|
||||
for (Entity entity : session().getEntityCache().getEntities().values()) {
|
||||
if (names.contains(entity.teamIdentifier())) {
|
||||
@ -263,7 +263,7 @@ public final class Team {
|
||||
}
|
||||
|
||||
private void removeRemovedEntities(Set<String> names) {
|
||||
var containsSelf = names.contains(playerName());
|
||||
boolean containsSelf = names.contains(playerName());
|
||||
|
||||
var iterator = managedEntities.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -60,8 +60,8 @@ public final class SidebarDisplayScore extends DisplayScore {
|
||||
public void update(Objective objective) {
|
||||
markUpdated();
|
||||
|
||||
var finalName = reference.name();
|
||||
var displayName = reference.displayName();
|
||||
String finalName = reference.name();
|
||||
String displayName = reference.displayName();
|
||||
|
||||
if (displayName != null) {
|
||||
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.objects.Object2ObjectOpenHashMap;
|
||||
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 org.geysermc.geyser.entity.type.Entity;
|
||||
import org.geysermc.geyser.entity.type.Tickable;
|
||||
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
||||
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
|
||||
* for that player (e.g. seeing vanished players from /vanish)
|
||||
@ -133,7 +136,7 @@ public class EntityCache {
|
||||
|
||||
public void addPlayerEntity(PlayerEntity entity) {
|
||||
// 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) {
|
||||
return;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren