I am working on a bukkit plugin. One thing I want this plugin to do is teleport you to other worlds on the server. However, I don't want the player's inventory to be saved.
Right now, I have this code:
File playerInvConfigFile = new File(plugin.getDataFolder() + File.separator + "players" + File.separator + sender.getName(), "inventory.yml");
FileConfiguration pInv = YamlConfiguration.loadConfiguration(playerInvConfigFile);
Player user = (Player)sender;
PlayerInventory inv = user.getInventory();
String worldName = user.getWorld().getName();
int i = 0;
for (ItemStack stack : inv.getContents()){
i++;
String start = worldName + "." + Integer.toString(i);
pInv.set(start + ".amount", stack.getAmount());
pInv.set(start + ".durability", stack.getDurability());
pInv.set(start + ".type", stack.getTypeId());
}
inv.clear();
This works great, but there is a big problem: enchantments are now saved! This is a big problem. I want to know how to both save enchantments to a file, and then read them back in and set them!
Thank you all!