Add SmartPlaceListener for Block under Repeater
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
d77e8e829e
Commit
552a1ea7fc
@ -24,6 +24,7 @@ import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.api.Plain;
|
||||
@ -41,9 +42,8 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -97,14 +97,17 @@ public class SmartPlaceListener implements Plain, Listener {
|
||||
TinyProtocol.instance.addFilter(useItem, (player, packet) -> {
|
||||
if(!Permission.BUILD.hasPermission(player)) return packet;
|
||||
if (!Config.getInstance().get(player).getPlainValueOrDefault("smartPlace", false)) return packet;
|
||||
Block block = player.getTargetBlockExact(6);
|
||||
RayTraceResult rayTraceResult = player.rayTraceBlocks(6);
|
||||
Block block = rayTraceResult != null ? rayTraceResult.getHitBlock() : null;
|
||||
BlockFace blockFace = rayTraceResult != null ? rayTraceResult.getHitBlockFace() : null;
|
||||
boolean shouldSneak = false;
|
||||
System.out.println(rayTraceResult + " " + block + " " + blockFace);
|
||||
if (block != null) {
|
||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||
if (block.getType().isInteractable() || block.getType() == Material.NOTE_BLOCK) {
|
||||
shouldSneak = true;
|
||||
}
|
||||
if (CONTAINERS.contains(block.getType())) {
|
||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||
if (itemStack.getType() == Material.TNT) {
|
||||
if (block.getType() == Material.CHEST || block.getType() == Material.BARREL || block.getType().name().endsWith("SHULKER_BOX")) {
|
||||
shouldSneak = false;
|
||||
@ -116,6 +119,9 @@ public class SmartPlaceListener implements Plain, Listener {
|
||||
if (IGNORED.contains(block.getType())) {
|
||||
shouldSneak = false;
|
||||
}
|
||||
if (blockFace == BlockFace.DOWN && (block.getType() == Material.REPEATER || block.getType() == Material.COMPARATOR) && itemStack.getType().isSolid()) {
|
||||
shouldSneak = true;
|
||||
}
|
||||
}
|
||||
boolean sneaking = player.isSneaking();
|
||||
if (sneaking) SMART_PLACING.add(player);
|
||||
@ -152,7 +158,7 @@ public class SmartPlaceListener implements Plain, Listener {
|
||||
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;
|
||||
if (!SMART_PLACING.contains(event.getPlayer())) {
|
||||
if (CONTAINERS.contains(event.getBlockAgainst().getType())) {
|
||||
if (Core.getVersion() >= 20 && CONTAINERS.contains(event.getBlockAgainst().getType())) {
|
||||
SoundGroup soundGroup = event.getBlockPlaced().getBlockData().getSoundGroup();
|
||||
event.getPlayer().playSound(event.getBlockPlaced().getLocation(), soundGroup.getPlaceSound(), soundGroup.getVolume() * 0.8F, soundGroup.getPitch() * 0.8F);
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren