вроде с нбт разобрался
пора за работу
This commit is contained in:
parent
1b47fe51e1
commit
324ef74e70
@ -1,9 +1,7 @@
|
||||
package tokarotik.giftapi.savemanager;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_6_R3.NBTCompressedStreamTools;
|
||||
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_6_R3.NBTTagString;
|
||||
import net.minecraft.server.v1_6_R3.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -17,42 +15,49 @@ public class NBTManager
|
||||
public void write(Player player, String path)
|
||||
{
|
||||
EntityPlayer entityPlayer = getPlayer(player);
|
||||
//entityPlayer.getName()
|
||||
|
||||
NBTTagCompound tag = readNBT(entityPlayer, path);
|
||||
NBTTagCompound tag = readNBT(entityPlayer);
|
||||
|
||||
if (tag == null){System.out.println("IS NULL!!!");};
|
||||
|
||||
tag.setShort("Health", (short) 15);
|
||||
tag.setFloat("HealF", 15.0F);
|
||||
tag.setInt("ASOME", 123);
|
||||
|
||||
System.out.println(tag);
|
||||
return writeNBT(tag, entityPlayer, path + "/players/" + player.getName() + ".dat")
|
||||
|
||||
entityPlayer.f(tag);
|
||||
|
||||
System.out.println();
|
||||
System.out.println(tag);
|
||||
|
||||
}
|
||||
|
||||
private NBTTagCompound readNBT(EntityPlayer player, String path)
|
||||
{
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(path + "/players/" + player.getName() + ".dat");
|
||||
NBTTagCompound compound = NBTCompressedStreamTools.a(fis); // Decompress and load
|
||||
fis.close();
|
||||
|
||||
player.b(compound);
|
||||
return compound;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private EntityPlayer getPlayer(Player player)
|
||||
{
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
|
||||
|
||||
private boolean writeNBT(NBTTagCompound compound, EntityPlayer entityPlayer, String path)
|
||||
{
|
||||
entityPlayer.f(compound);
|
||||
|
||||
try
|
||||
{
|
||||
FileOutputStream out = new FileOutputStream(path);
|
||||
NBTCompressedStreamTools.a(compound, out);
|
||||
out.close();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Bukkit.getLogger().warning(e.toString());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private NBTTagCompound readNBT(EntityPlayer entityPlayer)
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
entityPlayer.e(compound);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user