mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-25 12:45:35 +01:00
parent
b340c7246b
commit
25404d6c92
@ -11,6 +11,7 @@
|
|||||||
package nl.matsv.viabackwards;
|
package nl.matsv.viabackwards;
|
||||||
|
|
||||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||||
|
import nl.matsv.viabackwards.listener.FireExtinguishListener;
|
||||||
import nl.matsv.viabackwards.listener.LecternInteractListener;
|
import nl.matsv.viabackwards.listener.LecternInteractListener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
@ -27,8 +28,11 @@ public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onServerLoaded() {
|
private void onServerLoaded() {
|
||||||
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_14.getId()) {
|
|
||||||
BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader();
|
BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader();
|
||||||
|
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_16.getVersion()) {
|
||||||
|
loader.storeListener(new FireExtinguishListener(this)).register();
|
||||||
|
}
|
||||||
|
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_14.getVersion()) {
|
||||||
loader.storeListener(new LecternInteractListener(this)).register();
|
loader.storeListener(new LecternInteractListener(this)).register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package nl.matsv.viabackwards.listener;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.BukkitPlugin;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
||||||
|
|
||||||
|
public class FireExtinguishListener extends ViaBukkitListener {
|
||||||
|
|
||||||
|
public FireExtinguishListener(BukkitPlugin plugin) {
|
||||||
|
super(plugin, Protocol1_15_2To1_16.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onLecternInteract(PlayerInteractEvent event) {
|
||||||
|
if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
|
||||||
|
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
if (block == null) return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (!isOnPipe(player)) return;
|
||||||
|
|
||||||
|
Block relative = block.getRelative(event.getBlockFace());
|
||||||
|
if (relative.getType() == Material.FIRE) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
relative.setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,12 +21,12 @@ public class LecternInteractListener extends ViaBukkitListener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onLecternInteract(PlayerInteractEvent event) {
|
public void onLecternInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (!isOnPipe(player)) return;
|
|
||||||
|
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if (block == null || block.getType() != Material.LECTERN) return;
|
if (block == null || block.getType() != Material.LECTERN) return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (!isOnPipe(player)) return;
|
||||||
|
|
||||||
Lectern lectern = (Lectern) block.getState();
|
Lectern lectern = (Lectern) block.getState();
|
||||||
ItemStack book = lectern.getInventory().getItem(0);
|
ItemStack book = lectern.getInventory().getItem(0);
|
||||||
if (book == null) return;
|
if (book == null) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user