Code:
package com.rapidj.nicaea.server;
import java.io.File;
import java.io.FilenameFilter;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Map;
/**
* Created by IntelliJ IDEA.
* <code>com.rapidj.nicaea.server.MapPack</code>
*
* @author Light232 ([email protected])
*/
public final class MapPack {
private final HashMap<Short, int[]> mapXTEAKeys;
public MapPack() {
this.mapXTEAKeys = new HashMap<Short, int[]>(36, 2.0F);
}
public void load(String dir) throws IOException {
File[] mapXTEAs = new File(dir).listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".txt");
}
});
for(File mapXTEA : mapXTEAs) {
BufferedReader read = new BufferedReader(new FileReader(mapXTEA));
mapXTEAKeys.put(Short.valueOf(mapXTEA.getName().replace(".txt", ""))
, new int[] {Integer.valueOf(read.readLine()),Integer.valueOf(read.readLine())
,Integer.valueOf(read.readLine()),Integer.valueOf(read.readLine())});
read.close();
}
}
public void save(String dir) throws IOException {
DataOutputStream bin = new DataOutputStream(new FileOutputStream(dir));
for(Map.Entry<Short, int[]> entry : mapXTEAKeys.entrySet()) {
bin.writeShort(entry.getKey());
for(int key : entry.getValue()) {
bin.writeInt(key);
}
}
bin.writeShort(0);//regions should never == 0 so this marks our end
bin.close();
}
}
Code:
public virtual void LoadRegions()
{
try
{
FileStream mFile = new FileStream(@".\Bin\Data\MapData\Regions.dat", FileMode.Open);
BufferedStream mBuf = new BufferedStream(mFile);
BinaryReader mBin = new BinaryReader(mBuf);
short regionID = mBin.ReadInt16();
while((regionID = mBin.ReadInt16()) != 0) {
mMapRegions.Add(regionID, new int[] {mBin.ReadInt32(), mBin.readInt32(), mBin.readInt32(), mBin.readInt32()});
}
JoltEnvironment.GetLogger().WriteClean("Successfully loaded " + mMapRegions.Count + " map regions.");
}
catch (Exception ex)
{
JoltEnvironment.GetLogger().WriteError(ex.Message);
JoltEnvironment.ShutDown();
}
}
sorry but the mappacker that are out atm are shit ugly, or are literly shit, the above i made in a few minutes, so excuse me for the ugliness but its better than wats out atm
notice the packer is in java, and the code below it is for you to replace in ur server to comply with the packed xtea keys file