!Moved command API over to MMOLib

This commit is contained in:
Indyuce 2020-08-15 14:20:41 +02:00
parent 6f749e2684
commit ee41d3bf38
38 changed files with 316 additions and 605 deletions

Binary file not shown.

View File

@ -25,7 +25,7 @@ import net.Indyuce.mmocore.command.ClassCommand;
import net.Indyuce.mmocore.command.DepositCommand;
import net.Indyuce.mmocore.command.FriendsCommand;
import net.Indyuce.mmocore.command.GuildCommand;
import net.Indyuce.mmocore.command.MMOCoreCommand;
import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot;
import net.Indyuce.mmocore.command.PartyCommand;
import net.Indyuce.mmocore.command.PlayerStatsCommand;
import net.Indyuce.mmocore.command.QuestsCommand;
@ -341,7 +341,7 @@ public class MMOCore extends JavaPlugin {
ex.printStackTrace();
}
MMOCoreCommand mmoCoreCommand = new MMOCoreCommand();
MMOCoreCommandTreeRoot mmoCoreCommand = new MMOCoreCommandTreeRoot();
getCommand("mmocore").setExecutor(mmoCoreCommand);
getCommand("mmocore").setTabCompleter(mmoCoreCommand);

View File

@ -1,60 +0,0 @@
package net.Indyuce.mmocore.command;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import net.Indyuce.mmocore.command.api.CommandRoot;
import net.Indyuce.mmocore.command.rpg.CoinsCommandMap;
import net.Indyuce.mmocore.command.rpg.NoteCommandMap;
import net.Indyuce.mmocore.command.rpg.ReloadCommandMap;
import net.Indyuce.mmocore.command.rpg.admin.AdminCommandMap;
import net.Indyuce.mmocore.command.rpg.booster.BoosterCommandMap;
import net.Indyuce.mmocore.command.rpg.debug.DebugCommandMap;
import net.Indyuce.mmocore.command.rpg.quest.QuestCommandMap;
import net.Indyuce.mmocore.command.rpg.waypoint.WaypointsCommandMap;
public class MMOCoreCommand extends CommandRoot implements CommandExecutor, TabCompleter {
public MMOCoreCommand() {
super("mmocore");
addFloor(new ReloadCommandMap(this));
addFloor(new CoinsCommandMap(this));
addFloor(new NoteCommandMap(this));
addFloor(new AdminCommandMap(this));
addFloor(new DebugCommandMap(this));
addFloor(new BoosterCommandMap(this));
addFloor(new WaypointsCommandMap(this));
addFloor(new QuestCommandMap(this));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!sender.hasPermission("mmocore.admin"))
return false;
executeCommand(sender, args);
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (!sender.hasPermission("mmocore.admin"))
return new ArrayList<>();
CommandParser reader = readCommand(args);
List<String> list = reader.readTabCompletion();
return args[args.length - 1].isEmpty() ? list
: list.stream().filter(string -> string.toLowerCase().startsWith(args[args.length - 1].toLowerCase())).collect(Collectors.toList());
}
}

View File

@ -0,0 +1,38 @@
package net.Indyuce.mmocore.command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.TabCompleter;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.command.rpg.CoinsCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.NoteCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.ReloadCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.admin.AdminCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.booster.BoosterCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.debug.DebugCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.quest.QuestCommandTreeNode;
import net.Indyuce.mmocore.command.rpg.waypoint.WaypointsCommandTreeNode;
import net.mmogroup.mmolib.command.api.CommandTreeRoot;
import net.mmogroup.mmolib.command.api.Parameter;
public class MMOCoreCommandTreeRoot extends CommandTreeRoot implements CommandExecutor, TabCompleter {
public static final Parameter PROFESSION = new Parameter("<profession/main>", (explorer, list) -> {
MMOCore.plugin.professionManager.getAll().forEach(profession -> list.add(profession.getId()));
list.add("main");
});
public static final Parameter QUEST = new Parameter("<quest>",
(explorer, list) -> MMOCore.plugin.questManager.getAll().forEach(quest -> list.add(quest.getId())));
public MMOCoreCommandTreeRoot() {
super("mmocore", "mmocore.admin");
addChild(new ReloadCommandTreeNode(this));
addChild(new CoinsCommandTreeNode(this));
addChild(new NoteCommandTreeNode(this));
addChild(new AdminCommandTreeNode(this));
addChild(new DebugCommandTreeNode(this));
addChild(new BoosterCommandTreeNode(this));
addChild(new WaypointsCommandTreeNode(this));
addChild(new QuestCommandTreeNode(this));
}
}

View File

@ -1,27 +0,0 @@
package net.Indyuce.mmocore.command.api;
import java.util.ArrayList;
import java.util.List;
public abstract class CommandEnd extends CommandMap {
private final List<Parameter> parameters = new ArrayList<>();
public CommandEnd(CommandMap parent, String id) {
super(parent, id);
}
public void addParameter(Parameter param) {
parameters.add(param);
}
public List<Parameter> getParameters() {
return parameters;
}
public String formatParameters() {
String str = "";
for (Parameter param : parameters)
str += param.getKey() + " ";
return str.isEmpty() ? str : str.substring(0, str.length() - 1);
}
}

View File

@ -1,125 +0,0 @@
package net.Indyuce.mmocore.command.api;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.command.CommandSender;
public abstract class CommandMap {
private final Map<String, CommandMap> floors = new HashMap<>();
private final String id;
private final CommandMap parent;
public static final CommandMap EMPTY = new CommandMap(null, "empty") {
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
};
public CommandMap(CommandMap parent, String id) {
Validate.isTrue(!(parent instanceof CommandEnd), "You cannot use a CommandEnd as a parent");
this.id = id;
this.parent = parent;
}
public String getId() {
return id;
}
public String getPath() {
return (hasParent() ? parent.getPath() + " " : "") + getId();
}
public Collection<CommandMap> getFloors() {
return floors.values();
}
public boolean hasParent() {
return parent != null;
}
public CommandMap getFloor(String str) {
return floors.get(str.toLowerCase());
}
public boolean hasFloor(String str) {
return floors.containsKey(str.toLowerCase());
}
public void addFloor(CommandMap floor) {
floors.put(floor.getId(), floor);
}
public Set<String> getKeys() {
return floors.keySet();
}
public abstract CommandResult execute(CommandSender sender, String[] args);
public List<String> calculateTabCompletion(int parameterIndex) {
/*
* add extra floor keys. only commandEnds can have parameters, that
* means commands must be clean and cannot have both floors and
* parameters to input
*/
List<String> list = new ArrayList<>();
getKeys().forEach(key -> list.add(key));
/*
* if the player is at the end of a command branch, display the
* parameter with the right index that the player must input
*/
if (isEnd() && ((CommandEnd) this).getParameters().size() > parameterIndex)
((CommandEnd) this).getParameters().get(parameterIndex).autoComplete(list);
return list;
}
public List<String> calculateUsageList() {
return calculateUsageList(getPath(), new ArrayList<>());
}
private List<String> calculateUsageList(String path, List<String> usages) {
/*
* calculate for final arguments
*/
if (isEnd())
usages.add(path + " " + ((CommandEnd) this).formatParameters());
for (CommandMap floor : getFloors())
floor.calculateUsageList(new String(path + " " + floor.getId()), usages);
return usages;
}
public boolean isEnd() {
return this instanceof CommandEnd;
}
public enum CommandResult {
/*
* command cast successfully, nothing to do
*/
SUCCESS,
/*
* command cast unsuccessfully, display message handled via command
* floor
*/
FAILURE,
/*
* send command usage
*/
THROW_USAGE;
}
}

View File

@ -1,64 +0,0 @@
package net.Indyuce.mmocore.command.api;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public abstract class CommandRoot extends CommandMap {
public CommandRoot(String id) {
super(null, id);
}
public void executeCommand(CommandSender sender, String[] args) {
CommandMap read = readCommand(args).read();
if (read.execute(sender, args) == CommandResult.THROW_USAGE)
read.calculateUsageList().forEach(str -> sender.sendMessage(ChatColor.YELLOW + "/" + str));
}
public CommandParser readCommand(String[] args) {
return new CommandParser(this, args);
}
public class CommandParser {
private CommandMap current;
private int parameter = 0;
/*
* used to parse a command and identify the commandMap which is supposed
* to
*/
public CommandParser(CommandRoot begin, String[] args) {
this.current = begin;
for (String arg : args)
/*
* check if current command floor has the corresponding arg, if
* so let the next floor handle the command.
*/
if (parameter == 0 && current.hasFloor(arg))
current = current.getFloor(arg);
/*
* if the plugin cannot find a command map higher, then the
* current floor will handle the command.
*/
else
parameter++;
}
public CommandMap read() {
return current;
}
public int extraCount() {
return parameter;
}
public List<String> readTabCompletion() {
return current.calculateTabCompletion(Math.max(0, parameter - 1));
}
}
}

View File

@ -1,62 +0,0 @@
package net.Indyuce.mmocore.command.api;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.util.Consumer;
import net.Indyuce.mmocore.MMOCore;
public class Parameter {
private final String key;
// private final ParameterType type;ParameterType type,
private final Consumer<List<String>> autoComplete;
public static final Parameter PROFESSION = new Parameter("<profession/main>", list -> {
MMOCore.plugin.professionManager.getAll().forEach(profession -> list.add(profession.getId()));
list.add("main");
});
public static final Parameter PLAYER = new Parameter("<player>", list -> Bukkit.getOnlinePlayers().forEach(online -> list.add(online.getName())));
public static final Parameter QUEST = new Parameter("<quest>",
list -> MMOCore.plugin.questManager.getAll().forEach(quest -> list.add(quest.getId())));
public static final Parameter PLAYER_OPTIONAL = new Parameter("(player)",
list -> Bukkit.getOnlinePlayers().forEach(online -> list.add(online.getName())));
public static final Parameter AMOUNT = new Parameter("<amount>", list -> {
for (int j = 0; j <= 10; j++)
list.add("" + j);
});
public Parameter(String key, Consumer<List<String>> autoComplete) {
this.key = key;
// this.type = type;
this.autoComplete = autoComplete;
}
public String getKey() {
return key;
}
// public ParameterType getType() {
// return type;
// }
public void autoComplete(List<String> list) {
autoComplete.accept(list);
}
// public enum ParameterType {
// OPTIONAL('(', ')'),
// REQUIRED('<', '>');
//
// private final char prefix, suffix;
//
// private ParameterType(char... chars) {
// this.prefix = chars[0];
// this.suffix = chars[1];
// }
//
// public String format(Parameter parameter) {
// return prefix + parameter.getKey() + suffix;
// }
// }
}

View File

@ -6,13 +6,12 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.api.util.SmartGive;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class CoinsCommandMap extends CommandEnd {
public CoinsCommandMap(CommandMap parent) {
public class CoinsCommandTreeNode extends CommandTreeNode {
public CoinsCommandTreeNode(CommandTreeNode parent) {
super(parent, "coins");
addParameter(Parameter.PLAYER);

View File

@ -8,17 +8,17 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.api.util.SmartGive;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class NoteCommandMap extends CommandEnd {
public NoteCommandMap(CommandMap parent) {
public class NoteCommandTreeNode extends CommandTreeNode {
public NoteCommandTreeNode(CommandTreeNode parent) {
super(parent, "note");
addParameter(Parameter.PLAYER);
addParameter(new Parameter("<worth>", (list) -> list.addAll(Arrays.asList("10", "20", "30", "40", "50", "60", "70", "80", "90", "100"))));
addParameter(new Parameter("<worth>",
(explorer, list) -> list.addAll(Arrays.asList("10", "20", "30", "40", "50", "60", "70", "80", "90", "100"))));
}
@Override
@ -43,5 +43,4 @@ public class NoteCommandMap extends CommandEnd {
new SmartGive(player).give(new CurrencyItem("NOTE", worth).build());
return CommandResult.SUCCESS;
}
}

View File

@ -5,11 +5,10 @@ import org.bukkit.command.CommandSender;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
public class ReloadCommandMap extends CommandEnd {
public ReloadCommandMap(CommandMap parent) {
public class ReloadCommandTreeNode extends CommandTreeNode {
public ReloadCommandTreeNode(CommandTreeNode parent) {
super(parent, "reload");
}

View File

@ -1,35 +0,0 @@
package net.Indyuce.mmocore.command.rpg.admin;
import org.bukkit.command.CommandSender;
import net.Indyuce.mmocore.command.api.CommandMap;
public class AdminCommandMap extends CommandMap {
public AdminCommandMap(CommandMap parent) {
super(parent, "admin");
addFloor(new HideActionBarCommandMap(this));
addFloor(new NoCooldownCommandMap(this));
addFloor(new ResetCommandMap(this));
addFloor(new InfoCommandMap(this));
addFloor(new ClassCommandMap(this));
addFloor(new ExperienceCommandMap(this));
addFloor(new LevelCommandMap(this));
addFloor(new PointsCommandMap("skill", this, (data, points) -> data.setSkillPoints(points), (data, points) -> data.giveSkillPoints(points), (data) -> data.getSkillPoints()));
addFloor(new PointsCommandMap("class", this, (data, points) -> data.setClassPoints(points), (data, points) -> data.giveClassPoints(points), (data) -> data.getClassPoints()));
addFloor(new PointsCommandMap("attribute", this, (data, points) -> data.setAttributePoints(points), (data, points) -> data.giveAttributePoints(points), (data) -> data.getAttributePoints()));
addFloor(new PointsCommandMap("attr-realloc", this, (data, points) -> data.setAttributeReallocationPoints(points), (data, points) -> data.giveAttributeReallocationPoints(points), (data) -> data.getAttributeReallocationPoints()));
addFloor(new ResourceCommandMap("health", this, (data, value) -> data.getPlayer().setHealth(value), (data, value) -> data.heal(value), (data, value) -> data.heal(-value), (data) -> data.getPlayer().getHealth()));
addFloor(new ResourceCommandMap("mana", this, (data, value) -> data.setMana(value), (data, value) -> data.giveMana(value), (data, value) -> data.giveMana(-value), (data) -> data.getMana()));
addFloor(new ResourceCommandMap("stamina", this, (data, value) -> data.setStamina(value), (data, value) -> data.giveStamina(value), (data, value) -> data.giveStamina(-value), (data) -> data.getStamina()));
addFloor(new ResourceCommandMap("stellium", this, (data, value) -> data.setStellium(value), (data, value) -> data.giveStellium(value), (data, value) -> data.giveStellium(-value), (data) -> data.getStellium()));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
}

View File

@ -0,0 +1,35 @@
package net.Indyuce.mmocore.command.rpg.admin;
import org.bukkit.command.CommandSender;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
public class AdminCommandTreeNode extends CommandTreeNode {
public AdminCommandTreeNode(CommandTreeNode parent) {
super(parent, "admin");
addChild(new HideActionBarCommandTreeNode(this));
addChild(new NoCooldownCommandTreeNode(this));
addChild(new ResetCommandTreeNode(this));
addChild(new InfoCommandTreeNode(this));
addChild(new ClassCommandTreeNode(this));
addChild(new ExperienceCommandTreeNode(this));
addChild(new LevelCommandTreeNode(this));
addChild(new PointsCommandTreeNode("skill", this, (data, points) -> data.setSkillPoints(points), (data, points) -> data.giveSkillPoints(points), (data) -> data.getSkillPoints()));
addChild(new PointsCommandTreeNode("class", this, (data, points) -> data.setClassPoints(points), (data, points) -> data.giveClassPoints(points), (data) -> data.getClassPoints()));
addChild(new PointsCommandTreeNode("attribute", this, (data, points) -> data.setAttributePoints(points), (data, points) -> data.giveAttributePoints(points), (data) -> data.getAttributePoints()));
addChild(new PointsCommandTreeNode("attr-realloc", this, (data, points) -> data.setAttributeReallocationPoints(points), (data, points) -> data.giveAttributeReallocationPoints(points), (data) -> data.getAttributeReallocationPoints()));
addChild(new ResourceCommandTreeNode("health", this, (data, value) -> data.getPlayer().setHealth(value), (data, value) -> data.heal(value), (data, value) -> data.heal(-value), (data) -> data.getPlayer().getHealth()));
addChild(new ResourceCommandTreeNode("mana", this, (data, value) -> data.setMana(value), (data, value) -> data.giveMana(value), (data, value) -> data.giveMana(-value), (data) -> data.getMana()));
addChild(new ResourceCommandTreeNode("stamina", this, (data, value) -> data.setStamina(value), (data, value) -> data.giveStamina(value), (data, value) -> data.giveStamina(-value), (data) -> data.getStamina()));
addChild(new ResourceCommandTreeNode("stellium", this, (data, value) -> data.setStellium(value), (data, value) -> data.giveStellium(value), (data, value) -> data.giveStellium(-value), (data) -> data.getStellium()));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
}

View File

@ -8,16 +8,16 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class ClassCommandMap extends CommandEnd {
public ClassCommandMap(CommandMap parent) {
public class ClassCommandTreeNode extends CommandTreeNode {
public ClassCommandTreeNode(CommandTreeNode parent) {
super(parent, "class");
addParameter(Parameter.PLAYER);
addParameter(new Parameter("<class>", (list) -> MMOCore.plugin.classManager.getAll().forEach(profess -> list.add(profess.getId()))));
addParameter(
new Parameter("<class>", (explorer, list) -> MMOCore.plugin.classManager.getAll().forEach(profess -> list.add(profess.getId()))));
}
@Override
@ -41,7 +41,8 @@ public class ClassCommandMap extends CommandEnd {
PlayerData data = PlayerData.get(player);
data.setClass(profess);
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now a " + ChatColor.GOLD + profess.getName() + ChatColor.YELLOW + ".");
sender.sendMessage(
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now a " + ChatColor.GOLD + profess.getName() + ChatColor.YELLOW + ".");
return CommandResult.SUCCESS;
}
}

View File

@ -8,34 +8,39 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.EXPSource;
import net.Indyuce.mmocore.api.experience.PlayerProfessions;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class ExperienceCommandMap extends CommandMap {
public ExperienceCommandMap(CommandMap parent) {
public class ExperienceCommandTreeNode extends CommandTreeNode {
public ExperienceCommandTreeNode(CommandTreeNode parent) {
super(parent, "exp");
addFloor(new ActionCommandMap(this, "set", (data, value) -> data.setExperience(value), (professions, profession, value) -> professions.setExperience(profession, value)));
addFloor(new ActionCommandMap(this, "give", (data, value) -> data.giveExperience(value, data.getPlayer().getLocation(), EXPSource.COMMAND), (professions, profession, value) -> professions.giveExperience(profession, value, professions.getPlayerData().getPlayer().getLocation(), EXPSource.COMMAND)));
addChild(new ActionCommandTreeNode(this, "set", (data, value) -> data.setExperience(value),
(professions, profession, value) -> professions.setExperience(profession, value)));
addChild(new ActionCommandTreeNode(this, "give",
(data, value) -> data.giveExperience(value, data.getPlayer().getLocation(), EXPSource.COMMAND),
(professions, profession, value) -> professions.giveExperience(profession, value,
professions.getPlayerData().getPlayer().getLocation(), EXPSource.COMMAND)));
}
public class ActionCommandMap extends CommandEnd {
public class ActionCommandTreeNode extends CommandTreeNode {
private final BiConsumer<PlayerData, Integer> main;
private final TriConsumer<PlayerProfessions, Profession, Integer> profession;
public ActionCommandMap(CommandMap parent, String type, BiConsumer<PlayerData, Integer> main, TriConsumer<PlayerProfessions, Profession, Integer> profession) {
public ActionCommandTreeNode(CommandTreeNode parent, String type, BiConsumer<PlayerData, Integer> main,
TriConsumer<PlayerProfessions, Profession, Integer> profession) {
super(parent, type);
this.main = main;
this.profession = profession;
addParameter(Parameter.PLAYER);
addParameter(Parameter.PROFESSION);
addParameter(MMOCoreCommandTreeRoot.PROFESSION);
addParameter(Parameter.AMOUNT);
}
@ -61,7 +66,8 @@ public class ExperienceCommandMap extends CommandMap {
PlayerData data = PlayerData.get(player);
if (args[4].equalsIgnoreCase("main")) {
main.accept(data, amount);
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + data.getExperience() + ChatColor.YELLOW + " EXP.");
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + data.getExperience()
+ ChatColor.YELLOW + " EXP.");
return CommandResult.SUCCESS;
}
@ -73,7 +79,8 @@ public class ExperienceCommandMap extends CommandMap {
Profession profession = MMOCore.plugin.professionManager.get(format);
this.profession.accept(data.getCollectionSkills(), profession, amount);
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + data.getCollectionSkills().getExperience(profession) + ChatColor.YELLOW + " EXP in " + profession.getName() + ".");
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD
+ data.getCollectionSkills().getExperience(profession) + ChatColor.YELLOW + " EXP in " + profession.getName() + ".");
return CommandResult.SUCCESS;
}
}

View File

@ -6,12 +6,11 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class HideActionBarCommandMap extends CommandEnd {
public HideActionBarCommandMap(CommandMap parent) {
public class HideActionBarCommandTreeNode extends CommandTreeNode {
public HideActionBarCommandTreeNode(CommandTreeNode parent) {
super(parent, "hideab");
addParameter(Parameter.PLAYER);

View File

@ -8,12 +8,11 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class InfoCommandMap extends CommandEnd {
public InfoCommandMap(CommandMap parent) {
public class InfoCommandTreeNode extends CommandTreeNode {
public InfoCommandTreeNode(CommandTreeNode parent) {
super(parent, "info");
addParameter(Parameter.PLAYER);

View File

@ -8,34 +8,37 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.EXPSource;
import net.Indyuce.mmocore.api.experience.PlayerProfessions;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class LevelCommandMap extends CommandMap {
public LevelCommandMap(CommandMap parent) {
public class LevelCommandTreeNode extends CommandTreeNode {
public LevelCommandTreeNode(CommandTreeNode parent) {
super(parent, "level");
addFloor(new ActionCommandMap(this, "set", (data, value) -> data.setLevel(value), (professions, profession, value) -> professions.setLevel(profession, value)));
addFloor(new ActionCommandMap(this, "give", (data, value) -> data.giveLevels(value, EXPSource.COMMAND), (professions, profession, value) -> professions.giveLevels(profession, value, EXPSource.COMMAND)));
addChild(new ActionCommandTreeNode(this, "set", (data, value) -> data.setLevel(value),
(professions, profession, value) -> professions.setLevel(profession, value)));
addChild(new ActionCommandTreeNode(this, "give", (data, value) -> data.giveLevels(value, EXPSource.COMMAND),
(professions, profession, value) -> professions.giveLevels(profession, value, EXPSource.COMMAND)));
}
public class ActionCommandMap extends CommandEnd {
public class ActionCommandTreeNode extends CommandTreeNode {
private final BiConsumer<PlayerData, Integer> main;
private final TriConsumer<PlayerProfessions, Profession, Integer> profession;
public ActionCommandMap(CommandMap parent, String type, BiConsumer<PlayerData, Integer> main, TriConsumer<PlayerProfessions, Profession, Integer> profession) {
public ActionCommandTreeNode(CommandTreeNode parent, String type, BiConsumer<PlayerData, Integer> main,
TriConsumer<PlayerProfessions, Profession, Integer> profession) {
super(parent, type);
this.main = main;
this.profession = profession;
addParameter(Parameter.PLAYER);
addParameter(Parameter.PROFESSION);
addParameter(MMOCoreCommandTreeRoot.PROFESSION);
addParameter(Parameter.AMOUNT);
}
@ -61,7 +64,8 @@ public class LevelCommandMap extends CommandMap {
PlayerData data = PlayerData.get(player);
if (args[4].equalsIgnoreCase("main")) {
main.accept(data, amount);
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now Lvl " + ChatColor.GOLD + data.getLevel() + ChatColor.YELLOW + ".");
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now Lvl " + ChatColor.GOLD + data.getLevel()
+ ChatColor.YELLOW + ".");
return CommandResult.SUCCESS;
}
@ -73,7 +77,8 @@ public class LevelCommandMap extends CommandMap {
Profession profession = MMOCore.plugin.professionManager.get(format);
this.profession.accept(data.getCollectionSkills(), profession, amount);
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now Lvl " + ChatColor.GOLD + data.getCollectionSkills().getLevel(profession) + ChatColor.YELLOW + " in " + profession.getName() + ".");
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now Lvl " + ChatColor.GOLD
+ data.getCollectionSkills().getLevel(profession) + ChatColor.YELLOW + " in " + profession.getName() + ".");
return CommandResult.SUCCESS;
}
}

View File

@ -6,12 +6,11 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class NoCooldownCommandMap extends CommandEnd {
public NoCooldownCommandMap(CommandMap parent) {
public class NoCooldownCommandTreeNode extends CommandTreeNode {
public NoCooldownCommandTreeNode(CommandTreeNode parent) {
super(parent, "nocd");
addParameter(Parameter.PLAYER);

View File

@ -9,28 +9,28 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class PointsCommandMap extends CommandMap {
public class PointsCommandTreeNode extends CommandTreeNode {
private final String type;
private final Function<PlayerData, Integer> get;
public PointsCommandMap(String type, CommandMap parent, BiConsumer<PlayerData, Integer> set, BiConsumer<PlayerData, Integer> give, Function<PlayerData, Integer> get) {
public PointsCommandTreeNode(String type, CommandTreeNode parent, BiConsumer<PlayerData, Integer> set, BiConsumer<PlayerData, Integer> give,
Function<PlayerData, Integer> get) {
super(parent, type + "-points");
this.type = type;
this.get = get;
addFloor(new ActionCommandMap(this, "set", set));
addFloor(new ActionCommandMap(this, "give", give));
addChild(new ActionCommandTreeNode(this, "set", set));
addChild(new ActionCommandTreeNode(this, "give", give));
}
public class ActionCommandMap extends CommandEnd {
public class ActionCommandTreeNode extends CommandTreeNode {
private final BiConsumer<PlayerData, Integer> action;
public ActionCommandMap(CommandMap parent, String type, BiConsumer<PlayerData, Integer> action) {
public ActionCommandTreeNode(CommandTreeNode parent, String type, BiConsumer<PlayerData, Integer> action) {
super(parent, type);
this.action = action;
@ -60,7 +60,8 @@ public class PointsCommandMap extends CommandMap {
PlayerData data = PlayerData.get(player);
action.accept(data, amount);
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + get.apply(data) + ChatColor.YELLOW + " " + type + " points.");
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + get.apply(data)
+ ChatColor.YELLOW + " " + type + " points.");
return CommandResult.SUCCESS;
}
}

View File

@ -9,19 +9,18 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes.AttributeInstance;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class ResetCommandMap extends CommandMap {
public ResetCommandMap(CommandMap parent) {
public class ResetCommandTreeNode extends CommandTreeNode {
public ResetCommandTreeNode(CommandTreeNode parent) {
super(parent, "reset");
addFloor(new ResetLevelsCommandMap(this));
addFloor(new ResetSkillsCommandMap(this));
addFloor(new ResetAllCommandMap(this));
addFloor(new ResetAttributesCommandMap(this));
addFloor(new ResetWaypointsCommandMap(this));
addChild(new ResetLevelsCommandTreeNode(this));
addChild(new ResetSkillsCommandTreeNode(this));
addChild(new ResetAllCommandTreeNode(this));
addChild(new ResetAttributesCommandTreeNode(this));
addChild(new ResetWaypointsCommandTreeNode(this));
}
@Override
@ -29,8 +28,8 @@ public class ResetCommandMap extends CommandMap {
return CommandResult.THROW_USAGE;
}
public class ResetAllCommandMap extends CommandEnd {
public ResetAllCommandMap(CommandMap parent) {
public class ResetAllCommandTreeNode extends CommandTreeNode {
public ResetAllCommandTreeNode(CommandTreeNode parent) {
super(parent, "all");
addParameter(Parameter.PLAYER);
@ -72,8 +71,8 @@ public class ResetCommandMap extends CommandMap {
}
}
public class ResetWaypointsCommandMap extends CommandEnd {
public ResetWaypointsCommandMap(CommandMap parent) {
public class ResetWaypointsCommandTreeNode extends CommandTreeNode {
public ResetWaypointsCommandTreeNode(CommandTreeNode parent) {
super(parent, "waypoints");
addParameter(Parameter.PLAYER);
@ -98,8 +97,8 @@ public class ResetCommandMap extends CommandMap {
}
}
public class ResetQuestsCommandMap extends CommandEnd {
public ResetQuestsCommandMap(CommandMap parent) {
public class ResetQuestsCommandTreeNode extends CommandTreeNode {
public ResetQuestsCommandTreeNode(CommandTreeNode parent) {
super(parent, "quests");
addParameter(Parameter.PLAYER);
@ -123,8 +122,8 @@ public class ResetCommandMap extends CommandMap {
}
}
public class ResetSkillsCommandMap extends CommandEnd {
public ResetSkillsCommandMap(CommandMap parent) {
public class ResetSkillsCommandTreeNode extends CommandTreeNode {
public ResetSkillsCommandTreeNode(CommandTreeNode parent) {
super(parent, "skills");
addParameter(Parameter.PLAYER);
@ -150,12 +149,12 @@ public class ResetCommandMap extends CommandMap {
}
}
public class ResetAttributesCommandMap extends CommandEnd {
public ResetAttributesCommandMap(CommandMap parent) {
public class ResetAttributesCommandTreeNode extends CommandTreeNode {
public ResetAttributesCommandTreeNode(CommandTreeNode parent) {
super(parent, "attributes");
addParameter(Parameter.PLAYER);
addParameter(new Parameter("(-reallocate)", list -> list.add("-reallocate")));
addParameter(new Parameter("(-reallocate)", (explore, list) -> list.add("-reallocate")));
}
@Override
@ -193,8 +192,8 @@ public class ResetCommandMap extends CommandMap {
}
}
public class ResetLevelsCommandMap extends CommandEnd {
public ResetLevelsCommandMap(CommandMap parent) {
public class ResetLevelsCommandTreeNode extends CommandTreeNode {
public ResetLevelsCommandTreeNode(CommandTreeNode parent) {
super(parent, "levels");
addParameter(Parameter.PLAYER);

View File

@ -9,29 +9,29 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class ResourceCommandMap extends CommandMap {
public class ResourceCommandTreeNode extends CommandTreeNode {
private final String type;
private final Function<PlayerData, Double> get;
public ResourceCommandMap(String type, CommandMap parent, BiConsumer<PlayerData, Double> set, BiConsumer<PlayerData, Double> give, BiConsumer<PlayerData, Double> take, Function<PlayerData, Double> get) {
public ResourceCommandTreeNode(String type, CommandTreeNode parent, BiConsumer<PlayerData, Double> set, BiConsumer<PlayerData, Double> give,
BiConsumer<PlayerData, Double> take, Function<PlayerData, Double> get) {
super(parent, "resource-" + type);
this.type = type;
this.get = get;
addFloor(new ActionCommandMap(this, "set", set));
addFloor(new ActionCommandMap(this, "give", give));
addFloor(new ActionCommandMap(this, "take", take));
addChild(new ActionCommandTreeNode(this, "set", set));
addChild(new ActionCommandTreeNode(this, "give", give));
addChild(new ActionCommandTreeNode(this, "take", take));
}
public class ActionCommandMap extends CommandEnd {
public class ActionCommandTreeNode extends CommandTreeNode {
private final BiConsumer<PlayerData, Double> action;
public ActionCommandMap(CommandMap parent, String type, BiConsumer<PlayerData, Double> action) {
public ActionCommandTreeNode(CommandTreeNode parent, String type, BiConsumer<PlayerData, Double> action) {
super(parent, type);
this.action = action;
@ -61,7 +61,8 @@ public class ResourceCommandMap extends CommandMap {
PlayerData data = PlayerData.get(player);
action.accept(data, amount);
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + get.apply(data) + ChatColor.YELLOW + " " + type + " points.");
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + get.apply(data)
+ ChatColor.YELLOW + " " + type + " points.");
return CommandResult.SUCCESS;
}
}

View File

@ -1,20 +0,0 @@
package net.Indyuce.mmocore.command.rpg.booster;
import org.bukkit.command.CommandSender;
import net.Indyuce.mmocore.command.api.CommandMap;
public class BoosterCommandMap extends CommandMap {
public BoosterCommandMap(CommandMap parent) {
super(parent, "booster");
addFloor(new CreateCommandMap(this));
addFloor(new ListCommandMap(this));
addFloor(new RemoveCommandMap(this));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
}

View File

@ -0,0 +1,20 @@
package net.Indyuce.mmocore.command.rpg.booster;
import org.bukkit.command.CommandSender;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
public class BoosterCommandTreeNode extends CommandTreeNode {
public BoosterCommandTreeNode(CommandTreeNode parent) {
super(parent, "booster");
addChild(new CreateCommandTreeNode(this));
addChild(new ListCommandTreeNode(this));
addChild(new RemoveCommandTreeNode(this));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
}

View File

@ -11,17 +11,18 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.ConfigMessage;
import net.Indyuce.mmocore.api.experience.Booster;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class CreateCommandMap extends CommandEnd {
public CreateCommandMap(CommandMap parent) {
public class CreateCommandTreeNode extends CommandTreeNode {
public CreateCommandTreeNode(CommandTreeNode parent) {
super(parent, "create");
addParameter(Parameter.PROFESSION);
addParameter(new Parameter("<extra>", (list) -> list.addAll(Arrays.asList("0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1"))));
addParameter(new Parameter("<length>", (list) -> list.addAll(Arrays.asList("60", "300", "3600", "43200", "86400"))));
addParameter(MMOCoreCommandTreeRoot.PROFESSION);
addParameter(new Parameter("<extra>",
(explorer, list) -> list.addAll(Arrays.asList("0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1"))));
addParameter(new Parameter("<length>", (explorer, list) -> list.addAll(Arrays.asList("60", "300", "3600", "43200", "86400"))));
addParameter(Parameter.PLAYER_OPTIONAL);
}
@ -61,7 +62,8 @@ public class CreateCommandMap extends CommandEnd {
Profession profession = MMOCore.plugin.professionManager.get(format);
MMOCore.plugin.boosterManager.register(new Booster(args.length > 5 ? args[5] : null, profession, extra, length));
new ConfigMessage("booster-skill").addPlaceholders("multiplier", "" + (1 + extra), "profession", profession.getName()).send(Bukkit.getOnlinePlayers());
new ConfigMessage("booster-skill").addPlaceholders("multiplier", "" + (1 + extra), "profession", profession.getName())
.send(Bukkit.getOnlinePlayers());
Bukkit.getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1));
return CommandResult.SUCCESS;
}

View File

@ -7,12 +7,11 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Booster;
import net.Indyuce.mmocore.api.util.math.format.DelayFormat;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
public class ListCommandMap extends CommandEnd {
public ListCommandMap(CommandMap parent) {
public class ListCommandTreeNode extends CommandTreeNode {
public ListCommandTreeNode(CommandTreeNode parent) {
super(parent, "list");
}
@ -24,7 +23,13 @@ public class ListCommandMap extends CommandEnd {
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
for (Booster booster : MMOCore.plugin.boosterManager.getBoosters())
if (!booster.isTimedOut())
MMOLib.plugin.getVersion().getWrapper().sendJson((Player) sender, "{\"text\":\"" + ChatColor.YELLOW + "- " + ChatColor.GOLD + MMOCore.plugin.configManager.decimal.format((1 + booster.getExtra())) + "x" + ChatColor.YELLOW + " Booster - " + ChatColor.GOLD + (!booster.hasProfession() ? "ExploreAttributesCommand" : booster.getProfession().getName()) + ChatColor.YELLOW + " - " + ChatColor.GOLD + new DelayFormat().format(booster.getCreationDate() + booster.getLength() - System.currentTimeMillis()) + "\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/mmocore booster remove " + booster.getUniqueId().toString() + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to remove.\"}}}");
MMOLib.plugin.getVersion().getWrapper().sendJson((Player) sender, "{\"text\":\"" + ChatColor.YELLOW + "- " + ChatColor.GOLD
+ MMOCore.plugin.configManager.decimal.format((1 + booster.getExtra())) + "x" + ChatColor.YELLOW + " Booster - "
+ ChatColor.GOLD + (!booster.hasProfession() ? "ExploreAttributesCommand" : booster.getProfession().getName())
+ ChatColor.YELLOW + " - " + ChatColor.GOLD
+ new DelayFormat().format(booster.getCreationDate() + booster.getLength() - System.currentTimeMillis())
+ "\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/mmocore booster remove " + booster.getUniqueId().toString()
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to remove.\"}}}");
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
return CommandResult.SUCCESS;

View File

@ -8,15 +8,15 @@ import org.bukkit.command.CommandSender;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Booster;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class RemoveCommandMap extends CommandEnd {
public RemoveCommandMap(CommandMap parent) {
public class RemoveCommandTreeNode extends CommandTreeNode {
public RemoveCommandTreeNode(CommandTreeNode parent) {
super(parent, "remove");
addParameter(new Parameter("<id>", (list) -> MMOCore.plugin.boosterManager.getBoosters().forEach(booster -> list.add("" + booster.getUniqueId().toString()))));
addParameter(new Parameter("<id>",
(explorer, list) -> MMOCore.plugin.boosterManager.getBoosters().forEach(booster -> list.add("" + booster.getUniqueId().toString()))));
}
@Override

View File

@ -3,16 +3,16 @@ package net.Indyuce.mmocore.command.rpg.debug;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
public class DebugCommandMap extends CommandMap {
public class DebugCommandTreeNode extends CommandTreeNode {
public static final String commandPrefix = ChatColor.YELLOW + "[" + ChatColor.RED + "DEBUG" + ChatColor.GOLD + "] " + ChatColor.RESET;
public DebugCommandMap(CommandMap parent) {
public DebugCommandTreeNode(CommandTreeNode parent) {
super(parent, "debug");
addFloor(new StatValueCommandMap(this));
addFloor(new StatModifiersCommandMap(this));
addChild(new StatValueCommandTreeNode(this));
addChild(new StatModifiersCommandTreeNode(this));
}
@Override

View File

@ -6,17 +6,16 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.api.stat.StatInstance;
import net.mmogroup.mmolib.api.stat.modifier.StatModifier;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class StatModifiersCommandMap extends CommandEnd {
public StatModifiersCommandMap(CommandMap parent) {
public class StatModifiersCommandTreeNode extends CommandTreeNode {
public StatModifiersCommandTreeNode(CommandTreeNode parent) {
super(parent, "statmods");
addParameter(new Parameter("<stat>", list -> {
addParameter(new Parameter("<stat>", (explorer, list) -> {
for (StatType stat : StatType.values())
list.add(stat.name());
}));

View File

@ -6,19 +6,18 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class StatValueCommandMap extends CommandEnd {
public StatValueCommandMap(CommandMap parent) {
public class StatValueCommandTreeNode extends CommandTreeNode {
public StatValueCommandTreeNode(CommandTreeNode parent) {
super(parent, "statvalue");
addParameter(new Parameter("<stat>", list -> {
addParameter(new Parameter("<stat>", (explorer, list) -> {
for (StatType stat : StatType.values())
list.add(stat.name());
}));
addParameter(new Parameter("(formatted)", list -> {
addParameter(new Parameter("(formatted)", (explorer, list) -> {
list.add("true");
}));
}
@ -43,10 +42,10 @@ public class StatValueCommandMap extends CommandEnd {
}
if (args.length > 3 && args[3].equals("true"))
sender.sendMessage(DebugCommandMap.commandPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): "
sender.sendMessage(DebugCommandTreeNode.commandPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): "
+ ChatColor.GREEN + stat.format(data.getStats().getStat(stat)) + ChatColor.WHITE + " *");
else
sender.sendMessage(DebugCommandMap.commandPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): "
sender.sendMessage(DebugCommandTreeNode.commandPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): "
+ ChatColor.GREEN + data.getStats().getStat(stat));
return CommandResult.SUCCESS;

View File

@ -7,12 +7,11 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.PlayerQuests;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class CancelCommandEnd extends CommandEnd {
public CancelCommandEnd(CommandMap parent) {
public class CancelCommandTreeNode extends CommandTreeNode {
public CancelCommandTreeNode(CommandTreeNode parent) {
super(parent, "cancel");
addParameter(Parameter.PLAYER);

View File

@ -1,20 +0,0 @@
package net.Indyuce.mmocore.command.rpg.quest;
import org.bukkit.command.CommandSender;
import net.Indyuce.mmocore.command.api.CommandMap;
public class QuestCommandMap extends CommandMap {
public QuestCommandMap(CommandMap parent) {
super(parent, "quest");
addFloor(new StartCommandEnd(this));
addFloor(new CancelCommandEnd(this));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
}

View File

@ -0,0 +1,20 @@
package net.Indyuce.mmocore.command.rpg.quest;
import org.bukkit.command.CommandSender;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
public class QuestCommandTreeNode extends CommandTreeNode {
public QuestCommandTreeNode(CommandTreeNode parent) {
super(parent, "quest");
addChild(new StartCommandTreeNode(this));
addChild(new CancelCommandTreeNode(this));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
}

View File

@ -9,16 +9,16 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.PlayerQuests;
import net.Indyuce.mmocore.api.quest.Quest;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class StartCommandEnd extends CommandEnd {
public StartCommandEnd(CommandMap parent) {
public class StartCommandTreeNode extends CommandTreeNode {
public StartCommandTreeNode(CommandTreeNode parent) {
super(parent, "start");
addParameter(Parameter.PLAYER);
addParameter(Parameter.QUEST);
addParameter(MMOCoreCommandTreeRoot.QUEST);
}
@Override

View File

@ -5,13 +5,12 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.Indyuce.mmocore.manager.InventoryManager;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class OpenCommandMap extends CommandEnd {
public OpenCommandMap(CommandMap parent) {
public class OpenCommandTreeNode extends CommandTreeNode {
public OpenCommandTreeNode(CommandTreeNode parent) {
super(parent, "open");
addParameter(Parameter.PLAYER);

View File

@ -8,15 +8,14 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.Waypoint;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
import net.mmogroup.mmolib.command.api.Parameter;
public class UnlockCommandMap extends CommandEnd {
public UnlockCommandMap(CommandMap parent) {
public class UnlockCommandTreeNode extends CommandTreeNode {
public UnlockCommandTreeNode(CommandTreeNode parent) {
super(parent, "unlock");
addParameter(new Parameter("<waypoint>", (list) -> MMOCore.plugin.waypointManager.getAll().forEach(way -> list.add(way.getId()))));
addParameter(new Parameter("<waypoint>", (explorer, list) -> MMOCore.plugin.waypointManager.getAll().forEach(way -> list.add(way.getId()))));
addParameter(Parameter.PLAYER);
}
@ -38,7 +37,8 @@ public class UnlockCommandMap extends CommandEnd {
Waypoint waypoint = MMOCore.plugin.waypointManager.get(args[2]);
PlayerData.get(player).unlockWaypoint(waypoint);
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " successfully unlocked " + ChatColor.GOLD + waypoint.getId() + ChatColor.YELLOW + ".");
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " successfully unlocked " + ChatColor.GOLD + waypoint.getId()
+ ChatColor.YELLOW + ".");
return CommandResult.SUCCESS;
}
}

View File

@ -1,19 +0,0 @@
package net.Indyuce.mmocore.command.rpg.waypoint;
import org.bukkit.command.CommandSender;
import net.Indyuce.mmocore.command.api.CommandMap;
public class WaypointsCommandMap extends CommandMap {
public WaypointsCommandMap(CommandMap parent) {
super(parent, "waypoints");
addFloor(new UnlockCommandMap(this));
addFloor(new OpenCommandMap(this));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
}

View File

@ -0,0 +1,19 @@
package net.Indyuce.mmocore.command.rpg.waypoint;
import org.bukkit.command.CommandSender;
import net.mmogroup.mmolib.command.api.CommandTreeNode;
public class WaypointsCommandTreeNode extends CommandTreeNode {
public WaypointsCommandTreeNode(CommandTreeNode parent) {
super(parent, "waypoints");
addChild(new UnlockCommandTreeNode(this));
addChild(new OpenCommandTreeNode(this));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
}