Fix TNTSimulatorListener
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
ba4d8e5a28
Commit
0811f41b45
@ -32,12 +32,18 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import static de.steamwar.bausystem.features.simulator.TNTSimulator.WAND;
|
||||
import static de.steamwar.bausystem.features.simulator.TNTSimulator.get;
|
||||
|
||||
@ -88,14 +94,22 @@ public class TNTSimulatorListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
simulatorShowHide(e.getPlayer(), PlayerInventory::getItemInMainHand, e.getTo());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerItemHeld(PlayerItemHeldEvent e) {
|
||||
simulatorShowHide(e.getPlayer(), i -> i.getItem(e.getNewSlot()), e.getPlayer().getLocation());
|
||||
}
|
||||
|
||||
private void simulatorShowHide(Player player, Function<PlayerInventory, ItemStack> itemStackFunction, Location location) {
|
||||
TNTSimulator simulator = get(player);
|
||||
if (!player.getInventory().getItemInMainHand().isSimilar(WAND)) {
|
||||
if (!itemStackFunction.apply(player.getInventory()).isSimilar(WAND)) {
|
||||
simulator.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
simulator.show(trace(player, e.getTo()));
|
||||
simulator.show(trace(player, location));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren