forked from zhdev/griefus
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
|
|
@ -1,6 +1,7 @@
|
|||
package net.coreprotect.paper;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
|
|
@ -27,19 +28,21 @@ public class PaperAdapter implements PaperInterface {
|
|||
|
||||
switch (paperVersion) {
|
||||
case PAPER_UNAVAILABLE:
|
||||
case PAPER_V1_13:
|
||||
case PAPER_V1_14:
|
||||
PaperAdapter.ADAPTER = new PaperAdapter();
|
||||
break;
|
||||
case PAPER_V1_13:
|
||||
case PAPER_V1_14:
|
||||
case PAPER_V1_15:
|
||||
PaperAdapter.ADAPTER = new PaperHandler();
|
||||
break;
|
||||
case PAPER_V1_16:
|
||||
PaperAdapter.ADAPTER = new Paper_v1_16();
|
||||
break;
|
||||
case PAPER_V1_17:
|
||||
case PAPER_V1_18:
|
||||
case PAPER_V1_19:
|
||||
default:
|
||||
PaperAdapter.ADAPTER = new Paper_v1_16();
|
||||
PaperAdapter.ADAPTER = new Paper_v1_17();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -54,4 +57,9 @@ public class PaperAdapter implements PaperInterface {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
return sign.getLine(line);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package net.coreprotect.paper;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
|
|
@ -10,4 +11,6 @@ public interface PaperInterface {
|
|||
|
||||
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