forked from Upstream/mmocore
can-manually-bind option for SkillSlots and possibility to bind/unbind a skill to a slot through /mmocore admin slot bind <slot> <skill>.
This commit is contained in:
parent
015f4544ce
commit
943553632b
@ -111,7 +111,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
if (config.contains("skill-slots." + i))
|
if (config.contains("skill-slots." + i))
|
||||||
skillSlots.put(i, new SkillSlot(config.getConfigurationSection("skill-slots." + i)));
|
skillSlots.put(i, new SkillSlot(config.getConfigurationSection("skill-slots." + i)));
|
||||||
else
|
else
|
||||||
skillSlots.put(i, new SkillSlot(i, 0, "true", "&eSkill Slot " + MMOCoreUtils.intToRoman(i), new ArrayList<>(), false, new ArrayList<>()));
|
skillSlots.put(i, new SkillSlot(i, 0, "true", "&eSkill Slot " + MMOCoreUtils.intToRoman(i), new ArrayList<>(), false, true, new ArrayList<>()));
|
||||||
}
|
}
|
||||||
for (String string : config.getStringList("display.lore"))
|
for (String string : config.getStringList("display.lore"))
|
||||||
description.add(ChatColor.GRAY + MythicLib.plugin.parseColors(string));
|
description.add(ChatColor.GRAY + MythicLib.plugin.parseColors(string));
|
||||||
|
@ -20,16 +20,19 @@ public class SkillSlot implements Unlockable {
|
|||||||
|
|
||||||
private final boolean isUnlockedByDefault;
|
private final boolean isUnlockedByDefault;
|
||||||
|
|
||||||
|
private final boolean canManuallyBind;
|
||||||
|
|
||||||
private final List<SkillBuffTrigger> skillBuffTriggers;
|
private final List<SkillBuffTrigger> skillBuffTriggers;
|
||||||
|
|
||||||
private Material item;
|
private Material item;
|
||||||
|
|
||||||
public SkillSlot(int slot, int modelData, String formula, String name, List<String> lore, boolean isUnlockedByDefault, List<SkillBuffTrigger> skillBuffTriggers) {
|
public SkillSlot(int slot, int modelData, String formula, String name, List<String> lore, boolean isUnlockedByDefault, boolean canManuallyBind, List<SkillBuffTrigger> skillBuffTriggers) {
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
this.modelData = modelData;
|
this.modelData = modelData;
|
||||||
this.formula = formula;
|
this.formula = formula;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.lore = lore;
|
this.lore = lore;
|
||||||
|
this.canManuallyBind = canManuallyBind;
|
||||||
this.isUnlockedByDefault = isUnlockedByDefault;
|
this.isUnlockedByDefault = isUnlockedByDefault;
|
||||||
this.skillBuffTriggers = skillBuffTriggers;
|
this.skillBuffTriggers = skillBuffTriggers;
|
||||||
}
|
}
|
||||||
@ -43,6 +46,7 @@ public class SkillSlot implements Unlockable {
|
|||||||
this.item = Material.valueOf(section.getString("item"));
|
this.item = Material.valueOf(section.getString("item"));
|
||||||
this.modelData = section.getInt("model-data", 0);
|
this.modelData = section.getInt("model-data", 0);
|
||||||
isUnlockedByDefault = section.getBoolean("unlocked-by-default", true);
|
isUnlockedByDefault = section.getBoolean("unlocked-by-default", true);
|
||||||
|
canManuallyBind =section.getBoolean("can-manually-bind",true);
|
||||||
skillBuffTriggers = new ArrayList<>();
|
skillBuffTriggers = new ArrayList<>();
|
||||||
if (section.contains("skill-buffs"))
|
if (section.contains("skill-buffs"))
|
||||||
for (String skillBuff : section.getStringList("skill-buffs"))
|
for (String skillBuff : section.getStringList("skill-buffs"))
|
||||||
@ -83,6 +87,10 @@ public class SkillSlot implements Unlockable {
|
|||||||
return skillBuffTriggers;
|
return skillBuffTriggers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canManuallyBind() {
|
||||||
|
return canManuallyBind;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canPlaceSkill(ClassSkill classSkill) {
|
public boolean canPlaceSkill(ClassSkill classSkill) {
|
||||||
return classSkill.getSkill().matchesFormula(formula);
|
return classSkill.getSkill().matchesFormula(formula);
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,14 @@ public class AdminCommandTreeNode extends CommandTreeNode {
|
|||||||
addChild(new AttributeCommandTreeNode(this));
|
addChild(new AttributeCommandTreeNode(this));
|
||||||
addChild(new SkillCommandTreeNode(this));
|
addChild(new SkillCommandTreeNode(this));
|
||||||
addChild(new SaveDataTreeNode(this));
|
addChild(new SaveDataTreeNode(this));
|
||||||
|
addChild(new SlotCommandTreeNode(this));
|
||||||
addChild(new PointsCommandTreeNode("skill", this, PlayerData::setSkillPoints, PlayerData::giveSkillPoints, PlayerData::getSkillPoints));
|
addChild(new PointsCommandTreeNode("skill", this, PlayerData::setSkillPoints, PlayerData::giveSkillPoints, PlayerData::getSkillPoints));
|
||||||
addChild(new PointsCommandTreeNode("class", this, PlayerData::setClassPoints, PlayerData::giveClassPoints, PlayerData::getClassPoints));
|
addChild(new PointsCommandTreeNode("class", this, PlayerData::setClassPoints, PlayerData::giveClassPoints, PlayerData::getClassPoints));
|
||||||
addChild(new PointsCommandTreeNode("attribute", this, PlayerData::setAttributePoints, PlayerData::giveAttributePoints, PlayerData::getAttributePoints));
|
addChild(new PointsCommandTreeNode("attribute", this, PlayerData::setAttributePoints, PlayerData::giveAttributePoints, PlayerData::getAttributePoints));
|
||||||
addChild(new PointsCommandTreeNode("attr-realloc", this, PlayerData::setAttributeReallocationPoints, PlayerData::giveAttributeReallocationPoints, PlayerData::getAttributeReallocationPoints));
|
addChild(new PointsCommandTreeNode("attr-realloc", this, PlayerData::setAttributeReallocationPoints, PlayerData::giveAttributeReallocationPoints, PlayerData::getAttributeReallocationPoints));
|
||||||
addChild(new PointsCommandTreeNode("skill-realloc", this, PlayerData::setSkillReallocationPoints, PlayerData::giveSkillReallocationPoints, PlayerData::getSkillReallocationPoints));
|
addChild(new PointsCommandTreeNode("skill-realloc", this, PlayerData::setSkillReallocationPoints, PlayerData::giveSkillReallocationPoints, PlayerData::getSkillReallocationPoints));
|
||||||
addChild(new PointsCommandTreeNode("skill-tree-realloc", this, PlayerData::setSkillTreeReallocationPoints, PlayerData::giveSkillTreeReallocationPoints, PlayerData::getSkillTreeReallocationPoints));
|
addChild(new PointsCommandTreeNode("skill-tree-realloc", this, PlayerData::setSkillTreeReallocationPoints, PlayerData::giveSkillTreeReallocationPoints, PlayerData::getSkillTreeReallocationPoints));
|
||||||
addChild(new SkillTreePointsCommandTreeNode(this,(playerData, integer, s) -> playerData.setSkillTreePoints(s,integer),(playerData, integer, s) -> playerData.giveSkillTreePoints(s,integer),((playerData, s) -> playerData.getSkillTreePoint(s))));
|
addChild(new SkillTreePointsCommandTreeNode(this, (playerData, integer, s) -> playerData.setSkillTreePoints(s, integer), (playerData, integer, s) -> playerData.giveSkillTreePoints(s, integer), ((playerData, s) -> playerData.getSkillTreePoint(s))));
|
||||||
for (PlayerResource res : PlayerResource.values())
|
for (PlayerResource res : PlayerResource.values())
|
||||||
addChild(new ResourceCommandTreeNode(res.name().toLowerCase(), this, res));
|
addChild(new ResourceCommandTreeNode(res.name().toLowerCase(), this, res));
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,11 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class SlotCommandTreeNode extends CommandTreeNode {
|
public class SlotCommandTreeNode extends CommandTreeNode {
|
||||||
public SlotCommandTreeNode(CommandTreeNode parent) {
|
public SlotCommandTreeNode(CommandTreeNode parent) {
|
||||||
super(parent, "skill");
|
super(parent, "slot");
|
||||||
addChild(new LockSlotCommandTreeNode(this, "lock", true));
|
addChild(new LockSlotCommandTreeNode(this, "lock", true));
|
||||||
addChild(new LockSlotCommandTreeNode(this, "unlock", false));
|
addChild(new LockSlotCommandTreeNode(this, "unlock", false));
|
||||||
|
addChild(new UnbindSlotCommandTreeNode(this, "unbind"));
|
||||||
|
addChild(new BindSlotCommandTreeNode(this, "bind"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LockSlotCommandTreeNode extends CommandTreeNode {
|
public class LockSlotCommandTreeNode extends CommandTreeNode {
|
||||||
@ -51,7 +53,7 @@ public class SlotCommandTreeNode extends CommandTreeNode {
|
|||||||
sender.sendMessage(ChatColor.RED + "The slot can't be negative.");
|
sender.sendMessage(ChatColor.RED + "The slot can't be negative.");
|
||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
SkillSlot skillSlot=playerData.getProfess().getSkillSlot(slot);
|
SkillSlot skillSlot = playerData.getProfess().getSkillSlot(slot);
|
||||||
if (lock) {
|
if (lock) {
|
||||||
if (!playerData.hasUnlocked(skillSlot)) {
|
if (!playerData.hasUnlocked(skillSlot)) {
|
||||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.SKILL, ChatColor.RED + "The skill slot " + skillSlot.getName() + " is already locked" + " for " + player.getName());
|
CommandVerbose.verbose(sender, CommandVerbose.CommandType.SKILL, ChatColor.RED + "The skill slot " + skillSlot.getName() + " is already locked" + " for " + player.getName());
|
||||||
@ -72,6 +74,80 @@ public class SlotCommandTreeNode extends CommandTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class BindSlotCommandTreeNode extends CommandTreeNode {
|
||||||
|
|
||||||
|
public BindSlotCommandTreeNode(CommandTreeNode parent, String id) {
|
||||||
|
super(parent, id);
|
||||||
|
addParameter(Parameter.PLAYER);
|
||||||
|
addParameter(Parameter.AMOUNT);
|
||||||
|
addParameter(new Parameter("<skill>",
|
||||||
|
(explorer, list) -> MMOCore.plugin.skillManager.getAll().forEach(skill -> list.add(skill.getHandler().getId().toUpperCase()))));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandResult execute(CommandSender sender, String[] args) {
|
||||||
|
if (args.length < 6)
|
||||||
|
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 playerData = PlayerData.get(player);
|
||||||
|
int slot;
|
||||||
|
try {
|
||||||
|
slot = Integer.parseInt(args[4]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
sender.sendMessage(ChatColor.RED + args[4] + " is not a valid number.");
|
||||||
|
return CommandResult.FAILURE;
|
||||||
|
}
|
||||||
|
ClassSkill skill = playerData.getProfess().getSkill(args[5]);
|
||||||
|
if (skill == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "The player's class doesn't have a skill called " + args[5] + ".");
|
||||||
|
return CommandResult.FAILURE;
|
||||||
|
}
|
||||||
|
playerData.bindSkill(slot, skill);
|
||||||
|
|
||||||
|
CommandVerbose.verbose(sender, CommandVerbose.CommandType.SKILL, ChatColor.GOLD + "The skill " + skill.getSkill().getHandler().getId() + " is now bound to the slot " + slot);
|
||||||
|
return CommandResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UnbindSlotCommandTreeNode extends CommandTreeNode {
|
||||||
|
|
||||||
|
public UnbindSlotCommandTreeNode(CommandTreeNode parent, String id) {
|
||||||
|
super(parent, id);
|
||||||
|
addParameter(Parameter.PLAYER);
|
||||||
|
addParameter(Parameter.AMOUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandResult execute(CommandSender sender, String[] args) {
|
||||||
|
if (args.length < 5)
|
||||||
|
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 playerData = PlayerData.get(player);
|
||||||
|
int slot;
|
||||||
|
try {
|
||||||
|
slot = Integer.parseInt(args[4]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
sender.sendMessage(ChatColor.RED + args[4] + " is not a valid number.");
|
||||||
|
return CommandResult.FAILURE;
|
||||||
|
}
|
||||||
|
String skill = playerData.hasSkillBound(slot) ? playerData.getBoundSkill(slot).getSkill().getHandler().getId() : "none";
|
||||||
|
if (playerData.hasSkillBound(slot))
|
||||||
|
playerData.unbindSkill(slot);
|
||||||
|
|
||||||
|
CommandVerbose.verbose(sender, CommandVerbose.CommandType.SKILL, ChatColor.GOLD + "The skill " + skill + " has been unbounded from the slot " + slot);
|
||||||
|
return CommandResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(CommandSender sender, String[] args) {
|
public CommandResult execute(CommandSender sender, String[] args) {
|
||||||
return CommandResult.THROW_USAGE;
|
return CommandResult.THROW_USAGE;
|
||||||
|
@ -160,7 +160,7 @@ public class SkillList extends EditableInventory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack display(SkillViewerInventory inv, int n) {
|
public ItemStack display(SkillViewerInventory inv, int n) {
|
||||||
if (!inv.getPlayerData().hasUnlocked("slot:" + n)) {
|
if (!inv.getPlayerData().hasUnlocked("slot:" + (n+1))) {
|
||||||
return new ItemStack(Material.AIR);
|
return new ItemStack(Material.AIR);
|
||||||
}
|
}
|
||||||
SkillSlot skillSlot = inv.getPlayerData().getProfess().getSkillSlot(n + 1);
|
SkillSlot skillSlot = inv.getPlayerData().getProfess().getSkillSlot(n + 1);
|
||||||
@ -403,6 +403,11 @@ public class SkillList extends EditableInventory {
|
|||||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!playerData.getProfess().getSkillSlot(index).canManuallyBind()){
|
||||||
|
MMOCore.plugin.configManager.getSimpleMessage("cant-manually-bind").send(player);
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
|
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
|
||||||
playerData.unbindSkill(index);
|
playerData.unbindSkill(index);
|
||||||
open();
|
open();
|
||||||
@ -415,6 +420,12 @@ public class SkillList extends EditableInventory {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!skillSlot.canManuallyBind()){
|
||||||
|
MMOCore.plugin.configManager.getSimpleMessage("cant-manually-bind").send(player);
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!skillSlot.canPlaceSkill(selected)) {
|
if (!skillSlot.canPlaceSkill(selected)) {
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("not-compatible-skill").send(player);
|
MMOCore.plugin.configManager.getSimpleMessage("not-compatible-skill").send(player);
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||||
|
@ -198,7 +198,7 @@ death-exp-loss:
|
|||||||
percent: 30
|
percent: 30
|
||||||
|
|
||||||
#Maximum number of slot. This means that you can't unlock a slot greater than max-slots. (The slot count starts at 1 & end at max-slots).
|
#Maximum number of slot. This means that you can't unlock a slot greater than max-slots. (The slot count starts at 1 & end at max-slots).
|
||||||
max-slots: 10
|
max-slots: 8
|
||||||
|
|
||||||
#If you want players to bound their passive skills.
|
#If you want players to bound their passive skills.
|
||||||
#If false, all the passive skills unlocked will be active
|
#If false, all the passive skills unlocked will be active
|
||||||
|
@ -203,6 +203,7 @@ upgrade-skill: '&eYour &6{skill} &eis now Level &6{level}&e!'
|
|||||||
not-unlocked-skill: '&cYou have not unlocked that skill yet.'
|
not-unlocked-skill: '&cYou have not unlocked that skill yet.'
|
||||||
no-skill-bound: '&cYou don''t have any skill bound to this slot.'
|
no-skill-bound: '&cYou don''t have any skill bound to this slot.'
|
||||||
not-compatible-skill: '&cThe selected skill is not compatible with this slot.'
|
not-compatible-skill: '&cThe selected skill is not compatible with this slot.'
|
||||||
|
cant-manually-bind: "&cYou can't manually bind/unbind a skill to this slot."
|
||||||
skill-max-level-hit: '&cYou already hit the max level for that skill.'
|
skill-max-level-hit: '&cYou already hit the max level for that skill.'
|
||||||
no-skill-placeholder: 'No Skill Bound'
|
no-skill-placeholder: 'No Skill Bound'
|
||||||
not-skill-reallocation-point: '&cYou do not have 1 skill reallocation point.'
|
not-skill-reallocation-point: '&cYou do not have 1 skill reallocation point.'
|
||||||
|
Loading…
Reference in New Issue
Block a user