Fixed sign edits being logged even if no changes were made

This commit is contained in:
Intelli 2023-07-14 15:27:30 -06:00
parent c6a0f20fff
commit e501046073

View File

@ -27,6 +27,10 @@ public final class SignChangeListener extends Queue implements Listener {
Location location = block.getLocation(); Location location = block.getLocation();
BlockState blockState = block.getState(); 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 line1 = "";
String line2 = ""; String line2 = "";
String line3 = ""; String line3 = "";
@ -59,7 +63,13 @@ public final class SignChangeListener extends Queue implements Listener {
backGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, false); backGlowing = BukkitAdapter.ADAPTER.isGlowing(sign, false);
isWaxed = BukkitAdapter.ADAPTER.isWaxed(sign); 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; existingText = true;
Queue.queueSignText(player, location, 0, color, colorSecondary, frontGlowing, backGlowing, isWaxed, isFront, line1, line2, line3, line4, line5, line6, line7, line8, 1); 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()); Queue.queueBlockPlace(player, blockState, block.getType(), blockState, block.getType(), -1, 0, blockState.getBlockData().getAsString());
@ -67,16 +77,16 @@ public final class SignChangeListener extends Queue implements Listener {
} }
if (isFront) { if (isFront) {
line1 = event.getLine(0); line1 = edit1;
line2 = event.getLine(1); line2 = edit2;
line3 = event.getLine(2); line3 = edit3;
line4 = event.getLine(3); line4 = edit4;
} }
else { else {
line5 = event.getLine(0); line5 = edit1;
line6 = event.getLine(1); line6 = edit2;
line7 = event.getLine(2); line7 = edit3;
line8 = event.getLine(3); 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) { 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) {