Help With Faction API?!?!

Discussion in 'Plugin Development' started by waco001, Oct 13, 2012.

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

    waco001

    Hi I read the tutorial @: http://forums.bukkit.org/threads/how-to-check-if-a-player-is-in-a-safezone-factions.104416/
    However when a friend and I spent over 2 hours on that code, nothing happened. I add checkpoints and changed everything I could, I have the following code:
    PHP:
        public void onPlayerThrowGrenade (PlayerEggThrowEvent e) {
            
    Bukkit.getServer().broadcastMessage("POINT1");
     
            
    FLocation from FPlayers.i.get(e.getPlayer()).getLastStoodAt();
            
    Faction faction = (Board.getFactionAt(from));
            if (
    Board.getFactionAt(faction).isSafeZone() == true){
                if ((
    getConfig().getBoolean("enabled") == true)){
                    
    Bukkit.getServer().broadcastMessage("POINT2");
                    if(
    e.getPlayer().hasPermission("grenade.throw")){
     
                        
    Bukkit.getServer().broadcastMessage("POINT3");
     
                        
    e.getEgg().getLocation().getWorld().createExplosion(e.getEgg().getLocation(), getConfig().getInt("power"));
                        if (
    getConfig().getBoolean("broadcast") == trueBukkit.getServer().broadcastMessage(ChatColor.RED e.getPlayer().getName() + " threw a grenade!");
                    }
                }
            }
        }
    }
    Could anyone possibly help me solve this problem? Thx

    And when testing, I only get to POINT 1

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  2. Offline

    Vandrake

    First you need to add more debug messages. That's too little to find the cause.
    Then this is wrong :confused: Did you read my "tutorial"? you are trying to get the factions twice. I doubt that will work. Add me on skype I'll teach you "vanndrake"
    Faction faction = (Board.getFactionAt(from));
    if (
    Board.getFactionAt(faction)
     
  3. Offline

    TwistedMexi

    Code:
        public void onPlayerThrowGrenade (PlayerEggThrowEvent e) {
            Bukkit.getServer().broadcastMessage("POINT1");
     
            FLocation from = FPlayers.i.get(e.getPlayer()).getLastStoodAt();
            Faction faction = (Board.getFactionAt(from));
            Bukkit.getServer().broadcastMessage("POINT2");
            if (Board.getFactionAt(faction).isSafeZone() == true){
    Bukkit.getServer().broadcastMessage("POINT3");
                if ((getConfig().getBoolean("enabled") == true)){
                    Bukkit.getServer().broadcastMessage("POINT4");
                    if(e.getPlayer().hasPermission("grenade.throw")){
     
                        Bukkit.getServer().broadcastMessage("POINT5");
     
                        e.getEgg().getLocation().getWorld().createExplosion(e.getEgg().getLocation(), getConfig().getInt("power"));
                        if (getConfig().getBoolean("broadcast") == true)
                        Bukkit.getServer().broadcastMessage(ChatColor.RED + e.getPlayer().getName() + " threw a grenade!");
                    }
                }
            }
        }
    } 
    This will help you pinpoint the exact stopping point.
     
  4. Offline

    xXSniperzzXx_SD

    Going along with the faction api, how would i allow friendly fire if people are in a certain list?
    And hey Waco :p
     
  5. Offline

    Vandrake

    if getfaction of attacker is same as defender = Friendly fire. no?I never tried this so xD
     
  6. Offline

    xXSniperzzXx_SD

    Well i can check if both people are ally/enemies/members/etc but i dont got a clue how i'd enable pvp for em...
     
  7. Offline

    Vandrake

    I think that's a factions thing? They disabled friendly fire in the configurations. Can't be sure though o.o
     
  8. Offline

    xXSniperzzXx_SD

    Ya it is, but i want to be able to enable it for certain people
     
  9. Offline

    Vandrake

    i dont think you can. unless you do the oposite. allow friendly fire and if they are not in a list cancel the attack
     
Thread Status:
Not open for further replies.

Share This Page