Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Apricityx committed Oct 7, 2024
1 parent 936daec commit 47f1430
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@

@Mixin(SignBlockEntity.class)
public abstract class SignBlockEntityMixin {

@Shadow
protected abstract Text[] getTexts(boolean filtered);

@Inject(method = "onActivate", at = @At("HEAD"))
public void runCommandOnActivated(ServerPlayerEntity player, CallbackInfoReturnable<Boolean> ci) {
if (CMASettings.runCommandOnSign) {
Text[] texts = this.getTexts(player.shouldFilterText());
StringBuilder rawText = new StringBuilder();
for (Text t : texts) {
rawText.append(t.getString());
}
String text = rawText.toString();
if (text.startsWith("/") && player.getMainHandStack().isOf(Items.AIR) && !player.isSneaking()) {
String actualCommand = text.substring(1);
// No cheating!
ServerCommandSource commandSource = player.getCommandSource();
commandSource.getServer().getCommandManager().execute(commandSource, actualCommand);
}
}
}
//
// @Shadow
// protected abstract Text[] getTexts(boolean filtered);
//
// @Inject(method = "onActivate", at = @At("HEAD"))
// public void runCommandOnActivated(ServerPlayerEntity player, CallbackInfoReturnable<Boolean> ci) {
// if (CMASettings.runCommandOnSign) {
// Text[] texts = this.getTexts(player.shouldFilterText());
// StringBuilder rawText = new StringBuilder();
// for (Text t : texts) {
// rawText.append(t.getString());
// }
// String text = rawText.toString();
// if (text.startsWith("/") && player.getMainHandStack().isOf(Items.AIR) && !player.isSneaking()) {
// String actualCommand = text.substring(1);
// // No cheating!
// ServerCommandSource commandSource = player.getCommandSource();
// commandSource.getServer().getCommandManager().execute(commandSource, actualCommand);
// }
// }
// }
}

0 comments on commit 47f1430

Please sign in to comment.