diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index 88522f513..86a7e7b6c 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -22,26 +22,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; -import mineplex.mapparser.command.AdminCommand; -import mineplex.mapparser.command.AuthorCommand; -import mineplex.mapparser.command.BaseCommand; -import mineplex.mapparser.command.CopyCommand; -import mineplex.mapparser.command.CopySchematicsCommand; -import mineplex.mapparser.command.CreateCommand; -import mineplex.mapparser.command.DeleteCommand; -import mineplex.mapparser.command.GameTypeCommand; -import mineplex.mapparser.command.HubCommand; -import mineplex.mapparser.command.ListCommand; -import mineplex.mapparser.command.MapCommand; -import mineplex.mapparser.command.NameCommand; -import mineplex.mapparser.command.ParseCommand200; -import mineplex.mapparser.command.ParseCommand400; -import mineplex.mapparser.command.ParseCommand600; -import mineplex.mapparser.command.RenameCommand; -import mineplex.mapparser.command.SaveCommand; -import mineplex.mapparser.command.SetSpawnCommand; -import mineplex.mapparser.command.SpawnCommand; -import mineplex.mapparser.command.WorldsCommand; +import mineplex.mapparser.command.*; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -120,6 +101,9 @@ public class MapParser extends JavaPlugin implements Listener _commands.add(new CopyCommand(this)); _commands.add(new SpawnCommand(this)); _commands.add(new SetSpawnCommand(this)); + _commands.add(new ItemNameCommand(this)); + _commands.add(new AddLoreCommand(this)); + _commands.add(new ClearLoreCommand(this)); } @Override diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java new file mode 100644 index 000000000..14f5ad669 --- /dev/null +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java @@ -0,0 +1,58 @@ +package mineplex.mapparser.command; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.common.util.F; +import mineplex.mapparser.MapParser; + +public class AddLoreCommand extends BaseCommand +{ + public AddLoreCommand(MapParser plugin) + { + super(plugin, "addlore", "al"); + } + + @Override + public boolean execute(Player player, String alias, String[] args) + { + if (args == null || args.length < 1) + { + message(player, "Invalid Usage: " + F.elem("/" + alias + " ")); + return true; + } + + ItemStack is = player.getItemInHand(); + + if (is == null || is.getType() == Material.AIR) + { + message(player, "You must be holding an item in your hand."); + return true; + } + + ItemMeta im = is.getItemMeta(); + + String line = ""; + for (int i = 0; i < args.length; i++) + { + line += args[i] + " "; + } + line = line.replaceAll("&", "§").trim(); + + List lore = new ArrayList<>(im.getLore()); + lore.add(line); + im.setLore(lore); + is.setItemMeta(im); + + player.setItemInHand(is); + player.updateInventory(); + message(player, "Added lore: " + line); + + return true; + } +} diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ClearLoreCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ClearLoreCommand.java new file mode 100644 index 000000000..d6c6a38d6 --- /dev/null +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ClearLoreCommand.java @@ -0,0 +1,40 @@ +package mineplex.mapparser.command; + +import java.util.ArrayList; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.mapparser.MapParser; + +public class ClearLoreCommand extends BaseCommand +{ + public ClearLoreCommand(MapParser plugin) + { + super(plugin, "clearlore", "cl"); + } + + @Override + public boolean execute(Player player, String alias, String[] args) + { + ItemStack is = player.getItemInHand(); + + if (is == null || is.getType() == Material.AIR) + { + message(player, "You must be holding an item in your hand."); + return true; + } + + ItemMeta im = is.getItemMeta(); + im.setLore(new ArrayList<>()); + is.setItemMeta(im); + + player.setItemInHand(is); + player.updateInventory(); + message(player, "Cleared lore on item!"); + + return true; + } +} diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ItemNameCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ItemNameCommand.java new file mode 100644 index 000000000..95205dd51 --- /dev/null +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ItemNameCommand.java @@ -0,0 +1,52 @@ +package mineplex.mapparser.command; + +import mineplex.core.common.util.F; +import mineplex.mapparser.MapParser; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class ItemNameCommand extends BaseCommand +{ + public ItemNameCommand(MapParser plugin) + { + super(plugin, "itemname", "in"); + } + + @Override + public boolean execute(Player player, String alias, String[] args) + { + if (args == null || args.length < 1) + { + message(player, "Invalid Usage: " + F.elem("/" + alias + " ")); + return true; + } + + ItemStack is = player.getItemInHand(); + + if (is == null || is.getType() == Material.AIR) + { + message(player, "You must be holding an item in your hand."); + return true; + } + + ItemMeta im = is.getItemMeta(); + + String name = ""; + for (int i = 0; i < args.length; i++) + { + name += args[i] + " "; + } + name = name.replaceAll("&", "§").trim(); + + im.setDisplayName(name); + is.setItemMeta(im); + + player.setItemInHand(is); + player.updateInventory(); + message(player, "Set name: " + name); + + return true; + } +}