Solved [Solved]Sending Players Block on BlockPhysicsEvent

Discussion in 'Spigot Plugin Development' started by FREE2WIN, Mar 9, 2020.

Thread Status:
Not open for further replies.
  1. Hello,
    I want to hide some important stuff on our server. For that I use
    Code (Text):
    p.sendBlockChange(Location,Block);
    To keep things secret I have implemented this into an BlockPhysicsEvent. Now my issue:
    I want to hide Redstone stuff(Redstone Wire, Observer, repeater and so on). When I activate the redstone wire, the block becomes my block(here Stone..). But when the texture of the redstone wire gets an update, the block is no longer stone.
    Code (Text):
    @EventHandler(priority = EventPriority.HIGHEST)
        public void onBlockPhysics(BlockPhysicsEvent e) {
            if(Main.materials.contains(e.getBlock().getType())) {
                for(Player p:Bukkit.getServer().getOnlinePlayers()) {
                    p.sendBlockChange(e.getBlock().getLocation(), Material.STONE.createBlockData());
                }
            }
        }
    In Main.Materials I save materials i want to hide..

    Is it possible to fire that event after the local Blockupdate?
     
  2. What do you mean by "if the redstone wire gets an update"? Another signal or if you extend it by another redstone piece?
    Especially redstone has multiple block updates. Each connection point causes a new block update and depending on where the signal comes from, it has different powers which also causes a new update.
     
  3. I mean, i power the redstone:)
    I have the same code in the BlockRedstoneEvent. But always the same problem..
    When I extend the redstone, the redstone wire 2 blocks away become stone..
     
  4. Use a runnable to run the code a little bit later (in order to wait for all the block updates to be compelted)
     
    • Like Like x 1
  5. That works, thanks!(I use a asyncDelayedTask with one tick delay.)
     
Thread Status:
Not open for further replies.