Solved EXP issues

Discussion in 'Plugin Development' started by GodCipher, Oct 9, 2019.

Thread Status:
Not open for further replies.
  1. Code:
        public void onLevelWhenGroup(String customName, String startsWith, int maximumLevelToGetAnyExp, int playerLevel, int nearbyGroupMemberLevel, int expGetting, Player p, Player nearbyGroupMember) {
        
            if(customName.startsWith(startsWith)) {
                if(!(playerLevel >= maximumLevelToGetAnyExp)) {
                    p.giveExp(expGetting);
                    p.sendMessage("§e[Debug-WithGroup] §7You got §b" + expGetting + "§7 exp");
                }
    
                if(nearbyGroupMemberLevel >= maximumLevelToGetAnyExp) {
                    return;
                }
                nearbyGroupMember.giveExp(expGetting);
                nearbyGroupMember.sendMessage("§e[Debug-WithGroup] §7You got §b" + expGetting + "§7 exp as group member");
    
            }
        }
    Hey, I got a problem here that I can't find. If the level of the party member is higher than the maximum level to get EXP, he will still get EXP if a party member kills a monster. It's not supposed to be like that.

    I'm looking ahead for a positive answer.

    Greetings
     
  2. Offline

    timtower Administrator Administrator Moderator

    @GodCipher Could you rephrase that while using the variable names?
     
  3. sure

    Code:
                                                      
     int nearbyGroupMemberLevel = cfg2.getInt(groupMembers.getUniqueId() + ".level");
    
    int playerLevel = cfg2.getInt(p.getUniqueId() + ".level");
                                                        
    onLevelWhenGroup(le.getCustomName(), "§8[§eLvl 1§8]", 6, playerLevel, nearbyGroupMemberLevel, 1, p, groupMembers);
    
    you mean like that?
     
  4. Offline

    timtower Administrator Administrator Moderator

    @GodCipher More like this:
    Hey, I got a problem here that I can't find. If the level of the
    nearbyGroupMemberLevel is higher than maximumLevelToGetAnyExp, nearbyGroupMemberLevel still get EXP if p kills a monster. It's not supposed to be like that.
     
  5. Ohhhh, yeeeee

    "Hey, I got a problem here that i can't find. If the level of nearbyGroupMember -> nearbyGroupMemberLevel is higher than maximumLevelToGetAnyExp, than nearbyGroupMember will still get EXP (expGetting), if p kills a monster. It's not supposed to be like that."
     
  6. Offline

    robertlit

    Just to make the code cleaner, instead of checking if something is true and returning if it is, just check if it is not true. Can you post the code where you implement the method?
     
  7. Offline

    timtower Administrator Administrator Moderator

    @GodCipher Print the values side by side.
    What are the values?
     
  8. Offline

    KarimAKL

    If you do that you'll get a lot of nested scopes.
     
  9. Offline

    robertlit

    @KarimAKL I meant instead of
    Code:
    if (a>=b) {
    return;
    }
    //Do stuff
    
    Do this
    Code:
    if(!a>=b) {
    //Do stuff
    }
     
  10. Last edited: Oct 9, 2019
  11. Offline

    KarimAKL

    @robertlit
    1. That's exactly what i mean, if you keep doing that, you'll get a lot of nested scopes.
    2. I'm pretty sure you need to do '!(a>=b)' instead of '!a>=b'
    3. If you do that, you might as well do 'a<b'
     
  12. Offline

    timtower Administrator Administrator Moderator

  13. Okay, and whats the wrong now, that the nearbyGroupMember is still getting exp?
     
  14. Offline

    timtower Administrator Administrator Moderator

    Debug this check:
    if(nearbyGroupMemberLevel >= maximumLevelToGetAnyExp) {
    return;
    }
     
Thread Status:
Not open for further replies.

Share This Page