Faction Commands (API help)

Discussion in 'Plugin Development' started by flash1110, Sep 8, 2015.

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

    flash1110

    Hello,

    I'm currently coding a plugin for an extension of Factions. I need to block setting a fhome between a certain height. How would I get the event/command that a faction home has been set? I'm using the version of Factions before the transitioned to full MCore. (The Version with /f who, /f mod)
     
  2. Offline

    JABBZxLILJAY320

    I would just use a PlayerCommandPreprocessEvent and check if they typed the command "/f sethome" and if so check their Y to make sure they aren't higher than what you want players to set an f home at. Hope this helped.
     
  3. Code:
    @EventHandler
    public void onCommand(PlayerCommandPreprocessEvent event) {
    Player player = event.getPlayer();
    
    if(player.getLocation().getY() > 200) { //height
      if(event.getMessage().toLowerCase().startsWith("/f sethome")) {
       event.setCancelled(true);
       player.sendMessage(ChatColor.RED + "You can't use that command here");
      }
    }
    }
    
     
  4. Offline

    Xerox262

    And if the player does /faction rather than /f? i mean, listening for the EventFactionsHomeChange (if he's using mc core factions) would probably be better if you ask me. But hey what do I know?
     
  5. Offline

    mythbusterma

    @Xerox262

    Xerox has the right idea, since they provide an event for you to listen for, listen for it, and if they're in an undesirable area, cancel the event.
     
    Last edited by a moderator: Oct 23, 2015
Thread Status:
Not open for further replies.

Share This Page