forked from Upstream/mmocore
Merge remote-tracking branch 'origin/master'
# Conflicts: # MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java
This commit is contained in:
commit
41617f722c
@ -196,6 +196,20 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.civious</groupId>
|
||||||
|
<artifactId>OBTeam</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.playavalon</groupId>
|
||||||
|
<artifactId>DungeonParties</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alessiodp</groupId>
|
<groupId>com.alessiodp</groupId>
|
||||||
<artifactId>Parties</artifactId>
|
<artifactId>Parties</artifactId>
|
||||||
|
@ -21,6 +21,7 @@ import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
|||||||
import net.Indyuce.mmocore.api.player.profess.Subclass;
|
import net.Indyuce.mmocore.api.player.profess.Subclass;
|
||||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||||
import net.Indyuce.mmocore.manager.data.OfflinePlayerData;
|
import net.Indyuce.mmocore.manager.data.OfflinePlayerData;
|
||||||
|
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||||
import net.Indyuce.mmocore.skill.binding.BoundSkillInfo;
|
import net.Indyuce.mmocore.skill.binding.BoundSkillInfo;
|
||||||
import net.Indyuce.mmocore.api.player.social.FriendRequest;
|
import net.Indyuce.mmocore.api.player.social.FriendRequest;
|
||||||
import net.Indyuce.mmocore.api.player.stats.PlayerStats;
|
import net.Indyuce.mmocore.api.player.stats.PlayerStats;
|
||||||
@ -151,14 +152,15 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
|||||||
* /mmocore reload
|
* /mmocore reload
|
||||||
*/
|
*/
|
||||||
public void reload() {
|
public void reload() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
profess = profess == null ? null : MMOCore.plugin.classManager.get(profess.getId());
|
profess = profess == null ? null : MMOCore.plugin.classManager.get(profess.getId());
|
||||||
getStats().updateStats();
|
getStats().updateStats();
|
||||||
} catch (NullPointerException exception) {
|
} catch (NullPointerException exception) {
|
||||||
MMOCore.log(Level.SEVERE, "[Userdata] Could not find class " + getProfess().getId() + " while refreshing player data.");
|
MMOCore.log(Level.SEVERE, "[Userdata] Could not find class " + getProfess().getId() + " while refreshing player data.");
|
||||||
}
|
}
|
||||||
|
//We remove all the stats and buffs associated to triggers.
|
||||||
|
getMMOPlayerData().getStatMap().getInstances().forEach(statInstance -> statInstance.removeIf(key ->key.startsWith(Trigger.TRIGGER_PREFIX)));
|
||||||
|
getMMOPlayerData().getSkillModifierMap().getInstances().forEach(skillModifierInstance -> skillModifierInstance.removeIf(key ->key.startsWith(Trigger.TRIGGER_PREFIX)));
|
||||||
final Iterator<Map.Entry<Integer, BoundSkillInfo>> ite = boundSkills.entrySet().iterator();
|
final Iterator<Map.Entry<Integer, BoundSkillInfo>> ite = boundSkills.entrySet().iterator();
|
||||||
while (ite.hasNext())
|
while (ite.hasNext())
|
||||||
try {
|
try {
|
||||||
@ -167,10 +169,9 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
|||||||
final String skillId = entry.getValue().getClassSkill().getSkill().getHandler().getId();
|
final String skillId = entry.getValue().getClassSkill().getSkill().getHandler().getId();
|
||||||
final @Nullable ClassSkill classSkill = getProfess().getSkill(skillId);
|
final @Nullable ClassSkill classSkill = getProfess().getSkill(skillId);
|
||||||
Validate.notNull(skillSlot, "Could not find skill slot n" + entry.getKey());
|
Validate.notNull(skillSlot, "Could not find skill slot n" + entry.getKey());
|
||||||
Validate.notNull(skillSlot, "Could not find skill with ID '" + skillId + "'");
|
Validate.notNull(classSkill, "Could not find skill with ID '" + skillId + "'");
|
||||||
|
unbindSkill(entry.getKey());
|
||||||
entry.getValue().close();
|
bindSkill(entry.getKey(), classSkill);
|
||||||
boundSkills.put(entry.getKey(), new BoundSkillInfo(skillSlot, classSkill, this));
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not reload data of '" + getPlayer().getName() + "': " + exception.getMessage());
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not reload data of '" + getPlayer().getName() + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,10 @@ public class PlayerAttributes {
|
|||||||
return (int) d;
|
return (int) d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSpent() {
|
||||||
|
return spent;
|
||||||
|
}
|
||||||
|
|
||||||
public AttributeModifier getModifier(String key) {
|
public AttributeModifier getModifier(String key) {
|
||||||
return map.get(key);
|
return map.get(key);
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,6 @@ public class StatTrigger extends Trigger implements Removable {
|
|||||||
prevModifier.add(amount).register(player.getMMOPlayerData());
|
prevModifier.add(amount).register(player.getMMOPlayerData());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the effect of the trigger to the player by registering the
|
|
||||||
* opposite amount. (Little corrective term for the relative to have the inverse.
|
|
||||||
* Not a problem to store twice the stat modifiers are there only remain in the RAM.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(PlayerData playerData) {
|
public void remove(PlayerData playerData) {
|
||||||
playerData.getMMOPlayerData().getStatMap().getInstance(stat).remove(modifierKey);
|
playerData.getMMOPlayerData().getStatMap().getInstance(stat).remove(modifierKey);
|
||||||
|
@ -7,6 +7,7 @@ import io.lumine.mythic.lib.manager.StatManager;
|
|||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
||||||
import net.Indyuce.mmocore.api.quest.PlayerQuests;
|
import net.Indyuce.mmocore.api.quest.PlayerQuests;
|
||||||
import net.Indyuce.mmocore.experience.PlayerProfessions;
|
import net.Indyuce.mmocore.experience.PlayerProfessions;
|
||||||
import net.Indyuce.mmocore.experience.Profession;
|
import net.Indyuce.mmocore.experience.Profession;
|
||||||
@ -16,10 +17,10 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.attribute.AttributeInstance;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -71,7 +72,15 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
|||||||
String id = identifier.substring(12);
|
String id = identifier.substring(12);
|
||||||
RegisteredSkill skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(id), "Could not find skill with ID '" + id + "'");
|
RegisteredSkill skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(id), "Could not find skill with ID '" + id + "'");
|
||||||
return String.valueOf(playerData.getSkillLevel(skill));
|
return String.valueOf(playerData.getSkillLevel(skill));
|
||||||
} else if (identifier.equals("level_percent")) {
|
}
|
||||||
|
else if(identifier.startsWith("mmocore_attribute_points_spent_")){
|
||||||
|
String attributeId=identifier.substring(31);
|
||||||
|
PlayerAttributes.AttributeInstance attributeInstance=Objects.requireNonNull(playerData.getAttributes().getInstance(attributeId),"Could not find attribute with ID '"+attributeId+"'");
|
||||||
|
return String.valueOf(attributeInstance.getSpent());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if (identifier.equals("level_percent")) {
|
||||||
double current = playerData.getExperience(), next = playerData.getLevelUpExperience();
|
double current = playerData.getExperience(), next = playerData.getLevelUpExperience();
|
||||||
return MythicLib.plugin.getMMOConfig().decimal.format(current / next * 100);
|
return MythicLib.plugin.getMMOConfig().decimal.format(current / next * 100);
|
||||||
} else if (identifier.equals("health"))
|
} else if (identifier.equals("health"))
|
||||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmocore.gui;
|
|||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||||
|
import me.ulrich.clans.manager.I;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.SoundEvent;
|
import net.Indyuce.mmocore.api.SoundEvent;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
@ -88,6 +89,8 @@ public class SkillList extends EditableInventory {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if(function.equals("selected"))
|
||||||
|
return new SelectedItem(config);
|
||||||
|
|
||||||
return new SimplePlaceholderItem(config);
|
return new SimplePlaceholderItem(config);
|
||||||
}
|
}
|
||||||
@ -96,6 +99,31 @@ public class SkillList extends EditableInventory {
|
|||||||
return new SkillViewerInventory(data, this);
|
return new SkillViewerInventory(data, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SelectedItem extends InventoryItem<SkillViewerInventory> {
|
||||||
|
public SelectedItem(ConfigurationSection config) {
|
||||||
|
//We must use this constructor to show that there are not specified material
|
||||||
|
super(Material.BARRIER,config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack display(SkillViewerInventory inv, int n) {
|
||||||
|
ItemStack item =super.display(inv, n);
|
||||||
|
if(inv.selected== null)
|
||||||
|
return new ItemStack(Material.AIR);
|
||||||
|
if (inv.selected != null) {
|
||||||
|
item.setType(inv.selected.getSkill().getIcon().getType());
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Placeholders getPlaceholders(SkillViewerInventory inv, int n) {
|
||||||
|
Placeholders holders= new Placeholders();
|
||||||
|
holders.register("selected", inv.selected.getSkill().getName());
|
||||||
|
return holders;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class LevelItem extends InventoryItem<SkillViewerInventory> {
|
public class LevelItem extends InventoryItem<SkillViewerInventory> {
|
||||||
private final int offset;
|
private final int offset;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.gui;
|
package net.Indyuce.mmocore.gui;
|
||||||
|
|
||||||
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.skilltree.NodeStatus;
|
import net.Indyuce.mmocore.skilltree.NodeStatus;
|
||||||
@ -120,6 +121,8 @@ public class SkillTreeViewer extends EditableInventory {
|
|||||||
lore.add(holders.apply(inv.getPlayer(), string));
|
lore.add(holders.apply(inv.getPlayer(), string));
|
||||||
});
|
});
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
|
if (MythicLib.plugin.getVersion().isStrictlyHigher(1, 13))
|
||||||
|
meta.setCustomModelData(skillTree.getCustomModelData());
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
container.set(new NamespacedKey(MMOCore.plugin, "skill-tree-id"), PersistentDataType.STRING, skillTree.getId());
|
container.set(new NamespacedKey(MMOCore.plugin, "skill-tree-id"), PersistentDataType.STRING, skillTree.getId());
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
@ -4,6 +4,7 @@ import io.lumine.mythic.lib.MythicLib;
|
|||||||
import io.lumine.mythic.lib.UtilityMethods;
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.api.player.profess.ClassOption;
|
||||||
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
||||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||||
import net.Indyuce.mmocore.gui.api.InventoryClickContext;
|
import net.Indyuce.mmocore.gui.api.InventoryClickContext;
|
||||||
@ -112,13 +113,18 @@ public class SubclassSelect extends EditableInventory {
|
|||||||
|
|
||||||
if (item.getFunction().startsWith("sub-class")) {
|
if (item.getFunction().startsWith("sub-class")) {
|
||||||
String classId = item.getFunction().substring(10);
|
String classId = item.getFunction().substring(10);
|
||||||
|
PlayerClass profess = MMOCore.plugin.classManager.get(classId);
|
||||||
if (playerData.getClassPoints() < 1) {
|
if (playerData.getClassPoints() < 1) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(getPlayer());
|
MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(getPlayer());
|
||||||
new ConfigMessage("cant-choose-new-class").send(player);
|
new ConfigMessage("cant-choose-new-class").send(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (profess.hasOption(ClassOption.NEEDS_PERMISSION) && !player.hasPermission("mmocore.class." + profess.getId().toLowerCase())) {
|
||||||
|
MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(player);
|
||||||
|
new ConfigMessage("no-permission-for-class").send(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
InventoryManager.CLASS_CONFIRM.get(classId).newInventory(playerData, this, true).open();
|
InventoryManager.CLASS_CONFIRM.get(classId).newInventory(playerData, this, true).open();
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ public enum PartyModuleType {
|
|||||||
MCMMO("mcMMO", McMMOPartyModule::new),
|
MCMMO("mcMMO", McMMOPartyModule::new),
|
||||||
MMOCORE("MMOCore", MMOCorePartyModule::new),
|
MMOCORE("MMOCore", MMOCorePartyModule::new),
|
||||||
PARTIES("Parties", PartiesPartyModule::new),
|
PARTIES("Parties", PartiesPartyModule::new),
|
||||||
|
MYTHICDUNGEONS("MythicDungeons", DungeonPartiesPartyModule::new),
|
||||||
|
OBTEAM("OBTeam", OBTeamPartyModule::new),
|
||||||
PARTY_AND_FRIENDS("PartyAndFriends", PAFPartyModule::new),
|
PARTY_AND_FRIENDS("PartyAndFriends", PAFPartyModule::new),
|
||||||
PARTY_AND_FRIENDS_BUNGEECORD_VELOCITY("Spigot-Party-API-PAF", PAFProxyPartyModule::new),
|
PARTY_AND_FRIENDS_BUNGEECORD_VELOCITY("Spigot-Party-API-PAF", PAFProxyPartyModule::new),
|
||||||
;
|
;
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package net.Indyuce.mmocore.party.compat;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.party.AbstractParty;
|
||||||
|
import net.Indyuce.mmocore.party.PartyModule;
|
||||||
|
import net.playavalon.avnparty.AvNParty;
|
||||||
|
import net.playavalon.avnparty.party.Party;
|
||||||
|
import net.playavalon.avnparty.player.AvalonPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DungeonPartiesPartyModule implements PartyModule, Listener {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public AbstractParty getParty(PlayerData playerData) {
|
||||||
|
final @Nullable Party party = AvNParty.plugin.players.get(playerData.getPlayer()).getParty();
|
||||||
|
return party == null ? null : new CustomParty(party);
|
||||||
|
}
|
||||||
|
|
||||||
|
class CustomParty implements AbstractParty {
|
||||||
|
private final Party party;
|
||||||
|
|
||||||
|
public CustomParty(Party party) {
|
||||||
|
this.party = party;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasMember(Player player) {
|
||||||
|
for (AvalonPlayer member : party.getPlayers())
|
||||||
|
if (member.getPlayer().getUniqueId().equals(player.getUniqueId())) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PlayerData> getOnlineMembers() {
|
||||||
|
final List<PlayerData> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (AvalonPlayer member : party.getPlayers())
|
||||||
|
try {
|
||||||
|
list.add(PlayerData.get(member.getPlayer().getUniqueId()));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countMembers() {
|
||||||
|
return party.getPlayers().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -68,7 +68,7 @@ public class DungeonsXLPartyModule implements PartyModule, Listener {
|
|||||||
MMOCore.plugin.partyManager.getBonuses().forEach(buff -> buff.unregister(player.getMMOPlayerData()));
|
MMOCore.plugin.partyManager.getBonuses().forEach(buff -> buff.unregister(player.getMMOPlayerData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomParty implements AbstractParty, Listener {
|
class CustomParty implements AbstractParty {
|
||||||
private final PlayerGroup group;
|
private final PlayerGroup group;
|
||||||
|
|
||||||
public CustomParty(PlayerGroup group) {
|
public CustomParty(PlayerGroup group) {
|
||||||
|
@ -74,12 +74,11 @@ public class McMMOPartyModule implements PartyModule, Listener {
|
|||||||
MMOCore.plugin.partyManager.getBonuses().forEach(buff -> buff.unregister(player.getMMOPlayerData()));
|
MMOCore.plugin.partyManager.getBonuses().forEach(buff -> buff.unregister(player.getMMOPlayerData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomParty implements AbstractParty, Listener {
|
class CustomParty implements AbstractParty {
|
||||||
private final Party party;
|
private final Party party;
|
||||||
|
|
||||||
public CustomParty(Party party) {
|
public CustomParty(Party party) {
|
||||||
this.party = party;
|
this.party = party;
|
||||||
Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package net.Indyuce.mmocore.party.compat;
|
||||||
|
|
||||||
|
import com.civious.obteam.mechanics.Team;
|
||||||
|
import com.civious.obteam.mechanics.TeamManager;
|
||||||
|
import com.civious.obteam.mechanics.TeamMember;
|
||||||
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.party.AbstractParty;
|
||||||
|
import net.Indyuce.mmocore.party.PartyModule;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class OBTeamPartyModule implements PartyModule, Listener {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public AbstractParty getParty(PlayerData playerData) {
|
||||||
|
final @Nullable Team team = TeamManager.getInstance().getTeam(playerData.getPlayer());
|
||||||
|
return team == null ? null : new CustomParty(team);
|
||||||
|
}
|
||||||
|
|
||||||
|
class CustomParty implements AbstractParty {
|
||||||
|
private final Team team;
|
||||||
|
|
||||||
|
public CustomParty(Team team) {
|
||||||
|
this.team = team;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasMember(Player player) {
|
||||||
|
for (TeamMember member : team.getMembers())
|
||||||
|
if (member.getOfflinePlayer().getUniqueId().equals(player.getUniqueId())) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PlayerData> getOnlineMembers() {
|
||||||
|
final List<PlayerData> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (TeamMember member : team.getMembersAndOwner())
|
||||||
|
try {
|
||||||
|
list.add(PlayerData.get(member.getOfflinePlayer().getUniqueId()));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countMembers() {
|
||||||
|
return team.getMembersAndOwner().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -39,6 +39,8 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
|
|||||||
private final String id, name;
|
private final String id, name;
|
||||||
private final List<String> lore = new ArrayList<>();
|
private final List<String> lore = new ArrayList<>();
|
||||||
private final Material item;
|
private final Material item;
|
||||||
|
private final int customModelData;
|
||||||
|
|
||||||
//2 different maps to get the nodes
|
//2 different maps to get the nodes
|
||||||
|
|
||||||
//Represents all the coordinates that will be displayed as a path (between 2 nodes of the tree)
|
//Represents all the coordinates that will be displayed as a path (between 2 nodes of the tree)
|
||||||
@ -59,6 +61,7 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
|
|||||||
this.name = MythicLib.plugin.parseColors(Objects.requireNonNull(config.getString("name"), "Could not find skill tree name"));
|
this.name = MythicLib.plugin.parseColors(Objects.requireNonNull(config.getString("name"), "Could not find skill tree name"));
|
||||||
Objects.requireNonNull(config.getStringList("lore"), "Could not find skill tree lore").forEach(str -> lore.add(MythicLib.plugin.parseColors(str)));
|
Objects.requireNonNull(config.getStringList("lore"), "Could not find skill tree lore").forEach(str -> lore.add(MythicLib.plugin.parseColors(str)));
|
||||||
this.item = Material.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("item"))));
|
this.item = Material.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("item"))));
|
||||||
|
this.customModelData = config.getInt("custom-model-data", 0);
|
||||||
Validate.isTrue(config.isConfigurationSection("nodes"), "Could not find any nodes in the tree");
|
Validate.isTrue(config.isConfigurationSection("nodes"), "Could not find any nodes in the tree");
|
||||||
this.maxPointSpent = config.getInt("max-point-spent", Integer.MAX_VALUE);
|
this.maxPointSpent = config.getInt("max-point-spent", Integer.MAX_VALUE);
|
||||||
for (String key : config.getConfigurationSection("nodes").getKeys(false)) {
|
for (String key : config.getConfigurationSection("nodes").getKeys(false)) {
|
||||||
@ -148,6 +151,10 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
|
|||||||
return maxPointSpent;
|
return maxPointSpent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCustomModelData() {
|
||||||
|
return customModelData;
|
||||||
|
}
|
||||||
|
|
||||||
public static SkillTree loadSkillTree(ConfigurationSection config) {
|
public static SkillTree loadSkillTree(ConfigurationSection config) {
|
||||||
SkillTree skillTree = null;
|
SkillTree skillTree = null;
|
||||||
|
|
||||||
|
@ -61,6 +61,8 @@ protect-custom-mine: false
|
|||||||
# - party_and_friends (Use this one if you are using Party and Friends Extended for Spigot)
|
# - party_and_friends (Use this one if you are using Party and Friends Extended for Spigot)
|
||||||
# - party_and_friends_bungeecord_velocity (Use this one if you are using Party and Friends For Bungeecord, Party and Friends For Velocity or Party and Friends Extended Edition for Bungeecord/Velocity. This one requires https://www.spigotmc.org/resources/spigot-party-api-for-party-and-friends.39751/ to be installed)
|
# - party_and_friends_bungeecord_velocity (Use this one if you are using Party and Friends For Bungeecord, Party and Friends For Velocity or Party and Friends Extended Edition for Bungeecord/Velocity. This one requires https://www.spigotmc.org/resources/spigot-party-api-for-party-and-friends.39751/ to be installed)
|
||||||
# - mcmmo
|
# - mcmmo
|
||||||
|
# - obteam (addon for DungeonMMO)
|
||||||
|
# - mythicdungeons (only when using default party handler)
|
||||||
party-plugin: mmocore
|
party-plugin: mmocore
|
||||||
|
|
||||||
# Edit the plugin handling guilds here.
|
# Edit the plugin handling guilds here.
|
||||||
|
@ -3,9 +3,9 @@ version: ${project.version}
|
|||||||
main: net.Indyuce.mmocore.MMOCore
|
main: net.Indyuce.mmocore.MMOCore
|
||||||
author: Indyuce
|
author: Indyuce
|
||||||
description: ${project.description}
|
description: ${project.description}
|
||||||
loadbefore: [ MMOItems ]
|
loadbefore: [ MMOItems,MythicDungeons ]
|
||||||
depend: [ MythicLib ]
|
depend: [ MythicLib ]
|
||||||
softdepend: [ Vault,MythicMobs,PlaceholderAPI,Residence,Citizens,ProtocolLib ]
|
softdepend: [ Vault,MythicMobs,PlaceholderAPI,Residence,Citizens,ProtocolLib,OBTeam ]
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
commands:
|
commands:
|
||||||
mmocore:
|
mmocore:
|
||||||
|
Loading…
Reference in New Issue
Block a user