Plugin name: Gravity Gun What it will do: Add the gravity gun from Half life into Minecraft! When you right click a block with the gun (gun item configurable), it puts that block in to "falling mode" (like sand/gravel). Wherever you look with the block in the gun, it moves to the nearest block that you are looking at (also works in air). Right click again to place the block. Permissions: GravityGun.get: Get the gravity gun GravityGun.use: Use the Gravity Gun Commands: /gravitygun get - get the gravity gun /gravitygun reload - reload the config (config idea below) /gg could be an ailias for /gravitygun Config: Range: How far the blocks go away from the player (to prevent the block from going infinitely up when player looks up) Item: Item ID of the item Lore: For custom lore Line 1: Lore Line 2: Lore Line 3: Lore Line 4: Lore When I would like it by: Whenever it can be made
I could do most of this, the only thing I would have trouble with is the name and lore... I'm not good with metadata.
AndyMcB1 Here you go, Freelix2000 I assume that this one is for you code (Move your mouse to reveal the content) code (open) code (close) Code:java package nl.timdebrouwer.testplugin; import java.util.ArrayList;import java.util.Arrays;import java.util.List;import org.bukkit.Bukkit;import org.bukkit.inventory.ItemStack;import org.bukkit.inventory.meta.ItemMeta; public class LoreAPI{ /*** Adds lore to the ItemStack** @param itemStack* ItemStack to add lore to* @param lore* Lore to add to ItemStack* @return lored ItemStack*/ public ItemStack addLore(final ItemStack itemStack, final String lore) { ItemStack ret = itemStack; List<String> loreList = getLore(ret); loreList.add(lore); return setLore(ret, loreList); } /*** @return all items that the plugin can use*/ /*** Gets the lore of an ItemStack** @param itemStack* ItemStack to get the lore of* @return the lore of an ItemStack*/ public List<String> getLore(final ItemStack itemStack) { ItemStack ret = itemStack; ItemMeta itemMeta; if (ret.hasItemMeta()) { itemMeta = ret.getItemMeta(); } else { itemMeta = Bukkit.getItemFactory().getItemMeta(ret.getType()); } if (itemMeta.hasLore()) return itemMeta.getLore(); return new ArrayList<String>(); } /*** Gets the name of an ItemStack** @param itemStack* ItemStack to get the lore of* @return the lore of an ItemStack*/ public String getName(final ItemStack itemStack) { ItemStack ret = itemStack; ItemMeta itemMeta; if (ret.hasItemMeta()) { itemMeta = ret.getItemMeta(); } else { itemMeta = Bukkit.getItemFactory().getItemMeta(ret.getType()); } if (itemMeta.hasDisplayName()) return itemMeta.getDisplayName(); String unfName = ret.getType().name(); String[] split = unfName.split("_"); String fName = new String(); for (String s : split) { String firstLetter = s.substring(0, 1); String restOfWord = s.substring(1, s.length()); String newName = firstLetter.toUpperCase() + restOfWord.toLowerCase(); fName = fName + newName + " "; } return fName; } /*** Replace a line of lore with another line** @param tool* Tool to replace lore on* @param toReplace* Line of lore to be replaced* @param replaceWith* Line replacing toReplace* @return Tool with new lore*/ public ItemStack replaceLore(final ItemStack tool, final String toReplace, final String replaceWith) { ItemMeta meta = tool.getItemMeta(); List<String> loreList = meta.getLore(); if ((loreList == null) || loreList.isEmpty()) return tool; for (String s : meta.getLore()) if (s.equals(toReplace)) { loreList.remove(s); loreList.add(replaceWith); } meta.setLore(loreList); tool.setItemMeta(meta); return tool; } /*** Sets the lore of an ItemStack** @param itemStack* ItemStack to set lore for* @param lore* Lore to give to the ItemStack* @return lored ItemStack*/ public ItemStack setLore(final ItemStack itemStack, final List<String> lore) { ItemStack ret = itemStack; ItemMeta itemMeta; if (ret.hasItemMeta()) { itemMeta = ret.getItemMeta(); } else { itemMeta = Bukkit.getItemFactory().getItemMeta(ret.getType()); } itemMeta.setLore(lore); ret.setItemMeta(itemMeta); return ret; } /*** Sets the lore of an ItemStack** @param itemStack* ItemStack to set lore for* @param lore* Lore to give to the ItemStack* @return lored ItemStack*/ public ItemStack setLore(final ItemStack itemStack, final String... lore) { ItemStack ret = itemStack; ItemMeta itemMeta; if (ret.hasItemMeta()) { itemMeta = ret.getItemMeta(); } else { itemMeta = Bukkit.getItemFactory().getItemMeta(ret.getType()); } itemMeta.setLore(Arrays.asList(lore)); ret.setItemMeta(itemMeta); return ret; } /*** Sets the name of an ItemStack** @param itemStack* ItemStack to set name for* @param name* Name to give to the ItemStack* @return named ItemStack*/ public ItemStack setName(final ItemStack itemStack, final String name) { ItemStack ret = itemStack; ItemMeta itemMeta; if (ret.hasItemMeta()) { itemMeta = ret.getItemMeta(); } else { itemMeta = Bukkit.getItemFactory().getItemMeta(ret.getType()); } itemMeta.setDisplayName(name); ret.setItemMeta(itemMeta); return ret; }}
Sure. I'm not finished with making the name and lore and id for the item, but I have made a basic gravity gun. I'll make a page for it now, but I'll keep working on it.
Freelix2000 Back to the Lore thing its easy. I know timtower sent you code, but I'll explain: Code:java ItemStack yolo = new ItemStack(Material.DIRT, 1) //1 stack of dirtItemMeta meta = yolo.getItemMeta(); //The item metta variable of yolo//Do what you want here, I'll just set Displaynamemeta.setDisplayname("stupid" + ChatColor.RED + "word"); yolo.setItemMeta(meta); //We only made the meta variable, now we need to set it
JPG2000 Code: ItemStack yolo = new ItemStack(Material.DIRT, 1) //1 stack of dirt Isn't that 1 dirt block?
I already finished it. Well, it still needs a bit more improvement, but the name, lores, and custom materials are done.