Tweak ShareHandler a bit.

This commit is contained in:
GJ 2013-07-15 09:40:07 -04:00
parent c9aba059e2
commit 5af1164b5c

View File

@ -41,9 +41,6 @@ public final class ShareHandler {
private ShareHandler() {} private ShareHandler() {}
private static List<Player> nearMembers;
private static int partySize;
/** /**
* Distribute Xp amongst party members. * Distribute Xp amongst party members.
* *
@ -55,30 +52,28 @@ public final class ShareHandler {
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) { public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
Party party = mcMMOPlayer.getParty(); Party party = mcMMOPlayer.getParty();
switch (party.getXpShareMode()) { if (party.getXpShareMode() != ShareMode.EQUAL) {
case EQUAL: return false;
}
Player player = mcMMOPlayer.getPlayer(); 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()) { if (nearMembers.isEmpty()) {
return false; return false;
} }
double partySize = nearMembers.size() + 1; nearMembers.add(player);
double shareBonus = Math.min(Config.getInstance().getPartyShareBonusBase() + partySize * Config.getInstance().getPartyShareBonusIncrease(), Config.getInstance().getPartyShareBonusCap());
int partySize = nearMembers.size();
double shareBonus = Math.min(Config.getInstance().getPartyShareBonusBase() + (partySize * Config.getInstance().getPartyShareBonusIncrease()), Config.getInstance().getPartyShareBonusCap());
float splitXp = (float) (xp / partySize * shareBonus); float splitXp = (float) (xp / partySize * shareBonus);
for (Player member : nearMembers) { for (Player member : nearMembers) {
UserManager.getPlayer(member).beginUnsharedXpGain(skillType, splitXp); UserManager.getPlayer(member).beginUnsharedXpGain(skillType, splitXp);
} }
mcMMOPlayer.beginUnsharedXpGain(skillType, splitXp);
return true; return true;
case NONE:
default:
return false;
}
} }
/** /**
@ -109,8 +104,7 @@ public final class ShareHandler {
} }
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
List<Player> nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) { if (nearMembers.isEmpty()) {
return false; return false;
@ -120,7 +114,7 @@ public final class ShareHandler {
ItemStack newStack = itemStack.clone(); ItemStack newStack = itemStack.clone();
nearMembers.add(player); nearMembers.add(player);
partySize = nearMembers.size(); int partySize = nearMembers.size();
drop.remove(); drop.remove();
newStack.setAmount(1); newStack.setAmount(1);