SteamWar/BauSystem2.0
Archiviert
12
0

Fix SmartPlaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-10-03 23:02:11 +02:00
Ursprung 19b99ae8a0
Commit fc8d52cae4

Datei anzeigen

@ -37,6 +37,8 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
@Linked(LinkageType.LISTENER)
public class SmartPlaceListener implements Listener {
@ -62,9 +64,11 @@ public class SmartPlaceListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getPlayer().getGameMode() == GameMode.SPECTATOR) return;
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if (event.getPlayer().getGameMode() == GameMode.SPECTATOR) return;
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;
// Reverse repeater
if (event.getPlayer().isSneaking()) {
if (event.getClickedBlock().getType() == Material.REPEATER) {
if (event.getItem() != null && event.getMaterial() != Material.REPEATER) {
@ -79,8 +83,8 @@ public class SmartPlaceListener implements Listener {
}
return;
}
if (!event.getClickedBlock().getType().isInteractable()) return;
if (!event.getClickedBlock().getType().isInteractable()) return;
if (event.getItem() == null) return;
if (!event.getMaterial().isBlock()) return;
try {
@ -93,24 +97,20 @@ public class SmartPlaceListener implements Listener {
}
if (event.getClickedBlock().getType() == event.getMaterial()) {
switch (event.getMaterial()) {
case HOPPER:
case DISPENSER:
case DROPPER:
break;
default:
return;
if (!(event.getClickedBlock().getState() instanceof InventoryHolder)) {
return;
}
} else {
switch (event.getMaterial()) {
case REPEATER:
case COMPARATOR:
return;
default:
break;
BlockData blockData = event.getMaterial().createBlockData();
if (blockData instanceof Directional) {
return;
}
if (blockData instanceof Rotatable) {
return;
}
}
// TODO: Fix block setting
event.setUseInteractedBlock(Event.Result.DENY);
World world = event.getPlayer().getWorld();
Block block = world.getBlockAt(event.getClickedBlock().getX() + event.getBlockFace().getModX(), event.getClickedBlock().getY() + event.getBlockFace().getModY(), event.getClickedBlock().getZ() + event.getBlockFace().getModZ());