mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-03-13 13:30:06 +01:00
!Command mapping, give command is now /mi give <type> <id>
This commit is contained in:
parent
a79c9bbcd0
commit
5dbc4b53b1
@ -1,942 +0,0 @@
|
||||
package net.Indyuce.mmoitems.command;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.ItemTier;
|
||||
import net.Indyuce.mmoitems.api.PluginUpdate;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.ability.Ability;
|
||||
import net.Indyuce.mmoitems.api.ability.Ability.CastingMode;
|
||||
import net.Indyuce.mmoitems.api.crafting.CraftingStation;
|
||||
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.template.loot.ClassFilter;
|
||||
import net.Indyuce.mmoitems.api.item.template.loot.LootBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.template.loot.TypeFilter;
|
||||
import net.Indyuce.mmoitems.api.item.util.identify.IdentifiedItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.Indyuce.mmoitems.api.util.RandomAmount;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.gui.CraftingStationView;
|
||||
import net.Indyuce.mmoitems.gui.ItemBrowser;
|
||||
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
|
||||
import net.Indyuce.mmoitems.stat.LuteAttackEffectStat.LuteAttackEffect;
|
||||
import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import net.mmogroup.mmolib.api.util.SmartGive;
|
||||
|
||||
public class MMOItemsCommand implements CommandExecutor {
|
||||
private static final Random random = new Random();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!sender.hasPermission("mmoitems.admin")) {
|
||||
Message.NOT_ENOUGH_PERMS_COMMAND.format(ChatColor.RED).send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ==================================================================================================================================
|
||||
if (args.length < 1) {
|
||||
new PluginHelp(sender).open(1);
|
||||
return true;
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("help")) {
|
||||
if (args.length < 2) {
|
||||
new PluginHelp(sender).open(1);
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
new PluginHelp(sender).open(Integer.parseInt(args[1]));
|
||||
} catch (NumberFormatException exception) {
|
||||
sender.sendMessage(ChatColor.RED + args[1] + " is not a valid number.");
|
||||
}
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("generate")) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /mi generate <player> (extra-args)");
|
||||
sender.sendMessage(ChatColor.RED + "Possible extra arguments:");
|
||||
sender.sendMessage(ChatColor.RED + "-matchlevel " + ChatColor.GRAY + "the loot item's level matches the player level");
|
||||
sender.sendMessage(ChatColor.RED + "-matchclass " + ChatColor.GRAY + "the item's class matches the player class");
|
||||
sender.sendMessage(ChatColor.RED + "-gimme " + ChatColor.GRAY + "gives the item to you instead");
|
||||
sender.sendMessage(ChatColor.RED + "-class:<class-name> " + ChatColor.GRAY + "finds an item with a specific class");
|
||||
sender.sendMessage(ChatColor.RED + "-level:<level> " + ChatColor.GRAY + "uses a specific item level");
|
||||
sender.sendMessage(ChatColor.RED + "-tier:<tier> " + ChatColor.GRAY + "uses a specific item tier");
|
||||
sender.sendMessage(ChatColor.RED + "-type:<type> " + ChatColor.GRAY + "finds an item with a specific item type");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
final Player target = Bukkit.getPlayer(args[1]);
|
||||
Validate.notNull(target, "Could not find player called " + args[1] + ".");
|
||||
|
||||
GenerateCommandHandler handler = new GenerateCommandHandler(args);
|
||||
|
||||
final Player give = handler.hasArgument("gimme") || handler.hasArgument("giveme")
|
||||
? (sender instanceof Player ? (Player) sender : null)
|
||||
: target;
|
||||
Validate.notNull(give, "You cannot use -gimme");
|
||||
|
||||
RPGPlayer rpgPlayer = PlayerData.get(target).getRPG();
|
||||
final int itemLevel = handler.hasArgument("level") ? Integer.parseInt(handler.getValue("level"))
|
||||
: (handler.hasArgument("matchlevel") ? MMOItems.plugin.getTemplates().rollLevel(rpgPlayer.getLevel())
|
||||
: 1 + random.nextInt(100));
|
||||
final ItemTier itemTier = handler.hasArgument("tier")
|
||||
? MMOItems.plugin.getTiers().getOrThrow(handler.getValue("tier").toUpperCase().replace("-", "_"))
|
||||
: MMOItems.plugin.getTemplates().rollTier();
|
||||
|
||||
LootBuilder builder = new LootBuilder(itemLevel, itemTier);
|
||||
if (handler.hasArgument("matchclass"))
|
||||
builder.applyFilter(new ClassFilter(rpgPlayer));
|
||||
if (handler.hasArgument("class"))
|
||||
builder.applyFilter(new ClassFilter(handler.getValue("class").replace("-", " ").replace("_", " ")));
|
||||
if (handler.hasArgument("type")) {
|
||||
String format = handler.getValue("type");
|
||||
Validate.isTrue(Type.isValid(format), "Could not find type with ID '" + format + "'");
|
||||
builder.applyFilter(new TypeFilter(Type.get(format)));
|
||||
}
|
||||
|
||||
MMOItem mmoitem = builder.rollLoot();
|
||||
Validate.notNull(mmoitem, "No item matched your criterias.");
|
||||
|
||||
ItemStack item = mmoitem.newBuilder().build();
|
||||
Validate.isTrue(item != null && item.getType() != Material.AIR, "Could not generate item with ID '" + mmoitem.getId() + "'");
|
||||
new SmartGive(give).give(item);
|
||||
|
||||
} catch (IllegalArgumentException exception) {
|
||||
sender.sendMessage(ChatColor.RED + exception.getMessage());
|
||||
}
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("browse")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
new ItemBrowser((Player) sender).open();
|
||||
return true;
|
||||
}
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Please specify a valid item type.");
|
||||
return true;
|
||||
}
|
||||
|
||||
new ItemBrowser((Player) sender, Type.get(args[1])).open();
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("update")) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.GRAY
|
||||
+ "Sometimes updates happen to break config files due to a change in data storage. Applying a plugin config update using /mi update allows to instantly fix these issues.");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.RED
|
||||
+ "Make sure you only apply required updates! You may also consider backing up your data before applying any update.");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi update list" + ChatColor.WHITE + " lists available config updates.");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi update info <id>" + ChatColor.WHITE + " displays info about an update.");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi update apply <id>" + ChatColor.WHITE + " applies a config update.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equals("info")) {
|
||||
if (args.length < 3) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /mi update apply <id>");
|
||||
return true;
|
||||
}
|
||||
|
||||
int id;
|
||||
try {
|
||||
id = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException exception) {
|
||||
sender.sendMessage(ChatColor.RED + "Please specify a valid number.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!MMOItems.plugin.getUpdates().has(id)) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find any config update with ID " + id);
|
||||
return true;
|
||||
}
|
||||
|
||||
PluginUpdate update = MMOItems.plugin.getUpdates().get(id);
|
||||
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Config Update n" + update.getId());
|
||||
if (update.hasDescription()) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "Description:");
|
||||
for (String line : update.getDescription())
|
||||
sender.sendMessage(ChatColor.GRAY + "- " + ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Use " + ChatColor.GOLD + "/mi update apply " + update.getId() + ChatColor.YELLOW
|
||||
+ " to apply this config update.");
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("list")) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Available Config Updates");
|
||||
for (PluginUpdate update : MMOItems.plugin.getUpdates().getAll())
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "- Update " + update.getId());
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("apply")) {
|
||||
if (args.length < 4) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /mi update apply <id> <id>");
|
||||
return true;
|
||||
}
|
||||
|
||||
int id;
|
||||
try {
|
||||
id = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException exception) {
|
||||
sender.sendMessage(ChatColor.RED + "Please specify a valid number.");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
if (id != Integer.parseInt(args[3]))
|
||||
throw new NumberFormatException();
|
||||
} catch (NumberFormatException exception) {
|
||||
sender.sendMessage(ChatColor.RED
|
||||
+ "Update IDs do not match. Make sure you enter twice the same ID to confirm you want to apply this update.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!MMOItems.plugin.getUpdates().has(id)) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find any config update with ID " + id);
|
||||
return true;
|
||||
}
|
||||
|
||||
PluginUpdate update = MMOItems.plugin.getUpdates().get(id);
|
||||
sender.sendMessage(ChatColor.YELLOW + "Applying config update " + id + "...");
|
||||
update.apply(sender);
|
||||
sender.sendMessage(
|
||||
ChatColor.YELLOW + "Config update " + id + " was successfully applied. Check the console for potential update error logs.");
|
||||
}
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("checkstat")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStat stat = MMOItems.plugin.getStats().get(args[1].toUpperCase().replace("-", "_"));
|
||||
if (stat == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Couldn't find the stat called " + args[1].toUpperCase().replace("-", "_") + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
player.sendMessage("Found stat with ID " + stat.getId() + " = " + PlayerData.get((Player) sender).getStats().getStat(stat));
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("checkattribute")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2)
|
||||
return true;
|
||||
|
||||
Player player = (Player) sender;
|
||||
try {
|
||||
AttributeInstance att = player.getAttribute(Attribute.valueOf(args[1].toUpperCase().replace("-", "_")));
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
|
||||
sender.sendMessage(ChatColor.AQUA + "Default Value = " + ChatColor.RESET + att.getDefaultValue());
|
||||
sender.sendMessage(ChatColor.AQUA + "Base Value = " + ChatColor.RESET + att.getBaseValue());
|
||||
sender.sendMessage(ChatColor.AQUA + "Value = " + ChatColor.RESET + att.getValue());
|
||||
for (AttributeModifier mod : att.getModifiers())
|
||||
sender.sendMessage(mod.getName() + " " + new DecimalFormat("0.####").format(mod.getAmount()) + " " + mod.getOperation() + " "
|
||||
+ mod.getSlot());
|
||||
} catch (IllegalArgumentException exception) {
|
||||
player.sendMessage("Couldn't find attribute.");
|
||||
} catch (NoSuchMethodError error) {
|
||||
player.sendMessage("This command is not supported by your server version.");
|
||||
}
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("checktags")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
|
||||
for (String s : MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand()).getTags())
|
||||
player.sendMessage("- " + s);
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("checktag")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
if (args.length < 2)
|
||||
return true;
|
||||
|
||||
NBTItem item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand());
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
|
||||
player.sendMessage(
|
||||
ChatColor.AQUA + "Boolean = " + ChatColor.RESET + item.getBoolean("MMOITEMS_" + args[1].toUpperCase().replace("-", "_")));
|
||||
player.sendMessage(
|
||||
ChatColor.AQUA + "Double = " + ChatColor.RESET + item.getDouble("MMOITEMS_" + args[1].toUpperCase().replace("-", "_")));
|
||||
player.sendMessage(
|
||||
ChatColor.AQUA + "String = " + ChatColor.RESET + item.getString("MMOITEMS_" + args[1].toUpperCase().replace("-", "_")));
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("settag")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
if (args.length < 3)
|
||||
return true;
|
||||
try {
|
||||
player.getInventory().setItemInMainHand(MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand())
|
||||
.addTag(new ItemTag(args[1].toUpperCase().replace("-", "_"), args[2].replace("%%", " "))).toItem());
|
||||
player.sendMessage("Successfully set tag.");
|
||||
|
||||
} catch (Exception e) {
|
||||
player.sendMessage("Couldn't set tag.");
|
||||
}
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("unidentify")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
NBTItem item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand());
|
||||
if (item.getType() == null) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Couldn't unidentify the item you are holding.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getBoolean("MMOITEMS_UNIDENTIFIED")) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "The item you are holding is already unidentified.");
|
||||
return true;
|
||||
}
|
||||
|
||||
player.getInventory().setItemInMainHand(item.getType().getUnidentifiedTemplate().newBuilder(item).build());
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully unidentified the item you are holding.");
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("identify")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
NBTItem item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand());
|
||||
String tag = item.getString("MMOITEMS_UNIDENTIFIED_ITEM");
|
||||
if (tag.equals("")) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "The item you are holding is already identified.");
|
||||
return true;
|
||||
}
|
||||
|
||||
final int amount = player.getInventory().getItemInMainHand().getAmount();
|
||||
ItemStack identifiedItem = new IdentifiedItem(item).identify();
|
||||
identifiedItem.setAmount(amount);
|
||||
|
||||
player.getInventory().setItemInMainHand(identifiedItem);
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully identified the item you are holding.");
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("stations")) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE
|
||||
+ " Crafting Stations " + ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi stations list" + ChatColor.WHITE + " shows available crafting stations.");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi stations open <station> (player)" + ChatColor.WHITE + " opens a station.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("list")) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE
|
||||
+ " Crafting Stations " + ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
for (CraftingStation station : MMOItems.plugin.getCrafting().getAll())
|
||||
sender.sendMessage(ChatColor.GRAY + "- " + ChatColor.WHITE + station.getId());
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("open")) {
|
||||
if (args.length < 3) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /mi stations open <station> (player)");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!MMOItems.plugin.getCrafting().hasStation(args[2])) {
|
||||
sender.sendMessage(ChatColor.RED + "There is no station called " + args[2] + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = args.length > 3 ? Bukkit.getPlayer(args[3]) : (sender instanceof Player ? (Player) sender : null);
|
||||
if (target == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Please specify a valid player.");
|
||||
return true;
|
||||
}
|
||||
|
||||
new CraftingStationView(target, MMOItems.plugin.getCrafting().getStation(args[2]), 1).open();
|
||||
}
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("info")) {
|
||||
Player player = args.length > 1 ? Bukkit.getPlayer(args[1]) : (sender instanceof Player ? (Player) sender : null);
|
||||
if (player == null) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Couldn't find the target player.");
|
||||
return true;
|
||||
}
|
||||
|
||||
RPGPlayer rpg = PlayerData.get(player).getRPG();
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE
|
||||
+ " Player Information " + ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
sender.sendMessage(ChatColor.WHITE + "Information about " + ChatColor.LIGHT_PURPLE + player.getName());
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Class: " + ChatColor.LIGHT_PURPLE + rpg.getClassName());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Level: " + ChatColor.LIGHT_PURPLE + rpg.getLevel());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Mana: " + ChatColor.LIGHT_PURPLE + rpg.getMana());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Stamina: " + ChatColor.LIGHT_PURPLE + rpg.getStamina());
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("heal")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
player.setFoodLevel(20);
|
||||
player.setFireTicks(0);
|
||||
player.setSaturation(12);
|
||||
for (PotionEffectType pe : new PotionEffectType[] { PotionEffectType.POISON, PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION,
|
||||
PotionEffectType.HUNGER, PotionEffectType.WEAKNESS, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING })
|
||||
player.removePotionEffect(pe);
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("stations")) {
|
||||
MMOItems.plugin.getCrafting().reload();
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully reloaded the crafting stations..");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "- " + ChatColor.RED + MMOItems.plugin.getCrafting().getAll().size()
|
||||
+ ChatColor.GRAY + " Crafting Stations");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "- " + ChatColor.RED + MMOItems.plugin.getCrafting().countRecipes()
|
||||
+ ChatColor.GRAY + " Recipes");
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("recipes")) {
|
||||
MMOItems.plugin.getRecipes().reloadRecipes();
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully reloaded recipes.");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "- " + ChatColor.RED
|
||||
+ (MMOItems.plugin.getRecipes().getLoadedRecipes().size() + MMOItems.plugin.getRecipes().getCustomRecipes().size())
|
||||
+ ChatColor.GRAY + " Recipes");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
MMOItems.plugin.getLanguage().reload();
|
||||
MMOItems.plugin.getDropTables().reload();
|
||||
MMOItems.plugin.getTypes().reload();
|
||||
MMOItems.plugin.getTiers().reload();
|
||||
MMOItems.plugin.getSets().reload();
|
||||
MMOItems.plugin.getUpgrades().reload();
|
||||
MMOItems.plugin.getTemplates().reload();
|
||||
MMOItems.plugin.getWorldGen().reload();
|
||||
MMOItems.plugin.getCustomBlocks().reload();
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + MMOItems.plugin.getName() + " " + MMOItems.plugin.getDescription().getVersion() + " reloaded.");
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + "- " + ChatColor.RED + MMOItems.plugin.getTypes().getAll().size() + ChatColor.GRAY + " Item Types");
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + "- " + ChatColor.RED + MMOItems.plugin.getTiers().getAll().size() + ChatColor.GRAY + " Item Tiers");
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + "- " + ChatColor.RED + MMOItems.plugin.getSets().getAll().size() + ChatColor.GRAY + " Item Sets");
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("copy")) {
|
||||
if (args.length < 4) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Usage: /mi copy <type> <copied-item-id> <new-item-id>");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called "
|
||||
+ args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Type " + ChatColor.GREEN + "/mi list type " + ChatColor.GRAY
|
||||
+ "to see all the available item types.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1]);
|
||||
ConfigFile config = type.getConfigFile();
|
||||
String id1 = args[2].toUpperCase().replace("-", "_");
|
||||
if (!config.getConfig().contains(id1)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item called " + id1 + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
String id2 = args[3].toUpperCase();
|
||||
if (config.getConfig().contains(id2)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is already an item called " + id2 + "!");
|
||||
return true;
|
||||
}
|
||||
|
||||
config.getConfig().set(id2, config.getConfig().getConfigurationSection(id1));
|
||||
config.save();
|
||||
if (sender instanceof Player)
|
||||
new ItemEdition((Player) sender, MMOItems.plugin.getTemplates().getTemplate(type, id2)).open();
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GREEN + "You successfully copied " + id1 + " to " + id2 + "!");
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("allitems")) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
|
||||
sender.sendMessage(ChatColor.GREEN + "List of all mmoitems:");
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll()) {
|
||||
FileConfiguration config = type.getConfigFile().getConfig();
|
||||
for (String s : config.getKeys(false))
|
||||
sender.sendMessage("* " + ChatColor.GREEN + s
|
||||
+ (config.getConfigurationSection(s).contains("name")
|
||||
? " " + ChatColor.WHITE + "(" + MMOLib.plugin.parseColors(config.getString(s + ".name")) + ChatColor.WHITE + ")"
|
||||
: ""));
|
||||
}
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("itemlist")) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Usage: /mi itemlist <type>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_"));
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Type " + ChatColor.GREEN + "/mi list type " + ChatColor.GRAY
|
||||
+ "to see all the available item types.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1]);
|
||||
sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
|
||||
sender.sendMessage(ChatColor.GREEN + "List of all items in " + type.getId().toLowerCase() + ".yml:");
|
||||
FileConfiguration config = type.getConfigFile().getConfig();
|
||||
if (!(sender instanceof Player)) {
|
||||
for (String s : config.getKeys(false))
|
||||
sender.sendMessage("* " + ChatColor.GREEN + s
|
||||
+ (config.getConfigurationSection(s).contains("name")
|
||||
? " " + ChatColor.WHITE + "(" + MMOLib.plugin.parseColors(config.getString(s + ".name")) + ChatColor.WHITE + ")"
|
||||
: ""));
|
||||
return true;
|
||||
}
|
||||
for (String s : config.getKeys(false)) {
|
||||
String nameFormat = config.getConfigurationSection(s).contains("name")
|
||||
? " " + ChatColor.WHITE + "(" + MMOLib.plugin.parseColors(config.getString(s + ".name")) + ChatColor.WHITE + ")"
|
||||
: "";
|
||||
MMOLib.plugin.getVersion().getWrapper().sendJson((Player) sender,
|
||||
"{\"text\":\"* " + ChatColor.GREEN + s + nameFormat + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/mi edit "
|
||||
+ type.getId() + " " + s + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to edit "
|
||||
+ (nameFormat.equals("") ? s : MMOLib.plugin.parseColors(config.getString(s + ".name"))) + ChatColor.WHITE
|
||||
+ ".\",\"color\":\"white\"}}}");
|
||||
}
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("list")) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE
|
||||
+ " MMOItems: lists " + ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi list type " + ChatColor.WHITE + "shows all item types (sword, axe...)");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi list spirit " + ChatColor.WHITE + "shows all available staff spirits");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi list lute " + ChatColor.WHITE + "shows all available lute attack effects");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi list ability " + ChatColor.WHITE + "shows all available abilities");
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("Spigot Javadoc Links:");
|
||||
MMOLib.plugin.getVersion().getWrapper().sendJson((Player) sender, "[{\"text\":\"" + ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Materials/Blocks\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}},{\"text\":\" " + ChatColor.LIGHT_PURPLE + "- \"},{\"text\":\""
|
||||
+ ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Potion Effects\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}},{\"text\":\" " + ChatColor.LIGHT_PURPLE + "- \"},{\"text\":\""
|
||||
+ ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Sounds\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}}]");
|
||||
MMOLib.plugin.getVersion().getWrapper().sendJson((Player) sender, "[{\"text\":\"" + ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Entities/Mobs\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/EntityType.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}},{\"text\":\" " + ChatColor.LIGHT_PURPLE + "- \"},{\"text\":\""
|
||||
+ ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Enchantments\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/enchantments/Enchantment.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}},{\"text\":\" " + ChatColor.LIGHT_PURPLE + "- \"},{\"text\":\""
|
||||
+ ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Particles\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particles.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}}]");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ability list
|
||||
if (args[1].equalsIgnoreCase("ability")) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " Abilities "
|
||||
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
sender.sendMessage(ChatColor.WHITE + "Here are all the abilities you can bind to items.");
|
||||
sender.sendMessage(ChatColor.WHITE + "The values inside brackets are " + ChatColor.UNDERLINE + "modifiers" + ChatColor.WHITE
|
||||
+ " which allow you to change the ability values (cooldown, damage...)");
|
||||
for (Ability a : MMOItems.plugin.getAbilities().getAll()) {
|
||||
String modFormat = ChatColor.GRAY + String.join(ChatColor.WHITE + ", " + ChatColor.GRAY, a.getModifiers());
|
||||
modFormat = ChatColor.WHITE + "(" + modFormat + ChatColor.WHITE + ")";
|
||||
sender.sendMessage("* " + ChatColor.LIGHT_PURPLE + a.getName() + " " + modFormat);
|
||||
}
|
||||
}
|
||||
|
||||
// item type list
|
||||
if (args[1].equalsIgnoreCase("type")) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " Item Types "
|
||||
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + ChatColor.LIGHT_PURPLE + " Item Types " + ChatColor.DARK_GRAY + ""
|
||||
+ ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll())
|
||||
sender.sendMessage("* " + ChatColor.LIGHT_PURPLE + type.getName() + " (" + type.getId() + ")");
|
||||
}
|
||||
|
||||
// staff spirit list
|
||||
if (args[1].equalsIgnoreCase("spirit")) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE
|
||||
+ " Staff Spirits " + ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
for (StaffSpirit ss : StaffSpirit.values()) {
|
||||
String lore = !ss.hasLore() ? " " + ChatColor.WHITE + ">> " + ChatColor.GRAY + "" + ChatColor.ITALIC + ss.getLore() : "";
|
||||
sender.sendMessage("* " + ChatColor.LIGHT_PURPLE + ss.getName() + lore);
|
||||
}
|
||||
}
|
||||
|
||||
// lute attack effect list
|
||||
if (args[1].equalsIgnoreCase("lute")) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE
|
||||
+ " Lute Attack Effects " + ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
for (LuteAttackEffect lae : LuteAttackEffect.values())
|
||||
sender.sendMessage("* " + ChatColor.LIGHT_PURPLE + lae.getName());
|
||||
}
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("create")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 3) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Usage: /mi create <type> <item-id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called "
|
||||
+ args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type" + ChatColor.RED
|
||||
+ " to see all the available item types.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1]);
|
||||
String name = args[2].toUpperCase().replace("-", "_");
|
||||
ConfigFile config = type.getConfigFile();
|
||||
if (config.getConfig().contains(name)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is already an item called " + name + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
config.getConfig().set(name + ".base.material", type.getItem().getType().name());
|
||||
config.save();
|
||||
MMOItems.plugin.getTemplates().requestTemplateUpdate(type, name);
|
||||
|
||||
if (sender instanceof Player)
|
||||
new ItemEdition((Player) sender, MMOItems.plugin.getTemplates().getTemplate(type, name)).open();
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GREEN + "You successfully created " + name + "!");
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("drop")) {
|
||||
if (args.length != 10) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix()
|
||||
+ "Usage: /mi drop <type> <item-id> <world-name> <x> <y> <z> <drop-chance> <[min]-[max]> <unidentified-chance>");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called "
|
||||
+ args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type " + ChatColor.RED
|
||||
+ "to see all the available item types.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1].toUpperCase());
|
||||
String name = args[2].toUpperCase().replace("-", "_");
|
||||
FileConfiguration config = type.getConfigFile().getConfig();
|
||||
if (!config.contains(name)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item called " + name + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
World world = Bukkit.getWorld(args[3]);
|
||||
if (world == null) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Couldn't find the world called " + args[3] + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
double x, y, z, dropChance, unidentifiedChance;
|
||||
int min, max;
|
||||
|
||||
try {
|
||||
x = Double.parseDouble(args[4]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + args[4] + " is not a valid number.");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
y = Double.parseDouble(args[5]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + args[5] + " is not a valid number.");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
z = Double.parseDouble(args[6]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + args[6] + " is not a valid number.");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
dropChance = Double.parseDouble(args[7]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + args[7] + " is not a valid number.");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
unidentifiedChance = Double.parseDouble(args[9]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + args[9] + " is not a valid number.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String[] splitAmount = args[8].split("\\-");
|
||||
if (splitAmount.length != 2) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "The drop quantity format is incorrect.");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Format: [min]-[max]");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
min = Integer.parseInt(splitAmount[0]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + splitAmount[0] + " is not a valid number.");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
max = Integer.parseInt(splitAmount[1]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + splitAmount[1] + " is not a valid number.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack item = new MMOItemDropItem(type, name, dropChance / 100, unidentifiedChance / 100, min, max).getItem(null);
|
||||
if (item == null || item.getType() == Material.AIR) {
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + ChatColor.RED + "An error occured while attempting to generate the item called " + name + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "See console for more information!");
|
||||
return true;
|
||||
}
|
||||
|
||||
world.dropItem(new Location(world, x, y, z), item);
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("remove")) {
|
||||
if (args.length < 3) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Usage: /mi " + args[0] + " <type> <item-id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called "
|
||||
+ args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type" + ChatColor.RED
|
||||
+ " to see all the available item types.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1]);
|
||||
String id = args[2].toUpperCase().replace("-", "_");
|
||||
if (!MMOItems.plugin.getTemplates().hasTemplate(type, id)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item called " + id + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
MMOItems.plugin.getTemplates().deleteTemplate(type, id);
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GREEN + "You successfully deleted " + id + ".");
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("edit")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 3) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Usage: /mi edit <type> <item-id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called "
|
||||
+ args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type" + ChatColor.RED
|
||||
+ " to see all the available item types.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1]);
|
||||
String id = args[2].toUpperCase().replace("-", "_");
|
||||
if (!MMOItems.plugin.getTemplates().hasTemplate(type, id)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Could not find a template called '" + id + "'.");
|
||||
return true;
|
||||
}
|
||||
|
||||
new ItemEdition((Player) sender, MMOItems.plugin.getTemplates().getTemplate(type, id)).open();
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("ability")) {
|
||||
if (args.length < 3 && !(sender instanceof Player)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Please specify a player to use this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED
|
||||
+ "Usage: /mi ability <ability> (player) (modifier1) (value1) (modifier2) (value2)...");
|
||||
return false;
|
||||
}
|
||||
|
||||
// target
|
||||
Player target = args.length > 2 ? Bukkit.getPlayer(args[2]) : (Player) sender;
|
||||
if (target == null) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Couldn't find player called " + args[2] + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
// ability
|
||||
String key = args[1].toUpperCase().replace("-", "_");
|
||||
if (!MMOItems.plugin.getAbilities().hasAbility(key)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Couldn't find ability " + key + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
// modifiers
|
||||
AbilityData ability = new AbilityData(MMOItems.plugin.getAbilities().getAbility(key), CastingMode.RIGHT_CLICK);
|
||||
for (int j = 3; j < args.length - 1; j += 2) {
|
||||
String name = args[j];
|
||||
String value = args[j + 1];
|
||||
|
||||
try {
|
||||
ability.setModifier(name, Double.parseDouble(value));
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Wrong format: {" + name + " " + value + "}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerData.get(target).cast(ability);
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args[0].equalsIgnoreCase("giveall"))
|
||||
try {
|
||||
Validate.isTrue(args.length > 4, "Usage: /mi giveall <type> <item-id> <[min]-[max]> <unidentified-chance>");
|
||||
|
||||
// item
|
||||
Type type = MMOItems.plugin.getTypes().getOrThrow(args[1]);
|
||||
ItemStack item = new MMOItemDropItem(type, args[2], 1, Double.parseDouble(args[4]) / 100, new RandomAmount(args[3])).getItem(null);
|
||||
Validate.isTrue(item != null && item.getType() != Material.AIR, "Couldn't find/generate the item called '" + args[1].toUpperCase()
|
||||
+ "'. Check your console for potential item generation issues.");
|
||||
|
||||
for (Player target : Bukkit.getOnlinePlayers())
|
||||
new SmartGive(target).give(item);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + exception.getMessage());
|
||||
}
|
||||
// ==================================================================================================================================
|
||||
else if (args.length > 1)
|
||||
try {
|
||||
Validate.isTrue(args.length > 2 || sender instanceof Player,
|
||||
"Usage: /mi <type> <item> (player) (min-max) (unident-chance) (drop-chance)");
|
||||
|
||||
// target
|
||||
Player target = args.length > 2 ? Bukkit.getPlayer(args[2]) : (Player) sender;
|
||||
Validate.notNull(target, "Could not find player called '" + args[args.length > 2 ? 2 : 1] + "'.");
|
||||
|
||||
// item
|
||||
Type type = MMOItems.plugin.getTypes().getOrThrow(args[0].toUpperCase());
|
||||
MMOItemDropItem dropItem = new MMOItemDropItem(type, args[1].toUpperCase(), args.length > 5 ? Double.parseDouble(args[5]) / 100 : 1,
|
||||
args.length > 4 ? Double.parseDouble(args[4]) / 100 : 0,
|
||||
args.length > 3 ? new RandomAmount(args[3]) : new RandomAmount(1, 1));
|
||||
if (!dropItem.rollDrop())
|
||||
return true;
|
||||
|
||||
ItemStack item = dropItem.getItem(PlayerData.get(target));
|
||||
Validate.isTrue(item != null && item.getType() != Material.AIR, "Couldn't find/generate the item called '" + args[1].toUpperCase()
|
||||
+ "'. Check your console for potential item generation issues.");
|
||||
|
||||
// message
|
||||
if (!sender.equals(target))
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.YELLOW + "Successfully gave " + ChatColor.GOLD
|
||||
+ MMOUtils.getDisplayName(item) + (item.getAmount() > 1 ? " x" + item.getAmount() : "") + ChatColor.YELLOW + " to "
|
||||
+ ChatColor.GOLD + target.getName() + ChatColor.YELLOW + ".");
|
||||
Message.RECEIVED_ITEM.format(ChatColor.YELLOW, "#item#", MMOUtils.getDisplayName(item), "#amount#",
|
||||
(item.getAmount() > 1 ? " x" + item.getAmount() : "")).send(target);
|
||||
|
||||
// item
|
||||
new SmartGive(target).give(item);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + exception.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package net.Indyuce.mmoitems.command;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.AbilityCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.AllItemsCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.BrowseCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.CopyCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.CreateCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.DeleteCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.DropCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.EditCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.GenerateCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.GiveAllCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.GiveCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.IdentifyCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.ReloadCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.UnidentifyCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.debug.DebugCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.list.ListCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.stations.StationsCommandTreeNode;
|
||||
import net.Indyuce.mmoitems.command.mmoitems.update.UpdateCommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeRoot;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class MMOItemsCommandTreeRoot extends CommandTreeRoot {
|
||||
public static final Parameter TYPE = new Parameter("<type>",
|
||||
(explorer, list) -> MMOItems.plugin.getTypes().getAll().forEach(type -> list.add(type.getId())));
|
||||
public static final Parameter ID_2 = new Parameter("<id>", (explorer, list) -> {
|
||||
try {
|
||||
Type type = Type.get(explorer.getArguments()[1]);
|
||||
MMOItems.plugin.getTemplates().getTemplates(type).forEach(template -> list.add(template.getId()));
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
});
|
||||
|
||||
public MMOItemsCommandTreeRoot() {
|
||||
super("mmoitems", "mmoitems.admin");
|
||||
|
||||
addChild(new CreateCommandTreeNode(this));
|
||||
addChild(new DeleteCommandTreeNode(this));
|
||||
addChild(new EditCommandTreeNode(this));
|
||||
addChild(new CopyCommandTreeNode(this));
|
||||
addChild(new GiveCommandTreeNode(this));
|
||||
|
||||
addChild(new GenerateCommandTreeNode(this));
|
||||
// addChild(new HelpCommandTreeNode(this));
|
||||
addChild(new BrowseCommandTreeNode(this));
|
||||
addChild(new UpdateCommandTreeNode(this));
|
||||
addChild(new DebugCommandTreeNode(this));
|
||||
addChild(new ReloadCommandTreeNode(this));
|
||||
addChild(new StationsCommandTreeNode(this));
|
||||
addChild(new AllItemsCommandTreeNode(this));
|
||||
addChild(new ListCommandTreeNode(this));
|
||||
addChild(new DropCommandTreeNode(this));
|
||||
addChild(new AbilityCommandTreeNode(this));
|
||||
addChild(new GiveAllCommandTreeNode(this));
|
||||
|
||||
addChild(new IdentifyCommandTreeNode(this));
|
||||
addChild(new UnidentifyCommandTreeNode(this));
|
||||
}
|
||||
}
|
@ -1,167 +0,0 @@
|
||||
package net.Indyuce.mmoitems.command.completion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.ability.Ability;
|
||||
|
||||
public class MMOItemsCompletion implements TabCompleter {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!sender.hasPermission("mmoitems.admin"))
|
||||
return null;
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
if (args.length == 1) {
|
||||
list.add("edit");
|
||||
list.add("create");
|
||||
list.add("browse");
|
||||
list.add("load");
|
||||
list.add("copy");
|
||||
list.add("drop");
|
||||
list.add("generate");
|
||||
list.add("itemlist");
|
||||
list.add("reload");
|
||||
list.add("list");
|
||||
list.add("help");
|
||||
list.add("delete");
|
||||
list.add("remove");
|
||||
list.add("heal");
|
||||
list.add("identify");
|
||||
list.add("unidentify");
|
||||
list.add("info");
|
||||
list.add("ability");
|
||||
list.add("allitems");
|
||||
list.add("update");
|
||||
list.add("stations");
|
||||
list.add("giveall");
|
||||
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("ability"))
|
||||
list.addAll(MMOItems.plugin.getAbilities().getAbilityKeys());
|
||||
|
||||
else if (args[0].equalsIgnoreCase("update")) {
|
||||
list.add("list");
|
||||
list.add("apply");
|
||||
list.add("info");
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("stations")) {
|
||||
list.add("list");
|
||||
list.add("open");
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
list.add("recipes");
|
||||
list.add("stations");
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("list")) {
|
||||
list.add("type");
|
||||
list.add("spirit");
|
||||
list.add("lute");
|
||||
list.add("ability");
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("generate"))
|
||||
Bukkit.getOnlinePlayers().forEach(online -> list.add(online.getName()));
|
||||
|
||||
else if (args[0].equalsIgnoreCase("browse") || args[0].equalsIgnoreCase("itemlist") || args[0].equalsIgnoreCase("drop")
|
||||
|| args[0].equalsIgnoreCase("create") || args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("remove")
|
||||
|| args[0].equalsIgnoreCase("edit") || args[0].equalsIgnoreCase("copy") || args[0].equalsIgnoreCase("giveall"))
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll())
|
||||
list.add(type.getId());
|
||||
|
||||
else if (Type.isValid(args[0]))
|
||||
Type.get(args[0]).getConfigFile().getConfig().getKeys(false).forEach(key -> list.add(key.toUpperCase()));
|
||||
|
||||
} else if (args.length == 3) {
|
||||
if (args[0].equalsIgnoreCase("ability") || Type.isValid(args[0]))
|
||||
Bukkit.getOnlinePlayers().forEach(online -> list.add(online.getName()));
|
||||
|
||||
else if (args[0].equalsIgnoreCase("update") && (args[1].equalsIgnoreCase("apply") || args[1].equalsIgnoreCase("info")))
|
||||
MMOItems.plugin.getUpdates().getAll().forEach(update -> list.add("" + update.getId()));
|
||||
|
||||
else if (args[0].equalsIgnoreCase("stations") && args[1].equalsIgnoreCase("open"))
|
||||
MMOItems.plugin.getCrafting().getAll().forEach(station -> list.add(station.getId()));
|
||||
|
||||
else if (args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("edit")
|
||||
|| args[0].equalsIgnoreCase("copy") || args[0].equalsIgnoreCase("drop") || args[0].equalsIgnoreCase("giveall"))
|
||||
if (Type.isValid(args[1]))
|
||||
MMOItems.plugin.getTemplates().getTemplates(Type.get(args[1])).forEach(template -> list.add(template.getId()));
|
||||
|
||||
} else if (args[0].equals("drop")) {
|
||||
if (args.length == 4)
|
||||
Bukkit.getWorlds().forEach(world -> list.add(world.getName()));
|
||||
|
||||
if (args.length == 5)
|
||||
list.add("" + (sender instanceof Player ? (int) ((Player) sender).getLocation().getX() : 0));
|
||||
|
||||
if (args.length == 6)
|
||||
list.add("" + (sender instanceof Player ? (int) ((Player) sender).getLocation().getY() : 0));
|
||||
|
||||
if (args.length == 7)
|
||||
list.add("" + (sender instanceof Player ? (int) ((Player) sender).getLocation().getZ() : 0));
|
||||
|
||||
if (args.length == 8 || args.length == 10)
|
||||
for (int j = 0; j <= 100; j += 10)
|
||||
list.add("" + j);
|
||||
|
||||
if (args.length == 9)
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int k = j; k < 4; k++)
|
||||
list.add(j + "-" + k);
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("stations") && args[1].equalsIgnoreCase("open")) {
|
||||
Bukkit.getOnlinePlayers().forEach(online -> list.add(online.getName()));
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("ability")) {
|
||||
String path = args[1].toUpperCase().replace("-", "_");
|
||||
if (MMOItems.plugin.getAbilities().hasAbility(path)) {
|
||||
Ability ability = MMOItems.plugin.getAbilities().getAbility(path);
|
||||
if (args.length % 2 == 0)
|
||||
list.addAll(ability.getModifiers());
|
||||
else
|
||||
for (int j = 0; j < 10; j++)
|
||||
list.add("" + j);
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("giveall")) {
|
||||
if (args.length == 4)
|
||||
for (String str : new String[] { "1", "16", "64", "1-5", "1-10", "4-16" })
|
||||
list.add(str);
|
||||
|
||||
if (args.length == 5)
|
||||
for (int j : new int[] { 0, 10, 25, 50, 75, 100 })
|
||||
list.add("" + j);
|
||||
} else if (Type.isValid(args[0])) {
|
||||
if (args.length == 4)
|
||||
for (String str : new String[] { "1", "16", "64", "1-5", "1-10", "4-16" })
|
||||
list.add(str);
|
||||
|
||||
if (args.length == 5 || args.length == 6)
|
||||
for (int j : new int[] { 0, 10, 25, 50, 75, 100 })
|
||||
list.add("" + j);
|
||||
}
|
||||
|
||||
if (args.length > 2 && args[0].equalsIgnoreCase("generate")) {
|
||||
list.add("-matchlevel");
|
||||
list.add("-matchclass");
|
||||
list.add("-level:");
|
||||
list.add("-class:");
|
||||
list.add("-type:");
|
||||
list.add("-id:");
|
||||
list.add("-tier:");
|
||||
list.add("-gimme");
|
||||
}
|
||||
|
||||
return args[args.length - 1].isEmpty() ? list
|
||||
: list.stream().filter(string -> string.toLowerCase().startsWith(args[args.length - 1].toLowerCase())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ability.Ability;
|
||||
import net.Indyuce.mmoitems.api.ability.Ability.CastingMode;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class AbilityCommandTreeNode extends CommandTreeNode {
|
||||
public AbilityCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "ability");
|
||||
|
||||
addParameter(new Parameter("<ability>",
|
||||
(explorer, list) -> MMOItems.plugin.getAbilities().getAll().forEach(ability -> list.add(ability.getID()))));
|
||||
addParameter(Parameter.PLAYER_OPTIONAL);
|
||||
|
||||
// three modifiers but more can be used
|
||||
for (int j = 0; j < 3; j++) {
|
||||
addParameter(new Parameter("<modifier>", (explorer, list) -> {
|
||||
try {
|
||||
Ability ability = MMOItems.plugin.getAbilities().getAbility(explorer.getArguments()[1].toUpperCase().replace("-", "_"));
|
||||
list.addAll(ability.getModifiers());
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}));
|
||||
addParameter(new Parameter("<value>", (explorer, list) -> list.add("0")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 2)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (args.length < 3 && !(sender instanceof Player)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Please specify a player to use this command.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
// target
|
||||
Player target = args.length > 2 ? Bukkit.getPlayer(args[2]) : (Player) sender;
|
||||
if (target == null) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Couldn't find player called " + args[2] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
// ability
|
||||
String key = args[1].toUpperCase().replace("-", "_");
|
||||
if (!MMOItems.plugin.getAbilities().hasAbility(key)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Couldn't find ability " + key + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
// modifiers
|
||||
AbilityData ability = new AbilityData(MMOItems.plugin.getAbilities().getAbility(key), CastingMode.RIGHT_CLICK);
|
||||
for (int j = 3; j < args.length - 1; j += 2) {
|
||||
String name = args[j];
|
||||
String value = args[j + 1];
|
||||
|
||||
try {
|
||||
ability.setModifier(name, Double.parseDouble(value));
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Wrong format: {" + name + " " + value + "}");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerData.get(target).cast(ability);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class AllItemsCommandTreeNode extends CommandTreeNode {
|
||||
public AllItemsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "allitems");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
|
||||
sender.sendMessage(ChatColor.GREEN + "List of all MMOItems:");
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll()) {
|
||||
FileConfiguration config = type.getConfigFile().getConfig();
|
||||
for (String s : config.getKeys(false))
|
||||
sender.sendMessage("* " + ChatColor.GREEN + s
|
||||
+ (config.getConfigurationSection(s).contains("name")
|
||||
? " " + ChatColor.WHITE + "(" + MMOLib.plugin.parseColors(config.getString(s + ".name")) + ChatColor.WHITE + ")"
|
||||
: ""));
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.gui.ItemBrowser;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class BrowseCommandTreeNode extends CommandTreeNode {
|
||||
public BrowseCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "browse");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
new ItemBrowser((Player) sender).open();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Please specify a valid item type.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
new ItemBrowser((Player) sender, Type.get(args[1])).open();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class CopyCommandTreeNode extends CommandTreeNode {
|
||||
public CopyCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "copy");
|
||||
|
||||
addParameter(MMOItemsCommandTreeRoot.TYPE);
|
||||
addParameter(MMOItemsCommandTreeRoot.ID_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Type " + ChatColor.GREEN + "/mi list type " + ChatColor.GRAY
|
||||
+ "to see all the available item types.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1]);
|
||||
ConfigFile config = type.getConfigFile();
|
||||
String id1 = args[2].toUpperCase().replace("-", "_");
|
||||
if (!config.getConfig().contains(id1)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item called " + id1 + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
String id2 = args[3].toUpperCase();
|
||||
if (config.getConfig().contains(id2)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is already an item called " + id2 + "!");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
config.getConfig().set(id2, config.getConfig().getConfigurationSection(id1));
|
||||
config.save();
|
||||
if (sender instanceof Player)
|
||||
new ItemEdition((Player) sender, MMOItems.plugin.getTemplates().getTemplate(type, id2)).open();
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GREEN + "You successfully copied " + id1 + " to " + id2 + "!");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class CreateCommandTreeNode extends CommandTreeNode {
|
||||
public CreateCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "create");
|
||||
|
||||
addParameter(MMOItemsCommandTreeRoot.TYPE);
|
||||
addParameter(new Parameter("<id>", (explorer, list) -> list.add("ITEM_ID")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 3)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type" + ChatColor.RED
|
||||
+ " to see all the available item types.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1]);
|
||||
String name = args[2].toUpperCase().replace("-", "_");
|
||||
ConfigFile config = type.getConfigFile();
|
||||
if (config.getConfig().contains(name)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is already an item called " + name + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
config.getConfig().set(name + ".base.material", type.getItem().getType().name());
|
||||
config.save();
|
||||
MMOItems.plugin.getTemplates().requestTemplateUpdate(type, name);
|
||||
|
||||
if (sender instanceof Player)
|
||||
new ItemEdition((Player) sender, MMOItems.plugin.getTemplates().getTemplate(type, name)).open();
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GREEN + "You successfully created " + name + "!");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class DeleteCommandTreeNode extends CommandTreeNode {
|
||||
public DeleteCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "delete");
|
||||
|
||||
addParameter(MMOItemsCommandTreeRoot.TYPE);
|
||||
addParameter(MMOItemsCommandTreeRoot.ID_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 3)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type" + ChatColor.RED
|
||||
+ " to see all the available item types.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1]);
|
||||
String id = args[2].toUpperCase().replace("-", "_");
|
||||
if (!MMOItems.plugin.getTemplates().hasTemplate(type, id)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item called " + id + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
MMOItems.plugin.getTemplates().deleteTemplate(type, id);
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GREEN + "You successfully deleted " + id + ".");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class DropCommandTreeNode extends CommandTreeNode {
|
||||
public DropCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "drop");
|
||||
|
||||
addParameter(MMOItemsCommandTreeRoot.TYPE);
|
||||
addParameter(MMOItemsCommandTreeRoot.ID_2);
|
||||
addParameter(new Parameter("<world>", (explore, list) -> Bukkit.getWorlds().forEach(world -> list.add(world.getName()))));
|
||||
addParameter(new Parameter("<x>", (explore, list) -> list.add("<x>")));
|
||||
addParameter(new Parameter("<y>", (explore, list) -> list.add("<y>")));
|
||||
addParameter(new Parameter("<z>", (explore, list) -> list.add("<z>")));
|
||||
addParameter(new Parameter("<drop-chance>", (explore, list) -> list.add("<drop-chance>")));
|
||||
addParameter(new Parameter("<min-max>", (explore, list) -> list.add("1-3")));
|
||||
addParameter(new Parameter("<unidentify-chance>", (explore, list) -> list.add("<unidentify-chance>")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length != 10)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type " + ChatColor.RED
|
||||
+ "to see all the available item types.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1].toUpperCase());
|
||||
String name = args[2].toUpperCase().replace("-", "_");
|
||||
FileConfiguration config = type.getConfigFile().getConfig();
|
||||
if (!config.contains(name)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item called " + name + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
World world = Bukkit.getWorld(args[3]);
|
||||
if (world == null) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Couldn't find the world called " + args[3] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
double x, y, z, dropChance, unidentifiedChance;
|
||||
int min, max;
|
||||
|
||||
try {
|
||||
x = Double.parseDouble(args[4]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + args[4] + " is not a valid number.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
y = Double.parseDouble(args[5]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + args[5] + " is not a valid number.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
z = Double.parseDouble(args[6]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + args[6] + " is not a valid number.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
dropChance = Double.parseDouble(args[7]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + args[7] + " is not a valid number.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
unidentifiedChance = Double.parseDouble(args[9]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + args[9] + " is not a valid number.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
String[] splitAmount = args[8].split("\\-");
|
||||
if (splitAmount.length != 2) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "The drop quantity format is incorrect.");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Format: [min]-[max]");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
min = Integer.parseInt(splitAmount[0]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + splitAmount[0] + " is not a valid number.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
max = Integer.parseInt(splitAmount[1]);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + splitAmount[1] + " is not a valid number.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
ItemStack item = new MMOItemDropItem(type, name, dropChance / 100, unidentifiedChance / 100, min, max).getItem(null);
|
||||
if (item == null || item.getType() == Material.AIR) {
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + ChatColor.RED + "An error occured while attempting to generate the item called " + name + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "See console for more information!");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
world.dropItem(new Location(world, x, y, z), item);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class EditCommandTreeNode extends CommandTreeNode {
|
||||
public EditCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "edit");
|
||||
|
||||
addParameter(MMOItemsCommandTreeRoot.TYPE);
|
||||
addParameter(MMOItemsCommandTreeRoot.ID_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 3)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Type " + ChatColor.GREEN + "/mi list type" + ChatColor.RED
|
||||
+ " to see all the available item types.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1]);
|
||||
String id = args[2].toUpperCase().replace("-", "_");
|
||||
if (!MMOItems.plugin.getTemplates().hasTemplate(type, id)) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Could not find a template called '" + id + "'.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
new ItemEdition((Player) sender, MMOItems.plugin.getTemplates().getTemplate(type, id)).open();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.Indyuce.mmoitems.command;
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
@ -0,0 +1,81 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ItemTier;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.template.loot.ClassFilter;
|
||||
import net.Indyuce.mmoitems.api.item.template.loot.LootBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.template.loot.TypeFilter;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.mmogroup.mmolib.api.util.SmartGive;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class GenerateCommandTreeNode extends CommandTreeNode {
|
||||
private static final Random random = new Random();
|
||||
|
||||
public GenerateCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "generate");
|
||||
|
||||
addParameter(Parameter.PLAYER);
|
||||
addParameter(new Parameter("(extra-args)", (explorer, list) -> list
|
||||
.addAll(Arrays.asList("-matchlevel", "-matchclass", "-level:", "-class:", "-type:", "-id:", "-tier:", "-gimme"))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
try {
|
||||
final Player target = Bukkit.getPlayer(args[1]);
|
||||
Validate.notNull(target, "Could not find player called " + args[1] + ".");
|
||||
|
||||
GenerateCommandHandler handler = new GenerateCommandHandler(args);
|
||||
|
||||
final Player give = handler.hasArgument("gimme") || handler.hasArgument("giveme") ? (sender instanceof Player ? (Player) sender : null)
|
||||
: target;
|
||||
Validate.notNull(give, "You cannot use -gimme");
|
||||
|
||||
RPGPlayer rpgPlayer = PlayerData.get(target).getRPG();
|
||||
final int itemLevel = handler.hasArgument("level") ? Integer.parseInt(handler.getValue("level"))
|
||||
: (handler.hasArgument("matchlevel") ? MMOItems.plugin.getTemplates().rollLevel(rpgPlayer.getLevel()) : 1 + random.nextInt(100));
|
||||
final ItemTier itemTier = handler.hasArgument("tier")
|
||||
? MMOItems.plugin.getTiers().getOrThrow(handler.getValue("tier").toUpperCase().replace("-", "_"))
|
||||
: MMOItems.plugin.getTemplates().rollTier();
|
||||
|
||||
LootBuilder builder = new LootBuilder(itemLevel, itemTier);
|
||||
if (handler.hasArgument("matchclass"))
|
||||
builder.applyFilter(new ClassFilter(rpgPlayer));
|
||||
if (handler.hasArgument("class"))
|
||||
builder.applyFilter(new ClassFilter(handler.getValue("class").replace("-", " ").replace("_", " ")));
|
||||
if (handler.hasArgument("type")) {
|
||||
String format = handler.getValue("type");
|
||||
Validate.isTrue(Type.isValid(format), "Could not find type with ID '" + format + "'");
|
||||
builder.applyFilter(new TypeFilter(Type.get(format)));
|
||||
}
|
||||
|
||||
MMOItem mmoitem = builder.rollLoot();
|
||||
Validate.notNull(mmoitem, "No item matched your criterias.");
|
||||
|
||||
ItemStack item = mmoitem.newBuilder().build();
|
||||
Validate.isTrue(item != null && item.getType() != Material.AIR, "Could not generate item with ID '" + mmoitem.getId() + "'");
|
||||
new SmartGive(give).give(item);
|
||||
return CommandResult.SUCCESS;
|
||||
|
||||
} catch (IllegalArgumentException exception) {
|
||||
sender.sendMessage(ChatColor.RED + exception.getMessage());
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
|
||||
import net.Indyuce.mmoitems.api.util.RandomAmount;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.mmogroup.mmolib.api.util.SmartGive;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class GiveAllCommandTreeNode extends CommandTreeNode {
|
||||
public GiveAllCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "giveall");
|
||||
|
||||
addParameter(MMOItemsCommandTreeRoot.TYPE);
|
||||
addParameter(MMOItemsCommandTreeRoot.ID_2);
|
||||
addParameter(new Parameter("<min-max>", (explore, list) -> list.add("1-3")));
|
||||
addParameter(new Parameter("<unidentify-chance>", (explore, list) -> list.add("<unidentify-chance>")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
try {
|
||||
Validate.isTrue(args.length > 4, "Usage: /mi giveall <type> <item-id> <min-max> <unidentified-chance>");
|
||||
|
||||
// item
|
||||
Type type = MMOItems.plugin.getTypes().getOrThrow(args[1]);
|
||||
ItemStack item = new MMOItemDropItem(type, args[2], 1, Double.parseDouble(args[4]) / 100, new RandomAmount(args[3])).getItem(null);
|
||||
Validate.isTrue(item != null && item.getType() != Material.AIR, "Couldn't find/generate the item called '" + args[1].toUpperCase()
|
||||
+ "'. Check your console for potential item generation issues.");
|
||||
|
||||
for (Player target : Bukkit.getOnlinePlayers())
|
||||
new SmartGive(target).give(item);
|
||||
return CommandResult.SUCCESS;
|
||||
|
||||
} catch (IllegalArgumentException exception) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + exception.getMessage());
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.util.RandomAmount;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.mmogroup.mmolib.api.util.SmartGive;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class GiveCommandTreeNode extends CommandTreeNode {
|
||||
public GiveCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "give");
|
||||
|
||||
addParameter(MMOItemsCommandTreeRoot.TYPE);
|
||||
addParameter(MMOItemsCommandTreeRoot.ID_2);
|
||||
addParameter(Parameter.PLAYER_OPTIONAL);
|
||||
addParameter(new Parameter("(min-max)", (explore, list) -> list.add("1-3")));
|
||||
addParameter(new Parameter("(unidentify-chance)", (explore, list) -> list.add("0")));
|
||||
addParameter(new Parameter("(drop-chance)", (explore, list) -> list.add("1")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 3)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
try {
|
||||
Validate.isTrue(args.length > 3 || sender instanceof Player, "Please specify a player.");
|
||||
|
||||
// target
|
||||
Player target = args.length > 3 ? Bukkit.getPlayer(args[3]) : (Player) sender;
|
||||
Validate.notNull(target, "Could not find player called '" + args[args.length > 3 ? 3 : 2] + "'.");
|
||||
|
||||
// item
|
||||
Type type = MMOItems.plugin.getTypes().getOrThrow(args[1].toUpperCase().replace("-", "_"));
|
||||
MMOItemDropItem dropItem = new MMOItemDropItem(type, args[2].toUpperCase(), args.length > 6 ? Double.parseDouble(args[6]) / 100 : 1,
|
||||
args.length > 5 ? Double.parseDouble(args[5]) / 100 : 0, args.length > 4 ? new RandomAmount(args[4]) : new RandomAmount(1, 1));
|
||||
if (!dropItem.rollDrop())
|
||||
return CommandResult.SUCCESS;
|
||||
|
||||
ItemStack item = dropItem.getItem(PlayerData.get(target));
|
||||
Validate.isTrue(item != null && item.getType() != Material.AIR, "Couldn't find/generate the item called '" + args[2].toUpperCase()
|
||||
+ "'. Check your console for potential item generation issues.");
|
||||
|
||||
// message
|
||||
if (!sender.equals(target))
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.YELLOW + "Successfully gave " + ChatColor.GOLD
|
||||
+ MMOUtils.getDisplayName(item) + (item.getAmount() > 1 ? " x" + item.getAmount() : "") + ChatColor.YELLOW + " to "
|
||||
+ ChatColor.GOLD + target.getName() + ChatColor.YELLOW + ".");
|
||||
Message.RECEIVED_ITEM.format(ChatColor.YELLOW, "#item#", MMOUtils.getDisplayName(item), "#amount#",
|
||||
(item.getAmount() > 1 ? " x" + item.getAmount() : "")).send(target);
|
||||
|
||||
// item
|
||||
new SmartGive(target).give(item);
|
||||
return CommandResult.SUCCESS;
|
||||
|
||||
} catch (IllegalArgumentException exception) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + exception.getMessage());
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.command.PluginHelp;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class HelpCommandTreeNode extends CommandTreeNode {
|
||||
public HelpCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "help");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 2) {
|
||||
new PluginHelp(sender).open(1);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
try {
|
||||
new PluginHelp(sender).open(Integer.parseInt(args[1]));
|
||||
return CommandResult.SUCCESS;
|
||||
|
||||
} catch (NumberFormatException exception) {
|
||||
sender.sendMessage(ChatColor.RED + args[1] + " is not a valid number.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.item.util.identify.IdentifiedItem;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class IdentifyCommandTreeNode extends CommandTreeNode {
|
||||
public IdentifyCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "identify");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
NBTItem item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand());
|
||||
String tag = item.getString("MMOITEMS_UNIDENTIFIED_ITEM");
|
||||
if (tag.equals("")) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "The item you are holding is already identified.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
final int amount = player.getInventory().getItemInMainHand().getAmount();
|
||||
ItemStack identifiedItem = new IdentifiedItem(item).identify();
|
||||
identifiedItem.setAmount(amount);
|
||||
|
||||
player.getInventory().setItemInMainHand(identifiedItem);
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully identified the item you are holding.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class ItemListCommandTreeNode extends CommandTreeNode {
|
||||
public ItemListCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "itemlist");
|
||||
|
||||
addParameter(MMOItemsCommandTreeRoot.TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 2)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (!Type.isValid(args[1])) {
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + ChatColor.RED + "There is no item type called " + args[1].toUpperCase().replace("-", "_"));
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Type " + ChatColor.GREEN + "/mi list type " + ChatColor.GRAY
|
||||
+ "to see all the available item types.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Type type = Type.get(args[1]);
|
||||
sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
|
||||
sender.sendMessage(ChatColor.GREEN + "List of all items in " + type.getId().toLowerCase() + ".yml:");
|
||||
FileConfiguration config = type.getConfigFile().getConfig();
|
||||
|
||||
if (sender instanceof Player)
|
||||
for (String s : config.getKeys(false)) {
|
||||
String nameFormat = config.getConfigurationSection(s).contains("name")
|
||||
? " " + ChatColor.WHITE + "(" + MMOLib.plugin.parseColors(config.getString(s + ".name")) + ChatColor.WHITE + ")"
|
||||
: "";
|
||||
MMOLib.plugin.getVersion().getWrapper().sendJson((Player) sender,
|
||||
"{\"text\":\"* " + ChatColor.GREEN + s + nameFormat + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/mi edit "
|
||||
+ type.getId() + " " + s + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to edit "
|
||||
+ (nameFormat.equals("") ? s : MMOLib.plugin.parseColors(config.getString(s + ".name"))) + ChatColor.WHITE
|
||||
+ ".\",\"color\":\"white\"}}}");
|
||||
}
|
||||
|
||||
else
|
||||
for (String s : config.getKeys(false))
|
||||
sender.sendMessage("* " + ChatColor.GREEN + s
|
||||
+ (config.getConfigurationSection(s).contains("name")
|
||||
? " " + ChatColor.WHITE + "(" + MMOLib.plugin.parseColors(config.getString(s + ".name")) + ChatColor.WHITE + ")"
|
||||
: ""));
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class ReloadCommandTreeNode extends CommandTreeNode {
|
||||
public ReloadCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "reload");
|
||||
|
||||
addChild(new StationsCommandTreeNode(this));
|
||||
addChild(new RecipesCommandTreeNode(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
MMOItems.plugin.getLanguage().reload();
|
||||
MMOItems.plugin.getDropTables().reload();
|
||||
MMOItems.plugin.getTypes().reload();
|
||||
MMOItems.plugin.getTiers().reload();
|
||||
MMOItems.plugin.getSets().reload();
|
||||
MMOItems.plugin.getUpgrades().reload();
|
||||
MMOItems.plugin.getTemplates().reload();
|
||||
MMOItems.plugin.getWorldGen().reload();
|
||||
MMOItems.plugin.getCustomBlocks().reload();
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + MMOItems.plugin.getName() + " " + MMOItems.plugin.getDescription().getVersion() + " reloaded.");
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + "- " + ChatColor.RED + MMOItems.plugin.getTypes().getAll().size() + ChatColor.GRAY + " Item Types");
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + "- " + ChatColor.RED + MMOItems.plugin.getTiers().getAll().size() + ChatColor.GRAY + " Item Tiers");
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + "- " + ChatColor.RED + MMOItems.plugin.getSets().getAll().size() + ChatColor.GRAY + " Item Sets");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
public class RecipesCommandTreeNode extends CommandTreeNode {
|
||||
public RecipesCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "recipes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
MMOItems.plugin.getRecipes().reloadRecipes();
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully reloaded recipes.");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "- " + ChatColor.RED
|
||||
+ (MMOItems.plugin.getRecipes().getLoadedRecipes().size() + MMOItems.plugin.getRecipes().getCustomRecipes().size())
|
||||
+ ChatColor.GRAY + " Recipes");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
public class StationsCommandTreeNode extends CommandTreeNode {
|
||||
public StationsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "stations");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
MMOItems.plugin.getCrafting().reload();
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully reloaded the crafting stations..");
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "- " + ChatColor.RED + MMOItems.plugin.getCrafting().getAll().size() + ChatColor.GRAY
|
||||
+ " Crafting Stations");
|
||||
sender.sendMessage(
|
||||
MMOItems.plugin.getPrefix() + "- " + ChatColor.RED + MMOItems.plugin.getCrafting().countRecipes() + ChatColor.GRAY + " Recipes");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class UnidentifyCommandTreeNode extends CommandTreeNode {
|
||||
public UnidentifyCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "unidentify");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
NBTItem item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand());
|
||||
if (item.getType() == null) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Couldn't unidentify the item you are holding.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
if (item.getBoolean("MMOITEMS_UNIDENTIFIED")) {
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "The item you are holding is already unidentified.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
player.getInventory().setItemInMainHand(item.getType().getUnidentifiedTemplate().newBuilder(item).build());
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully unidentified the item you are holding.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class CheckAttributeCommandTreeNode extends CommandTreeNode {
|
||||
public CheckAttributeCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "checkattribute");
|
||||
|
||||
addParameter(
|
||||
new Parameter("<attribute>", (explorer, list) -> Arrays.asList(Attribute.values()).forEach(attribute -> list.add(attribute.name()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
if (args.length < 3)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
Player player = (Player) sender;
|
||||
try {
|
||||
AttributeInstance att = player.getAttribute(Attribute.valueOf(args[2].toUpperCase().replace("-", "_")));
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
|
||||
sender.sendMessage(ChatColor.AQUA + "Default Value = " + ChatColor.RESET + att.getDefaultValue());
|
||||
sender.sendMessage(ChatColor.AQUA + "Base Value = " + ChatColor.RESET + att.getBaseValue());
|
||||
sender.sendMessage(ChatColor.AQUA + "Value = " + ChatColor.RESET + att.getValue());
|
||||
for (AttributeModifier mod : att.getModifiers())
|
||||
sender.sendMessage(
|
||||
mod.getName() + " " + new DecimalFormat("0.####").format(mod.getAmount()) + " " + mod.getOperation() + " " + mod.getSlot());
|
||||
} catch (IllegalArgumentException exception) {
|
||||
player.sendMessage("Couldn't find attribute.");
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class CheckStatCommandTreeNode extends CommandTreeNode {
|
||||
public CheckStatCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "checkstat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 2)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
ItemStat stat = MMOItems.plugin.getStats().get(args[1].toUpperCase().replace("-", "_"));
|
||||
if (stat == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Couldn't find the stat called " + args[1].toUpperCase().replace("-", "_") + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
player.sendMessage("Found stat with ID " + stat.getId() + " = " + PlayerData.get((Player) sender).getStats().getStat(stat));
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class CheckTagCommandTreeNode extends CommandTreeNode {
|
||||
public CheckTagCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "checktag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 3)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
NBTItem item = MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand());
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
|
||||
player.sendMessage(ChatColor.AQUA + "Boolean = " + ChatColor.RESET + item.getBoolean("MMOITEMS_" + args[2].toUpperCase().replace("-", "_")));
|
||||
player.sendMessage(ChatColor.AQUA + "Double = " + ChatColor.RESET + item.getDouble("MMOITEMS_" + args[2].toUpperCase().replace("-", "_")));
|
||||
player.sendMessage(ChatColor.AQUA + "String = " + ChatColor.RESET + item.getString("MMOITEMS_" + args[2].toUpperCase().replace("-", "_")));
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class CheckTagsCommandTreeNode extends CommandTreeNode {
|
||||
public CheckTagsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "checktags");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
|
||||
for (String s : MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand()).getTags())
|
||||
player.sendMessage("- " + s);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class DebugCommandTreeNode extends CommandTreeNode {
|
||||
public DebugCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "debug");
|
||||
|
||||
addChild(new CheckStatCommandTreeNode(this));
|
||||
addChild(new CheckAttributeCommandTreeNode(this));
|
||||
addChild(new CheckTagCommandTreeNode(this));
|
||||
addChild(new SetTagCommandTreeNode(this));
|
||||
addChild(new CheckTagsCommandTreeNode(this));
|
||||
addChild(new InfoCommandTreeNode(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
return CommandResult.THROW_USAGE;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class HealCommandTreeNode extends CommandTreeNode {
|
||||
public HealCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "heal");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
player.setFoodLevel(20);
|
||||
player.setFireTicks(0);
|
||||
player.setSaturation(12);
|
||||
for (PotionEffectType pe : new PotionEffectType[] { PotionEffectType.POISON, PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION,
|
||||
PotionEffectType.HUNGER, PotionEffectType.WEAKNESS, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING })
|
||||
player.removePotionEffect(pe);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class InfoCommandTreeNode extends CommandTreeNode {
|
||||
public InfoCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "info");
|
||||
|
||||
addParameter(Parameter.PLAYER_OPTIONAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
Player player = args.length > 2 ? Bukkit.getPlayer(args[2]) : (sender instanceof Player ? (Player) sender : null);
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Couldn't find target player.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
RPGPlayer rpg = PlayerData.get(player).getRPG();
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " Player Information "
|
||||
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
sender.sendMessage(ChatColor.WHITE + "Information about " + ChatColor.LIGHT_PURPLE + player.getName());
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Class: " + ChatColor.LIGHT_PURPLE + rpg.getClassName());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Level: " + ChatColor.LIGHT_PURPLE + rpg.getLevel());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Mana: " + ChatColor.LIGHT_PURPLE + rpg.getMana());
|
||||
sender.sendMessage(ChatColor.WHITE + "Player Stamina: " + ChatColor.LIGHT_PURPLE + rpg.getStamina());
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.ItemTag;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class SetTagCommandTreeNode extends CommandTreeNode {
|
||||
public SetTagCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "settag");
|
||||
|
||||
addParameter(new Parameter("<path>", (explorer, list) -> list.add("TagPath")));
|
||||
addParameter(new Parameter("<value>", (explorer, list) -> list.add("TagValue")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 4)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is only for players.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
Player player = (Player) sender;
|
||||
player.getInventory().setItemInMainHand(MMOLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand())
|
||||
.addTag(new ItemTag(args[2].toUpperCase().replace("-", "_"), args[3].replace("%%", " "))).toItem());
|
||||
player.sendMessage("Successfully set tag.");
|
||||
return CommandResult.SUCCESS;
|
||||
|
||||
} catch (Exception exception) {
|
||||
sender.sendMessage("Couldn't set tag.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.list;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ability.Ability;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class AbilityCommandTreeNode extends CommandTreeNode {
|
||||
public AbilityCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "ability");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " Abilities "
|
||||
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
sender.sendMessage(ChatColor.WHITE + "Here are all the abilities you can bind to items.");
|
||||
sender.sendMessage(ChatColor.WHITE + "The values inside brackets are " + ChatColor.UNDERLINE + "modifiers" + ChatColor.WHITE
|
||||
+ " which allow you to change the ability values (cooldown, damage...)");
|
||||
for (Ability a : MMOItems.plugin.getAbilities().getAll()) {
|
||||
String modFormat = ChatColor.GRAY + String.join(ChatColor.WHITE + ", " + ChatColor.GRAY, a.getModifiers());
|
||||
modFormat = ChatColor.WHITE + "(" + modFormat + ChatColor.WHITE + ")";
|
||||
sender.sendMessage("* " + ChatColor.LIGHT_PURPLE + a.getName() + " " + modFormat);
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.list;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class ListCommandTreeNode extends CommandTreeNode {
|
||||
public ListCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "list");
|
||||
|
||||
addChild(new AbilityCommandTreeNode(this));
|
||||
addChild(new LuteAttackCommandTreeNode(this));
|
||||
addChild(new StaffSpiritCommandTreeNode(this));
|
||||
addChild(new TypeCommandTreeNode(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " MMOItems: lists "
|
||||
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi list type " + ChatColor.WHITE + "shows all item types (sword, axe...)");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi list spirit " + ChatColor.WHITE + "shows all available staff spirits");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi list lute " + ChatColor.WHITE + "shows all available lute attack effects");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "/mi list ability " + ChatColor.WHITE + "shows all available abilities");
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("Spigot Javadoc Links:");
|
||||
MMOLib.plugin.getVersion().getWrapper().sendJson((Player) sender, "[{\"text\":\"" + ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Materials/Blocks\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}},{\"text\":\" " + ChatColor.LIGHT_PURPLE + "- \"},{\"text\":\""
|
||||
+ ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Potion Effects\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}},{\"text\":\" " + ChatColor.LIGHT_PURPLE + "- \"},{\"text\":\""
|
||||
+ ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Sounds\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}}]");
|
||||
MMOLib.plugin.getVersion().getWrapper().sendJson((Player) sender, "[{\"text\":\"" + ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Entities/Mobs\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/EntityType.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}},{\"text\":\" " + ChatColor.LIGHT_PURPLE + "- \"},{\"text\":\""
|
||||
+ ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Enchantments\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/enchantments/Enchantment.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}},{\"text\":\" " + ChatColor.LIGHT_PURPLE + "- \"},{\"text\":\""
|
||||
+ ChatColor.UNDERLINE + ChatColor.GREEN
|
||||
+ "Particles\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particles.html\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\""
|
||||
+ ChatColor.GREEN + "Click to open webpage.\"}]}}}]");
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.list;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.stat.LuteAttackEffectStat.LuteAttackEffect;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class LuteAttackCommandTreeNode extends CommandTreeNode {
|
||||
public LuteAttackCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "lute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE
|
||||
+ " Lute Attack Effects " + ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
for (LuteAttackEffect lae : LuteAttackEffect.values())
|
||||
sender.sendMessage("* " + ChatColor.LIGHT_PURPLE + lae.getName());
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.list;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class StaffSpiritCommandTreeNode extends CommandTreeNode {
|
||||
public StaffSpiritCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "spirit");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " Staff Spirits "
|
||||
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
for (StaffSpirit ss : StaffSpirit.values()) {
|
||||
String lore = !ss.hasLore() ? " " + ChatColor.WHITE + ">> " + ChatColor.GRAY + "" + ChatColor.ITALIC + ss.getLore() : "";
|
||||
sender.sendMessage("* " + ChatColor.LIGHT_PURPLE + ss.getName() + lore);
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.list;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class TypeCommandTreeNode extends CommandTreeNode {
|
||||
public TypeCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " Item Types "
|
||||
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + ChatColor.LIGHT_PURPLE + " Item Types " + ChatColor.DARK_GRAY + ""
|
||||
+ ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
for (Type type : MMOItems.plugin.getTypes().getAll())
|
||||
sender.sendMessage("* " + ChatColor.LIGHT_PURPLE + type.getName() + " (" + type.getId() + ")");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.stations;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.crafting.CraftingStation;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class ListCommandTreeNode extends CommandTreeNode {
|
||||
public ListCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------[" + ChatColor.LIGHT_PURPLE + " Crafting Stations "
|
||||
+ ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "]-----------------");
|
||||
for (CraftingStation station : MMOItems.plugin.getCrafting().getAll())
|
||||
sender.sendMessage(ChatColor.GRAY + "- " + ChatColor.WHITE + station.getId());
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.stations;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.gui.CraftingStationView;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class OpenCommandTreeNode extends CommandTreeNode {
|
||||
public OpenCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "open");
|
||||
|
||||
addParameter(new Parameter("<station>",
|
||||
(explorer, list) -> MMOItems.plugin.getCrafting().getStations().forEach(station -> list.add(station.getId()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 3)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
if (!MMOItems.plugin.getCrafting().hasStation(args[2])) {
|
||||
sender.sendMessage(ChatColor.RED + "There is no station called " + args[2] + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Player target = args.length > 3 ? Bukkit.getPlayer(args[3]) : (sender instanceof Player ? (Player) sender : null);
|
||||
if (target == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Please specify a valid player.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
new CraftingStationView(target, MMOItems.plugin.getCrafting().getStation(args[2]), 1).open();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.stations;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class StationsCommandTreeNode extends CommandTreeNode {
|
||||
public StationsCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "stations");
|
||||
|
||||
addChild(new OpenCommandTreeNode(this));
|
||||
addChild(new ListCommandTreeNode(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
return CommandResult.THROW_USAGE;
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.update;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.PluginUpdate;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class ApplyCommandTreeNode extends CommandTreeNode {
|
||||
public ApplyCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "apply");
|
||||
|
||||
addParameter(
|
||||
new Parameter("<id>", (explorer, list) -> MMOItems.plugin.getUpdates().getAll().forEach(update -> list.add("" + update.getId()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 3)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
int id;
|
||||
try {
|
||||
id = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException exception) {
|
||||
sender.sendMessage(ChatColor.RED + "Please specify a valid number.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
if (!MMOItems.plugin.getUpdates().has(id)) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find any config update with ID " + id);
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
PluginUpdate update = MMOItems.plugin.getUpdates().get(id);
|
||||
sender.sendMessage(ChatColor.YELLOW + "Applying config update " + id + "...");
|
||||
update.apply(sender);
|
||||
sender.sendMessage(
|
||||
ChatColor.YELLOW + "Config update " + id + " was successfully applied. Check the console for potential update error logs.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.update;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.PluginUpdate;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
import net.mmogroup.mmolib.command.api.Parameter;
|
||||
|
||||
public class InfoCommandTreeNode extends CommandTreeNode {
|
||||
public InfoCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "info");
|
||||
|
||||
addParameter(
|
||||
new Parameter("<id>", (explorer, list) -> MMOItems.plugin.getUpdates().getAll().forEach(update -> list.add("" + update.getId()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
if (args.length < 3)
|
||||
return CommandResult.THROW_USAGE;
|
||||
|
||||
int id;
|
||||
try {
|
||||
id = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException exception) {
|
||||
sender.sendMessage(ChatColor.RED + "Please specify a valid number.");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
if (!MMOItems.plugin.getUpdates().has(id)) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not find any config update with ID " + id);
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
PluginUpdate update = MMOItems.plugin.getUpdates().get(id);
|
||||
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Config Update n" + update.getId());
|
||||
if (update.hasDescription()) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "Description:");
|
||||
for (String line : update.getDescription())
|
||||
sender.sendMessage(ChatColor.GRAY + "- " + ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Use " + ChatColor.GOLD + "/mi update apply " + update.getId() + ChatColor.YELLOW
|
||||
+ " to apply this config update.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.update;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.PluginUpdate;
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class ListCommandTreeNode extends CommandTreeNode {
|
||||
public ListCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Available Config Updates");
|
||||
for (PluginUpdate update : MMOItems.plugin.getUpdates().getAll())
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "- Update " + update.getId());
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.update;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||
|
||||
public class UpdateCommandTreeNode extends CommandTreeNode {
|
||||
public UpdateCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "update");
|
||||
|
||||
addChild(new ListCommandTreeNode(this));
|
||||
addChild(new ApplyCommandTreeNode(this));
|
||||
addChild(new InfoCommandTreeNode(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
return CommandResult.THROW_USAGE;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user