Reformat and clean up "net" package
This commit is contained in:
@@ -26,10 +26,10 @@ import net.server.world.World;
|
||||
*/
|
||||
public abstract class BaseTask implements Runnable {
|
||||
protected World wserv;
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {}
|
||||
|
||||
|
||||
public BaseTask(World world) {
|
||||
wserv = world;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import server.expeditions.ExpeditionBossLog;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class BossLogTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ExpeditionBossLog.resetBossLogTable();
|
||||
|
||||
@@ -28,19 +28,21 @@ import net.server.world.World;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class CharacterAutosaverTask extends BaseTask implements Runnable { // thanks Alex09 (Alex-0000) for noticing these runnable classes are tasks, "workers" runs them
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(!YamlConfig.config.server.USE_AUTOSAVE) return;
|
||||
|
||||
if (!YamlConfig.config.server.USE_AUTOSAVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerStorage ps = wserv.getPlayerStorage();
|
||||
for(Character chr: ps.getAllCharacters()) {
|
||||
if(chr != null && chr.isLoggedin()) {
|
||||
for (Character chr : ps.getAllCharacters()) {
|
||||
if (chr != null && chr.isLoggedin()) {
|
||||
chr.saveCharToDB(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public CharacterAutosaverTask(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ import net.server.Server;
|
||||
|
||||
/**
|
||||
* @author Ronan
|
||||
* @info Thread responsible for announcing other players diseases when one enters into a map
|
||||
* @info Thread responsible for announcing other players diseases when one enters into a map
|
||||
*/
|
||||
public class CharacterDiseaseTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
Server serv = Server.getInstance();
|
||||
|
||||
|
||||
serv.updateCurrentTime();
|
||||
serv.runAnnouncePlayerDiseasesSchedule();
|
||||
}
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
*/
|
||||
package net.server.task;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* @author Ronan
|
||||
* @info Thread responsible for maintaining coupons EXP & DROP effects active
|
||||
* @info Thread responsible for maintaining coupons EXP & DROP effects active
|
||||
*/
|
||||
public class CouponTask implements Runnable {
|
||||
private static final Logger log = LoggerFactory.getLogger(CouponTask.class);
|
||||
|
||||
@@ -26,7 +26,7 @@ import client.processor.npc.FredrickProcessor;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class DueyFredrickTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
FredrickProcessor.runFredrickSchedule();
|
||||
|
||||
@@ -22,11 +22,10 @@ package net.server.task;
|
||||
import net.server.coordinator.world.EventRecallCoordinator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class EventRecallCoordinatorTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
EventRecallCoordinator.getInstance().manageEventInstances();
|
||||
|
||||
@@ -21,7 +21,7 @@ public class FamilyDailyResetTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
resetEntitlementUsage(world);
|
||||
for(Family family : world.getFamilies()) {
|
||||
for (Family family : world.getFamilies()) {
|
||||
family.resetDailyReps();
|
||||
}
|
||||
}
|
||||
@@ -33,22 +33,22 @@ public class FamilyDailyResetTask implements Runnable {
|
||||
resetTime.set(Calendar.MINUTE, 0);
|
||||
resetTime.set(Calendar.SECOND, 0);
|
||||
resetTime.set(Calendar.MILLISECOND, 0);
|
||||
try(Connection con = DatabaseConnection.getConnection()) {
|
||||
try(PreparedStatement ps = con.prepareStatement("UPDATE family_character SET todaysrep = 0, reptosenior = 0 WHERE lastresettime <= ?")) {
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE family_character SET todaysrep = 0, reptosenior = 0 WHERE lastresettime <= ?")) {
|
||||
ps.setLong(1, resetTime.getTimeInMillis());
|
||||
ps.executeUpdate();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not reset daily rep for families. On " + Calendar.getInstance().getTime());
|
||||
e.printStackTrace();
|
||||
}
|
||||
try(PreparedStatement ps = con.prepareStatement("DELETE FROM family_entitlement WHERE timestamp <= ?")) {
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM family_entitlement WHERE timestamp <= ?")) {
|
||||
ps.setLong(1, resetTime.getTimeInMillis());
|
||||
ps.executeUpdate();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not do daily reset for family entitlements. On " + Calendar.getInstance().getTime());
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get connection to DB.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ import net.server.world.World;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class FishingTask extends BaseTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
wserv.runCheckFishingSchedule();
|
||||
}
|
||||
|
||||
|
||||
public FishingTask(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ import net.server.world.World;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class HiredMerchantTask extends BaseTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
wserv.runHiredMerchantSchedule();
|
||||
}
|
||||
|
||||
|
||||
public HiredMerchantTask(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import net.server.coordinator.world.InviteCoordinator;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class InvitationTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
InviteCoordinator.runTimeoutSchedule();
|
||||
|
||||
@@ -22,11 +22,10 @@ package net.server.task;
|
||||
import net.server.coordinator.session.SessionCoordinator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class LoginCoordinatorTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SessionCoordinator.getInstance().clearExpiredHwidHistory();
|
||||
|
||||
@@ -23,11 +23,10 @@ import net.server.coordinator.login.LoginBypassCoordinator;
|
||||
import net.server.coordinator.session.SessionCoordinator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class LoginStorageTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SessionCoordinator.getInstance().runUpdateLoginHistory();
|
||||
|
||||
@@ -19,21 +19,21 @@
|
||||
*/
|
||||
package net.server.task;
|
||||
|
||||
import net.server.world.World;
|
||||
import net.server.channel.Channel;
|
||||
import net.server.world.World;
|
||||
|
||||
/**
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MapOwnershipTask extends BaseTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Channel ch : wserv.getChannels()) {
|
||||
ch.runCheckOwnedMapsSchedule();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public MapOwnershipTask(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ import net.server.world.World;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MountTirednessTask extends BaseTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
wserv.runMountSchedule();
|
||||
}
|
||||
|
||||
|
||||
public MountTirednessTask(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@@ -22,16 +22,15 @@ package net.server.task;
|
||||
import net.server.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class PartySearchTask extends BaseTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
wserv.runPartySearchUpdateSchedule();
|
||||
}
|
||||
|
||||
|
||||
public PartySearchTask(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ import net.server.world.World;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class PetFullnessTask extends BaseTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
wserv.runPetSchedule();
|
||||
}
|
||||
|
||||
|
||||
public PetFullnessTask(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@@ -22,11 +22,10 @@ package net.server.task;
|
||||
import net.server.Server;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class RankingCommandTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Server.getInstance().updateWorldPlayerRanking();
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.sql.SQLException;
|
||||
*/
|
||||
public class RankingLoginTask implements Runnable {
|
||||
private long lastUpdate = System.currentTimeMillis();
|
||||
|
||||
|
||||
private void resetMoveRank(boolean job) throws SQLException {
|
||||
String query = "UPDATE characters SET " + (job ? "jobRankMove = 0" : "rankMove = 0");
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
@@ -82,7 +82,7 @@ public class RankingLoginTask implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import net.server.audit.LockCollector;
|
||||
|
||||
/**
|
||||
* @author Ronan
|
||||
* @info Thread responsible for expiring locks signalized for dispose.
|
||||
* @info Thread responsible for expiring locks signalized for dispose.
|
||||
*/
|
||||
public class ReleaseLockTask implements Runnable {
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,7 @@ import server.maps.MapManager;
|
||||
* @author Resinate
|
||||
*/
|
||||
public class RespawnTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Channel ch : Server.getInstance().getAllChannels()) {
|
||||
|
||||
@@ -25,15 +25,15 @@ import net.server.world.World;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class ServerMessageTask extends BaseTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// It's purpose is for tracking whether the player client currently displays a boss HPBar and, if so,
|
||||
// temporarily disable the server message for that player.
|
||||
|
||||
|
||||
wserv.runDisabledServerMessagesSchedule();
|
||||
}
|
||||
|
||||
|
||||
public ServerMessageTask(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ import net.server.world.World;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class TimedMapObjectTask extends BaseTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
wserv.runTimedMapObjectSchedule();
|
||||
}
|
||||
|
||||
|
||||
public TimedMapObjectTask(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import tools.FilePrinter;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Shavit
|
||||
*/
|
||||
public class TimeoutTask extends BaseTask implements Runnable {
|
||||
@@ -16,8 +15,8 @@ public class TimeoutTask extends BaseTask implements Runnable {
|
||||
public void run() {
|
||||
long time = System.currentTimeMillis();
|
||||
Collection<Character> chars = wserv.getPlayerStorage().getAllCharacters();
|
||||
for(Character chr : chars) {
|
||||
if(time - chr.getClient().getLastPacket() > YamlConfig.config.server.TIMEOUT_DURATION) {
|
||||
for (Character chr : chars) {
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -19,37 +19,38 @@
|
||||
*/
|
||||
package net.server.task;
|
||||
|
||||
import java.util.Set;
|
||||
import net.server.world.World;
|
||||
import net.server.channel.Channel;
|
||||
import net.server.world.World;
|
||||
import tools.Pair;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Ronan
|
||||
*/
|
||||
public class WeddingReservationTask extends BaseTask implements Runnable {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for(Channel ch : wserv.getChannels()) {
|
||||
for (Channel ch : wserv.getChannels()) {
|
||||
Pair<Boolean, Pair<Integer, Set<Integer>>> wedding;
|
||||
|
||||
|
||||
wedding = ch.getNextWeddingReservation(true); // start cathedral
|
||||
if(wedding != null) {
|
||||
if (wedding != null) {
|
||||
ch.setOngoingWedding(true, wedding.getLeft(), wedding.getRight().getLeft(), wedding.getRight().getRight());
|
||||
} else {
|
||||
ch.setOngoingWedding(true, null, null, null);
|
||||
}
|
||||
|
||||
|
||||
wedding = ch.getNextWeddingReservation(false); // start chapel
|
||||
if(wedding != null) {
|
||||
if (wedding != null) {
|
||||
ch.setOngoingWedding(false, wedding.getLeft(), wedding.getRight().getLeft(), wedding.getRight().getRight());
|
||||
} else {
|
||||
ch.setOngoingWedding(false, null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public WeddingReservationTask(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user