Skip to content

Commit

Permalink
chore: Fix checkstyle errors and progress on block gen editing gui
Browse files Browse the repository at this point in the history
  • Loading branch information
Awakened-Redstone committed Aug 5, 2024
1 parent f2b3d0d commit d442a22
Show file tree
Hide file tree
Showing 36 changed files with 782 additions and 226 deletions.
4 changes: 4 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ plugins {
repositories {
mavenCentral()
}

dependencies {
implementation("com.puppycrawl.tools:checkstyle:10.17.0")
}
4 changes: 4 additions & 0 deletions src/main/java/com/awakenedredstone/neoskies/NeoSkies.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ public void onInitialize() {
public static Identifier id(String path) {
return new Identifier(MOD_ID, path);
}

public static Identifier generatedId(String path) {
return new Identifier(MOD_ID + "_generated", path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.awakenedredstone.neoskies.command.island.MenuCommand;
import com.awakenedredstone.neoskies.command.island.SettingCommands;
import com.awakenedredstone.neoskies.command.island.VisitCommand;
import com.awakenedredstone.neoskies.gui.CobbleGenGui;
import com.awakenedredstone.neoskies.gui.blockgen.BlockGenManageScreen;
import com.awakenedredstone.neoskies.logic.AdminLevelCommand;
import com.awakenedredstone.neoskies.logic.Island;
import com.awakenedredstone.neoskies.logic.IslandLogic;
Expand Down Expand Up @@ -122,11 +122,11 @@ private static void registerAdminCommands(CommandDispatcher<ServerCommandSource>
.executes(context -> {
ServerCommandSource source = context.getSource();
if (!source.isExecutedByPlayer()) {
source.sendError(Texts.of("This command must be executed by a player!"));
source.sendError(Texts.translatable("commands.neoskies.error.player_only"));
return 0;
}

new CobbleGenGui(source.getPlayer()).open();
new BlockGenManageScreen(source.getPlayer()).open();

return 0;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {

private static @Nullable EconomyAccount getWallet(ServerCommandSource source, Island island) {
if (island == null) {
source.sendError(Texts.of("message.neoskies.error.island_not_found"));
source.sendError(Texts.translatable("message.neoskies.error.island_not_found"));
return null;
}
EconomyAccount islandWallet = NeoSkiesAPI.getIslandWallet(island);
if (islandWallet == null) {
source.sendError(Texts.of("message.neoskies.error.island_wallet_not_found"));
source.sendError(Texts.translatable("message.neoskies.error.island_wallet_not_found"));
return null;
}
return islandWallet;
Expand All @@ -78,7 +78,7 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
private static int getBalance(ServerCommandSource source, @Nullable Island island) {
EconomyAccount wallet = getWallet(source, island);
if (wallet == null) return 0;
source.sendFeedback(() -> Texts.of("message.neoskies.balance.get", map -> new MapBuilder.StringMap()
source.sendFeedback(() -> Texts.translatable("message.neoskies.balance.get", map -> new MapBuilder.StringMap()
.put("island", island.getIslandId().toString())
.putAny("amount", wallet.balance())), true);
return 1;
Expand All @@ -88,7 +88,7 @@ private static int setBalance(ServerCommandSource source, @Nullable Island islan
EconomyAccount wallet = getWallet(source, island);
if (wallet == null) return 0;
wallet.setBalance(amount);
source.sendFeedback(() -> Texts.of("message.neoskies.balance.set", map -> new MapBuilder.StringMap()
source.sendFeedback(() -> Texts.translatable("message.neoskies.balance.set", map -> new MapBuilder.StringMap()
.put("island", island.getIslandId().toString())
.putAny("amount", amount)), true);
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {

if (island.isPresent()) {
IslandLogic.getInstance().islands.delete(playerName);
context.getSource().sendFeedback(() -> Texts.of("message.neoskies.force_delete.success", map -> map.put("player", playerName)), true);
context.getSource().sendFeedback(() -> Texts.translatable("message.neoskies.force_delete.success", map -> map.put("player", playerName)), true);
} else {
context.getSource().sendFeedback(() -> Texts.of("message.neoskies.force_delete.fail", map -> map.put("player", playerName)), true);
context.getSource().sendFeedback(() -> Texts.translatable("message.neoskies.force_delete.fail", map -> map.put("player", playerName)), true);
}

return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {

private static int getIslandData(ServerCommandSource source, @Nullable Island island) {
if (island == null) {
source.sendError(Texts.of("message.neoskies.error.island_not_found"));
source.sendError(Texts.translatable("message.neoskies.error.island_not_found"));
return 0;
}

Expand All @@ -86,7 +86,7 @@ private static int getIslandData(ServerCommandSource source, @Nullable Island is
.putAny("radius", island.radius)
.putAny("locked", island.locked)
.putAny("created", island.getCreated().toEpochMilli());
source.sendFeedback(() -> Texts.of("message.neoskies.island_data", map.build()), false);
source.sendFeedback(() -> Texts.translatable("message.neoskies.island_data", map.build()), false);
return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static int modifyIslandSize(ServerCommandSource source, @Nullable Island
if (!assertIsland(source, island)) return 0;
island.radius = size;

source.sendFeedback(() -> Texts.of(Texts.of("message.neoskies.island.modify.size", new MapBuilder.StringMap()
source.sendFeedback(() -> Texts.of(Texts.translatable("message.neoskies.island.modify.size", new MapBuilder.StringMap()
.put("player", island.owner.name)
.putAny("size", size)
.build())), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
private static void run(ServerCommandSource source, CommandDispatcher<ServerCommandSource> dispatcher) {
ParseResults<ServerCommandSource> parseResults = dispatcher.parse(IslandLogic.getConfig().commands.command, source);
if (parseResults.getContext().getNodes().isEmpty()) {
source.sendError(Texts.of("commands.neoskies.error.no_commands"));
source.sendError(Texts.translatable("commands.neoskies.error.no_commands"));
return;
}

//Map<CommandNode<ServerCommandSource>, String> nodes2 = dispatcher.getSmartUsage(Iterables.getLast(parseResults.getContext().getNodes()).getNode(), source);

CommandNode<ServerCommandSource> node = Iterables.getLast(parseResults.getContext().getNodes()).getNode();
Collection<CommandNode<ServerCommandSource>> nodes = node.getChildren().stream().sorted().toList();
source.sendFeedback(() -> Texts.of("commands.neoskies.help"), false);
source.sendFeedback(() -> Texts.translatable("commands.neoskies.help"), false);
sendCommands(nodes, source, "", "");
}

private static boolean sendCommands(Collection<CommandNode<ServerCommandSource>> nodes, ServerCommandSource source, String parent, String parentTranslation) {
for (CommandNode<ServerCommandSource> node : nodes) {
if (node.getChildren().isEmpty() || node.getCommand() != null) {
String command = node.getUsageText();
MutableText prefix = Texts.of("commands.neoskies.help.prefix", map -> {
MutableText prefix = Texts.translatable("commands.neoskies.help.prefix", map -> {
map.put("prefix", IslandLogic.getConfig().commands.command);
map.put("command", parent + command);
});
String string = "commands.description.neoskies." + parentTranslation + command;
Text description = Texts.of(string.replaceAll("\\.<.*>$", ""));
Text description = Texts.literal(string.replaceAll("\\.<.*>$", ""));
source.sendFeedback(() -> prefix.append(description), false);
}
sendCommands(node.getChildren(), source, parent + node.getUsageText() + " ", parentTranslation + node.getUsageText() + ".");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
builder.append(top5.getFirst().owner.name).append(": ").append(top5.getFirst().getPoints());
builder.appendLine(top5.getLast().owner.name).append(": ").append(top5.getLast().getPoints());

context.getSource().sendMessage(Texts.of(builder.toString()));
context.getSource().sendMessage(Texts.literal(builder.toString()));
return 0;
})
)
Expand All @@ -94,7 +94,7 @@ private static int view(ServerCommandSource source) {
Island island = NeoSkiesAPI.getIslandByPlayer(player).orElse(null);
if (!assertIsland(source, island)) return 0;
if (island.isScanning()) {
source.sendError(Texts.of("message.neoskies.island.error.scanning"));
source.sendError(Texts.translatable("message.neoskies.island.error.scanning"));
return 0;
}

Expand Down Expand Up @@ -134,13 +134,13 @@ private static int view(ServerCommandSource source) {
});

SimpleGui gui = PagedGui.of(player, elements);
gui.setTitle(Texts.of("gui.neoskies.level.title", map -> {
gui.setTitle(Texts.translatable("gui.neoskies.level.title", map -> {
map.put("points", String.valueOf(island.getPoints()));
map.put("level", String.valueOf(island.getLevel()));
}));
gui.open();

source.sendFeedback(() -> Texts.of(sum.get() + " points"), false);
source.sendFeedback(() -> Texts.translatable(sum.get() + " points"), false);

return sum.get();
}
Expand All @@ -152,7 +152,7 @@ private static int runScan(ServerCommandSource source) {
Island island = NeoSkiesAPI.getIslandByPlayer(player).orElse(null);
if (!assertIsland(source, island)) return 0;
if (island.isScanning()) {
source.sendError(Texts.of("message.neoskies.island.error.scanning"));
source.sendError(Texts.translatable("message.neoskies.island.error.scanning"));
return 0;
}

Expand All @@ -171,10 +171,10 @@ private static int runScan(ServerCommandSource source) {
new ChunkAttachment(holder, (WorldChunk) world.getChunk(blockPos), pos, true);
Identifier scanCloseTaskId = Identifier.of(island.getIslandId().toString(), "close_scan_screen");

MutableText text = Texts.of("message.neoskies.island.level.scan.background").copy();
MutableText text = Texts.translatable("message.neoskies.island.level.scan.background").copy();

Text startScanText = Texts.of("message.neoskies.island.level.scan.start");
Text cancelText = Texts.of("message.neoskies.island.level.scan.cancel");
Text startScanText = Texts.translatable("message.neoskies.island.level.scan.start");
Text cancelText = Texts.translatable("message.neoskies.island.level.scan.cancel");

TextDisplayElement textDisplay = new TextDisplayElement();
textDisplay.setText(text);
Expand Down Expand Up @@ -209,10 +209,10 @@ private static int runScan(ServerCommandSource source) {

//TODO: Fix all 100 bugs this thing has
//TODO: Make this readable
TextDisplayElement display = createDisplay(Texts.of(""), yaw, new Vec3d(0, 0, 0));
TextDisplayElement display = createDisplay(Texts.literal(""), yaw, new Vec3d(0, 0, 0));
VirtualElement.InteractionHandler startScan = createHandler((interactor, hand) -> {
if (island.isScanning()) {
source.sendError(Texts.of("message.neoskies.island.error.scanning"));
source.sendError(Texts.translatable("message.neoskies.island.error.scanning"));
return;
}

Expand All @@ -223,18 +223,18 @@ private static int runScan(ServerCommandSource source) {
IslandLogic.getScheduler().scheduleDelayed(scanCloseTaskId, IslandLogic.getServer(), 0, () -> {});

display.setTranslation(new Vec3d(0, 0.25 * (lines / 2d) + 0.0625 + 0.5, 0).toVector3f());
display.setText(Texts.of("message.neoskies.island.level.scan.preparing"));
display.setText(Texts.translatable("message.neoskies.island.level.scan.preparing"));

AtomicInteger toScan = new AtomicInteger();
IslandLogic.getInstance().islandScanner.queueScan(island, total -> {
toScan.set(total);
display.setText(Texts.of("message.neoskies.island.level.scan.progress", new MapBuilder.StringMap()
display.setText(Texts.translatable("message.neoskies.island.level.scan.progress", new MapBuilder.StringMap()
.putAny("progress", 0)
.putAny("total", UnitConvertions.readableNumber(total))
.build()));
}, current -> {
int total = toScan.get();
Text progress = Texts.of("message.neoskies.island.level.scan.progress", new MapBuilder.StringMap()
Text progress = Texts.translatable("message.neoskies.island.level.scan.progress", new MapBuilder.StringMap()
.putAny("progress", UnitConvertions.readableNumber(current))
.putAny("total", UnitConvertions.readableNumber(total))
.build());
Expand All @@ -243,7 +243,7 @@ private static int runScan(ServerCommandSource source) {
IslandLogic.runOnNextTick(() -> {
int scanned = scannedBlocks.values().stream().mapToInt(value -> value).sum();

source.sendFeedback(() -> Texts.of("message.neoskies.island.level.scan.time_taken", new MapBuilder.StringMap()
source.sendFeedback(() -> Texts.translatable("message.neoskies.island.level.scan.time_taken", new MapBuilder.StringMap()
.put("time", UnitConvertions.formatTimings(timeTaken))
.putAny("count", UnitConvertions.readableNumber(scanned))
.build()), false);
Expand All @@ -266,7 +266,7 @@ private static int runScan(ServerCommandSource source) {
blockDisplay.setBrightness(Brightness.FULL);
holder.addElement(blockDisplay);
blockDisplays.add(blockDisplay);
Text amountText = Texts.of("message.neoskies.island.level.scan.block_info", new MapBuilder.StringMap()
Text amountText = Texts.translatable("message.neoskies.island.level.scan.block_info", new MapBuilder.StringMap()
.putAny("amount", UnitConvertions.readableNumber(amount))
.put("block", block.getName().getString())
.build());
Expand All @@ -282,7 +282,7 @@ private static int runScan(ServerCommandSource source) {
removeInteraction(ref.closeButton);
};

ref.closeButton = createInteraction(Texts.of("message.neoskies.island.level.scan.close"), createHandler((player1, hand1) -> {
ref.closeButton = createInteraction(Texts.translatable("message.neoskies.island.level.scan.close"), createHandler((player1, hand1) -> {
removeBlocksView.run();
closeBackground.run();
}), yaw);
Expand All @@ -294,7 +294,7 @@ private static int runScan(ServerCommandSource source) {
});
});
}, () -> {
display.setText(Texts.of("message.neoskies.island.level.scan.error"));
display.setText(Texts.translatable("message.neoskies.island.level.scan.error"));
});
});

Expand All @@ -321,7 +321,7 @@ private static int runScan(ServerCommandSource source) {
});

IslandLogic.getScheduler().scheduleDelayed(IslandLogic.getServer(), 15, () -> {
message.set(createDisplay(Texts.of("message.neoskies.island.level.scan.confirm"), yaw, new Vec3d(0, 0.25 * (lines / 2d) + 0.0625 + 0.5, 0)));
message.set(createDisplay(Texts.translatable("message.neoskies.island.level.scan.confirm"), yaw, new Vec3d(0, 0.25 * (lines / 2d) + 0.0625 + 0.5, 0)));
startScanPair.set(createInteraction(startScanText, startScan, yaw, new Vec3d(-2 + getTextWidth(startScanText), 0.25 * (lines / 2d) + 0.0625, 0)));
cancalScanPair.set(createInteraction(cancelText, cancelScan, yaw, new Vec3d(2 - getTextWidth(startScanText), 0.25 * (lines / 2d) + 0.0625, 0)));
});
Expand All @@ -334,7 +334,7 @@ private static int runScan(ServerCommandSource source) {
closeBackground.run();
}
});
source.sendFeedback(() -> Texts.of("message.neoskies.island.level.scan.opening"), false);
source.sendFeedback(() -> Texts.translatable("message.neoskies.island.level.scan.opening"), false);
return 1;
}

Expand Down
Loading

0 comments on commit d442a22

Please sign in to comment.