mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-28 11:19:08 +00:00
replace guava ImmutableList with fastutil ObjectImmutableList
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
+ return this.tickInformationCollector.latestTickInformation();
|
||||
+ }
|
||||
+
|
||||
+ public final ImmutableList<me.samsuik.sakura.tps.ServerTickInformation> tickHistory(final long from, final long to) {
|
||||
+ public final it.unimi.dsi.fastutil.objects.ObjectImmutableList<me.samsuik.sakura.tps.ServerTickInformation> tickHistory(final long from, final long to) {
|
||||
+ return this.tickInformationCollector.collect(from, to);
|
||||
+ }
|
||||
+ // Sakura end - track tick information
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.samsuik.sakura.command.subcommands;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
|
||||
import me.samsuik.sakura.command.BaseSubCommand;
|
||||
import me.samsuik.sakura.tps.ServerTickInformation;
|
||||
import me.samsuik.sakura.tps.graph.BuiltComponentCanvas;
|
||||
@@ -38,7 +38,7 @@ public final class TPSCommand extends BaseSubCommand {
|
||||
scale = this.dynamicScale(identifier);
|
||||
}
|
||||
|
||||
final ImmutableList<ServerTickInformation> tickHistory = MinecraftServer.getServer().tickHistory(identifier - GRAPH_WIDTH, identifier);
|
||||
final ObjectImmutableList<ServerTickInformation> tickHistory = MinecraftServer.getServer().tickHistory(identifier - GRAPH_WIDTH, identifier);
|
||||
final DetailedTPSGraph graph = new DetailedTPSGraph(GRAPH_WIDTH, GRAPH_HEIGHT, scale, tickHistory);
|
||||
final BuiltComponentCanvas canvas = graph.plot();
|
||||
|
||||
@@ -56,7 +56,7 @@ public final class TPSCommand extends BaseSubCommand {
|
||||
}
|
||||
|
||||
private double dynamicScale(final long identifier) {
|
||||
final ImmutableList<ServerTickInformation> tickHistory = MinecraftServer.getServer().tickHistory(identifier - 5, identifier);
|
||||
final ObjectImmutableList<ServerTickInformation> tickHistory = MinecraftServer.getServer().tickHistory(identifier - 5, identifier);
|
||||
final double averageTps = tickHistory.stream()
|
||||
.mapToDouble(ServerTickInformation::tps)
|
||||
.average()
|
||||
|
||||
@@ -2,10 +2,10 @@ package me.samsuik.sakura.player.gui;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Multimap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
|
||||
import me.samsuik.sakura.player.gui.components.GuiComponent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -38,12 +38,12 @@ public final class FeatureGuiInventory implements InventoryHolder {
|
||||
return this.gui;
|
||||
}
|
||||
|
||||
public ImmutableList<GuiComponent> getComponents() {
|
||||
return ImmutableList.copyOf(this.componentKeys.keySet());
|
||||
public ObjectImmutableList<GuiComponent> getComponents() {
|
||||
return new ObjectImmutableList<>(this.componentKeys.keySet());
|
||||
}
|
||||
|
||||
public ImmutableList<GuiComponent> findComponents(final NamespacedKey key) {
|
||||
return ImmutableList.copyOf(this.componentsUnderKey.get(key));
|
||||
public ObjectImmutableList<GuiComponent> findComponents(final NamespacedKey key) {
|
||||
return new ObjectImmutableList<>(this.componentsUnderKey.get(key));
|
||||
}
|
||||
|
||||
public Optional<GuiComponent> findFirst(final NamespacedKey key) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.samsuik.sakura.player.visibility;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||
import me.samsuik.sakura.player.gui.ItemStackUtil;
|
||||
@@ -15,7 +15,7 @@ import java.util.Locale;
|
||||
|
||||
@NullMarked
|
||||
public final class VisibilityGuiItems {
|
||||
static final Reference2ObjectMap<VisibilityType, ImmutableList<ItemStack>> GUI_ITEMS = new Reference2ObjectOpenHashMap<>();
|
||||
static final Reference2ObjectMap<VisibilityType, ObjectImmutableList<ItemStack>> GUI_ITEMS = new Reference2ObjectOpenHashMap<>();
|
||||
static final Reference2ObjectMap<VisibilityState, ItemStack> TOGGLE_BUTTON_ITEMS = new Reference2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
@@ -28,9 +28,9 @@ public final class VisibilityGuiItems {
|
||||
|
||||
for (final VisibilityType type : VisibilityTypes.types()) {
|
||||
final ItemStack item = items.get(type);
|
||||
final ImmutableList<ItemStack> stateItems = type.states().stream()
|
||||
final ObjectImmutableList<ItemStack> stateItems = type.states().stream()
|
||||
.map(state -> createItemForState(item, state))
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
.collect(ObjectImmutableList.toList());
|
||||
GUI_ITEMS.put(type, stateItems);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package me.samsuik.sakura.tps;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
@@ -53,7 +53,7 @@ public final class TickInformationCollector {
|
||||
this.tickSamples.add(timeTaken);
|
||||
}
|
||||
|
||||
public ImmutableList<ServerTickInformation> collect(final long from, final long to) {
|
||||
public ObjectImmutableList<ServerTickInformation> collect(final long from, final long to) {
|
||||
final List<ServerTickInformation> collected = new ObjectArrayList<>();
|
||||
for (final ServerTickInformation tickInformation : this.collectedInformation.reversed()) {
|
||||
if (tickInformation.identifier() >= from && tickInformation.identifier() < to) {
|
||||
@@ -68,6 +68,6 @@ public final class TickInformationCollector {
|
||||
collected.add(index, ServerTickInformation.UNKNOWN);
|
||||
}
|
||||
|
||||
return ImmutableList.copyOf(collected);
|
||||
return new ObjectImmutableList<>(collected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.samsuik.sakura.tps.graph;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class BuiltComponentCanvas {
|
||||
this.components.add(component);
|
||||
}
|
||||
|
||||
public ImmutableList<Component> components() {
|
||||
return ImmutableList.copyOf(this.components);
|
||||
public ObjectImmutableList<Component> components() {
|
||||
return new ObjectImmutableList<>(this.components);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user