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