mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Misc intellij suggestions
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
3e2ac14048
commit
c95ced9493
@ -1,7 +1,6 @@
|
||||
package net.minestom.server.command.builder.arguments;
|
||||
|
||||
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
|
||||
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
|
||||
import net.minestom.server.utils.StringUtils;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
|
@ -245,9 +245,9 @@ non-sealed class EventNodeImpl<T extends Event> implements EventNode<T> {
|
||||
for (Iterator<? extends @NotNull Graph> iterator = nextNodes.iterator(); iterator.hasNext(); ) {
|
||||
Graph next = iterator.next();
|
||||
if (iterator.hasNext()) {
|
||||
genToStringTree(buffer, childrenPrefix + '\u251C' + '\u2500' + " ", childrenPrefix + '\u2502' + " ", next);
|
||||
genToStringTree(buffer, childrenPrefix + '├' + '─' + " ", childrenPrefix + '│' + " ", next);
|
||||
} else {
|
||||
genToStringTree(buffer, childrenPrefix + '\u2514' + '\u2500' + " ", childrenPrefix + " ", next);
|
||||
genToStringTree(buffer, childrenPrefix + '└' + '─' + " ", childrenPrefix + " ", next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,8 @@ public class AnvilLoader implements IChunkLoader {
|
||||
private final Path levelPath;
|
||||
private final Path regionPath;
|
||||
|
||||
private static class RegionCache extends ConcurrentHashMap<IntIntImmutablePair, Set<IntIntImmutablePair>> {}
|
||||
private static class RegionCache extends ConcurrentHashMap<IntIntImmutablePair, Set<IntIntImmutablePair>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the chunks currently loaded per region. Used to determine when a region file can be unloaded.
|
||||
@ -49,12 +50,7 @@ public class AnvilLoader implements IChunkLoader {
|
||||
private final RegionCache perRegionLoadedChunks = new RegionCache();
|
||||
|
||||
// thread local to avoid contention issues with locks
|
||||
private final ThreadLocal<Int2ObjectMap<BlockState>> blockStateId2ObjectCacheTLS = new ThreadLocal<>() {
|
||||
@Override
|
||||
protected Int2ObjectMap<BlockState> initialValue() {
|
||||
return new Int2ObjectArrayMap<>();
|
||||
}
|
||||
};
|
||||
private final ThreadLocal<Int2ObjectMap<BlockState>> blockStateId2ObjectCacheTLS = ThreadLocal.withInitial(() -> new Int2ObjectArrayMap<>());
|
||||
|
||||
public AnvilLoader(@NotNull Path path) {
|
||||
this.path = path;
|
||||
@ -137,7 +133,7 @@ public class AnvilLoader implements IChunkLoader {
|
||||
int regionZ = CoordinatesKt.chunkToRegion(chunkZ);
|
||||
var chunks = perRegionLoadedChunks.computeIfAbsent(new IntIntImmutablePair(regionX, regionZ), r -> new HashSet<>()); // region cache may have been removed on another thread due to unloadChunk
|
||||
chunks.add(new IntIntImmutablePair(chunkX, chunkZ));
|
||||
};
|
||||
}
|
||||
return CompletableFuture.completedFuture(chunk);
|
||||
}
|
||||
|
||||
@ -153,7 +149,7 @@ public class AnvilLoader implements IChunkLoader {
|
||||
synchronized (perRegionLoadedChunks) {
|
||||
Set<IntIntImmutablePair> previousVersion = perRegionLoadedChunks.put(new IntIntImmutablePair(regionX, regionZ), new HashSet<>());
|
||||
assert previousVersion == null : "The AnvilLoader cache should not already have data for this region.";
|
||||
};
|
||||
}
|
||||
return new RegionFile(new RandomAccessFile(regionPath.toFile(), "rw"), regionX, regionZ, instance.getDimensionType().getMinY(), instance.getDimensionType().getMaxY() - 1);
|
||||
} catch (IOException | AnvilException e) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
@ -440,6 +436,7 @@ public class AnvilLoader implements IChunkLoader {
|
||||
|
||||
/**
|
||||
* Unload a given chunk. Also unloads a region when no chunk from that region is loaded.
|
||||
*
|
||||
* @param chunk the chunk to unload
|
||||
*/
|
||||
@Override
|
||||
@ -466,7 +463,7 @@ public class AnvilLoader implements IChunkLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,7 +3,6 @@ package net.minestom.server.instance.generator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Generator {
|
||||
|
@ -1,9 +1,7 @@
|
||||
package net.minestom.server.item;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.item.attribute.ItemAttribute;
|
||||
import net.minestom.server.registry.ProtocolObject;
|
||||
import net.minestom.server.tag.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -32,31 +32,31 @@ public final class Messenger {
|
||||
static {
|
||||
try {
|
||||
CHAT_REGISTRY = (NBTCompound) new SNBTParser(new StringReader(
|
||||
"{\n" +
|
||||
" \"type\": \"minecraft:chat_type\",\n" +
|
||||
" \"value\": [\n" +
|
||||
" {\n" +
|
||||
" \"name\":\"minecraft:chat\",\n" +
|
||||
" \"id\":1,\n" +
|
||||
" \"element\":{\n" +
|
||||
" \"chat\":{\n" +
|
||||
" \"translation_key\":\"chat.type.text\",\n" +
|
||||
" \"parameters\":[\n" +
|
||||
" \"sender\",\n" +
|
||||
" \"content\"\n" +
|
||||
" ]\n" +
|
||||
" },\n" +
|
||||
" \"narration\":{\n" +
|
||||
" \"translation_key\":\"chat.type.text.narrate\",\n" +
|
||||
" \"parameters\":[\n" +
|
||||
" \"sender\",\n" +
|
||||
" \"content\"\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }" +
|
||||
" ]\n" +
|
||||
"}"
|
||||
"""
|
||||
{
|
||||
"type": "minecraft:chat_type",
|
||||
"value": [
|
||||
{
|
||||
"name":"minecraft:chat",
|
||||
"id":1,
|
||||
"element":{
|
||||
"chat":{
|
||||
"translation_key":"chat.type.text",
|
||||
"parameters":[
|
||||
"sender",
|
||||
"content"
|
||||
]
|
||||
},
|
||||
"narration":{
|
||||
"translation_key":"chat.type.text.narrate",
|
||||
"parameters":[
|
||||
"sender",
|
||||
"content"
|
||||
]
|
||||
}
|
||||
}
|
||||
} ]
|
||||
}"""
|
||||
)).parse();
|
||||
} catch (NBTException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@ -15,7 +15,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public record AdvancementsPacket(boolean reset, @NotNull List<AdvancementMapping> advancementMappings,
|
||||
@NotNull List<String> identifiersToRemove,
|
||||
|
@ -10,7 +10,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
|
@ -12,7 +12,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public record SetSlotPacket(byte windowId, int stateId, short slot,
|
||||
|
@ -12,9 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public record WindowItemsPacket(byte windowId, int stateId, @NotNull List<ItemStack> items,
|
||||
@NotNull ItemStack carriedItem) implements ComponentHoldingServerPacket {
|
||||
|
@ -89,10 +89,10 @@ public enum ServerListPingType {
|
||||
final String motd = SECTION.serialize(data.getDescription());
|
||||
|
||||
if (supportsVersions) {
|
||||
return String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d",
|
||||
return String.format("§1\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d",
|
||||
data.getProtocol(), data.getVersion(), motd, data.getOnline(), data.getMaxPlayer());
|
||||
} else {
|
||||
return String.format("%s\u00a7%d\u00a7%d", motd, data.getOnline(), data.getMaxPlayer());
|
||||
return String.format("%s§%d§%d", motd, data.getOnline(), data.getMaxPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ public class Sidebar implements Scoreboard {
|
||||
* Creates a new {@link SidebarTeam}
|
||||
*/
|
||||
private void createTeam() {
|
||||
this.entityName = '\u00A7' + Integer.toHexString(colorName);
|
||||
this.entityName = '§' + Integer.toHexString(colorName);
|
||||
|
||||
this.sidebarTeam = new SidebarTeam(teamName, content, Component.empty(), entityName);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public final class MinestomConsoleWriter extends AbstractFormatPatternWriter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
public void close() {
|
||||
// EMPTY
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.utils;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.intellij.lang.annotations.Pattern;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -95,6 +96,7 @@ public final class NamespaceID implements CharSequence, Key {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pattern("[a-z0-9_\\-.]+")
|
||||
public @NotNull String namespace() {
|
||||
return this.domain;
|
||||
}
|
||||
|
@ -30,9 +30,7 @@ public record BiomeParticle(float probability, Option option) {
|
||||
nbtCompound.setString("Name", block.name());
|
||||
Map<String, String> propertiesMap = block.properties();
|
||||
if (propertiesMap.size() != 0) {
|
||||
nbtCompound.set("Properties", NBT.Compound(p -> {
|
||||
propertiesMap.forEach(p::setString);
|
||||
}));
|
||||
nbtCompound.set("Properties", NBT.Compound(p -> propertiesMap.forEach(p::setString)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -59,9 +57,7 @@ public record BiomeParticle(float probability, Option option) {
|
||||
public NBTCompound toNbt() {
|
||||
//todo test count might be wrong type
|
||||
NBTCompound nbtCompound = item.meta().toNBT();
|
||||
return nbtCompound.modify(n -> {
|
||||
n.setString("type", type);
|
||||
});
|
||||
return nbtCompound.modify(n -> n.setString("type", type));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user