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
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?
@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.
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."
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?
@KarimAKL I meant instead of Code: if (a>=b) { return; } //Do stuff Do this Code: if(!a>=b) { //Do stuff }
https://hastebin.com/jecafolulu.java Here's my entire class. Do you also have btw tips that bypass this "code spamm"?
@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'