mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Tweak ShareHandler a bit.
This commit is contained in:
parent
c9aba059e2
commit
5af1164b5c
@ -41,9 +41,6 @@ public final class ShareHandler {
|
||||
|
||||
private ShareHandler() {}
|
||||
|
||||
private static List<Player> nearMembers;
|
||||
private static int partySize;
|
||||
|
||||
/**
|
||||
* Distribute Xp amongst party members.
|
||||
*
|
||||
@ -55,30 +52,28 @@ public final class ShareHandler {
|
||||
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
switch (party.getXpShareMode()) {
|
||||
case EQUAL:
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
||||
|
||||
if (nearMembers.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
double partySize = nearMembers.size() + 1;
|
||||
double shareBonus = Math.min(Config.getInstance().getPartyShareBonusBase() + partySize * Config.getInstance().getPartyShareBonusIncrease(), Config.getInstance().getPartyShareBonusCap());
|
||||
float splitXp = (float) (xp / partySize * shareBonus);
|
||||
|
||||
for (Player member : nearMembers) {
|
||||
UserManager.getPlayer(member).beginUnsharedXpGain(skillType, splitXp);
|
||||
}
|
||||
|
||||
mcMMOPlayer.beginUnsharedXpGain(skillType, splitXp);
|
||||
return true;
|
||||
|
||||
case NONE:
|
||||
default:
|
||||
return false;
|
||||
if (party.getXpShareMode() != ShareMode.EQUAL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
List<Player> nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
||||
|
||||
if (nearMembers.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nearMembers.add(player);
|
||||
|
||||
int partySize = nearMembers.size();
|
||||
double shareBonus = Math.min(Config.getInstance().getPartyShareBonusBase() + (partySize * Config.getInstance().getPartyShareBonusIncrease()), Config.getInstance().getPartyShareBonusCap());
|
||||
float splitXp = (float) (xp / partySize * shareBonus);
|
||||
|
||||
for (Player member : nearMembers) {
|
||||
UserManager.getPlayer(member).beginUnsharedXpGain(skillType, splitXp);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,8 +104,7 @@ public final class ShareHandler {
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
||||
List<Player> nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
||||
|
||||
if (nearMembers.isEmpty()) {
|
||||
return false;
|
||||
@ -120,7 +114,7 @@ public final class ShareHandler {
|
||||
ItemStack newStack = itemStack.clone();
|
||||
|
||||
nearMembers.add(player);
|
||||
partySize = nearMembers.size();
|
||||
int partySize = nearMembers.size();
|
||||
|
||||
drop.remove();
|
||||
newStack.setAmount(1);
|
||||
|
Loading…
Reference in New Issue
Block a user