Refactor maple leaf logging
Not even sure anyone is using this system. Keeping it around just in case.
This commit is contained in:
@@ -57,6 +57,7 @@ import scripting.npc.NPCConversationManager;
|
||||
import scripting.npc.NPCScriptManager;
|
||||
import scripting.quest.QuestActionManager;
|
||||
import scripting.quest.QuestScriptManager;
|
||||
import server.MapleLeafLogger;
|
||||
import server.ThreadManager;
|
||||
import server.TimerManager;
|
||||
import server.life.Monster;
|
||||
@@ -1263,7 +1264,7 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
votePoints -= points;
|
||||
saveVotePoints();
|
||||
LogHelper.logLeaf(player, false, Integer.toString(points));
|
||||
MapleLeafLogger.log(player, false, Integer.toString(points));
|
||||
}
|
||||
|
||||
private void saveVotePoints() {
|
||||
|
||||
@@ -62,7 +62,6 @@ import server.partyquest.MonsterCarnival;
|
||||
import server.partyquest.Pyramid;
|
||||
import server.partyquest.Pyramid.PyramidMode;
|
||||
import tools.FilePrinter;
|
||||
import tools.LogHelper;
|
||||
import tools.PacketCreator;
|
||||
import tools.packets.WeddingPackets;
|
||||
|
||||
@@ -492,7 +491,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
}
|
||||
|
||||
public void logLeaf(String prize) {
|
||||
LogHelper.logLeaf(getPlayer(), true, prize);
|
||||
MapleLeafLogger.log(getPlayer(), true, prize);
|
||||
}
|
||||
|
||||
public boolean createPyramid(String mode, boolean party) {//lol
|
||||
|
||||
14
src/main/java/server/MapleLeafLogger.java
Normal file
14
src/main/java/server/MapleLeafLogger.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package server;
|
||||
|
||||
import client.Character;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MapleLeafLogger {
|
||||
private static final Logger log = LoggerFactory.getLogger(MapleLeafLogger.class);
|
||||
|
||||
public static void log(Character player, boolean gotPrize, String operation) {
|
||||
String action = gotPrize ? " used a maple leaf to buy " + operation : " redeemed " + operation + " VP for a leaf";
|
||||
log.info("{} {}", player.getName(), action);
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ import org.slf4j.LoggerFactory;
|
||||
import server.TimerManager;
|
||||
import server.life.Monster;
|
||||
import server.maps.MapleMap;
|
||||
import tools.LogHelper;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -48,6 +47,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
/**
|
||||
* @author Alan (SharpAceX)
|
||||
@@ -159,11 +159,11 @@ public class Expedition {
|
||||
}
|
||||
|
||||
private void log() {
|
||||
final String gmMessage = type + " Expedition with leader " + leader.getName() + " finished after " + LogHelper.getTimeString(getStartTime());
|
||||
final String gmMessage = type + " Expedition with leader " + leader.getName() + " finished after " + getTimeString(getStartTime());
|
||||
Server.getInstance().broadcastGMMessage(getLeader().getWorld(), PacketCreator.serverNotice(6, gmMessage));
|
||||
|
||||
String log = type + " EXPEDITION\r\n";
|
||||
log += LogHelper.getTimeString(startTime) + "\r\n";
|
||||
log += getTimeString(startTime) + "\r\n";
|
||||
|
||||
for (String memberName : getMembers().values()) {
|
||||
log += ">>" + memberName + "\r\n";
|
||||
@@ -177,6 +177,13 @@ public class Expedition {
|
||||
Expedition.log.info(log);
|
||||
}
|
||||
|
||||
private static String getTimeString(long then) {
|
||||
long duration = System.currentTimeMillis() - then;
|
||||
int seconds = (int) (duration / SECONDS.toMillis(1)) % 60;
|
||||
int minutes = (int) ((duration / MINUTES.toMillis(1)) % 60);
|
||||
return minutes + " Minutes and " + seconds + " Seconds";
|
||||
}
|
||||
|
||||
public void finishRegistration() {
|
||||
registering = false;
|
||||
}
|
||||
@@ -289,7 +296,7 @@ public class Expedition {
|
||||
for (int expeditionBoss : EXPEDITION_BOSSES) {
|
||||
if (mob.getId() == expeditionBoss) { //If the monster killed was a boss
|
||||
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date());
|
||||
bossLogs.add(">" + mob.getName() + " was killed after " + LogHelper.getTimeString(startTime) + " - " + timeStamp + "\r\n");
|
||||
bossLogs.add(">" + mob.getName() + " was killed after " + getTimeString(startTime) + " - " + timeStamp + "\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package tools;
|
||||
|
||||
import client.Character;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public class LogHelper {
|
||||
|
||||
public static String getTimeString(long then) {
|
||||
long duration = System.currentTimeMillis() - then;
|
||||
int seconds = (int) (duration / SECONDS.toMillis(1)) % 60;
|
||||
int minutes = (int) ((duration / MINUTES.toMillis(1)) % 60);
|
||||
return minutes + " Minutes and " + seconds + " Seconds";
|
||||
}
|
||||
|
||||
public static void logLeaf(Character player, boolean gotPrize, String operation) {
|
||||
String timeStamp = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss").format(new Date());
|
||||
String log = player.getName() + (gotPrize ? " used a maple leaf to buy " + operation : " redeemed " + operation + " VP for a leaf") + " - " + timeStamp;
|
||||
FilePrinter.print(FilePrinter.LOG_LEAF, log);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user