コード例 #1
0
ファイル: SaveHandler.java プロジェクト: ppypp/CanaryMod
  @Override
  public WorldInfo d() {
    File file1 = new File(this.worldDir, "level.dat");
    NBTTagCompound nbttagcompound;
    NBTTagCompound nbttagcompound1;

    if (file1.exists()) {
      try {
        nbttagcompound = CompressedStreamTools.a((InputStream) (new FileInputStream(file1)));
        nbttagcompound1 = nbttagcompound.m("Data");
        return new WorldInfo(nbttagcompound1);
      } catch (Exception exception) {
        exception.printStackTrace();
      }
    }

    file1 = new File(this.worldDir, "level.dat_old");
    if (file1.exists()) {
      try {
        nbttagcompound = CompressedStreamTools.a((InputStream) (new FileInputStream(file1)));
        nbttagcompound1 = nbttagcompound.m("Data");
        return new WorldInfo(nbttagcompound1);
      } catch (Exception exception1) {
        exception1.printStackTrace();
      }
    }

    return null;
  }
コード例 #2
0
ファイル: SaveHandler.java プロジェクト: ppypp/CanaryMod
  @Override
  public void a(WorldInfo worldinfo) {
    NBTTagCompound nbttagcompound = worldinfo.a();
    NBTTagCompound nbttagcompound1 = new NBTTagCompound();

    nbttagcompound1.a("Data", (NBTBase) nbttagcompound);

    try {
      File file1 = new File(this.worldDir, "level.dat_new");
      File file2 = new File(this.worldDir, "level.dat_old");
      File file3 = new File(this.worldDir, "level.dat");

      CompressedStreamTools.a(nbttagcompound1, (OutputStream) (new FileOutputStream(file1)));
      if (file2.exists()) {
        file2.delete();
      }

      file3.renameTo(file2);
      if (file3.exists()) {
        file3.delete();
      }

      file1.renameTo(file3);
      if (file1.exists()) {
        file1.delete();
      }
    } catch (Exception exception) {
      exception.printStackTrace();
    }
  }
コード例 #3
0
ファイル: SaveHandler.java プロジェクト: ppypp/CanaryMod
  // CanaryMod: Added player.dat by UUID getter
  public NBTTagCompound b(UUID uuid) {
    NBTTagCompound nbttagcompound = null;

    try {
      File file1 = new File(this.globalPlayerFilesDir, uuid.toString() + ".dat");

      if (file1.exists() && file1.isFile()) {
        nbttagcompound = CompressedStreamTools.a((InputStream) (new FileInputStream(file1)));
      }
    } catch (Exception exception) {
      a.warn("Failed to load player data for " + uuid.toString());
    }

    return nbttagcompound;
  }
コード例 #4
0
ファイル: SaveHandler.java プロジェクト: ppypp/CanaryMod
  // CanaryMod enable writing dat files from player name and a given base tag
  // This is a copy of this.a(EntityPlayer and might need adjustments accordingly!)
  // TODO UUID
  public void writePlayerNbt(UUID uuid, CanaryCompoundTag tag) {
    try {
      NBTTagCompound nbttagcompound = tag.getHandle();

      File file1 = new File(this.worldDir, uuid.toString() + ".dat.tmp");
      File file2 = new File(this.worldDir, uuid.toString() + ".dat");

      CompressedStreamTools.a(nbttagcompound, (OutputStream) (new FileOutputStream(file1)));
      if (file2.exists()) {
        file2.delete();
      }
      file1.renameTo(file2);
    } catch (Exception exception) {
      a.warn("Failed to save player data for " + uuid.toString());
    }
  }
コード例 #5
0
ファイル: SaveHandler.java プロジェクト: ppypp/CanaryMod
  public NBTTagCompound b(EntityPlayer entityplayer) {
    NBTTagCompound nbttagcompound = null;

    try {
      File file1 = new File(this.globalPlayerFilesDir, entityplayer.aJ().toString() + ".dat");

      if (file1.exists() && file1.isFile()) {
        nbttagcompound = CompressedStreamTools.a((InputStream) (new FileInputStream(file1)));
      }
    } catch (Exception exception) {
      a.warn("Failed to load player data for " + entityplayer.d_());
    }

    if (nbttagcompound != null) {
      entityplayer.f(nbttagcompound);
    }

    return nbttagcompound;
  }
コード例 #6
0
ファイル: SaveHandler.java プロジェクト: ppypp/CanaryMod
  @Override
  public void a(EntityPlayer entityplayer) {
    try {
      NBTTagCompound nbttagcompound = new NBTTagCompound();

      entityplayer.e(nbttagcompound);
      File file1 = new File(this.globalPlayerFilesDir, entityplayer.aJ().toString() + ".dat.tmp");
      File file2 = new File(this.globalPlayerFilesDir, entityplayer.aJ().toString() + ".dat");

      CompressedStreamTools.a(nbttagcompound, (OutputStream) (new FileOutputStream(file1)));
      if (file2.exists()) {
        file2.delete();
      }

      file1.renameTo(file2);
    } catch (Exception exception) {
      a.warn("Failed to save player data for " + entityplayer.d_());
    }
  }