Code:
package com.rs2.server.utility.tools.prefetch;
import com.wycody.cache.Cache;
import com.wycody.cache.config.Js5Archive;
/**
* Created at: Jan 19, 2017 6:04:40 PM
*
* @author Walied-Yassen A.k.A Cody
*/
public enum Js5PrefetchType {
/**
* The defaults ARCHIVEe.
*/
DEFAULTS(new Js5PrefetchArchive(Js5Archive.JS5_DEFAULTS)),
/**
* The native JagexCoreLib library node.
*/
JACLIB(new Js5PrefetchNative("jaclib")),
/**
* The native JagexOpenGL library node.
*/
JAGGL(new Js5PrefetchNative("jaggl")),
/**
* The native JagexDirectX library node.
*/
JAGDX(new Js5PrefetchNative("jagdx")),
/**
* The native Software3D library node.
*/
SW3D(new Js5PrefetchNative("sw3d")),
/**
* The native Hardware3D library node.
*/
HW3D(new Js5PrefetchNative("hw3d")),
/**
* The native JagexTheora library node.
*/
JAGTHEORA(new Js5PrefetchNative("jagtheora")),
/**
* The shaders archive node.
*/
SHADERS(new Js5PrefetchArchive(Js5Archive.JS5_SHADERS)),
/**
* The materials archive node.
*/
MATERIALS(new Js5PrefetchArchive(Js5Archive.JS5_MATERIALS)),
/**
* The configurations archive node.
*/
CONFIG(new Js5PrefetchArchive(Js5Archive.JS5_CONFIG)),
/**
* The locations type configurations archive node.
*/
CONFIG_LOC(new Js5PrefetchArchive(Js5Archive.JS5_CONFIG_LOC)),
/**
* the enum type configurations archive node.
*/
CONFIG_ENUM(new Js5PrefetchArchive(Js5Archive.JS5_CONFIG_ENUM)),
/**
* The NPC type configurations archive node.
*/
CONFIG_NPC(new Js5PrefetchArchive(Js5Archive.JS5_CONFIG_NPC)),
/**
* The object type configurations archive node.
*/
CONFIG_OBJ(new Js5PrefetchArchive(Js5Archive.JS5_CONFIG_OBJ)),
/**
* The animation sequence type configurations archive node.
*/
CONFIG_SEQ(new Js5PrefetchArchive(Js5Archive.JS5_CONFIG_SEQ)),
/**
* The spot animation type configurations archive node.
*/
CONFIG_SPOT(new Js5PrefetchArchive(Js5Archive.JS5_CONFIG_SPOT)),
/**
* The variable bit type configurations archive node.
*/
VAR_BIT(new Js5PrefetchArchive(Js5Archive.JS5_VAR_BIT)),
/**
* The common quick chat entries archive node.
*/
QUICKCHAT(new Js5PrefetchArchive(Js5Archive.JS5_QUICKCHAT)),
/**
* The global quick chat entries archive node.
*/
QUICKCHAT_GLOBAL(new Js5PrefetchArchive(Js5Archive.JS5_QUICKCHAT_GLOBAL)),
/**
* The particles archive node.
*/
PARTICLES(new Js5PrefetchArchive(Js5Archive.JS5_CONFIG_PARTICLE)),
/**
* The billboards archive node.
*/
BILLBOARDS(new Js5PrefetchArchive(Js5Archive.JS5_CONFIG_BILLBOARD)),
/**
* The huffman binary archive node.
*/
HUFFMAN(new Js5PrefetchFile(Js5Archive.JS5_BINARY, "huffman")),
/**
* The interfaces archive node.
*/
INTERFACES(new Js5PrefetchArchive(Js5Archive.JS5_INTERFACES)),
/**
* The client scripts archive node.
*/
CLIENTSCRIPTS(new Js5PrefetchArchive(Js5Archive.JS5_CLIENTSCRIPTS)),
/**
* The font metrics archive node.
*/
FONTMETRICS(new Js5PrefetchArchive(Js5Archive.JS5_FONTMETRICS)),
/**
* The world map data file node.
*/
WORLDMAP_DATA(new Js5PrefetchGroup(Js5Archive.JS5_WORLDMAPDATA, "details")) ;
/**
* The prefetch type.
*/
private Js5Prefetch prefetch;
/**
* Construct a new {@link Js5PrefetchType} object instance.
*
* @param prefetch
* the type prefetch.
*/
private Js5PrefetchType(Js5Prefetch prefetch) {
this.prefetch = prefetch;
}
/**
* Initializes all the prefetch types.
*
* @param cache
* the cache to initialize for.
*/
public static void initialize(Cache cache) {
for (Js5PrefetchType type : values())
type.getPrefetch().initialize(cache);
}
/**
* Gets the prefetch type.
*
* @return the prefetch type.
*/
public Js5Prefetch getPrefetch() {
return prefetch;
}
}
Code:
package com.rs2.server.utility.tools.prefetch;
import com.wycody.cache.Cache;
import com.wycody.cache.config.Js5Archive;
/**
* Created at: Jan 19, 2017 6:22:18 PM
*
* @author Walied-Yassen A.k.A Cody
*/
public class Js5PrefetchNative implements Js5Prefetch {
/**
* The library name.
*/
private String name;
/**
* The prefetch value.
*/
private int value;
/**
* Construct a new {@link Js5PrefetchNative} object instance.
*
* @param name
* the library name.
*/
public Js5PrefetchNative(String name) {
this.name = name;
}
/*
* (non-Javadoc)
*
* @see
* com.rs2.server.utility.tools.prefetch.impl.Js5Prefetch#initialize(com.
* wycody.cache.Cache)
*/
@Override
public void initialize(Cache cache) {
if (name != null) {
int groupId = cache.getArchive(Js5Archive.JS5_DLLS).getGroupId("windows/x86/" + name + ".dll");
value = groupId != -1 ? cache.getArchive(Js5Archive.JS5_DLLS).getIndexStore().load(groupId).length - 2 : 0;
}
}
/*
* (non-Javadoc)
*
* @see com.rs2.server.utility.tools.prefetch.impl.Js5Prefetch#getValue()
*/
@Override
public int getValue() {
return value;
}
}
Code:
package com.rs2.server.utility.tools.prefetch;
import com.wycody.cache.Cache;
import com.wycody.cache.archive.Archive;
import com.wycody.cache.config.Js5Archive;
/**
* Created at: Jan 19, 2017 7:09:11 PM
*
* @author Walied-Yassen A.k.A Cody
*/
public class Js5PrefetchGroup implements Js5Prefetch {
/**
* The archive id.
*/
private Js5Archive type;
/**
* The group name.
*/
private String name;
/**
* The prefetch value.
*/
private int value;
/**
* Construct a new {@link Js5PrefetchGroup} object instance.
*
* @param type
* the archive type.
* @param name
* the group name.
*/
public Js5PrefetchGroup(Js5Archive type, String name) {
this.type = type;
this.name = name;
}
/*
* (non-Javadoc)
*
* @see
* com.rs2.server.utility.tools.prefetch.impl.Js5Prefetch#initialize(com.
* wycody.cache.Cache)
*/
@Override
public void initialize(Cache cache) {
if (type != null) {
Archive archive = cache.getArchive(type);
value = archive.getIndexStore().load(archive.getGroupId(name)).length - 2;
}
}
/*
* (non-Javadoc)
*
* @see com.rs2.server.utility.tools.prefetch.impl.Js5Prefetch#getValue()
*/
@Override
public int getValue() {
return value;
}
}
Code:
package com.rs2.server.utility.tools.prefetch;
import com.wycody.cache.Cache;
import com.wycody.cache.archive.Archive;
import com.wycody.cache.config.Js5Archive;
/**
* Created at: Jan 19, 2017 7:09:19 PM
*
* @author Walied-Yassen A.k.A Cody
*/
public class Js5PrefetchFile implements Js5Prefetch {
/**
* The group archive.
*/
private Js5Archive type;
/**
* The file name.
*/
private String name;
/**
* The prefetch value.
*/
private int value;
/**
* Construct a new {@link Js5PrefetchFile} object instance.
*
* @param type
* the archive type.
* @param name
* the file name.
*/
public Js5PrefetchFile(Js5Archive type, String name) {
this.type = type;
this.name = name;
}
/*
* (non-Javadoc)
*
* @see
* com.rs2.server.utility.tools.prefetch.impl.Js5Prefetch#initialize(com.
* wycody.cache.Cache)
*/
@Override
public void initialize(Cache cache) {
if (type != null) {
Archive archive = cache.getArchive(type);
value = archive.getIndexStore().load(archive.getGroupId(name)).length - 2;
}
}
/*
* (non-Javadoc)
*
* @see com.rs2.server.utility.tools.prefetch.impl.Js5Prefetch#getValue()
*/
@Override
public int getValue() {
return value;
}
}
Code:
package com.rs2.server.utility.tools.prefetch;
import com.wycody.cache.Cache;
import com.wycody.cache.archive.Archive;
import com.wycody.cache.config.Js5Archive;
/**
* Created at: Jan 19, 2017 6:47:08 PM
*
* @author Walied-Yassen A.k.A Cody
*/
public class Js5PrefetchArchive implements Js5Prefetch {
/**
* The archive id.
*/
private Js5Archive type;
/**
* The prefetch value.
*/
private int value;
/**
* Construct a new {@link Js5PrefetchArchive} object instance.
*
* @param type
* the archive type.
*/
public Js5PrefetchArchive(Js5Archive type) {
this.type = type;
}
/*
* (non-Javadoc)
*
* @see
* com.rs2.server.utility.tools.prefetch.impl.Js5Prefetch#initialize(com.
* wycody.cache.Cache)
*/
@Override
public void initialize(Cache cache) {
if (type != null) {
Archive archive = cache.getArchive(type);
int total = 0;
for (int groupId = 0; groupId < archive.getBiggestGroupId() + 1; groupId++) {
if (archive.groupExists(groupId)) {
total += archive.getIndexStore().load(groupId).length;
}
}
total += cache.getMetaStore().load(type.getId()).length;
value = total;
}
}
/*
* (non-Javadoc)
*
* @see com.rs2.server.utility.tools.prefetch.impl.Js5Prefetch#getValue()
*/
@Override
public int getValue() {
return value;
}
}
Code:
package com.rs2.server.utility.tools.prefetch;
import com.wycody.cache.Cache;
/**
* Created at: Jan 19, 2017 6:22:53 PM
*
* @author Walied-Yassen A.k.A Cody
*/
public interface Js5Prefetch {
/**
* Initializes the prefetch type.
*
* @param cache
* the cache to initialize for.
*/
public void initialize(Cache cache);
/**
* Gets the prefetch value.
*
* @return the prefetch value.
*/
public int getValue();
}