A suggestion for a new anti-grief feature on EMC?

Discussion in 'Community Discussion' started by Joshyy, Mar 8, 2012.

  1. Henry, But it'll need to be about 15/20 blocks and would be stopped by mobs, And blocks.
  2. 5 blocks is enough to not stand directly in new the lava or be directly ignited. If you stand at a position where people can pour lava 249 blocks over you head, bad luck.

    @JustinGuy:

    Code:
    public class NoFireKill extends JavaPlugin implements Listener {
    
        @Override
        public void onEnable() {
            this.getServer().getPluginManager().registerEvents(this, this);
        }
    
        @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
        public void onBlockPlace(BlockPlaceEvent event){
            if (Material.FIRE.equals(event.getBlock().getType())) {
                doCheck(event, event.getPlayer(), event.getBlockAgainst().getLocation());
            }
        }
    
        @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
        public void onBucketEmpty(PlayerBucketEmptyEvent event) {
            if (Material.LAVA_BUCKET.equals(event.getBucket())) {
                doCheck(event, event.getPlayer(), event.getBlockClicked().getLocation());
            }
        }
    
        protected void doCheck(Cancellable event, Player player, Location location) {
            if (otherPlayerAround(player, location)) {
                event.setCancelled(true);
                player.sendMessage("Keep away from other players when playing with fire!");
            }
        }
    
        protected boolean otherPlayerAround(Player player, Location location) {
            for (Player otherPlayer : location.getWorld().getPlayers()) {
                if (!otherPlayer.equals(player)) {
                    if (otherPlayer.getLocation().distance(location) <= 6) {
                        return true;
                    }
                }
            }
            return false;
        }
    
    Yes, I use the clicked block, in one case to save calculating the target block, in the other case to have both cases work the same way.
    copherfield likes this.
  3. Henry, If your sprinting and someone places lava infront of you 5 blocks ins't enough.
  4. Ok, I see this case. If Justin decides to use this, we should do some tests to find a usable compromise between "to restrictive" and "doesn't help enough". That'd be fun ;)

    20 blocks? You could sleepwalk around with that protection range.
  5. 15 to 20 blocks seems acceptable.
  6. It is not actually that far when you think about it, But I agree more like maybe 10-15? 10 will give you ample time to notice and stop and 15's just to be safe.
  7. 10 is ok, I think. I can think of a few cases of team-play where this can become annoying, but that's the price of safety. 15 is so much that people start becoming careless.

    I said 5 initially because this can only catch the least prepared PKing. If I really want to kill someone, I dig under the surface where I expect them to walk on. Leave 1 layer of dirt, then some air, then lava. Maybe put obsidian (or just a stack of sand) around the pit, so they cannot get out fast. When they come by, spleef!

    That'd be very hard to prevent, if not impossible. Preventing a BlockBreak if someone is standing on that block would be simple (same code as above, basically), but at 20 blocks distance and only if the drop is dangerous and the hole actually is in the path of the other player? No way.
  8. I got nothing of what you just wrote. I just gaved you a like because of you beard :p
  9. Well, i do have another 'square' so maybe your affirmation isn't true xD
  10. Justin made it first.
    copherfield likes this.
  11. LOL
    Indeed, it was Justin who made it.
    I wonder why wiki peeps forgot to add his name.
    Crazy1080 likes this.
  12. That code looks right to me. And the method names are probably wrong, but that's irrelevant.
  13. Crazy didn't get the joke -.-
  14. Hey copher xD breaked isn't a word lol
  15. I got the joke just as well, Justin invented squares. This is a fact.
  16. Sorry, english it's just my fourth language, After Spanish, Portuguese and French.
    jackomighty likes this.
  17. Nobody invented 'squares' ! Justin however did invent 'Square' :D