Riizade/config file (#520)

* added POJO + yaml file

* made config members public

* switched to yaml

* modified files to use YamlConfig over ServerConstants

* removed constants from ServerConstants

* removed unused imports

* removed unused import

* removed world ini

* removed now unused .ini files

* fixed docker-launch.sh

* added jackson dependency JARs

* fixed errors

* removed unused server config values, added world defaults

* don't use env variables for docker

* fixed package imports/specifiers for js files
This commit is contained in:
Adam James-Liebau Johnson
2019-09-20 20:49:24 -03:00
committed by Ronan Lana
parent e169971384
commit 181573dc74
163 changed files with 1531 additions and 1113 deletions
+3 -1
View File
@@ -28,6 +28,8 @@ import java.util.HashSet;
import java.util.Calendar;
import java.util.concurrent.atomic.AtomicLong;
import config.ServerConfig;
import config.YamlConfig;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;
@@ -188,7 +190,7 @@ public class MapleServerHandler extends IoHandlerAdapter {
short packetId = slea.readShort();
MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
if(ServerConstants.USE_DEBUG_SHOW_RCVD_PACKET && !ignoredDebugRecvPackets.contains(packetId)) System.out.println("Received packet id " + packetId);
if(YamlConfig.config.server.USE_DEBUG_SHOW_RCVD_PACKET && !ignoredDebugRecvPackets.contains(packetId)) System.out.println("Received packet id " + packetId);
final MaplePacketHandler packetHandler = processor.getHandler(packetId);
if (packetHandler != null && packetHandler.validateState(client)) {
try {
+2 -1
View File
@@ -21,6 +21,7 @@
*/
package net.mina;
import config.YamlConfig;
import constants.ServerConstants;
import client.MapleClient;
import constants.OpcodeConstants;
@@ -75,7 +76,7 @@ public class MaplePacketDecoder extends CumulativeProtocolDecoder {
rcvdCrypto.crypt(decryptedPacket);
MapleCustomEncryption.decryptData(decryptedPacket);
out.write(decryptedPacket);
if (ServerConstants.USE_DEBUG_SHOW_PACKET){ // packet traffic log: Atoot's idea, applied using auto-identation thanks to lrenex
if (YamlConfig.config.server.USE_DEBUG_SHOW_PACKET){ // packet traffic log: Atoot's idea, applied using auto-identation thanks to lrenex
int packetLen = decryptedPacket.length;
int pHeader = readFirstShort(decryptedPacket);
String pHeaderStr = Integer.toHexString(pHeader).toUpperCase();
+2 -1
View File
@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.mina;
import config.YamlConfig;
import constants.ServerConstants;
import client.MapleClient;
import constants.OpcodeConstants;
@@ -46,7 +47,7 @@ public class MaplePacketEncoder implements ProtocolEncoder {
try {
final MapleAESOFB send_crypto = client.getSendCrypto();
final byte[] input = (byte[]) message;
if (ServerConstants.USE_DEBUG_SHOW_PACKET) {
if (YamlConfig.config.server.USE_DEBUG_SHOW_PACKET) {
int packetLen = input.length;
int pHeader = readFirstShort(input);
String pHeaderStr = Integer.toHexString(pHeader).toUpperCase();
+49 -73
View File
@@ -46,6 +46,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import config.YamlConfig;
import net.server.audit.ThreadTracker;
import net.server.audit.locks.MonitoredLockType;
import net.server.audit.locks.MonitoredReentrantReadWriteLock;
@@ -170,7 +171,7 @@ public class Server {
}
public void updateCurrentTime() {
serverCurrentTime = currentTime.addAndGet(ServerConstants.UPDATE_INTERVAL);
serverCurrentTime = currentTime.addAndGet(YamlConfig.config.server.UPDATE_INTERVAL);
}
public long forceUpdateCurrentTime() {
@@ -342,18 +343,13 @@ public class Server {
if(worldChannels == null) return -3;
int channelid = worldChannels.size();
if(channelid >= ServerConstants.CHANNEL_SIZE) return -2;
Properties p = loadWorldINI();
if(p == null) {
return -1;
}
if(channelid >= YamlConfig.config.server.CHANNEL_SIZE) return -2;
channelid++;
World world = this.getWorld(worldid);
Channel channel = new Channel(worldid, channelid, getCurrentTime());
channel.setServerMessage(p.getProperty("whyamirecommended" + worldid));
channel.setServerMessage(YamlConfig.config.worlds.get(worldid).why_am_i_recommended);
world.addChannel(channel);
worldChannels.put(channelid, channel.getIP());
@@ -365,10 +361,7 @@ public class Server {
}
public int addWorld() {
Properties p = loadWorldINI();
if(p == null) return -2;
int newWorld = initWorld(p);
int newWorld = initWorld();
if(newWorld > -1) {
installWorldPlayerRanking(newWorld);
@@ -388,40 +381,40 @@ public class Server {
return newWorld;
}
private static int getWorldProperty(Properties p, String property, int wid, int defaultValue) {
String content = p.getProperty(property + wid);
return content != null ? Integer.parseInt(content) : defaultValue;
}
private int initWorld(Properties p) {
private int initWorld() {
wldWLock.lock();
try {
int i = worlds.size();
if(i >= ServerConstants.WLDLIST_SIZE) {
if(i >= YamlConfig.config.server.WLDLIST_SIZE) {
return -1;
}
System.out.println("Starting world " + i);
int exprate = getWorldProperty(p, "exprate", i, ServerConstants.EXP_RATE);
int mesorate = getWorldProperty(p, "mesorate", i, ServerConstants.MESO_RATE);
int droprate = getWorldProperty(p, "droprate", i, ServerConstants.DROP_RATE);
int bossdroprate = getWorldProperty(p, "bossdroprate", i, ServerConstants.BOSS_DROP_RATE);
int questrate = getWorldProperty(p, "questrate", i, ServerConstants.QUEST_RATE);
int travelrate = getWorldProperty(p, "travelrate", i, ServerConstants.TRAVEL_RATE);
int fishingrate = getWorldProperty(p, "fishrate", i, ServerConstants.FISHING_RATE);
int exprate = YamlConfig.config.worlds.get(i).exp_rate;
int mesorate = YamlConfig.config.worlds.get(i).meso_rate;
int droprate = YamlConfig.config.worlds.get(i).drop_rate;
int bossdroprate = YamlConfig.config.worlds.get(i).boss_drop_rate;
int questrate = YamlConfig.config.worlds.get(i).quest_rate;
int travelrate = YamlConfig.config.worlds.get(i).travel_rate;
int fishingrate = YamlConfig.config.worlds.get(i).fishing_rate;
int flag = YamlConfig.config.worlds.get(i).flag;
String event_message = YamlConfig.config.worlds.get(i).event_message;
String why_am_i_recommended = YamlConfig.config.worlds.get(i).why_am_i_recommended;
World world = new World(i,
Integer.parseInt(p.getProperty("flag" + i)),
p.getProperty("eventmessage" + i),
flag,
event_message,
exprate, droprate, bossdroprate, mesorate, questrate, travelrate, fishingrate);
worldRecommendedList.add(new Pair<>(i, p.getProperty("whyamirecommended" + i)));
worldRecommendedList.add(new Pair<>(i, why_am_i_recommended));
worlds.add(world);
Map<Integer, String> channelInfo = new HashMap<>();
long bootTime = getCurrentTime();
for (int j = 1; j <= Integer.parseInt(p.getProperty("channels" + i)); j++) {
for (int j = 1; j <= YamlConfig.config.worlds.get(i).channels; j++) {
int channelid = j;
Channel channel = new Channel(i, channelid, bootTime);
@@ -431,7 +424,7 @@ public class Server {
channels.add(i, channelInfo);
world.setServerMessage(p.getProperty("servermessage" + i));
world.setServerMessage(YamlConfig.config.worlds.get(i).server_message);
System.out.println("Finished loading world " + i + "\r\n");
return i;
@@ -511,18 +504,6 @@ public class Server {
}
}
public static Properties loadWorldINI() {
Properties p = new Properties();
try {
p.load(new FileInputStream("world.ini"));
return p;
} catch (Exception e) {
e.printStackTrace();
System.out.println("[SEVERE] Could not find/open 'world.ini'.");
return null;
}
}
private static long getTimeLeftForNextHour() {
Calendar nextHour = Calendar.getInstance();
nextHour.add(Calendar.HOUR, 1);
@@ -547,7 +528,7 @@ public class Server {
}
public static void cleanNxcodeCoupons(Connection con) throws SQLException {
if (!ServerConstants.USE_CLEAR_OUTDATED_COUPONS) return;
if (!YamlConfig.config.server.USE_CLEAR_OUTDATED_COUPONS) return;
long timeClear = System.currentTimeMillis() - 14 * 24 * 60 * 60 * 1000;
@@ -705,7 +686,7 @@ public class Server {
public List<Pair<String, Integer>> getWorldPlayerRanking(int worldid) {
wldRLock.lock();
try {
return new ArrayList<>(playerRanking.get(!ServerConstants.USE_WHOLE_SERVER_RANKING ? worldid : 0));
return new ArrayList<>(playerRanking.get(!YamlConfig.config.server.USE_WHOLE_SERVER_RANKING ? worldid : 0));
} finally {
wldRLock.unlock();
}
@@ -716,7 +697,7 @@ public class Server {
if(!ranking.isEmpty()) {
wldWLock.lock();
try {
if (!ServerConstants.USE_WHOLE_SERVER_RANKING) {
if (!YamlConfig.config.server.USE_WHOLE_SERVER_RANKING) {
for(int i = playerRanking.size(); i <= worldid; i++) {
playerRanking.add(new ArrayList<Pair<String, Integer>>(0));
}
@@ -732,7 +713,7 @@ public class Server {
}
private void removeWorldPlayerRanking() {
if (!ServerConstants.USE_WHOLE_SERVER_RANKING) {
if (!YamlConfig.config.server.USE_WHOLE_SERVER_RANKING) {
wldWLock.lock();
try {
if(playerRanking.size() < this.getWorldsSize()) {
@@ -760,7 +741,7 @@ public class Server {
if(!rankUpdates.isEmpty()) {
wldWLock.lock();
try {
if (!ServerConstants.USE_WHOLE_SERVER_RANKING) {
if (!YamlConfig.config.server.USE_WHOLE_SERVER_RANKING) {
for(int i = playerRanking.size(); i <= rankUpdates.get(rankUpdates.size() - 1).getLeft(); i++) {
playerRanking.add(new ArrayList<Pair<String, Integer>>(0));
}
@@ -778,7 +759,7 @@ public class Server {
}
private void initWorldPlayerRanking() {
if (ServerConstants.USE_WHOLE_SERVER_RANKING) {
if (YamlConfig.config.server.USE_WHOLE_SERVER_RANKING) {
playerRanking.add(new ArrayList<Pair<String, Integer>>(0));
}
updateWorldPlayerRanking();
@@ -795,7 +776,7 @@ public class Server {
con = DatabaseConnection.getConnection();
String worldQuery;
if (!ServerConstants.USE_WHOLE_SERVER_RANKING) {
if (!YamlConfig.config.server.USE_WHOLE_SERVER_RANKING) {
if(worldid >= 0) {
worldQuery = (" AND `characters`.`world` = " + worldid);
} else {
@@ -805,10 +786,10 @@ public class Server {
worldQuery = (" AND `characters`.`world` >= 0 AND `characters`.`world` <= " + Math.abs(worldid));
}
ps = con.prepareStatement("SELECT `characters`.`name`, `characters`.`level`, `characters`.`world` FROM `characters` LEFT JOIN accounts ON accounts.id = characters.accountid WHERE `characters`.`gm` < 2 AND `accounts`.`banned` = '0'" + worldQuery + " ORDER BY " + (!ServerConstants.USE_WHOLE_SERVER_RANKING ? "world, " : "") + "level DESC, exp DESC, lastExpGainTime ASC LIMIT 50");
ps = con.prepareStatement("SELECT `characters`.`name`, `characters`.`level`, `characters`.`world` FROM `characters` LEFT JOIN accounts ON accounts.id = characters.accountid WHERE `characters`.`gm` < 2 AND `accounts`.`banned` = '0'" + worldQuery + " ORDER BY " + (!YamlConfig.config.server.USE_WHOLE_SERVER_RANKING ? "world, " : "") + "level DESC, exp DESC, lastExpGainTime ASC LIMIT 50");
rs = ps.executeQuery();
if (!ServerConstants.USE_WHOLE_SERVER_RANKING) {
if (!YamlConfig.config.server.USE_WHOLE_SERVER_RANKING) {
int currentWorld = -1;
while(rs.next()) {
int rsWorld = rs.getInt("world");
@@ -854,17 +835,12 @@ public class Server {
}
public void init() {
Properties p = loadWorldINI();
if(p == null) {
System.exit(0);
}
System.out.println("HeavenMS v" + ServerConstants.VERSION + " starting up.\r\n");
if(ServerConstants.SHUTDOWNHOOK)
if(YamlConfig.config.server.SHUTDOWNHOOK)
Runtime.getRuntime().addShutdownHook(new Thread(shutdown(false)));
TimeZone.setDefault(TimeZone.getTimeZone(ServerConstants.TIMEZONE));
TimeZone.setDefault(TimeZone.getTimeZone(YamlConfig.config.server.TIMEZONE));
Connection c = null;
try {
@@ -897,21 +873,21 @@ public class Server {
ThreadManager.getInstance().start();
TimerManager tMan = TimerManager.getInstance();
tMan.start();
tMan.register(tMan.purge(), ServerConstants.PURGING_INTERVAL);//Purging ftw...
tMan.register(tMan.purge(), YamlConfig.config.server.PURGING_INTERVAL);//Purging ftw...
disconnectIdlesOnLoginTask();
long timeLeft = getTimeLeftForNextHour();
tMan.register(new CharacterDiseaseWorker(), ServerConstants.UPDATE_INTERVAL, ServerConstants.UPDATE_INTERVAL);
tMan.register(new CharacterDiseaseWorker(), YamlConfig.config.server.UPDATE_INTERVAL, YamlConfig.config.server.UPDATE_INTERVAL);
tMan.register(new ReleaseLockWorker(), 2 * 60 * 1000, 2 * 60 * 1000);
tMan.register(new CouponWorker(), ServerConstants.COUPON_INTERVAL, timeLeft);
tMan.register(new CouponWorker(), YamlConfig.config.server.COUPON_INTERVAL, timeLeft);
tMan.register(new RankingCommandWorker(), 5 * 60 * 1000, 5 * 60 * 1000);
tMan.register(new RankingLoginWorker(), ServerConstants.RANKING_INTERVAL, timeLeft);
tMan.register(new RankingLoginWorker(), YamlConfig.config.server.RANKING_INTERVAL, timeLeft);
tMan.register(new LoginCoordinatorWorker(), 60 * 60 * 1000, timeLeft);
tMan.register(new EventRecallCoordinatorWorker(), 60 * 60 * 1000, timeLeft);
tMan.register(new LoginStorageWorker(), 2 * 60 * 1000, 2 * 60 * 1000);
tMan.register(new DueyFredrickWorker(), 60 * 60 * 1000, timeLeft);
tMan.register(new InvitationWorker(), 30 * 1000, 30 * 1000);
tMan.register(new RespawnWorker(), ServerConstants.RESPAWN_INTERVAL, ServerConstants.RESPAWN_INTERVAL);
tMan.register(new RespawnWorker(), YamlConfig.config.server.RESPAWN_INTERVAL, YamlConfig.config.server.RESPAWN_INTERVAL);
timeLeft = getTimeLeftForNextDay();
MapleExpeditionBossLog.resetBossLogTable();
@@ -932,13 +908,13 @@ public class Server {
NewYearCardRecord.startPendingNewYearCardRequests();
if(ServerConstants.USE_THREAD_TRACKER) ThreadTracker.getInstance().registerThreadTrackerTask();
if(YamlConfig.config.server.USE_THREAD_TRACKER) ThreadTracker.getInstance().registerThreadTrackerTask();
try {
Integer worldCount = Math.min(GameConstants.WORLD_NAMES.length, Integer.parseInt(p.getProperty("worlds")));
Integer worldCount = Math.min(GameConstants.WORLD_NAMES.length, YamlConfig.config.worlds.size());
for (int i = 0; i < worldCount; i++) {
initWorld(p);
initWorld();
}
initWorldPlayerRanking();
@@ -952,7 +928,7 @@ public class Server {
System.out.println();
if(ServerConstants.USE_FAMILY_SYSTEM) {
if(YamlConfig.config.server.USE_FAMILY_SYSTEM) {
timeToTake = System.currentTimeMillis();
MapleFamily.loadAllFamilies();
System.out.println("Families loaded in " + ((System.currentTimeMillis() - timeToTake) / 1000.0) + " seconds\r\n");
@@ -1767,7 +1743,7 @@ public class Server {
}
public boolean validateCharacteridInTransition(IoSession session, int charId) {
if (!ServerConstants.USE_IP_VALIDATION) {
if (!YamlConfig.config.server.USE_IP_VALIDATION) {
return true;
}
@@ -1783,7 +1759,7 @@ public class Server {
}
public Integer freeCharacteridInTransition(IoSession session) {
if (!ServerConstants.USE_IP_VALIDATION) {
if (!YamlConfig.config.server.USE_IP_VALIDATION) {
return null;
}
@@ -1798,7 +1774,7 @@ public class Server {
}
public boolean hasCharacteridInTransition(IoSession session) {
if (!ServerConstants.USE_IP_VALIDATION) {
if (!YamlConfig.config.server.USE_IP_VALIDATION) {
return true;
}
@@ -1905,7 +1881,7 @@ public class Server {
List<Channel> allChannels = getAllChannels();
if(ServerConstants.USE_THREAD_TRACKER) ThreadTracker.getInstance().cancelThreadTrackerTask();
if(YamlConfig.config.server.USE_THREAD_TRACKER) ThreadTracker.getInstance().cancelThreadTrackerTask();
for (Channel ch : allChannels) {
while (!ch.finishedShutdown()) {
@@ -19,6 +19,7 @@
*/
package net.server.audit.locks.active;
import config.YamlConfig;
import constants.ServerConstants;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -59,7 +60,7 @@ public class TrackerReadLock extends ReentrantReadWriteLock.ReadLock implements
@Override
public void lock() {
if(ServerConstants.USE_THREAD_TRACKER) {
if(YamlConfig.config.server.USE_THREAD_TRACKER) {
if(deadlockedState != null) {
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getDefault());
@@ -77,7 +78,7 @@ public class TrackerReadLock extends ReentrantReadWriteLock.ReadLock implements
@Override
public void unlock() {
if(ServerConstants.USE_THREAD_TRACKER) {
if(YamlConfig.config.server.USE_THREAD_TRACKER) {
unregisterLocking();
}
@@ -87,7 +88,7 @@ public class TrackerReadLock extends ReentrantReadWriteLock.ReadLock implements
@Override
public boolean tryLock() {
if(super.tryLock()) {
if(ServerConstants.USE_THREAD_TRACKER) {
if(YamlConfig.config.server.USE_THREAD_TRACKER) {
if(deadlockedState != null) {
//FilePrinter.printError(FilePrinter.DEADLOCK_ERROR, "Deadlock occurred when trying to use the '" + id.name() + "' lock resources:\r\n" + printStackTrace(deadlockedState));
ThreadTracker.getInstance().accessThreadTracker(true, true, id, hashcode);
@@ -114,7 +115,7 @@ public class TrackerReadLock extends ReentrantReadWriteLock.ReadLock implements
public void run() {
issueDeadlock(t);
}
}, ServerConstants.LOCK_MONITOR_TIME);
}, YamlConfig.config.server.LOCK_MONITOR_TIME);
}
} finally {
state.unlock();
@@ -23,6 +23,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.ScheduledFuture;
import config.YamlConfig;
import constants.ServerConstants;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -61,7 +63,7 @@ public class TrackerReentrantLock extends ReentrantLock implements MonitoredReen
@Override
public void lock() {
if(ServerConstants.USE_THREAD_TRACKER) {
if(YamlConfig.config.server.USE_THREAD_TRACKER) {
if(deadlockedState != null) {
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getDefault());
@@ -79,7 +81,7 @@ public class TrackerReentrantLock extends ReentrantLock implements MonitoredReen
@Override
public void unlock() {
if(ServerConstants.USE_THREAD_TRACKER) {
if(YamlConfig.config.server.USE_THREAD_TRACKER) {
unregisterLocking();
}
@@ -89,7 +91,7 @@ public class TrackerReentrantLock extends ReentrantLock implements MonitoredReen
@Override
public boolean tryLock() {
if(super.tryLock()) {
if(ServerConstants.USE_THREAD_TRACKER) {
if(YamlConfig.config.server.USE_THREAD_TRACKER) {
if(deadlockedState != null) {
//FilePrinter.printError(FilePrinter.DEADLOCK_ERROR, "Deadlock occurred when trying to use the '" + id.name() + "' lock resources:\r\n" + printStackTrace(deadlockedState));
ThreadTracker.getInstance().accessThreadTracker(true, true, id, hashcode);
@@ -116,7 +118,7 @@ public class TrackerReentrantLock extends ReentrantLock implements MonitoredReen
public void run() {
issueDeadlock(t);
}
}, ServerConstants.LOCK_MONITOR_TIME);
}, YamlConfig.config.server.LOCK_MONITOR_TIME);
}
} finally {
state.unlock();
@@ -19,6 +19,7 @@
*/
package net.server.audit.locks.active;
import config.YamlConfig;
import constants.ServerConstants;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -57,7 +58,7 @@ public class TrackerWriteLock extends ReentrantReadWriteLock.WriteLock implement
@Override
public void lock() {
if(ServerConstants.USE_THREAD_TRACKER) {
if(YamlConfig.config.server.USE_THREAD_TRACKER) {
if(deadlockedState != null) {
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getDefault());
@@ -75,7 +76,7 @@ public class TrackerWriteLock extends ReentrantReadWriteLock.WriteLock implement
@Override
public void unlock() {
if(ServerConstants.USE_THREAD_TRACKER) {
if(YamlConfig.config.server.USE_THREAD_TRACKER) {
unregisterLocking();
}
@@ -85,7 +86,7 @@ public class TrackerWriteLock extends ReentrantReadWriteLock.WriteLock implement
@Override
public boolean tryLock() {
if(super.tryLock()) {
if(ServerConstants.USE_THREAD_TRACKER) {
if(YamlConfig.config.server.USE_THREAD_TRACKER) {
if(deadlockedState != null) {
//FilePrinter.printError(FilePrinter.DEADLOCK_ERROR, "Deadlock occurred when trying to use the '" + id.name() + "' lock resources:\r\n" + printStackTrace(deadlockedState));
ThreadTracker.getInstance().accessThreadTracker(true, true, id, hashcode);
@@ -112,7 +113,7 @@ public class TrackerWriteLock extends ReentrantReadWriteLock.WriteLock implement
public void run() {
issueDeadlock(t);
}
}, ServerConstants.LOCK_MONITOR_TIME);
}, YamlConfig.config.server.LOCK_MONITOR_TIME);
}
} finally {
state.unlock();
+20 -18
View File
@@ -37,6 +37,8 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import config.YamlConfig;
import net.server.audit.LockCollector;
import net.server.audit.locks.MonitoredLockType;
import net.server.audit.locks.MonitoredReentrantLock;
@@ -88,13 +90,13 @@ public final class Channel {
private String ip, serverMessage;
private MapleMapManager mapManager;
private EventScriptManager eventSM;
private MobStatusScheduler mobStatusSchedulers[] = new MobStatusScheduler[ServerConstants.CHANNEL_LOCKS];
private MobAnimationScheduler mobAnimationSchedulers[] = new MobAnimationScheduler[ServerConstants.CHANNEL_LOCKS];
private MobClearSkillScheduler mobClearSkillSchedulers[] = new MobClearSkillScheduler[ServerConstants.CHANNEL_LOCKS];
private MobMistScheduler mobMistSchedulers[] = new MobMistScheduler[ServerConstants.CHANNEL_LOCKS];
private FaceExpressionScheduler faceExpressionSchedulers[] = new FaceExpressionScheduler[ServerConstants.CHANNEL_LOCKS];
private EventScheduler eventSchedulers[] = new EventScheduler[ServerConstants.CHANNEL_LOCKS];
private OverallScheduler channelSchedulers[] = new OverallScheduler[ServerConstants.CHANNEL_LOCKS];
private MobStatusScheduler mobStatusSchedulers[] = new MobStatusScheduler[YamlConfig.config.server.CHANNEL_LOCKS];
private MobAnimationScheduler mobAnimationSchedulers[] = new MobAnimationScheduler[YamlConfig.config.server.CHANNEL_LOCKS];
private MobClearSkillScheduler mobClearSkillSchedulers[] = new MobClearSkillScheduler[YamlConfig.config.server.CHANNEL_LOCKS];
private MobMistScheduler mobMistSchedulers[] = new MobMistScheduler[YamlConfig.config.server.CHANNEL_LOCKS];
private FaceExpressionScheduler faceExpressionSchedulers[] = new FaceExpressionScheduler[YamlConfig.config.server.CHANNEL_LOCKS];
private EventScheduler eventSchedulers[] = new EventScheduler[YamlConfig.config.server.CHANNEL_LOCKS];
private OverallScheduler channelSchedulers[] = new OverallScheduler[YamlConfig.config.server.CHANNEL_LOCKS];
private Map<Integer, MapleHiredMerchant> hiredMerchants = new HashMap<>();
private final Map<Integer, Integer> storedVars = new HashMap<>();
private Set<Integer> playersAway = new HashSet<>();
@@ -129,7 +131,7 @@ public final class Channel {
private ReadLock merchRlock = merchantLock.readLock();
private WriteLock merchWlock = merchantLock.writeLock();
private MonitoredReentrantLock faceLock[] = new MonitoredReentrantLock[ServerConstants.CHANNEL_LOCKS];
private MonitoredReentrantLock faceLock[] = new MonitoredReentrantLock[YamlConfig.config.server.CHANNEL_LOCKS];
private MonitoredReentrantLock lock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.CHANNEL, true);
@@ -143,7 +145,7 @@ public final class Channel {
eventSM = new EventScriptManager(this, getEvents());
port = 7575 + this.channel - 1;
port += (world * 100);
ip = ServerConstants.HOST + ":" + port;
ip = YamlConfig.config.server.HOST + ":" + port;
IoBuffer.setUseDirectBuffer(false);
IoBuffer.setAllocator(new SimpleBufferAllocator());
acceptor = new NioSocketAcceptor();
@@ -166,7 +168,7 @@ public final class Channel {
dojoTask[i] = null;
}
for(int i = 0; i < ServerConstants.CHANNEL_LOCKS; i++) {
for(int i = 0; i < YamlConfig.config.server.CHANNEL_LOCKS; i++) {
faceLock[i] = MonitoredReentrantLockFactory.createLock(MonitoredLockType.CHANNEL_FACEEXPRS, true);
mobStatusSchedulers[i] = new MobStatusScheduler();
@@ -228,7 +230,7 @@ public final class Channel {
}
}
for(int i = 0; i < ServerConstants.CHANNEL_LOCKS; i++) {
for(int i = 0; i < YamlConfig.config.server.CHANNEL_LOCKS; i++) {
if(mobStatusSchedulers[i] != null) {
mobStatusSchedulers[i].dispose();
mobStatusSchedulers[i] = null;
@@ -278,7 +280,7 @@ public final class Channel {
}
private void emptyLocks() {
for(int i = 0; i < ServerConstants.CHANNEL_LOCKS; i++) {
for(int i = 0; i < YamlConfig.config.server.CHANNEL_LOCKS; i++) {
faceLock[i] = faceLock[i].dispose();
}
@@ -335,7 +337,7 @@ public final class Channel {
}
public int getChannelCapacity() {
return (int)(Math.ceil(((float) players.getAllCharacters().size() / ServerConstants.CHANNEL_LOAD) * 800));
return (int)(Math.ceil(((float) players.getAllCharacters().size() / YamlConfig.config.server.CHANNEL_LOAD) * 800));
}
public void broadcastPacket(final byte[] data) {
@@ -786,7 +788,7 @@ public final class Channel {
try {
List<Integer> weddingReservationQueue = (cathedral ? cathedralReservationQueue : chapelReservationQueue);
int delay = ServerConstants.WEDDING_RESERVATION_DELAY - 1 - weddingReservationQueue.size();
int delay = YamlConfig.config.server.WEDDING_RESERVATION_DELAY - 1 - weddingReservationQueue.size();
for(int i = 0; i < delay; i++) {
weddingReservationQueue.add(null); // push empty slots to fill the waiting time
}
@@ -869,7 +871,7 @@ public final class Channel {
public void run() {
closeOngoingWedding(cathedral);
}
}, ServerConstants.WEDDING_RESERVATION_TIMEOUT * 60 * 1000);
}, YamlConfig.config.server.WEDDING_RESERVATION_TIMEOUT * 60 * 1000);
if(cathedral) {
cathedralReservationTask = weddingTask;
@@ -933,7 +935,7 @@ public final class Channel {
}
public static long getRelativeWeddingTicketExpireTime(int resSlot) {
return (resSlot * ServerConstants.WEDDING_RESERVATION_INTERVAL * 60 * 1000);
return (resSlot * YamlConfig.config.server.WEDDING_RESERVATION_INTERVAL * 60 * 1000);
}
public String getWeddingReservationTimeLeft(Integer weddingId) {
@@ -959,7 +961,7 @@ public final class Channel {
return venue + " - RIGHT NOW";
}
return venue + " - " + getTimeLeft(ongoingStartTime + (resStatus * ServerConstants.WEDDING_RESERVATION_INTERVAL * 60 * 1000)) + " from now";
return venue + " - " + getTimeLeft(ongoingStartTime + (resStatus * YamlConfig.config.server.WEDDING_RESERVATION_INTERVAL * 60 * 1000)) + " from now";
} finally {
lock.unlock();
}
@@ -1019,7 +1021,7 @@ public final class Channel {
}
private static int getChannelSchedulerIndex(int mapid) {
int section = 1000000000 / ServerConstants.CHANNEL_LOCKS;
int section = 1000000000 / YamlConfig.config.server.CHANNEL_LOCKS;
return mapid / section;
}
@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import config.YamlConfig;
import net.AbstractMaplePacketHandler;
import server.MapleStatEffect;
import server.TimerManager;
@@ -462,7 +463,7 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
int threeSnailsId = player.getJobType() * 10000000 + 1000;
if(attack.skill == threeSnailsId) {
if(ServerConstants.USE_ULTRA_THREE_SNAILS) {
if(YamlConfig.config.server.USE_ULTRA_THREE_SNAILS) {
int skillLv = player.getSkillLevel(threeSnailsId);
if(skillLv > 0) {
@@ -21,6 +21,7 @@
*/
package net.server.channel.handlers;
import config.YamlConfig;
import constants.ServerConstants;
import java.sql.Connection;
@@ -50,7 +51,7 @@ public final class AcceptFamilyHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if(!ServerConstants.USE_FAMILY_SYSTEM) {
if(!YamlConfig.config.server.USE_FAMILY_SYSTEM) {
return;
}
MapleCharacter chr = c.getPlayer();
@@ -79,7 +80,7 @@ public final class AcceptFamilyHandler extends AbstractMaplePacketHandler {
MapleFamilyEntry targetEntry = chr.getFamilyEntry();
MapleFamily targetFamily = targetEntry.getFamily();
if(targetFamily.getLeader() != targetEntry) return;
if(inviter.getFamily().getTotalGenerations() + targetFamily.getTotalGenerations() <= ServerConstants.FAMILY_MAX_GENERATIONS) {
if(inviter.getFamily().getTotalGenerations() + targetFamily.getTotalGenerations() <= YamlConfig.config.server.FAMILY_MAX_GENERATIONS) {
targetEntry.join(inviter.getFamilyEntry());
} else {
inviter.announce(MaplePacketCreator.sendFamilyMessage(76, 0));
@@ -88,7 +89,7 @@ public final class AcceptFamilyHandler extends AbstractMaplePacketHandler {
}
}
} else { // create new family
if(chr.getFamily() != null && inviter.getFamily() != null && chr.getFamily().getTotalGenerations() + inviter.getFamily().getTotalGenerations() >= ServerConstants.FAMILY_MAX_GENERATIONS) {
if(chr.getFamily() != null && inviter.getFamily() != null && chr.getFamily().getTotalGenerations() + inviter.getFamily().getTotalGenerations() >= YamlConfig.config.server.FAMILY_MAX_GENERATIONS) {
inviter.announce(MaplePacketCreator.sendFamilyMessage(76, 0));
chr.announce(MaplePacketCreator.sendFamilyMessage(76, 0));
return;
@@ -1,6 +1,7 @@
package net.server.channel.handlers;
import client.MapleClient;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import tools.LogHelper;
@@ -25,19 +26,19 @@ public class AdminChatHandler extends AbstractMaplePacketHandler {
switch (mode) {
case 0:// /alertall, /noticeall, /slideall
c.getWorldServer().broadcastPacket(packet);
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Alert All", message);
}
break;
case 1:// /alertch, /noticech, /slidech
c.getChannelServer().broadcastPacket(packet);
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Alert Ch", message);
}
break;
case 2:// /alertm /alertmap, /noticem /noticemap, /slidem /slidemap
c.getPlayer().getMap().broadcastMessage(packet);
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Alert Map", message);
}
break;
@@ -28,6 +28,7 @@ import client.inventory.Equip;
import client.inventory.Item;
import client.inventory.MapleInventory;
import client.inventory.MapleInventoryType;
import config.YamlConfig;
import constants.ItemConstants;
import java.sql.SQLException;
import java.util.Calendar;
@@ -76,7 +77,7 @@ public final class CashOperationHandler extends AbstractMaplePacketHandler {
if (ItemConstants.isCashStore(cItem.getItemId()) && chr.getLevel() < 16) {
c.enableCSActions();
return;
} else if (ItemConstants.isRateCoupon(cItem.getItemId()) && !ServerConstants.USE_SUPPLY_RATE_COUPONS) {
} else if (ItemConstants.isRateCoupon(cItem.getItemId()) && !YamlConfig.config.server.USE_SUPPLY_RATE_COUPONS) {
chr.dropMessage(1, "Rate coupons are currently unavailable to purchase.");
c.enableCSActions();
return;
@@ -376,7 +377,7 @@ public final class CashOperationHandler extends AbstractMaplePacketHandler {
c.enableCSActions();
return;
}
if(cItem.getSN() == 50600000 && ServerConstants.ALLOW_CASHSHOP_NAME_CHANGE) {
if(cItem.getSN() == 50600000 && YamlConfig.config.server.ALLOW_CASHSHOP_NAME_CHANGE) {
slea.readMapleAsciiString(); //old name
String newName = slea.readMapleAsciiString();
if(!MapleCharacter.canCreateChar(newName) || chr.getLevel() < 10) { //(longest ban duration isn't tracked currently)
@@ -405,7 +406,7 @@ public final class CashOperationHandler extends AbstractMaplePacketHandler {
c.enableCSActions();
return;
}
if(cItem.getSN() == 50600001 && ServerConstants.ALLOW_CASHSHOP_WORLD_TRANSFER) {
if(cItem.getSN() == 50600001 && YamlConfig.config.server.ALLOW_CASHSHOP_WORLD_TRANSFER) {
int newWorldSelection = slea.readInt();
int worldTransferError = chr.checkWorldTransferEligibility();
@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import config.YamlConfig;
import server.MapleStatEffect;
import tools.MaplePacketCreator;
import tools.Pair;
@@ -70,7 +71,7 @@ public final class CloseRangeDamageHandler extends AbstractDealDamageHandler {
if (chr.getDojoEnergy() < 10000 && (attack.skill == 1009 || attack.skill == 10001009 || attack.skill == 20001009)) // PE hacking or maybe just lagging
return;
if (chr.getMap().isDojoMap() && attack.numAttacked > 0) {
chr.setDojoEnergy(chr.getDojoEnergy() + ServerConstants.DOJO_ENERGY_ATK);
chr.setDojoEnergy(chr.getDojoEnergy() + YamlConfig.config.server.DOJO_ENERGY_ATK);
c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
}
@@ -23,6 +23,7 @@ package net.server.channel.handlers;
import client.MapleClient;
import client.processor.DueyProcessor;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
@@ -33,7 +34,7 @@ public final class DueyHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if (!ServerConstants.USE_DUEY){
if (!YamlConfig.config.server.USE_DUEY){
c.announce(MaplePacketCreator.enableActions());
return;
}
@@ -28,6 +28,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import config.YamlConfig;
import constants.ServerConstants;
import client.MapleCharacter;
import client.MapleClient;
@@ -49,11 +50,11 @@ public final class EnterMTSHandler extends AbstractMaplePacketHandler {
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
MapleCharacter chr = c.getPlayer();
if(!chr.isAlive() && ServerConstants.USE_BUYBACK_SYSTEM) {
if(!chr.isAlive() && YamlConfig.config.server.USE_BUYBACK_SYSTEM) {
BuybackProcessor.processBuyback(c);
c.announce(MaplePacketCreator.enableActions());
} else {
if (!ServerConstants.USE_MTS) {
if (!YamlConfig.config.server.USE_MTS) {
c.announce(MaplePacketCreator.enableActions());
return;
}
@@ -21,6 +21,7 @@
*/
package net.server.channel.handlers;
import config.YamlConfig;
import constants.ServerConstants;
import client.MapleCharacter;
import client.MapleClient;
@@ -38,7 +39,7 @@ import tools.data.input.SeekableLittleEndianAccessor;
public final class FamilyAddHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if(!ServerConstants.USE_FAMILY_SYSTEM) {
if(!YamlConfig.config.server.USE_FAMILY_SYSTEM) {
return;
}
String toAdd = slea.readMapleAsciiString();
@@ -58,7 +59,7 @@ public final class FamilyAddHandler extends AbstractMaplePacketHandler {
c.announce(MaplePacketCreator.enableActions());
} else if(MapleInviteCoordinator.hasInvite(InviteType.FAMILY, addChr.getId())) {
c.announce(MaplePacketCreator.sendFamilyMessage(73, 0));
} else if(chr.getFamily() != null && addChr.getFamily() != null && addChr.getFamily().getTotalGenerations() + chr.getFamily().getTotalGenerations() > ServerConstants.FAMILY_MAX_GENERATIONS) {
} else if(chr.getFamily() != null && addChr.getFamily() != null && addChr.getFamily().getTotalGenerations() + chr.getFamily().getTotalGenerations() > YamlConfig.config.server.FAMILY_MAX_GENERATIONS) {
c.announce(MaplePacketCreator.sendFamilyMessage(76, 0));
} else {
MapleInviteCoordinator.createInvite(InviteType.FAMILY, chr, addChr, addChr.getId());
@@ -22,6 +22,7 @@ package net.server.channel.handlers;
import client.MapleClient;
import client.MapleFamily;
import client.MapleFamilyEntry;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import tools.MaplePacketCreator;
@@ -31,7 +32,7 @@ public class FamilySeparateHandler extends AbstractMaplePacketHandler {
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if(!ServerConstants.USE_FAMILY_SYSTEM) return;
if(!YamlConfig.config.server.USE_FAMILY_SYSTEM) return;
MapleFamily oldFamily = c.getPlayer().getFamily();
if(oldFamily == null) return;
MapleFamilyEntry forkOn = null;
@@ -4,6 +4,7 @@ import client.MapleCharacter;
import client.MapleClient;
import client.MapleFamilyEntitlement;
import client.MapleFamilyEntry;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import net.server.coordinator.MapleInviteCoordinator;
@@ -18,7 +19,7 @@ public class FamilySummonResponseHandler extends AbstractMaplePacketHandler {
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if(!ServerConstants.USE_FAMILY_SYSTEM) return;
if(!YamlConfig.config.server.USE_FAMILY_SYSTEM) return;
slea.readMapleAsciiString(); //family name
boolean accept = slea.readByte() != 0;
MapleInviteResult inviteResult = MapleInviteCoordinator.answerInvite(InviteType.FAMILY_SUMMON, c.getPlayer().getId(), c.getPlayer(), accept);
@@ -25,6 +25,7 @@ import client.MapleCharacter;
import client.MapleClient;
import client.MapleFamilyEntitlement;
import client.MapleFamilyEntry;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import net.server.coordinator.MapleInviteCoordinator;
@@ -42,7 +43,7 @@ import tools.data.input.SeekableLittleEndianAccessor;
public final class FamilyUseHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if(!ServerConstants.USE_FAMILY_SYSTEM) {
if(!YamlConfig.config.server.USE_FAMILY_SYSTEM) {
return;
}
MapleFamilyEntitlement type = MapleFamilyEntitlement.values()[slea.readInt()];
@@ -25,6 +25,7 @@ import client.MapleCharacter;
import client.MapleClient;
import client.autoban.AutobanFactory;
import client.command.CommandsExecutor;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import tools.FilePrinter;
@@ -59,12 +60,12 @@ public final class GeneralChatHandler extends AbstractMaplePacketHandler {
if (!chr.isHidden()) {
chr.getMap().broadcastMessage(MaplePacketCreator.getChatText(chr.getId(), s, chr.getWhiteChat(), show));
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "General", s);
}
} else {
chr.getMap().broadcastGMMessage(MaplePacketCreator.getChatText(chr.getId(), s, chr.getWhiteChat(), show));
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "GM General", s);
}
}
@@ -21,6 +21,7 @@
*/
package net.server.channel.handlers;
import config.YamlConfig;
import net.server.guild.MapleGuildResponse;
import net.server.guild.MapleGuild;
import constants.GameConstants;
@@ -65,8 +66,8 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
mc.dropMessage(1, "You cannot create a new Guild while in one.");
return;
}
if (mc.getMeso() < ServerConstants.CREATE_GUILD_COST) {
mc.dropMessage(1, "You do not have " + GameConstants.numberWithCommas(ServerConstants.CREATE_GUILD_COST) + " mesos to create a Guild.");
if (mc.getMeso() < YamlConfig.config.server.CREATE_GUILD_COST) {
mc.dropMessage(1, "You do not have " + GameConstants.numberWithCommas(YamlConfig.config.server.CREATE_GUILD_COST) + " mesos to create a Guild.");
return;
}
String guildName = slea.readMapleAsciiString();
@@ -76,8 +77,8 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
}
Set<MapleCharacter> eligibleMembers = new HashSet<>(MapleGuild.getEligiblePlayersForGuild(mc));
if (eligibleMembers.size() < ServerConstants.CREATE_GUILD_MIN_PARTNERS) {
if (mc.getMap().getAllPlayers().size() < ServerConstants.CREATE_GUILD_MIN_PARTNERS) {
if (eligibleMembers.size() < YamlConfig.config.server.CREATE_GUILD_MIN_PARTNERS) {
if (mc.getMap().getAllPlayers().size() < YamlConfig.config.server.CREATE_GUILD_MIN_PARTNERS) {
// thanks NovaStory for noticing message in need of smoother info
mc.dropMessage(1, "Your Guild doesn't have enough cofounders present here and therefore cannot be created at this time.");
} else {
@@ -211,8 +212,8 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
System.out.println("[Hack] " + mc.getName() + " tried to change guild emblem without being the guild leader.");
return;
}
if (mc.getMeso() < ServerConstants.CHANGE_EMBLEM_COST) {
c.announce(MaplePacketCreator.serverNotice(1, "You do not have " + GameConstants.numberWithCommas(ServerConstants.CHANGE_EMBLEM_COST) + " mesos to change the Guild emblem."));
if (mc.getMeso() < YamlConfig.config.server.CHANGE_EMBLEM_COST) {
c.announce(MaplePacketCreator.serverNotice(1, "You do not have " + GameConstants.numberWithCommas(YamlConfig.config.server.CHANGE_EMBLEM_COST) + " mesos to change the Guild emblem."));
return;
}
short bg = slea.readShort();
@@ -226,7 +227,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c.getWorld()), -1, -1);
}
mc.gainMeso(-ServerConstants.CHANGE_EMBLEM_COST, true, false, true);
mc.gainMeso(-YamlConfig.config.server.CHANGE_EMBLEM_COST, true, false, true);
mc.getGuild().broadcastNameChanged();
mc.getGuild().broadcastEmblemChanged();
break;
@@ -21,6 +21,7 @@
*/
package net.server.channel.handlers;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import client.inventory.manipulator.MapleInventoryManipulator;
@@ -42,7 +43,7 @@ public final class InventoryMergeHandler extends AbstractMaplePacketHandler {
slea.readInt();
chr.getAutobanManager().setTimestamp(2, Server.getInstance().getCurrentTimestamp(), 4);
if(!ServerConstants.USE_ITEM_SORT) {
if(!YamlConfig.config.server.USE_ITEM_SORT) {
c.announce(MaplePacketCreator.enableActions());
return;
}
@@ -24,6 +24,7 @@ package net.server.channel.handlers;
import java.util.ArrayList;
import java.util.List;
import config.YamlConfig;
import net.AbstractMaplePacketHandler;
import tools.MaplePacketCreator;
import tools.data.input.SeekableLittleEndianAccessor;
@@ -265,7 +266,7 @@ public final class InventorySortHandler extends AbstractMaplePacketHandler {
slea.readInt();
chr.getAutobanManager().setTimestamp(3, Server.getInstance().getCurrentTimestamp(), 4);
if(!ServerConstants.USE_ITEM_SORT) {
if(!YamlConfig.config.server.USE_ITEM_SORT) {
c.announce(MaplePacketCreator.enableActions());
return;
}
@@ -295,7 +296,7 @@ public final class InventorySortHandler extends AbstractMaplePacketHandler {
}
int invTypeCriteria = (MapleInventoryType.getByType(invType) == MapleInventoryType.EQUIP) ? 3 : 1;
int sortCriteria = (ServerConstants.USE_ITEM_SORT_BY_NAME == true) ? 2 : 0;
int sortCriteria = (YamlConfig.config.server.USE_ITEM_SORT_BY_NAME == true) ? 2 : 0;
PairedQuicksort pq = new PairedQuicksort(itemarray, sortCriteria, invTypeCriteria);
for (Item item : itemarray) {
@@ -21,6 +21,7 @@
*/
package net.server.channel.handlers;
import config.YamlConfig;
import server.MapleStatEffect;
import tools.MaplePacketCreator;
import tools.data.input.SeekableLittleEndianAccessor;
@@ -58,7 +59,7 @@ public final class MagicDamageHandler extends AbstractDealDamageHandler {
}
if (chr.getMap().isDojoMap() && attack.numAttacked > 0) {
chr.setDojoEnergy(chr.getDojoEnergy() + + ServerConstants.DOJO_ENERGY_ATK);
chr.setDojoEnergy(chr.getDojoEnergy() + + YamlConfig.config.server.DOJO_ENERGY_ATK);
c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
}
@@ -26,6 +26,8 @@ import client.MapleClient;
import java.awt.Point;
import java.util.LinkedList;
import java.util.List;
import config.YamlConfig;
import constants.ServerConstants;
import server.life.MapleMonster;
import server.life.MapleMonsterInformationProvider;
@@ -156,7 +158,7 @@ public final class MoveLifeHandler extends AbstractMovementPacketHandler {
}
if (movementDataLength > 0) {
if (ServerConstants.USE_DEBUG_SHOW_RCVD_MVLIFE) {
if (YamlConfig.config.server.USE_DEBUG_SHOW_RCVD_MVLIFE) {
System.out.println((isSkill ? "SKILL " : (isAttack ? "ATTCK " : " ")) + "castPos: " + castPos + " rawAct: " + rawActivity + " opt: " + pOption + " skillID: " + useSkillId + " skillLV: " + useSkillLevel + " " + "allowSkill: " + nextMovementCouldBeSkill + " mobMp: " + mobMp);
}
slea.seek(movementDataStart);
@@ -24,6 +24,7 @@ package net.server.channel.handlers;
import client.MapleCharacter;
import client.MapleClient;
import client.autoban.AutobanFactory;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import net.server.Server;
@@ -57,24 +58,24 @@ public final class MultiChatHandler extends AbstractMaplePacketHandler {
World world = c.getWorldServer();
if (type == 0) {
world.buddyChat(recipients, player.getId(), player.getName(), chattext);
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Buddy", chattext);
}
} else if (type == 1 && player.getParty() != null) {
world.partyChat(player.getParty(), chattext, player.getName());
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Party", chattext);
}
} else if (type == 2 && player.getGuildId() > 0) {
Server.getInstance().guildChat(player.getGuildId(), player.getName(), player.getId(), chattext);
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Guild", chattext);
}
} else if (type == 3 && player.getGuild() != null) {
int allianceId = player.getGuild().getAllianceId();
if (allianceId > 0) {
Server.getInstance().allianceMessage(allianceId, MaplePacketCreator.multiChat(player.getName(), chattext, 3), player.getId(), -1);
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Ally", chattext);
}
}
@@ -23,6 +23,7 @@ package net.server.channel.handlers;
import client.MapleClient;
import client.processor.DueyProcessor;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import scripting.npc.NPCScriptManager;
@@ -41,7 +42,7 @@ public final class NPCTalkHandler extends AbstractMaplePacketHandler {
return;
}
if(currentServerTime() - c.getPlayer().getNpcCooldown() < ServerConstants.BLOCK_NPC_RACE_CONDT) {
if(currentServerTime() - c.getPlayer().getNpcCooldown() < YamlConfig.config.server.BLOCK_NPC_RACE_CONDT) {
c.announce(MaplePacketCreator.enableActions());
return;
}
@@ -50,7 +51,7 @@ public final class NPCTalkHandler extends AbstractMaplePacketHandler {
MapleMapObject obj = c.getPlayer().getMap().getMapObject(oid);
if (obj instanceof MapleNPC) {
MapleNPC npc = (MapleNPC) obj;
if(ServerConstants.USE_DEBUG == true) c.getPlayer().dropMessage(5, "Talking to NPC " + npc.getId());
if(YamlConfig.config.server.USE_DEBUG == true) c.getPlayer().dropMessage(5, "Talking to NPC " + npc.getId());
if (npc.getId() == 9010009) { //is duey
DueyProcessor.dueySendTalk(c, false);
@@ -19,6 +19,7 @@
*/
package net.server.channel.handlers;
import config.YamlConfig;
import constants.ServerConstants;
import client.MapleCharacter;
import client.MapleClient;
@@ -33,7 +34,7 @@ import tools.data.input.SeekableLittleEndianAccessor;
public final class OpenFamilyHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if(!ServerConstants.USE_FAMILY_SYSTEM) return;
if(!YamlConfig.config.server.USE_FAMILY_SYSTEM) return;
MapleCharacter chr = c.getPlayer();
c.announce(MaplePacketCreator.getFamilyInfo(chr.getFamilyEntry()));
}
@@ -19,6 +19,7 @@
*/
package net.server.channel.handlers;
import config.YamlConfig;
import constants.ServerConstants;
import client.MapleCharacter;
import client.MapleClient;
@@ -33,7 +34,7 @@ import tools.data.input.SeekableLittleEndianAccessor;
public final class OpenFamilyPedigreeHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if(!ServerConstants.USE_FAMILY_SYSTEM) return;
if(!YamlConfig.config.server.USE_FAMILY_SYSTEM) return;
MapleCharacter target = c.getChannelServer().getPlayerStorage().getCharacterByName(slea.readMapleAsciiString());
if(target != null && target.getFamily() != null) {
c.announce(MaplePacketCreator.showPedigree(target.getFamilyEntry()));
@@ -21,6 +21,7 @@
*/
package net.server.channel.handlers;
import config.YamlConfig;
import net.AbstractMaplePacketHandler;
import net.server.world.MapleParty;
import net.server.world.MaplePartyCharacter;
@@ -77,11 +78,11 @@ public final class PartyOperationHandler extends AbstractMaplePacketHandler {
String name = slea.readMapleAsciiString();
MapleCharacter invited = world.getPlayerStorage().getCharacterByName(name);
if (invited != null) {
if(invited.getLevel() < 10 && (!ServerConstants.USE_PARTY_FOR_STARTERS || player.getLevel() >= 10)) { //min requirement is level 10
if(invited.getLevel() < 10 && (!YamlConfig.config.server.USE_PARTY_FOR_STARTERS || player.getLevel() >= 10)) { //min requirement is level 10
c.announce(MaplePacketCreator.serverNotice(5, "The player you have invited does not meet the requirements."));
return;
}
if(ServerConstants.USE_PARTY_FOR_STARTERS && invited.getLevel() >= 10 && player.getLevel() < 10) { //trying to invite high level
if(YamlConfig.config.server.USE_PARTY_FOR_STARTERS && invited.getLevel() >= 10 && player.getLevel() < 10) { //trying to invite high level
c.announce(MaplePacketCreator.serverNotice(5, "The player you have invited does not meet the requirements."));
return;
}
@@ -23,6 +23,7 @@ package net.server.channel.handlers;
import client.MapleClient;
import client.autoban.AutobanFactory;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import tools.FilePrinter;
@@ -50,7 +51,7 @@ public final class PetChatHandler extends AbstractMaplePacketHandler {
return;
}
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.petChat(c.getPlayer().getId(), pet, act, text), true);
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Pet", text);
}
}
@@ -26,6 +26,7 @@ import java.util.Set;
import client.MapleCharacter;
import client.MapleClient;
import client.inventory.MaplePet;
import config.YamlConfig;
import net.AbstractMaplePacketHandler;
import server.maps.MapleMapItem;
import server.maps.MapleMapObject;
@@ -41,7 +42,7 @@ public final class PetLootHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
MapleCharacter chr = c.getPlayer();
if(currentServerTime() - chr.getPetLootCd() < ServerConstants.PET_LOOT_UPON_ATTACK) {
if(currentServerTime() - chr.getPetLootCd() < YamlConfig.config.server.PET_LOOT_UPON_ATTACK) {
c.announce(MaplePacketCreator.enableActions());
return;
}
@@ -29,6 +29,7 @@ import client.inventory.MapleInventory;
import client.inventory.MapleInventoryType;
import client.inventory.manipulator.MapleInventoryManipulator;
import client.inventory.manipulator.MapleKarmaManipulator;
import config.YamlConfig;
import constants.ItemConstants;
import constants.ServerConstants;
@@ -369,7 +370,7 @@ public final class PlayerInteractionHandler extends AbstractMaplePacketHandler {
MaplePlayerShop shop = chr.getPlayerShop();
MapleHiredMerchant merchant = chr.getHiredMerchant();
if (shop != null && shop.isOwner(chr)) {
if(ServerConstants.USE_ERASE_PERMIT_ON_OPENSHOP) {
if(YamlConfig.config.server.USE_ERASE_PERMIT_ON_OPENSHOP) {
try {
MapleInventoryManipulator.removeById(c, MapleInventoryType.CASH, shop.getItemId(), 1, true, false);
} catch(RuntimeException re) {} // fella does not have a player shop permit...
@@ -642,7 +643,7 @@ public final class PlayerInteractionHandler extends AbstractMaplePacketHandler {
c.announce(MaplePacketCreator.updateHiredMerchant(merchant, chr));
if (ServerConstants.USE_ENFORCE_MERCHANT_SAVE) {
if (YamlConfig.config.server.USE_ENFORCE_MERCHANT_SAVE) {
chr.saveCharToDB(false);
}
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import config.YamlConfig;
import net.AbstractMaplePacketHandler;
import net.server.PlayerBuffValueHolder;
import net.server.Server;
@@ -233,7 +234,7 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
c.announce(MaplePacketCreator.getCharInfo(player));
if (!player.isHidden()) {
if(player.isGM() && ServerConstants.USE_AUTOHIDE_GM) {
if(player.isGM() && YamlConfig.config.server.USE_AUTOHIDE_GM) {
player.toggleHide(true);
}
}
@@ -402,7 +403,7 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
if (player.getMap().getHPDec() > 0) player.resetHpDecreaseTask();
player.resetPlayerRates();
if(ServerConstants.USE_ADD_RATES_BY_LEVEL == true) player.setPlayerRates();
if(YamlConfig.config.server.USE_ADD_RATES_BY_LEVEL == true) player.setPlayerRates();
player.setWorldRates();
player.updateCouponRates();
@@ -425,7 +426,7 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
}
}
if (ServerConstants.USE_NPCS_SCRIPTABLE) {
if (YamlConfig.config.server.USE_NPCS_SCRIPTABLE) {
c.announce(MaplePacketCreator.setNPCScriptable(ScriptableNPCConstants.SCRIPTABLE_NPCS));
}
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package net.server.channel.handlers;
import client.inventory.manipulator.MapleInventoryManipulator;
import config.YamlConfig;
import server.MapleItemInformationProvider;
import server.MapleStatEffect;
import tools.MaplePacketCreator;
@@ -70,7 +71,7 @@ public final class RangedAttackHandler extends AbstractDealDamageHandler {
}
if (chr.getMap().isDojoMap() && attack.numAttacked > 0) {
chr.setDojoEnergy(chr.getDojoEnergy() + ServerConstants.DOJO_ENERGY_ATK);
chr.setDojoEnergy(chr.getDojoEnergy() + YamlConfig.config.server.DOJO_ENERGY_ATK);
c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
}
@@ -23,6 +23,7 @@ package net.server.channel.handlers;
import java.awt.Point;
import config.YamlConfig;
import net.AbstractMaplePacketHandler;
import server.MapleStatEffect;
import server.life.MapleMonster;
@@ -81,7 +82,7 @@ public final class SpecialMoveHandler extends AbstractMaplePacketHandler {
return;
} else if (skillid != Corsair.BATTLE_SHIP) {
int cooldownTime = effect.getCooldown();
if(MapleStatEffect.isHerosWill(skillid) && ServerConstants.USE_FAST_REUSE_HERO_WILL) {
if(MapleStatEffect.isHerosWill(skillid) && YamlConfig.config.server.USE_FAST_REUSE_HERO_WILL) {
cooldownTime /= 60;
}
@@ -23,6 +23,7 @@ package net.server.channel.handlers;
import client.MapleCharacter;
import client.MapleClient;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import tools.LogHelper;
@@ -41,7 +42,7 @@ public final class SpouseChatHandler extends AbstractMaplePacketHandler {
if (spouse != null) {
spouse.announce(MaplePacketCreator.OnCoupleMessage(c.getPlayer().getName(), msg, true));
c.announce(MaplePacketCreator.OnCoupleMessage(c.getPlayer().getName(), msg, true));
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Spouse", msg);
}
} else {
@@ -31,6 +31,7 @@ import client.inventory.MapleInventory;
import client.inventory.MapleInventoryType;
import client.status.MonsterStatus;
import client.status.MonsterStatusEffect;
import config.YamlConfig;
import constants.GameConstants;
import constants.ItemConstants;
import constants.ServerConstants;
@@ -197,7 +198,7 @@ public final class TakeDamageHandler extends AbstractMaplePacketHandler {
}
//in dojo player cannot use pot, so deadly attacks should be turned off as well
if(is_deadly && chr.getMap().isDojoMap() && !ServerConstants.USE_DEADLY_DOJO) {
if(is_deadly && chr.getMap().isDojoMap() && !YamlConfig.config.server.USE_DEADLY_DOJO) {
damage = 0;
mpattack = 0;
}
@@ -282,7 +283,7 @@ public final class TakeDamageHandler extends AbstractMaplePacketHandler {
map.broadcastGMMessage(chr, MaplePacketCreator.damagePlayer(damagefrom, monsteridfrom, chr.getId(), damage, fake, direction, is_pgmr, pgmr, is_pg, oid, pos_x, pos_y), false);
}
if (GameConstants.isDojo(map.getId())) {
chr.setDojoEnergy(chr.getDojoEnergy() + ServerConstants.DOJO_ENERGY_DMG);
chr.setDojoEnergy(chr.getDojoEnergy() + YamlConfig.config.server.DOJO_ENERGY_DMG);
c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
}
@@ -29,6 +29,7 @@ import java.sql.Connection;
import client.MapleCharacter;
import client.MapleClient;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import tools.DatabaseConnection;
@@ -51,7 +52,7 @@ public final class TransferNameHandler extends AbstractMaplePacketHandler {
c.announce(MaplePacketCreator.enableActions());
return;
}
if(!ServerConstants.ALLOW_CASHSHOP_NAME_CHANGE) {
if(!YamlConfig.config.server.ALLOW_CASHSHOP_NAME_CHANGE) {
c.announce(MaplePacketCreator.sendNameTransferRules(4));
return;
}
@@ -73,7 +74,7 @@ public final class TransferNameHandler extends AbstractMaplePacketHandler {
if(completedTimestamp == null) { //has pending name request
c.announce(MaplePacketCreator.sendNameTransferRules(1));
return;
} else if(completedTimestamp.getTime() + ServerConstants.NAME_CHANGE_COOLDOWN > System.currentTimeMillis()) {
} else if(completedTimestamp.getTime() + YamlConfig.config.server.NAME_CHANGE_COOLDOWN > System.currentTimeMillis()) {
c.announce(MaplePacketCreator.sendNameTransferRules(3));
return;
};
@@ -28,6 +28,7 @@ import java.sql.Timestamp;
import client.MapleCharacter;
import client.MapleClient;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import net.server.Server;
@@ -52,7 +53,7 @@ public final class TransferWorldHandler extends AbstractMaplePacketHandler {
return;
}
MapleCharacter chr = c.getPlayer();
if(!ServerConstants.ALLOW_CASHSHOP_WORLD_TRANSFER || Server.getInstance().getWorldsSize() <= 1) {
if(!YamlConfig.config.server.ALLOW_CASHSHOP_WORLD_TRANSFER || Server.getInstance().getWorldsSize() <= 1) {
c.announce(MaplePacketCreator.sendWorldTransferRules(9, c));
return;
}
@@ -70,7 +71,7 @@ public final class TransferWorldHandler extends AbstractMaplePacketHandler {
if(completedTimestamp == null) { //has pending world transfer
c.announce(MaplePacketCreator.sendWorldTransferRules(6, c));
return;
} else if(completedTimestamp.getTime() + ServerConstants.WORLD_TRANSFER_COOLDOWN > System.currentTimeMillis()) {
} else if(completedTimestamp.getTime() + YamlConfig.config.server.WORLD_TRANSFER_COOLDOWN > System.currentTimeMillis()) {
c.announce(MaplePacketCreator.sendWorldTransferRules(7, c));
return;
};
@@ -38,6 +38,7 @@ import client.inventory.manipulator.MapleKarmaManipulator;
import client.processor.AssignAPProcessor;
import client.processor.AssignSPProcessor;
import client.processor.DueyProcessor;
import config.YamlConfig;
import constants.GameConstants;
import constants.ItemConstants;
import constants.ServerConstants;
@@ -373,7 +374,7 @@ public final class UseCashItemHandler extends AbstractMaplePacketHandler {
} else if (itemType == 523) {
int itemid = slea.readInt();
if(!ServerConstants.USE_ENFORCE_ITEM_SUGGESTION) c.getWorldServer().addOwlItemSearch(itemid);
if(!YamlConfig.config.server.USE_ENFORCE_ITEM_SUGGESTION) c.getWorldServer().addOwlItemSearch(itemid);
player.setOwlSearch(itemid);
List<Pair<MaplePlayerShopItem, AbstractMapleMapObject>> hmsAvailable = c.getWorldServer().getAvailableItemBundles(itemid);
if(!hmsAvailable.isEmpty()) remove(c, position, itemId);
@@ -26,6 +26,7 @@ import client.MapleClient;
import client.MapleDisease;
import client.inventory.Item;
import client.inventory.MapleInventoryType;
import config.YamlConfig;
import constants.ItemConstants;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
@@ -77,7 +78,7 @@ public final class UseItemHandler extends AbstractMaplePacketHandler {
long banTime = currentServerTime();
if (ii.getItemEffect(toUse.getItemId()).applyTo(chr)) {
if(ServerConstants.USE_BANISHABLE_TOWN_SCROLL) {
if(YamlConfig.config.server.USE_BANISHABLE_TOWN_SCROLL) {
chr.setBanishPlayerData(banMap, banSp, banTime);
}
@@ -14,6 +14,7 @@ import client.inventory.MapleInventory;
import client.inventory.MapleInventoryType;
import client.inventory.manipulator.MapleInventoryManipulator;
import client.inventory.manipulator.MapleKarmaManipulator;
import config.YamlConfig;
import constants.ItemConstants;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
@@ -50,7 +51,7 @@ public final class WeddingHandler extends AbstractMaplePacketHandler {
String groomWishlistProp = "giftedItem" + (groomWishlist ? "G" : "B") + chr.getId();
int giftCount = marriage.getIntProperty(groomWishlistProp);
if (giftCount < ServerConstants.WEDDING_GIFT_LIMIT) {
if (giftCount < YamlConfig.config.server.WEDDING_GIFT_LIMIT) {
int cid = marriage.getIntProperty(groomWishlist ? "groomId" : "brideId");
if (chr.getId() != cid) { // cannot gift yourself
MapleCharacter spouse = marriage.getPlayerById(cid);
@@ -69,7 +70,7 @@ public final class WeddingHandler extends AbstractMaplePacketHandler {
marriage.addGiftItem(groomWishlist, newItem);
MapleInventoryManipulator.removeFromSlot(c, type, slot, quantity, false, false);
if (ServerConstants.USE_ENFORCE_MERCHANT_SAVE) chr.saveCharToDB(false);
if (YamlConfig.config.server.USE_ENFORCE_MERCHANT_SAVE) chr.saveCharToDB(false);
marriage.saveGiftItemsToDb(c, groomWishlist, cid);
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(newItem);
@@ -25,6 +25,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import config.YamlConfig;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import net.server.world.World;
@@ -62,7 +63,7 @@ public final class WhisperHandler extends AbstractMaplePacketHandler {
}
if (player != null) {
player.getClient().announce(MaplePacketCreator.getWhisper(c.getPlayer().getName(), c.getChannel(), text));
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Whisper To " + player.getName(), text);
}
if(player.isHidden() && player.gmLevel() >= c.getPlayer().gmLevel()) {
@@ -74,7 +75,7 @@ public final class WhisperHandler extends AbstractMaplePacketHandler {
World world = c.getWorldServer();
if (world.isConnected(recipient)) {
world.whisper(c.getPlayer().getName(), recipient, c.getChannel(), text);
if (ServerConstants.USE_ENABLE_CHAT_LOG) {
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
LogHelper.logChat(c, "Whisper To " + recipient, text);
}
player = world.getPlayerStorage().getCharacterByName(recipient);
@@ -19,6 +19,7 @@
*/
package net.server.channel.worker;
import config.YamlConfig;
import constants.ServerConstants;
import java.util.Collections;
import java.util.HashMap;
@@ -101,7 +102,7 @@ public abstract class BaseScheduler {
if(registeredEntries.isEmpty()) {
idleProcs++;
if(idleProcs >= ServerConstants.MOB_STATUS_MONITOR_LIFE) {
if(idleProcs >= YamlConfig.config.server.MOB_STATUS_MONITOR_LIFE) {
if(schedulerTask != null) {
schedulerTask.cancel(false);
schedulerTask = null;
@@ -147,7 +148,7 @@ public abstract class BaseScheduler {
try {
idleProcs = 0;
if(schedulerTask == null) {
schedulerTask = TimerManager.getInstance().register(monitorTask, ServerConstants.MOB_STATUS_MONITOR_PROC, ServerConstants.MOB_STATUS_MONITOR_PROC);
schedulerTask = TimerManager.getInstance().register(monitorTask, YamlConfig.config.server.MOB_STATUS_MONITOR_PROC, YamlConfig.config.server.MOB_STATUS_MONITOR_PROC);
}
registeredEntries.put(key, new Pair<>(removalAction, Server.getInstance().getCurrentTime() + duration));
@@ -20,6 +20,7 @@
package net.server.channel.worker;
import client.status.MonsterStatusEffect;
import config.YamlConfig;
import constants.ServerConstants;
import java.util.HashMap;
import java.util.ArrayList;
@@ -45,7 +46,7 @@ public class MobStatusScheduler extends BaseScheduler {
protected MobStatusOvertimeEntry(int delay, Runnable run) {
procCount = 0;
procLimit = (int)Math.ceil((float) delay / ServerConstants.MOB_STATUS_MONITOR_PROC);
procLimit = (int)Math.ceil((float) delay / YamlConfig.config.server.MOB_STATUS_MONITOR_PROC);
r = run;
}
+4 -3
View File
@@ -19,6 +19,7 @@
*/
package net.server.coordinator;
import config.YamlConfig;
import constants.ServerConstants;
import java.util.Collections;
import java.util.LinkedList;
@@ -40,8 +41,8 @@ public class LoginStorage {
List<Long> accHist = loginHistory.putIfAbsent(accountId, new LinkedList<Long>());
if (accHist != null) {
synchronized (accHist) {
if (accHist.size() > ServerConstants.MAX_ACCOUNT_LOGIN_ATTEMPT) {
long blockExpiration = Server.getInstance().getCurrentTime() + ServerConstants.LOGIN_ATTEMPT_DURATION;
if (accHist.size() > YamlConfig.config.server.MAX_ACCOUNT_LOGIN_ATTEMPT) {
long blockExpiration = Server.getInstance().getCurrentTime() + YamlConfig.config.server.LOGIN_ATTEMPT_DURATION;
Collections.fill(accHist, blockExpiration);
return false;
@@ -52,7 +53,7 @@ public class LoginStorage {
}
synchronized (accHist) {
accHist.add(Server.getInstance().getCurrentTime() + ServerConstants.LOGIN_ATTEMPT_DURATION);
accHist.add(Server.getInstance().getCurrentTime() + YamlConfig.config.server.LOGIN_ATTEMPT_DURATION);
return true;
}
}
@@ -19,6 +19,7 @@
*/
package net.server.coordinator;
import config.YamlConfig;
import constants.ServerConstants;
import scripting.event.EventInstanceManager;
import java.util.LinkedList;
@@ -50,7 +51,7 @@ public class MapleEventRecallCoordinator {
}
public void storeEventInstance(int characterId, EventInstanceManager eim) {
if (ServerConstants.USE_ENABLE_RECALL_EVENT && isRecallableEvent(eim)) {
if (YamlConfig.config.server.USE_ENABLE_RECALL_EVENT && isRecallableEvent(eim)) {
eventHistory.put(characterId, eim);
}
}
@@ -19,6 +19,7 @@
*/
package net.server.coordinator;
import config.YamlConfig;
import constants.ServerConstants;
import java.util.HashSet;
import java.util.LinkedList;
@@ -59,7 +60,7 @@ public class MapleLoginBypassCoordinator {
}
public void registerLoginBypassEntry(String nibbleHwid, int accId, boolean pic) {
long expireTime = (pic ? ServerConstants.BYPASS_PIC_EXPIRATION : ServerConstants.BYPASS_PIN_EXPIRATION);
long expireTime = (pic ? YamlConfig.config.server.BYPASS_PIC_EXPIRATION : YamlConfig.config.server.BYPASS_PIN_EXPIRATION);
if (expireTime > 0) {
Pair<String, Integer> entry = new Pair<>(nibbleHwid, accId);
expireTime = Server.getInstance().getCurrentTime() + expireTime * 60 * 1000;
@@ -30,6 +30,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import config.YamlConfig;
import constants.ServerConstants;
import client.MapleCharacter;
import java.util.concurrent.ScheduledFuture;
@@ -101,19 +102,19 @@ public class MapleMonsterAggroCoordinator {
runAggroUpdate(1);
runSortLeadingCharactersAggro();
}
}, ServerConstants.MOB_STATUS_AGGRO_INTERVAL, ServerConstants.MOB_STATUS_AGGRO_INTERVAL);
}, YamlConfig.config.server.MOB_STATUS_AGGRO_INTERVAL, YamlConfig.config.server.MOB_STATUS_AGGRO_INTERVAL);
} finally {
idleLock.unlock();
}
int timeDelta = (int) Math.ceil((Server.getInstance().getCurrentTime() - lastStopTime) / ServerConstants.MOB_STATUS_AGGRO_INTERVAL);
int timeDelta = (int) Math.ceil((Server.getInstance().getCurrentTime() - lastStopTime) / YamlConfig.config.server.MOB_STATUS_AGGRO_INTERVAL);
if (timeDelta > 0) {
runAggroUpdate(timeDelta);
}
}
private static void updateEntryExpiration(PlayerAggroEntry pae) {
pae.toNextUpdate = (int) Math.ceil((120000L / ServerConstants.MOB_STATUS_AGGRO_INTERVAL) / Math.pow(2, pae.expireStreak + pae.currentDamageInstances));
pae.toNextUpdate = (int) Math.ceil((120000L / YamlConfig.config.server.MOB_STATUS_AGGRO_INTERVAL) / Math.pow(2, pae.expireStreak + pae.currentDamageInstances));
}
private static void insertEntryDamage(PlayerAggroEntry pae, int damage) {
@@ -318,7 +319,7 @@ public class MapleMonsterAggroCoordinator {
if (chr != null) {
if (player.getId() == pae.cid) {
return true;
} else if (pae.updateStreak < ServerConstants.MOB_STATUS_AGGRO_PERSISTENCE && chr.isAlive()) { // verifies currently leading players activity
} else if (pae.updateStreak < YamlConfig.config.server.MOB_STATUS_AGGRO_PERSISTENCE && chr.isAlive()) { // verifies currently leading players activity
return false;
}
}
@@ -21,6 +21,7 @@ package net.server.coordinator;
import client.MapleCharacter;
import client.MapleJob;
import config.YamlConfig;
import constants.ServerConstants;
import java.io.File;
import net.server.world.MapleParty;
@@ -370,7 +371,7 @@ public class MaplePartySearchCoordinator {
} else {
LeaderSearchMetadata settings = searchSettings.get(leader.getId());
if (settings != null) {
if (settings.reentryCount < ServerConstants.PARTY_SEARCH_REENTRY_LIMIT) {
if (settings.reentryCount < YamlConfig.config.server.PARTY_SEARCH_REENTRY_LIMIT) {
settings.reentryCount += 1;
recalledLeaders.add(leader);
} else {
@@ -413,7 +414,7 @@ public class MaplePartySearchCoordinator {
if (leader.isLoggedinWorld()) {
if (settings != null) {
recycledLeaders.add(new Pair<>(leader, settings));
if (ServerConstants.USE_DEBUG && leader.isGM()) leader.dropMessage(5, "Your Party Search token session is now on waiting queue for up to 7 minutes, to get it working right away please stop your Party Search and retry again later.");
if (YamlConfig.config.server.USE_DEBUG && leader.isGM()) leader.dropMessage(5, "Your Party Search token session is now on waiting queue for up to 7 minutes, to get it working right away please stop your Party Search and retry again later.");
} else {
leader.dropMessage(5, "Your Party Search token session expired, please stop your Party Search and retry again later.");
}
@@ -21,6 +21,7 @@ package net.server.coordinator;
import client.MapleCharacter;
import client.MapleClient;
import config.YamlConfig;
import constants.ServerConstants;
import net.server.Server;
@@ -163,8 +164,8 @@ public class MapleSessionCoordinator {
hwidCount++;
}
}
if (hwidCount < ServerConstants.MAX_ALLOWED_ACCOUNT_HWID) {
if (hwidCount < YamlConfig.config.server.MAX_ALLOWED_ACCOUNT_HWID) {
registerAccessAccount(con, remoteHwid, accountId);
return true;
}
@@ -174,15 +175,15 @@ public class MapleSessionCoordinator {
} catch (SQLException ex) {
ex.printStackTrace();
}
return false;
}
private static boolean attemptAccessAccount(String nibbleHwid, int accountId, boolean routineCheck) {
try {
Connection con = DatabaseConnection.getConnection();
int hwidCount = 0;
try (PreparedStatement ps = con.prepareStatement("SELECT SQL_CACHE * FROM hwidaccounts WHERE accountid = ?")) {
ps.setInt(1, accountId);
try (ResultSet rs = ps.executeQuery()) {
@@ -191,19 +192,19 @@ public class MapleSessionCoordinator {
if (rsHwid.endsWith(nibbleHwid)) {
if (!routineCheck) {
// better update HWID relevance as soon as the login is authenticated
int loginRelevance = rs.getInt("relevance");
updateAccessAccount(con, rsHwid, accountId, loginRelevance);
}
return true;
}
hwidCount++;
}
}
if (hwidCount < ServerConstants.MAX_ALLOWED_ACCOUNT_HWID) {
if (hwidCount < YamlConfig.config.server.MAX_ALLOWED_ACCOUNT_HWID) {
return true;
}
} finally {
@@ -212,25 +213,25 @@ public class MapleSessionCoordinator {
} catch (SQLException ex) {
ex.printStackTrace();
}
return false;
}
private Lock getCoodinatorLock(String remoteHost) {
return poolLock.get(Math.abs(remoteHost.hashCode()) % 100);
}
public static String getSessionRemoteAddress(IoSession session) {
return (String) session.getAttribute(MapleClient.CLIENT_REMOTE_ADDRESS);
}
private static MapleClient getSessionClient(IoSession session) {
return (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
}
public void updateOnlineSession(IoSession session) {
MapleClient client = getSessionClient(session);
if (client != null) {
int accountId = client.getAccID();
MapleClient ingameClient = onlineClients.get(accountId);
@@ -241,13 +242,13 @@ public class MapleSessionCoordinator {
onlineClients.put(accountId, client);
}
}
public boolean canStartLoginSession(IoSession session) {
if (!ServerConstants.DETERRED_MULTICLIENT) return true;
if (!YamlConfig.config.server.DETERRED_MULTICLIENT) return true;
String remoteHost = getSessionRemoteAddress(session);
Lock lock = getCoodinatorLock(remoteHost);
try {
int tries = 0;
while (true) {
@@ -256,19 +257,19 @@ public class MapleSessionCoordinator {
if (pooledRemoteHosts.contains(remoteHost)) {
return false;
}
pooledRemoteHosts.add(remoteHost);
} finally {
lock.unlock();
}
break;
} else {
if(tries == 2) {
return true;
}
tries++;
Thread.sleep(1777);
}
}
@@ -276,7 +277,7 @@ public class MapleSessionCoordinator {
e.printStackTrace();
return true;
}
try {
String knownHwid = cachedHostHwids.get(remoteHost);
if (knownHwid != null) {
@@ -284,15 +285,15 @@ public class MapleSessionCoordinator {
return false;
}
}
if (loginRemoteHosts.containsKey(remoteHost)) {
return false;
}
Set<IoSession> lrh = new HashSet<>(2);
lrh.add(session);
loginRemoteHosts.put(remoteHost, lrh);
return true;
} finally {
lock.lock();
@@ -303,7 +304,7 @@ public class MapleSessionCoordinator {
}
}
}
public void closeLoginSession(IoSession session) {
String remoteHost = getSessionRemoteAddress(session);
Set<IoSession> lrh = loginRemoteHosts.get(remoteHost);
@@ -313,15 +314,15 @@ public class MapleSessionCoordinator {
loginRemoteHosts.remove(remoteHost);
}
}
String nibbleHwid = (String) session.removeAttribute(MapleClient.CLIENT_NIBBLEHWID);
if (nibbleHwid != null) {
onlineRemoteHwids.remove(nibbleHwid);
MapleClient client = getSessionClient(session);
if (client != null) {
MapleClient loggedClient = onlineClients.get(client.getAccID());
// do not remove an online game session here, only login session
if (loggedClient != null && loggedClient.getSessionId() == client.getSessionId()) {
onlineClients.remove(client.getAccID());
@@ -329,16 +330,16 @@ public class MapleSessionCoordinator {
}
}
}
public AntiMulticlientResult attemptLoginSession(IoSession session, String nibbleHwid, int accountId, boolean routineCheck) {
if (!ServerConstants.DETERRED_MULTICLIENT) {
if (!YamlConfig.config.server.DETERRED_MULTICLIENT) {
session.setAttribute(MapleClient.CLIENT_NIBBLEHWID, nibbleHwid);
return AntiMulticlientResult.SUCCESS;
}
String remoteHost = getSessionRemoteAddress(session);
Lock lock = getCoodinatorLock(remoteHost);
try {
int tries = 0;
while (true) {
@@ -347,19 +348,19 @@ public class MapleSessionCoordinator {
if (pooledRemoteHosts.contains(remoteHost)) {
return AntiMulticlientResult.REMOTE_PROCESSING;
}
pooledRemoteHosts.add(remoteHost);
} finally {
lock.unlock();
}
break;
} else {
if(tries == 2) {
return AntiMulticlientResult.COORDINATOR_ERROR;
}
tries++;
Thread.sleep(1777);
}
}
@@ -367,12 +368,12 @@ public class MapleSessionCoordinator {
e.printStackTrace();
return AntiMulticlientResult.COORDINATOR_ERROR;
}
try {
if (!loginStorage.registerLogin(accountId)) {
return AntiMulticlientResult.MANY_ACCOUNT_ATTEMPTS;
}
if (!routineCheck) {
if (onlineRemoteHwids.contains(nibbleHwid)) {
return AntiMulticlientResult.REMOTE_LOGGEDIN;
@@ -381,7 +382,7 @@ public class MapleSessionCoordinator {
if (!attemptAccessAccount(nibbleHwid, accountId, routineCheck)) {
return AntiMulticlientResult.REMOTE_REACHED_LIMIT;
}
session.setAttribute(MapleClient.CLIENT_NIBBLEHWID, nibbleHwid);
onlineRemoteHwids.add(nibbleHwid);
} else {
@@ -389,7 +390,7 @@ public class MapleSessionCoordinator {
return AntiMulticlientResult.REMOTE_REACHED_LIMIT;
}
}
return AntiMulticlientResult.SUCCESS;
} finally {
lock.lock();
@@ -400,10 +401,10 @@ public class MapleSessionCoordinator {
}
}
}
public AntiMulticlientResult attemptGameSession(IoSession session, int accountId, String remoteHwid) {
String remoteHost = getSessionRemoteAddress(session);
if (!ServerConstants.DETERRED_MULTICLIENT) {
if (!YamlConfig.config.server.DETERRED_MULTICLIENT) {
associateRemoteHostHwid(remoteHost, remoteHwid);
return AntiMulticlientResult.SUCCESS;
}
@@ -20,6 +20,7 @@
package net.server.coordinator.matchchecker.listener;
import client.MapleCharacter;
import config.YamlConfig;
import constants.GameConstants;
import constants.ServerConstants;
import net.server.coordinator.matchchecker.AbstractMatchCheckerListener;
@@ -103,8 +104,8 @@ public class MatchCheckerGuildCreation implements MatchCheckerListenerRecipe {
return;
}
}
if (leader.getMeso() < ServerConstants.CREATE_GUILD_COST) {
leader.dropMessage(1, "You do not have " + GameConstants.numberWithCommas(ServerConstants.CREATE_GUILD_COST) + " mesos to create a Guild.");
if (leader.getMeso() < YamlConfig.config.server.CREATE_GUILD_COST) {
leader.dropMessage(1, "You do not have " + GameConstants.numberWithCommas(YamlConfig.config.server.CREATE_GUILD_COST) + " mesos to create a Guild.");
broadcastGuildCreationDismiss(matchPlayers);
return;
}
@@ -115,7 +116,7 @@ public class MatchCheckerGuildCreation implements MatchCheckerListenerRecipe {
broadcastGuildCreationDismiss(matchPlayers);
return;
}
leader.gainMeso(-ServerConstants.CREATE_GUILD_COST, true, false, true);
leader.gainMeso(-YamlConfig.config.server.CREATE_GUILD_COST, true, false, true);
leader.getMGC().setGuildId(gid);
MapleGuild guild = Server.getInstance().getGuild(leader.getGuildId(), leader.getWorld(), leader); // initialize guild structure
+3 -2
View File
@@ -23,6 +23,7 @@ package net.server.guild;
import client.MapleCharacter;
import client.MapleClient;
import config.YamlConfig;
import constants.ServerConstants;
import java.sql.Connection;
@@ -838,10 +839,10 @@ public class MapleGuild {
}
public static int getIncreaseGuildCost(int size) {
int cost = ServerConstants.EXPAND_GUILD_BASE_COST + Math.max(0, (size - 15) / 5) * ServerConstants.EXPAND_GUILD_TIER_COST;
int cost = YamlConfig.config.server.EXPAND_GUILD_BASE_COST + Math.max(0, (size - 15) / 5) * YamlConfig.config.server.EXPAND_GUILD_TIER_COST;
if (size > 30) {
return Math.min(ServerConstants.EXPAND_GUILD_MAX_COST, Math.max(cost, 5000000));
return Math.min(YamlConfig.config.server.EXPAND_GUILD_MAX_COST, Math.max(cost, 5000000));
} else {
return cost;
}
@@ -26,6 +26,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Calendar;
import config.YamlConfig;
import constants.ServerConstants;
import net.MaplePacketHandler;
import net.server.Server;
@@ -64,14 +65,14 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
String remoteHost = getRemoteIp(c.getSession());
if (!remoteHost.contentEquals("null")) {
if (ServerConstants.USE_IP_VALIDATION) { // thanks Alex (CanIGetaPR) for suggesting IP validation as a server flag
if (YamlConfig.config.server.USE_IP_VALIDATION) { // thanks Alex (CanIGetaPR) for suggesting IP validation as a server flag
if (remoteHost.startsWith("127.")) {
if (!ServerConstants.LOCALSERVER) { // thanks Mills for noting HOST can also have a field named "localhost"
if (!YamlConfig.config.server.LOCALSERVER) { // thanks Mills for noting HOST can also have a field named "localhost"
c.announce(MaplePacketCreator.getLoginFailed(13)); // cannot login as localhost if it's not a local server
return;
}
} else {
if (ServerConstants.LOCALSERVER) {
if (YamlConfig.config.server.LOCALSERVER) {
c.announce(MaplePacketCreator.getLoginFailed(13)); // cannot login as non-localhost if it's a local server
return;
}
@@ -93,12 +94,12 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
Connection con = null;
PreparedStatement ps = null;
if (ServerConstants.AUTOMATIC_REGISTER && loginok == 5) {
if (YamlConfig.config.server.AUTOMATIC_REGISTER && loginok == 5) {
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("INSERT INTO accounts (name, password, birthday, tempban) VALUES (?, ?, ?, ?);", Statement.RETURN_GENERATED_KEYS); //Jayd: Added birthday, tempban
ps.setString(1, login);
ps.setString(2, ServerConstants.BCRYPT_MIGRATION ? BCrypt.hashpw(pwd, BCrypt.gensalt(12)) : hashpwSHA512(pwd));
ps.setString(2, YamlConfig.config.server.BCRYPT_MIGRATION ? BCrypt.hashpw(pwd, BCrypt.gensalt(12)) : hashpwSHA512(pwd));
ps.setString(3, "2018-06-20"); //Jayd's idea: was added to solve the MySQL 5.7 strict checking (birthday)
ps.setString(4, "2018-06-20"); //Jayd's idea: was added to solve the MySQL 5.7 strict checking (tempban)
ps.executeUpdate();
@@ -116,7 +117,7 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
}
}
if (ServerConstants.BCRYPT_MIGRATION && (loginok <= -10)) { // -10 means migration to bcrypt, -23 means TOS wasn't accepted
if (YamlConfig.config.server.BCRYPT_MIGRATION && (loginok <= -10)) { // -10 means migration to bcrypt, -23 means TOS wasn't accepted
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("UPDATE accounts SET password = ? WHERE name = ?;");
@@ -23,6 +23,7 @@ package net.server.handlers.login;
import client.MapleCharacter;
import client.MapleClient;
import config.YamlConfig;
import constants.ServerConstants;
import java.util.List;
import net.AbstractMaplePacketHandler;
@@ -64,7 +65,7 @@ public final class ViewAllCharHandler extends AbstractMaplePacketHandler {
c.announce(MaplePacketCreator.showAllCharacter(charsSize, unk));
for (Pair<Integer, List<MapleCharacter>> wchars : worldChars) {
c.announce(MaplePacketCreator.showAllCharacterInfo(wchars.getLeft(), wchars.getRight(), ServerConstants.ENABLE_PIC && !c.canBypassPic()));
c.announce(MaplePacketCreator.showAllCharacterInfo(wchars.getLeft(), wchars.getRight(), YamlConfig.config.server.ENABLE_PIC && !c.canBypassPic()));
}
} catch (Exception e) {
e.printStackTrace();
@@ -19,6 +19,7 @@
*/
package net.server.worker;
import config.YamlConfig;
import net.server.world.World;
import client.MapleCharacter;
import constants.ServerConstants;
@@ -31,7 +32,7 @@ public class CharacterAutosaverWorker extends BaseWorker implements Runnable {
@Override
public void run() {
if(!ServerConstants.USE_AUTOSAVE) return;
if(!YamlConfig.config.server.USE_AUTOSAVE) return;
PlayerStorage ps = wserv.getPlayerStorage();
for(MapleCharacter chr: ps.getAllCharacters()) {
@@ -26,6 +26,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import client.MapleJob;
import config.YamlConfig;
import tools.DatabaseConnection;
import constants.ServerConstants;
import net.server.Server;
@@ -85,7 +86,7 @@ public class RankingLoginWorker implements Runnable {
con = DatabaseConnection.getConnection();
con.setAutoCommit(false);
if(ServerConstants.USE_REFRESH_RANK_MOVE == true) {
if(YamlConfig.config.server.USE_REFRESH_RANK_MOVE == true) {
resetMoveRank(true);
resetMoveRank(false);
}
+2 -1
View File
@@ -1,6 +1,7 @@
package net.server.worker;
import client.MapleCharacter;
import config.YamlConfig;
import constants.ServerConstants;
import net.server.world.World;
import tools.FilePrinter;
@@ -17,7 +18,7 @@ public class TimeoutWorker extends BaseWorker implements Runnable {
long time = System.currentTimeMillis();
Collection<MapleCharacter> chars = wserv.getPlayerStorage().getAllCharacters();
for(MapleCharacter chr : chars) {
if(time - chr.getClient().getLastPacket() > ServerConstants.TIMEOUT_DURATION) {
if(time - chr.getClient().getLastPacket() > YamlConfig.config.server.TIMEOUT_DURATION) {
FilePrinter.print(FilePrinter.DCS + chr.getClient().getAccountName(), chr.getName() + " auto-disconnected due to inactivity.");
chr.getClient().disconnect(true, chr.getCashShop().isOpened());
}
+2 -1
View File
@@ -23,6 +23,7 @@ package net.server.world;
import client.MapleCharacter;
import client.MapleClient;
import config.YamlConfig;
import constants.ServerConstants;
import java.util.Collection;
import java.util.Collections;
@@ -344,7 +345,7 @@ public class MapleParty {
public static boolean createParty(MapleCharacter player, boolean silentCheck) {
MapleParty party = player.getParty();
if (party == null) {
if (player.getLevel() < 10 && !ServerConstants.USE_PARTY_FOR_STARTERS) {
if (player.getLevel() < 10 && !YamlConfig.config.server.USE_PARTY_FOR_STARTERS) {
player.announce(MaplePacketCreator.partyStatusMessage(10));
return false;
} else if (player.getAriantColiseum() != null) {
+14 -13
View File
@@ -27,6 +27,7 @@ import client.BuddyList.BuddyOperation;
import client.BuddylistEntry;
import client.MapleCharacter;
import client.MapleFamily;
import config.YamlConfig;
import constants.GameConstants;
import constants.ServerConstants;
import java.sql.Connection;
@@ -211,13 +212,13 @@ public class World {
merchantSchedule = tman.register(new HiredMerchantWorker(this), 10 * 60 * 1000, 10 * 60 * 1000);
timedMapObjectsSchedule = tman.register(new TimedMapObjectWorker(this), 60 * 1000, 60 * 1000);
charactersSchedule = tman.register(new CharacterAutosaverWorker(this), 60 * 60 * 1000, 60 * 60 * 1000);
marriagesSchedule = tman.register(new WeddingReservationWorker(this), ServerConstants.WEDDING_RESERVATION_INTERVAL * 60 * 1000, ServerConstants.WEDDING_RESERVATION_INTERVAL * 60 * 1000);
marriagesSchedule = tman.register(new WeddingReservationWorker(this), YamlConfig.config.server.WEDDING_RESERVATION_INTERVAL * 60 * 1000, YamlConfig.config.server.WEDDING_RESERVATION_INTERVAL * 60 * 1000);
mapOwnershipSchedule = tman.register(new MapOwnershipWorker(this), 20 * 1000, 20 * 1000);
fishingSchedule = tman.register(new FishingWorker(this), 10 * 1000, 10 * 1000);
partySearchSchedule = tman.register(new PartySearchWorker(this), 10 * 1000, 10 * 1000);
timeoutSchedule = tman.register(new TimeoutWorker(this), 10 * 1000, 10 * 1000);
if(ServerConstants.USE_FAMILY_SYSTEM) {
if(YamlConfig.config.server.USE_FAMILY_SYSTEM) {
long timeLeft = Server.getTimeLeftForNextDay();
FamilyDailyResetWorker.resetEntitlementUsage(this);
tman.register(new FamilyDailyResetWorker(this), 24 * 60 * 60 * 1000, timeLeft);
@@ -624,7 +625,7 @@ public class World {
}
public int getWorldCapacityStatus() {
int worldCap = getChannelsSize() * ServerConstants.CHANNEL_LOAD;
int worldCap = getChannelsSize() * YamlConfig.config.server.CHANNEL_LOAD;
int num = players.getSize();
int status;
@@ -1320,7 +1321,7 @@ public class World {
}
public List<Pair<Integer, Integer>> getOwlSearchedItems() {
if(ServerConstants.USE_ENFORCE_ITEM_SUGGESTION) {
if(YamlConfig.config.server.USE_ENFORCE_ITEM_SUGGESTION) {
return new ArrayList<>(0);
}
@@ -1355,7 +1356,7 @@ public class World {
}
private List<List<Pair<Integer, Integer>>> getBoughtCashItems() {
if (ServerConstants.USE_ENFORCE_ITEM_SUGGESTION) {
if (YamlConfig.config.server.USE_ENFORCE_ITEM_SUGGESTION) {
List<List<Pair<Integer, Integer>>> boughtCounts = new ArrayList<>(9);
// thanks GabrielSin for pointing out an issue here
@@ -1445,7 +1446,7 @@ public class World {
}
public void registerPetHunger(MapleCharacter chr, byte petSlot) {
if(chr.isGM() && ServerConstants.GM_PETS_NEVER_HUNGRY || ServerConstants.PETS_NEVER_HUNGRY) {
if(chr.isGM() && YamlConfig.config.server.GM_PETS_NEVER_HUNGRY || YamlConfig.config.server.PETS_NEVER_HUNGRY) {
return;
}
@@ -1454,8 +1455,8 @@ public class World {
activePetsLock.lock();
try {
int initProc;
if(Server.getInstance().getCurrentTime() - petUpdate > 55000) initProc = ServerConstants.PET_EXHAUST_COUNT - 2;
else initProc = ServerConstants.PET_EXHAUST_COUNT - 1;
if(Server.getInstance().getCurrentTime() - petUpdate > 55000) initProc = YamlConfig.config.server.PET_EXHAUST_COUNT - 2;
else initProc = YamlConfig.config.server.PET_EXHAUST_COUNT - 1;
activePets.put(key, initProc);
} finally {
@@ -1490,7 +1491,7 @@ public class World {
if(chr == null || !chr.isLoggedinWorld()) continue;
Integer dpVal = dp.getValue() + 1;
if(dpVal == ServerConstants.PET_EXHAUST_COUNT) {
if(dpVal == YamlConfig.config.server.PET_EXHAUST_COUNT) {
chr.runFullnessSchedule(dp.getKey() % 4);
dpVal = 0;
}
@@ -1505,7 +1506,7 @@ public class World {
}
public void registerMountHunger(MapleCharacter chr) {
if(chr.isGM() && ServerConstants.GM_PETS_NEVER_HUNGRY || ServerConstants.PETS_NEVER_HUNGRY) {
if(chr.isGM() && YamlConfig.config.server.GM_PETS_NEVER_HUNGRY || YamlConfig.config.server.PETS_NEVER_HUNGRY) {
return;
}
@@ -1513,8 +1514,8 @@ public class World {
activeMountsLock.lock();
try {
int initProc;
if(Server.getInstance().getCurrentTime() - mountUpdate > 45000) initProc = ServerConstants.MOUNT_EXHAUST_COUNT - 2;
else initProc = ServerConstants.MOUNT_EXHAUST_COUNT - 1;
if(Server.getInstance().getCurrentTime() - mountUpdate > 45000) initProc = YamlConfig.config.server.MOUNT_EXHAUST_COUNT - 2;
else initProc = YamlConfig.config.server.MOUNT_EXHAUST_COUNT - 1;
activeMounts.put(key, initProc);
} finally {
@@ -1548,7 +1549,7 @@ public class World {
if(chr == null || !chr.isLoggedinWorld()) continue;
int dpVal = dp.getValue() + 1;
if(dpVal == ServerConstants.MOUNT_EXHAUST_COUNT) {
if(dpVal == YamlConfig.config.server.MOUNT_EXHAUST_COUNT) {
if (!chr.runTirednessSchedule()) {
continue;
}