Skip to content

Commit

Permalink
Fix some formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pop4959 committed Sep 25, 2024
1 parent 11fd015 commit 74cabeb
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 79 deletions.
88 changes: 44 additions & 44 deletions fabric/src/main/java/org/popcraft/chunky/ChunkyFabric.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,77 +86,77 @@ public void onInitialize() {
return Command.SINGLE_SUCCESS;
});
registerArguments(command, literal(CommandLiteral.CANCEL),
argument(CommandLiteral.WORLD, dimension()));
argument(CommandLiteral.WORLD, dimension()));
registerArguments(command, literal(CommandLiteral.CENTER),
argument(CommandLiteral.X, word()),
argument(CommandLiteral.Z, word()));
argument(CommandLiteral.X, word()),
argument(CommandLiteral.Z, word()));
registerArguments(command, literal(CommandLiteral.CONFIRM));
registerArguments(command, literal(CommandLiteral.CONTINUE),
argument(CommandLiteral.WORLD, dimension()));
argument(CommandLiteral.WORLD, dimension()));
registerArguments(command, literal(CommandLiteral.CORNERS),
argument(CommandLiteral.X1, word()),
argument(CommandLiteral.Z1, word()),
argument(CommandLiteral.X2, word()),
argument(CommandLiteral.Z2, word()));
argument(CommandLiteral.X1, word()),
argument(CommandLiteral.Z1, word()),
argument(CommandLiteral.X2, word()),
argument(CommandLiteral.Z2, word()));
registerArguments(command, literal(CommandLiteral.HELP),
argument(CommandLiteral.PAGE, integer()));
argument(CommandLiteral.PAGE, integer()));
registerArguments(command, literal(CommandLiteral.PATTERN),
argument(CommandLiteral.PATTERN, string()).suggests(SuggestionProviders.PATTERNS),
argument(CommandLiteral.VALUE, string()));
argument(CommandLiteral.PATTERN, string()).suggests(SuggestionProviders.PATTERNS),
argument(CommandLiteral.VALUE, string()));
registerArguments(command, literal(CommandLiteral.PAUSE),
argument(CommandLiteral.WORLD, dimension()));
argument(CommandLiteral.WORLD, dimension()));
registerArguments(command, literal(CommandLiteral.PROGRESS));
registerArguments(command, literal(CommandLiteral.QUIET),
argument(CommandLiteral.INTERVAL, integer()));
argument(CommandLiteral.INTERVAL, integer()));
registerArguments(command, literal(CommandLiteral.RADIUS),
argument(CommandLiteral.RADIUS, word()),
argument(CommandLiteral.RADIUS, word()));
argument(CommandLiteral.RADIUS, word()),
argument(CommandLiteral.RADIUS, word()));
registerArguments(command, literal(CommandLiteral.RELOAD),
argument(CommandLiteral.TYPE, word()));
argument(CommandLiteral.TYPE, word()));
registerArguments(command, literal(CommandLiteral.SELECTION));
registerArguments(command, literal(CommandLiteral.SHAPE),
argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES));
argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES));
registerArguments(command, literal(CommandLiteral.SILENT));
registerArguments(command, literal(CommandLiteral.SPAWN));
registerArguments(command, literal(CommandLiteral.START),
argument(CommandLiteral.WORLD, dimension()),
argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES),
argument(CommandLiteral.CENTER_X, word()),
argument(CommandLiteral.CENTER_Z, word()),
argument(CommandLiteral.RADIUS_X, word()),
argument(CommandLiteral.RADIUS_Z, word()));
argument(CommandLiteral.WORLD, dimension()),
argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES),
argument(CommandLiteral.CENTER_X, word()),
argument(CommandLiteral.CENTER_Z, word()),
argument(CommandLiteral.RADIUS_X, word()),
argument(CommandLiteral.RADIUS_Z, word()));
registerArguments(command, literal(CommandLiteral.TRIM),
argument(CommandLiteral.WORLD, dimension()),
argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES),
argument(CommandLiteral.CENTER_X, word()),
argument(CommandLiteral.CENTER_Z, word()),
argument(CommandLiteral.RADIUS_X, word()),
argument(CommandLiteral.RADIUS_Z, word()),
argument(CommandLiteral.TRIM_MODE, string()).suggests(SuggestionProviders.TRIM_MODES),
argument(CommandLiteral.INHABITED, word()));
argument(CommandLiteral.WORLD, dimension()),
argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES),
argument(CommandLiteral.CENTER_X, word()),
argument(CommandLiteral.CENTER_Z, word()),
argument(CommandLiteral.RADIUS_X, word()),
argument(CommandLiteral.RADIUS_Z, word()),
argument(CommandLiteral.TRIM_MODE, string()).suggests(SuggestionProviders.TRIM_MODES),
argument(CommandLiteral.INHABITED, word()));
registerArguments(command, literal(CommandLiteral.WORLDBORDER));
registerArguments(command, literal(CommandLiteral.WORLD),
argument(CommandLiteral.WORLD, dimension()));
argument(CommandLiteral.WORLD, dimension()));
final LiteralArgumentBuilder<CommandSourceStack> borderCommand = literal(CommandLiteral.BORDER)
.requires(serverCommandSource -> chunky != null && chunky.getCommands().containsKey(CommandLiteral.BORDER))
.executes(command.getCommand());
.requires(serverCommandSource -> chunky != null && chunky.getCommands().containsKey(CommandLiteral.BORDER))
.executes(command.getCommand());
registerArguments(borderCommand, literal(CommandLiteral.ADD),
argument(CommandLiteral.WORLD, dimension()),
argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES),
argument(CommandLiteral.CENTER_X, word()),
argument(CommandLiteral.CENTER_Z, word()),
argument(CommandLiteral.RADIUS_X, word()),
argument(CommandLiteral.RADIUS_Z, word()));
argument(CommandLiteral.WORLD, dimension()),
argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES),
argument(CommandLiteral.CENTER_X, word()),
argument(CommandLiteral.CENTER_Z, word()),
argument(CommandLiteral.RADIUS_X, word()),
argument(CommandLiteral.RADIUS_Z, word()));
registerArguments(borderCommand, literal(CommandLiteral.BYPASS),
argument(CommandLiteral.PLAYER, player()));
argument(CommandLiteral.PLAYER, player()));
registerArguments(borderCommand, literal(CommandLiteral.HELP));
registerArguments(borderCommand, literal(CommandLiteral.LIST));
registerArguments(borderCommand, literal(CommandLiteral.LOAD),
argument(CommandLiteral.WORLD, dimension()));
argument(CommandLiteral.WORLD, dimension()));
registerArguments(borderCommand, literal(CommandLiteral.REMOVE),
argument(CommandLiteral.WORLD, dimension()));
argument(CommandLiteral.WORLD, dimension()));
registerArguments(borderCommand, literal(CommandLiteral.WRAP),
argument(CommandLiteral.WRAP, word()));
argument(CommandLiteral.WRAP, word()));
registerArguments(command, borderCommand);
dispatcher.register(command);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public void accept(final GenerationTaskUpdateEvent event) {
}
final GenerationTask.Progress progress = task.getProgress();
bossBar.setName(Component.nullToEmpty(String.format("%s | %s%% | %s:%s:%s",
worldIdentifier,
String.format("%.2f", progress.getPercentComplete()),
String.format("%01d", progress.getHours()),
String.format("%02d", progress.getMinutes()),
String.format("%02d", progress.getSeconds()))));
bossBar.setProgress(task.getProgress().getPercentComplete() / 100f);
worldIdentifier,
String.format("%.2f", progress.getPercentComplete()),
String.format("%01d", progress.getHours()),
String.format("%02d", progress.getMinutes()),
String.format("%02d", progress.getSeconds()))));
bossBar.setProgress(progress.getPercentComplete() / 100f);
if (progress.isComplete()) {
bossBar.removeAllPlayers();
bossBars.remove(worldIdentifier);
Expand All @@ -61,9 +61,9 @@ public void accept(final GenerationTaskUpdateEvent event) {

private ServerBossEvent createNewBossBar(final ResourceLocation worldIdentifier) {
final ServerBossEvent bossBar = new ServerBossEvent(
Component.nullToEmpty(worldIdentifier.toString()),
bossBarColor(worldIdentifier),
BossEvent.BossBarOverlay.PROGRESS
Component.nullToEmpty(worldIdentifier.toString()),
bossBarColor(worldIdentifier),
BossEvent.BossBarOverlay.PROGRESS
);
bossBar.setDarkenScreen(false);
bossBar.setPlayBossMusic(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ public Map<String, Integration> getIntegrations() {
@Override
public Optional<World> getWorld(final String name) {
return Optional.ofNullable(ResourceLocation.tryParse(name))
.map(resourceLocation -> server.getLevel(ResourceKey.create(Registries.DIMENSION, resourceLocation)))
.or(() -> {
for (final ServerLevel level : server.getAllLevels()) {
if (name.equals(level.dimension().location().getPath())) {
return Optional.of(level);
.map(resourceLocation -> server.getLevel(ResourceKey.create(Registries.DIMENSION, resourceLocation)))
.or(() -> {
for (final ServerLevel level : server.getAllLevels()) {
if (name.equals(level.dimension().location().getPath())) {
return Optional.of(level);
}
}
}
return Optional.empty();
})
.map(FabricWorld::new);
return Optional.empty();
})
.map(FabricWorld::new);
}

@Override
Expand Down
34 changes: 17 additions & 17 deletions fabric/src/main/java/org/popcraft/chunky/platform/FabricWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@ public CompletableFuture<Boolean> isChunkGenerated(final int x, final int z) {
}
if (UPDATE_CHUNK_NBT) {
return chunkMapMixin.invokeReadChunk(chunkPos)
.thenApply(optionalNbt -> optionalNbt
.filter(chunkNbt -> chunkNbt.contains("Status", Tag.TAG_STRING))
.map(chunkNbt -> chunkNbt.getString("Status"))
.map(status -> "minecraft:full".equals(status) || "full".equals(status))
.orElse(false));
.thenApply(optionalNbt -> optionalNbt
.filter(chunkNbt -> chunkNbt.contains("Status", Tag.TAG_STRING))
.map(chunkNbt -> chunkNbt.getString("Status"))
.map(status -> "minecraft:full".equals(status) || "full".equals(status))
.orElse(false));
}
final FieldSelector statusSelector = new FieldSelector(StringTag.TYPE, "Status");
final CollectFields statusCollector = new CollectFields(statusSelector);
return serverChunkCache.chunkScanner().scanChunk(chunkPos, statusCollector)
.thenApply(ignored -> {
if (statusCollector.getResult() instanceof final CompoundTag chunkNbt) {
final String status = chunkNbt.getString("Status");
return "minecraft:full".equals(status) || "full".equals(status);
}
return false;
});
.thenApply(ignored -> {
if (statusCollector.getResult() instanceof final CompoundTag chunkNbt) {
final String status = chunkNbt.getString("Status");
return "minecraft:full".equals(status) || "full".equals(status);
}
return false;
});
}
}

Expand All @@ -106,7 +106,7 @@ public CompletableFuture<Void> getChunkAtAsync(final int x, final int z) {
if (TICKING_LOAD_DURATION > 0) {
serverChunkCache.addRegionTicket(CHUNKY_TICKING, chunkPos, 1, Unit.INSTANCE);
}
((ServerChunkCacheMixin)serverChunkCache).invokeRunDistanceManagerUpdates();
((ServerChunkCacheMixin) serverChunkCache).invokeRunDistanceManagerUpdates();
final ChunkMap chunkManager = serverChunkCache.chunkMap;
final ChunkMapMixin chunkMapMixin = (ChunkMapMixin) chunkManager;
final ChunkHolder chunkHolder = chunkMapMixin.invokeGetVisibleChunkIfPresent(chunkPos.toLong());
Expand Down Expand Up @@ -173,10 +173,10 @@ public void playEffect(final Player player, final String effect) {
public void playSound(final Player player, final String sound) {
final Location location = player.getLocation();
world.getServer()
.registryAccess()
.registry(Registries.SOUND_EVENT)
.flatMap(soundEventRegistry -> soundEventRegistry.getOptional(ResourceLocation.tryParse(sound)))
.ifPresent(soundEvent -> world.playSound(null, location.getX(), location.getY(), location.getZ(), soundEvent, SoundSource.MASTER, 2f, 1f));
.registryAccess()
.registry(Registries.SOUND_EVENT)
.flatMap(soundEventRegistry -> soundEventRegistry.getOptional(ResourceLocation.tryParse(sound)))
.ifPresent(soundEvent -> world.playSound(null, location.getX(), location.getY(), location.getZ(), soundEvent, SoundSource.MASTER, 2f, 1f));
}

@Override
Expand Down

0 comments on commit 74cabeb

Please sign in to comment.