Added party levels

Parties now have XP and Levels. Party features such as party teleport and party chat have to be unlocked before they can be used by the party members
This commit is contained in:
TfT_02
2013-11-11 17:42:57 +01:00
parent c729297615
commit 818962e668
34 changed files with 561 additions and 89 deletions

View File

@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
@ -24,7 +25,9 @@ import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.events.fake.FakePlayerFishEvent;
import com.gmail.nossr50.events.hardcore.McMMOPlayerDeathPenaltyEvent;
import com.gmail.nossr50.events.party.McMMOPartyLevelUpEvent;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.events.party.McMMOPartyXpGainEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
@ -108,6 +111,34 @@ public class EventUtils {
mcMMOPlayer.getPartyTeleportRecord().actualizeLastUse();
}
public static boolean handlePartyXpGainEvent(Party party, float xpGained) {
McMMOPartyXpGainEvent event = new McMMOPartyXpGainEvent(party, xpGained);
mcMMO.p.getServer().getPluginManager().callEvent(event);
boolean isCancelled = event.isCancelled();
if (!isCancelled) {
party.addXp(event.getRawXpGained());
}
return !isCancelled;
}
public static boolean handlePartyLevelChangeEvent(Party party, int levelsChanged, float xpRemoved) {
McMMOPartyLevelUpEvent event = new McMMOPartyLevelUpEvent(party, levelsChanged);
mcMMO.p.getServer().getPluginManager().callEvent(event);
boolean isCancelled = event.isCancelled();
if (isCancelled) {
party.setLevel(party.getLevel() + levelsChanged);
party.addXp(xpRemoved);
}
return !isCancelled;
}
public static boolean handleXpGainEvent(Player player, SkillType skill, float xpGained) {
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skill, xpGained);
mcMMO.p.getServer().getPluginManager().callEvent(event);

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.util;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
@ -30,7 +31,7 @@ public class StringUtils {
}
public static String getPrettySecondaryAbilityString(SecondaryAbility secondaryAbility) {
switch(secondaryAbility) {
switch (secondaryAbility) {
case HERBALISM_DOUBLE_DROPS:
case MINING_DOUBLE_DROPS:
case WOODCUTTING_DOUBLE_DROPS:
@ -46,6 +47,10 @@ public class StringUtils {
}
}
public static String getPrettyPartyFeatureString(PartyFeature partyFeature) {
return createPrettyEnumString(partyFeature.toString());
}
private static String createPrettyEnumString(String baseString) {
String[] substrings = baseString.split("_");
String prettyString = "";
@ -125,4 +130,5 @@ public class StringUtils {
return false;
}
}
}

View File

@ -330,7 +330,7 @@ public final class CommandRegistrationManager {
PluginCommand command = mcMMO.p.getCommand("party");
command.setDescription(LocaleLoader.getString("Commands.Description.party"));
command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" +
"mcmmo.commands.party.expshare;mcmmo.commands.party.invite;mcmmo.commands.party.itemshare;mcmmo.commands.party.join;" +
"mcmmo.commands.party.xpshare;mcmmo.commands.party.invite;mcmmo.commands.party.itemshare;mcmmo.commands.party.join;" +
"mcmmo.commands.party.kick;mcmmo.commands.party.lock;mcmmo.commands.party.owner;mcmmo.commands.party.password;" +
"mcmmo.commands.party.quit;mcmmo.commands.party.rename;mcmmo.commands.party.unlock");
command.setPermissionMessage(permissionsMessage);