mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-28 03:19:14 +00:00
略微优化
This commit is contained in:
@@ -6,7 +6,6 @@ import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||
import net.momirealms.craftengine.core.block.parser.BlockStateParser;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Minecart;
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.momirealms.craftengine.bukkit.plugin.network.handler;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.craftengine.bukkit.entity.data.BaseEntityData;
|
||||
import net.momirealms.craftengine.bukkit.entity.data.BlockDisplayEntityData;
|
||||
import net.momirealms.craftengine.bukkit.entity.data.PrimedTntData;
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.plugin.network.PacketConsumers;
|
||||
|
||||
@@ -6,7 +6,6 @@ import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import net.momirealms.craftengine.core.item.ItemDataModifierFactory;
|
||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||
import net.momirealms.craftengine.core.plugin.text.minimessage.FormattedLine;
|
||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import net.momirealms.craftengine.core.item.ItemDataModifierFactory;
|
||||
import net.momirealms.craftengine.core.plugin.text.minimessage.FormattedLine;
|
||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
@@ -49,6 +49,9 @@ public record Key(String namespace, String value) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Key key)) return false;
|
||||
// 先比value命中率高
|
||||
return this.value.equals(key.value()) && this.namespace.equals(key.namespace());
|
||||
@@ -56,7 +59,7 @@ public record Key(String namespace, String value) {
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return this.namespace + ":" + this.value;
|
||||
return asString();
|
||||
}
|
||||
|
||||
public String asString() {
|
||||
|
||||
@@ -71,14 +71,14 @@ public class ChunkPos {
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (o == null) return false;
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof ChunkPos chunkPos)) return false;
|
||||
return x == chunkPos.x && z == chunkPos.z;
|
||||
return this.longKey == chunkPos.longKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = x;
|
||||
result = 31 * result + z;
|
||||
return result;
|
||||
return Long.hashCode(this.longKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ public class CachedStorage<T extends WorldDataStorage> implements WorldDataStora
|
||||
this.chunkCache = Caffeine.newBuilder()
|
||||
.executor(CraftEngine.instance().scheduler().async())
|
||||
.scheduler(Scheduler.systemScheduler())
|
||||
.expireAfterAccess(30, TimeUnit.SECONDS)
|
||||
.initialCapacity(2048)
|
||||
.expireAfterAccess(60, TimeUnit.SECONDS)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user