Jump to content
  • 0
Sign in to follow this  
raivorots

item bonueses unpacked

Question

Hello idk why but itembonuses unpacked didnt make folder bonuses in data/items
but i think it should
i think need make from bonuses.ib to folder but idk it didnt make all works fine no errors nothing but it justs unpacking but didnt make folder:(
Code
[HTML]package com.rs.tools;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import com.rs.cache.Cache;
import com.rs.utils.ItemBonuses;
import com.rs.utils.Utils;

/**
* @author Frosty Teh Snowman
*
* Unpacks the Item Bonuses that are packed into the bonuses.ib file.
*/
public class ItemBonusesUnpacker {

public static final void main(String[] args) {
log("Unpacker Started.");
try {
Cache.init();
log("Cache Initiated.");
} catch (IOException e) {
log("Exception in initializing cache.");
}
ItemBonuses.init();
log("Item Bonuses Initiated.");
for (int itemId = 0; itemId < Utils.getItemDefinitionsSize(); itemId++) {
log("Getting Values for item " + itemId);
int[] bonuses = ItemBonuses.getItemBonuses(itemId);
File file = new File("data/items/bonuses/" + itemId + ".txt");
try {
if (file.createNewFile()) {
BufferedWriter writer = new BufferedWriter(new FileWriter(
file));
writer.write("Attack Bonus");
writer.newLine();
writer.write(Integer.toString(bonuses[0]));
writer.newLine();
writer.write(Integer.toString(bonuses[1]));
writer.newLine();
writer.write(Integer.toString(bonuses[2]));
writer.newLine();
writer.write(Integer.toString(bonuses[3]));
writer.newLine();
writer.write(Integer.toString(bonuses[4]));
writer.newLine();
writer.write("Defense Bonus");
writer.newLine();
writer.write(Integer.toString(bonuses[5]));
writer.newLine();
writer.write(Integer.toString(bonuses[6]));
writer.newLine();
writer.write(Integer.toString(bonuses[7]));
writer.newLine();
writer.write(Integer.toString(bonuses[8]));
writer.newLine();
writer.write(Integer.toString(bonuses[9]));
writer.newLine();
writer.write(Integer.toString(bonuses[10]));
writer.newLine();
writer.write("Damage Absorption");
writer.newLine();
writer.write(Integer.toString(bonuses[11]));
writer.newLine();
writer.write(Integer.toString(bonuses[12]));
writer.newLine();
writer.write(Integer.toString(bonuses[13]));
writer.newLine();
writer.write("Other Bonuses");
writer.newLine();
writer.write(Integer.toString(bonuses[14]));
writer.newLine();
writer.write(Integer.toString(bonuses[15]));
writer.newLine();
writer.write(Integer.toString(bonuses[16]));
writer.newLine();
writer.write(Integer.toString(bonuses[17]));
writer.flush();
writer.close();
}
} catch (Exception e) {
}
}
log("Finished Unpacking.");
}

private static void log(String s) {
System.out.println(s);
}

}[/HTML]

Share this post


Link to post
Share on other sites

14 answers to this question

Recommended Posts

  • 0
if (file.createNewFile()) {

Does the file already exist?

"Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist." Edited by Jon

Share this post


Link to post
Share on other sites
  • 0
[quote name='Jon']if (file.createNewFile()) {

Does the file already exist?

"Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist."[/QUOTE]

nope it didnt exist idk what to do:(

Share this post


Link to post
Share on other sites
  • 0
Replace it with this.

[code]
package com.rs.tools;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import com.rs.cache.Cache;
import com.rs.utils.ItemBonuses;
import com.rs.utils.Utils;

/**
* [MENTION=52317]auth[/MENTION]or Frosty Teh Snowman
* Unpacks the Item Bonuses that are packed into the bonuses.ib file.
*
*/
public class ItemBonusesUnpacker {

public static final void main(String[] args) {
log("Unpacker Started.");
try {
Cache.init();
log("Cache Initiated.");
} catch (IOException e) {
log("Exception in initializing cache.");
}
ItemBonuses.init();
log("Item Bonuses Initiated.");
for (int itemId = 0; itemId < Utils.getItemDefinitionsSize(); itemId++) {
log("Getting Values for item " + itemId);
int[] bonuses = ItemBonuses.getItemBonuses(itemId);
File file = new File("data/items/bonuses/" + itemId + ".txt");
try {
if (!file.exists()) {
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
for(int index = 0; index < bonuses.length; indexs++) {
if(index == 0) {
writer.write("Attack Bonus");
writer.newLine();
} else if(index == 5) {
writer.write("Defense Bonus");
writer.newLine();
} else if(index == 11) {
writer.write("Damage Absorption");
writer.newLine();
} else if(index == 14) {
writer.write("Other Bonuses");
writer.newLine();
} else if(index > 17)
break;
writer.write(Integer.toString(bonuses[index]));
if(index != 17)
writer.newLine();
}
writer.flush();
writer.close();
} else {
System.err.println("File Already Exist: " + "data/items/bonuses/" + itemId + ".txt");
}
} catch (Exception e) {
}
}
log("Finished Unpacking.");
}

private static void log(String s) {
System.out.println(s);
}
}
[/code]

Tell me if it prints anything.

Share this post


Link to post
Share on other sites
  • 0
[quote name='Jon']Replace it with this.

[code]
package com.rs.tools;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import com.rs.cache.Cache;
import com.rs.utils.ItemBonuses;
import com.rs.utils.Utils;

/**
* [MENTION=52317]auth[/MENTION]or Frosty Teh Snowman
* Unpacks the Item Bonuses that are packed into the bonuses.ib file.
*
*/
public class ItemBonusesUnpacker {

public static final void main(String[] args) {
log("Unpacker Started.");
try {
Cache.init();
log("Cache Initiated.");
} catch (IOException e) {
log("Exception in initializing cache.");
}
ItemBonuses.init();
log("Item Bonuses Initiated.");
for (int itemId = 0; itemId < Utils.getItemDefinitionsSize(); itemId++) {
log("Getting Values for item " + itemId);
int[] bonuses = ItemBonuses.getItemBonuses(itemId);
File file = new File("data/items/bonuses/" + itemId + ".txt");
try {
if (!file.exists()) {
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
for(int index = 0; index < bonuses.length; indexs++) {
if(index == 0) {
writer.write("Attack Bonus");
writer.newLine();
} else if(index == 5) {
writer.write("Defense Bonus");
writer.newLine();
} else if(index == 11) {
writer.write("Damage Absorption");
writer.newLine();
} else if(index == 14) {
writer.write("Other Bonuses");
writer.newLine();
} else if(index > 17)
break;
writer.write(Integer.toString(bonuses[index]));
if(index != 17)
writer.newLine();
}
writer.flush();
writer.close();
} else {
System.err.println("File Already Exist: " + "data/items/bonuses/" + itemId + ".txt");
}
} catch (Exception e) {
}
}
log("Finished Unpacking.");
}

private static void log(String s) {
System.out.println(s);
}
}
[/code]

Tell me if it prints anything.[/QUOTE]
[IMG]http://i58.tinypic.com/29bh4t3.png[/IMG]

Share this post


Link to post
Share on other sites
  • 0
[quote name='raivorots'][IMG]http://i58.tinypic.com/29bh4t3.png[/IMG][/QUOTE]

Where it says indexs++ change it to index++

Share this post


Link to post
Share on other sites
  • 0
[quote name='Jon']Where it says indexs++ change it to index++[/QUOTE]

nope it didnt make bonuses anyway

Share this post


Link to post
Share on other sites
  • 0
[quote name='raivorots']nope it didnt make bonuses anyway[/QUOTE]

I saidddd, did it print?

You should see
Item Bonuses Initiated.
Finished Unpacking.

On your cmd window

Share this post


Link to post
Share on other sites
  • 0
[quote name='Jon']I saidddd, did it print?[/QUOTE]
yes it print like
getting values for item and codes
finished unpacking
but nothing:(

Share this post


Link to post
Share on other sites
  • 0
try this... It wont dump them all at once not sure why you want it that way because it would just create a blank file in which youd have to add the data yourself still... But simply use this:

[CODE] [MENTION=7458]echo[/MENTION] off
title Chronicscape Item Definitions Generator
echo Started!
"C:/Program Files/Java/jre7/bin/java.exe" -Xmx512m -cp bin;lib/* com.rs.tools.ItemDefinitionsGenerator
pause
[/CODE]

Share this post


Link to post
Share on other sites
  • 0
[quote name='Chronicscape']try this... It wont dump them all at once not sure why you want it that way because it would just create a blank file in which youd have to add the data yourself still... But simply use this:

[CODE] [MENTION=7458]echo[/MENTION] off
title Chronicscape Item Definitions Generator
echo Started!
"C:/Program Files/Java/jre7/bin/java.exe" -Xmx512m -cp bin;lib/* com.rs.tools.ItemDefinitionsGenerator
pause
[/CODE][/QUOTE]

ok and what this doing?

Share this post


Link to post
Share on other sites
Sign in to follow this  

×