Skip to content

Commit

Permalink
Fixed sign edits being logged even if no changes were made
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Jul 14, 2023
1 parent c6a0f20 commit e501046
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ protected void onSignChange(SignChangeEvent event) {
Location location = block.getLocation();
BlockState blockState = block.getState();

String edit1 = event.getLine(0);
String edit2 = event.getLine(1);
String edit3 = event.getLine(2);
String edit4 = event.getLine(3);
String line1 = "";
String line2 = "";
String line3 = "";
Expand Down Expand Up @@ -59,24 +63,30 @@ protected void onSignChange(SignChangeEvent event) {
backGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, false);
isWaxed = BukkitAdapter.ADAPTER.isWaxed(sign);

if (line1.length() > 0 || line2.length() > 0 || line3.length() > 0 || line4.length() > 0 || line5.length() > 0 || line6.length() > 0 || line7.length() > 0 || line8.length() > 0) {
if (isFront && line1.equals(edit1) && line2.equals(edit2) && line3.equals(edit3) && line4.equals(edit4)) {
return;
}
else if (!isFront && line5.equals(edit1) && line6.equals(edit2) && line7.equals(edit3) && line8.equals(edit4)) {
return;
}
else if (line1.length() > 0 || line2.length() > 0 || line3.length() > 0 || line4.length() > 0 || line5.length() > 0 || line6.length() > 0 || line7.length() > 0 || line8.length() > 0) {
existingText = true;
Queue.queueSignText(player, location, 0, color, colorSecondary, frontGlowing, backGlowing, isWaxed, isFront, line1, line2, line3, line4, line5, line6, line7, line8, 1);
Queue.queueBlockPlace(player, blockState, block.getType(), blockState, block.getType(), -1, 0, blockState.getBlockData().getAsString());
}
}

if (isFront) {
line1 = event.getLine(0);
line2 = event.getLine(1);
line3 = event.getLine(2);
line4 = event.getLine(3);
line1 = edit1;
line2 = edit2;
line3 = edit3;
line4 = edit4;
}
else {
line5 = event.getLine(0);
line6 = event.getLine(1);
line7 = event.getLine(2);
line8 = event.getLine(3);
line5 = edit1;
line6 = edit2;
line7 = edit3;
line8 = edit4;
}

if (existingText || line1.length() > 0 || line2.length() > 0 || line3.length() > 0 || line4.length() > 0 || line5.length() > 0 || line6.length() > 0 || line7.length() > 0 || line8.length() > 0) {
Expand Down

0 comments on commit e501046

Please sign in to comment.