mirror of
https://github.com/moparisthebest/MoparClassic
synced 2024-12-21 23:18:52 -05:00
Merge pull request #33 from Joe0/issue-24-example
Lots of Updates & Fixes
This commit is contained in:
commit
fde87bff45
@ -4,11 +4,12 @@
|
||||
<property name="bin" location="bin" />
|
||||
<property name="lib_managed" location="lib_managed" />
|
||||
<property name="lib" location="lib" />
|
||||
<property name="module" location="module" />
|
||||
<property name="doc" location="doc" />
|
||||
<property name="jar" value="moparclassic.jar" />
|
||||
<property name="main-class" value="org.moparscape.msc.gs.Server" />
|
||||
<property name="scala-version" value="2.9.1" />
|
||||
<property name="ivy.lib.dir" value="lib_managed"/>
|
||||
<property name="ivy.lib.dir" value="lib_managed" />
|
||||
|
||||
<fileset id="libraries" dir="${lib}">
|
||||
<include name="*.jar" />
|
||||
@ -18,6 +19,10 @@
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
|
||||
<fileset id="modules" dir="${module}">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
|
||||
<fileset id="production-classes" dir="${bin}">
|
||||
<include name="**/*.class" />
|
||||
</fileset>
|
||||
@ -29,6 +34,7 @@
|
||||
<path id="library-path">
|
||||
<fileset refid="libraries" />
|
||||
<fileset refid="libraries_managed" />
|
||||
<fileset refid="modules" />
|
||||
</path>
|
||||
|
||||
<path id="master-path">
|
||||
@ -69,7 +75,7 @@
|
||||
<delete file="${jar}" />
|
||||
</target>
|
||||
|
||||
<target name="run" depends="build">
|
||||
<target name="run">
|
||||
<java classpathref="master-path" fork="true" classname="${main-class}" />
|
||||
</target>
|
||||
|
||||
|
@ -78,4 +78,7 @@
|
||||
<entry key="alert-config">conf/alert-config.xml</entry>
|
||||
<!-- Location of configuration file for commands -->
|
||||
<entry key="command-config">conf/command-config.xml</entry>
|
||||
|
||||
<!-- The class that should be used for the DataStore -->
|
||||
<entry key="data-store">org.moparscape.msc.gs.persistence.impl.XMLUsingXStream</entry>
|
||||
</properties>
|
||||
|
@ -15,5 +15,8 @@
|
||||
<dependency org="commons-collections" name="commons-collections" rev="3.2.1"/>
|
||||
|
||||
<dependency org="org.slf4j" name="slf4j-simple" rev="1.6.3"/>
|
||||
|
||||
<dependency org="net.jcip" name="jcip-annotations" rev="1.0"/>
|
||||
|
||||
</dependencies>
|
||||
</ivy-module>
|
||||
|
BIN
GameServer/module/DataStoreCore.jar
Normal file
BIN
GameServer/module/DataStoreCore.jar
Normal file
Binary file not shown.
BIN
GameServer/module/XMLUsingXStreamDataStore.jar
Normal file
BIN
GameServer/module/XMLUsingXStreamDataStore.jar
Normal file
Binary file not shown.
BIN
GameServer/moparclassic.jar
Normal file
BIN
GameServer/moparclassic.jar
Normal file
Binary file not shown.
@ -42,6 +42,7 @@ public class Config {
|
||||
public static boolean OS_LEVEL_BLOCKING, APPLICATION_LEVEL_THROTTLE_ALERT,
|
||||
OS_LEVEL_THROTTLE_ALERT, OS_LEVEL_UNBLOCK_FAILED_ALERT,
|
||||
CONGRATS_FOR_MAX_LEVEL;
|
||||
public static String DATA_STORE;
|
||||
|
||||
static {
|
||||
loadEnv();
|
||||
@ -127,6 +128,8 @@ public class Config {
|
||||
.getProperty("wild-combat-bonus"));
|
||||
CONGRATS_FOR_MAX_LEVEL = Boolean.parseBoolean(props
|
||||
.getProperty("max-level-congrats"));
|
||||
|
||||
DATA_STORE = props.getProperty("data-store");
|
||||
|
||||
props.clear();
|
||||
|
||||
|
@ -1132,7 +1132,7 @@ public class Formulae {
|
||||
* - ItemLoc, GameObjectLoc, NPCLoc or an Integer.
|
||||
* @return - true if inside P2P area, otherwise false.
|
||||
*/
|
||||
public static boolean isP2P(boolean f2pwildy, Object... objs) {
|
||||
public static boolean isP2P(Boolean f2pwildy, Object... objs) {
|
||||
int x = -1;
|
||||
int y = -1;
|
||||
if (objs.length == 1) {
|
||||
|
@ -1,9 +1,12 @@
|
||||
package org.moparscape.msc.gs;
|
||||
|
||||
import org.moparscape.msc.config.Config;
|
||||
import org.moparscape.msc.gs.core.DelayedEventHandler;
|
||||
import org.moparscape.msc.gs.db.DBConnection;
|
||||
import org.moparscape.msc.gs.db.ReportHandlerQueries;
|
||||
import org.moparscape.msc.gs.model.World;
|
||||
import org.moparscape.msc.gs.persistence.DataStore;
|
||||
import org.moparscape.msc.gs.persistence.impl.DataStoreFactory;
|
||||
import org.moparscape.msc.gs.plugins.dependencies.PluginHandler;
|
||||
|
||||
/**
|
||||
@ -33,4 +36,23 @@ public class Instance {
|
||||
public static ReportHandlerQueries getReport() {
|
||||
return DBConnection.getReport();
|
||||
}
|
||||
|
||||
private static DataStore dataStore;
|
||||
|
||||
private static void createDataStore() {
|
||||
try {
|
||||
dataStore = DataStoreFactory.create(Config.DATA_STORE);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Could not create DataStore - " + Config.DATA_STORE);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static DataStore getDataStore() {
|
||||
if(dataStore == null) {
|
||||
createDataStore();
|
||||
}
|
||||
return dataStore;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,12 @@ public class Server {
|
||||
|
||||
Config.initConfig(configFile);
|
||||
world = Instance.getWorld();
|
||||
world.wl.loadObjects();
|
||||
try {
|
||||
world.wl.loadObjects();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
World.initilizeDB();
|
||||
|
||||
|
@ -34,7 +34,6 @@ public final class DelayedEventHandler {
|
||||
events.addAll(toAdd);
|
||||
toAdd.clear();
|
||||
}
|
||||
|
||||
Iterator<DelayedEvent> iterator = events.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
DelayedEvent event = iterator.next();
|
||||
|
@ -26,7 +26,6 @@ import org.moparscape.msc.gs.phandler.PacketHandlerDef;
|
||||
import org.moparscape.msc.gs.plugins.dependencies.NpcAI;
|
||||
import org.moparscape.msc.gs.tools.Captcha;
|
||||
import org.moparscape.msc.gs.util.Logger;
|
||||
import org.moparscape.msc.gs.util.PersistenceManager;
|
||||
|
||||
/**
|
||||
* The central motor of the game. This class is responsible for the primary
|
||||
@ -92,7 +91,12 @@ public final class GameEngine extends Thread {
|
||||
captcha = new Captcha();
|
||||
captcha.init();
|
||||
packetQueue = new PacketQueue<RSCPacket>();
|
||||
loadPacketHandlers();
|
||||
try {
|
||||
loadPacketHandlers();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
for (Shop shop : world.getShops()) {
|
||||
shop.initRestock();
|
||||
}
|
||||
@ -147,10 +151,11 @@ public final class GameEngine extends Thread {
|
||||
|
||||
/**
|
||||
* Loads the packet handling classes from the persistence manager.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected void loadPacketHandlers() {
|
||||
PacketHandlerDef[] handlerDefs = (PacketHandlerDef[]) PersistenceManager
|
||||
.load("PacketHandlers.xml");
|
||||
protected void loadPacketHandlers() throws Exception {
|
||||
PacketHandlerDef[] handlerDefs = Instance.getDataStore()
|
||||
.loadPacketHandlerDefs();
|
||||
for (PacketHandlerDef handlerDef : handlerDefs) {
|
||||
try {
|
||||
String className = handlerDef.getClassName();
|
||||
@ -171,25 +176,21 @@ public final class GameEngine extends Thread {
|
||||
clientUpdater.sendQueuedPackets();
|
||||
long now = GameEngine.getTime();
|
||||
if (now - lastSentClientUpdate >= 600) {
|
||||
if (now - lastSentClientUpdate >= 1000) {
|
||||
// Logger.println("MAJOR UPDATE DELAYED: " + (now -
|
||||
// lastSentClientUpdate));
|
||||
}
|
||||
lastSentClientUpdate = now;
|
||||
clientUpdater.doMajor();
|
||||
}
|
||||
if (now - lastSentClientUpdateFast >= 104) {
|
||||
if (now - lastSentClientUpdateFast >= 6000) {
|
||||
// Logger.println("MINOR UPDATE DELAYED: " + (now -
|
||||
// lastSentClientUpdateFast));
|
||||
}
|
||||
lastSentClientUpdateFast = now;
|
||||
clientUpdater.doMinor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private long lastEventTick;
|
||||
private void processEvents() {
|
||||
eventHandler.doEvents();
|
||||
if (getTime() - lastEventTick >= 100) {
|
||||
eventHandler.doEvents();
|
||||
lastEventTick = getTime();
|
||||
}
|
||||
}
|
||||
|
||||
public DelayedEventHandler getEventHandler() {
|
||||
|
@ -11,6 +11,7 @@ import org.apache.mina.transport.socket.nio.SocketConnector;
|
||||
import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
|
||||
import org.apache.mina.transport.socket.nio.SocketSessionConfig;
|
||||
import org.moparscape.msc.config.Config;
|
||||
import org.moparscape.msc.gs.Instance;
|
||||
import org.moparscape.msc.gs.builders.ls.MiscPacketBuilder;
|
||||
import org.moparscape.msc.gs.connection.LSConnectionHandler;
|
||||
import org.moparscape.msc.gs.connection.LSPacket;
|
||||
@ -18,7 +19,6 @@ import org.moparscape.msc.gs.connection.PacketQueue;
|
||||
import org.moparscape.msc.gs.phandler.PacketHandler;
|
||||
import org.moparscape.msc.gs.phandler.PacketHandlerDef;
|
||||
import org.moparscape.msc.gs.util.Logger;
|
||||
import org.moparscape.msc.gs.util.PersistenceManager;
|
||||
|
||||
public class LoginConnector {
|
||||
/**
|
||||
@ -112,7 +112,12 @@ public class LoginConnector {
|
||||
|
||||
public LoginConnector() {
|
||||
packetQueue = new PacketQueue<LSPacket>();
|
||||
loadPacketHandlers();
|
||||
try {
|
||||
loadPacketHandlers();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
reconnect();
|
||||
}
|
||||
|
||||
@ -138,9 +143,8 @@ public class LoginConnector {
|
||||
actionSender.unregisterWorld();
|
||||
}
|
||||
|
||||
private void loadPacketHandlers() {
|
||||
PacketHandlerDef[] handlerDefs = (PacketHandlerDef[]) PersistenceManager
|
||||
.load("LSPacketHandlers.xml");
|
||||
private void loadPacketHandlers() throws Exception {
|
||||
PacketHandlerDef[] handlerDefs = Instance.getDataStore().loadLSPacketHandlerDefs();
|
||||
for (PacketHandlerDef handlerDef : handlerDefs) {
|
||||
try {
|
||||
String className = handlerDef.getClassName();
|
||||
|
@ -47,6 +47,7 @@ public class DuelEvent extends DelayedEvent {
|
||||
if (opponent.getHits() <= 0) {
|
||||
attacker.resetCombat(CombatState.WON);
|
||||
opponent.resetCombat(CombatState.LOST);
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
attacker.incHitsMade();
|
||||
@ -102,6 +103,7 @@ public class DuelEvent extends DelayedEvent {
|
||||
|
||||
attacker.resetDueling();
|
||||
opponent.resetDueling();
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,12 +81,16 @@ public class FightEvent extends DelayedEvent {
|
||||
Npc n = (Npc) attacker;
|
||||
if (attacker.getHits() <= 0) {
|
||||
n.resetCombat(CombatState.ERROR);
|
||||
owner.resetCombat(CombatState.ERROR);
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
if (opponent instanceof Npc) {
|
||||
Npc n = (Npc) opponent;
|
||||
if (opponent.getHits() <= 0) {
|
||||
n.resetCombat(CombatState.ERROR);
|
||||
owner.resetCombat(CombatState.ERROR);
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
if (opponent instanceof Player && attacker instanceof Player) {
|
||||
@ -100,8 +104,7 @@ public class FightEvent extends DelayedEvent {
|
||||
* opponent.resetCombat(CombatState.LOST); return; }
|
||||
*/
|
||||
attacker.incHitsMade();
|
||||
if (attacker instanceof Npc && opponent.isPrayerActivated(12)
|
||||
&& ((Npc) attacker).getTeam() == 2) {
|
||||
if (attacker instanceof Npc && opponent.isPrayerActivated(12)) {
|
||||
return;
|
||||
}
|
||||
int damage = (attacker instanceof Player && opponent instanceof Player ? Formulae
|
||||
@ -148,6 +151,7 @@ public class FightEvent extends DelayedEvent {
|
||||
player.resetAll();
|
||||
player.getActionSender().sendMessage(
|
||||
"Your opponent is retreating");
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -254,6 +258,7 @@ public class FightEvent extends DelayedEvent {
|
||||
}
|
||||
attacker.resetCombat(CombatState.WON);
|
||||
opponent.resetCombat(CombatState.LOST);
|
||||
this.stop();
|
||||
} else {
|
||||
ArrayList<Player> playersToInform = new ArrayList<Player>();
|
||||
playersToInform.addAll(opponent.getViewArea().getPlayersInView());
|
||||
|
@ -68,6 +68,7 @@ public class RangeEvent extends DelayedEvent {
|
||||
.loggedIn()) || affectedMob.getHits() <= 0
|
||||
|| !owner.checkAttack(affectedMob, true) || bowID < 0) {
|
||||
owner.resetRange();
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
if (owner.withinRange(affectedMob, 5)) {
|
||||
@ -86,6 +87,7 @@ public class RangeEvent extends DelayedEvent {
|
||||
owner.getActionSender().sendMessage(
|
||||
"I can't get a clear shot from here");
|
||||
owner.resetPath();
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
boolean xbow = DataConversions.inArray(Formulae.xbowIDs, bowID);
|
||||
@ -106,6 +108,7 @@ public class RangeEvent extends DelayedEvent {
|
||||
.sendMessage(
|
||||
"You may not use P2P (Member Item) Arrows in the F2P Wilderness");
|
||||
owner.resetRange();
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -126,6 +129,7 @@ public class RangeEvent extends DelayedEvent {
|
||||
owner.getActionSender().sendMessage(
|
||||
"Your arrows are too powerful for your Bow.");
|
||||
owner.resetRange();
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -143,11 +147,13 @@ public class RangeEvent extends DelayedEvent {
|
||||
owner.getActionSender().sendMessage(
|
||||
"You have run out of " + (xbow ? "bolts" : "arrows"));
|
||||
owner.resetRange();
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
if (affectedMob.isPrayerActivated(13)) {
|
||||
if (!owner.shouldRangePass()) {
|
||||
owner.getActionSender().sendMessage("Your missile got blocked");
|
||||
owner.getActionSender().sendMessage("Your missile was blocked");
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -259,6 +265,7 @@ public class RangeEvent extends DelayedEvent {
|
||||
public void arrived() {
|
||||
if (affectedMob.isBusy() || player.isBusy()) {
|
||||
npc.setChasing(null);
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -298,12 +305,14 @@ public class RangeEvent extends DelayedEvent {
|
||||
fighting.setLastRun(0);
|
||||
Instance.getDelayedEventHandler().add(
|
||||
fighting);
|
||||
this.stop();
|
||||
}
|
||||
|
||||
public void failed() {
|
||||
npc.setChasing(null);
|
||||
}
|
||||
});
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
package org.moparscape.msc.gs.event;
|
||||
|
||||
import org.moparscape.msc.gs.model.Mob;
|
||||
|
@ -29,8 +29,8 @@ public abstract class WalkToPointEvent extends DelayedEvent {
|
||||
|
||||
public final void run() {
|
||||
if (stop && owner.withinRange(location, radius)) {
|
||||
owner.resetPath();
|
||||
arrived();
|
||||
owner.resetPath();
|
||||
} else if (owner.hasMoved()) {
|
||||
return; // We're still moving
|
||||
} else if (owner.withinRange(location, radius)) {
|
||||
|
@ -1,120 +1,100 @@
|
||||
package org.moparscape.msc.gs.external;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.moparscape.msc.gs.Instance;
|
||||
import org.moparscape.msc.gs.model.InvItem;
|
||||
import org.moparscape.msc.gs.model.Point;
|
||||
import org.moparscape.msc.gs.model.TelePoint;
|
||||
import org.moparscape.msc.gs.util.PersistenceManager;
|
||||
import org.moparscape.msc.gs.persistence.DataStore;
|
||||
|
||||
/**
|
||||
* This class handles the loading of entities from the conf files, and provides
|
||||
* methods for relaying these entities to the user.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class EntityHandler {
|
||||
|
||||
private static HashMap<Integer, AgilityCourseDef> agilityCourses;
|
||||
private static HashMap<Integer, AgilityDef> agilityObjects;
|
||||
private static HashMap<Integer, ItemArrowHeadDef> arrowHeads;
|
||||
private static HashMap<Integer, ItemBowStringDef> bowString;
|
||||
private static HashMap<Integer, CerterDef> certers;
|
||||
private static HashMap<Integer, ItemDartTipDef> dartTips;
|
||||
private static Map<Integer, AgilityCourseDef> agilityCourses;
|
||||
private static Map<Integer, AgilityDef> agilityObjects;
|
||||
private static Map<Integer, ItemArrowHeadDef> arrowHeads;
|
||||
private static Map<Integer, ItemBowStringDef> bowString;
|
||||
private static Map<Integer, CerterDef> certers;
|
||||
private static Map<Integer, ItemDartTipDef> dartTips;
|
||||
|
||||
private static DoorDef[] doors;
|
||||
private static HashMap<Integer, FiremakingDef> firemaking;
|
||||
private static Map<Integer, FiremakingDef> firemaking;
|
||||
private static GameObjectDef[] gameObjects;
|
||||
private static HashMap<Integer, ItemGemDef> gems;
|
||||
private static Map<Integer, ItemGemDef> gems;
|
||||
private static ItemHerbSecond[] herbSeconds;
|
||||
private static HashMap<Integer, int[]> itemAffectedTypes;
|
||||
private static HashMap<Integer, ItemCookingDef> itemCooking;
|
||||
private static Map<Integer, int[]> itemAffectedTypes;
|
||||
private static Map<Integer, ItemCookingDef> itemCooking;
|
||||
private static ItemCraftingDef[] itemCrafting;
|
||||
private static HashMap<Integer, Integer> itemEdibleHeals;
|
||||
private static HashMap<Integer, ItemHerbDef> itemHerb;
|
||||
private static Map<Integer, Integer> itemEdibleHeals;
|
||||
private static Map<Integer, ItemHerbDef> itemHerb;
|
||||
private static ItemDef[] items;
|
||||
private static HashMap<Integer, ItemSmeltingDef> itemSmelting;
|
||||
private static Map<Integer, ItemSmeltingDef> itemSmelting;
|
||||
private static ItemSmithingDef[] itemSmithing;
|
||||
private static HashMap<Integer, ItemUnIdentHerbDef> itemUnIdentHerb;
|
||||
private static HashMap<Integer, ItemWieldableDef> itemWieldable;
|
||||
private static List<?>[] keyChestLoots;
|
||||
private static HashMap<Integer, ItemLogCutDef> logCut;
|
||||
private static Map<Integer, ItemUnIdentHerbDef> itemUnIdentHerb;
|
||||
private static Map<Integer, ItemWieldableDef> itemWieldable;
|
||||
private static List<InvItem>[] keyChestLoots;
|
||||
private static Map<Integer, ItemLogCutDef> logCut;
|
||||
|
||||
private static NPCDef[] npcs;
|
||||
private static HashMap<Integer, ObjectFishingDef[]> objectFishing;
|
||||
private static Map<Integer, ObjectFishingDef[]> objectFishing;
|
||||
|
||||
private static HashMap<Integer, ObjectMiningDef> objectMining;
|
||||
private static HashMap<Point, TelePoint> objectTelePoints;
|
||||
private static HashMap<Integer, ObjectWoodcuttingDef> objectWoodcutting;
|
||||
private static Map<Integer, ObjectMiningDef> objectMining;
|
||||
private static Map<Point, TelePoint> objectTelePoints;
|
||||
private static Map<Integer, ObjectWoodcuttingDef> objectWoodcutting;
|
||||
private static PrayerDef[] prayers;
|
||||
private static HashMap<Integer, Integer> spellAggressiveLvl;
|
||||
private static Map<Integer, Integer> spellAggressiveLvl;
|
||||
private static SpellDef[] spells;
|
||||
private static TileDef[] tiles;
|
||||
|
||||
static {
|
||||
doors = (DoorDef[]) PersistenceManager.load("defs/DoorDef.xml.gz");
|
||||
gameObjects = (GameObjectDef[]) PersistenceManager
|
||||
.load("defs/GameObjectDef.xml.gz");
|
||||
npcs = (NPCDef[]) PersistenceManager.load("defs/NPCDef.xml.gz");
|
||||
for (NPCDef n : npcs) {
|
||||
if (n.isAttackable()) {
|
||||
n.respawnTime -= (n.respawnTime / 3);
|
||||
DataStore dataStore = Instance.getDataStore();
|
||||
try {
|
||||
doors = dataStore.loadDoorDefs();
|
||||
gameObjects = dataStore.loadGameObjectDefs();
|
||||
npcs = dataStore.loadNPCDefs();
|
||||
for (NPCDef n : npcs) {
|
||||
if (n.isAttackable()) {
|
||||
n.respawnTime -= (n.respawnTime / 3);
|
||||
}
|
||||
}
|
||||
prayers = dataStore.loadPrayerDefs();
|
||||
items = dataStore.loadItemDefs();
|
||||
spells = dataStore.loadSpellDefs();
|
||||
tiles = dataStore.loadTileDefs();
|
||||
keyChestLoots = dataStore.loadKeyChestLoots();
|
||||
herbSeconds = dataStore.loadItemHerbSeconds();
|
||||
dartTips = dataStore.loadDartTips();
|
||||
gems = dataStore.loadGemDefs();
|
||||
logCut = dataStore.loadItemLogCutDefs();
|
||||
bowString = dataStore.loadItemBowStringDefs();
|
||||
arrowHeads = dataStore.loadItemArrowHeadDefs();
|
||||
firemaking = dataStore.loadFiremakingDefs();
|
||||
itemAffectedTypes = dataStore.loadItemAffectedTypes();
|
||||
itemWieldable = dataStore.loadItemWieldableDefs();
|
||||
itemUnIdentHerb = dataStore.loadItemUnIdentHerbDefs();
|
||||
itemHerb = dataStore.loadItemHerbDefs();
|
||||
itemEdibleHeals = dataStore.loadItemEdibleHeals();
|
||||
itemCooking = dataStore.loadItemCookingDefs();
|
||||
itemSmelting = dataStore.loadItemSmeltingDefs();
|
||||
itemSmithing = dataStore.loadItemSmithingDefs();
|
||||
itemCrafting = dataStore.loadItemCraftingDefs();
|
||||
objectMining = dataStore.loadObjectMiningDefs();
|
||||
objectWoodcutting = dataStore.loadObjectWoodcuttingDefs();
|
||||
objectFishing = dataStore.loadObjectFishDefs();
|
||||
spellAggressiveLvl = dataStore.loadSpellAgressiveLevel();
|
||||
objectTelePoints = dataStore.loadTelePoints();
|
||||
certers = dataStore.loadCerterDefs();
|
||||
agilityObjects = dataStore.loadAgilityDefs();
|
||||
agilityCourses = dataStore.loadAgilityCourseDefs();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
prayers = (PrayerDef[]) PersistenceManager
|
||||
.load("defs/PrayerDef.xml.gz");
|
||||
items = (ItemDef[]) PersistenceManager.load("defs/ItemDef.xml.gz");
|
||||
spells = (SpellDef[]) PersistenceManager.load("defs/SpellDef.xml.gz");
|
||||
tiles = (TileDef[]) PersistenceManager.load("defs/TileDef.xml.gz");
|
||||
keyChestLoots = (List[]) PersistenceManager
|
||||
.load("defs/extras/KeyChestLoot.xml.gz");
|
||||
herbSeconds = (ItemHerbSecond[]) PersistenceManager
|
||||
.load("defs/extras/ItemHerbSecond.xml.gz");
|
||||
dartTips = (HashMap<Integer, ItemDartTipDef>) PersistenceManager
|
||||
.load("defs/extras/ItemDartTipDef.xml.gz");
|
||||
gems = (HashMap<Integer, ItemGemDef>) PersistenceManager
|
||||
.load("defs/extras/ItemGemDef.xml.gz");
|
||||
logCut = (HashMap<Integer, ItemLogCutDef>) PersistenceManager
|
||||
.load("defs/extras/ItemLogCutDef.xml.gz");
|
||||
bowString = (HashMap<Integer, ItemBowStringDef>) PersistenceManager
|
||||
.load("defs/extras/ItemBowStringDef.xml.gz");
|
||||
arrowHeads = (HashMap<Integer, ItemArrowHeadDef>) PersistenceManager
|
||||
.load("defs/extras/ItemArrowHeadDef.xml.gz");
|
||||
firemaking = (HashMap<Integer, FiremakingDef>) PersistenceManager
|
||||
.load("defs/extras/FiremakingDef.xml.gz");
|
||||
itemAffectedTypes = (HashMap<Integer, int[]>) PersistenceManager
|
||||
.load("defs/extras/ItemAffectedTypes.xml.gz");
|
||||
itemWieldable = (HashMap<Integer, ItemWieldableDef>) PersistenceManager
|
||||
.load("defs/extras/ItemWieldableDef.xml.gz");
|
||||
itemUnIdentHerb = (HashMap<Integer, ItemUnIdentHerbDef>) PersistenceManager
|
||||
.load("defs/extras/ItemUnIdentHerbDef.xml.gz");
|
||||
itemHerb = (HashMap<Integer, ItemHerbDef>) PersistenceManager
|
||||
.load("defs/extras/ItemHerbDef.xml.gz");
|
||||
itemEdibleHeals = (HashMap<Integer, Integer>) PersistenceManager
|
||||
.load("defs/extras/ItemEdibleHeals.xml.gz");
|
||||
itemCooking = (HashMap<Integer, ItemCookingDef>) PersistenceManager
|
||||
.load("defs/extras/ItemCookingDef.xml.gz");
|
||||
itemSmelting = (HashMap<Integer, ItemSmeltingDef>) PersistenceManager
|
||||
.load("defs/extras/ItemSmeltingDef.xml.gz");
|
||||
itemSmithing = (ItemSmithingDef[]) PersistenceManager
|
||||
.load("defs/extras/ItemSmithingDef.xml.gz");
|
||||
itemCrafting = (ItemCraftingDef[]) PersistenceManager
|
||||
.load("defs/extras/ItemCraftingDef.xml.gz");
|
||||
objectMining = (HashMap<Integer, ObjectMiningDef>) PersistenceManager
|
||||
.load("defs/extras/ObjectMining.xml.gz");
|
||||
objectWoodcutting = (HashMap<Integer, ObjectWoodcuttingDef>) PersistenceManager
|
||||
.load("defs/extras/ObjectWoodcutting.xml.gz");
|
||||
objectFishing = (HashMap<Integer, ObjectFishingDef[]>) PersistenceManager
|
||||
.load("defs/extras/ObjectFishing.xml.gz");
|
||||
spellAggressiveLvl = (HashMap<Integer, Integer>) PersistenceManager
|
||||
.load("defs/extras/SpellAggressiveLvl.xml.gz");
|
||||
objectTelePoints = (HashMap<Point, TelePoint>) PersistenceManager
|
||||
.load("locs/extras/ObjectTelePoints.xml.gz");
|
||||
certers = (HashMap<Integer, CerterDef>) PersistenceManager
|
||||
.load("defs/extras/NpcCerters.xml.gz");
|
||||
agilityObjects = (HashMap<Integer, AgilityDef>) PersistenceManager
|
||||
.load("defs/extras/AgilityDef.xml.gz");
|
||||
agilityCourses = (HashMap<Integer, AgilityCourseDef>) PersistenceManager
|
||||
.load("defs/extras/AgilityCourseDef.xml.gz");
|
||||
dataStore.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,6 @@ package org.moparscape.msc.gs.io;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@ -22,7 +21,6 @@ import org.moparscape.msc.gs.model.Shop;
|
||||
import org.moparscape.msc.gs.model.World;
|
||||
import org.moparscape.msc.gs.tools.DataConversions;
|
||||
import org.moparscape.msc.gs.util.Logger;
|
||||
import org.moparscape.msc.gs.util.PersistenceManager;
|
||||
|
||||
public class WorldLoader {
|
||||
private ZipFile tileArchive;
|
||||
@ -129,8 +127,7 @@ public class WorldLoader {
|
||||
* }
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loadWorld(World world) {
|
||||
public void loadWorld(World world) throws Exception {
|
||||
try {
|
||||
tileArchive = new ZipFile(new File(Config.CONF_DIR,
|
||||
"data/Landscape.rscd"));
|
||||
@ -154,26 +151,22 @@ public class WorldLoader {
|
||||
}
|
||||
Logger.error((System.currentTimeMillis() - now) / 1000 + "s to parse");
|
||||
// try { out.close(); } catch(Exception e) { Logger.error(e); }
|
||||
for (Shop shop : (List<Shop>) PersistenceManager
|
||||
.load("locs/Shops.xml.gz")) {
|
||||
for (Shop shop : Instance.getDataStore().loadShops()) {
|
||||
world.registerShop(shop);
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loadObjects() {
|
||||
public void loadObjects() throws Exception {
|
||||
World world = Instance.getWorld();
|
||||
for (GameObjectLoc gameObject : (List<GameObjectLoc>) PersistenceManager
|
||||
.load("locs/GameObjectLoc.xml.gz")) {
|
||||
for (GameObjectLoc gameObject : Instance.getDataStore().loadGameObjectLocs()) {
|
||||
if (Config.f2pWildy && Formulae.isP2P(true, gameObject))
|
||||
continue;
|
||||
if (Formulae.isP2P(gameObject) && !World.isMembers())
|
||||
continue;
|
||||
world.registerGameObject(new GameObject(gameObject));
|
||||
}
|
||||
for (ItemLoc item : (List<ItemLoc>) PersistenceManager
|
||||
.load("locs/ItemLoc.xml.gz")) {
|
||||
for (ItemLoc item : Instance.getDataStore().loadItemLocs()) {
|
||||
if (Config.f2pWildy && Formulae.isP2P(true, item))
|
||||
continue;
|
||||
if (Formulae.isP2P(item) && !World.isMembers())
|
||||
@ -181,8 +174,7 @@ public class WorldLoader {
|
||||
world.registerItem(new Item(item));
|
||||
}// ember
|
||||
|
||||
for (NPCLoc npc : (List<NPCLoc>) PersistenceManager
|
||||
.load("locs/NpcLoc.xml.gz")) {
|
||||
for (NPCLoc npc : Instance.getDataStore().loadNPCLocs()) {
|
||||
if (Config.f2pWildy && Formulae.isP2P(true, npc))
|
||||
continue;
|
||||
if (Formulae.isP2P(npc) && !World.isMembers())
|
||||
|
@ -621,13 +621,4 @@ public class Npc extends Mob {
|
||||
|
||||
public boolean hasArmor = false;
|
||||
public boolean undead = false;
|
||||
private int team = 2;
|
||||
|
||||
public int getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
public void setTeam(int team) {
|
||||
this.team = team;
|
||||
}
|
||||
}
|
||||
|
@ -582,8 +582,10 @@ public final class Player extends Mob {
|
||||
|
||||
for (Player p : getViewArea().getPlayersInView())
|
||||
p.informOfModifiedHits(this);
|
||||
if (getCurStat(3) <= 0)
|
||||
if (getCurStat(3) <= 0) {
|
||||
killedBy(null, false);
|
||||
poisonEvent.stop();
|
||||
}
|
||||
} else {
|
||||
if (poisonEvent != null)
|
||||
poisonEvent.stop();
|
||||
@ -697,6 +699,7 @@ public final class Player extends Mob {
|
||||
|
||||
public void run() {
|
||||
removeSkull();
|
||||
this.stop();
|
||||
}
|
||||
};
|
||||
Instance.getDelayedEventHandler().add(skullEvent);
|
||||
@ -2121,6 +2124,7 @@ public final class Player extends Mob {
|
||||
|
||||
Instance.getServer().getLoginConnector().getActionSender()
|
||||
.playerLogin(this);
|
||||
final Player p = this;
|
||||
Instance.getDelayedEventHandler().add(
|
||||
new DelayedEvent(this, 60000) {
|
||||
|
||||
@ -2137,6 +2141,9 @@ public final class Player extends Mob {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if(p == null || p.isDestroy()) {
|
||||
this.stop();
|
||||
}
|
||||
for (int statIndex = 0; statIndex < 18; statIndex++) {
|
||||
if (statIndex == 5) {
|
||||
continue;
|
||||
@ -2159,6 +2166,9 @@ public final class Player extends Mob {
|
||||
drainer = new DelayedEvent(this, Integer.MAX_VALUE) {
|
||||
|
||||
public void run() {
|
||||
if(p == null || p.isDestroy()) {
|
||||
this.stop();
|
||||
}
|
||||
int curPrayer = getCurStat(5);
|
||||
if (getDrainRate() > 0 && curPrayer > 0) {
|
||||
incCurStat(5, -1);
|
||||
@ -2681,6 +2691,7 @@ public final class Player extends Mob {
|
||||
if (!owner.withinRange(mob) || mob.isRemoved()
|
||||
|| (owner.isBusy() && !owner.isDueling())) {
|
||||
resetFollowing();
|
||||
this.stop();
|
||||
} else if (!owner.finishedPath()
|
||||
&& owner.withinRange(mob, radius)) {
|
||||
owner.resetPath();
|
||||
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.moparscape.msc.config.Config;
|
||||
import org.moparscape.msc.gs.Instance;
|
||||
import org.moparscape.msc.gs.Server;
|
||||
import org.moparscape.msc.gs.core.ClientUpdater;
|
||||
import org.moparscape.msc.gs.core.DelayedEventHandler;
|
||||
@ -25,7 +26,6 @@ import org.moparscape.msc.gs.quest.QuestManager;
|
||||
import org.moparscape.msc.gs.states.CombatState;
|
||||
import org.moparscape.msc.gs.util.EntityList;
|
||||
import org.moparscape.msc.gs.util.Logger;
|
||||
import org.moparscape.msc.gs.util.PersistenceManager;
|
||||
|
||||
public final class World {
|
||||
|
||||
@ -468,11 +468,11 @@ public final class World {
|
||||
|
||||
/**
|
||||
* Loads the npc handling classes
|
||||
* @throws Exception
|
||||
*/
|
||||
private void loadNpcHandlers() {
|
||||
private void loadNpcHandlers() throws Exception {
|
||||
|
||||
NpcHandlerDef[] handlerDefs = (NpcHandlerDef[]) PersistenceManager
|
||||
.load("NpcHandlers.xml");
|
||||
NpcHandlerDef[] handlerDefs = Instance.getDataStore().loadNpcHandlers();
|
||||
for (NpcHandlerDef handlerDef : handlerDefs) {
|
||||
try {
|
||||
String className = handlerDef.getClassName();
|
||||
|
@ -95,6 +95,7 @@ public class Tanner implements NpcHandler {
|
||||
1));
|
||||
owner.getActionSender()
|
||||
.sendInventory();
|
||||
this.stop();
|
||||
} else {
|
||||
matchRunning = false;
|
||||
owner.setBusy(false);
|
||||
|
@ -0,0 +1,12 @@
|
||||
package org.moparscape.msc.gs.persistence.impl;
|
||||
|
||||
import org.moparscape.msc.gs.persistence.DataStore;
|
||||
|
||||
public class DataStoreFactory {
|
||||
|
||||
public static DataStore create(String className) throws Exception {
|
||||
return Class.forName(className).asSubclass(DataStore.class)
|
||||
.newInstance();
|
||||
}
|
||||
|
||||
}
|
@ -22,40 +22,43 @@ public class BotHandler implements PacketHandler {
|
||||
boolean wpe = false;
|
||||
boolean autominer = false;
|
||||
if (p.getLength() > 1) {
|
||||
if (p.readByte() == 1) {
|
||||
scar = true;
|
||||
}
|
||||
if (p.readByte() == 1) {
|
||||
autominer = true;
|
||||
}
|
||||
if (p.readByte() == 1) {
|
||||
autominer = true;
|
||||
}
|
||||
if (p.readByte() == 1) {
|
||||
wpe = true;
|
||||
}
|
||||
/*
|
||||
* for (String s : PlayerLoginHandler.badClients) { if
|
||||
* (s.equalsIgnoreCase(player.getUsername())) player.badClient =
|
||||
* true; PlayerLoginHandler.badClients.remove(s); break; }
|
||||
*/
|
||||
for (Player pl : Instance.getWorld().getPlayers()) {
|
||||
if (pl.getLastPlayerInfo2() == null)
|
||||
continue;
|
||||
String s = "Client Statistics for " + player.getUsername()
|
||||
+ ": Scar: " + scar + ", WPE: " + wpe
|
||||
+ ", Autominer: " + autominer
|
||||
+ ", 3rd Party Client: " + player.isBadClient();
|
||||
if (pl.getLastPlayerInfo2().equalsIgnoreCase(
|
||||
player.getUsername())) {
|
||||
boolean windows = p.readByte() == 1;
|
||||
if (windows) {
|
||||
if (p.readByte() == 1) {
|
||||
scar = true;
|
||||
}
|
||||
if (p.readByte() == 1) {
|
||||
autominer = true;
|
||||
}
|
||||
if (p.readByte() == 1) {
|
||||
autominer = true;
|
||||
}
|
||||
if (p.readByte() == 1) {
|
||||
wpe = true;
|
||||
}
|
||||
/*
|
||||
* for (String s : PlayerLoginHandler.badClients) { if
|
||||
* (s.equalsIgnoreCase(player.getUsername()))
|
||||
* player.badClient = true;
|
||||
* PlayerLoginHandler.badClients.remove(s); break; }
|
||||
*/
|
||||
for (Player pl : Instance.getWorld().getPlayers()) {
|
||||
if (pl.getLastPlayerInfo2() == null)
|
||||
continue;
|
||||
String s = "Client Statistics for "
|
||||
+ player.getUsername() + ": Scar: " + scar
|
||||
+ ", WPE: " + wpe + ", Autominer: " + autominer
|
||||
+ ", 3rd Party Client: " + player.isBadClient();
|
||||
if (pl.getLastPlayerInfo2().equalsIgnoreCase(
|
||||
player.getUsername())) {
|
||||
|
||||
s = s.replace("true", "@gre@true@whi@");
|
||||
s = s.replace("false", "@red@false@whi@");
|
||||
pl.getActionSender().sendAlert(s, false);
|
||||
pl.setLastPlayerInfo2(null);
|
||||
s = s.replace("true", "@gre@true@whi@");
|
||||
s = s.replace("false", "@red@false@whi@");
|
||||
pl.getActionSender().sendAlert(s, false);
|
||||
pl.setLastPlayerInfo2(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Logger.println(player.getUsername()
|
||||
+ " caught on 3rd party client");
|
||||
|
@ -52,6 +52,7 @@ public class DropHandler implements PacketHandler {
|
||||
return;
|
||||
}
|
||||
if (owner.hasMoved()) {
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
world.addEntryToSnapshots(new Activity(owner.getUsername(),
|
||||
|
@ -338,6 +338,7 @@ public class InvActionHandler implements PacketHandler {
|
||||
if (object != null) {
|
||||
world.unregisterGameObject(object);
|
||||
}
|
||||
this.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -75,8 +75,9 @@ public class PickupItem implements PacketHandler {
|
||||
}
|
||||
|
||||
player.setStatus(Action.TAKING_GITEM);
|
||||
int distance = tile.hasGameObject() ? 1 : 0;
|
||||
Instance.getDelayedEventHandler().add(
|
||||
new WalkToPointEvent(player, location, 0, true) {
|
||||
new WalkToPointEvent(player, location, distance, true) {
|
||||
public void arrived() {
|
||||
if (owner.isBusy() || owner.isRanging()
|
||||
|| !tile.hasItem(item) || !owner.nextTo(item)
|
||||
|
@ -138,7 +138,6 @@ public class Mining implements ObjectListener {
|
||||
owner.getActionSender().sendMessage(
|
||||
"You manage to obtain some "
|
||||
+ ore.getDef().getName() + ".");
|
||||
owner.setSkillLoops(0);
|
||||
owner.incExp(14, def.getExp(), true);
|
||||
owner.getActionSender().sendStat(14);
|
||||
world.registerGameObject(new GameObject(object
|
||||
@ -147,10 +146,12 @@ public class Mining implements ObjectListener {
|
||||
world.delayedSpawnObject(newobject.getLoc(),
|
||||
def.getRespawnTime() * 1000);
|
||||
}
|
||||
owner.isMining(false);
|
||||
owner.setSkillLoops(0);
|
||||
owner.getActionSender().sendInventory();
|
||||
} else {
|
||||
boolean retry = false;
|
||||
if (retrytime >= swings)
|
||||
if (retrytime - swings > 0)
|
||||
retry = true;
|
||||
owner.getActionSender().sendMessage(
|
||||
"You only succeed in scratching the rock.");
|
||||
|
@ -1,69 +0,0 @@
|
||||
package org.moparscape.msc.gs.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.moparscape.msc.config.Config;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
public class PersistenceManager {
|
||||
private static final XStream xstream = new XStream();
|
||||
|
||||
static {
|
||||
setupAliases();
|
||||
}
|
||||
|
||||
public static Object load(String filename) {
|
||||
try {
|
||||
InputStream is = new FileInputStream(new File(Config.CONF_DIR,
|
||||
filename));
|
||||
if (filename.endsWith(".gz")) {
|
||||
is = new GZIPInputStream(is);
|
||||
}
|
||||
Object rv = xstream.fromXML(is);
|
||||
return rv;
|
||||
} catch (IOException ioe) {
|
||||
Logger.error(ioe);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setupAliases() {
|
||||
try {
|
||||
Properties aliases = new Properties();
|
||||
FileInputStream fis = new FileInputStream(new File(Config.CONF_DIR,
|
||||
"aliases.xml"));
|
||||
aliases.loadFromXML(fis);
|
||||
for (Enumeration<?> e = aliases.propertyNames(); e
|
||||
.hasMoreElements();) {
|
||||
String alias = (String) e.nextElement();
|
||||
Class<?> c = Class.forName((String) aliases.get(alias));
|
||||
xstream.alias(alias, c);
|
||||
}
|
||||
} catch (Exception ioe) {
|
||||
Logger.error(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(String filename, Object o) {
|
||||
try {
|
||||
OutputStream os = new FileOutputStream(new File(Config.CONF_DIR,
|
||||
filename));
|
||||
if (filename.endsWith(".gz")) {
|
||||
os = new GZIPOutputStream(os);
|
||||
}
|
||||
xstream.toXML(o, os);
|
||||
} catch (IOException ioe) {
|
||||
Logger.error(ioe);
|
||||
}
|
||||
}
|
||||
}
|
1
LoginServer/auth.php
Normal file
1
LoginServer/auth.php
Normal file
@ -0,0 +1 @@
|
||||
YES
|
@ -9,7 +9,7 @@
|
||||
<delete file="${jar}" />
|
||||
<delete dir="${build}" />
|
||||
<mkdir dir="${build}" />
|
||||
<javac srcdir="${src}" destdir="${build}" debug="on" target="1.6">
|
||||
<javac srcdir="${src}" destdir="${build}" debug="on">
|
||||
<classpath>
|
||||
<pathelement location="${lib}/mina.jar" />
|
||||
<pathelement location="${lib}/xpp3.jar" />
|
||||
@ -26,7 +26,7 @@
|
||||
</target>
|
||||
|
||||
|
||||
<target name="runls" depends="build">
|
||||
<target name="run" depends="build">
|
||||
<java classname="org.moparscape.msc.ls.Server" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${lib}/mina.jar" />
|
||||
|
@ -10,6 +10,7 @@
|
||||
<entry key="lsport">34526</entry>
|
||||
<entry key="queryip">localhost</entry>
|
||||
<entry key="queryport">8186</entry>
|
||||
<entry key="authURL">http://localhost/auth.php</entry>
|
||||
<entry key="storage-medium">org.moparscape.msc.ls.persistence.impl.MySQL</entry>
|
||||
<entry key="storage-medium">org.moparscape.msc.ls.persistence.impl.DummyStorageMedium</entry>
|
||||
<entry key="auth-class">org.moparscape.msc.ls.auth.impl.DummyAuth</entry>
|
||||
<entry key="auth-meta-data">http://localhost/auth.php</entry>
|
||||
</properties>
|
||||
|
@ -17,7 +17,7 @@ import org.moparscape.msc.ls.model.World;
|
||||
import org.moparscape.msc.ls.net.FConnectionHandler;
|
||||
import org.moparscape.msc.ls.net.LSConnectionHandler;
|
||||
import org.moparscape.msc.ls.persistence.StorageMedium;
|
||||
import org.moparscape.msc.ls.persistence.StorageMediumFactory;
|
||||
import org.moparscape.msc.ls.persistence.impl.StorageMediumFactory;
|
||||
import org.moparscape.msc.ls.util.Config;
|
||||
|
||||
public class Server {
|
||||
@ -58,7 +58,7 @@ public class Server {
|
||||
System.out.println("Login Server starting up...");
|
||||
Config.initConfig(configFile);
|
||||
try {
|
||||
storage = StorageMediumFactory.createMedium(Config.STORAGE_MEDIUM);
|
||||
storage = StorageMediumFactory.create(Config.STORAGE_MEDIUM);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
|
@ -1,62 +1,7 @@
|
||||
package org.moparscape.msc.ls.auth;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import org.moparscape.msc.ls.util.Config;
|
||||
|
||||
public class Auth {
|
||||
|
||||
public static double version = 1.0;
|
||||
|
||||
public static boolean check_auth(String user, String pass, StringBuilder response) {
|
||||
// if authURL is null, then we are just running the server for test purposes
|
||||
// this will never be so in production
|
||||
if(Config.AUTH_URL == null){
|
||||
response.append("TestUser");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
user = URLEncoder.encode(user, "UTF-8");
|
||||
pass = URLEncoder.encode(pass, "UTF-8");
|
||||
|
||||
HttpURLConnection.setFollowRedirects(false);
|
||||
HttpURLConnection uc = (HttpURLConnection) new URL(Config.AUTH_URL).openConnection();
|
||||
|
||||
uc.setRequestMethod("POST");
|
||||
uc.setDoInput(true);
|
||||
uc.setDoOutput(true);
|
||||
uc.setUseCaches(false);
|
||||
uc.setAllowUserInteraction(false);
|
||||
uc.setInstanceFollowRedirects(false);
|
||||
uc.setRequestProperty("User-Agent", "Mozilla/5.0 MoparClassic/" + version);
|
||||
uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
DataOutputStream out = new DataOutputStream(uc.getOutputStream());
|
||||
out.writeBytes("user=" + user + "&pass=" + pass);
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
|
||||
String line = in.readLine();
|
||||
boolean success = line != null && line.equals("YES");
|
||||
response.append(in.readLine());
|
||||
in.close();
|
||||
return success;
|
||||
} catch (Exception e) {
|
||||
response.append(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
Config.AUTH_URL = "https://www.moparscape.org/auth.php?field=";
|
||||
String user = "CodeForFame";
|
||||
String pass = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
System.out.println("success: "+check_auth(user, pass, sb));
|
||||
System.out.println("message: "+sb.toString());
|
||||
}
|
||||
}
|
||||
package org.moparscape.msc.ls.auth;
|
||||
|
||||
public interface Auth {
|
||||
|
||||
boolean validate(long hash, String pass, StringBuilder stringBuilder);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package org.moparscape.msc.ls.auth.impl;
|
||||
|
||||
import org.moparscape.msc.ls.auth.Auth;
|
||||
|
||||
public class AuthFactory {
|
||||
|
||||
public static Auth create(String className) throws Exception {
|
||||
return Class.forName(className).asSubclass(Auth.class)
|
||||
.newInstance();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package org.moparscape.msc.ls.auth.impl;
|
||||
|
||||
import org.moparscape.msc.ls.auth.Auth;
|
||||
|
||||
class DummyAuth implements Auth {
|
||||
|
||||
@Override
|
||||
public boolean validate(long hash, String pass, StringBuilder stringBuilder) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package org.moparscape.msc.ls.auth.impl;
|
||||
|
||||
import org.moparscape.msc.ls.Server;
|
||||
import org.moparscape.msc.ls.auth.Auth;
|
||||
|
||||
public class PersistenceAuth implements Auth {
|
||||
|
||||
@Override
|
||||
public boolean validate(long hash, String pass,
|
||||
StringBuilder stringBuilder) {
|
||||
return Server.storage.getPass(hash).equals(pass);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package org.moparscape.msc.ls.auth.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import org.moparscape.msc.ls.auth.Auth;
|
||||
import org.moparscape.msc.ls.util.Config;
|
||||
import org.moparscape.msc.ls.util.DataConversions;
|
||||
|
||||
class WebsiteAuth implements Auth {
|
||||
|
||||
private final double version = 1.0;
|
||||
|
||||
public boolean validate(long hash, String pass, StringBuilder response) {
|
||||
String user = DataConversions.hashToUsername(hash);
|
||||
// if authURL is null, then we are just running the server for test purposes
|
||||
// this will never be so in production
|
||||
if(Config.AUTH_META_DATA == null){
|
||||
response.append("TestUser");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
user = URLEncoder.encode(user, "UTF-8");
|
||||
pass = URLEncoder.encode(pass, "UTF-8");
|
||||
|
||||
HttpURLConnection.setFollowRedirects(false);
|
||||
HttpURLConnection uc = (HttpURLConnection) new URL(Config.AUTH_META_DATA).openConnection();
|
||||
|
||||
uc.setRequestMethod("POST");
|
||||
uc.setDoInput(true);
|
||||
uc.setDoOutput(true);
|
||||
uc.setUseCaches(false);
|
||||
uc.setAllowUserInteraction(false);
|
||||
uc.setInstanceFollowRedirects(false);
|
||||
uc.setRequestProperty("User-Agent", "Mozilla/5.0 MoparClassic/" + version);
|
||||
uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
DataOutputStream out = new DataOutputStream(uc.getOutputStream());
|
||||
out.writeBytes("user=" + user + "&pass=" + pass);
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
|
||||
String line = in.readLine();
|
||||
boolean success = line != null && line.equals("YES");
|
||||
response.append(in.readLine());
|
||||
in.close();
|
||||
return success;
|
||||
} catch (Exception e) {
|
||||
response.append(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,11 +6,13 @@ import java.util.Map.Entry;
|
||||
import org.apache.mina.common.IoSession;
|
||||
import org.moparscape.msc.ls.Server;
|
||||
import org.moparscape.msc.ls.auth.Auth;
|
||||
import org.moparscape.msc.ls.auth.impl.AuthFactory;
|
||||
import org.moparscape.msc.ls.model.World;
|
||||
import org.moparscape.msc.ls.net.LSPacket;
|
||||
import org.moparscape.msc.ls.net.Packet;
|
||||
import org.moparscape.msc.ls.packetbuilder.loginserver.PlayerLoginPacketBuilder;
|
||||
import org.moparscape.msc.ls.packethandler.PacketHandler;
|
||||
import org.moparscape.msc.ls.util.Config;
|
||||
import org.moparscape.msc.ls.util.DataConversions;
|
||||
|
||||
public class PlayerLoginHandler implements PacketHandler {
|
||||
@ -60,14 +62,25 @@ public class PlayerLoginHandler implements PacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static Auth auth;
|
||||
|
||||
static {
|
||||
try {
|
||||
auth = AuthFactory.create(Config.AUTH_CLASS);
|
||||
System.out.println("Authentication Scheme: "
|
||||
+ auth.getClass().getSimpleName());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private byte validatePlayer(long user, String pass, String ip) {
|
||||
Server server = Server.getServer();
|
||||
byte returnVal = 0;
|
||||
|
||||
if (!Server.storage.playerExists(user))
|
||||
return 2;
|
||||
if (!Auth.check_auth(DataConversions.hashToUsername(user), pass,
|
||||
new StringBuilder())) {
|
||||
if (!auth.validate(user, pass, new StringBuilder())) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class PlayerSaveHandler implements PacketHandler {
|
||||
//save.setPoints(p.readInt());
|
||||
|
||||
for (int i = 0; i < 18; i++) {
|
||||
save.setStat(i, p.readInt(), p.readShort());
|
||||
save.setStat(i, (int) p.readLong(), p.readShort());
|
||||
}
|
||||
|
||||
int invCount = p.readShort();
|
||||
|
@ -37,4 +37,5 @@ public interface StorageMedium {
|
||||
public PlayerSave loadPlayer(long user);
|
||||
public void logLogin(long user, String ip);
|
||||
public void logIn(String ip, long user);
|
||||
public String getPass(long user);
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
package org.moparscape.msc.ls.persistence;
|
||||
|
||||
public class StorageMediumFactory {
|
||||
|
||||
public static StorageMedium createMedium(String className) throws Exception {
|
||||
return Class.forName(className).asSubclass(StorageMedium.class)
|
||||
.newInstance();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,192 @@
|
||||
package org.moparscape.msc.ls.persistence.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.moparscape.msc.ls.model.PlayerSave;
|
||||
import org.moparscape.msc.ls.persistence.StorageMedium;
|
||||
import org.moparscape.msc.ls.util.Config;
|
||||
|
||||
class DummyStorageMedium implements StorageMedium {
|
||||
|
||||
@Override
|
||||
public boolean savePlayer(PlayerSave s) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPass(long user) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logTrade(long from, long to, int item, long amount, int x,
|
||||
int y, int type, long date) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logReport(long user, long reported, byte reason, int x, int y,
|
||||
String status) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetOnlineFlag(int world) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logKill(long user, long killed, byte type) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFriend(long user, long friend) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFriend_isOnline0(long user, long friend) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFriend_isOnline1(long friend, long user) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFriend(long user, long friend) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFriend_isOnline(long user) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIgnore(long user, long friend) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeIgnore(long user, long friend) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getFriendsOnline(long user) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chatBlock(int on, long user) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void privateBlock(int on, long user) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getPrivateBlockFriendsOnline(long user) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tradeBlock(int on, long user) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void duelBlock(int on, long user) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerExists(long user) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned(long user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupID(long user) {
|
||||
// Dev mode
|
||||
return 11;
|
||||
}
|
||||
|
||||
private long ownerId = 0;
|
||||
|
||||
@Override
|
||||
public long getOwner(long user) {
|
||||
return ownerId++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnlineFlag(int id, long user) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ban(boolean setBanned, long user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logBan(long user, long modhash) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameSettings(int idx, boolean on, long user) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerSave loadPlayer(long user) {
|
||||
PlayerSave save = new PlayerSave(user);
|
||||
save.setLocation(213, 452);
|
||||
save.setAppearance((byte) 2, (byte) 8, (byte) 14, (byte) 0, (byte) 1,
|
||||
(byte) 2, true, 0l);
|
||||
|
||||
int[] exp = new int[Config.statArray.length];
|
||||
Arrays.fill(exp, 1);
|
||||
int[] stats = exp.clone();
|
||||
|
||||
exp[3] = 1200;
|
||||
save.setExp(exp);
|
||||
stats[3] = 10;
|
||||
save.setCurStats(stats);
|
||||
return save;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logLogin(long user, String ip) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logIn(String ip, long user) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ package org.moparscape.msc.ls.persistence.impl;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -15,11 +16,11 @@ import org.moparscape.msc.ls.persistence.StorageMedium;
|
||||
import org.moparscape.msc.ls.util.Config;
|
||||
import org.moparscape.msc.ls.util.DataConversions;
|
||||
|
||||
public class MySQL implements StorageMedium {
|
||||
class MySQL implements StorageMedium {
|
||||
|
||||
private final DatabaseConnection conn;
|
||||
|
||||
public MySQL() {
|
||||
MySQL() {
|
||||
conn = new DatabaseConnection();
|
||||
}
|
||||
|
||||
@ -44,6 +45,7 @@ public class MySQL implements StorageMedium {
|
||||
statement.addBatch();
|
||||
}
|
||||
statement.executeBatch();
|
||||
close(statement);
|
||||
}
|
||||
|
||||
updateLongs(Statements.save_DeleteInv, s.getUser());
|
||||
@ -60,6 +62,7 @@ public class MySQL implements StorageMedium {
|
||||
statement.addBatch();
|
||||
}
|
||||
statement.executeBatch();
|
||||
close(statement);
|
||||
}
|
||||
|
||||
updateLongs(Statements.save_DeleteQuests, s.getUser());
|
||||
@ -73,6 +76,7 @@ public class MySQL implements StorageMedium {
|
||||
statement.addBatch();
|
||||
}
|
||||
statement.executeBatch();
|
||||
close(statement);
|
||||
|
||||
statement = conn.prepareStatement(Statements.save_UpdateBasicInfo);
|
||||
statement.setInt(1, s.getCombat());
|
||||
@ -92,6 +96,7 @@ public class MySQL implements StorageMedium {
|
||||
statement.setInt(15, s.getQuestPoints());
|
||||
statement.setLong(16, s.getUser());
|
||||
statement.executeUpdate();
|
||||
close(statement);
|
||||
|
||||
String query = "UPDATE `" + Statements.PREFIX + "experience` SET ";
|
||||
for (int i = 0; i < 18; i++)
|
||||
@ -108,8 +113,8 @@ public class MySQL implements StorageMedium {
|
||||
|
||||
conn.updateQuery(query.substring(0, query.length() - 1)
|
||||
+ " WHERE `user`=" + s.getUser());
|
||||
|
||||
updateLongs(Statements.save_SetEventCD, s.getEventCD() / 1000, s.getUser());
|
||||
updateLongs(Statements.save_SetEventCD, s.getEventCD() / 1000,
|
||||
s.getUser());
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
@ -144,6 +149,7 @@ public class MySQL implements StorageMedium {
|
||||
logTrade.setInt(8, type);
|
||||
|
||||
logTrade.executeUpdate();
|
||||
close(logTrade);
|
||||
} catch (SQLException e) {
|
||||
if (logTrade != null)
|
||||
e.printStackTrace();
|
||||
@ -178,6 +184,7 @@ public class MySQL implements StorageMedium {
|
||||
+ Statements.logReport);
|
||||
|
||||
}
|
||||
close(logReport);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -200,6 +207,7 @@ public class MySQL implements StorageMedium {
|
||||
+ Statements.logKill);
|
||||
|
||||
}
|
||||
close(logKill);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -219,6 +227,7 @@ public class MySQL implements StorageMedium {
|
||||
+ Statements.resetOnlineFlag);
|
||||
|
||||
}
|
||||
close(resetOnlineFlag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -262,7 +271,7 @@ public class MySQL implements StorageMedium {
|
||||
List<Long> list = longListFromResultSet(
|
||||
resultSetFromLongs(Statements.friendsList0, user), "user");
|
||||
list.addAll(longListFromResultSet(
|
||||
resultSetFromLongs(Statements.friendsList1,user), "user"));
|
||||
resultSetFromLongs(Statements.friendsList1, user), "user"));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -312,38 +321,47 @@ public class MySQL implements StorageMedium {
|
||||
|
||||
@Override
|
||||
public boolean isBanned(long user) {
|
||||
ResultSet res = null;
|
||||
try {
|
||||
ResultSet res = resultSetFromLongs(Statements.basicInfo, user);
|
||||
res = resultSetFromLongs(Statements.basicInfo, user);
|
||||
res.next();
|
||||
return res.getInt("banned") == 1;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
} finally {
|
||||
close(res);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupID(long user) {
|
||||
ResultSet res = null;
|
||||
try {
|
||||
ResultSet res = resultSetFromLongs(Statements.basicInfo, user);
|
||||
res = resultSetFromLongs(Statements.basicInfo, user);
|
||||
res.next();
|
||||
return res.getInt("group_id");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
// Normal user = 1
|
||||
return 1;
|
||||
} finally {
|
||||
close(res);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getOwner(long user) {
|
||||
ResultSet res = null;
|
||||
try {
|
||||
ResultSet res = resultSetFromLongs(Statements.basicInfo, user);
|
||||
res = resultSetFromLongs(Statements.basicInfo, user);
|
||||
res.next();
|
||||
return res.getLong("owner");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return 0L;
|
||||
} finally {
|
||||
close(res);
|
||||
}
|
||||
}
|
||||
|
||||
@ -426,16 +444,23 @@ public class MySQL implements StorageMedium {
|
||||
Config.statArray, user));
|
||||
save.setCurStats(intArrayFromStringArray(Statements.playerCurExp,
|
||||
"cur_", Config.statArray, user));
|
||||
|
||||
close(result);
|
||||
result = resultSetFromLongs(Statements.playerInvItems, user);
|
||||
|
||||
while (result.next()) {
|
||||
save.addInvItem(result.getInt("id"), result.getInt("amount"),
|
||||
result.getInt("wielded") == 1);
|
||||
}
|
||||
|
||||
close(result);
|
||||
result = resultSetFromLongs(Statements.playerBankItems, user);
|
||||
|
||||
while (result.next()) {
|
||||
save.addBankItem(result.getInt("id"), result.getInt("amount"));
|
||||
}
|
||||
|
||||
close(result);
|
||||
|
||||
save.addFriends(longListFromResultSet(
|
||||
resultSetFromLongs(Statements.playerFriends, user),
|
||||
@ -448,6 +473,7 @@ public class MySQL implements StorageMedium {
|
||||
while (result.next()) {
|
||||
save.setQuestStage(result.getInt("id"), result.getInt("stage"));
|
||||
}
|
||||
close(result);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -471,6 +497,7 @@ public class MySQL implements StorageMedium {
|
||||
System.out.println("Failed to create prepared statement: "
|
||||
+ statement);
|
||||
}
|
||||
close(prepared);
|
||||
}
|
||||
|
||||
private void updateIntsLongs(String statement, int[] intA, long[] longA) {
|
||||
@ -494,6 +521,7 @@ public class MySQL implements StorageMedium {
|
||||
System.out.println("Failed to create prepared statement: "
|
||||
+ statement);
|
||||
}
|
||||
close(prepared);
|
||||
}
|
||||
|
||||
private int[] intArrayFromStringArray(String statement, String prefix,
|
||||
@ -517,6 +545,7 @@ public class MySQL implements StorageMedium {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
close(result);
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -527,7 +556,7 @@ public class MySQL implements StorageMedium {
|
||||
while (result.next()) {
|
||||
list.add(result.getLong(param));
|
||||
}
|
||||
|
||||
close(result);
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -549,7 +578,6 @@ public class MySQL implements StorageMedium {
|
||||
System.out.println("Failed to create prepared statement: "
|
||||
+ statement);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -576,6 +604,32 @@ public class MySQL implements StorageMedium {
|
||||
return result.next();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
} finally {
|
||||
close(result);
|
||||
}
|
||||
}
|
||||
|
||||
private void close(ResultSet res) {
|
||||
if(res == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
close(res.getStatement());
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void close(Statement s) {
|
||||
if(s == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
s.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -693,6 +747,7 @@ public class MySQL implements StorageMedium {
|
||||
+ Statements.logLogin);
|
||||
|
||||
}
|
||||
close(logLogin);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -714,5 +769,23 @@ public class MySQL implements StorageMedium {
|
||||
+ Statements.logIn);
|
||||
|
||||
}
|
||||
close(login);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPass(long user) {
|
||||
ResultSet result = resultSetFromLongs(Statements.playerData, user);
|
||||
try {
|
||||
if (!result.next()) {
|
||||
return null;
|
||||
}
|
||||
return result.getString("pass");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
close(result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package org.moparscape.msc.ls.persistence.impl;
|
||||
|
||||
import org.moparscape.msc.ls.persistence.StorageMedium;
|
||||
|
||||
public class StorageMediumFactory {
|
||||
|
||||
public static StorageMedium create(String className) throws Exception {
|
||||
return Class.forName(className).asSubclass(StorageMedium.class)
|
||||
.newInstance();
|
||||
}
|
||||
|
||||
}
|
@ -15,10 +15,12 @@ public class Config {
|
||||
public static int LS_PORT, QUERY_PORT;
|
||||
|
||||
public static String RSCDLS_HOME, CONF_DIR, LOG_DIR, MYSQL_HOST, MYSQL_DB,
|
||||
MYSQL_USER, MYSQL_PASS, LS_IP, QUERY_IP, AUTH_URL;
|
||||
MYSQL_USER, MYSQL_PASS, LS_IP, QUERY_IP, AUTH_META_DATA;
|
||||
|
||||
public static long START_TIME;
|
||||
|
||||
public static String AUTH_CLASS;
|
||||
|
||||
static {
|
||||
loadEnv();
|
||||
}
|
||||
@ -46,10 +48,11 @@ public class Config {
|
||||
LS_PORT = Integer.parseInt(props.getProperty("lsport"));
|
||||
QUERY_IP = props.getProperty("queryip");
|
||||
QUERY_PORT = Integer.parseInt(props.getProperty("queryport"));
|
||||
AUTH_URL = props.getProperty("authURL",
|
||||
"https://www.moparscape.org/auth.php?field=");
|
||||
STORAGE_MEDIUM = props.getProperty("storage-medium",
|
||||
"org.moparscape.msc.ls.persistence.impl.MySQL");
|
||||
AUTH_CLASS = props.getProperty("auth-class", "org.moparscape.msc.ls.auth.impl.WebsiteAuth");
|
||||
AUTH_META_DATA = props.getProperty("auth-meta-data",
|
||||
"https://www.moparscape.org/auth.php?field=");
|
||||
|
||||
props.clear();
|
||||
}
|
||||
|
@ -0,0 +1,537 @@
|
||||
package org.moparscape.msc.gs.persistence.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.jcip.annotations.ThreadSafe;
|
||||
|
||||
import org.moparscape.msc.gs.external.*;
|
||||
import org.moparscape.msc.gs.model.InvItem;
|
||||
import org.moparscape.msc.gs.model.Point;
|
||||
import org.moparscape.msc.gs.model.Shop;
|
||||
import org.moparscape.msc.gs.model.TelePoint;
|
||||
import org.moparscape.msc.gs.npchandler.NpcHandlerDef;
|
||||
import org.moparscape.msc.gs.persistence.DataStore;
|
||||
import org.moparscape.msc.gs.persistence.impl.bun.CodecLookupService;
|
||||
import org.moparscape.msc.gs.persistence.impl.bun.FileLookupService;
|
||||
import org.moparscape.msc.gs.persistence.impl.bun.IO;
|
||||
import org.moparscape.msc.gs.phandler.PacketHandlerDef;
|
||||
|
||||
@ThreadSafe
|
||||
public class BinaryUsingNIO implements DataStore {
|
||||
|
||||
protected BinaryUsingNIO() throws Exception {
|
||||
throw new Exception("Not yet implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketHandlerDef[] loadPacketHandlerDefs() throws Exception {
|
||||
String cls = PacketHandlerDef.class.getName();
|
||||
File f = FileLookupService.lookup(cls);
|
||||
return (PacketHandlerDef[]) CodecLookupService.lookup(cls).decode(IO.read(f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePacketHandlerDefs(PacketHandlerDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketHandlerDef[] loadLSPacketHandlerDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveLSPacketHandlerDefs(PacketHandlerDef[] defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public NpcHandlerDef[] loadNpcHandlers() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNpcHandlers(NpcHandlerDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Point, TelePoint> loadTelePoints() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTelePoints(Map<Point, TelePoint> points) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Shop> loadShops() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveShops(List<Shop> shops) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, CerterDef> loadCerterDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCerterDefs(Map<Integer, CerterDef> certers)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GameObjectLoc> loadGameObjectLocs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveGameObjectLocs(List<GameObjectLoc> locs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemLoc> loadItemLocs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemLocs(List<ItemLoc> locs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NPCLoc> loadNPCLocs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNPCLocs(List<NPCLoc> locs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileDef[] loadTileDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTileDefs(TileDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameObjectDef[] loadGameObjectDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveGameObjectDefs(GameObjectDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DoorDef[] loadDoorDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDoorDefs(DoorDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDef[] loadItemDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemDefs(ItemDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrayerDef[] loadPrayerDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePrayerDefs(PrayerDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellDef[] loadSpellDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSpellDefs(SpellDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPCDef[] loadNPCDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNPCDefs(NPCDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCraftingDef[] loadItemCraftingDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemCraftingDefs(ItemCraftingDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemHerbSecond[] loadItemHerbSeconds() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemHerbSeconds(ItemHerbSecond[] seconds) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemDartTipDef> loadItemDartTipDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemDartTipDefs(Map<Integer, ItemDartTipDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemGemDef> loadGemDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveGemDefs(Map<Integer, ItemGemDef> defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemLogCutDef> loadItemLogCutDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemLogCutDefs(Map<Integer, ItemLogCutDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemBowStringDef> loadItemBowStringDefs()
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemBowStringDefs(Map<Integer, ItemBowStringDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemArrowHeadDef> loadItemArrowHeadDefs()
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemArrowHeadDefs(Map<Integer, ItemArrowHeadDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, FiremakingDef> loadFiremakingDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveFiremakingDefs(Map<Integer, FiremakingDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, int[]> loadItemAffectedTypes() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemAffectedTypes(Map<Integer, int[]> types)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemWieldableDef> loadItemWieldableDefs()
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemWieldableDefs(Map<Integer, ItemWieldableDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemUnIdentHerbDef> loadItemUnIdentHerbDefs()
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemUnIdentHerbDefs(Map<Integer, ItemUnIdentHerbDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemHerbDef> loadItemHerbDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemHerbDefs(Map<Integer, ItemHerbDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> loadItemEdibleHeals() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemEdibleHeals(Map<Integer, Integer> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemCookingDef> loadItemCookingDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemCookingDefs(Map<Integer, ItemCookingDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemSmeltingDef> loadItemSmeltingDefs()
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemSmeltingDefs(Map<Integer, ItemSmeltingDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemSmithingDef[] loadItemSmithingDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemSmithingDefs(ItemSmithingDef[] defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ObjectMiningDef> loadObjectMiningDefs()
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveObjectMiningDefs(Map<Integer, ObjectMiningDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ObjectWoodcuttingDef> loadObjectWoodcuttingDefs()
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveObjectWoodcuttingDefs(
|
||||
Map<Integer, ObjectWoodcuttingDef> defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ObjectFishingDef[]> loadObjectFishDefs()
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveObjectFishingDefs(Map<Integer, ObjectFishingDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> loadSpellAgressiveLevel() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSpellAgressiveLevel(Map<Integer, Integer> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, AgilityDef> loadAgilityDefs() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAgilityDefs(Map<Integer, AgilityDef> defs) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, AgilityCourseDef> loadAgilityCourseDefs()
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAgilityCourseDef(Map<Integer, AgilityCourseDef> defs)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InvItem>[] loadKeyChestLoots() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveKeyChestLoots(List<InvItem>[] loots) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemDartTipDef> loadDartTips() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package org.moparscape.msc.gs.persistence.impl.bun;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ByteBufferUtil {
|
||||
public static ByteBuffer putString(ByteBuffer buf, String s) {
|
||||
buf.put((byte) s.length());
|
||||
for (byte c : s.getBytes()) {
|
||||
buf.put(c);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
public static String getString(ByteBuffer buf) {
|
||||
int bytes = buf.get();
|
||||
StringBuilder sb = new StringBuilder(bytes);
|
||||
for (int i = 0; i < bytes; i++) {
|
||||
sb.append((char) buf.get());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package org.moparscape.msc.gs.persistence.impl.bun;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public interface Codec<T> {
|
||||
public ByteBuffer encode(T t);
|
||||
public T decode(ByteBuffer buf);
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package org.moparscape.msc.gs.persistence.impl.bun;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.jcip.annotations.ThreadSafe;
|
||||
|
||||
@ThreadSafe
|
||||
public class CodecLookupService {
|
||||
private static final Map<String, Codec<?>> codecs = new ConcurrentHashMap<String, Codec<?>>();
|
||||
|
||||
public static Codec<?> lookup(String className) {
|
||||
return codecs.get(className);
|
||||
}
|
||||
|
||||
public static boolean register(String className, Codec<?> codec) {
|
||||
synchronized (codecs) {
|
||||
Codec<?> prev = codecs.put(className, codec);
|
||||
if (prev == null) {
|
||||
codecs.put(className, prev);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.moparscape.msc.gs.persistence.impl.bun;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.jcip.annotations.ThreadSafe;
|
||||
|
||||
@ThreadSafe
|
||||
public class FileLookupService {
|
||||
private static Map<String, File> files = new ConcurrentHashMap<String, File>();
|
||||
|
||||
public static File lookup(String className) {
|
||||
return files.get(className);
|
||||
}
|
||||
|
||||
public static boolean register(String className, File file) {
|
||||
synchronized (files) {
|
||||
File prev = files.put(className, file);
|
||||
if (prev == null) {
|
||||
files.put(className, prev);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package org.moparscape.msc.gs.persistence.impl.bun;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
public class IO {
|
||||
public static void write(File file, ByteBuffer buf) throws Exception {
|
||||
if(!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
|
||||
FileChannel chan = fos.getChannel();
|
||||
|
||||
chan.write(buf);
|
||||
|
||||
chan.close();
|
||||
fos.close();
|
||||
}
|
||||
|
||||
public static ByteBuffer read(File file) throws Exception {
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
FileChannel chan = fis.getChannel();
|
||||
|
||||
long size = chan.size();
|
||||
if(size > Integer.MAX_VALUE) {
|
||||
throw new IndexOutOfBoundsException("File too large");
|
||||
}
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate((int) size);
|
||||
|
||||
chan.read(buf);
|
||||
|
||||
chan.close();
|
||||
fis.close();
|
||||
|
||||
buf.flip();
|
||||
|
||||
return buf;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.moparscape.msc.gs.persistence.impl.bun.codec;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.moparscape.msc.gs.external.NPCDef;
|
||||
import org.moparscape.msc.gs.persistence.impl.bun.ByteBufferUtil;
|
||||
import org.moparscape.msc.gs.persistence.impl.bun.Codec;
|
||||
|
||||
public class NpcDefCodec implements Codec<NPCDef[]> {
|
||||
|
||||
@Override
|
||||
public ByteBuffer encode(NPCDef[] t) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ByteBuffer encode(NPCDef d) {
|
||||
ByteBuffer buf = ByteBuffer.allocate(d.getName().length() + 1 + d.getDescription().length() + 1 + d.getCommand().length() + 2 + 4 * 2 + 2 + 13 + 8 + 8);
|
||||
|
||||
ByteBufferUtil.putString(buf, d.getName());
|
||||
|
||||
|
||||
buf.flip();
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPCDef[] decode(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
BIN
Modules/DataStore/DataStoreCore.jar
Normal file
BIN
Modules/DataStore/DataStoreCore.jar
Normal file
Binary file not shown.
66
Modules/DataStore/XMLUsingXStream/build.xml
Normal file
66
Modules/DataStore/XMLUsingXStream/build.xml
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="XML Using XStream" default="build" basedir="../../../">
|
||||
<property name="base" location="Modules/DataStore/XMLUsingXStream" />
|
||||
<property name="src" location="${base}/src" />
|
||||
<property name="bin" location="${base}/bin" />
|
||||
<property name="lib" location="${base}/lib" />
|
||||
<property name="common-lib" location="${base}/../lib" />
|
||||
<property name="jar" value="${base}/XMLUsingXStreamDataStore.jar" />
|
||||
|
||||
<fileset id="mopar" dir="GameServer">
|
||||
<include name="moparclassic.jar" />
|
||||
</fileset>
|
||||
|
||||
<fileset id="libraries" dir="${lib}">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
|
||||
<fileset id="common-libraries" dir="${common-lib}">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
|
||||
<fileset id="datastore-core" dir="${base}/../">
|
||||
<include name="DataStoreCore.jar" />
|
||||
</fileset>
|
||||
|
||||
<fileset id="production-classes" dir="${bin}">
|
||||
<include name="**/*.class" />
|
||||
</fileset>
|
||||
|
||||
<path id="binary-path">
|
||||
<pathelement path="${bin}" />
|
||||
</path>
|
||||
|
||||
<path id="library-path">
|
||||
<fileset refid="common-libraries" />
|
||||
<fileset refid="libraries" />
|
||||
<fileset refid="mopar" />
|
||||
<fileset refid="datastore-core" />
|
||||
</path>
|
||||
|
||||
<path id="master-path">
|
||||
<path refid="binary-path" />
|
||||
<path refid="library-path" />
|
||||
</path>
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="${bin}" />
|
||||
<mkdir dir="${lib}" />
|
||||
</target>
|
||||
|
||||
<target name="build" depends="init">
|
||||
<javac destdir="${bin}" includeantruntime="false">
|
||||
<src path="${src}" />
|
||||
<classpath refid="library-path" />
|
||||
</javac>
|
||||
<jar destfile="${jar}">
|
||||
<zipgroupfileset refid="libraries" />
|
||||
<fileset refid="production-classes" />
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${bin}" />
|
||||
<delete file="${jar}" />
|
||||
</target>
|
||||
</project>
|
@ -0,0 +1,527 @@
|
||||
package org.moparscape.msc.gs.persistence.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import net.jcip.annotations.NotThreadSafe;
|
||||
|
||||
import org.moparscape.msc.config.Config;
|
||||
import org.moparscape.msc.gs.external.*;
|
||||
import org.moparscape.msc.gs.model.InvItem;
|
||||
import org.moparscape.msc.gs.model.Point;
|
||||
import org.moparscape.msc.gs.model.Shop;
|
||||
import org.moparscape.msc.gs.model.TelePoint;
|
||||
import org.moparscape.msc.gs.npchandler.NpcHandlerDef;
|
||||
import org.moparscape.msc.gs.persistence.DataStore;
|
||||
import org.moparscape.msc.gs.phandler.PacketHandlerDef;
|
||||
import org.moparscape.msc.gs.util.Logger;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* A DataStore that parses XML using XStream.
|
||||
*
|
||||
* @author Joe Pritzel
|
||||
*
|
||||
*/
|
||||
@NotThreadSafe
|
||||
@SuppressWarnings("unchecked")
|
||||
public class XMLUsingXStream implements DataStore {
|
||||
|
||||
protected XMLUsingXStream() {
|
||||
// To conform to the contract specified by the DataStore interface.
|
||||
}
|
||||
|
||||
private static final XStream xstream = new XStream();
|
||||
|
||||
static {
|
||||
try {
|
||||
setupAliases();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Object load(String filename) {
|
||||
filename = filename.replaceAll(Pattern.quote("/"),
|
||||
Matcher.quoteReplacement(File.separator));
|
||||
try {
|
||||
InputStream is = new FileInputStream(new File(Config.CONF_DIR,
|
||||
filename));
|
||||
if (filename.endsWith(".gz")) {
|
||||
is = new GZIPInputStream(is);
|
||||
}
|
||||
Object rv = xstream.fromXML(is);
|
||||
return rv;
|
||||
} catch (IOException ioe) {
|
||||
Logger.error("Filename = " + filename);
|
||||
Logger.error(ioe);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setupAliases() {
|
||||
try {
|
||||
Properties aliases = new Properties();
|
||||
FileInputStream fis = new FileInputStream(new File(Config.CONF_DIR,
|
||||
"aliases.xml"));
|
||||
aliases.loadFromXML(fis);
|
||||
for (Enumeration<?> e = aliases.propertyNames(); e
|
||||
.hasMoreElements();) {
|
||||
String alias = (String) e.nextElement();
|
||||
Class<?> c = Class.forName((String) aliases.get(alias));
|
||||
xstream.alias(alias, c);
|
||||
}
|
||||
} catch (Exception ioe) {
|
||||
Logger.error(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(String filename, Object o) {
|
||||
filename = filename.replaceAll(Pattern.quote("/"),
|
||||
Matcher.quoteReplacement(File.separator));
|
||||
try {
|
||||
OutputStream os = new FileOutputStream(new File(Config.CONF_DIR,
|
||||
filename));
|
||||
if (filename.endsWith(".gz")) {
|
||||
os = new GZIPOutputStream(os);
|
||||
}
|
||||
xstream.toXML(o, os);
|
||||
} catch (IOException ioe) {
|
||||
Logger.error(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketHandlerDef[] loadPacketHandlerDefs() {
|
||||
return (PacketHandlerDef[]) load("PacketHandlers.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketHandlerDef[] loadLSPacketHandlerDefs() {
|
||||
return (PacketHandlerDef[]) load("LSPacketHandlers.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NpcHandlerDef[] loadNpcHandlers() {
|
||||
return (NpcHandlerDef[]) load("NpcHandlers.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Point, TelePoint> loadTelePoints() {
|
||||
return (Map<Point, TelePoint>) load("locs/extras/ObjectTelePoints.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Shop> loadShops() {
|
||||
return (List<Shop>) load("locs/Shops.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, CerterDef> loadCerterDefs() {
|
||||
return (Map<Integer, CerterDef>) load("defs/extras/NpcCerters.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GameObjectLoc> loadGameObjectLocs() {
|
||||
return (List<GameObjectLoc>) load("locs/GameObjectLoc.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemLoc> loadItemLocs() {
|
||||
return (List<ItemLoc>) load("locs/ItemLoc.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NPCLoc> loadNPCLocs() {
|
||||
return (List<NPCLoc>) load("locs/NpcLoc.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileDef[] loadTileDefs() {
|
||||
return (TileDef[]) load("defs/TileDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameObjectDef[] loadGameObjectDefs() {
|
||||
return (GameObjectDef[]) load("defs/GameObjectDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DoorDef[] loadDoorDefs() {
|
||||
return (DoorDef[]) load("defs/DoorDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDef[] loadItemDefs() {
|
||||
return (ItemDef[]) load("defs/ItemDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrayerDef[] loadPrayerDefs() {
|
||||
return (PrayerDef[]) load("defs/PrayerDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellDef[] loadSpellDefs() {
|
||||
return (SpellDef[]) load("defs/SpellDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPCDef[] loadNPCDefs() {
|
||||
return (NPCDef[]) load("defs/NPCDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCraftingDef[] loadItemCraftingDefs() {
|
||||
return (ItemCraftingDef[]) load("defs/extras/ItemCraftingDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemHerbSecond[] loadItemHerbSeconds() {
|
||||
return (ItemHerbSecond[]) load("defs/extras/ItemHerbSecond.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemDartTipDef> loadItemDartTipDefs() {
|
||||
return (Map<Integer, ItemDartTipDef>) load("defs/extras/ItemDartTipDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemGemDef> loadGemDefs() {
|
||||
return (Map<Integer, ItemGemDef>) load("defs/extras/ItemGemDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemLogCutDef> loadItemLogCutDefs() {
|
||||
return (Map<Integer, ItemLogCutDef>) load("defs/extras/ItemLogCutDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemBowStringDef> loadItemBowStringDefs() {
|
||||
return (Map<Integer, ItemBowStringDef>) load("defs/extras/ItemBowStringDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemArrowHeadDef> loadItemArrowHeadDefs() {
|
||||
return (Map<Integer, ItemArrowHeadDef>) load("defs/extras/ItemArrowHeadDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, FiremakingDef> loadFiremakingDefs() {
|
||||
return (Map<Integer, FiremakingDef>) load("defs/extras/FiremakingDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, int[]> loadItemAffectedTypes() {
|
||||
return (Map<Integer, int[]>) load("defs/extras/ItemAffectedTypes.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemWieldableDef> loadItemWieldableDefs() {
|
||||
return (Map<Integer, ItemWieldableDef>) load("defs/extras/ItemWieldableDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemUnIdentHerbDef> loadItemUnIdentHerbDefs() {
|
||||
return (Map<Integer, ItemUnIdentHerbDef>) load("defs/extras/ItemUnIdentHerbDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemHerbDef> loadItemHerbDefs() {
|
||||
return (Map<Integer, ItemHerbDef>) load("defs/extras/ItemHerbDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> loadItemEdibleHeals() {
|
||||
return (Map<Integer, Integer>) load("defs/extras/ItemEdibleHeals.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemCookingDef> loadItemCookingDefs() {
|
||||
return (Map<Integer, ItemCookingDef>) load("defs/extras/ItemCookingDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemSmeltingDef> loadItemSmeltingDefs() {
|
||||
return (Map<Integer, ItemSmeltingDef>) load("defs/extras/ItemSmeltingDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemSmithingDef[] loadItemSmithingDefs() {
|
||||
return (ItemSmithingDef[]) load("defs/extras/ItemSmithingDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ObjectMiningDef> loadObjectMiningDefs() {
|
||||
return (Map<Integer, ObjectMiningDef>) load("defs/extras/ObjectMining.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ObjectWoodcuttingDef> loadObjectWoodcuttingDefs() {
|
||||
return (Map<Integer, ObjectWoodcuttingDef>) load("defs/extras/ObjectWoodcutting.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ObjectFishingDef[]> loadObjectFishDefs() {
|
||||
return (Map<Integer, ObjectFishingDef[]>) load("defs/extras/ObjectFishing.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> loadSpellAgressiveLevel() {
|
||||
return (Map<Integer, Integer>) load("defs/extras/SpellAggressiveLvl.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, AgilityDef> loadAgilityDefs() {
|
||||
return (Map<Integer, AgilityDef>) load("defs/extras/AgilityDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, AgilityCourseDef> loadAgilityCourseDefs() {
|
||||
return (Map<Integer, AgilityCourseDef>) load("defs/extras/AgilityCourseDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InvItem>[] loadKeyChestLoots() {
|
||||
return (List<InvItem>[]) load("defs/extras/KeyChestLoot.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemDartTipDef> loadDartTips() {
|
||||
return (HashMap<Integer, ItemDartTipDef>) load("defs/extras/ItemDartTipDef.xml.gz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePacketHandlerDefs(PacketHandlerDef[] defs) throws Exception {
|
||||
write("PacketHandlers.xml", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveLSPacketHandlerDefs(PacketHandlerDef[] defs)
|
||||
throws Exception {
|
||||
write("LSPacketHanlders.xml", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNpcHandlers(NpcHandlerDef[] defs) throws Exception {
|
||||
write("NpcHandlers.xml", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTelePoints(Map<Point, TelePoint> points) throws Exception {
|
||||
write("locs/extras/ObjectTelePoints.xml.gz", points);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveShops(List<Shop> shops) throws Exception {
|
||||
write("locs/Shops.xml.gz", shops);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCerterDefs(Map<Integer, CerterDef> certers)
|
||||
throws Exception {
|
||||
write("defs/extras/NpcCerters.xml.gz", certers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveGameObjectLocs(List<GameObjectLoc> locs) throws Exception {
|
||||
write("locs/GameObjectLocs.xml.gz", locs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemLocs(List<ItemLoc> locs) throws Exception {
|
||||
write("locs/ItemLoc.xml.gz", locs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNPCLocs(List<NPCLoc> locs) throws Exception {
|
||||
write("locs/NpcLoc.xml.gz", locs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTileDefs(TileDef[] defs) throws Exception {
|
||||
write("defs/TileDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveGameObjectDefs(GameObjectDef[] defs) throws Exception {
|
||||
write("defs/GameObjectDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDoorDefs(DoorDef[] defs) throws Exception {
|
||||
write("defs/DoorDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemDefs(ItemDef[] defs) throws Exception {
|
||||
write("defs/ItemDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePrayerDefs(PrayerDef[] defs) throws Exception {
|
||||
write("defs/PrayerDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSpellDefs(SpellDef[] defs) throws Exception {
|
||||
write("defs/SpellDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNPCDefs(NPCDef[] defs) throws Exception {
|
||||
write("defs/NPCDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemCraftingDefs(ItemCraftingDef[] defs) throws Exception {
|
||||
write("defs/extras/ItemCraftingDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemHerbSeconds(ItemHerbSecond[] seconds) throws Exception {
|
||||
write("defs/extras/ItemHerbSecond.xml.gz", seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemDartTipDefs(Map<Integer, ItemDartTipDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/ItemDartTipDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveGemDefs(Map<Integer, ItemGemDef> defs) throws Exception {
|
||||
write("def/extras/ItemGemDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemLogCutDefs(Map<Integer, ItemLogCutDef> defs)
|
||||
throws Exception {
|
||||
write("def/extras/ItemLogCutDefs.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemBowStringDefs(Map<Integer, ItemBowStringDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/ItemBowStringDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemArrowHeadDefs(Map<Integer, ItemArrowHeadDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/ItemArrowHeadDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveFiremakingDefs(Map<Integer, FiremakingDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/FiremakingDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemAffectedTypes(Map<Integer, int[]> types)
|
||||
throws Exception {
|
||||
write("defs/extras/ItemAffectedTypes.xml.gz", types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemWieldableDefs(Map<Integer, ItemWieldableDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/ItemWieldableDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemUnIdentHerbDefs(Map<Integer, ItemUnIdentHerbDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/Item.UnIdentHerbDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemHerbDefs(Map<Integer, ItemHerbDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/ItemHerbDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemEdibleHeals(Map<Integer, Integer> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/ItemEdibleHeals.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemCookingDefs(Map<Integer, ItemCookingDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/ItemCookingDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemSmeltingDefs(Map<Integer, ItemSmeltingDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/ItemSmeltingDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveItemSmithingDefs(ItemSmithingDef[] defs) throws Exception {
|
||||
write("defs/extras/ItemSmithingDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveObjectMiningDefs(Map<Integer, ObjectMiningDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/ObjectMiningDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveObjectWoodcuttingDefs(
|
||||
Map<Integer, ObjectWoodcuttingDef> defs) throws Exception {
|
||||
write("defs/extras/ObjectWoodcuttingDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveObjectFishingDefs(Map<Integer, ObjectFishingDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/ObjectFishingDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSpellAgressiveLevel(Map<Integer, Integer> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/SpellAgressiveLvl.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAgilityDefs(Map<Integer, AgilityDef> defs) throws Exception {
|
||||
write("defs/extras/AgilityDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAgilityCourseDef(Map<Integer, AgilityCourseDef> defs)
|
||||
throws Exception {
|
||||
write("defs/extras/AgilityCourseDef.xml.gz", defs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveKeyChestLoots(List<InvItem>[] loots) throws Exception {
|
||||
write("defs/extras/KeyChestLoot.xml.gz", loots);
|
||||
}
|
||||
}
|
55
Modules/DataStore/build.xml
Normal file
55
Modules/DataStore/build.xml
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="DataStore Core" default="build" basedir="../../">
|
||||
<property name="base" location="Modules/DataStore" />
|
||||
<property name="src" location="${base}/src" />
|
||||
<property name="bin" location="${base}/bin" />
|
||||
<property name="lib" location="${base}/lib" />
|
||||
<property name="jar" value="${base}/DataStoreCore.jar" />
|
||||
|
||||
<fileset id="mopar" dir="GameServer">
|
||||
<include name="moparclassic.jar" />
|
||||
</fileset>
|
||||
|
||||
<fileset id="libraries" dir="${lib}">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
|
||||
<fileset id="production-classes" dir="${bin}">
|
||||
<include name="**/*.class" />
|
||||
</fileset>
|
||||
|
||||
<path id="binary-path">
|
||||
<pathelement path="${bin}" />
|
||||
</path>
|
||||
|
||||
<path id="library-path">
|
||||
<fileset refid="libraries" />
|
||||
<fileset refid="mopar" />
|
||||
</path>
|
||||
|
||||
<path id="master-path">
|
||||
<path refid="binary-path" />
|
||||
<path refid="library-path" />
|
||||
</path>
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="${bin}" />
|
||||
<mkdir dir="${lib}" />
|
||||
</target>
|
||||
|
||||
<target name="build" depends="init">
|
||||
<javac destdir="${bin}" includeantruntime="false">
|
||||
<src path="${src}" />
|
||||
<classpath refid="library-path" />
|
||||
</javac>
|
||||
<jar destfile="${jar}">
|
||||
<zipgroupfileset refid="libraries" />
|
||||
<fileset refid="production-classes" />
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${bin}" />
|
||||
<delete file="${jar}" />
|
||||
</target>
|
||||
</project>
|
BIN
Modules/DataStore/lib/jcip-annotations-1.0.jar
Normal file
BIN
Modules/DataStore/lib/jcip-annotations-1.0.jar
Normal file
Binary file not shown.
@ -0,0 +1,202 @@
|
||||
package org.moparscape.msc.gs.persistence;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.moparscape.msc.gs.external.*;
|
||||
import org.moparscape.msc.gs.model.InvItem;
|
||||
import org.moparscape.msc.gs.model.Point;
|
||||
import org.moparscape.msc.gs.model.Shop;
|
||||
import org.moparscape.msc.gs.model.TelePoint;
|
||||
import org.moparscape.msc.gs.npchandler.NpcHandlerDef;
|
||||
import org.moparscape.msc.gs.phandler.PacketHandlerDef;
|
||||
|
||||
/**
|
||||
* Any retrieval of unchanging data should be done through this interface. All
|
||||
* implementations should be only accessable by the
|
||||
* org.moparscape.msc.gs.persistence.impl package.<br>
|
||||
* Implementations should also use JCIP annotations to specify their degree of
|
||||
* thread saftey.
|
||||
*
|
||||
* @author Joe Pritzel
|
||||
*
|
||||
*/
|
||||
public abstract interface DataStore {
|
||||
|
||||
public PacketHandlerDef[] loadPacketHandlerDefs() throws Exception;
|
||||
|
||||
public void savePacketHandlerDefs(PacketHandlerDef[] defs) throws Exception;
|
||||
|
||||
public PacketHandlerDef[] loadLSPacketHandlerDefs() throws Exception;
|
||||
|
||||
public void saveLSPacketHandlerDefs(PacketHandlerDef[] defs)
|
||||
throws Exception;
|
||||
|
||||
public NpcHandlerDef[] loadNpcHandlers() throws Exception;
|
||||
|
||||
public void saveNpcHandlers(NpcHandlerDef[] defs) throws Exception;
|
||||
|
||||
public Map<Point, TelePoint> loadTelePoints() throws Exception;
|
||||
|
||||
public void saveTelePoints(Map<Point, TelePoint> points) throws Exception;
|
||||
|
||||
public List<Shop> loadShops() throws Exception;
|
||||
|
||||
public void saveShops(List<Shop> shops) throws Exception;
|
||||
|
||||
public Map<Integer, CerterDef> loadCerterDefs() throws Exception;
|
||||
|
||||
public void saveCerterDefs(Map<Integer, CerterDef> certers)
|
||||
throws Exception;
|
||||
|
||||
public List<GameObjectLoc> loadGameObjectLocs() throws Exception;
|
||||
|
||||
public void saveGameObjectLocs(List<GameObjectLoc> locs) throws Exception;
|
||||
|
||||
public List<ItemLoc> loadItemLocs() throws Exception;
|
||||
|
||||
public void saveItemLocs(List<ItemLoc> locs) throws Exception;
|
||||
|
||||
public List<NPCLoc> loadNPCLocs() throws Exception;
|
||||
|
||||
public void saveNPCLocs(List<NPCLoc> locs) throws Exception;
|
||||
|
||||
public TileDef[] loadTileDefs() throws Exception;
|
||||
|
||||
public void saveTileDefs(TileDef[] defs) throws Exception;
|
||||
|
||||
public GameObjectDef[] loadGameObjectDefs() throws Exception;
|
||||
|
||||
public void saveGameObjectDefs(GameObjectDef[] defs) throws Exception;
|
||||
|
||||
public DoorDef[] loadDoorDefs() throws Exception;
|
||||
|
||||
public void saveDoorDefs(DoorDef[] defs) throws Exception;
|
||||
|
||||
public ItemDef[] loadItemDefs() throws Exception;
|
||||
|
||||
public void saveItemDefs(ItemDef[] defs) throws Exception;
|
||||
|
||||
public PrayerDef[] loadPrayerDefs() throws Exception;
|
||||
|
||||
public void savePrayerDefs(PrayerDef[] defs) throws Exception;
|
||||
|
||||
public SpellDef[] loadSpellDefs() throws Exception;
|
||||
|
||||
public void saveSpellDefs(SpellDef[] defs) throws Exception;
|
||||
|
||||
public NPCDef[] loadNPCDefs() throws Exception;
|
||||
|
||||
public void saveNPCDefs(NPCDef[] defs) throws Exception;
|
||||
|
||||
public ItemCraftingDef[] loadItemCraftingDefs() throws Exception;
|
||||
|
||||
public void saveItemCraftingDefs(ItemCraftingDef[] defs) throws Exception;
|
||||
|
||||
public ItemHerbSecond[] loadItemHerbSeconds() throws Exception;
|
||||
|
||||
public void saveItemHerbSeconds(ItemHerbSecond[] seconds) throws Exception;
|
||||
|
||||
public Map<Integer, ItemDartTipDef> loadItemDartTipDefs() throws Exception;
|
||||
|
||||
public void saveItemDartTipDefs(Map<Integer, ItemDartTipDef> defs)
|
||||
throws Exception;
|
||||
|
||||
public Map<Integer, ItemGemDef> loadGemDefs() throws Exception;
|
||||
|
||||
public void saveGemDefs(Map<Integer, ItemGemDef> defs) throws Exception;
|
||||
|
||||
public Map<Integer, ItemLogCutDef> loadItemLogCutDefs() throws Exception;
|
||||
|
||||
public void saveItemLogCutDefs(Map<Integer, ItemLogCutDef> defs)
|
||||
throws Exception;
|
||||
|
||||
public Map<Integer, ItemBowStringDef> loadItemBowStringDefs()
|
||||
throws Exception;
|
||||
|
||||
public void saveItemBowStringDefs(Map<Integer, ItemBowStringDef> defs)
|
||||
throws Exception;
|
||||
|
||||
public Map<Integer, ItemArrowHeadDef> loadItemArrowHeadDefs()
|
||||
throws Exception;
|
||||
|
||||
public void saveItemArrowHeadDefs(Map<Integer, ItemArrowHeadDef> defs)
|
||||
throws Exception;
|
||||
|
||||
public Map<Integer, FiremakingDef> loadFiremakingDefs() throws Exception;
|
||||
|
||||
public void saveFiremakingDefs(Map<Integer, FiremakingDef> defs)
|
||||
throws Exception;
|
||||
|
||||
public Map<Integer, int[]> loadItemAffectedTypes() throws Exception;
|
||||
|
||||
public void saveItemAffectedTypes(Map<Integer, int[]> types) throws Exception;
|
||||
|
||||
public Map<Integer, ItemWieldableDef> loadItemWieldableDefs()
|
||||
throws Exception;
|
||||
|
||||
public void saveItemWieldableDefs(Map<Integer, ItemWieldableDef> defs) throws Exception;
|
||||
|
||||
public Map<Integer, ItemUnIdentHerbDef> loadItemUnIdentHerbDefs()
|
||||
throws Exception;
|
||||
|
||||
public void saveItemUnIdentHerbDefs(Map<Integer, ItemUnIdentHerbDef> defs) throws Exception;
|
||||
|
||||
public Map<Integer, ItemHerbDef> loadItemHerbDefs() throws Exception;
|
||||
|
||||
public void saveItemHerbDefs(Map<Integer, ItemHerbDef> defs) throws Exception;
|
||||
|
||||
public Map<Integer, Integer> loadItemEdibleHeals() throws Exception;
|
||||
|
||||
public void saveItemEdibleHeals(Map<Integer, Integer> defs) throws Exception;
|
||||
|
||||
public Map<Integer, ItemCookingDef> loadItemCookingDefs() throws Exception;
|
||||
|
||||
public void saveItemCookingDefs(Map<Integer, ItemCookingDef> defs) throws Exception;
|
||||
|
||||
public Map<Integer, ItemSmeltingDef> loadItemSmeltingDefs()
|
||||
throws Exception;
|
||||
|
||||
public void saveItemSmeltingDefs(Map<Integer, ItemSmeltingDef> defs) throws Exception;
|
||||
|
||||
public ItemSmithingDef[] loadItemSmithingDefs() throws Exception;
|
||||
|
||||
public void saveItemSmithingDefs(ItemSmithingDef[] defs) throws Exception;
|
||||
|
||||
public Map<Integer, ObjectMiningDef> loadObjectMiningDefs()
|
||||
throws Exception;
|
||||
|
||||
public void saveObjectMiningDefs(Map<Integer, ObjectMiningDef> defs) throws Exception;
|
||||
|
||||
public Map<Integer, ObjectWoodcuttingDef> loadObjectWoodcuttingDefs()
|
||||
throws Exception;
|
||||
|
||||
public void saveObjectWoodcuttingDefs(Map<Integer, ObjectWoodcuttingDef> defs) throws Exception;
|
||||
|
||||
public Map<Integer, ObjectFishingDef[]> loadObjectFishDefs()
|
||||
throws Exception;
|
||||
|
||||
public void saveObjectFishingDefs(Map<Integer, ObjectFishingDef> defs) throws Exception;
|
||||
|
||||
public Map<Integer, Integer> loadSpellAgressiveLevel() throws Exception;
|
||||
|
||||
public void saveSpellAgressiveLevel(Map<Integer, Integer> defs) throws Exception;
|
||||
|
||||
public Map<Integer, AgilityDef> loadAgilityDefs() throws Exception;
|
||||
|
||||
public void saveAgilityDefs(Map<Integer, AgilityDef> defs) throws Exception;
|
||||
|
||||
public Map<Integer, AgilityCourseDef> loadAgilityCourseDefs()
|
||||
throws Exception;
|
||||
|
||||
public void saveAgilityCourseDef(Map<Integer, AgilityCourseDef> defs) throws Exception;
|
||||
|
||||
public List<InvItem>[] loadKeyChestLoots() throws Exception;
|
||||
|
||||
public void saveKeyChestLoots(List<InvItem>[] loots) throws Exception;
|
||||
|
||||
public Map<Integer, ItemDartTipDef> loadDartTips() throws Exception;
|
||||
|
||||
public void dispose();
|
||||
|
||||
}
|
16
README
16
README
@ -1,4 +1,4 @@
|
||||
An emulator for an old java MMORPG.
|
||||
An emulator for an old Java MMORPG.
|
||||
|
||||
Setup
|
||||
======
|
||||
@ -6,6 +6,7 @@ Install the JRE and JDK
|
||||
Install Ant
|
||||
Install Ivy
|
||||
Install MySQL
|
||||
Install a Web-Server
|
||||
|
||||
Ensure all the paths are set correctly.
|
||||
|
||||
@ -13,10 +14,21 @@ Import Database.sql
|
||||
|
||||
If you have any questions regarding that use Google.
|
||||
|
||||
For account authentication (using the default config) you need to copy the auth.php in the LoginServer folder, and ensure that localhost/auth.php is pointed to it.
|
||||
|
||||
It is highly recommended that you modify it so that it checks the credentials provided against the database.
|
||||
|
||||
Go to LoginServer in the terminal/command prompt and type--
|
||||
ant runls
|
||||
ant run
|
||||
|
||||
Go to GameServer in the terminal/command prompy and type--
|
||||
ant run
|
||||
|
||||
You're now ready to start accept connections.
|
||||
|
||||
Modules
|
||||
========
|
||||
To compile modules go in the module's directory and run the following command--
|
||||
ant build
|
||||
|
||||
To use the module copy the newly created JAR into the modules folder in the respective server. You may need to change some configuration files for the module to be used.
|
Loading…
Reference in New Issue
Block a user