Change Int if player has permission

Discussion in 'Plugin Development' started by Serilum, Nov 15, 2012.

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

    Serilum

    Hello, I'm still trying to figure out this problem. I have tried multiple things so I wondered if the bukkit community could squash this bug.
    What I'm trying to do is change amount of warps a player can have by changing the "int maxWarps". While I'm almost sure that I'm using the right code, this does not seem to change.

    Code:java
    1. public static boolean SetWarp(String playerName, String warpName, Location location)
    2. {
    3. Hashtable<String, Location> warpList = GetWarpList(playerName);
    4. if(!warpList.containsKey(warpName))
    5. {
    6. int maxWarps = 3;
    7. if(MVP.IsPREM(playerName))
    8. maxWarps = 20;
    9. else
    10. if(VIP.IsElite(playerName))
    11. maxWarps = 15;
    12. else
    13. if(MVP.IsMVP(playerName))
    14. maxWarps = 12;
    15. else
    16. if(VIP.IsVIP(playerName))
    17. maxWarps = 8;
    18. if(maxWarps == -1 || warpList.keySet().size() >= maxWarps)
    19. return false;
    20. }
    21. warpList.put(warpName, location);
    22. SaveWarps(playerName);
    23. return true;
    24. }


    If anyone has an idea on how to fix this, I would be very grateful ;)
     
  2. Offline

    fireblast709

    check the keySet size and the maxWarps at that moment to see if it should even return false
     
  3. Offline

    Serilum

    Currently what it does is that it sets the warps to 3, in other words it uses the first line:
    "int maxWarps =3;". But the else/ifs does not seem to change that amount, which is what I'm aiming for
     
  4. Offline

    fireblast709

    then check whether the 4 functions return true/false and compare that to what they should return
     
  5. Code:
    int x = 12;
    if (player.hasPermission("some.pointless.permission")) {
        x = 54;
        return true;
    }
     
  6. Offline

    the_merciless

    Seriously, no one noticed the lack of brackets

    Code:
    public static boolean SetWarp(String playerName, String warpName, Location location)
    {
    Hashtable<String, Location> warpList = GetWarpList(playerName);
    if(!warpList.containsKey(warpName))
    {
    int maxWarps = 3;
    if(MVP.IsPREM(playerName)){
    maxWarps = 20;
    }else
    if(VIP.IsElite(playerName)){
    maxWarps = 15;
    }else
    if(MVP.IsMVP(playerName)){
    maxWarps = 12;
    }else
    if(VIP.IsVIP(playerName)){
    maxWarps = 8;
    }
    if(maxWarps == -1 || warpList.keySet().size() >= maxWarps){
    return false;
    }
    }
    warpList.put(warpName, location);
    SaveWarps(playerName);
    return true;
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  7. Offline

    cman1885

    Seriously, you never knew you don't need brackets for only one line of code?
    eg.
    Code:
    if(you.havePermission("pointless.perm"))
        return;
    else
        you.sendMessage("congratulations");
    
     
    fireblast709 likes this.
  8. Offline

    fireblast709

    The code is correct, he should check what is inside the if statements returns, like:
    Code:java
    1.  
    2. MVP.IsPREM(playerName);
    3. VIP.IsElite(playerName);
    4. MVP.IsMVP(playerName);
    5. VIP.IsVIP(playerName);
    6.  

    Is any of the above even returning true? Probably not, else you would not have the problem
     
Thread Status:
Not open for further replies.

Share This Page