Plugin category: Admin-Tools, General Suggested name: EnchantAll What I want: When you use /enchant all you will get all enchants (highest enchants) on example a diamond sword. The plugin muss not overwrite the Essentials plugin so you can still use /enchant efficiency 3 (example) or /enchant sharpness 2. Ideas for commands: /enchant all Ideas for permissions: EnchantAll.use (use for the /enchant all command) When I'd like it by: Whenever you finish it Additional Info: Can the creator of this plugin release the source code so i can learn from it
No And tag me next time EDIT by Moderator: merged posts, please use the edit button instead of double posting.
MinecraftPlayer8 Here is the source code for it (to get the plugin, compile it with eclipse) : EnchantAll.class : Code:java package me.au2001.EnchantAll; import java.util.logging.Logger; import org.bukkit.ChatColor;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.enchantments.Enchantment;import org.bukkit.entity.Player;import org.bukkit.plugin.PluginDescriptionFile;import org.bukkit.plugin.java.JavaPlugin; public class EnchantAll extends JavaPlugin {public final Logger logger = Logger.getLogger("Minecraft");public static EnchantAll plugin; public void onEnable() {PluginDescriptionFile pdfFile = this.getDescription();this.logger.info("[" + pdfFile.getName() + "] v" + pdfFile.getVersion() + " is enabled!");} public void onDisable() {PluginDescriptionFile pdfFile = this.getDescription();this.logger.info("[" + pdfFile.getName() + "] is disabled!");} public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {if (commandLabel.equalsIgnoreCase("enchantme")) {if (sender instanceof Player) {if (sender.hasPermission("echantme.use")) {if (args.length == 2) {if (Enchantment.getByName(args[0]) != null) {Player player = (Player)sender;int level = Integer.parseInt(args[1].replaceAll("[\\D]", ""));player.getItemInHand().addUnsafeEnchantment(Enchantment.getByName(args[0]), level);sender.sendMessage(ChatColor.GREEN + "This item has successfully been enchanted.");} else {sender.sendMessage(ChatColor.RED + "This enchantment doesn't exists.");}} else {sender.sendMessage(ChatColor.RED + "Wrong number of command parameters.");}} else {sender.sendMessage(ChatColor.RED + "You don't have permissions to execute this command.");}} else {sender.sendMessage("You must be a player to execute this command.");}return true;}return false;}} plugin.yml : Code:text name: EnchantAllmain: me.au2001. EnchantAll. EnchantAllversion: 1.0descirption: >Plugin description!commands:enchantme:description: Enchants an item.permissions:enchantme.use:description: Give access to the /enchantme command.
MinecraftPlayer8 Do you mean the minecraft console of your server? If so, just select and do ctrl+c (or cmd+c on a mac) then paste it here (ctrl+v or cmd+v).
au2001 Here, don't get all complicated; he doesn't know how to compile code. Besides, I can write him a plugin that uses the /enchant command without overwriting Essentials.
Maurdekye He is learning how to code so he could have done it Would you use this? Code:java plugin.getServer().getPluginCommand("enchant").equals(plugin.getCommand("enchant")) ; MinecraftPlayer8 Download link: http://www.shadowcasted.com/#downloads Then it's EnchantAll
au2001 No, it's just broken. Try this one; https://mega.co.nz/#!HU00xAhQ!gQckVPQjER_pnjqF8pnNPNXH3dVdnWn0cS9S3FAiCwA au2001 Nope, sorry. That one was slightly broken as well. Use this one; ought to be the final draft; https://mega.co.nz/#!2QUhBI4Z!uFF0B_HCIvgg4VHVlZWhwveLmwrDGOvZxJJ3xou4FQY Edit: By the way, the permission is 'enchantall.use'. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
MinecraftPlayer8 au2001 By the way, here's the source; Code:java import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.enchantments.Enchantment;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.EventPriority;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerCommandPreprocessEvent;import org.bukkit.inventory.ItemStack;import org.bukkit.plugin.java.JavaPlugin; public class EnchantAll extends JavaPlugin implements Listener { public void onEnable() { Bukkit.getPluginManager().registerEvents(this, this); } @EventHandler(priority = EventPriority.HIGHEST) public void PreCommand(PlayerCommandPreprocessEvent event) { Player sender = event.getPlayer(); if (!event.getPlayer().hasPermission("enchantall.use")) return; String[] commargs = event.getMessage().split(" +"); if (commargs.length < 2) return; if (commargs[0].equalsIgnoreCase("/enchant") && commargs[1].equalsIgnoreCase("all")) { event.setCancelled(true); ItemStack held = sender.getItemInHand(); boolean enchanted = false; for (Enchantment ench : Enchantment.values()) { try { held.addEnchantment(ench, ench.getMaxLevel()); enchanted = true; } catch (Exception ignored) {} } String goodname = held.getType().name().replaceAll("_", " ").toLowerCase(); if (enchanted) sender.sendMessage(ChatColor.AQUA + "Fully enchanted your " + goodname); else sender.sendMessage(ChatColor.GRAY + "You can't enchant " + goodname + "!"); } }}
Maurdekye So, would that work? Code:java package me.au2001.EnchantAll; import java.util.logging.Logger; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.enchantments.Enchantment;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.EventPriority;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerCommandPreprocessEvent;import org.bukkit.plugin.PluginDescriptionFile;import org.bukkit.plugin.java.JavaPlugin; public class EnchantAll extends JavaPlugin implements Listener { public final Logger logger = Logger.getLogger("Minecraft"); public static EnchantAll plugin; public void onEnable() { PluginDescriptionFile pdfFile = this.getDescription(); Bukkit.getPluginManager().registerEvents(this, this); this.logger.info("[" + pdfFile.getName() + "] v" + pdfFile.getVersion() + " is enabled!"); } public void onDisable() { PluginDescriptionFile pdfFile = this.getDescription(); this.logger.info("[" + pdfFile.getName() + "] is disabled!"); } @EventHandler(priority=EventPriority.HIGHEST) public void beforeCommand (PlayerCommandPreprocessEvent event) { Player sender = event.getPlayer(); String[] args = event.getMessage().split(" +"); String commandLabel = args[0]; if (commandLabel.equalsIgnoreCase("/enchant")) { if (sender.hasPermission("echantall.use")) { if (args.length == 2) { if (Enchantment.getByName(args[1]) != null) { Player player = (Player)sender; int level = Integer.parseInt(args[2].replaceAll("[\\D]", "")); player.getItemInHand().addUnsafeEnchantment(Enchantment.getByName(args[0]), level); sender.sendMessage(ChatColor.GREEN + "This item has successfully been enchanted."); } else { sender.sendMessage(ChatColor.RED + "This enchantment doesn't exists."); } } else { sender.sendMessage(ChatColor.RED + "Wrong number of command parameters."); } } else { sender.sendMessage(ChatColor.RED + "You don't have permissions to execute this command."); } event.setCancelled(true); } }}
au2001 The code you posted? I'm fairly sure it would overwrite the default /enchant command on most occasions, which is what you don't want.
MinecraftPlayer8 Why do you want to keep the essentials command? If our plugin does the same thing, it wouldn't change anything. @Murdekye But when I try it, it doesn't do anything! The default command is called and nothing else...
What exactly are you asking for then? A command that gets the item in your hand and enchants it to the highest legit level?