Update bedrock protocol lib and remove trove

This commit is contained in:
Redned 2020-03-18 16:10:28 -05:00 committed by RednedEpic
parent 51050e3868
commit 62b183a387
9 changed files with 55 additions and 20 deletions

View file

@ -39,13 +39,37 @@
<dependency> <dependency>
<groupId>com.nukkitx.protocol</groupId> <groupId>com.nukkitx.protocol</groupId>
<artifactId>bedrock-v389</artifactId> <artifactId>bedrock-v389</artifactId>
<version>2.5.1</version> <version>2.5.4</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-int-int-maps</artifactId>
<version>8.3.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.nukkitx</groupId> <groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-lite</artifactId> <artifactId>fastutil-int-float-maps</artifactId>
<version>8.1.1</version> <version>8.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-long-long-maps</artifactId>
<version>8.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.fastutil</groupId>
<artifactId>fastutil-object-long-maps</artifactId>
<version>8.3.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>

View file

@ -26,6 +26,9 @@
package org.geysermc.connector.network.session.cache; package org.geysermc.connector.network.session.cache;
import it.unimi.dsi.fastutil.longs.*; import it.unimi.dsi.fastutil.longs.*;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.Getter; import lombok.Getter;
import org.geysermc.connector.entity.Entity; import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.PlayerEntity; import org.geysermc.connector.entity.PlayerEntity;
@ -45,7 +48,7 @@ public class EntityCache {
private Long2ObjectMap<Entity> entities = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<>()); private Long2ObjectMap<Entity> entities = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<>());
private Long2LongMap entityIdTranslations = Long2LongMaps.synchronize(new Long2LongOpenHashMap()); private Long2LongMap entityIdTranslations = Long2LongMaps.synchronize(new Long2LongOpenHashMap());
private Map<UUID, PlayerEntity> playerEntities = Collections.synchronizedMap(new HashMap<>()); private Map<UUID, PlayerEntity> playerEntities = Collections.synchronizedMap(new HashMap<>());
private Map<UUID, Long> bossbars = new HashMap<>(); private Object2LongMap<UUID> bossbars = new Object2LongOpenHashMap<>();
@Getter @Getter
private AtomicLong nextEntityId = new AtomicLong(2L); private AtomicLong nextEntityId = new AtomicLong(2L);
@ -92,7 +95,7 @@ public class EntityCache {
} }
public <T extends Entity> Set<T> getEntitiesByType(Class<T> entityType) { public <T extends Entity> Set<T> getEntitiesByType(Class<T> entityType) {
Set<T> entitiesOfType = new HashSet<>(); Set<T> entitiesOfType = new ObjectOpenHashSet<>();
for (Entity entity : (entityType == PlayerEntity.class ? playerEntities : entities).values()) { for (Entity entity : (entityType == PlayerEntity.class ? playerEntities : entities).values()) {
if (entity.is(entityType)) { if (entity.is(entityType)) {
entitiesOfType.add(entity.as(entityType)); entitiesOfType.add(entity.as(entityType));

View file

@ -32,9 +32,14 @@ import com.nukkitx.nbt.NbtUtils;
import com.nukkitx.nbt.stream.NBTInputStream; import com.nukkitx.nbt.stream.NBTInputStream;
import com.nukkitx.nbt.tag.CompoundTag; import com.nukkitx.nbt.tag.CompoundTag;
import com.nukkitx.nbt.tag.ListTag; import com.nukkitx.nbt.tag.ListTag;
import gnu.trove.map.TObjectIntMap; import it.unimi.dsi.fastutil.ints.Int2IntMap;
import gnu.trove.map.hash.TObjectIntHashMap; import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.utils.Toolbox; import org.geysermc.connector.utils.Toolbox;
@ -78,7 +83,8 @@ public class BlockTranslator {
} catch (Exception e) { } catch (Exception e) {
throw new AssertionError("Unable to load Java block mappings", e); throw new AssertionError("Unable to load Java block mappings", e);
} }
TObjectIntMap<CompoundTag> addedStatesMap = new TObjectIntHashMap<>(512, 0.5f, -1); Object2IntMap<CompoundTag> addedStatesMap = new Object2IntOpenHashMap<>();
addedStatesMap.defaultReturnValue(-1);
List<CompoundTag> paletteList = new ArrayList<>(); List<CompoundTag> paletteList = new ArrayList<>();
int waterRuntimeId = -1; int waterRuntimeId = -1;

View file

@ -31,11 +31,11 @@ import com.nukkitx.protocol.bedrock.data.EntityFlag;
import com.nukkitx.protocol.bedrock.data.PlayerPermission; import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket; import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket; import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.geysermc.connector.entity.Entity; import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ServerPlayerAbilitiesPacket> { public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ServerPlayerAbilitiesPacket> {
@ -54,7 +54,7 @@ public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ServerPlayer
entityDataPacket.getMetadata().putAll(metadata); entityDataPacket.getMetadata().putAll(metadata);
session.getUpstream().sendPacket(entityDataPacket); session.getUpstream().sendPacket(entityDataPacket);
Set<AdventureSettingsPacket.Flag> playerFlags = new HashSet<>(); Set<AdventureSettingsPacket.Flag> playerFlags = new ObjectOpenHashSet<>();
playerFlags.add(AdventureSettingsPacket.Flag.AUTO_JUMP); playerFlags.add(AdventureSettingsPacket.Flag.AUTO_JUMP);
if (packet.isCanFly()) if (packet.isCanFly())
playerFlags.add(AdventureSettingsPacket.Flag.MAY_FLY); playerFlags.add(AdventureSettingsPacket.Flag.MAY_FLY);

View file

@ -27,6 +27,7 @@ package org.geysermc.connector.network.translators.java.scoreboard;
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
@ -73,6 +74,6 @@ public class JavaTeamTranslator extends PacketTranslator<ServerTeamPacket> {
} }
private Set<String> toPlayerSet(String[] players) { private Set<String> toPlayerSet(String[] players) {
return new HashSet<>(Arrays.asList(players)); return new ObjectOpenHashSet<>(Arrays.asList(players));
} }
} }

View file

@ -36,11 +36,11 @@ import com.nukkitx.protocol.bedrock.data.EntityFlag;
import com.nukkitx.protocol.bedrock.data.LevelEventType; import com.nukkitx.protocol.bedrock.data.LevelEventType;
import com.nukkitx.protocol.bedrock.data.PlayerPermission; import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.*; import com.nukkitx.protocol.bedrock.packet.*;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.geysermc.connector.entity.Entity; import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -68,7 +68,7 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
session.getUpstream().sendPacket(stopRainPacket); session.getUpstream().sendPacket(stopRainPacket);
break; break;
case CHANGE_GAMEMODE: case CHANGE_GAMEMODE:
Set<AdventureSettingsPacket.Flag> playerFlags = new HashSet<>(); Set<AdventureSettingsPacket.Flag> playerFlags = new ObjectOpenHashSet<>();
GameMode gameMode = (GameMode) packet.getValue(); GameMode gameMode = (GameMode) packet.getValue();
if (gameMode == GameMode.ADVENTURE) if (gameMode == GameMode.ADVENTURE)
playerFlags.add(AdventureSettingsPacket.Flag.IMMUTABLE_WORLD); playerFlags.add(AdventureSettingsPacket.Flag.IMMUTABLE_WORLD);

View file

@ -30,6 +30,7 @@ import com.nukkitx.protocol.bedrock.data.ScoreInfo;
import com.nukkitx.protocol.bedrock.packet.RemoveObjectivePacket; import com.nukkitx.protocol.bedrock.packet.RemoveObjectivePacket;
import com.nukkitx.protocol.bedrock.packet.SetDisplayObjectivePacket; import com.nukkitx.protocol.bedrock.packet.SetDisplayObjectivePacket;
import com.nukkitx.protocol.bedrock.packet.SetScorePacket; import com.nukkitx.protocol.bedrock.packet.SetScorePacket;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.Getter; import lombok.Getter;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
@ -113,7 +114,7 @@ public class Scoreboard {
} }
public void onUpdate() { public void onUpdate() {
Set<Objective> changedObjectives = new HashSet<>(); Set<Objective> changedObjectives = new ObjectOpenHashSet<>();
List<ScoreInfo> addScores = new ArrayList<>(); List<ScoreInfo> addScores = new ArrayList<>();
List<ScoreInfo> removeScores = new ArrayList<>(); List<ScoreInfo> removeScores = new ArrayList<>();
@ -133,7 +134,7 @@ public class Scoreboard {
boolean hasUpdate = globalUpdate; boolean hasUpdate = globalUpdate;
List<Score> handledScores = new ArrayList<>(); List<Score> handledScores = new ArrayList<>();
for (String identifier : new HashSet<>(objective.getScores().keySet())) { for (String identifier : new ObjectOpenHashSet<>(objective.getScores().keySet())) {
Score score = objective.getScores().get(identifier); Score score = objective.getScores().get(identifier);
Team team = score.getTeam(); Team team = score.getTeam();

View file

@ -25,12 +25,12 @@
package org.geysermc.connector.scoreboard; package org.geysermc.connector.scoreboard;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -45,7 +45,7 @@ public class Team {
private String name; private String name;
private String prefix; private String prefix;
private String suffix; private String suffix;
private Set<String> entities = new HashSet<>(); private Set<String> entities = new ObjectOpenHashSet<>();
public Team(Scoreboard scoreboard, String id) { public Team(Scoreboard scoreboard, String id) {

View file

@ -48,7 +48,7 @@ public class Toolbox {
public static final ObjectMapper JSON_MAPPER = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES); public static final ObjectMapper JSON_MAPPER = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
public static final CompoundTag BIOMES; public static final CompoundTag BIOMES;
public static final Collection<StartGamePacket.ItemEntry> ITEMS = new ArrayList<>(); public static final List<StartGamePacket.ItemEntry> ITEMS = new ArrayList<>();
public static final Int2ObjectMap<ItemEntry> ITEM_ENTRIES = new Int2ObjectOpenHashMap<>(); public static final Int2ObjectMap<ItemEntry> ITEM_ENTRIES = new Int2ObjectOpenHashMap<>();