Skip to content

Commit

Permalink
fix issues#5
Browse files Browse the repository at this point in the history
  • Loading branch information
3093FengMing committed Apr 8, 2023
1 parent 33b8d5f commit 1d88168
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/me/fengming/vaultpatcher/ThePatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ThePatcher() {
}

public static String patch(String string, String method) {
if (string == null || string.equals("") || string.isBlank()) {
if (string == null || string.equals("")) {
return string;
}
if (!VaultPatcherConfig.getOptimize().isDisableExport()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public abstract class BaseComponentMixin {
)
)
private FormattedText proxy_getVisualOrder(FormattedText p_128116_) {
if (p_128116_ instanceof TranslatableComponent) return p_128116_;
if (p_128116_ instanceof TextComponent text) {
String c = ThePatcher.patch(text.getText(), "BaseComponent#getVisualOrder");
if (c != null && !c.equals("")) {
Expand All @@ -44,6 +45,7 @@ private FormattedText proxy_getVisualOrder(FormattedText p_128116_) {

@Inject(method = "append", at = @At("HEAD"), cancellable = true)
private void proxy_append(Component p_130585_, CallbackInfoReturnable<MutableComponent> cir) {
if (p_130585_ instanceof TranslatableComponent) return;
if (p_130585_ instanceof TextComponent text) {
String c = ThePatcher.patch(text.getText(), "BaseComponent#append");
if (c != null && !c.equals("")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ private void proxy_getContents(CallbackInfoReturnable<String> cir) {
if (c != null && !c.equals("")) {
this.text = c;
cir.setReturnValue(c);
}
} else cir.setReturnValue(this.text);
}

@Inject(method = "getText", at = @At("HEAD"), cancellable = true)
private void proxy_getText(CallbackInfoReturnable<String> cir) {
String c = ThePatcher.patch(this.getText_(), "TextComponent#getText");
if (c != null && !c.equals("")) {
this.text = c;
cir.setReturnValue(c);
}
if (c == null) {
cir.setReturnValue(this.text);
} else cir.setReturnValue(this.text);
}

}
Expand Down

0 comments on commit 1d88168

Please sign in to comment.