I was helping a friend do this with his NRS3server source and I thought this would be good to share with the community. This is a good idea because I think the cache's item prices are wack. Also, people were changing item's prices one by one and that just made me
Credits to the developer of NRS3Server for the first few steps in this tutorial.
Firstly, if you are already using the NRS3Server source, you do not need to do Steps 1 or 2, but to follow the tutorial exactly, you should change the name from getGEPrices to getTipitPrices.
Step one
Go to src>com>rs>cache>loaders>ItemDefinitions.java
Then add all of this code into the class...
Code:
public int getTipitPrice() {
try {
for (String lines : FileUtilities.readFile("./data/items/tipit_dump.txt")) {
String[] data = lines.split(" - ");
if (Integer.parseInt(data[0]) == id) return Integer.parseInt(data[1]);
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return -1;
}
public static class FileUtilities {
public static final int BUFFER = 1024;
public static boolean exists(String name) {
File file = new File(name);
return file.exists();
}
public static ByteBuffer fileBuffer(String name) throws IOException {
File file = new File(name);
if(!file.exists())
return null;
FileInputStream in = new FileInputStream(name);
byte[] data = new byte[BUFFER];
int read;
try {
ByteBuffer buffer = ByteBuffer.allocate(in.available() + 1);
while ((read = in.read(data, 0, BUFFER)) != -1) {
buffer.put(data, 0, read);
}
buffer.flip();
return buffer;
} finally {
if (in != null)
in.close();
in = null;
}
}
public static void writeBufferToFile(String name, ByteBuffer buffer) throws IOException {
File file = new File(name);
if(!file.exists())
file.createNewFile();
FileOutputStream out = new FileOutputStream(name);
out.write(buffer.array(), 0, buffer.remaining());
out.flush();
out.close();
}
public static LinkedList<String> readFile(String directory) throws IOException {
LinkedList<String> fileLines = new LinkedList<String>();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(directory));
String string;
while ((string = reader.readLine()) != null) {
fileLines.add(string);
}
} finally {
if (reader != null) {
reader.close();
reader = null;
}
}
return fileLines;
}
}
Then add these imports if you don't already have them.
I created that dump and sold a service to somebody for it. This isn't yours to release, at least give me credits.
I'm still laughing at the FileUtilities class in ItemDefinitions. I did that cause I was lazy.
[Only registered and activated users can see links. ] | [Only registered and activated users can see links. ] | [Only registered and activated users can see links. ] (official dog of rune-server)