Skip to content

Commit

Permalink
Remove legacy color codes
Browse files Browse the repository at this point in the history
  • Loading branch information
RappyTV committed Aug 18, 2023
1 parent 8482ee8 commit 0875a6a
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 34 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ labyMod {
author = "RappyTV"
description = "This addon saves your last death point, so you can find your items again."
minecraftVersion = "1.8<1.20.1"
version = System.getenv().getOrDefault("VERSION", "1.0.1")
version = System.getenv().getOrDefault("VERSION", "1.0.2")
}

minecraft {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
import com.rappytv.deathfinder.commands.CoordsCommand;
import com.rappytv.deathfinder.util.Location;
import net.labymod.api.addon.LabyAddon;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.format.NamedTextColor;
import net.labymod.api.client.component.format.Style;
import net.labymod.api.client.component.format.TextDecoration;
import net.labymod.api.models.addon.annotation.AddonMain;

@AddonMain
public class DeathFinderAddon extends LabyAddon<DeathFinderConfig> {

public final static String prefix = "§5§lDF §8» §7";
public final static Component prefix = Component
.text("DF ", Style.builder().color(NamedTextColor.DARK_PURPLE).decorate(TextDecoration.BOLD).build())
.append(Component.text("» ", NamedTextColor.DARK_GRAY));

private static Location deathLocation;
private static DeathFinderAddon instance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.rappytv.deathfinder.util.Util;
import net.labymod.api.Laby;
import net.labymod.api.client.chat.command.Command;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.format.NamedTextColor;

public class BackCommand extends Command {

Expand All @@ -22,7 +24,7 @@ public boolean execute(String prefix, String[] arguments) {
return false;

if(DeathFinderAddon.getDeathLocation() == null) {
Util.msg("§c" + Util.getTranslation("deathfinder.messages.noSavedPoint"));
Util.msg(Component.translatable("deathfinder.messages.noSavedPoint", NamedTextColor.RED));
return true;
}
Location death = DeathFinderAddon.getDeathLocation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.rappytv.deathfinder.util.Location;
import com.rappytv.deathfinder.util.Util;
import net.labymod.api.client.chat.command.Command;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.format.NamedTextColor;

public class CoordsCommand extends Command {

Expand All @@ -21,18 +23,17 @@ public boolean execute(String prefix, String[] arguments) {
return false;

if(DeathFinderAddon.getDeathLocation() == null) {
Util.msg("§c" + Util.getTranslation("deathfinder.messages.noSavedPoint"));
Util.msg(Component.translatable("deathfinder.messages.noSavedPoint", NamedTextColor.RED));
return true;
}
Location death = DeathFinderAddon.getDeathLocation();
Util.msg(
"§e" + Util.getTranslation("deathfinder.messages.deathPoint",
"§aX: §b" + String.format(java.util.Locale.US,"%.2f", death.getX()),
"§aY: §b" + String.format(java.util.Locale.US,"%.2f", death.getY()),
"§aZ: §b" + String.format(java.util.Locale.US,"%.2f", death.getZ()),
"§aYaw: §b" + String.format(java.util.Locale.US,"%.2f", death.getYaw()),
"§aPitch: §b" + String.format(java.util.Locale.US,"%.2f", death.getPitch())
)
Component.translatable("deathfinder.messages.deathPoint", NamedTextColor.YELLOW),
Component.text("X: ", NamedTextColor.GREEN).append(Component.text(String.format(java.util.Locale.US,"%.2f", death.getX()), NamedTextColor.AQUA)),
Component.text("Y: ", NamedTextColor.GREEN).append(Component.text(String.format(java.util.Locale.US,"%.2f", death.getY()), NamedTextColor.AQUA)),
Component.text("Z: ", NamedTextColor.GREEN).append(Component.text(String.format(java.util.Locale.US,"%.2f", death.getZ()), NamedTextColor.AQUA)),
Component.text("Yaw: ", NamedTextColor.GREEN).append(Component.text(String.format(java.util.Locale.US,"%.2f", death.getYaw()), NamedTextColor.AQUA)),
Component.text("Pitch: ", NamedTextColor.GREEN).append(Component.text(String.format(java.util.Locale.US,"%.2f", death.getPitch()), NamedTextColor.AQUA))
);
return true;
}
Expand Down
30 changes: 18 additions & 12 deletions core/src/main/java/com/rappytv/deathfinder/events/DeathEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import com.rappytv.deathfinder.util.Location;
import com.rappytv.deathfinder.util.Util;
import net.labymod.api.Laby;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.TextComponent;
import net.labymod.api.client.component.event.ClickEvent;
import net.labymod.api.client.component.event.HoverEvent;
import net.labymod.api.client.component.format.NamedTextColor;
import net.labymod.api.client.component.format.Style;
import net.labymod.api.client.component.format.TextDecoration;

public class DeathEvent {

Expand All @@ -19,27 +23,29 @@ public DeathEvent(Location location) {

// Message

TextComponent.Builder builder = TextComponent.builder();
builder.append("§8»\n");
builder.append(
DeathFinderAddon.prefix + "§a" + Util.getTranslation("deathfinder.messages.savedPoint") + "\n");
Component builder = Component
.text(\n", NamedTextColor.DARK_GRAY)
.append(DeathFinderAddon.prefix)
.append(Component.translatable("deathfinder.messages.savedPoint", NamedTextColor.GREEN))
.append(Component.text("\n"));

if(backCommand || coordsCommand) builder.append(DeathFinderAddon.prefix);
if(backCommand) builder.append(
TextComponent.builder()
.text("§8[§c§lTP§8]")
Component
.text("[", NamedTextColor.DARK_GRAY)
.append(Component.text("TP", Style.builder().color(NamedTextColor.RED).decorate(TextDecoration.BOLD).build()))
.append(Component.text("]", NamedTextColor.DARK_GRAY))
.hoverEvent(HoverEvent.showText(TextComponent.builder().text("§a" + Util.getTranslation("deathfinder.messages.clickToTeleport")).build()))
.clickEvent(ClickEvent.runCommand("/back"))
.build()
);
if(backCommand && coordsCommand) builder.append(TextComponent.builder().text(" §7| ").build());
if(backCommand && coordsCommand) builder.append(Component.text(" §7| "));
if(coordsCommand) builder.append(
TextComponent.builder()
Component
.text("§8[§b§lINFO§8]")
.hoverEvent(HoverEvent.showText(TextComponent.builder().text("§a" + Util.getTranslation("deathfinder.messages.clickToShow")).build()))
.clickEvent(ClickEvent.runCommand("/coords"))
.build()
);
builder.append((backCommand || coordsCommand ? "\n" : "") + "§8»");
Laby.references().chatExecutor().displayClientMessage(builder.build());
builder.append(Component.text((backCommand || coordsCommand ? "\n" : "") + "§8»", NamedTextColor.DARK_GRAY));
Laby.references().chatExecutor().displayClientMessage(builder);
}
}
18 changes: 9 additions & 9 deletions core/src/main/java/com/rappytv/deathfinder/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import static com.rappytv.deathfinder.DeathFinderAddon.prefix;

import com.rappytv.deathfinder.DeathFinderAddon;
import net.labymod.api.client.component.TextComponent;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.format.NamedTextColor;
import net.labymod.api.util.I18n;

public class Util {
Expand All @@ -13,16 +14,15 @@ public static String getTranslation(String key, Object... args) {
return I18n.getTranslation(key, args);
}

public static void msg(String text) {
TextComponent.Builder component = TextComponent.builder();
String[] lines = text.split("\n");
component.append("§8»\n");
public static void msg(Component... lines) {
Component component = Component
.text(\n", NamedTextColor.DARK_GRAY);

for(String line : lines) {
component.append(prefix + line + "\n");
for(Component line : lines) {
component.append(prefix).append(line).append(Component.text("\n"));
}

component.append("§8»");
DeathFinderAddon.get().displayMessage(component.build());
component.append(Component.text("»", NamedTextColor.DARK_GRAY));
DeathFinderAddon.get().displayMessage(component);
}
}
2 changes: 1 addition & 1 deletion core/src/main/resources/assets/deathfinder/i18n/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"clickToTeleport": "Click to teleport to coordinates!",
"clickToShow": "Click to show coordinates",
"noSavedPoint": "There is no death point saved!",
"deathPoint": "Those are your death coordinates:\n%s\n%s\n%s\n%s\n%s"
"deathPoint": "Those are your death coordinates:"
}
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
### 📦 Installation
1. Press `Win` + `R`
2. Paste this into the window that popped up: `%appdata%/.minecraft/LabyMod-neo/addons` and press enter (This path may change when lm4 gets released)
3. It should open your Labymod addon directory; Paste the [Death-Finder.jar](https://github.com/RappyLabyAddons/Death-Finder/releases/download/v1.0.1/Death-Finder.jar) in there.
3. It should open your Labymod addon directory; Paste the [Death-Finder.jar](https://github.com/RappyLabyAddons/Death-Finder/releases/download/v1.0.2/Death-Finder.jar) in there.
4. Launch your Labymod client.

If you have any problems with the addon/have update ideas, feel free to
Expand Down

0 comments on commit 0875a6a

Please sign in to comment.