diff --git a/all/pom.xml b/all/pom.xml index d1acd979..f45869b7 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -41,7 +41,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.1 + 3.2.2 false false @@ -91,36 +91,42 @@ nl.matsv viabackwards-core ${project.parent.version} + compile nl.matsv viabackwards-bukkit ${project.parent.version} + compile nl.matsv viabackwards-bungee ${project.parent.version} + compile nl.matsv viabackwards-fabric ${project.parent.version} + compile nl.matsv viabackwards-sponge ${project.parent.version} + compile nl.matsv viabackwards-velocity ${project.parent.version} + compile diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 8f98e030..a17c2698 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -12,12 +12,12 @@ + 4.0.0 viabackwards-parent nl.matsv 3.0.0-SNAPSHOT - 4.0.0 viabackwards-bukkit @@ -32,13 +32,14 @@ org.spigotmc spigot-api - 1.13-R0.1-SNAPSHOT + 1.15.2-R0.1-SNAPSHOT provided nl.matsv viabackwards-core ${project.parent.version} + compile diff --git a/bukkit/src/main/java/nl/matsv/viabackwards/BukkitPlugin.java b/bukkit/src/main/java/nl/matsv/viabackwards/BukkitPlugin.java index 4be9bd39..f761e9e4 100644 --- a/bukkit/src/main/java/nl/matsv/viabackwards/BukkitPlugin.java +++ b/bukkit/src/main/java/nl/matsv/viabackwards/BukkitPlugin.java @@ -11,13 +11,26 @@ package nl.matsv.viabackwards; import nl.matsv.viabackwards.api.ViaBackwardsPlatform; +import nl.matsv.viabackwards.listener.LecternInteractListener; import org.bukkit.plugin.java.JavaPlugin; +import us.myles.ViaVersion.api.Via; +import us.myles.ViaVersion.api.protocol.ProtocolRegistry; +import us.myles.ViaVersion.api.protocol.ProtocolVersion; +import us.myles.ViaVersion.bukkit.platform.BukkitViaLoader; public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform { @Override public void onEnable() { init(getDataFolder()); + Via.getPlatform().runSync(this::onServerLoaded); + } + + private void onServerLoaded() { + if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_14.getId()) { + BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader(); + loader.storeListener(new LecternInteractListener()).register(); + } } @Override diff --git a/bukkit/src/main/java/nl/matsv/viabackwards/listener/LecternInteractListener.java b/bukkit/src/main/java/nl/matsv/viabackwards/listener/LecternInteractListener.java new file mode 100644 index 00000000..36aa6ed7 --- /dev/null +++ b/bukkit/src/main/java/nl/matsv/viabackwards/listener/LecternInteractListener.java @@ -0,0 +1,47 @@ +package nl.matsv.viabackwards.listener; + +import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Lectern; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BookMeta; +import us.myles.ViaVersion.ViaVersionPlugin; +import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener; + +public class LecternInteractListener extends ViaBukkitListener { + + public LecternInteractListener() { + super(ViaVersionPlugin.getInstance(), Protocol1_13_2To1_14.class); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onLecternInteract(PlayerInteractEvent event) { + Player player = event.getPlayer(); + if (!isOnPipe(player)) return; + + Block block = event.getClickedBlock(); + if (block == null || block.getType() != Material.LECTERN) return; + + Lectern lectern = (Lectern) block.getState(); + ItemStack book = lectern.getInventory().getItem(0); + if (book == null) return; + + BookMeta meta = (BookMeta) book.getItemMeta(); + + // Open a book with the text of the lectern's writable book + ItemStack newBook = new ItemStack(Material.WRITTEN_BOOK); + BookMeta newBookMeta = (BookMeta) newBook.getItemMeta(); + newBookMeta.setPages(meta.getPages()); + newBookMeta.setAuthor("an upsidedown person"); + newBookMeta.setTitle("buk"); + newBook.setItemMeta(newBookMeta); + player.openBook(newBook); + + event.setCancelled(true); + } +} diff --git a/bungee/pom.xml b/bungee/pom.xml index d8f73ff1..92e3952c 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -12,12 +12,12 @@ + 4.0.0 viabackwards-parent nl.matsv 3.0.0-SNAPSHOT - 4.0.0 viabackwards-bungee @@ -34,7 +34,7 @@ net.md-5 bungeecord-api - 1.13-SNAPSHOT + 1.15-SNAPSHOT provided @@ -43,6 +43,7 @@ nl.matsv viabackwards-core ${project.parent.version} + compile diff --git a/core/pom.xml b/core/pom.xml index 3b670519..46c2a03a 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -12,22 +12,15 @@ + 4.0.0 viabackwards-parent nl.matsv 3.0.0-SNAPSHOT - 4.0.0 viabackwards-core - - - viaversion-repo - https://repo.viaversion.com/ - - - diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java index ded1308c..914d80f6 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java @@ -79,7 +79,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It if (type == 2) containerTitle = "Barrel"; stringType = "minecraft:container"; slotSize = (type + 1) * 9; - } else + } else { switch (type) { case 11: stringType = "minecraft:crafting_table"; @@ -126,6 +126,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It slotSize = 27; break; } + } if (stringType == null) { ViaBackwards.getPlatform().getLogger().warning("Can't open inventory for 1.13 player! Type: " + type); diff --git a/fabric/pom.xml b/fabric/pom.xml index c1086858..58dbf7c3 100644 --- a/fabric/pom.xml +++ b/fabric/pom.xml @@ -12,12 +12,12 @@ + 4.0.0 viabackwards-parent nl.matsv 3.0.0-SNAPSHOT - 4.0.0 viabackwards-fabric @@ -45,6 +45,7 @@ nl.matsv viabackwards-core ${project.parent.version} + compile diff --git a/sponge/pom.xml b/sponge/pom.xml index b01031ad..aa125d3b 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -12,12 +12,12 @@ + 4.0.0 viabackwards-parent nl.matsv 3.0.0-SNAPSHOT - 4.0.0 viabackwards-sponge @@ -70,6 +70,7 @@ nl.matsv viabackwards-core ${project.parent.version} + compile diff --git a/velocity/pom.xml b/velocity/pom.xml index 162c5196..a9f40c5f 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -12,12 +12,12 @@ + 4.0.0 viabackwards-parent nl.matsv 3.0.0-SNAPSHOT - 4.0.0 viabackwards-velocity @@ -70,6 +70,7 @@ nl.matsv viabackwards-core ${project.parent.version} + compile