mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
more work towards party stuff
This commit is contained in:
parent
85ad0ddd17
commit
a8257f3d6e
@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.axes.Axes;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
|
@ -4,10 +4,8 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -13,7 +13,6 @@ import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -6,12 +6,10 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -5,12 +5,10 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
|
@ -4,9 +4,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.api.exceptions.ProfileRetrievalException;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.MobHealthBarType;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.datatypes.experience;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -2,10 +2,6 @@ package com.gmail.nossr50.datatypes.experience;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.experience.SkillXpGain;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PersistentPlayerData;
|
||||
@ -19,16 +15,13 @@ import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ExperienceManager {
|
||||
|
||||
|
@ -1,21 +1,11 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import com.gmail.nossr50.chat.SamePartyPredicate;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.google.common.base.Objects;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Party {
|
||||
@ -29,7 +19,7 @@ public class Party {
|
||||
|
||||
//Initialize Managers
|
||||
partyMemberManager = new PartyMemberManager(persistentPartyData);
|
||||
partyExperienceManager = new PartyExperienceManager();
|
||||
partyExperienceManager = new PartyExperienceManager(partyMemberManager, this);
|
||||
samePartyPredicate = new SamePartyPredicate<>(this);
|
||||
}
|
||||
|
||||
@ -41,11 +31,11 @@ public class Party {
|
||||
return partyExperienceManager;
|
||||
}
|
||||
|
||||
public Set<PartyMember> getPartyMembers() {
|
||||
public @NotNull Set<PartyMember> getPartyMembers() {
|
||||
return partyMemberManager.getPartyMembers();
|
||||
}
|
||||
|
||||
public String getPartyName() {
|
||||
public @NotNull String getPartyName() {
|
||||
return persistentPartyData.getPartyName();
|
||||
}
|
||||
|
||||
@ -67,12 +57,15 @@ public class Party {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Party party = (Party) o;
|
||||
return Objects.equal(persistentPartyData, party.persistentPartyData);
|
||||
return samePartyPredicate.equals(party.samePartyPredicate)
|
||||
&& persistentPartyData.equals(party.persistentPartyData)
|
||||
&& partyMemberManager.equals(party.partyMemberManager)
|
||||
&& partyExperienceManager.equals(party.partyExperienceManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(persistentPartyData);
|
||||
return Objects.hash(samePartyPredicate, persistentPartyData, partyMemberManager, partyExperienceManager);
|
||||
}
|
||||
|
||||
public @NotNull Predicate<CommandSender> getSamePartyPredicate() {
|
||||
|
@ -17,13 +17,20 @@ public class PartyExperienceManager {
|
||||
|
||||
private int partyLevel;
|
||||
private float partyExperience;
|
||||
private ShareMode xpShareMode = ShareMode.NONE;
|
||||
private final @NotNull Party partyRef;
|
||||
private final @NotNull PartyMemberManager partyMemberManagerRef;
|
||||
private @NotNull ShareMode xpShareMode = ShareMode.NONE;
|
||||
|
||||
public void setXpShareMode(ShareMode xpShareMode) {
|
||||
public PartyExperienceManager(@NotNull PartyMemberManager partyMemberManager, @NotNull Party party) {
|
||||
this.partyRef = party;
|
||||
this.partyMemberManagerRef = partyMemberManager;
|
||||
}
|
||||
|
||||
public void setXpShareMode(@NotNull ShareMode xpShareMode) {
|
||||
this.xpShareMode = xpShareMode;
|
||||
}
|
||||
|
||||
public ShareMode getXpShareMode() {
|
||||
public @NotNull ShareMode getXpShareMode() {
|
||||
return xpShareMode;
|
||||
}
|
||||
|
||||
@ -33,7 +40,7 @@ public class PartyExperienceManager {
|
||||
* @param xp Experience amount to add
|
||||
*/
|
||||
public void applyXpGain(float xp) {
|
||||
if (!EventUtils.handlePartyXpGainEvent(this, xp)) {
|
||||
if (!EventUtils.handlePartyXpGainEvent(partyRef, xp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -54,12 +61,12 @@ public class PartyExperienceManager {
|
||||
levelsGained++;
|
||||
}
|
||||
|
||||
if (!EventUtils.handlePartyLevelChangeEvent(this, levelsGained, xpRemoved)) {
|
||||
if (!EventUtils.handlePartyLevelChangeEvent(partyRef, levelsGained, xpRemoved)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getPartyInformAllMembers()) {
|
||||
Player leader = mcMMO.p.getServer().getPlayer(this.leader.getUniqueId());
|
||||
Player leader = mcMMO.p.getServer().getPlayer(partyMemberManagerRef.getPartyLeader().getUniqueId());
|
||||
|
||||
if (leader != null) {
|
||||
leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel()));
|
||||
@ -68,10 +75,10 @@ public class PartyExperienceManager {
|
||||
SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.getPartyManager().informPartyMembersLevelUp(this, levelsGained, getLevel());
|
||||
} else {
|
||||
mcMMO.getPartyManager().informPartyMembersLevelUp(partyRef, levelsGained, getLevel());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasReachedLevelCap() {
|
||||
@ -79,19 +86,19 @@ public class PartyExperienceManager {
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
return partyLevel;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
partyLevel = level;
|
||||
}
|
||||
|
||||
public float getXp() {
|
||||
return xp;
|
||||
return partyExperience;
|
||||
}
|
||||
|
||||
public void setXp(float xp) {
|
||||
this.xp = xp;
|
||||
this.partyExperience = xp;
|
||||
}
|
||||
|
||||
public void addXp(float xp) {
|
||||
@ -107,13 +114,18 @@ public class PartyExperienceManager {
|
||||
return xpRemoved;
|
||||
}
|
||||
|
||||
//TODO: Why is it based on the number of party members? seems dumb
|
||||
public int getXpToLevel() {
|
||||
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
|
||||
return (mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType)) * (getPartyMembers().size() + Config.getInstance().getPartyXpCurveMultiplier());
|
||||
return (mcMMO.getFormulaManager().getXPtoNextLevel(partyLevel, formulaType)) * (partyMemberManagerRef.getPartyMembers().size() + Config.getInstance().getPartyXpCurveMultiplier());
|
||||
}
|
||||
|
||||
public @NotNull String getXpToLevelPercentage() {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
return percent.format(this.getXp() / getXpToLevel());
|
||||
}
|
||||
|
||||
public @NotNull Party getParty() {
|
||||
return partyRef;
|
||||
}
|
||||
}
|
||||
|
@ -130,4 +130,8 @@ public class PartyMemberManager {
|
||||
|
||||
return nearMembers;
|
||||
}
|
||||
|
||||
public @NotNull PartyMember getPartyLeader() {
|
||||
return persistentPartyData.getPartyLeader();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.dirtydata.DirtySet;
|
||||
import com.gmail.nossr50.datatypes.mutableprimitives.MutableBoolean;
|
||||
import com.gmail.nossr50.datatypes.mutableprimitives.MutableString;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
@ -16,7 +15,7 @@ public class PersistentPartyData {
|
||||
private final @NotNull MutableBoolean dirtyFlag; //Dirty values in this class will change this flag as needed
|
||||
private final @NotNull DirtyData<MutableString> partyName;
|
||||
private final @NotNull DirtySet<PartyMember> partyMembers; //TODO: Add cache for subsets
|
||||
private @Nullable PartyMember partyLeaderRef;
|
||||
private @NotNull PartyMember partyLeaderRef;
|
||||
|
||||
public PersistentPartyData(@NotNull String partyName,
|
||||
@NotNull Set<PartyMember> partyMembers) {
|
||||
@ -33,11 +32,12 @@ public class PersistentPartyData {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Make it impossible for the party leader to be null
|
||||
if(partyLeaderRef == null)
|
||||
throw new RuntimeException("Party leader is null!");
|
||||
}
|
||||
|
||||
public @Nullable PartyMember getPartyLeader() {
|
||||
public @NotNull PartyMember getPartyLeader() {
|
||||
return partyLeaderRef;
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,13 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import com.gmail.nossr50.config.WorldBlacklist;
|
||||
import com.gmail.nossr50.chat.author.PlayerAuthor;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.ChatConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.WorldBlacklist;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.interfaces.Toolable;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
@ -40,12 +33,9 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||
import com.gmail.nossr50.util.input.AbilityActivationProcessor;
|
||||
import com.gmail.nossr50.util.input.SuperAbilityManager;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import net.kyori.adventure.identity.Identified;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
@ -5,8 +5,8 @@ import com.gmail.nossr50.commands.admin.CompatibilityCommand;
|
||||
import com.gmail.nossr50.commands.admin.McmmoReloadLocaleCommand;
|
||||
import com.gmail.nossr50.commands.admin.PlayerDebugCommand;
|
||||
import com.gmail.nossr50.commands.chat.McChatSpy;
|
||||
import com.gmail.nossr50.commands.database.McpurgeCommand;
|
||||
import com.gmail.nossr50.commands.database.DatabaseRemovePlayerCommand;
|
||||
import com.gmail.nossr50.commands.database.McpurgeCommand;
|
||||
import com.gmail.nossr50.commands.database.MmoshowdbCommand;
|
||||
import com.gmail.nossr50.commands.experience.AddlevelsCommand;
|
||||
import com.gmail.nossr50.commands.experience.AddxpCommand;
|
||||
|
@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -12,7 +12,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PartyUtils {
|
||||
public static boolean isAllowed(@NotNull Party party, @NotNull PartyFeature partyFeature) {
|
||||
|
@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.listeners.InteractionManager;
|
||||
import com.gmail.nossr50.runnables.skills.SkillUnlockNotificationTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -17,7 +17,6 @@ import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.AbstractPersistentDataLayer;
|
||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
Loading…
Reference in New Issue
Block a user