Rename and clean up MapleExpeditionBossLog
This commit is contained in:
@@ -59,7 +59,7 @@ import server.CashShop.CashItemFactory;
|
|||||||
import server.MapleSkillbookInformationProvider;
|
import server.MapleSkillbookInformationProvider;
|
||||||
import server.ThreadManager;
|
import server.ThreadManager;
|
||||||
import server.TimerManager;
|
import server.TimerManager;
|
||||||
import server.expeditions.MapleExpeditionBossLog;
|
import server.expeditions.ExpeditionBossLog;
|
||||||
import server.life.MaplePlayerNPCFactory;
|
import server.life.MaplePlayerNPCFactory;
|
||||||
import server.quest.MapleQuest;
|
import server.quest.MapleQuest;
|
||||||
import tools.DatabaseConnection;
|
import tools.DatabaseConnection;
|
||||||
@@ -951,7 +951,7 @@ public class Server {
|
|||||||
tMan.register(new RespawnTask(), YamlConfig.config.server.RESPAWN_INTERVAL, YamlConfig.config.server.RESPAWN_INTERVAL);
|
tMan.register(new RespawnTask(), YamlConfig.config.server.RESPAWN_INTERVAL, YamlConfig.config.server.RESPAWN_INTERVAL);
|
||||||
|
|
||||||
timeLeft = getTimeLeftForNextDay();
|
timeLeft = getTimeLeftForNextDay();
|
||||||
MapleExpeditionBossLog.resetBossLogTable();
|
ExpeditionBossLog.resetBossLogTable();
|
||||||
tMan.register(new BossLogTask(), 24 * 60 * 60 * 1000, timeLeft);
|
tMan.register(new BossLogTask(), 24 * 60 * 60 * 1000, timeLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.server.task;
|
package net.server.task;
|
||||||
|
|
||||||
import server.expeditions.MapleExpeditionBossLog;
|
import server.expeditions.ExpeditionBossLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ronan
|
* @author Ronan
|
||||||
@@ -28,6 +28,6 @@ public class BossLogTask implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MapleExpeditionBossLog.resetBossLogTable();
|
ExpeditionBossLog.resetBossLogTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import scripting.npc.NPCScriptManager;
|
|||||||
import server.MapleItemInformationProvider;
|
import server.MapleItemInformationProvider;
|
||||||
import server.MapleMarriage;
|
import server.MapleMarriage;
|
||||||
import server.expeditions.Expedition;
|
import server.expeditions.Expedition;
|
||||||
import server.expeditions.MapleExpeditionBossLog;
|
import server.expeditions.ExpeditionBossLog;
|
||||||
import server.expeditions.MapleExpeditionType;
|
import server.expeditions.MapleExpeditionType;
|
||||||
import server.life.*;
|
import server.life.*;
|
||||||
import server.maps.MapleMap;
|
import server.maps.MapleMap;
|
||||||
@@ -1076,7 +1076,7 @@ public class AbstractPlayerInteraction {
|
|||||||
Expedition exped = new Expedition(player, type, silent, minPlayers, maxPlayers);
|
Expedition exped = new Expedition(player, type, silent, minPlayers, maxPlayers);
|
||||||
|
|
||||||
int channel = player.getMap().getChannelServer().getId();
|
int channel = player.getMap().getChannelServer().getId();
|
||||||
if (!MapleExpeditionBossLog.attemptBoss(player.getId(), channel, exped, false)) { // thanks Conrad for noticing missing expeditions entry limit
|
if (!ExpeditionBossLog.attemptBoss(player.getId(), channel, exped, false)) { // thanks Conrad for noticing missing expeditions entry limit
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ public class Expedition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int channel = this.getRecruitingMap().getChannelServer().getId();
|
int channel = this.getRecruitingMap().getChannelServer().getId();
|
||||||
if (!MapleExpeditionBossLog.attemptBoss(player.getId(), channel, this, false)) { // thanks Conrad, Cato for noticing some expeditions have entry limit
|
if (!ExpeditionBossLog.attemptBoss(player.getId(), channel, this, false)) { // thanks Conrad, Cato for noticing some expeditions have entry limit
|
||||||
return "Sorry, you've already reached the quota of attempts for this expedition! Try again another day...";
|
return "Sorry, you've already reached the quota of attempts for this expedition! Try again another day...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ public class Expedition {
|
|||||||
int channel = this.getRecruitingMap().getChannelServer().getId();
|
int channel = this.getRecruitingMap().getChannelServer().getId();
|
||||||
|
|
||||||
for (Character chr : getActiveMembers()) {
|
for (Character chr : getActiveMembers()) {
|
||||||
MapleExpeditionBossLog.attemptBoss(chr.getId(), channel, this, true);
|
ExpeditionBossLog.attemptBoss(chr.getId(), channel, this, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,96 +29,96 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Conrad
|
* @author Conrad
|
||||||
* @author Ronan
|
* @author Ronan
|
||||||
*/
|
*/
|
||||||
public class MapleExpeditionBossLog {
|
public class ExpeditionBossLog {
|
||||||
|
|
||||||
public enum BossLogEntry {
|
public enum BossLogEntry {
|
||||||
ZAKUM(2, 1, false),
|
ZAKUM(2, 1, false),
|
||||||
HORNTAIL(2, 1, false),
|
HORNTAIL(2, 1, false),
|
||||||
PINKBEAN(1, 1, false),
|
PINKBEAN(1, 1, false),
|
||||||
SCARGA(1, 1, false),
|
SCARGA(1, 1, false),
|
||||||
PAPULATUS(2, 1, false);
|
PAPULATUS(2, 1, false);
|
||||||
|
|
||||||
private int entries;
|
private final int entries;
|
||||||
private int timeLength;
|
private final int timeLength;
|
||||||
private int minChannel, maxChannel;
|
private final int minChannel;
|
||||||
private boolean week;
|
private final int maxChannel;
|
||||||
|
private final boolean week;
|
||||||
private BossLogEntry(int entries, int timeLength, boolean week) {
|
|
||||||
|
BossLogEntry(int entries, int timeLength, boolean week) {
|
||||||
this(entries, 0, Integer.MAX_VALUE, timeLength, week);
|
this(entries, 0, Integer.MAX_VALUE, timeLength, week);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BossLogEntry(int entries, int minChannel, int maxChannel, int timeLength, boolean week) {
|
BossLogEntry(int entries, int minChannel, int maxChannel, int timeLength, boolean week) {
|
||||||
this.entries = entries;
|
this.entries = entries;
|
||||||
this.minChannel = minChannel;
|
this.minChannel = minChannel;
|
||||||
this.maxChannel = maxChannel;
|
this.maxChannel = maxChannel;
|
||||||
this.timeLength = timeLength;
|
this.timeLength = timeLength;
|
||||||
this.week = week;
|
this.week = week;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Pair<Timestamp, BossLogEntry>> getBossLogResetTimestamps(Calendar timeNow, boolean week) {
|
private static List<Pair<Timestamp, BossLogEntry>> getBossLogResetTimestamps(Calendar timeNow, boolean week) {
|
||||||
List<Pair<Timestamp, BossLogEntry>> resetTimestamps = new LinkedList<>();
|
List<Pair<Timestamp, BossLogEntry>> resetTimestamps = new LinkedList<>();
|
||||||
|
|
||||||
Timestamp ts = new Timestamp(timeNow.getTime().getTime()); // reset all table entries actually, thanks Conrad
|
Timestamp ts = new Timestamp(timeNow.getTime().getTime()); // reset all table entries actually, thanks Conrad
|
||||||
for (BossLogEntry b : BossLogEntry.values()) {
|
for (BossLogEntry b : BossLogEntry.values()) {
|
||||||
if (b.week == week) {
|
if (b.week == week) {
|
||||||
resetTimestamps.add(new Pair<>(ts, b));
|
resetTimestamps.add(new Pair<>(ts, b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resetTimestamps;
|
return resetTimestamps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BossLogEntry getBossEntryByName(String name) {
|
private static BossLogEntry getBossEntryByName(String name) {
|
||||||
for (BossLogEntry b : BossLogEntry.values()) {
|
for (BossLogEntry b : BossLogEntry.values()) {
|
||||||
if (name.contentEquals(b.name())) {
|
if (name.contentEquals(b.name())) {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resetBossLogTable() {
|
public static void resetBossLogTable() {
|
||||||
/*
|
/*
|
||||||
Boss logs resets 12am, weekly thursday 12AM - thanks Smitty Werbenjagermanjensen (superadlez) - https://www.reddit.com/r/Maplestory/comments/61tiup/about_reset_time/
|
Boss logs resets 12am, weekly thursday 12AM - thanks Smitty Werbenjagermanjensen (superadlez) - https://www.reddit.com/r/Maplestory/comments/61tiup/about_reset_time/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Calendar thursday = Calendar.getInstance();
|
Calendar thursday = Calendar.getInstance();
|
||||||
thursday.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
|
thursday.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
|
||||||
thursday.set(Calendar.HOUR, 0);
|
thursday.set(Calendar.HOUR, 0);
|
||||||
thursday.set(Calendar.MINUTE, 0);
|
thursday.set(Calendar.MINUTE, 0);
|
||||||
thursday.set(Calendar.SECOND, 0);
|
thursday.set(Calendar.SECOND, 0);
|
||||||
|
|
||||||
Calendar now = Calendar.getInstance();
|
Calendar now = Calendar.getInstance();
|
||||||
|
|
||||||
long weekLength = 7 * 24 * 60 * 60 * 1000;
|
long weekLength = 7 * 24 * 60 * 60 * 1000;
|
||||||
long halfDayLength = 12 * 60 * 60 * 1000;
|
long halfDayLength = 12 * 60 * 60 * 1000;
|
||||||
|
|
||||||
long deltaTime = now.getTime().getTime() - thursday.getTime().getTime(); // 2x time: get Date into millis
|
long deltaTime = now.getTime().getTime() - thursday.getTime().getTime(); // 2x time: get Date into millis
|
||||||
deltaTime += halfDayLength;
|
deltaTime += halfDayLength;
|
||||||
deltaTime %= weekLength;
|
deltaTime %= weekLength;
|
||||||
deltaTime -= halfDayLength;
|
deltaTime -= halfDayLength;
|
||||||
|
|
||||||
if (deltaTime < halfDayLength) {
|
if (deltaTime < halfDayLength) {
|
||||||
MapleExpeditionBossLog.resetBossLogTable(true, thursday);
|
ExpeditionBossLog.resetBossLogTable(true, thursday);
|
||||||
}
|
}
|
||||||
|
|
||||||
now.set(Calendar.HOUR, 0);
|
now.set(Calendar.HOUR, 0);
|
||||||
now.set(Calendar.MINUTE, 0);
|
now.set(Calendar.MINUTE, 0);
|
||||||
now.set(Calendar.SECOND, 0);
|
now.set(Calendar.SECOND, 0);
|
||||||
|
|
||||||
MapleExpeditionBossLog.resetBossLogTable(false, now);
|
ExpeditionBossLog.resetBossLogTable(false, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void resetBossLogTable(boolean week, Calendar c) {
|
private static void resetBossLogTable(boolean week, Calendar c) {
|
||||||
List<Pair<Timestamp, BossLogEntry>> resetTimestamps = BossLogEntry.getBossLogResetTimestamps(c, week);
|
List<Pair<Timestamp, BossLogEntry>> resetTimestamps = BossLogEntry.getBossLogResetTimestamps(c, week);
|
||||||
|
|
||||||
try (Connection con = DatabaseConnection.getConnection()) {
|
try (Connection con = DatabaseConnection.getConnection()) {
|
||||||
for (Pair<Timestamp, BossLogEntry> p : resetTimestamps) {
|
for (Pair<Timestamp, BossLogEntry> p : resetTimestamps) {
|
||||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM " + getBossLogTable(week) + " WHERE attempttime <= ? AND bosstype LIKE ?")) {
|
try (PreparedStatement ps = con.prepareStatement("DELETE FROM " + getBossLogTable(week) + " WHERE attempttime <= ? AND bosstype LIKE ?")) {
|
||||||
@@ -131,7 +131,7 @@ public class MapleExpeditionBossLog {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getBossLogTable(boolean week) {
|
private static String getBossLogTable(boolean week) {
|
||||||
return week ? "bosslog_weekly" : "bosslog_daily";
|
return week ? "bosslog_weekly" : "bosslog_daily";
|
||||||
}
|
}
|
||||||
@@ -167,25 +167,25 @@ public class MapleExpeditionBossLog {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean attemptBoss(int cid, int channel, Expedition exped, boolean log) {
|
public static boolean attemptBoss(int cid, int channel, Expedition exped, boolean log) {
|
||||||
if (!YamlConfig.config.server.USE_ENABLE_DAILY_EXPEDITIONS) {
|
if (!YamlConfig.config.server.USE_ENABLE_DAILY_EXPEDITIONS) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BossLogEntry boss = BossLogEntry.getBossEntryByName(exped.getType().name());
|
BossLogEntry boss = BossLogEntry.getBossEntryByName(exped.getType().name());
|
||||||
if (boss == null) {
|
if (boss == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel < boss.minChannel || channel > boss.maxChannel) {
|
if (channel < boss.minChannel || channel > boss.maxChannel) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (countPlayerEntries(cid, boss) >= boss.entries) {
|
if (countPlayerEntries(cid, boss) >= boss.entries) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log) {
|
if (log) {
|
||||||
insertPlayerEntry(cid, boss);
|
insertPlayerEntry(cid, boss);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user