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
5f2c2f591f
@ -6,6 +6,8 @@ import io.lumine.mythic.lib.api.stat.StatInstance;
|
||||
import io.lumine.mythic.lib.api.stat.modifier.StatModifier;
|
||||
import io.lumine.mythic.lib.player.cooldown.CooldownMap;
|
||||
import io.lumine.mythic.lib.player.skill.PassiveSkill;
|
||||
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
||||
import net.Indyuce.mmocore.party.provided.Party;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.api.SoundEvent;
|
||||
@ -32,9 +34,8 @@ import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||
import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
|
||||
import net.Indyuce.mmocore.party.AbstractParty;
|
||||
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
||||
import net.Indyuce.mmocore.party.provided.Party;
|
||||
import net.Indyuce.mmocore.player.Unlockable;
|
||||
import net.Indyuce.mmocore.player.stats.StatInfo;
|
||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||
import net.Indyuce.mmocore.skill.cast.SkillCastingHandler;
|
||||
@ -170,24 +171,31 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
} finally {
|
||||
j++;
|
||||
}
|
||||
|
||||
for (SkillTree skillTree : profess.getSkillTrees()) {
|
||||
for (SkillTreeNode node : skillTree.getNodes()) {
|
||||
if (!nodeLevels.containsKey(node))
|
||||
nodeLevels.put(node, 0);
|
||||
}
|
||||
}
|
||||
|
||||
setupSkillTree();
|
||||
}
|
||||
|
||||
public void setupSkillTree() {
|
||||
// Node states setup
|
||||
for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll())
|
||||
//Node states setup
|
||||
for (SkillTree skillTree : profess.getSkillTrees())
|
||||
skillTree.setupNodeState(this);
|
||||
|
||||
// Stat triggers setup
|
||||
if (!statLoaded)
|
||||
for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll()) {
|
||||
for (SkillTreeNode node : skillTree.getNodes()) {
|
||||
if (!statLoaded) {
|
||||
for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll())
|
||||
for (SkillTreeNode node : skillTree.getNodes())
|
||||
node.getExperienceTable().claimStatTriggers(this, node);
|
||||
}
|
||||
}
|
||||
|
||||
statLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getPointSpent(SkillTree skillTree) {
|
||||
return pointSpent.getOrDefault(skillTree, 0);
|
||||
}
|
||||
@ -220,6 +228,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
return new HashMap(skillTreePoints);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void clearSkillTreePoints() {
|
||||
skillTreePoints.clear();
|
||||
}
|
||||
@ -358,19 +368,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
return result;
|
||||
}
|
||||
|
||||
public void resetNodeTimesClaimed() {
|
||||
Map<String, Integer> newTableItemClaims = new HashMap<>();
|
||||
tableItemClaims.forEach((str, val) -> {
|
||||
if (!str.startsWith(SkillTreeNode.getPrefix()))
|
||||
newTableItemClaims.put(str, val);
|
||||
});
|
||||
public void resetTimesClaimed() {
|
||||
tableItemClaims.clear();
|
||||
tableItemClaims.putAll(newTableItemClaims);
|
||||
}
|
||||
|
||||
|
||||
public void addNodeLevel(SkillTreeNode node) {
|
||||
nodeLevels.put(node, nodeLevels.get(node) + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
||||
import net.Indyuce.mmocore.tree.skilltree.SkillTree;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -14,210 +15,250 @@ import io.lumine.mythic.lib.command.api.CommandTreeNode;
|
||||
import io.lumine.mythic.lib.command.api.Parameter;
|
||||
|
||||
public class ResetCommandTreeNode extends CommandTreeNode {
|
||||
public ResetCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "reset");
|
||||
public ResetCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "reset");
|
||||
|
||||
addChild(new ResetLevelsCommandTreeNode(this));
|
||||
addChild(new ResetSkillsCommandTreeNode(this));
|
||||
addChild(new ResetAllCommandTreeNode(this));
|
||||
addChild(new ResetAttributesCommandTreeNode(this));
|
||||
addChild(new ResetWaypointsCommandTreeNode(this));
|
||||
}
|
||||
addChild(new ResetLevelsCommandTreeNode(this));
|
||||
addChild(new ResetSkillsCommandTreeNode(this));
|
||||
addChild(new ResetAllCommandTreeNode(this));
|
||||
addChild(new ResetAttributesCommandTreeNode(this));
|
||||
addChild(new ResetWaypointsCommandTreeNode(this));
|
||||
addChild(new ResetSkillTreesCommandTreeNode(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
return CommandResult.THROW_USAGE;
|
||||
}
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
return CommandResult.THROW_USAGE;
|
||||
}
|
||||
|
||||
public static class ResetAllCommandTreeNode extends CommandTreeNode {
|
||||
public ResetAllCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "all");
|
||||
public static class ResetAllCommandTreeNode extends CommandTreeNode {
|
||||
public ResetAllCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "all");
|
||||
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
MMOCore.plugin.dataProvider.getDataManager().getDefaultData().apply(data);
|
||||
data.setExperience(0);
|
||||
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
||||
data.getCollectionSkills().setExperience(profession, 0);
|
||||
data.getCollectionSkills().setLevel(profession, 0);
|
||||
}
|
||||
MMOCore.plugin.classManager.getAll().forEach(data::unloadClassInfo);
|
||||
data.getAttributes().getInstances().forEach(ins -> ins.setBase(0));
|
||||
data.mapSkillLevels().forEach((skill, level) -> data.resetSkillLevel(skill));
|
||||
while (data.hasSkillBound(0))
|
||||
data.unbindSkill(0);
|
||||
data.getQuestData().resetFinishedQuests();
|
||||
data.getQuestData().start(null);
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s data was succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
PlayerData data = PlayerData.get(player);
|
||||
MMOCore.plugin.dataProvider.getDataManager().getDefaultData().apply(data);
|
||||
data.setExperience(0);
|
||||
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
||||
data.getCollectionSkills().setExperience(profession, 0);
|
||||
data.getCollectionSkills().setLevel(profession, 0);
|
||||
}
|
||||
MMOCore.plugin.classManager.getAll().forEach(data::unloadClassInfo);
|
||||
data.getAttributes().getInstances().forEach(ins -> ins.setBase(0));
|
||||
data.mapSkillLevels().forEach((skill, level) -> data.resetSkillLevel(skill));
|
||||
data.setSkillTreePoints("global", 0);
|
||||
for (SkillTree skillTree : data.getProfess().getSkillTrees()) {
|
||||
data.resetSkillTree(skillTree);
|
||||
data.setSkillTreePoints(skillTree.getId(), 0);
|
||||
}
|
||||
|
||||
public static class ResetWaypointsCommandTreeNode extends CommandTreeNode {
|
||||
public ResetWaypointsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "waypoints");
|
||||
data.resetTimesClaimed();
|
||||
while (data.hasSkillBound(0))
|
||||
data.unbindSkill(0);
|
||||
while (data.hasPassiveSkillBound(0))
|
||||
data.unbindPassiveSkill(0);
|
||||
data.getQuestData().resetFinishedQuests();
|
||||
data.getQuestData().start(null);
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s data was succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
public static class ResetWaypointsCommandTreeNode extends CommandTreeNode {
|
||||
public ResetWaypointsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "waypoints");
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.getWaypoints().clear();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
public static class ResetQuestsCommandTreeNode extends CommandTreeNode {
|
||||
public ResetQuestsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "quests");
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.getWaypoints().clear();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
public static class ResetQuestsCommandTreeNode extends CommandTreeNode {
|
||||
public ResetQuestsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "quests");
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.getQuestData().resetFinishedQuests();
|
||||
data.getQuestData().start(null);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
public static class ResetSkillsCommandTreeNode extends CommandTreeNode {
|
||||
public ResetSkillsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "skills");
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.getQuestData().resetFinishedQuests();
|
||||
data.getQuestData().start(null);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
public static class ResetSkillsCommandTreeNode extends CommandTreeNode {
|
||||
public ResetSkillsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "skills");
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.mapSkillLevels().forEach((skill, level) -> data.resetSkillLevel(skill));
|
||||
while (data.hasSkillBound(0))
|
||||
data.unbindSkill(0);
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s skill data was succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
public class ResetAttributesCommandTreeNode extends CommandTreeNode {
|
||||
public ResetAttributesCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "attributes");
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.mapSkillLevels().forEach((skill, level) -> data.resetSkillLevel(skill));
|
||||
while (data.hasSkillBound(0))
|
||||
data.unbindSkill(0);
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s skill data was succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
addParameter(Parameter.PLAYER);
|
||||
addParameter(new Parameter("(-reallocate)", (explore, list) -> list.add("-reallocate")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
public static class ResetSkillTreesCommandTreeNode extends CommandTreeNode {
|
||||
public ResetSkillTreesCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "skill-trees");
|
||||
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
/*
|
||||
* force reallocating of player attribute points
|
||||
*/
|
||||
if (args.length > 4 && args[4].equalsIgnoreCase("-reallocate")) {
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
int points = 0;
|
||||
for (PlayerAttributes.AttributeInstance ins : data.getAttributes().getInstances()) {
|
||||
points += ins.getBase();
|
||||
ins.setBase(0);
|
||||
}
|
||||
PlayerData data = PlayerData.get(player);
|
||||
for (SkillTree skillTree : data.getProfess().getSkillTrees())
|
||||
data.resetSkillTree(skillTree);
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s skill-tree data was succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
data.giveAttributePoints(points);
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s attribute points spendings were successfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
public class ResetAttributesCommandTreeNode extends CommandTreeNode {
|
||||
public ResetAttributesCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "attributes");
|
||||
|
||||
data.getAttributes().getInstances().forEach(ins -> ins.setBase(0));
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s attributes were succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
addParameter(Parameter.PLAYER);
|
||||
addParameter(new Parameter("(-reallocate)", (explore, list) -> list.add("-reallocate")));
|
||||
}
|
||||
|
||||
public static class ResetLevelsCommandTreeNode extends CommandTreeNode {
|
||||
public ResetLevelsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "levels");
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
PlayerData data = PlayerData.get(player);
|
||||
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
/*
|
||||
* force reallocating of player attribute points
|
||||
*/
|
||||
if (args.length > 4 && args[4].equalsIgnoreCase("-reallocate")) {
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.setLevel(MMOCore.plugin.dataProvider.getDataManager().getDefaultData().getLevel());
|
||||
data.setExperience(0);
|
||||
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
||||
data.getCollectionSkills().setExperience(profession, 0);
|
||||
data.getCollectionSkills().setLevel(profession, 0);
|
||||
}
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s levels were succesfully reset.");
|
||||
int points = 0;
|
||||
for (PlayerAttributes.AttributeInstance ins : data.getAttributes().getInstances()) {
|
||||
points += ins.getBase();
|
||||
ins.setBase(0);
|
||||
}
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
data.giveAttributePoints(points);
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s attribute points spendings were successfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
data.getAttributes().getInstances().forEach(ins -> ins.setBase(0));
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s attributes were succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ResetLevelsCommandTreeNode extends CommandTreeNode {
|
||||
public ResetLevelsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "levels");
|
||||
|
||||
addParameter(Parameter.PLAYER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[3]);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find the player called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.setLevel(MMOCore.plugin.dataProvider.getDataManager().getDefaultData().getLevel());
|
||||
data.setExperience(0);
|
||||
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
||||
data.getCollectionSkills().setExperience(profession, 0);
|
||||
data.getCollectionSkills().setLevel(profession, 0);
|
||||
profession.getExperienceTable().reset(data, profession);
|
||||
}
|
||||
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s levels were succesfully reset.");
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -337,8 +337,7 @@ public class SkillTreeViewer extends EditableInventory {
|
||||
|
||||
@Override
|
||||
public void whenClicked(InventoryClickContext event, InventoryItem item) {
|
||||
if(event.getClickedItem()==null)
|
||||
return;
|
||||
|
||||
|
||||
if (item.getFunction().equals("next-tree-list-page")) {
|
||||
treeListPage++;
|
||||
@ -401,7 +400,7 @@ public class SkillTreeViewer extends EditableInventory {
|
||||
String id = event.getClickedItem().getItemMeta().getPersistentDataContainer().get(
|
||||
new NamespacedKey(MMOCore.plugin, "skill-tree-id"), PersistentDataType.STRING);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.CHANGE_SKILL_TREE).playTo(player);
|
||||
skillTree=MMOCore.plugin.skillTreeManager.get(id);
|
||||
skillTree = MMOCore.plugin.skillTreeManager.get(id);
|
||||
open();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -42,8 +42,6 @@ public class DepositMenu extends PluginInventory {
|
||||
|
||||
@Override
|
||||
public void whenClicked(InventoryClickContext event) {
|
||||
if (event.getClickedItem() == null || event.getClickedItem().getType() == Material.AIR)
|
||||
return;
|
||||
|
||||
if (event.getClickedItem().isSimilar(depositItem)) {
|
||||
event.setCancelled(true);
|
||||
|
@ -17,6 +17,7 @@ public class RandomWeightedRoll<T extends Weighted> {
|
||||
private final T rolled;
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
private static final double CHANCE_COEFFICIENT = 7. / 100;
|
||||
|
||||
public RandomWeightedRoll(PlayerData player, Collection<T> collection, double chanceWeight) {
|
||||
this.collection = collection;
|
||||
@ -26,13 +27,13 @@ public class RandomWeightedRoll<T extends Weighted> {
|
||||
|
||||
for (T item : collection) {
|
||||
partialSum += computeRealWeight(item, chance);
|
||||
if (partialSum > randomCoefficient * sum) {
|
||||
if (partialSum >= randomCoefficient * sum) {
|
||||
rolled = item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("Could not roll item");
|
||||
throw new RuntimeException("Could not roll item, the chance is :"+chance);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +54,6 @@ public class RandomWeightedRoll<T extends Weighted> {
|
||||
return sum;
|
||||
}
|
||||
|
||||
private static final double CHANCE_COEFFICIENT = 7. / 100;
|
||||
|
||||
/**
|
||||
* chance = 0 | tier chances are unchanged
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmocore.loot.droptable.dropitem;
|
||||
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
|
||||
import net.Indyuce.mmocore.loot.LootBuilder;
|
||||
@ -46,7 +47,7 @@ public abstract class DropItem {
|
||||
*/
|
||||
public boolean rollChance(PlayerData player) {
|
||||
double value = random.nextDouble();
|
||||
return value < Math.pow(chance, 1 / Math.pow(1 + CHANCE_COEFFICIENT * player.getStats().getStat("CHANCE"), 1.0 / 3.0));
|
||||
return value < Math.pow(chance, 1 / Math.pow(1 + CHANCE_COEFFICIENT * MMOCore.plugin.configManager.dropItemsChanceWeight* player.getStats().getStat("CHANCE"), 1.0 / 3.0));
|
||||
}
|
||||
|
||||
public abstract void collect(LootBuilder builder);
|
||||
|
@ -26,7 +26,7 @@ public class ConfigManager {
|
||||
public String partyChatPrefix, noSkillBoundPlaceholder;
|
||||
public ChatColor staminaFull, staminaHalf, staminaEmpty;
|
||||
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
|
||||
public double lootChestsChanceWeight, fishingDropsChanceWeight, partyMaxExpSplitRange;
|
||||
public double lootChestsChanceWeight,dropItemsChanceWeight, fishingDropsChanceWeight, partyMaxExpSplitRange;
|
||||
public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills, waypointWarpTime;
|
||||
|
||||
private final FileConfiguration messages;
|
||||
@ -111,6 +111,7 @@ public class ConfigManager {
|
||||
globalSkillCooldown = MMOCore.plugin.getConfig().getLong("global-skill-cooldown") * 50;
|
||||
noSkillBoundPlaceholder = getSimpleMessage("no-skill-placeholder").message();
|
||||
lootChestsChanceWeight = MMOCore.plugin.getConfig().getDouble("chance-stat-weight.loot-chests");
|
||||
dropItemsChanceWeight = MMOCore.plugin.getConfig().getDouble("chance-stat-weight.drop-items");
|
||||
fishingDropsChanceWeight = MMOCore.plugin.getConfig().getDouble("chance-stat-weight.fishing-drops");
|
||||
maxPartyLevelDifference = MMOCore.plugin.getConfig().getInt("party.max-level-difference");
|
||||
partyMaxExpSplitRange = MMOCore.plugin.getConfig().getDouble("party.max-exp-split-range");
|
||||
|
@ -184,6 +184,8 @@ public abstract class PlayerDataManager {
|
||||
player.setSkillPoints(skillPoints);
|
||||
player.setAttributePoints(attributePoints);
|
||||
player.setAttributeReallocationPoints(attrReallocPoints);
|
||||
player.setSkillTreeReallocationPoints(skillTreeReallocPoints);
|
||||
player.setSkillReallocationPoints(skillReallocPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
data.getBoundSkills().add(skill);
|
||||
}
|
||||
if (!isEmpty(result.getString("class_info"))) {
|
||||
JsonObject object = MythicLib.plugin.getJson().parse(result.getString("class_info"), JsonObject.class);
|
||||
JsonObject object = new Gson().fromJson(result.getString("class_info"), JsonObject.class);
|
||||
for (Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
try {
|
||||
PlayerClass profess = MMOCore.plugin.classManager.get(entry.getKey());
|
||||
|
@ -79,6 +79,7 @@ guild-plugin: mmocore
|
||||
chance-stat-weight:
|
||||
loot-chests: 1
|
||||
fishing-drops: 1
|
||||
drop-items: 1
|
||||
|
||||
# Whether blocks generated with a "cobblegenerator" should
|
||||
# provide the player with experience points or not
|
||||
|
Loading…
Reference in New Issue
Block a user