Added legacy component serialization support for signs in Paper 1.17+
This commit is contained in:
parent
5eabee6504
commit
20710a00de
4 changed files with 34 additions and 7 deletions
|
|
@ -38,6 +38,7 @@ import net.coreprotect.config.Config;
|
||||||
import net.coreprotect.consumer.Queue;
|
import net.coreprotect.consumer.Queue;
|
||||||
import net.coreprotect.database.Database;
|
import net.coreprotect.database.Database;
|
||||||
import net.coreprotect.model.BlockGroup;
|
import net.coreprotect.model.BlockGroup;
|
||||||
|
import net.coreprotect.paper.PaperAdapter;
|
||||||
import net.coreprotect.utility.Util;
|
import net.coreprotect.utility.Util;
|
||||||
|
|
||||||
public final class BlockBreakListener extends Queue implements Listener {
|
public final class BlockBreakListener extends Queue implements Listener {
|
||||||
|
|
@ -278,10 +279,10 @@ public final class BlockBreakListener extends Queue implements Listener {
|
||||||
try {
|
try {
|
||||||
Location location = blockState.getLocation();
|
Location location = blockState.getLocation();
|
||||||
Sign sign = (Sign) blockLog.getState();
|
Sign sign = (Sign) blockLog.getState();
|
||||||
String line1 = sign.getLine(0);
|
String line1 = PaperAdapter.ADAPTER.getLine(sign, 0);
|
||||||
String line2 = sign.getLine(1);
|
String line2 = PaperAdapter.ADAPTER.getLine(sign, 1);
|
||||||
String line3 = sign.getLine(2);
|
String line3 = PaperAdapter.ADAPTER.getLine(sign, 2);
|
||||||
String line4 = sign.getLine(3);
|
String line4 = PaperAdapter.ADAPTER.getLine(sign, 3);
|
||||||
int color = sign.getColor().getColor().asRGB();
|
int color = sign.getColor().getColor().asRGB();
|
||||||
boolean isGlowing = BukkitAdapter.ADAPTER.isGlowing(sign);
|
boolean isGlowing = BukkitAdapter.ADAPTER.isGlowing(sign);
|
||||||
Queue.queueSignText(user, location, 0, color, isGlowing, line1, line2, line3, line4, 5);
|
Queue.queueSignText(user, location, 0, color, isGlowing, line1, line2, line3, line4, 5);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package net.coreprotect.paper;
|
package net.coreprotect.paper;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
|
|
@ -27,19 +28,21 @@ public class PaperAdapter implements PaperInterface {
|
||||||
|
|
||||||
switch (paperVersion) {
|
switch (paperVersion) {
|
||||||
case PAPER_UNAVAILABLE:
|
case PAPER_UNAVAILABLE:
|
||||||
case PAPER_V1_13:
|
|
||||||
case PAPER_V1_14:
|
|
||||||
PaperAdapter.ADAPTER = new PaperAdapter();
|
PaperAdapter.ADAPTER = new PaperAdapter();
|
||||||
break;
|
break;
|
||||||
|
case PAPER_V1_13:
|
||||||
|
case PAPER_V1_14:
|
||||||
case PAPER_V1_15:
|
case PAPER_V1_15:
|
||||||
PaperAdapter.ADAPTER = new PaperHandler();
|
PaperAdapter.ADAPTER = new PaperHandler();
|
||||||
break;
|
break;
|
||||||
case PAPER_V1_16:
|
case PAPER_V1_16:
|
||||||
|
PaperAdapter.ADAPTER = new Paper_v1_16();
|
||||||
|
break;
|
||||||
case PAPER_V1_17:
|
case PAPER_V1_17:
|
||||||
case PAPER_V1_18:
|
case PAPER_V1_18:
|
||||||
case PAPER_V1_19:
|
case PAPER_V1_19:
|
||||||
default:
|
default:
|
||||||
PaperAdapter.ADAPTER = new Paper_v1_16();
|
PaperAdapter.ADAPTER = new Paper_v1_17();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -54,4 +57,9 @@ public class PaperAdapter implements PaperInterface {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLine(Sign sign, int line) {
|
||||||
|
return sign.getLine(line);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package net.coreprotect.paper;
|
package net.coreprotect.paper;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
|
|
@ -10,4 +11,6 @@ public interface PaperInterface {
|
||||||
|
|
||||||
public boolean isStopping(Server server);
|
public boolean isStopping(Server server);
|
||||||
|
|
||||||
|
public String getLine(Sign sign, int line);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
src/main/java/net/coreprotect/paper/Paper_v1_17.java
Normal file
15
src/main/java/net/coreprotect/paper/Paper_v1_17.java
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package net.coreprotect.paper;
|
||||||
|
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
|
||||||
|
public class Paper_v1_17 extends Paper_v1_16 implements PaperInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLine(Sign sign, int line) {
|
||||||
|
// https://docs.adventure.kyori.net/serializer/
|
||||||
|
return LegacyComponentSerializer.legacySection().serialize(sign.line(line));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue