From d83952ae5ce01cc0714eb3f3d3557f1ec17e6def Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 11 Mar 2022 16:39:42 +0100 Subject: [PATCH] Golden pressure plate --- src/de/steamwar/lobby/LobbySystem.java | 3 ++- .../lobby/listener/InventoryInteraction.java | 12 +++++++++--- .../steamwar/lobby/listener/WorldInteraction.java | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index 927c67b..d53da98 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -55,7 +55,8 @@ public class LobbySystem extends JavaPlugin { new ParticleListener(); new InventoryInteraction(); new WorldInteraction(); - new AlphaWall(l -> l.getZ() > 1250, AlphaWall.REFLECT_Z); + //new AlphaWall(l -> l.getZ() > 1250, AlphaWall.REFLECT_Z); + } diff --git a/src/de/steamwar/lobby/listener/InventoryInteraction.java b/src/de/steamwar/lobby/listener/InventoryInteraction.java index 8b41119..ac41aba 100644 --- a/src/de/steamwar/lobby/listener/InventoryInteraction.java +++ b/src/de/steamwar/lobby/listener/InventoryInteraction.java @@ -23,21 +23,27 @@ import de.steamwar.lobby.command.ModifyCommand; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerSwapHandItemsEvent; +import org.bukkit.inventory.ItemStack; public class InventoryInteraction extends BasicListener { @EventHandler(priority = EventPriority.LOW) public void handlePlayerInteract(PlayerInteractEvent event) { - if(event.getItem() == null) return; - if (event.getItem().getType() == Material.FIREWORK_ROCKET) { - event.getItem().setAmount(2); + ItemStack item = event.getItem(); + if(item == null) + return; + + if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && item.getType() == Material.FIREWORK_ROCKET) { + item.setAmount(2); return; } + if(!ModifyCommand.modifying(event.getPlayer())) event.setCancelled(true); } diff --git a/src/de/steamwar/lobby/listener/WorldInteraction.java b/src/de/steamwar/lobby/listener/WorldInteraction.java index 9528104..52c7463 100644 --- a/src/de/steamwar/lobby/listener/WorldInteraction.java +++ b/src/de/steamwar/lobby/listener/WorldInteraction.java @@ -20,13 +20,18 @@ package de.steamwar.lobby.listener; import de.steamwar.lobby.command.ModifyCommand; +import org.bukkit.Material; import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; public class WorldInteraction extends BasicListener { @@ -57,5 +62,14 @@ public class WorldInteraction extends BasicListener { if(!ModifyCommand.modifying((HumanEntity) event.getRemover())) event.setCancelled(true); } + + @EventHandler + public void handleGoldenPressurePlate(PlayerInteractEvent event) { + if(!event.hasBlock() || event.getAction() != Action.PHYSICAL || event.getClickedBlock().getType() != Material.LIGHT_WEIGHTED_PRESSURE_PLATE) + return; + + Player player = event.getPlayer(); + player.setVelocity(player.getLocation().getDirection().multiply(5).add(new Vector(0, 1, 0))); + } }