How to make a plugin that can toggle falldamage with a command

Discussion in 'Plugin Development' started by AJProCoding, Feb 19, 2015.

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

    AJProCoding

    How to make a bukkit plugin that can toggle fall damage on with a command.
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    AJProCoding

    I think there is no Damageevent
     
  4. Offline

    timtower Administrator Administrator Moderator

    @AJProCoding I know that for sure. I am giving the directions, you need to go there yourself.
     
  5. Offline

    DaanSander

    @AJProCoding

    Listener:
    Code:
    public static ArrayList<String> fall = new ArrayList<String>();
        @EventHandler
        public void onDamageEvent(EntityDamageEvent e) {
            Player p = (Player) e.getEntity();
            if(e.getCause() == DamageCause.FALL) {
                if(fall.contains(p.getName())) {
                    e.setCancelled(true);
                }
            }
        }
    main:
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("nofall") && sender instanceof Player) {
                Player p = (Player) sender;
                if(!PlayerListener.fall.contains(p.getName())) {
                    PlayerListener.fall.add(p.getName());
                    return true;
                } else{
                    PlayerListener.fall.remove(p.getName());
                }
            }
            return true;
        }
    if this helped please like
    if this solved your problem change the title to solved
     
  6. Offline

    AJProCoding

    Can somebody also show me how to do it with all the players on the server
     
  7. Offline

    Bancey

    @AJProCoding use a FOR loop to iterate through the online players.
     
  8. Offline

    Zombie_Striker

    You could make a public boolean that, if true, will cancel fall damage for anyone.
     
  9. Offline

    SuperOriginal

    I haven't seen much serious spoonfeed in a while, I was starting to gain hope.

    *sobs*
     
  10. Offline

    teej107

    @SuperOriginal Not only that, the spoonfed code is terrible like most spoonfed code.
     
  11. Offline

    DaanSander

    whats wrong with my code then?!
     
  12. Offline

    1Rogue

    I'll just stop there
     
    teej107 and SuperOriginal like this.
Thread Status:
Not open for further replies.

Share This Page