diff --git a/.editorconfig b/.editorconfig index 227a561f..fe005408 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,7 +8,7 @@ indent_style = space insert_final_newline = false max_line_length = 1000 tab_width = 4 -ij_continuation_indent_size = 8 +ij_continuation_indent_size = 4 ij_formatter_off_tag = @formatter:off ij_formatter_on_tag = @formatter:on ij_formatter_tags_enabled = true diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotCommand.java index 8ac02d27..5c235e89 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotCommand.java @@ -54,8 +54,8 @@ public class BotCommand extends Command { commands.put(Set.of("list"), new BotListCommand()); return commands.entrySet().stream() - .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }); @NotNull diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/MojangAPI.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/MojangAPI.java index 4162df88..5ceb6bfe 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/MojangAPI.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/MojangAPI.java @@ -28,9 +28,9 @@ public class MojangAPI { public static String[] pullFromAPI(String name) { try { String uuid = JsonParser.parseReader(new InputStreamReader(URI.create("https://api.mojang.com/users/profiles/minecraft/" + name).toURL().openStream())) - .getAsJsonObject().get("id").getAsString(); + .getAsJsonObject().get("id").getAsString(); JsonObject property = JsonParser.parseReader(new InputStreamReader(URI.create("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false").toURL().openStream())) - .getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + .getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); return new String[]{property.get("value").getAsString(), property.get("signature").getAsString()}; } catch (IOException | IllegalStateException | IllegalArgumentException e) { return null; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java index 94aee660..0475837d 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java @@ -142,10 +142,10 @@ public class ServerBot extends ServerPlayer { public void renderAll() { this.server.getPlayerList().getPlayers().forEach( - player -> { - this.sendPlayerInfo(player); - this.sendFakeDataIfNeed(player, false); - } + player -> { + this.sendPlayerInfo(player); + this.sendFakeDataIfNeed(player, false); + } ); } @@ -295,7 +295,7 @@ public class ServerBot extends ServerPlayer { if (this.fallDistance > 0.0F) { state.getBlock().fallOn(serverLevel, state, pos, this, this.fallDistance); serverLevel.gameEvent(GameEvent.HIT_GROUND, this.position(), - GameEvent.Context.of(this, this.mainSupportingBlockPos.map(supportingPos -> this.level().getBlockState(supportingPos)).orElse(state)) + GameEvent.Context.of(this, this.mainSupportingBlockPos.map(supportingPos -> this.level().getBlockState(supportingPos)).orElse(state)) ); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SimulationDistanceConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SimulationDistanceConfig.java index 3ec252ca..6fba9a42 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SimulationDistanceConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SimulationDistanceConfig.java @@ -40,7 +40,7 @@ public class SimulationDistanceConfig extends AbstractBotConfig { @Override public void load(@NotNull CompoundTag nbt) { - this.setValue(new CommandArgumentResult(new ArrayList<>(){{ + this.setValue(new CommandArgumentResult(new ArrayList<>() {{ add(nbt.getInt("simulation_distance")); }})); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SpawnPhantomConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SpawnPhantomConfig.java index 8e4a8e06..374ef8b0 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SpawnPhantomConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SpawnPhantomConfig.java @@ -32,8 +32,8 @@ public class SpawnPhantomConfig extends AbstractBotConfig { @Override public List getMessage() { return List.of( - bot.getScoreboardName() + "'s spawn_phantom: " + this.getValue(), - bot.getScoreboardName() + "'s not_sleeping_ticks: " + bot.notSleepTicks + bot.getScoreboardName() + "'s spawn_phantom: " + this.getValue(), + bot.getScoreboardName() + "'s not_sleeping_ticks: " + bot.notSleepTicks ); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/subcommands/BotActionCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/subcommands/BotActionCommand.java index cfe1b38b..5c573386 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/subcommands/BotActionCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/subcommands/BotActionCommand.java @@ -59,7 +59,7 @@ public class BotActionCommand implements LeavesSubcommand { for (int i = 0; i < bot.getBotActions().size(); i++) { AbstractBotAction action = bot.getBotActions().get(i); BotActionStopEvent event = new BotActionStopEvent( - bot.getBukkitEntity(), action.getName(), action.getUUID(), BotActionStopEvent.Reason.COMMAND, sender + bot.getBukkitEntity(), action.getName(), action.getUUID(), BotActionStopEvent.Reason.COMMAND, sender ); event.callEvent(); if (!event.isCancelled()) { @@ -78,7 +78,7 @@ public class BotActionCommand implements LeavesSubcommand { AbstractBotAction action = bot.getBotActions().get(i); BotActionStopEvent event = new BotActionStopEvent( - bot.getBukkitEntity(), action.getName(), action.getUUID(), BotActionStopEvent.Reason.COMMAND, sender + bot.getBukkitEntity(), action.getName(), action.getUUID(), BotActionStopEvent.Reason.COMMAND, sender ); event.callEvent(); if (!event.isCancelled()) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/LeavesCommandUtil.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/LeavesCommandUtil.java index 38bcf396..40fb2fd0 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/LeavesCommandUtil.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/LeavesCommandUtil.java @@ -27,9 +27,9 @@ public class LeavesCommandUtil { // Code from Mojang - copyright them public static List getListMatchingLast( - final CommandSender sender, - final String[] args, - final String... matches + final CommandSender sender, + final String[] args, + final String... matches ) { return getListMatchingLast(sender, args, Arrays.asList(matches)); } @@ -39,19 +39,19 @@ public class LeavesCommandUtil { } public static List getListMatchingLast( - final CommandSender sender, - final String[] strings, - final Collection collection + final CommandSender sender, + final String[] strings, + final Collection collection ) { return getListMatchingLast(sender, strings, collection, LeavesCommand.BASE_PERM, "bukkit.command.leaves"); } public static List getListMatchingLast( - final CommandSender sender, - final String[] strings, - final Collection collection, - final String basePermission, - final String overridePermission + final CommandSender sender, + final String[] strings, + final Collection collection, + final String basePermission, + final String overridePermission ) { String last = strings[strings.length - 1]; ArrayList results = Lists.newArrayList(); @@ -85,10 +85,10 @@ public class LeavesCommandUtil { // end copy stuff public static List getListClosestMatchingLast( - final CommandSender sender, - final String last, - final Collection collection, - final String overridePermission + final CommandSender sender, + final String last, + final Collection collection, + final String overridePermission ) { ArrayList candidates = Lists.newArrayList(); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/subcommands/ConfigCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/subcommands/ConfigCommand.java index 12195071..8ec9bd62 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/subcommands/ConfigCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/subcommands/ConfigCommand.java @@ -30,9 +30,9 @@ public class ConfigCommand implements LeavesSubcommand { VerifiedConfig verifiedConfig = GlobalConfigManager.getVerifiedConfig(args[0]); if (verifiedConfig == null) { sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), - Component.text("Config ", NamedTextColor.GRAY), - Component.text(args[0], NamedTextColor.RED), - Component.text(" is Not Found.", NamedTextColor.GRAY) + Component.text("Config ", NamedTextColor.GRAY), + Component.text(args[0], NamedTextColor.RED), + Component.text(" is Not Found.", NamedTextColor.GRAY) )); return true; } @@ -41,25 +41,25 @@ public class ConfigCommand implements LeavesSubcommand { try { verifiedConfig.set(args[1]); sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), - Component.text("Config ", NamedTextColor.GRAY), - Component.text(args[0], NamedTextColor.AQUA), - Component.text(" changed to ", NamedTextColor.GRAY), - Component.text(verifiedConfig.getString(), NamedTextColor.AQUA) + Component.text("Config ", NamedTextColor.GRAY), + Component.text(args[0], NamedTextColor.AQUA), + Component.text(" changed to ", NamedTextColor.GRAY), + Component.text(verifiedConfig.getString(), NamedTextColor.AQUA) )); } catch (IllegalArgumentException exception) { sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), - Component.text("Config ", NamedTextColor.GRAY), - Component.text(args[0], NamedTextColor.RED), - Component.text(" modify error by ", NamedTextColor.GRAY), - Component.text(exception.getMessage(), NamedTextColor.RED) + Component.text("Config ", NamedTextColor.GRAY), + Component.text(args[0], NamedTextColor.RED), + Component.text(" modify error by ", NamedTextColor.GRAY), + Component.text(exception.getMessage(), NamedTextColor.RED) )); } } else { sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), - Component.text("Config ", NamedTextColor.GRAY), - Component.text(args[0], NamedTextColor.AQUA), - Component.text(" value is ", NamedTextColor.GRAY), - Component.text(verifiedConfig.getString(), NamedTextColor.AQUA) + Component.text("Config ", NamedTextColor.GRAY), + Component.text(args[0], NamedTextColor.AQUA), + Component.text(" value is ", NamedTextColor.GRAY), + Component.text(verifiedConfig.getString(), NamedTextColor.AQUA) )); } @@ -86,7 +86,7 @@ public class ConfigCommand implements LeavesSubcommand { int dotIndex = arg.lastIndexOf("."); builder = builder.createOffset(builder.getInput().lastIndexOf(' ') + dotIndex + 2); LeavesCommandUtil.getListClosestMatchingLast(sender, arg.substring(dotIndex + 1), GlobalConfigManager.getVerifiedConfigSubPaths(arg), "bukkit.command.leaves.config") - .forEach(builder::suggest); + .forEach(builder::suggest); return builder.buildFuture(); } return null; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/plugin/provider/LeavesPluginProviderFactory.java b/leaves-server/src/main/java/org/leavesmc/leaves/plugin/provider/LeavesPluginProviderFactory.java index 35fe2f6a..29db4775 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/plugin/provider/LeavesPluginProviderFactory.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/plugin/provider/LeavesPluginProviderFactory.java @@ -33,7 +33,7 @@ public class LeavesPluginProviderFactory implements PluginTypeFactory reader) - .defaultOptions((options) -> - options.serializers((serializers) -> - serializers.register(new ScalarSerializer<>(ApiVersion.class) { - @Override - public ApiVersion deserialize(final Type type, final Object obj) throws SerializationException { - try { - final ApiVersion version = ApiVersion.getOrCreateVersion(obj.toString()); - if (version.isOlderThan(MINIMUM)) { - throw new SerializationException(version + " is too old for a leaves plugin!"); - } - return version; - } catch (final IllegalArgumentException e) { - throw new SerializationException(e); - } - } + .prettyPrinting(true) + .emitComments(true) + .emitJsonCompatible(true) + .source(() -> reader) + .defaultOptions((options) -> + options.serializers((serializers) -> + serializers.register(new ScalarSerializer<>(ApiVersion.class) { + @Override + public ApiVersion deserialize(final Type type, final Object obj) throws SerializationException { + try { + final ApiVersion version = ApiVersion.getOrCreateVersion(obj.toString()); + if (version.isOlderThan(MINIMUM)) { + throw new SerializationException(version + " is too old for a leaves plugin!"); + } + return version; + } catch (final IllegalArgumentException e) { + throw new SerializationException(e); + } + } - @Override - protected Object serialize(final ApiVersion item, final Predicate> typeSupported) { - return item.getVersionString(); - } - }) - .register(new EnumValueSerializer()) - .register(PermissionConfiguration.class, PermissionConfigurationSerializer.SERIALIZER) - .register(new ComponentSerializer()) - .registerAnnotatedObjects( - ObjectMapper.factoryBuilder() - .addConstraint(Constraint.class, new Constraint.Factory()) - .addConstraint(PluginConfigConstraints.PluginName.class, String.class, new PluginConfigConstraints.PluginName.Factory()) - .addConstraint(PluginConfigConstraints.PluginNameSpace.class, String.class, new PluginConfigConstraints.PluginNameSpace.Factory()) - .addNodeResolver(new FlattenedResolver.Factory()) - .build() - ) + @Override + protected Object serialize(final ApiVersion item, final Predicate> typeSupported) { + return item.getVersionString(); + } + }) + .register(new EnumValueSerializer()) + .register(PermissionConfiguration.class, PermissionConfigurationSerializer.SERIALIZER) + .register(new ComponentSerializer()) + .registerAnnotatedObjects( + ObjectMapper.factoryBuilder() + .addConstraint(Constraint.class, new Constraint.Factory()) + .addConstraint(PluginConfigConstraints.PluginName.class, String.class, new PluginConfigConstraints.PluginName.Factory()) + .addConstraint(PluginConfigConstraints.PluginNameSpace.class, String.class, new PluginConfigConstraints.PluginNameSpace.Factory()) + .addNodeResolver(new FlattenedResolver.Factory()) + .build() ) ) - .build(); + ) + .build(); CommentedConfigurationNode node = loader.load(); LegacyPaperMeta.migrate(node); LeavesPluginMeta pluginConfiguration = node.require(LeavesPluginMeta.class); if (!node.node("author").virtual()) { pluginConfiguration.authors = ImmutableList.builder() - .addAll(pluginConfiguration.authors) - .add(node.node("author").getString()) - .build(); + .addAll(pluginConfiguration.authors) + .add(node.node("author").getString()) + .build(); } return pluginConfiguration; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/profile/LeavesMinecraftSessionService.java b/leaves-server/src/main/java/org/leavesmc/leaves/profile/LeavesMinecraftSessionService.java index 609f79a5..49ef02e1 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/profile/LeavesMinecraftSessionService.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/profile/LeavesMinecraftSessionService.java @@ -85,8 +85,8 @@ public class LeavesMinecraftSessionService extends PaperMinecraftSessionService } final Set profileActions = response.profileActions().stream() - .map(ProfileAction::type) - .collect(Collectors.toSet()); + .map(ProfileAction::type) + .collect(Collectors.toSet()); return new ProfileResult(result1, profileActions); } } catch (final MinecraftClientException e) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/LitematicaEasyPlaceProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/LitematicaEasyPlaceProtocol.java index e9e8ad9c..fa8669dc 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/LitematicaEasyPlaceProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/LitematicaEasyPlaceProtocol.java @@ -26,32 +26,32 @@ import java.util.List; public class LitematicaEasyPlaceProtocol { public static final ImmutableSet> WHITELISTED_PROPERTIES = ImmutableSet.of( - BlockStateProperties.INVERTED, - BlockStateProperties.OPEN, - BlockStateProperties.BELL_ATTACHMENT, - BlockStateProperties.AXIS, - BlockStateProperties.BED_PART, - BlockStateProperties.HALF, - BlockStateProperties.ATTACH_FACE, - BlockStateProperties.CHEST_TYPE, - BlockStateProperties.MODE_COMPARATOR, - BlockStateProperties.DOOR_HINGE, - BlockStateProperties.FACING_HOPPER, - BlockStateProperties.HORIZONTAL_FACING, - BlockStateProperties.ORIENTATION, - BlockStateProperties.RAIL_SHAPE, - BlockStateProperties.RAIL_SHAPE_STRAIGHT, - BlockStateProperties.SLAB_TYPE, - BlockStateProperties.STAIRS_SHAPE, - BlockStateProperties.BITES, - BlockStateProperties.DELAY, - BlockStateProperties.NOTE, - BlockStateProperties.ROTATION_16 + BlockStateProperties.INVERTED, + BlockStateProperties.OPEN, + BlockStateProperties.BELL_ATTACHMENT, + BlockStateProperties.AXIS, + BlockStateProperties.BED_PART, + BlockStateProperties.HALF, + BlockStateProperties.ATTACH_FACE, + BlockStateProperties.CHEST_TYPE, + BlockStateProperties.MODE_COMPARATOR, + BlockStateProperties.DOOR_HINGE, + BlockStateProperties.FACING_HOPPER, + BlockStateProperties.HORIZONTAL_FACING, + BlockStateProperties.ORIENTATION, + BlockStateProperties.RAIL_SHAPE, + BlockStateProperties.RAIL_SHAPE_STRAIGHT, + BlockStateProperties.SLAB_TYPE, + BlockStateProperties.STAIRS_SHAPE, + BlockStateProperties.BITES, + BlockStateProperties.DELAY, + BlockStateProperties.NOTE, + BlockStateProperties.ROTATION_16 ); public static final ImmutableSet> BLACKLISTED_PROPERTIES = ImmutableSet.of( - BlockStateProperties.WATERLOGGED, - BlockStateProperties.POWERED + BlockStateProperties.WATERLOGGED, + BlockStateProperties.POWERED ); public static BlockState applyPlacementProtocol(BlockState state, BlockPlaceContext context) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java index b7cd2c86..fd71036f 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java @@ -163,7 +163,8 @@ public class PcaSyncProtocol { return; } } - case EVERYONE -> {} + case EVERYONE -> { + } case null -> LeavesLogger.LOGGER.warning("pcaSyncPlayerEntity wtf???"); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java index e27205f6..0d3a81fc 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java @@ -285,8 +285,8 @@ public class JadeProtocol { private static void rebuildShearableBlocks() { try { shearableBlocks = Collections.unmodifiableList(LootTableMineableCollector.execute( - MinecraftServer.getServer().reloadableRegistries().lookup().lookupOrThrow(Registries.LOOT_TABLE), - Items.SHEARS.getDefaultInstance() + MinecraftServer.getServer().reloadableRegistries().lookup().lookupOrThrow(Registries.LOOT_TABLE), + Items.SHEARS.getDefaultInstance() )); } catch (Throwable ignore) { shearableBlocks = List.of(); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java index 1be4efcc..3d40670d 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java @@ -14,9 +14,9 @@ public record ClientHandshakePayload(String protocolVersion) implements LeavesCu private static final ResourceLocation PACKET_CLIENT_HANDSHAKE = JadeProtocol.id("client_handshake"); private static final StreamCodec CODEC = StreamCodec.composite( - ByteBufCodecs.STRING_UTF8, - ClientHandshakePayload::protocolVersion, - ClientHandshakePayload::new); + ByteBufCodecs.STRING_UTF8, + ClientHandshakePayload::protocolVersion, + ClientHandshakePayload::new); @Override public void write(FriendlyByteBuf buf) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java index 5e5b4a0c..a152da5a 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java @@ -24,14 +24,14 @@ public record RequestBlockPayload(BlockAccessorImpl.SyncData data, List<@Nullabl private static final ResourceLocation PACKET_REQUEST_BLOCK = JadeProtocol.id("request_block"); private static final StreamCodec CODEC = StreamCodec.composite( - BlockAccessorImpl.SyncData.STREAM_CODEC, - RequestBlockPayload::data, - ByteBufCodecs.>list() - .apply(ByteBufCodecs.idMapper( - $ -> Objects.requireNonNull(blockDataProviders.idMapper()).byId($), - $ -> Objects.requireNonNull(blockDataProviders.idMapper()).getIdOrThrow($))), - RequestBlockPayload::dataProviders, - RequestBlockPayload::new); + BlockAccessorImpl.SyncData.STREAM_CODEC, + RequestBlockPayload::data, + ByteBufCodecs.>list() + .apply(ByteBufCodecs.idMapper( + $ -> Objects.requireNonNull(blockDataProviders.idMapper()).byId($), + $ -> Objects.requireNonNull(blockDataProviders.idMapper()).getIdOrThrow($))), + RequestBlockPayload::dataProviders, + RequestBlockPayload::new); @Override public void write(FriendlyByteBuf buf) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java index 515dc5d1..e55bcda8 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java @@ -24,15 +24,15 @@ public record RequestEntityPayload(EntityAccessorImpl.SyncData data, List<@Nulla private static final ResourceLocation PACKET_REQUEST_ENTITY = JadeProtocol.id("request_entity"); private static final StreamCodec CODEC = StreamCodec.composite( - EntityAccessorImpl.SyncData.STREAM_CODEC, - RequestEntityPayload::data, - ByteBufCodecs.>list() - .apply(ByteBufCodecs.idMapper( - $ -> Objects.requireNonNull(entityDataProviders.idMapper()).byId($), - $ -> Objects.requireNonNull(entityDataProviders.idMapper()).getIdOrThrow($) - )), - RequestEntityPayload::dataProviders, - RequestEntityPayload::new); + EntityAccessorImpl.SyncData.STREAM_CODEC, + RequestEntityPayload::data, + ByteBufCodecs.>list() + .apply(ByteBufCodecs.idMapper( + $ -> Objects.requireNonNull(entityDataProviders.idMapper()).byId($), + $ -> Objects.requireNonNull(entityDataProviders.idMapper()).getIdOrThrow($) + )), + RequestEntityPayload::dataProviders, + RequestEntityPayload::new); @Override diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java index f6a2ed7c..0fba9c36 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java @@ -24,15 +24,15 @@ public record ServerHandshakePayload(Map serverConfig, private static final ResourceLocation PACKET_SERVER_HANDSHAKE = JadeProtocol.id("server_handshake"); private static final StreamCodec CODEC = StreamCodec.composite( - ByteBufCodecs.map(Maps::newHashMapWithExpectedSize, ResourceLocation.STREAM_CODEC, PRIMITIVE_STREAM_CODEC), - ServerHandshakePayload::serverConfig, - ByteBufCodecs.registry(Registries.BLOCK).apply(ByteBufCodecs.list()), - ServerHandshakePayload::shearableBlocks, - ByteBufCodecs.list().apply(ResourceLocation.STREAM_CODEC), - ServerHandshakePayload::blockProviderIds, - ByteBufCodecs.list().apply(ResourceLocation.STREAM_CODEC), - ServerHandshakePayload::entityProviderIds, - ServerHandshakePayload::new); + ByteBufCodecs.map(Maps::newHashMapWithExpectedSize, ResourceLocation.STREAM_CODEC, PRIMITIVE_STREAM_CODEC), + ServerHandshakePayload::serverConfig, + ByteBufCodecs.registry(Registries.BLOCK).apply(ByteBufCodecs.list()), + ServerHandshakePayload::shearableBlocks, + ByteBufCodecs.list().apply(ResourceLocation.STREAM_CODEC), + ServerHandshakePayload::blockProviderIds, + ByteBufCodecs.list().apply(ResourceLocation.STREAM_CODEC), + ServerHandshakePayload::entityProviderIds, + ServerHandshakePayload::new); @Override public void write(FriendlyByteBuf buf) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java index 3efa3ceb..c9e00e50 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java @@ -123,7 +123,7 @@ public enum ItemStorageExtensionProvider implements IServerExtensionProvider accessor) { Object target = accessor.getTarget(); if (target == null && accessor instanceof BlockAccessor blockAccessor && - blockAccessor.getBlock() instanceof WorldlyContainerHolder holder) { + blockAccessor.getBlock() instanceof WorldlyContainerHolder holder) { return holder.getContainer(blockAccessor.getBlockState(), accessor.getLevel(), blockAccessor.getPosition()); } else if (target instanceof Container container) { return container; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java index ffc57187..74706271 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java @@ -19,16 +19,16 @@ public enum StatusEffectsProvider implements StreamServerDataProvider> STREAM_CODEC = ByteBufCodecs.list() - .apply(MobEffectInstance.STREAM_CODEC); + .apply(MobEffectInstance.STREAM_CODEC); private static final ResourceLocation MC_POTION_EFFECTS = JadeProtocol.mc_id("potion_effects"); @Override @Nullable public List streamData(@NotNull EntityAccessor accessor) { List effects = ((LivingEntity) accessor.getEntity()).getActiveEffects() - .stream() - .filter(MobEffectInstance::isVisible) - .toList(); + .stream() + .filter(MobEffectInstance::isVisible) + .toList(); return effects.isEmpty() ? null : effects; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java index a0a85361..47701b17 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java @@ -60,8 +60,8 @@ public class CommonUtil { public static Map.Entry>> getServerExtensionData( - Accessor accessor, - WrappedHierarchyLookup> lookup) { + Accessor accessor, + WrappedHierarchyLookup> lookup) { for (var provider : lookup.wrappedGet(accessor)) { List> groups; try { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java index 0070fd22..0b1a99db 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java @@ -117,9 +117,9 @@ public class HierarchyLookup implements IHierarchyLooku for (T provider : list) { if (set.contains(provider.getUid())) { throw new IllegalStateException("Duplicate UID: %s for %s".formatted(provider.getUid(), list.stream() - .filter(p -> p.getUid().equals(provider.getUid())) - .map(p -> p.getClass().getName()) - .toList() + .filter(p -> p.getUid().equals(provider.getUid())) + .map(p -> p.getClass().getName()) + .toList() )); } set.add(provider.getUid()); @@ -127,9 +127,9 @@ public class HierarchyLookup implements IHierarchyLooku }); objects = ImmutableListMultimap., T>builder() - .orderValuesBy(Comparator.comparingInt(priorityStore::byValue)) - .putAll(objects) - .build(); + .orderValuesBy(Comparator.comparingInt(priorityStore::byValue)) + .putAll(objects) + .build(); if (idMapped) { idMapper = createIdMapper(); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java index 0536309c..2e5ccafc 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java @@ -24,8 +24,8 @@ public interface IHierarchyLookup { default List mappedIds() { return Streams.stream(Objects.requireNonNull(idMapper())) - .map(IJadeProvider::getUid) - .toList(); + .map(IJadeProvider::getUid) + .toList(); } void register(Class clazz, T provider); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java index 408c81a0..68f93978 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java @@ -75,7 +75,7 @@ public class ItemCollector { updateCollectingProgress(mergedResult.getFirst()); return mergedResult; } - List partialResult = items.object2IntEntrySet().stream().limit(MAX_SIZE ).map(entry -> { + List partialResult = items.object2IntEntrySet().stream().limit(MAX_SIZE).map(entry -> { ItemDefinition def = entry.getKey(); return def.toStack(entry.getIntValue()); }).toList(); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java index cb5c8201..8069ee8e 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java @@ -47,8 +47,8 @@ public class PairHierarchyLookup implements IHierarchyL return firstList; } return ImmutableList.sortedCopyOf( - Comparator.comparingInt(JadeProtocol.priorities::byValue), - Iterables.concat(firstList, secondList) + Comparator.comparingInt(JadeProtocol.priorities::byValue), + Iterables.concat(firstList, secondList) ); }); } catch (ExecutionException e) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java index 520eadbf..ef22f89d 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java @@ -14,22 +14,22 @@ import java.util.Optional; public class ViewGroup { public static StreamCodec> codec(StreamCodec viewCodec) { return StreamCodec.composite( - ByteBufCodecs.list().apply(viewCodec), - $ -> $.views, - ByteBufCodecs.optional(ByteBufCodecs.STRING_UTF8), - $ -> Optional.ofNullable($.id), - ByteBufCodecs.optional(ByteBufCodecs.COMPOUND_TAG), - $ -> Optional.ofNullable($.extraData), - ViewGroup::new); + ByteBufCodecs.list().apply(viewCodec), + $ -> $.views, + ByteBufCodecs.optional(ByteBufCodecs.STRING_UTF8), + $ -> Optional.ofNullable($.id), + ByteBufCodecs.optional(ByteBufCodecs.COMPOUND_TAG), + $ -> Optional.ofNullable($.extraData), + ViewGroup::new); } public static StreamCodec>>> listCodec(StreamCodec viewCodec) { return StreamCodec.composite( - ResourceLocation.STREAM_CODEC, - Map.Entry::getKey, - ByteBufCodecs.>list().apply(codec(viewCodec)), - Map.Entry::getValue, - Map::entry); + ResourceLocation.STREAM_CODEC, + Map.Entry::getKey, + ByteBufCodecs.>list().apply(codec(viewCodec)), + Map.Entry::getValue, + Map::entry); } public List views; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java index 9b49efd3..91bf986b 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java @@ -28,12 +28,12 @@ public class WrappedHierarchyLookup extends HierarchyLo public static WrappedHierarchyLookup forAccessor() { WrappedHierarchyLookup lookup = new WrappedHierarchyLookup<>(); lookup.overrides.add(Pair.of( - new HierarchyLookup<>(Block.class), accessor -> { - if (accessor instanceof BlockAccessor blockAccessor) { - return blockAccessor.getBlock(); - } - return null; - })); + new HierarchyLookup<>(Block.class), accessor -> { + if (accessor instanceof BlockAccessor blockAccessor) { + return blockAccessor.getBlock(); + } + return null; + })); return lookup; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java index 9139394e..a630b123 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java @@ -28,7 +28,7 @@ public class FileStorage { } private boolean isDownloading(final ServerPlacement placement) { - return SyncmaticaProtocol.getCommunicationManager().getDownloadState(placement); + return CommunicationManager.getDownloadState(placement); } public File getLocalLitematic(final ServerPlacement placement) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java index df2254ed..4a6248fc 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java @@ -18,7 +18,7 @@ public class PlayerIdentifierProvider { } public PlayerIdentifier createOrGet(final ExchangeTarget exchangeTarget) { - return createOrGet(SyncmaticaProtocol.getCommunicationManager().getGameProfile(exchangeTarget)); + return createOrGet(CommunicationManager.getGameProfile(exchangeTarget)); } public PlayerIdentifier createOrGet(final @NotNull GameProfile gameProfile) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java index c691201f..f7f423c7 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java @@ -4,6 +4,7 @@ import io.netty.buffer.Unpooled; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; +import org.leavesmc.leaves.protocol.syncmatica.CommunicationManager; import org.leavesmc.leaves.protocol.syncmatica.PacketType; import org.leavesmc.leaves.protocol.syncmatica.PlayerIdentifier; import org.leavesmc.leaves.protocol.syncmatica.ServerPlacement; @@ -31,7 +32,7 @@ public class ModifyExchangeServer extends AbstractExchange { public void handle(final @NotNull ResourceLocation id, final @NotNull FriendlyByteBuf packetBuf) { packetBuf.readUUID(); if (id.equals(PacketType.MODIFY_FINISH.identifier)) { - SyncmaticaProtocol.getCommunicationManager().receivePositionData(placement, packetBuf, getPartner()); + CommunicationManager.receivePositionData(placement, packetBuf, getPartner()); final PlayerIdentifier identifier = SyncmaticaProtocol.getPlayerIdentifierProvider().createOrGet( getPartner() ); @@ -43,7 +44,7 @@ public class ModifyExchangeServer extends AbstractExchange { @Override public void init() { - if (getPlacement() == null || SyncmaticaProtocol.getCommunicationManager().getModifier(placement) != null) { + if (getPlacement() == null || CommunicationManager.getModifier(placement) != null) { close(true); } else { if (SyncmaticaProtocol.getPlayerIdentifierProvider().createOrGet(this.getPartner()).uuid.equals(placement.getOwner().uuid)) { @@ -58,7 +59,7 @@ public class ModifyExchangeServer extends AbstractExchange { final FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); buf.writeUUID(placement.getId()); getPartner().sendPacket(PacketType.MODIFY_REQUEST_ACCEPT.identifier, buf); - SyncmaticaProtocol.getCommunicationManager().setModifier(placement, this); + CommunicationManager.setModifier(placement, this); } @Override @@ -74,8 +75,8 @@ public class ModifyExchangeServer extends AbstractExchange { @Override protected void onClose() { - if (SyncmaticaProtocol.getCommunicationManager().getModifier(placement) == this) { - SyncmaticaProtocol.getCommunicationManager().setModifier(placement, null); + if (CommunicationManager.getModifier(placement) == this) { + CommunicationManager.setModifier(placement, null); } } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/region/IRegionFileFactory.java b/leaves-server/src/main/java/org/leavesmc/leaves/region/IRegionFileFactory.java index 5ccb7420..05e17ef1 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/region/IRegionFileFactory.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/region/IRegionFileFactory.java @@ -37,8 +37,8 @@ public class IRegionFileFactory { @NotNull public static Pattern getRegionFileRegex() { String extensionsPattern = String.join("|", regionArguments.stream() - .map(extension -> extension.replace(".", "")) - .toList()); + .map(extension -> extension.replace(".", "")) + .toList()); return Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(" + extensionsPattern + ")$"); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/replay/Recorder.java b/leaves-server/src/main/java/org/leavesmc/leaves/replay/Recorder.java index d1fb2f08..d8ea3495 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/replay/Recorder.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/replay/Recorder.java @@ -112,14 +112,14 @@ public class Recorder extends Connection { this.savePacket(new ClientboundSelectKnownPacks(knownPackslist), ConnectionProtocol.CONFIGURATION); server.getServerResourcePack().ifPresent((info) -> this.savePacket(new ClientboundResourcePackPushPacket( - info.id(), info.url(), info.hash(), info.isRequired(), Optional.ofNullable(info.prompt()) + info.id(), info.url(), info.hash(), info.isRequired(), Optional.ofNullable(info.prompt()) ))); LayeredRegistryAccess layeredregistryaccess = server.registries(); DynamicOps dynamicOps = layeredregistryaccess.compositeAccess().createSerializationContext(NbtOps.INSTANCE); RegistrySynchronization.packRegistries(dynamicOps, layeredregistryaccess.getAccessFrom(RegistryLayer.WORLDGEN), Set.copyOf(knownPackslist), - (key, entries) -> - this.savePacket(new ClientboundRegistryDataPacket(key, entries), ConnectionProtocol.CONFIGURATION) + (key, entries) -> + this.savePacket(new ClientboundRegistryDataPacket(key, entries), ConnectionProtocol.CONFIGURATION) ); this.savePacket(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(layeredregistryaccess)), ConnectionProtocol.CONFIGURATION); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java b/leaves-server/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java index 8978fe0c..454248d6 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java @@ -46,7 +46,7 @@ public class RecorderOption { private final List> packets; - private RecordWeather(Packet... packets) { + RecordWeather(Packet... packets) { this.packets = List.of(packets); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/spark/LeavesServerConfigProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/spark/LeavesServerConfigProvider.java index 79e0c55c..4adace63 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/spark/LeavesServerConfigProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/spark/LeavesServerConfigProvider.java @@ -39,8 +39,8 @@ public class LeavesServerConfigProvider extends ServerConfigProvider { private static class YamlConfigParser implements ConfigParser { public static final YamlConfigParser INSTANCE = new YamlConfigParser(); protected static final Gson GSON = new GsonBuilder() - .registerTypeAdapter(MemorySection.class, (JsonSerializer) (obj, type, ctx) -> ctx.serialize(obj.getValues(false))) - .create(); + .registerTypeAdapter(MemorySection.class, (JsonSerializer) (obj, type, ctx) -> ctx.serialize(obj.getValues(false))) + .create(); @Override public JsonElement load(String file, ExcludedConfigFilter filter) throws IOException { @@ -104,32 +104,32 @@ public class LeavesServerConfigProvider extends ServerConfigProvider { static { ImmutableMap.Builder files = ImmutableMap.builder() - .put("server.properties", PropertiesConfigParser.INSTANCE) - .put("bukkit.yml", YamlConfigParser.INSTANCE) - .put("spigot.yml", YamlConfigParser.INSTANCE) - .put("paper/", SplitYamlConfigParser.INSTANCE) - .put("leaves.yml", YamlConfigParser.INSTANCE); + .put("server.properties", PropertiesConfigParser.INSTANCE) + .put("bukkit.yml", YamlConfigParser.INSTANCE) + .put("spigot.yml", YamlConfigParser.INSTANCE) + .put("paper/", SplitYamlConfigParser.INSTANCE) + .put("leaves.yml", YamlConfigParser.INSTANCE); for (String config : getSystemPropertyList("spark.serverconfigs.extra")) { files.put(config, YamlConfigParser.INSTANCE); } ImmutableSet.Builder hiddenPaths = ImmutableSet.builder() - .add("database") - .add("settings.bungeecord-addresses") - .add("settings.velocity-support.secret") - .add("proxies.velocity.secret") - .add("server-ip") - .add("motd") - .add("resource-pack") - .add("rconpassword") - .add("rconip") - .add("level-seed") - .add("world-settings.*.feature-seeds") - .add("world-settings.*.seed-*") - .add("feature-seeds") - .add("seed-*") - .addAll(getSystemPropertyList("spark.serverconfigs.hiddenpaths")); + .add("database") + .add("settings.bungeecord-addresses") + .add("settings.velocity-support.secret") + .add("proxies.velocity.secret") + .add("server-ip") + .add("motd") + .add("resource-pack") + .add("rconpassword") + .add("rconip") + .add("level-seed") + .add("world-settings.*.feature-seeds") + .add("world-settings.*.seed-*") + .add("feature-seeds") + .add("seed-*") + .addAll(getSystemPropertyList("spark.serverconfigs.hiddenpaths")); FILES = files.build(); HIDDEN_PATHS = hiddenPaths.build(); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/ArrayConstants.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/ArrayConstants.java index 99d6484c..232e3cb0 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/ArrayConstants.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/ArrayConstants.java @@ -6,7 +6,8 @@ import net.minecraft.server.level.ServerLevel; public class ArrayConstants { - private ArrayConstants() {} + private ArrayConstants() { + } public static final Object[] emptyObjectArray = new Object[0]; public static final int[] emptyIntArray = new int[0]; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java index 00fb833c..dfc081cc 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java @@ -14,7 +14,7 @@ public class ElytraAeronauticsHelper { public static void flightBehaviour(Player player, Vec3 velocity) { if (LeavesConfig.modify.elytraAeronautics.noChunk) { if ((LeavesConfig.modify.elytraAeronautics.noChunkSpeed <= 0.0D || velocity.horizontalDistanceSqr() >= LeavesConfig.modify.elytraAeronautics.noChunkSpeed) - && (LeavesConfig.modify.elytraAeronautics.noChunkHeight <= 0.0D || player.getY() >= LeavesConfig.modify.elytraAeronautics.noChunkHeight)) { + && (LeavesConfig.modify.elytraAeronautics.noChunkHeight <= 0.0D || player.getY() >= LeavesConfig.modify.elytraAeronautics.noChunkHeight)) { if (!player.elytraAeronauticsNoChunk) { player.elytraAeronauticsNoChunk = true; ServerPlayer serverPlayer = (ServerPlayer) player; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java index f87dfa76..9c101506 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java @@ -108,21 +108,21 @@ public class HopperCounter { long total = getTotalItems(); if (total <= 0) { return Collections.singletonList(Component.text() - .append(Component.text("No items for "), coloredName) - .append(Component.text(" yet ("), Component.text(String.format("%.2f ", ticks / (20.0 * 60.0)), Style.style(TextDecoration.BOLD))) - .append(Component.text("min"), Component.text(realTime ? " - real time" : ""), Component.text(")")) - .build()); + .append(Component.text("No items for "), coloredName) + .append(Component.text(" yet ("), Component.text(String.format("%.2f ", ticks / (20.0 * 60.0)), Style.style(TextDecoration.BOLD))) + .append(Component.text("min"), Component.text(realTime ? " - real time" : ""), Component.text(")")) + .build()); } List items = new ArrayList<>(); items.add(Component.text() - .append(Component.text("Items for "), coloredName, Component.text(" ")) - .append(Component.text("("), Component.text(String.format("%.2f ", ticks * 1.0 / (20 * 60)), Style.style(TextDecoration.BOLD))) - .append(Component.text("min"), Component.text(realTime ? " - real time" : ""), Component.text("), ")) - .append(Component.text("total: "), Component.text(total, Style.style(TextDecoration.BOLD)), Component.text(", ")) - .append(Component.text("("), Component.text(String.format("%.1f", total * 1.0 * (20 * 60 * 60) / ticks), Style.style(TextDecoration.BOLD))) - .append(Component.text("/h):")) - .build()); + .append(Component.text("Items for "), coloredName, Component.text(" ")) + .append(Component.text("("), Component.text(String.format("%.2f ", ticks * 1.0 / (20 * 60)), Style.style(TextDecoration.BOLD))) + .append(Component.text("min"), Component.text(realTime ? " - real time" : ""), Component.text("), ")) + .append(Component.text("total: "), Component.text(total, Style.style(TextDecoration.BOLD)), Component.text(", ")) + .append(Component.text("("), Component.text(String.format("%.1f", total * 1.0 * (20 * 60 * 60) / ticks), Style.style(TextDecoration.BOLD))) + .append(Component.text("/h):")) + .build()); items.addAll(counter.object2LongEntrySet().stream().sorted((e, f) -> Long.compare(f.getLongValue(), e.getLongValue())).map(entry -> { Item item = entry.getKey(); @@ -137,102 +137,102 @@ public class HopperCounter { long count = entry.getLongValue(); return Component.text() - .append(Component.text("- ", NamedTextColor.GRAY)) - .append(name) - .append(Component.text(": ", NamedTextColor.GRAY)) - .append(Component.text(count, Style.style(TextDecoration.BOLD)), Component.text(", ", NamedTextColor.GRAY)) - .append(Component.text(String.format("%.1f", count * (20.0 * 60.0 * 60.0) / ticks), Style.style(TextDecoration.BOLD))) - .append(Component.text("/h")) - .build(); + .append(Component.text("- ", NamedTextColor.GRAY)) + .append(name) + .append(Component.text(": ", NamedTextColor.GRAY)) + .append(Component.text(count, Style.style(TextDecoration.BOLD)), Component.text(", ", NamedTextColor.GRAY)) + .append(Component.text(String.format("%.1f", count * (20.0 * 60.0 * 60.0) / ticks), Style.style(TextDecoration.BOLD))) + .append(Component.text("/h")) + .build(); }).toList()); return items; } private static final Map DEFAULTS = Map.ofEntries( - entry(Items.DANDELION, Blocks.YELLOW_WOOL), - entry(Items.POPPY, Blocks.RED_WOOL), - entry(Items.BLUE_ORCHID, Blocks.LIGHT_BLUE_WOOL), - entry(Items.ALLIUM, Blocks.MAGENTA_WOOL), - entry(Items.AZURE_BLUET, Blocks.SNOW_BLOCK), - entry(Items.RED_TULIP, Blocks.RED_WOOL), - entry(Items.ORANGE_TULIP, Blocks.ORANGE_WOOL), - entry(Items.WHITE_TULIP, Blocks.SNOW_BLOCK), - entry(Items.PINK_TULIP, Blocks.PINK_WOOL), - entry(Items.OXEYE_DAISY, Blocks.SNOW_BLOCK), - entry(Items.CORNFLOWER, Blocks.BLUE_WOOL), - entry(Items.WITHER_ROSE, Blocks.BLACK_WOOL), - entry(Items.LILY_OF_THE_VALLEY, Blocks.WHITE_WOOL), - entry(Items.BROWN_MUSHROOM, Blocks.BROWN_MUSHROOM_BLOCK), - entry(Items.RED_MUSHROOM, Blocks.RED_MUSHROOM_BLOCK), - entry(Items.STICK, Blocks.OAK_PLANKS), - entry(Items.GOLD_INGOT, Blocks.GOLD_BLOCK), - entry(Items.IRON_INGOT, Blocks.IRON_BLOCK), - entry(Items.DIAMOND, Blocks.DIAMOND_BLOCK), - entry(Items.NETHERITE_INGOT, Blocks.NETHERITE_BLOCK), - entry(Items.SUNFLOWER, Blocks.YELLOW_WOOL), - entry(Items.LILAC, Blocks.MAGENTA_WOOL), - entry(Items.ROSE_BUSH, Blocks.RED_WOOL), - entry(Items.PEONY, Blocks.PINK_WOOL), - entry(Items.CARROT, Blocks.ORANGE_WOOL), - entry(Items.APPLE, Blocks.RED_WOOL), - entry(Items.WHEAT, Blocks.HAY_BLOCK), - entry(Items.PORKCHOP, Blocks.PINK_WOOL), - entry(Items.RABBIT, Blocks.PINK_WOOL), - entry(Items.CHICKEN, Blocks.WHITE_TERRACOTTA), - entry(Items.BEEF, Blocks.NETHERRACK), - entry(Items.ENCHANTED_GOLDEN_APPLE, Blocks.GOLD_BLOCK), - entry(Items.COD, Blocks.WHITE_TERRACOTTA), - entry(Items.SALMON, Blocks.ACACIA_PLANKS), - entry(Items.ROTTEN_FLESH, Blocks.BROWN_WOOL), - entry(Items.PUFFERFISH, Blocks.YELLOW_TERRACOTTA), - entry(Items.TROPICAL_FISH, Blocks.ORANGE_WOOL), - entry(Items.POTATO, Blocks.WHITE_TERRACOTTA), - entry(Items.MUTTON, Blocks.RED_WOOL), - entry(Items.BEETROOT, Blocks.NETHERRACK), - entry(Items.MELON_SLICE, Blocks.MELON), - entry(Items.POISONOUS_POTATO, Blocks.SLIME_BLOCK), - entry(Items.SPIDER_EYE, Blocks.NETHERRACK), - entry(Items.GUNPOWDER, Blocks.GRAY_WOOL), - entry(Items.TURTLE_SCUTE, Blocks.LIME_WOOL), - entry(Items.ARMADILLO_SCUTE, Blocks.ANCIENT_DEBRIS), - entry(Items.FEATHER, Blocks.WHITE_WOOL), - entry(Items.FLINT, Blocks.BLACK_WOOL), - entry(Items.LEATHER, Blocks.SPRUCE_PLANKS), - entry(Items.GLOWSTONE_DUST, Blocks.GLOWSTONE), - entry(Items.PAPER, Blocks.WHITE_WOOL), - entry(Items.BRICK, Blocks.BRICKS), - entry(Items.INK_SAC, Blocks.BLACK_WOOL), - entry(Items.SNOWBALL, Blocks.SNOW_BLOCK), - entry(Items.WATER_BUCKET, Blocks.WATER), - entry(Items.LAVA_BUCKET, Blocks.LAVA), - entry(Items.MILK_BUCKET, Blocks.WHITE_WOOL), - entry(Items.CLAY_BALL, Blocks.CLAY), - entry(Items.COCOA_BEANS, Blocks.COCOA), - entry(Items.BONE, Blocks.BONE_BLOCK), - entry(Items.COD_BUCKET, Blocks.BROWN_TERRACOTTA), - entry(Items.PUFFERFISH_BUCKET, Blocks.YELLOW_TERRACOTTA), - entry(Items.SALMON_BUCKET, Blocks.PINK_TERRACOTTA), - entry(Items.TROPICAL_FISH_BUCKET, Blocks.ORANGE_TERRACOTTA), - entry(Items.SUGAR, Blocks.WHITE_WOOL), - entry(Items.BLAZE_POWDER, Blocks.GOLD_BLOCK), - entry(Items.ENDER_PEARL, Blocks.WARPED_PLANKS), - entry(Items.NETHER_STAR, Blocks.DIAMOND_BLOCK), - entry(Items.PRISMARINE_CRYSTALS, Blocks.SEA_LANTERN), - entry(Items.PRISMARINE_SHARD, Blocks.PRISMARINE), - entry(Items.RABBIT_HIDE, Blocks.OAK_PLANKS), - entry(Items.CHORUS_FRUIT, Blocks.PURPUR_BLOCK), - entry(Items.SHULKER_SHELL, Blocks.SHULKER_BOX), - entry(Items.NAUTILUS_SHELL, Blocks.BONE_BLOCK), - entry(Items.HEART_OF_THE_SEA, Blocks.CONDUIT), - entry(Items.HONEYCOMB, Blocks.HONEYCOMB_BLOCK), - entry(Items.NAME_TAG, Blocks.BONE_BLOCK), - entry(Items.TOTEM_OF_UNDYING, Blocks.YELLOW_TERRACOTTA), - entry(Items.TRIDENT, Blocks.PRISMARINE), - entry(Items.GHAST_TEAR, Blocks.WHITE_WOOL), - entry(Items.PHANTOM_MEMBRANE, Blocks.BONE_BLOCK), - entry(Items.EGG, Blocks.BONE_BLOCK), - entry(Items.COPPER_INGOT, Blocks.COPPER_BLOCK), - entry(Items.AMETHYST_SHARD, Blocks.AMETHYST_BLOCK) + entry(Items.DANDELION, Blocks.YELLOW_WOOL), + entry(Items.POPPY, Blocks.RED_WOOL), + entry(Items.BLUE_ORCHID, Blocks.LIGHT_BLUE_WOOL), + entry(Items.ALLIUM, Blocks.MAGENTA_WOOL), + entry(Items.AZURE_BLUET, Blocks.SNOW_BLOCK), + entry(Items.RED_TULIP, Blocks.RED_WOOL), + entry(Items.ORANGE_TULIP, Blocks.ORANGE_WOOL), + entry(Items.WHITE_TULIP, Blocks.SNOW_BLOCK), + entry(Items.PINK_TULIP, Blocks.PINK_WOOL), + entry(Items.OXEYE_DAISY, Blocks.SNOW_BLOCK), + entry(Items.CORNFLOWER, Blocks.BLUE_WOOL), + entry(Items.WITHER_ROSE, Blocks.BLACK_WOOL), + entry(Items.LILY_OF_THE_VALLEY, Blocks.WHITE_WOOL), + entry(Items.BROWN_MUSHROOM, Blocks.BROWN_MUSHROOM_BLOCK), + entry(Items.RED_MUSHROOM, Blocks.RED_MUSHROOM_BLOCK), + entry(Items.STICK, Blocks.OAK_PLANKS), + entry(Items.GOLD_INGOT, Blocks.GOLD_BLOCK), + entry(Items.IRON_INGOT, Blocks.IRON_BLOCK), + entry(Items.DIAMOND, Blocks.DIAMOND_BLOCK), + entry(Items.NETHERITE_INGOT, Blocks.NETHERITE_BLOCK), + entry(Items.SUNFLOWER, Blocks.YELLOW_WOOL), + entry(Items.LILAC, Blocks.MAGENTA_WOOL), + entry(Items.ROSE_BUSH, Blocks.RED_WOOL), + entry(Items.PEONY, Blocks.PINK_WOOL), + entry(Items.CARROT, Blocks.ORANGE_WOOL), + entry(Items.APPLE, Blocks.RED_WOOL), + entry(Items.WHEAT, Blocks.HAY_BLOCK), + entry(Items.PORKCHOP, Blocks.PINK_WOOL), + entry(Items.RABBIT, Blocks.PINK_WOOL), + entry(Items.CHICKEN, Blocks.WHITE_TERRACOTTA), + entry(Items.BEEF, Blocks.NETHERRACK), + entry(Items.ENCHANTED_GOLDEN_APPLE, Blocks.GOLD_BLOCK), + entry(Items.COD, Blocks.WHITE_TERRACOTTA), + entry(Items.SALMON, Blocks.ACACIA_PLANKS), + entry(Items.ROTTEN_FLESH, Blocks.BROWN_WOOL), + entry(Items.PUFFERFISH, Blocks.YELLOW_TERRACOTTA), + entry(Items.TROPICAL_FISH, Blocks.ORANGE_WOOL), + entry(Items.POTATO, Blocks.WHITE_TERRACOTTA), + entry(Items.MUTTON, Blocks.RED_WOOL), + entry(Items.BEETROOT, Blocks.NETHERRACK), + entry(Items.MELON_SLICE, Blocks.MELON), + entry(Items.POISONOUS_POTATO, Blocks.SLIME_BLOCK), + entry(Items.SPIDER_EYE, Blocks.NETHERRACK), + entry(Items.GUNPOWDER, Blocks.GRAY_WOOL), + entry(Items.TURTLE_SCUTE, Blocks.LIME_WOOL), + entry(Items.ARMADILLO_SCUTE, Blocks.ANCIENT_DEBRIS), + entry(Items.FEATHER, Blocks.WHITE_WOOL), + entry(Items.FLINT, Blocks.BLACK_WOOL), + entry(Items.LEATHER, Blocks.SPRUCE_PLANKS), + entry(Items.GLOWSTONE_DUST, Blocks.GLOWSTONE), + entry(Items.PAPER, Blocks.WHITE_WOOL), + entry(Items.BRICK, Blocks.BRICKS), + entry(Items.INK_SAC, Blocks.BLACK_WOOL), + entry(Items.SNOWBALL, Blocks.SNOW_BLOCK), + entry(Items.WATER_BUCKET, Blocks.WATER), + entry(Items.LAVA_BUCKET, Blocks.LAVA), + entry(Items.MILK_BUCKET, Blocks.WHITE_WOOL), + entry(Items.CLAY_BALL, Blocks.CLAY), + entry(Items.COCOA_BEANS, Blocks.COCOA), + entry(Items.BONE, Blocks.BONE_BLOCK), + entry(Items.COD_BUCKET, Blocks.BROWN_TERRACOTTA), + entry(Items.PUFFERFISH_BUCKET, Blocks.YELLOW_TERRACOTTA), + entry(Items.SALMON_BUCKET, Blocks.PINK_TERRACOTTA), + entry(Items.TROPICAL_FISH_BUCKET, Blocks.ORANGE_TERRACOTTA), + entry(Items.SUGAR, Blocks.WHITE_WOOL), + entry(Items.BLAZE_POWDER, Blocks.GOLD_BLOCK), + entry(Items.ENDER_PEARL, Blocks.WARPED_PLANKS), + entry(Items.NETHER_STAR, Blocks.DIAMOND_BLOCK), + entry(Items.PRISMARINE_CRYSTALS, Blocks.SEA_LANTERN), + entry(Items.PRISMARINE_SHARD, Blocks.PRISMARINE), + entry(Items.RABBIT_HIDE, Blocks.OAK_PLANKS), + entry(Items.CHORUS_FRUIT, Blocks.PURPUR_BLOCK), + entry(Items.SHULKER_SHELL, Blocks.SHULKER_BOX), + entry(Items.NAUTILUS_SHELL, Blocks.BONE_BLOCK), + entry(Items.HEART_OF_THE_SEA, Blocks.CONDUIT), + entry(Items.HONEYCOMB, Blocks.HONEYCOMB_BLOCK), + entry(Items.NAME_TAG, Blocks.BONE_BLOCK), + entry(Items.TOTEM_OF_UNDYING, Blocks.YELLOW_TERRACOTTA), + entry(Items.TRIDENT, Blocks.PRISMARINE), + entry(Items.GHAST_TEAR, Blocks.WHITE_WOOL), + entry(Items.PHANTOM_MEMBRANE, Blocks.BONE_BLOCK), + entry(Items.EGG, Blocks.BONE_BLOCK), + entry(Items.COPPER_INGOT, Blocks.COPPER_BLOCK), + entry(Items.AMETHYST_SHARD, Blocks.AMETHYST_BLOCK) ); @Nullable diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java index 0b48f91f..07070242 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java @@ -133,10 +133,10 @@ public class LeavesUpdateHelper { Files.deleteIfExists(outFile); try ( - final ReadableByteChannel source = Channels.newChannel(new URI( - buildInfo.url + LeavesConfig.mics.autoUpdate.source).toURL().openStream() - ); - final FileChannel fileChannel = FileChannel.open(outFile, CREATE, WRITE, TRUNCATE_EXISTING) + final ReadableByteChannel source = Channels.newChannel(new URI( + buildInfo.url + LeavesConfig.mics.autoUpdate.source).toURL().openStream() + ); + final FileChannel fileChannel = FileChannel.open(outFile, CREATE, WRITE, TRUNCATE_EXISTING) ) { fileChannel.transferFrom(source, 0, Long.MAX_VALUE); LeavesLogger.LOGGER.info("Download " + buildInfo.fileName + " completed."); @@ -204,7 +204,7 @@ public class LeavesUpdateHelper { private static LeavesBuildInfo getLatestBuildInfo(String mcVersion, String gitHash) { try { HttpURLConnection connection = (HttpURLConnection) new URI( - "https://api.leavesmc.org/v2/projects/leaves/versions/" + mcVersion + "/builds/latest" + "https://api.leavesmc.org/v2/projects/leaves/versions/" + mcVersion + "/builds/latest" ).toURL().openConnection(); connection.connect(); if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { @@ -243,7 +243,7 @@ public class LeavesUpdateHelper { } } - private record LeavesBuildInfo(int build, String fileName, String sha256, boolean needUpdate, String url) { + private record LeavesBuildInfo(int build, String fileName, String sha256, boolean needUpdate, String url) { public static LeavesBuildInfo ERROR = null; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/ShulkerBoxUtils.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/ShulkerBoxUtils.java index 07ed58fb..34518687 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/ShulkerBoxUtils.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/ShulkerBoxUtils.java @@ -17,7 +17,7 @@ public class ShulkerBoxUtils { public static int getItemStackMaxCount(ItemStack stack) { if (LeavesConfig.modify.shulkerBoxStackSize > 1 && stack.getItem() instanceof BlockItem bi && - bi.getBlock() instanceof ShulkerBoxBlock && shulkerBoxNoItem(stack)) { + bi.getBlock() instanceof ShulkerBoxBlock && shulkerBoxNoItem(stack)) { return LeavesConfig.modify.shulkerBoxStackSize; } return stack.getMaxStackSize();