Skip to content

Commit

Permalink
Fix some errors not being displayed correctly
Browse files Browse the repository at this point in the history
Fixes #97
  • Loading branch information
RappyTV committed Jan 18, 2025
1 parent b95e59c commit 21ea26e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.rappytv.globaltags.command.subcommands;

import com.rappytv.globaltags.api.GlobalTagAPI;
import com.rappytv.globaltags.GlobalTagAddon;
import com.rappytv.globaltags.api.GlobalTagAPI;
import net.labymod.api.Laby;
import net.labymod.api.client.chat.command.SubCommand;
import net.labymod.api.client.component.Component;
Expand Down Expand Up @@ -34,7 +34,7 @@ public boolean execute(String prefix, String[] arguments) {
} else {
this.displayMessage(
GlobalTagAddon.prefix.copy().append(Component.text(
info.getData(),
info.getError(),
NamedTextColor.RED
))
);
Expand Down Expand Up @@ -80,7 +80,7 @@ public boolean execute(String prefix, String[] arguments) {
this.displayMessage(
Component.empty()
.append(GlobalTagAddon.prefix)
.append(Component.text(info.getData(), NamedTextColor.RED))
.append(Component.text(info.getError(), NamedTextColor.RED))
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,35 @@ public void updateSettings(Setting setting) {
}
if(info == null || !info.getPlainTag().equals(this.tag.get())) api.getApiHandler().setTag(
this.tag.get(), (response) -> {
if(response.isSuccessful()) Util.update(api, ResultType.TAG, Component.text("✔", NamedTextColor.GREEN));
else Util.update(api, ResultType.TAG, Component.text(response.getData(), NamedTextColor.RED));
if (response.isSuccessful())
Util.update(api, ResultType.TAG,
Component.text("✔", NamedTextColor.GREEN));
else {
Util.update(api, ResultType.TAG,
Component.text(response.getError(), NamedTextColor.RED));
}
});
else Util.update(api, ResultType.TAG, Util.unchanged);
if(info != null && !info.getPosition().equals(this.position.get())) api.getApiHandler().setPosition(
this.position.get(), (response) -> {
if(response.isSuccessful()) Util.update(api, ResultType.POSITION, Component.text("✔", NamedTextColor.GREEN));
else Util.update(api, ResultType.POSITION, Component.text(response.getData(), NamedTextColor.RED));
if (response.isSuccessful())
Util.update(api, ResultType.POSITION,
Component.text("✔", NamedTextColor.GREEN));
else {
Util.update(api, ResultType.POSITION,
Component.text(response.getError(), NamedTextColor.RED));
}
});
else Util.update(api, ResultType.POSITION, Util.unchanged);
if(info != null && !info.getGlobalIcon().equals(this.globalIcon.get())) api.getApiHandler().setIcon(
this.globalIcon.get(), (response) -> {
if(response.isSuccessful()) Util.update(api, ResultType.ICON, Component.text("✔", NamedTextColor.GREEN));
else Util.update(api, ResultType.ICON, Component.text(response.getData(), NamedTextColor.RED));
if (response.isSuccessful())
Util.update(api, ResultType.ICON,
Component.text("✔", NamedTextColor.GREEN));
else {
Util.update(api, ResultType.ICON,
Component.text(response.getError(), NamedTextColor.RED));
}
});
else Util.update(api, ResultType.ICON, Util.unchanged);
});
Expand All @@ -100,7 +115,7 @@ public void resetTag(Setting setting) {
? "globaltags.general.success"
: "globaltags.general.error"
),
Component.text(info.getData(), NamedTextColor.WHITE)
Util.getResponseComponent(info).color(NamedTextColor.WHITE)
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AppealPopup(GlobalTagAPI api) {
? "globaltags.general.success"
: "globaltags.general.error"
),
Component.text(response.getData(), NamedTextColor.WHITE)
Util.getResponseComponent(response).color(NamedTextColor.WHITE)
)
);
this.close();
Expand Down

0 comments on commit 21ea26e

Please sign in to comment.