9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-30 20:39:15 +00:00

[ci skip] Reformat continuation intent from 8 to 4 (#432)

This commit is contained in:
Lumine1909
2025-03-14 20:41:17 +08:00
committed by GitHub
parent 57f825950b
commit c3651150b0
40 changed files with 328 additions and 325 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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))
);
}

View File

@@ -40,7 +40,7 @@ public class SimulationDistanceConfig extends AbstractBotConfig<Integer> {
@Override
public void load(@NotNull CompoundTag nbt) {
this.setValue(new CommandArgumentResult(new ArrayList<>(){{
this.setValue(new CommandArgumentResult(new ArrayList<>() {{
add(nbt.getInt("simulation_distance"));
}}));
}

View File

@@ -32,8 +32,8 @@ public class SpawnPhantomConfig extends AbstractBotConfig<Boolean> {
@Override
public List<String> 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
);
}

View File

@@ -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()) {

View File

@@ -27,9 +27,9 @@ public class LeavesCommandUtil {
// Code from Mojang - copyright them
public static List<String> 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<String> 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<String> 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<String> results = Lists.newArrayList();
@@ -85,10 +85,10 @@ public class LeavesCommandUtil {
// end copy stuff
public static List<String> 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<Candidate> candidates = Lists.newArrayList();

View File

@@ -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;

View File

@@ -33,7 +33,7 @@ public class LeavesPluginProviderFactory implements PluginTypeFactory<PaperPlugi
if (configuration.getLoader() != null) {
try (
PaperSimplePluginClassLoader simplePluginClassLoader = new PaperSimplePluginClassLoader(source, file, configuration, this.getClass().getClassLoader())
PaperSimplePluginClassLoader simplePluginClassLoader = new PaperSimplePluginClassLoader(source, file, configuration, this.getClass().getClassLoader())
) {
PluginLoader loader = ProviderUtil.loadClass(configuration.getLoader(), PluginLoader.class, simplePluginClassLoader);
loader.classloader(builder);

View File

@@ -31,54 +31,54 @@ public class LeavesPluginMeta extends PaperPluginMeta {
public static LeavesPluginMeta create(BufferedReader reader) throws ConfigurateException {
HoconConfigurationLoader loader = HoconConfigurationLoader.builder()
.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);
}
}
.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<Class<?>> 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<Class<?>> 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.<String>builder()
.addAll(pluginConfiguration.authors)
.add(node.node("author").getString())
.build();
.addAll(pluginConfiguration.authors)
.add(node.node("author").getString())
.build();
}
return pluginConfiguration;

View File

@@ -85,8 +85,8 @@ public class LeavesMinecraftSessionService extends PaperMinecraftSessionService
}
final Set<ProfileActionType> 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) {

View File

@@ -26,32 +26,32 @@ import java.util.List;
public class LitematicaEasyPlaceProtocol {
public static final ImmutableSet<Property<?>> 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<Property<?>> BLACKLISTED_PROPERTIES = ImmutableSet.of(
BlockStateProperties.WATERLOGGED,
BlockStateProperties.POWERED
BlockStateProperties.WATERLOGGED,
BlockStateProperties.POWERED
);
public static BlockState applyPlacementProtocol(BlockState state, BlockPlaceContext context) {

View File

@@ -163,7 +163,8 @@ public class PcaSyncProtocol {
return;
}
}
case EVERYONE -> {}
case EVERYONE -> {
}
case null -> LeavesLogger.LOGGER.warning("pcaSyncPlayerEntity wtf???");
}
}

View File

@@ -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();

View File

@@ -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<RegistryFriendlyByteBuf, ClientHandshakePayload> CODEC = StreamCodec.composite(
ByteBufCodecs.STRING_UTF8,
ClientHandshakePayload::protocolVersion,
ClientHandshakePayload::new);
ByteBufCodecs.STRING_UTF8,
ClientHandshakePayload::protocolVersion,
ClientHandshakePayload::new);
@Override
public void write(FriendlyByteBuf buf) {

View File

@@ -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<RegistryFriendlyByteBuf, RequestBlockPayload> CODEC = StreamCodec.composite(
BlockAccessorImpl.SyncData.STREAM_CODEC,
RequestBlockPayload::data,
ByteBufCodecs.<ByteBuf, IServerDataProvider<BlockAccessor>>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.<ByteBuf, IServerDataProvider<BlockAccessor>>list()
.apply(ByteBufCodecs.idMapper(
$ -> Objects.requireNonNull(blockDataProviders.idMapper()).byId($),
$ -> Objects.requireNonNull(blockDataProviders.idMapper()).getIdOrThrow($))),
RequestBlockPayload::dataProviders,
RequestBlockPayload::new);
@Override
public void write(FriendlyByteBuf buf) {

View File

@@ -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<RegistryFriendlyByteBuf, RequestEntityPayload> CODEC = StreamCodec.composite(
EntityAccessorImpl.SyncData.STREAM_CODEC,
RequestEntityPayload::data,
ByteBufCodecs.<ByteBuf, IServerDataProvider<EntityAccessor>>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.<ByteBuf, IServerDataProvider<EntityAccessor>>list()
.apply(ByteBufCodecs.idMapper(
$ -> Objects.requireNonNull(entityDataProviders.idMapper()).byId($),
$ -> Objects.requireNonNull(entityDataProviders.idMapper()).getIdOrThrow($)
)),
RequestEntityPayload::dataProviders,
RequestEntityPayload::new);
@Override

View File

@@ -24,15 +24,15 @@ public record ServerHandshakePayload(Map<ResourceLocation, Object> serverConfig,
private static final ResourceLocation PACKET_SERVER_HANDSHAKE = JadeProtocol.id("server_handshake");
private static final StreamCodec<RegistryFriendlyByteBuf, ServerHandshakePayload> 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.<ByteBuf, ResourceLocation>list().apply(ResourceLocation.STREAM_CODEC),
ServerHandshakePayload::blockProviderIds,
ByteBufCodecs.<ByteBuf, ResourceLocation>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.<ByteBuf, ResourceLocation>list().apply(ResourceLocation.STREAM_CODEC),
ServerHandshakePayload::blockProviderIds,
ByteBufCodecs.<ByteBuf, ResourceLocation>list().apply(ResourceLocation.STREAM_CODEC),
ServerHandshakePayload::entityProviderIds,
ServerHandshakePayload::new);
@Override
public void write(FriendlyByteBuf buf) {

View File

@@ -123,7 +123,7 @@ public enum ItemStorageExtensionProvider implements IServerExtensionProvider<Ite
public static @Nullable Container findContainer(@NotNull Accessor<?> 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;

View File

@@ -19,16 +19,16 @@ public enum StatusEffectsProvider implements StreamServerDataProvider<EntityAcce
private static final StreamCodec<RegistryFriendlyByteBuf, List<MobEffectInstance>> STREAM_CODEC = ByteBufCodecs.<RegistryFriendlyByteBuf, MobEffectInstance>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<MobEffectInstance> streamData(@NotNull EntityAccessor accessor) {
List<MobEffectInstance> effects = ((LivingEntity) accessor.getEntity()).getActiveEffects()
.stream()
.filter(MobEffectInstance::isVisible)
.toList();
.stream()
.filter(MobEffectInstance::isVisible)
.toList();
return effects.isEmpty() ? null : effects;
}

View File

@@ -60,8 +60,8 @@ public class CommonUtil {
public static <T> Map.Entry<ResourceLocation, List<ViewGroup<T>>> getServerExtensionData(
Accessor<?> accessor,
WrappedHierarchyLookup<IServerExtensionProvider<T>> lookup) {
Accessor<?> accessor,
WrappedHierarchyLookup<IServerExtensionProvider<T>> lookup) {
for (var provider : lookup.wrappedGet(accessor)) {
List<ViewGroup<T>> groups;
try {

View File

@@ -117,9 +117,9 @@ public class HierarchyLookup<T extends IJadeProvider> 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<T extends IJadeProvider> implements IHierarchyLooku
});
objects = ImmutableListMultimap.<Class<?>, T>builder()
.orderValuesBy(Comparator.comparingInt(priorityStore::byValue))
.putAll(objects)
.build();
.orderValuesBy(Comparator.comparingInt(priorityStore::byValue))
.putAll(objects)
.build();
if (idMapped) {
idMapper = createIdMapper();

View File

@@ -24,8 +24,8 @@ public interface IHierarchyLookup<T extends IJadeProvider> {
default List<ResourceLocation> mappedIds() {
return Streams.stream(Objects.requireNonNull(idMapper()))
.map(IJadeProvider::getUid)
.toList();
.map(IJadeProvider::getUid)
.toList();
}
void register(Class<?> clazz, T provider);

View File

@@ -75,7 +75,7 @@ public class ItemCollector<T> {
updateCollectingProgress(mergedResult.getFirst());
return mergedResult;
}
List<ItemStack> partialResult = items.object2IntEntrySet().stream().limit(MAX_SIZE ).map(entry -> {
List<ItemStack> partialResult = items.object2IntEntrySet().stream().limit(MAX_SIZE).map(entry -> {
ItemDefinition def = entry.getKey();
return def.toStack(entry.getIntValue());
}).toList();

View File

@@ -47,8 +47,8 @@ public class PairHierarchyLookup<T extends IJadeProvider> 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) {

View File

@@ -14,22 +14,22 @@ import java.util.Optional;
public class ViewGroup<T> {
public static <B extends ByteBuf, T> StreamCodec<B, ViewGroup<T>> codec(StreamCodec<B, T> viewCodec) {
return StreamCodec.composite(
ByteBufCodecs.<B, T>list().apply(viewCodec),
$ -> $.views,
ByteBufCodecs.optional(ByteBufCodecs.STRING_UTF8),
$ -> Optional.ofNullable($.id),
ByteBufCodecs.optional(ByteBufCodecs.COMPOUND_TAG),
$ -> Optional.ofNullable($.extraData),
ViewGroup::new);
ByteBufCodecs.<B, T>list().apply(viewCodec),
$ -> $.views,
ByteBufCodecs.optional(ByteBufCodecs.STRING_UTF8),
$ -> Optional.ofNullable($.id),
ByteBufCodecs.optional(ByteBufCodecs.COMPOUND_TAG),
$ -> Optional.ofNullable($.extraData),
ViewGroup::new);
}
public static <B extends ByteBuf, T> StreamCodec<B, Map.Entry<ResourceLocation, List<ViewGroup<T>>>> listCodec(StreamCodec<B, T> viewCodec) {
return StreamCodec.composite(
ResourceLocation.STREAM_CODEC,
Map.Entry::getKey,
ByteBufCodecs.<B, ViewGroup<T>>list().apply(codec(viewCodec)),
Map.Entry::getValue,
Map::entry);
ResourceLocation.STREAM_CODEC,
Map.Entry::getKey,
ByteBufCodecs.<B, ViewGroup<T>>list().apply(codec(viewCodec)),
Map.Entry::getValue,
Map::entry);
}
public List<T> views;

View File

@@ -28,12 +28,12 @@ public class WrappedHierarchyLookup<T extends IJadeProvider> extends HierarchyLo
public static <T extends IJadeProvider> WrappedHierarchyLookup<T> forAccessor() {
WrappedHierarchyLookup<T> 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;
}

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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);
}
}
}

View File

@@ -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 + ")$");
}

View File

@@ -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<RegistryLayer> layeredregistryaccess = server.registries();
DynamicOps<Tag> 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);

View File

@@ -46,7 +46,7 @@ public class RecorderOption {
private final List<Packet<?>> packets;
private RecordWeather(Packet<?>... packets) {
RecordWeather(Packet<?>... packets) {
this.packets = List.of(packets);
}

View File

@@ -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<MemorySection>) (obj, type, ctx) -> ctx.serialize(obj.getValues(false)))
.create();
.registerTypeAdapter(MemorySection.class, (JsonSerializer<MemorySection>) (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<String, ConfigParser> files = ImmutableMap.<String, ConfigParser>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<String> hiddenPaths = ImmutableSet.<String>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("rcon<dot>password")
.add("rcon<dot>ip")
.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("rcon<dot>password")
.add("rcon<dot>ip")
.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();

View File

@@ -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];

View File

@@ -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;

View File

@@ -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<Component> 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<Item, Block> DEFAULTS = Map.<Item, Block>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

View File

@@ -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;
}
}

View File

@@ -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();