[UTIL] BetterEvents! - New Events to bukkit!

Discussion in 'Plugin Development' started by erez9901, May 25, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    erez9901

    Hey Guys! I'm erez9901, The creator of the Hub plugin! - Hub Plugin

    This UTIL give you more useful events that are used very often!

    - PlayerBlockMoveEvent - Calls when player walk one block.
    - PlayerLookAtBlockEvent - Calls when player look at block (Great for detection!).
    - PlayerSwordBlock - Calls when player block with sword.
    - PlayerReleaseSwordBlock - Calls when player release the sword block.

    How to use?:
    Simply replace the old events register:

    Code:
    public void onEnable(){
        Bukkit.getServer().getPluginManager.registerEvents(listener,plugin);
    }
    With a new one:

    Code:
    public void onEnable(){
        BetterEvents.getBetterEvents().registerEvents(listener, plugin);
    }
    Thats it!

    Examples:

    - PlayerBlockMoveEvent:

    Code:
    @EventHandler
        public void onPlayerBlockMove(PlayerBlockMoveEvent e){
            Player p = e.getPlayer();
            p.sendMessage(ChatColor.RED + "You moved one block!");
        }
    - PlayerSwordBlockEvent:
    Code:
    @EventHandler
        public void onPlayerSwordBlock(PlayerSwordBlockEvent e){
            Player p = e.getPlayer();
            ItemStack sword = e.getSword();
            if(sword.getType() == Material.DIAMOND_SWORD){
                p.sendMessage(ChatColor.AQUA + "You are so OP!!!!");
            }
        }
    - PlayerReleaseSwordBlockEvent:

    Code:
    @EventHandler
        public void onPlayerSwordBlockRelease(PlayerReleaseSwordBlockEvent e){
            Player p = e.getPlayer();
            p.sendMessage(ChatColor.RED+ "Somebody can attack you..... you better block!");
        }

    Github here:

    www.github.com/erez9901/BetterEvents
     
    gabrielhowat likes this.
  2. Offline

    desht

    Your PlayerLookAtBlockEvent calls player.getTargetBlock() every single time someone moves or looks somewhere. You must really love those "can't keep up!" messages.
     
    DSH105, CeramicTitan, Cirno and 3 others like this.
  3. Offline

    erez9901

    desht
    Lol yea i know but.. is there another way of doing it?

    New version came out!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  4. lol... xD packet & NMS dude (xTrollxDudex ) strikes again :)

    erez9901 nice! would be cool to add some other events such as maybe player bow release event... where are you coming from?
     
  5. Offline

    erez9901

  6. Offline

    Garris0n

    EntityShootBowEvent

    Someone_Like_You The entire resource is questionable, really. The first one is just a great way to make the PlayerMoveEvent cause more lag, the second is an absolutely terrible idea that will completely destroy the TPS of any server it's running on, and the last two really should've been combined into one event.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
    Someone_Like_You likes this.
  7. Offline

    Cirno

    Most, if not all, of these "events" can be easily done with simple if-statements...
     
  8. Offline

    RawCode

    This UTIL give you more useful events that are used very often! erez9901

    20 times per second to be precise
     
  9. Garris0n yea I just noticed he checking every tick if the player still blocking, and his move events... bukkit forums are lucky to have people like you and few more people...
     
  10. Offline

    desht

    No, there isn't, but that's still not an excuse for bringing servers to a grinding halt with this sledgehammer-to-crack-a-walnut approach. Finding the block a player has targeted (not the cheapest of operations) should really only be done in reponse to a specific event (e.g. an interaction with some specific item), not every single time someone moves or looks around.
     
    mbaxter and Someone_Like_You like this.
  11. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Removed a derailment involving advertisement-based URL shorteners.
    edit: Removed more derailment...
     
Thread Status:
Not open for further replies.

Share This Page