Skip to content

Commit

Permalink
Use more formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Apr 25, 2024
1 parent 2a19c39 commit a64b111
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ checkstyle {
// To fix a conflict in checkstyle dependencies
configurations.checkstyle {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:" + libs.guava.get().version)
select("com.google.guava:guava:${libs.guava.get().version}")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private void updatePopup() {
var url = LogsUploadService.upload(textComponent.getText()).url();
JOptionPane.showMessageDialog(
this,
SFSwingUtils.createHtmlPane("Uploaded to: <a href='" + url + "'>" + url + "</a>"),
SFSwingUtils.createHtmlPane("Uploaded to: <a href='%s'>%s</a>".formatted(url, url)),
"Success",
JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public static JTextPane createHtmlPane(@Language("html") String text) {
}

public static String htmlCenterText(String text) {
return htmlText("<center>" + text + "</center>");
return htmlText("<center>%s</center>".formatted(text));
}

public static String htmlText(String text) {
return "<html>" + text + "</html>";
return "<html>%s</html>".formatted(text);
}

public static UndoManager addUndoRedo(JTextComponent textComponent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static void addComponents(
yield comboBox;
}
case VALUE_NOT_SET -> throw new IllegalStateException(
"Unexpected value: " + settingType.getValueCase());
"Unexpected value: %s".formatted(settingType.getValueCase()));
};
GBC.create(panel)
.grid(1, row++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public AboutPopup(JFrame parent) {

content.add(SFSwingUtils.createHtmlPane("<b>SoulFire</b>"));
content.add(
SFSwingUtils.createHtmlPane("Version: <b><code>" + BuildData.VERSION + "</code></b>"));
SFSwingUtils.createHtmlPane("Version: <b><code>%s</code></b>".formatted(BuildData.VERSION)));
content.add(
SFSwingUtils.createHtmlPane(
"Author: <b><a href='https://github.com/AlexProgrammerDE'>AlexProgrammerDE</a></b>"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static OfflineJavaData fromProto(MinecraftAccountProto.OfflineJavaData da
}

public static UUID getOfflineUUID(String username) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(StandardCharsets.UTF_8));
return UUID.nameUUIDFromBytes(("OfflinePlayer:%s".formatted(username)).getBytes(StandardCharsets.UTF_8));
}

public MinecraftAccountProto.OfflineJavaData toProto() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public static String readStringCustom(StringReader stringReader) throws CommandS
public R parse(StringReader stringReader) throws CommandSyntaxException {
final var start = stringReader.getCursor();
var string = readStringCustom(stringReader);
System.out.println("string = " + string);

var currentKeys = directKeys;
var currentSupplier = directSupplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ public static <T> T fromJson(String dataFile, String dataKey, Class<T> clazz,
}
}

throw new RuntimeException("Failed to find data key " + dataKey + " in file " + dataFile);
throw new RuntimeException("Failed to find data key %s in file %s".formatted(dataKey, dataFile));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public static ResourceKey fromString(String formatted) {

@Override
public String toString() {
return namespace + ":" + path;
return "%s:%s".formatted(namespace, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ public Vector3d toVector3d() {

@Override
public String toString() {
return "SFVec3i(" + x + ", " + y + ", " + z + ")";
return "SFVec3i(%d, %d, %d)".formatted(x, y, z);
}

public String formatXYZ() {
return "[" + x + ", " + y + ", " + z + "]";
return "[%d, %d, %d]".formatted(x, y, z);
}

public double distance(SFVec3i goal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static boolean placeBestToolInHand(SessionDataManager dataManager, SFVec3

var optionalBlockType = dataManager.currentLevel().getBlockState(blockPosition).blockType();
if (optionalBlockType == BlockType.VOID_AIR) {
throw new IllegalStateException("Block at " + blockPosition + " is not in view range");
throw new IllegalStateException("Block at %s is not in view range".formatted(blockPosition));
}

var cost =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void onChat(ChatMessageReceiveEvent event) {
.getSingleton(ServerCommandManager.class)
.execute(command, new LocalConsole());

connection.botControl().sendMessage("Command \"" + command + "\" executed! (Code: " + code + ")");
connection.botControl().sendMessage("Command \"%s\" executed! (Code: %d)".formatted(command, code));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void onMessage(ChatMessageReceiveEvent event) {
Optional.ofNullable(event.sender())
.map(ChatMessageReceiveEvent.ChatMessageSender::senderName)
.orElse("Server");
var message = Component.text("<" + sender + "> ").append(event.message());
var message = Component.text("<%s> ".formatted(sender)).append(event.message());

var ansiMessage = ANSI_MESSAGE_SERIALIZER.serialize(message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public POVServerInstance(int port, AttackManager attackManager) {
MinecraftCodec.CODEC.getMinecraftVersion(),
MinecraftCodec.CODEC.getProtocolVersion()),
new PlayerInfo(100, 0, new ArrayList<>()),
Component.text("Attack POV server for attack " + attackManager.id() + "!")
Component.text("Attack POV server for attack %d!".formatted(attackManager.id()))
.color(NamedTextColor.GREEN)
.decorate(TextDecoration.BOLD),
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public int hashCode() {

@Override
public String toString() {
return "ContainerSlot[" + "slot=" + slot + ", " + "item=" + item + ']';
return "ContainerSlot[slot=%d, item=%s]".formatted(slot, item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out)

if (buf.readableBytes() > 0) {
throw new IllegalStateException(
"Packet \"" + packet.getClass().getSimpleName() + "\" not fully read.");
"Packet \"%s\" not fully read.".formatted(packet.getClass().getSimpleName()));
}

out.add(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void sendMessage(UUID uuid, String message) {
if (uuid == null) {
this.getLogger().info(message);
} else {
this.getLogger().info("[" + uuid + "] " + message);
this.getLogger().info("[%s] %s".formatted(uuid, message));
}
}

Expand Down

0 comments on commit a64b111

Please sign in to comment.