Plugin category: Fun Suggested name: Vaults What I want: I want a plugin where if you type /vault it will open a chest gui, but not a normal chest gui, i want it so it'll open only 1 slot, not 9 as a normal chest row will hold. I want it to hold 1, and you can configurable how many slots each rank can get. So for example, player gets 1, lowest donator gets 2, next donor gets 3, ETC. And it will save the players vault in a file. Ideas for commands: /vault (/v) Ideas for permissions: vault.1 (for 1 slot) vault.2 (for 2 slots) vault.3 (for 3 slots) vault.4 (for 4 slots) ETC When I'd like it by: Tomorrow if that's possible. With no permission when they type /vault With vault.1 (They have a free 1 slot and i so happened to put a stack of diamond blocks.
ThePluginMaker http://dev.bukkit.org/bukkit-plugins/playervaults/ What I use for my server works awesome
ThePluginMaker I don't think minecraft itself supports individual slots. Maybe open not a chest GUI but a modified Brewing Stand GUI? IDK lol.
A server called Gontroller has it, but used for their enderchests If not then could you make it so it's 9 slots, but 8 of them back a unmoveable block in it? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
ThePluginMaker You do realize that that is a player inventory? Harrison015 Apparently you make nice pictures
timtower It was an example..... i didn't have a 1 row chest with unused inventory slots in it, so i used his picture
Harrison015 Thanks, that would be perfect! Now we just need someone to make it EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Onlineids I think I need help with the metadata and the enchantments.. I am saving the players' data in the config.yml, Code:java private void saveItem(ConfigurationSection section, ItemStack itemStack) { section.set("type", itemStack.getType().name()); section.set("amount", itemStack.getAmount()); section.set("meta", itemStack.getItemMeta()); //How to save all the item's data properly? And then later loading it Code:java private ItemStack loadItem(ConfigurationSection section) { return new ItemStack(Material.valueOf(section.getString("type")), section.getInt("amount")); //Load more item data
Harrison015 Inventory handling: http://hastebin.com/tuxufemogu.php Save and Load: Code:java public void saveInventory(Player p, ConfigurationSection cs){ String inv = InventoryHandling.saveInventory(p); String armor = InventoryHandling.saveArmor(p); cs.set("inv", inv); cs.set("armor", armor); saveInv(); } public void loadInventory(Player p, ConfigurationSection cs) throws IOException{ String inv = cs.getString("inv"); if(inv != null){ Inventory playerInv = InventoryHandling.fromBase64(inv); p.getInventory().setContents(playerInv.getContents()); } String armor = cs.getString("armor"); if(armor != null){ ItemStack[] playerArmor = InventoryHandling.itemStackArrayFromBase64(armor); p.getInventory().setArmorContents(playerArmor); } }
Onlineids But I am not saving their inventory, I am saving the contents of their "Vault". Here is the code I have so far: Code:java package me.harmar.vaults; import java.util.HashMap;import java.util.Map.Entry;import java.util.UUID; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.Material;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.configuration.ConfigurationSection;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.inventory.InventoryType;import org.bukkit.event.player.PlayerJoinEvent;import org.bukkit.event.player.PlayerQuitEvent;import org.bukkit.inventory.Inventory;import org.bukkit.inventory.ItemStack;import org.bukkit.plugin.java.JavaPlugin; public class VaultInv extends JavaPlugin implements Listener { private HashMap<UUID, Inventory> vaults = new HashMap<UUID, Inventory>(); @EventHandler public void onPlayerJoin(PlayerJoinEvent e) { Inventory inv = Bukkit.getServer().createInventory(e.getPlayer(), 9, "Your Vault"); if (getConfig().contains("vaults." + e.getPlayer().getUniqueId())) { for (String item : getConfig().getConfigurationSection("vaults." + e.getPlayer().getUniqueId()).getKeys(false)) { inv.addItem(loadItem(getConfig().getConfigurationSection("vaults." + e.getPlayer().getUniqueId() + "." + item))); } } vaults.put(e.getPlayer().getUniqueId(), inv); } @EventHandler public void onPlayerLeave(PlayerQuitEvent e) { if (!getConfig().contains("vaults." + e.getPlayer().getUniqueId())) { getConfig().createSection("vaults." + e.getPlayer().getUniqueId()); } char c = 'a'; for (ItemStack itemStack : vaults.get(e.getPlayer().getUniqueId())) { if (itemStack != null) { saveItem(getConfig().createSection("vaults." + e.getPlayer().getUniqueId() + "." + c++), itemStack); } } saveConfig(); } public void onEnable() { Bukkit.getServer().getPluginManager().registerEvents(this, this); } public void onDisable() { for (Entry<UUID, Inventory> entry : vaults.entrySet()) { if (!getConfig().contains("vaults." + entry.getKey())) { getConfig().createSection("vaults." + entry.getKey()); } char c = 'a'; for (ItemStack itemStack : entry.getValue()) { if (itemStack != null) { saveItem(getConfig().createSection("vaults." + entry.getKey() + "." + c++), itemStack); } } saveConfig(); } } @Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "The console cannot have a Vault."); return true; } Player p = (Player) sender; if (cmd.getName().equalsIgnoreCase("vault")) { p.openInventory(vaults.get(p.getUniqueId())); } return true; } private void saveItem(ConfigurationSection section, ItemStack itemStack) { section.set("type", itemStack.getType().name()); section.set("amount", itemStack.getAmount()); section.set("meta", itemStack.getItemMeta()); //Save more info } private ItemStack loadItem(ConfigurationSection section) { return new ItemStack(Material.valueOf(section.getString("type")), section.getInt("amount")); // Load more information. }} ThePluginMaker Keep in mind, I haven't added the blocked slots feature yet.
ThePluginMaker Onlineids I'm doing the best I can. Vaults version 1.0 So far all I have is the command /vault that brings up your vault. The items are saved except for their cusom names, enchantments, and lores. (I'm working on that). There also is no restricted slots yet. (Also working on that). This is my first plugin by the way! Expect Bugs and horrible coding.
Harrison015 You really want to reconsider your way of storing the items. It is pretty much a free repair method.
Just use: Code: config.set("path.path", itemStack); Have it save items that are not the unused inventory itemstack.
I am not sure if I can anymore. It's turning out to be harder than I expected, and I have less time to do things now. Might be a good idea to get someone else to make this.
<Edit by Moderator: Redacted mediafire url> To some people who saw my deleted post, I forgot to change some things because I was testing for bugs and I wasn't sure if someone else was working on this. You're probably going to get some errors but idk. Just reload if you do. If it doesn't go away, just say with the error if there's one. Permissions * vaults.1 - Default, given to all players only the first row available * vaults.2 - Top row disabled * vaults.3 - All rows enabled Here's what I have done that didn't give me errors. No guarentees it wont give you errors though * Item data type (For colored wool, stained glass, logs, pistons, etc) * Item durability * Item lore with colors * Item displayname with color * Item amounts * Enchantments with levels * Material type * The item should be saved in the slot that it was placed in * Items that would get overlapped with the '&cNo Access' item would get dropped (Not tested but should work) * Config file to cusotmize the '&cNo access' item type, name (with color), and data value * Contents saved when that specific inventory is closed - Not sure if this is a good idea but I did it * The '&cNo Access' item can't be moved or dropped - hooorah! If something's not right just tell me. It's probably because I was testing things. the command to open the vault is /vault
izarooni Hey your plugin has rows, is there a way you can change it to slots? like the pictures i have up there?
izarooni sure thing izarooni could i have the source? EDIT by Moderator: merged posts, please use the edit button instead of double posting.