Solved Factions API

Discussion in 'Plugin Development' started by iforgot290, Nov 19, 2012.

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

    iforgot290

    I'm trying to hook into factions API, but I cant seem to get the FPlayer stuff to work
    For example, if I wanted to set a join message to the color of the relation of the player to you, I am doing this:

    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerJoin(PlayerJoinEvent event){
    4. Player player = event.getPlayer();
    5. event.setJoinMessage(null);
    6. for (Player p : Bukkit.getOnlinePlayers()){
    7. FPlayer fp = (FPlayer)p;
    8. FPlayer fp2 = (FPlayer)player;
    9. ChatColor color = fp.getRelationTo(fp2);
    10. p.sendMessage(color+player.getName()+ChatColor.GRAY+" has joined the game");
    11. }
    12. }


    Then when a player joins, I get the error of FPlayer cannot be cast to Player

    I know that the problem is at FPlayer fp = (FPlayer)p; and FPlayer fp2 = (FPlayer)player;
    But how could I change that part to work?
     
  2. Offline

    fireblast709

    Because Player does not extend FPlayer
    [EDIT]
    Code:java
    1. FPlayers.i.get(player);

    got this from the API. Make sure it does not return null!
     
  3. Offline

    iforgot290

    aight thanks, changing tag to solved
     
Thread Status:
Not open for further replies.

Share This Page