Moved some variables from Constants to Config, and made them configurable via XML.

This commit is contained in:
CodeForFame 2011-05-16 19:15:24 -05:00
parent 5fc6663ec2
commit bee6a45477
20 changed files with 140 additions and 141 deletions

View File

@ -24,7 +24,13 @@ public class Config {
public static int SERVER_PORT, SERVER_VERSION, MAX_PLAYERS, LS_PORT, SERVER_NUM; public static int SERVER_PORT, SERVER_VERSION, MAX_PLAYERS, LS_PORT, SERVER_NUM;
public static long START_TIME; public static long START_TIME;
public static boolean members, f2pWildy;
public static double expRate, subExpRate;
public static String[] pmods, mods, admins;
static { static {
loadEnv(); loadEnv();
} }
@ -60,8 +66,20 @@ public class Config {
LS_IP = props.getProperty("lsip"); LS_IP = props.getProperty("lsip");
LS_PORT = Integer.parseInt(props.getProperty("lsport")); LS_PORT = Integer.parseInt(props.getProperty("lsport"));
SERVER_NUM = Integer.parseInt(props.getProperty("servernum")); SERVER_NUM = Integer.parseInt(props.getProperty("servernum"));
members = Boolean.parseBoolean(props.getProperty("members", "false"));
f2pWildy = Boolean.parseBoolean(props.getProperty("f2pWildy", "true"));
expRate = Double.parseDouble(props.getProperty("expRate"));
subExpRate = Double.parseDouble(props.getProperty("subExpRate"));
pmods = props.getProperty("pmods").replaceAll(", +", ",").split(",");
mods = props.getProperty("mods").replaceAll(", +", ",").split(",");
admins = props.getProperty("admins").replaceAll(", +", ",").split(",");
props.clear(); props.clear();
Constants.GameServer.MOTD = "@yel@Welcome to @whi@" + Config.SERVER_NAME + "@yel@ - World @whi@" + (Config.SERVER_NUM == 0 ? 2 : Config.SERVER_NUM) + " (" + (Config.members ? "P2P" : "F2P") + ")";
} }
/** /**

View File

@ -13,40 +13,10 @@ public class Constants {
* @category GameServer * @category GameServer
*/ */
public static class GameServer { public static class GameServer {
/**
* Used throughout strings ingame, this is your Server's name.
*/
public static final String SERVER_NAME = "MoparScape Classic";
/**
* Set by runtime arguments. Is this World a Members/Subscriber (P2P)
* world?
*/
public static boolean MEMBER_WORLD = false;
/**
* Is this wilderness fully f2p (no p2p weapons, items etc)
*/
public static boolean F2P_WILDY = true;
/**
* Our World's Number, Gets set upon launch.
*/
public static int WORLD_NUMBER = 0;
/** /**
* Message of the Day (Seen as you log in) * Message of the Day (Seen as you log in)
*/ */
public static String MOTD = ""; public static String MOTD = "";
/**
* Exp Rate multiplier per kill.
*/
public static final double EXP_RATE = 4.0;
/**
* Subscribed Exp Rate multiplier per kill.
*/
public static final double SUB_EXP_RATE = 4.0;
/**
* The amount of players on this server.
*/
public static int ONLINE_COUNT = Instance.getWorld().getPlayers()
.size();
/** /**
* Each time a connection is made to the server, this is incremented. * Each time a connection is made to the server, this is incremented.
*/ */
@ -83,13 +53,6 @@ public class Constants {
public static final int[] NPCS_THAT_DONT_RETREAT = { 65, 102, 100, 127, public static final int[] NPCS_THAT_DONT_RETREAT = { 65, 102, 100, 127,
258 }; 258 };
public static final String[] PMODS = { "There are currently no PMODS" };
public static final String[] MODS = { "Mod Jake", "Mod Robert",
"Mod x0x0", "Mod Andrew", "Mod Trauma", "Mod Andrew",
"Mod Miku" };
public static final String[] ADMINS = { "Mod Necroth", "KO9" };
} }
/** /**
@ -113,7 +76,7 @@ public class Constants {
* Channel for the IRC bot to join * Channel for the IRC bot to join
*/ */
public static final String NICK = "msc_" public static final String NICK = "msc_"
+ (GameServer.MEMBER_WORLD ? "P2P" : "F2P") + "_" + (Config.members ? "P2P" : "F2P") + "_"
+ Formulae.Rand(0, 900); + Formulae.Rand(0, 900);
/** /**
* the login/full name thing IRC wants. [NOT NICKNAME] * the login/full name thing IRC wants. [NOT NICKNAME]

View File

@ -44,23 +44,20 @@ public class Server {
if (args[2] != null && args[2].equalsIgnoreCase("no")) if (args[2] != null && args[2].equalsIgnoreCase("no"))
Constants.IRC.USE_IRC = false; Constants.IRC.USE_IRC = false;
Constants.GameServer.MEMBER_WORLD = args[1].equalsIgnoreCase("p2p");
Constants.GameServer.MOTD = "@yel@Welcome to @whi@" + Constants.GameServer.SERVER_NAME + "@yel@ - World @whi@" + (Constants.GameServer.WORLD_NUMBER == 0 ? 2 : Constants.GameServer.WORLD_NUMBER) + " (" + (Constants.GameServer.MEMBER_WORLD ? "P2P" : "F2P") + ")";
world = Instance.getWorld(); world = Instance.getWorld();
world.wl.loadObjects(); world.wl.loadObjects();
Config.initConfig(configFile); Config.initConfig(configFile);
World.initilizeDB(); World.initilizeDB();
Logger.println(Constants.GameServer.SERVER_NAME + " [" + (Constants.GameServer.MEMBER_WORLD ? "P2P" : "F2P") + "] " + "Server starting up..."); Logger.println(Config.SERVER_NAME + " [" + (Config.members ? "P2P" : "F2P") + "] " + "Server starting up...");
new Server(); new Server();
} }
public static boolean isMembers() { public static boolean isMembers() {
return Constants.GameServer.MEMBER_WORLD; return Config.members;
} }
/** /**
@ -182,7 +179,7 @@ public class Server {
* @throws InterruptedException * @throws InterruptedException
*/ */
public void kill() { public void kill() {
Logger.print(Constants.GameServer.SERVER_NAME + " shutting down..."); Logger.print(Config.SERVER_NAME + " shutting down...");
running = false; running = false;
engine.emptyWorld(); engine.emptyWorld();
connector.kill(); connector.kill();

View File

@ -2,7 +2,7 @@ package org.moparscape.msc.gs.event;
import java.util.ArrayList; import java.util.ArrayList;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
import org.moparscape.msc.gs.core.GameEngine; import org.moparscape.msc.gs.core.GameEngine;
@ -96,7 +96,7 @@ public class RangeEvent extends DelayedEvent {
continue; continue;
} }
arrowID = aID; arrowID = aID;
if(owner.getLocation().inWilderness() && Constants.GameServer.F2P_WILDY) { if(owner.getLocation().inWilderness() && Config.f2pWildy) {
if(arrowID != 11 && arrowID != 190) { if(arrowID != 11 && arrowID != 190) {
owner.getActionSender().sendMessage("You may not use P2P (Member Item) Arrows in the F2P Wilderness"); owner.getActionSender().sendMessage("You may not use P2P (Member Item) Arrows in the F2P Wilderness");
owner.resetRange(); owner.resetRange();

View File

@ -8,7 +8,6 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import org.moparscape.msc.config.Config; import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Constants;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
import org.moparscape.msc.gs.external.EntityHandler; import org.moparscape.msc.gs.external.EntityHandler;
@ -142,14 +141,14 @@ public class WorldLoader {
public void loadObjects() { public void loadObjects() {
World world = Instance.getWorld(); World world = Instance.getWorld();
for (GameObjectLoc gameObject : (List<GameObjectLoc>) PersistenceManager.load("locs/GameObjectLoc.xml.gz")) { for (GameObjectLoc gameObject : (List<GameObjectLoc>) PersistenceManager.load("locs/GameObjectLoc.xml.gz")) {
if(Constants.GameServer.F2P_WILDY && Formulae.isP2P(true, gameObject)) if(Config.f2pWildy && Formulae.isP2P(true, gameObject))
continue; continue;
if (Formulae.isP2P(gameObject) && !World.isMembers()) if (Formulae.isP2P(gameObject) && !World.isMembers())
continue; continue;
world.registerGameObject(new GameObject(gameObject)); world.registerGameObject(new GameObject(gameObject));
} }
for (ItemLoc item : (List<ItemLoc>) PersistenceManager.load("locs/ItemLoc.xml.gz")) { for (ItemLoc item : (List<ItemLoc>) PersistenceManager.load("locs/ItemLoc.xml.gz")) {
if(Constants.GameServer.F2P_WILDY && Formulae.isP2P(true, item)) if(Config.f2pWildy && Formulae.isP2P(true, item))
continue; continue;
if (Formulae.isP2P(item) && !World.isMembers()) if (Formulae.isP2P(item) && !World.isMembers())
continue; continue;
@ -157,7 +156,7 @@ public class WorldLoader {
}// ember }// ember
for (NPCLoc npc : (List<NPCLoc>) PersistenceManager.load("locs/NpcLoc.xml.gz")) { for (NPCLoc npc : (List<NPCLoc>) PersistenceManager.load("locs/NpcLoc.xml.gz")) {
if(Constants.GameServer.F2P_WILDY && Formulae.isP2P(true, npc)) if(Config.f2pWildy && Formulae.isP2P(true, npc))
continue; continue;
if (Formulae.isP2P(npc) && !World.isMembers()) if (Formulae.isP2P(npc) && !World.isMembers())
continue; continue;

View File

@ -1,5 +1,6 @@
package org.moparscape.msc.gs.model; package org.moparscape.msc.gs.model;
import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Constants;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
@ -185,7 +186,7 @@ public class Entity {
} }
public void setLocation(Point p) { public void setLocation(Point p) {
if(this instanceof Player && location != null && Constants.GameServer.F2P_WILDY) { if(this instanceof Player && location != null && Config.f2pWildy) {
Player pl = (Player)this; Player pl = (Player)this;
if(pl != null && getX() > 0 && getY() > 0) { if(pl != null && getX() > 0 && getY() > 0) {
if(!Point.inWilderness(getX(), getY()) && Point.inWilderness(p.getX(), p.getY())) { if(!Point.inWilderness(getX(), getY()) && Point.inWilderness(p.getX(), p.getY())) {

View File

@ -3,6 +3,7 @@ package org.moparscape.msc.gs.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.ConcurrentModificationException; import java.util.ConcurrentModificationException;
import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Constants;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
@ -423,7 +424,7 @@ public class Npc extends Mob {
int hit = DataConversions.random(0, total); int hit = DataConversions.random(0, total);
total = 0; total = 0;
if (!this.getDef().name.equalsIgnoreCase("ghost")) { if (!this.getDef().name.equalsIgnoreCase("ghost")) {
if (this.getCombatLevel() >= 90 && Constants.GameServer.MEMBER_WORLD) { if (this.getCombatLevel() >= 90 && Config.members) {
if (Formulae.Rand(0, 3000) == 500) { if (Formulae.Rand(0, 3000) == 500) {
if (Formulae.Rand(0, 1) == 1) { if (Formulae.Rand(0, 1) == 1) {
world.registerItem(new Item(1276, getX(), getY(), 1, owner)); world.registerItem(new Item(1276, getX(), getY(), 1, owner));

View File

@ -14,6 +14,7 @@ import java.util.TreeMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.mina.common.IoSession; import org.apache.mina.common.IoSession;
import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Constants;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
@ -22,7 +23,6 @@ import org.moparscape.msc.gs.builders.ls.SavePacketBuilder;
import org.moparscape.msc.gs.connection.LSPacket; import org.moparscape.msc.gs.connection.LSPacket;
import org.moparscape.msc.gs.connection.RSCPacket; import org.moparscape.msc.gs.connection.RSCPacket;
import org.moparscape.msc.gs.core.GameEngine; import org.moparscape.msc.gs.core.GameEngine;
import org.moparscape.msc.gs.db.DBConnection;
import org.moparscape.msc.gs.event.DelayedEvent; import org.moparscape.msc.gs.event.DelayedEvent;
import org.moparscape.msc.gs.event.MiniEvent; import org.moparscape.msc.gs.event.MiniEvent;
import org.moparscape.msc.gs.event.RangeEvent; import org.moparscape.msc.gs.event.RangeEvent;
@ -1511,9 +1511,9 @@ public final class Player extends Mob {
return; return;
} }
double exprate = Constants.GameServer.EXP_RATE; double exprate = Config.expRate;
if (isSubscriber()) { if (isSubscriber()) {
exprate = Constants.GameServer.SUB_EXP_RATE; exprate = Config.subExpRate;
} }
if(getLocation().wildernessLevel() > 1) { if(getLocation().wildernessLevel() > 1) {
@ -1741,7 +1741,7 @@ public final class Player extends Mob {
* Restricts P2P stuff in wilderness. * Restricts P2P stuff in wilderness.
*/ */
public void p2pWildy() { public void p2pWildy() {
if (Constants.GameServer.F2P_WILDY) { if (Config.f2pWildy) {
boolean found = false; boolean found = false;
for (InvItem i : getInventory().getItems()) { for (InvItem i : getInventory().getItems()) {

View File

@ -8,7 +8,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.TreeMap; import java.util.TreeMap;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Config;
import org.moparscape.msc.gs.Server; import org.moparscape.msc.gs.Server;
import org.moparscape.msc.gs.core.ClientUpdater; import org.moparscape.msc.gs.core.ClientUpdater;
import org.moparscape.msc.gs.core.DelayedEventHandler; import org.moparscape.msc.gs.core.DelayedEventHandler;
@ -128,7 +128,7 @@ public final class World {
} }
public static boolean isMembers() { public static boolean isMembers() {
return Constants.GameServer.MEMBER_WORLD; return Config.members;
} }
public WorldLoader wl; public WorldLoader wl;
/** /**

View File

@ -1,6 +1,7 @@
package org.moparscape.msc.gs.phandler; package org.moparscape.msc.gs.phandler;
import org.apache.mina.common.IoSession; import org.apache.mina.common.IoSession;
import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Constants;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
@ -230,7 +231,7 @@ public class PlayerLogin implements PacketHandler {
sender.sendOnlinePlayers(); sender.sendOnlinePlayers();
if(newchar) if(newchar)
player.getActionSender().sendMessage("@ran@Talk to the Community Instructor for information about " + Constants.GameServer.SERVER_NAME); player.getActionSender().sendMessage("@ran@Talk to the Community Instructor for information about " + Config.SERVER_NAME);
if (player.clientWarn()) { if (player.clientWarn()) {
player.getActionSender().sendAlert("@red@Alert! @whi@You are using an old client, please download the new client from our website. This client WILL stop working @red@soon.", false); player.getActionSender().sendAlert("@red@Alert! @whi@You are using an old client, please download the new client from our website. This client WILL stop working @red@soon.", false);

View File

@ -1,7 +1,7 @@
package org.moparscape.msc.gs.phandler.client; package org.moparscape.msc.gs.phandler.client;
import org.apache.mina.common.IoSession; import org.apache.mina.common.IoSession;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
import org.moparscape.msc.gs.connection.Packet; import org.moparscape.msc.gs.connection.Packet;
@ -152,7 +152,7 @@ public class AttackHandler implements PacketHandler {
player.resetPath(); player.resetPath();
return; return;
} }
if(Constants.GameServer.F2P_WILDY && player.getLocation().inWilderness()) { if(Config.f2pWildy && player.getLocation().inWilderness()) {
for(InvItem i : player.getInventory().getItems()) { for(InvItem i : player.getInventory().getItems()) {
if(i.getID() == 638 || i.getID() == 640 || i.getID() == 642 || i.getID() == 644 || i.getID() == 646) { if(i.getID() == 638 || i.getID() == 640 || i.getID() == 642 || i.getID() == 644 || i.getID() == 646) {

View File

@ -1,7 +1,7 @@
package org.moparscape.msc.gs.phandler.client; package org.moparscape.msc.gs.phandler.client;
import org.apache.mina.common.IoSession; import org.apache.mina.common.IoSession;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Config;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
import org.moparscape.msc.gs.Server; import org.moparscape.msc.gs.Server;
import org.moparscape.msc.gs.connection.Packet; import org.moparscape.msc.gs.connection.Packet;
@ -42,7 +42,7 @@ public class InvActionHandler implements PacketHandler {
player.setSuspiciousPlayer(true); player.setSuspiciousPlayer(true);
return; return;
} }
if(item.getDef().isMembers() && Constants.GameServer.F2P_WILDY && player.getLocation().inWilderness() && item.getID() != 814) { if(item.getDef().isMembers() && Config.f2pWildy && player.getLocation().inWilderness() && item.getID() != 814) {
player.getActionSender().sendMessage("Can not use a Member item in the wilderness"); player.getActionSender().sendMessage("Can not use a Member item in the wilderness");
return; return;
} }

View File

@ -1,7 +1,7 @@
package org.moparscape.msc.gs.phandler.client; package org.moparscape.msc.gs.phandler.client;
import org.apache.mina.common.IoSession; import org.apache.mina.common.IoSession;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
import org.moparscape.msc.gs.Server; import org.moparscape.msc.gs.Server;
@ -36,7 +36,7 @@ public class InvUseOnItem implements PacketHandler {
private boolean attachFeathers(Player player, final InvItem feathers, final InvItem item) { private boolean attachFeathers(Player player, final InvItem feathers, final InvItem item) {
int amount = 10; int amount = 10;
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender().sendMessage("This feature is not avaliable in f2p"); player.getActionSender().sendMessage("This feature is not avaliable in f2p");
return true; return true;
} }
@ -89,7 +89,7 @@ public class InvUseOnItem implements PacketHandler {
private boolean doArrowHeads(Player player, final InvItem headlessArrows, final InvItem arrowHeads) { private boolean doArrowHeads(Player player, final InvItem headlessArrows, final InvItem arrowHeads) {
final ItemArrowHeadDef headDef = EntityHandler.getItemArrowHeadDef(arrowHeads.getID()); final ItemArrowHeadDef headDef = EntityHandler.getItemArrowHeadDef(arrowHeads.getID());
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender().sendMessage("This feature is not avaliable in f2p"); player.getActionSender().sendMessage("This feature is not avaliable in f2p");
return true; return true;
} }
@ -125,7 +125,7 @@ public class InvUseOnItem implements PacketHandler {
private boolean doBowString(Player player, final InvItem bowString, final InvItem bow) { private boolean doBowString(Player player, final InvItem bowString, final InvItem bow) {
final ItemBowStringDef stringDef = EntityHandler.getItemBowStringDef(bow.getID()); final ItemBowStringDef stringDef = EntityHandler.getItemBowStringDef(bow.getID());
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender().sendMessage("This feature is not avaliable in f2p"); player.getActionSender().sendMessage("This feature is not avaliable in f2p");
return true; return true;
} }
@ -180,7 +180,7 @@ public class InvUseOnItem implements PacketHandler {
if (glass.getID() != 623) { if (glass.getID() != 623) {
return false; return false;
} }
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender().sendMessage("This feature is not avaliable in f2p"); player.getActionSender().sendMessage("This feature is not avaliable in f2p");
return true; return true;
} }
@ -254,7 +254,7 @@ public class InvUseOnItem implements PacketHandler {
if (herbDef == null) { if (herbDef == null) {
return false; return false;
} }
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender().sendMessage("This feature is not avaliable in f2p"); player.getActionSender().sendMessage("This feature is not avaliable in f2p");
return true; return true;
} }
@ -277,7 +277,7 @@ public class InvUseOnItem implements PacketHandler {
} }
private boolean doHerbSecond(Player player, final InvItem second, final InvItem unfinished, final ItemHerbSecond def) { private boolean doHerbSecond(Player player, final InvItem second, final InvItem unfinished, final ItemHerbSecond def) {
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender().sendMessage("This feature is not avaliable in f2p"); player.getActionSender().sendMessage("This feature is not avaliable in f2p");
return true; return true;
} }
@ -304,7 +304,7 @@ public class InvUseOnItem implements PacketHandler {
private boolean doLogCut(final Player player, final InvItem knife, final InvItem log, int times) { private boolean doLogCut(final Player player, final InvItem knife, final InvItem log, int times) {
final int retries = --times; final int retries = --times;
final ItemLogCutDef cutDef = EntityHandler.getItemLogCutDef(log.getID()); final ItemLogCutDef cutDef = EntityHandler.getItemLogCutDef(log.getID());
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender().sendMessage("This feature is not avaliable in f2p"); player.getActionSender().sendMessage("This feature is not avaliable in f2p");
return true; return true;
} }
@ -810,7 +810,7 @@ public class InvUseOnItem implements PacketHandler {
for (int i = 0; i < combinePotions.length; i++) { for (int i = 0; i < combinePotions.length; i++) {
if ((item1.getID() == combinePotions[i][0] && item2.getID() == combinePotions[i][1]) || (item2.getID() == combinePotions[i][0] && item1.getID() == combinePotions[i][1])) { if ((item1.getID() == combinePotions[i][0] && item2.getID() == combinePotions[i][1]) || (item2.getID() == combinePotions[i][0] && item1.getID() == combinePotions[i][1])) {
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender().sendMessage("This feature is not avaliable in f2p"); player.getActionSender().sendMessage("This feature is not avaliable in f2p");
return; return;
} }
@ -821,7 +821,7 @@ public class InvUseOnItem implements PacketHandler {
return; return;
} }
} else if (item1.getID() == combinePotions[i][1] && item2.getID() == combinePotions[i][1]) { } else if (item1.getID() == combinePotions[i][1] && item2.getID() == combinePotions[i][1]) {
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender().sendMessage("This feature is not avaliable in f2p"); player.getActionSender().sendMessage("This feature is not avaliable in f2p");
return; return;
} }
@ -835,7 +835,7 @@ public class InvUseOnItem implements PacketHandler {
player.getActionSender().sendMessage("You combine the Potions"); player.getActionSender().sendMessage("You combine the Potions");
return; return;
} else if (item1.getID() == combinePotions[i][0] && item2.getID() == combinePotions[i][0]) { } else if (item1.getID() == combinePotions[i][0] && item2.getID() == combinePotions[i][0]) {
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender().sendMessage("This feature is not avaliable in f2p"); player.getActionSender().sendMessage("This feature is not avaliable in f2p");
return; return;
} }

View File

@ -3,7 +3,7 @@ package org.moparscape.msc.gs.phandler.client;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.mina.common.IoSession; import org.apache.mina.common.IoSession;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
import org.moparscape.msc.gs.Server; import org.moparscape.msc.gs.Server;
@ -127,7 +127,7 @@ public class ObjectAction implements PacketHandler {
} }
world.addEntryToSnapshots(new Activity(owner.getUsername(), owner.getUsername() + " used an Object (" + object.getID() + ") @ " + object.getX() + ", " + object.getY())); world.addEntryToSnapshots(new Activity(owner.getUsername(), owner.getUsername() + " used an Object (" + object.getID() + ") @ " + object.getX() + ", " + object.getY()));
owner.resetAll(); owner.resetAll();
if (object.getX() == 621 && object.getY() == 596 && Constants.GameServer.F2P_WILDY) { if (object.getX() == 621 && object.getY() == 596 && Config.f2pWildy) {
owner.getActionSender().sendMessage("Currently disabled!1!"); owner.getActionSender().sendMessage("Currently disabled!1!");
return; return;
} }

View File

@ -3,12 +3,12 @@ package org.moparscape.msc.gs.phandler.client;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.mina.common.IoSession; import org.apache.mina.common.IoSession;
import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Constants;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
@ -1037,14 +1037,14 @@ public class SpellHandler implements PacketHandler {
|| spell.getReqLevel() == 65 || spell.getReqLevel() == 65
|| spell.getReqLevel() == 70 || spell.getReqLevel() == 70
|| spell.getReqLevel() == 75) { || spell.getReqLevel() == 75) {
if (!Constants.GameServer.MEMBER_WORLD) { if (!Config.members) {
player.getActionSender() player.getActionSender()
.sendMessage( .sendMessage(
"Must be on a members server to use this"); "Must be on a members server to use this");
return; return;
} }
if (player.getLocation().inWilderness() if (player.getLocation().inWilderness()
&& Constants.GameServer.F2P_WILDY) { && Config.f2pWildy) {
player.getActionSender() player.getActionSender()
.sendMessage( .sendMessage(
"You can not cast this Members spell in F2P Wilderness"); "You can not cast this Members spell in F2P Wilderness");

View File

@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.mina.common.IoSession; import org.apache.mina.common.IoSession;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
import org.moparscape.msc.gs.connection.Packet; import org.moparscape.msc.gs.connection.Packet;
@ -46,7 +46,7 @@ public class WieldHandler implements PacketHandler {
player.setSuspiciousPlayer(true); player.setSuspiciousPlayer(true);
return; return;
} }
if(player.getLocation().inWilderness() && item.getDef().isMembers() && Constants.GameServer.F2P_WILDY) { if(player.getLocation().inWilderness() && item.getDef().isMembers() && Config.f2pWildy) {
player.getActionSender().sendMessage("Can't wield a P2P item in wilderness"); player.getActionSender().sendMessage("Can't wield a P2P item in wilderness");
return; return;
} }
@ -91,7 +91,7 @@ public class WieldHandler implements PacketHandler {
player.getActionSender().sendMessage("You must have at least " + youNeed.substring(0, youNeed.length() - 2) + " to use this item."); player.getActionSender().sendMessage("You must have at least " + youNeed.substring(0, youNeed.length() - 2) + " to use this item.");
return; return;
} }
if (Constants.GameServer.MEMBER_WORLD) { if (Config.members) {
if (item.getID() == 594) { if (item.getID() == 594) {
int count = 0; int count = 0;
for (Quest q : World.getQuestManager().getQuests()) { for (Quest q : World.getQuestManager().getQuests()) {

View File

@ -2,7 +2,7 @@ package org.moparscape.msc.gs.plugins.ai;
import java.util.ArrayList; import java.util.ArrayList;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Config;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
import org.moparscape.msc.gs.event.ObjectRemover; import org.moparscape.msc.gs.event.ObjectRemover;
import org.moparscape.msc.gs.model.GameObject; import org.moparscape.msc.gs.model.GameObject;
@ -51,7 +51,7 @@ public class RedDragon extends NpcScript implements NpcAI {
@Override @Override
public void onNpcDeath(Npc npc, Player player) { public void onNpcDeath(Npc npc, Player player) {
if(npc.getLocation().atAltar()) { if(npc.getLocation().atAltar()) {
if(Constants.GameServer.F2P_WILDY) { if(Config.f2pWildy) {
switch(DataConversions.random(0, 3)) { switch(DataConversions.random(0, 3)) {
case 0: { case 0: {
if(DataConversions.random(0, 2000) < 4) { // Drop d med if(DataConversions.random(0, 2000) < 4) { // Drop d med

View File

@ -6,64 +6,73 @@ import java.util.Date;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
import org.moparscape.msc.gs.model.World; import org.moparscape.msc.gs.model.World;
public class Logger { public class Logger {
/** /**
* World instance * World instance
*/ */
private static final World world = Instance.getWorld(); private static final World world = Instance.getWorld();
/** /**
* Simple date formatter to keep a date on outputs * Simple date formatter to keep a date on outputs
*/ */
private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); private static SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy.MM.dd HH:mm:ss");
public static void connection(Object o) {
// Logging.debug(o.toString());
}
public static void error(Object o) { public static void connection(Object o) {
if (o instanceof Exception) { // Logging.debug(o.toString());
Exception e = (Exception) o;
e.printStackTrace();
if (world == null || !Instance.getServer().isInitialized()) {
System.exit(1);
} else {
Instance.getServer().kill();
}
return;
} }
if (o.toString() != null)
Instance.getServer().getLoginConnector().getActionSender().logAction(o.toString(), 2);
}
public static void event(Object o) { public static void error(Object o) {
Instance.getServer().getLoginConnector().getActionSender().logAction(o.toString(), 1); if (o instanceof Exception) {
} Exception e = (Exception) o;
e.printStackTrace();
if (world == null || !Instance.getServer().isInitialized()) {
System.exit(1);
} else {
Instance.getServer().kill();
}
return;
}
}
public static void mod(Object o) { public static void event(Object o) {
Instance.getServer().getLoginConnector().getActionSender().logAction(o.toString(), 3); Instance.getServer().getLoginConnector().getActionSender()
} .logAction(o.toString(), 1);
/** }
* Sends s to loginserver and prints to stdout
* @param s public static void mod(Object o) {
*/ Instance.getServer().getLoginConnector().getActionSender()
public static void systemerr(String s) { .logAction(o.toString(), 3);
Instance.getServer().getLoginConnector().getActionSender().logAction(s, 4); }
print(s);
} /**
/** * Sends s to loginserver and prints to stdout
* Prints to console with timestamp *
* @param o Object to print * @param s
*/ */
public static void print(Object o) { public static void systemerr(String s) {
System.out.print(formatter.format(new Date()) + " " + o.toString()); Instance.getServer().getLoginConnector().getActionSender()
} .logAction(s, 4);
/** print(s);
* Prints to console with timestamp and newline }
* @param o Object to print
*/ /**
public static void println(Object o) { * Prints to console with timestamp
System.out.println(formatter.format(new Date()) + " " + o.toString()); *
} * @param o
* Object to print
*/
public static void print(Object o) {
System.out.print(formatter.format(new Date()) + " " + o.toString());
}
/**
* Prints to console with timestamp and newline
*
* @param o
* Object to print
*/
public static void println(Object o) {
System.out.println(formatter.format(new Date()) + " " + o.toString());
}
} }

View File

@ -15,4 +15,14 @@
<entry key="mysqlpass"></entry> <entry key="mysqlpass"></entry>
<entry key="mysqlhost">localhost</entry> <entry key="mysqlhost">localhost</entry>
<entry key="mysqldb">moparclassic</entry> <entry key="mysqldb">moparclassic</entry>
<entry key="members">false</entry>
<entry key="f2pwildy">true</entry>
<entry key="expRate">4.0</entry>
<entry key="subExpRate">4.0</entry>
<!-- Separate names by commas -->
<entry key="pmods">None</entry>
<entry key="mods">None</entry>
<entry key="admins">None</entry>
</properties> </properties>

View File

@ -10,5 +10,5 @@
<entry key="lsport">34526</entry> <entry key="lsport">34526</entry>
<entry key="queryip">localhost</entry> <entry key="queryip">localhost</entry>
<entry key="queryport">8186</entry> <entry key="queryport">8186</entry>
<entry key="authURL">https://www.moparscape.org/auth.php?field=rscnam</entry> <entry key="authURL">http://localhost/auth.php</entry>
</properties> </properties>