Custom Plugin List Message + Negate Fall Damage

Discussion in 'Plugin Development' started by Camaflicks, Jun 24, 2014.

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

    Camaflicks

    I am currently developing a Hub plugin and don't wont players to see what the plugins are. When someone types /plugin or /pl I want it to say in color, "Plugins made by PistonGaming". I also was wondering how to negate fall damage for my double jump plugin, which is also part of the Hub plugin. When I double jump and land on a fence, I lose half my hearts. How would I disable this?

    Thanks guys!

    - Camaflicks
     
  2. Offline

    Traks

    1. Create a listener that listens for PlayerCommandPreprocessEvent and check if the command is /pl or /plugins.
    2. Cancel the EntityDamageEvent if the entity is a player and the damage is done by falling.
     
  3. Offline

    iQuetzalito

    For the plugin command, make a new plugin and make a command "plugin".

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String cmmd, String args[]){
    2. Player p = (Player) sender;
    3. //should probably check if player is sender
    4. if(cmmd.equalsIgnoreCase("plugin") ||
    5. cmmd.equalsIgnoreCase("pl")){
    6. p.sendMessage(ChatColor.RED + "Plugins made by PistonGaming.");
    7. }


    For the no fall damage, just use the EntityDamageEvent and get how they were damaged, Cause.FALL and set it to event.setCancelled(true);
     
  4. Offline

    Camaflicks

    Traks Ok. The fall damage worked.
    Code:java
    1. @EventHandler
    2. public void onEntityDamage(EntityDamageEvent event){
    3. if(!(event.getEntity() instanceof Player)) return;
    4. if(event.getCause().equals(DamageCause.FALL)) {
    5. event.setCancelled(true);
    6. }
    7.  
    8. }


    Traks But I still cannot get the plugin thing to work :?

    iQuetzalito If I could meet you I would hug you. Maybe. Thank you so much dude!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    iQuetzalito

  6. Offline

    MCForger

    Camaflicks
    Just listen for the PlayerCommandPreprocessEvent and if the message equals ignorecase /plugin or /pl cancel the event and send a message to the player that attempted the command.
     
  7. Offline

    fireblast709

    /bukkit: plugins, I win (in other words, mind aliases. Also, remove that space between : and p).
     
  8. Offline

    MCForger

  9. Offline

    AoH_Ruthless

    Traks Camaflicks iQuetzalito
    In my opinion, it's easier to cancel fall damage with Player#setFallDistance(negative float value, like -500.0F);
    than to use the EntityDamageEvent -> DamageCause check. It at least seems better (one line of code opposed to 5 or 6, but amount of lines in your code doesn't really matter), but it does seem more efficient because you aren't listening for every single entity damage event...

    But hey, it works so I guess there isn't really a reason to fix what's not broken :)
     
  10. Offline

    Camaflicks

    MCForger fireblast709 Thank you both guys! fireblast, I actually did that already :p And MCForger, it works! Much better than what I tried xD

    AoH_Ruthless Thanks dude! I will try that so it looks nicer and just might work a tad better.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  11. Offline

    Traks

    AoH_Ruthless It doesn't really matter, two extra if-statements and no extra minecraft server and bukkit code when the event is cancelled. Also, with the method you provided, you have a lot less control...
     
  12. Offline

    AoH_Ruthless

    Traks
    How do I have less control over fall damage? I actually believe the opposite. Using the event and checking the damage cause has only one on/off toggle. With #setFallDistance(), you can change how far the 'no fall damage' is active, providing you with more control over the fall.
     
Thread Status:
Not open for further replies.

Share This Page