Hi guys I just want to ask if someone can code me a save.yml for my Backpack Plugin Here is my Main: Code:java package me.saith1999.team; import org.bukkit.plugin.java.JavaPlugin; import Commands.backpack;public class Main extends JavaPlugin {public void onEnable(){this.getCommand("bp").setExecutor(new backpack());}public void onDisable(){}} Here is the backpack: Code:java package Commands; import org.bukkit.Bukkit;import org.bukkit.Sound;import org.bukkit.command.Command;import org.bukkit.command.CommandExecutor;import org.bukkit.command.CommandSender;import org.bukkit.command.ConsoleCommandSender;import org.bukkit.entity.Player;import org.bukkit.inventory.Inventory; public class backpack implements CommandExecutor { public static Inventory BACKPACK;@Overridepublic boolean onCommand(CommandSender sender, Command cmd, String label,String[] args) { if(sender instanceof ConsoleCommandSender){System.out.println("nope");return true;}if(cmd.getName().equalsIgnoreCase("bp")){Player p = (Player) sender;if(!(p.hasPermission("saith.bp.Ironraider"))){p.sendMessage("§0[§6§lStarNetwork§0]§4§m§lPermissions");p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F);p.playSound(p.getLocation(), Sound.FIZZ, 1F, 1F); return true;}BACKPACK = Bukkit.createInventory(null, 9, "§7§l"+ p.getName()+ "'s §4Backpack");((Player) p).openInventory(BACKPACK); return true; } return false;} } Thx
Saith1998 This probably belongs to "Plugin Developement" not "Plugin Requests". Also something like this is pretty easy. In fact there are multiple backpack plugins out there... But since I havent got much time right now, I will not send you any code for now. I will just explain you how you can do this: 1. You probably wanna insert if (sender instanceof Player) there as well before casting it. 2. Since every player probably will have its own backpack, dont make a public variable. Use an ArrayList with player UUIDs/Names instead. 3. On closing the inventory (InventoryCloseEvent) just loop through all Slots of the closed Inventory and store the item in this slot in the save.yml under something like "backpacks.Moewe1.inventory.0" and then 1,2,3,4... 4. Then on opening the backpack look if the file contains the players name. If so loop through the slots again, and create an Inventory which has the same Items in the same Slots. put the players UUID/Name in the ArrayList. And then check for the players UUID/Name in the list in step 3.
Saith1998 Wrong section, Also you should watch this video about Backpacks by Pogostick29dev: this should help you out a bit.
I suggest you learn Java and Bukkit, before attempting to "make" a plugin. You're casting sender to player, then checking if it's the console. You're casting sender to player twice, instead of using the player variable the second time
TheMcScavenger I started learning Java and Bukkit just 3 ore 4 days ago. That's the reasonwhy I am making some silly mistakes.
While "doing it" is a great way to learn, you can't do it without any knowledge in advance. Learn the basics before you attempt coding yourself, because this simply isn't going to work out. You're stuck with mistakes you'll learn about in the first or second tutorial on the Bukkit API, causing you to not even get around to fixing the mistakes in your actual code.