SteamWar/BauSystem2.0
Archiviert
12
0

Fix SmartPlaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2023-12-22 11:48:55 +01:00
Ursprung 0bf27db398
Commit 927ce1f495

Datei anzeigen

@ -40,6 +40,8 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -106,29 +108,16 @@ public class SmartPlaceListener implements Plain, Listener {
}
}
boolean sneaking = player.isSneaking();
run(player, packet, true, sneaking, shouldSneak);
return null;
if (sneaking) SMART_PLACING.add(player);
player.setSneaking(shouldSneak || sneaking);
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
SMART_PLACING.remove(player);
player.setSneaking(sneaking);
}, 0);
return packet;
});
}
private void run(Player player, Object packet, boolean first, boolean sneaking, boolean shouldSneak) {
if (sneaking) SMART_PLACING.add(player);
player.setSneaking(shouldSneak || sneaking);
try {
packetExecutor.invoke(playerConnection.get(getHandle.invoke(player)), packet);
} catch (Exception e) {
return;
} finally {
SMART_PLACING.remove(player);
player.setSneaking(sneaking);
}
if (!WAS_EXECUTED.contains(player) && first) {
run(player, packet, false, sneaking, shouldSneak);
}
WAS_EXECUTED.remove(player);
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;