Merge pull request #66 from P0nk/logging-consolidation
Consolidate logging
This commit is contained in:
3
pom.xml
3
pom.xml
@@ -17,7 +17,7 @@
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<mainClass>net.server.Server</mainClass>
|
||||
|
||||
<log4j.version>2.16.0</log4j.version>
|
||||
<log4j.version>2.17.1</log4j.version>
|
||||
<graalvm.version>21.1.0</graalvm.version>
|
||||
<netty.version>4.1.67.Final</netty.version>
|
||||
<junit.version>5.7.2</junit.version>
|
||||
@@ -139,6 +139,7 @@
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
|
||||
@@ -57,6 +57,8 @@ import net.server.services.task.world.CharacterSaveService;
|
||||
import net.server.services.type.ChannelServices;
|
||||
import net.server.services.type.WorldServices;
|
||||
import net.server.world.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import scripting.item.ItemScriptManager;
|
||||
@@ -95,10 +97,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.*;
|
||||
|
||||
public class Character extends AbstractCharacterObject {
|
||||
private static final Logger log = LoggerFactory.getLogger(Character.class);
|
||||
private static final ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
private static final String LEVEL_200 = "[Congrats] %s has reached Level %d! Congratulate %s on such an amazing achievement!";
|
||||
private static final String[] BLOCKED_NAMES = {"admin", "owner", "moderator", "intern", "donor", "administrator", "FREDRICK", "help", "helper", "alert", "notice", "maplestory", "fuck", "wizet", "fucking", "negro", "fuk", "fuc", "penis", "pussy", "asshole", "gay",
|
||||
@@ -1721,7 +1725,7 @@ public class Character extends AbstractCharacterObject {
|
||||
resetHpDecreaseTask();
|
||||
}
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.MAPLE_MAP, "Character " + this.getName() + " got stuck when moving to map " + map.getId() + ".");
|
||||
log.warn("Chr {} got stuck when moving to map {}", getName(), map.getId());
|
||||
client.disconnect(true, false); // thanks BHB for noticing a player storage stuck case here
|
||||
return;
|
||||
}
|
||||
@@ -3584,26 +3588,25 @@ public class Character extends AbstractCharacterObject {
|
||||
effLock.lock();
|
||||
chrLock.lock();
|
||||
try {
|
||||
System.out.println("-------------------");
|
||||
System.out.println("CACHED BUFF COUNT: ");
|
||||
for (Entry<BuffStat, Byte> bpl : buffEffectsCount.entrySet()) {
|
||||
System.out.println(bpl.getKey() + ": " + bpl.getValue());
|
||||
}
|
||||
System.out.println("-------------------");
|
||||
System.out.println("CACHED BUFFS: ");
|
||||
for (Entry<Integer, Map<BuffStat, BuffStatValueHolder>> bpl : buffEffects.entrySet()) {
|
||||
System.out.print(bpl.getKey() + ": ");
|
||||
for (Entry<BuffStat, BuffStatValueHolder> pble : bpl.getValue().entrySet()) {
|
||||
System.out.print(pble.getKey().name() + pble.getValue().value + ", ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println("-------------------");
|
||||
log.debug("-------------------");
|
||||
log.debug("CACHED BUFF COUNT: {}", buffEffectsCount.entrySet().stream()
|
||||
.map(entry -> entry.getKey() + ": " + entry.getValue())
|
||||
.collect(Collectors.joining(", "))
|
||||
);
|
||||
|
||||
System.out.println("IN ACTION:");
|
||||
for (Entry<BuffStat, BuffStatValueHolder> bpl : effects.entrySet()) {
|
||||
System.out.println(bpl.getKey().name() + " -> " + ItemInformationProvider.getInstance().getName(bpl.getValue().effect.getSourceId()));
|
||||
}
|
||||
log.debug("-------------------");
|
||||
log.debug("CACHED BUFFS: {}", buffEffects.entrySet().stream()
|
||||
.map(entry -> entry.getKey() + ": (" + entry.getValue().entrySet().stream()
|
||||
.map(innerEntry -> innerEntry.getKey().name() + innerEntry.getValue().value)
|
||||
.collect(Collectors.joining(", ")) + ")")
|
||||
.collect(Collectors.joining(", "))
|
||||
);
|
||||
|
||||
log.debug("-------------------");
|
||||
log.debug("IN ACTION: {}", effects.entrySet().stream()
|
||||
.map(entry -> entry.getKey().name() + " -> " + ItemInformationProvider.getInstance().getName(entry.getValue().effect.getSourceId()))
|
||||
.collect(Collectors.joining(", "))
|
||||
);
|
||||
} finally {
|
||||
chrLock.unlock();
|
||||
effLock.unlock();
|
||||
@@ -3614,9 +3617,10 @@ public class Character extends AbstractCharacterObject {
|
||||
effLock.lock();
|
||||
chrLock.lock();
|
||||
try {
|
||||
for (Entry<BuffStat, Byte> mbsl : buffEffectsCount.entrySet()) {
|
||||
System.out.println(mbsl.getKey().name() + " -> " + mbsl.getValue());
|
||||
}
|
||||
log.debug("ALL BUFFS COUNT: {}", buffEffectsCount.entrySet().stream()
|
||||
.map(entry -> entry.getKey().name() + " -> " + entry.getValue())
|
||||
.collect(Collectors.joining(", "))
|
||||
);
|
||||
} finally {
|
||||
chrLock.unlock();
|
||||
effLock.unlock();
|
||||
@@ -5604,9 +5608,8 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
try {
|
||||
merchant.saveItems(false);
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, "Error while saving " + name + "'s Hired Merchant items.");
|
||||
} catch (SQLException e) {
|
||||
log.error("Error while saving {}'s Hired Merchant items.", name, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7548,7 +7551,7 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, e, "Character.mobKilled. CID: " + this.id + " last Quest Processed: " + lastQuestProcessed);
|
||||
log.warn("Character.mobKilled. chrId {}, last quest processed: {}", this.id, lastQuestProcessed, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8068,7 +8071,7 @@ public class Character extends AbstractCharacterObject {
|
||||
if (tap >= 0) {
|
||||
updateStrDexIntLukSp(tstr, tdex, tint, tluk, tap, tsp, GameConstants.getSkillBook(job.getId()));
|
||||
} else {
|
||||
FilePrinter.print(FilePrinter.EXCEPTION_CAUGHT, name + " tried to get their stats reseted, without having enough AP available.");
|
||||
log.warn("Chr {} tried to have its stats reset without enough AP available");
|
||||
}
|
||||
} finally {
|
||||
statWlock.unlock();
|
||||
@@ -8241,7 +8244,7 @@ public class Character extends AbstractCharacterObject {
|
||||
|
||||
int updateRows = ps.executeUpdate();
|
||||
if (updateRows < 1) {
|
||||
FilePrinter.printError(FilePrinter.INSERT_CHAR, "Error trying to insert " + name);
|
||||
log.error("Error trying to insert chr {}", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8249,7 +8252,7 @@ public class Character extends AbstractCharacterObject {
|
||||
if (rs.next()) {
|
||||
this.id = rs.getInt(1);
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.INSERT_CHAR, "Inserting char failed " + name);
|
||||
log.error("Inserting chr {} failed", name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -8329,7 +8332,7 @@ public class Character extends AbstractCharacterObject {
|
||||
con.setAutoCommit(true);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
FilePrinter.printError(FilePrinter.INSERT_CHAR, t, "Error creating " + name + " Level: " + level + " Job: " + job.getId());
|
||||
log.error("Error creating chr {}, level: {}, job: {}", name, level, job.getId(), t);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -8358,12 +8361,7 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
||||
if (notAutosave) {
|
||||
FilePrinter.print(FilePrinter.SAVING_CHARACTER, "Attempting to save " + name + " at " + c.getTime());
|
||||
} else {
|
||||
FilePrinter.print(FilePrinter.AUTOSAVING_CHARACTER, "Attempting to autosave " + name + " at " + c.getTime());
|
||||
}
|
||||
log.debug("Attempting to {} chr {}", notAutosave ? "save" : "autosave", name);
|
||||
|
||||
Server.getInstance().updateCharacterEntry(this);
|
||||
|
||||
@@ -8756,7 +8754,7 @@ public class Character extends AbstractCharacterObject {
|
||||
con.setAutoCommit(true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FilePrinter.printError(FilePrinter.SAVE_CHAR, e, "Error saving " + name + " Level: " + level + " Job: " + job.getId());
|
||||
log.error("Error saving chr {}, level: {}, job: {}", name, level, job.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8772,14 +8770,13 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
|
||||
public void sendPolice(String text) {
|
||||
String message = getName() + " received this - " + text;
|
||||
final String message = getName() + " received this - " + text;
|
||||
if (Server.getInstance().isGmOnline(this.getWorld())) { //Alert and log if a GM is online
|
||||
Server.getInstance().broadcastGMMessage(this.getWorld(), PacketCreator.sendYellowTip(message));
|
||||
FilePrinter.print(FilePrinter.AUTOBAN_WARNING, message);
|
||||
} else { //Auto DC and log if no GM is online
|
||||
client.disconnect(false, false);
|
||||
FilePrinter.print(FilePrinter.AUTOBAN_DC, message);
|
||||
}
|
||||
log.info(message);
|
||||
//Server.getInstance().broadcastGMMessage(0, PacketCreator.serverNotice(1, getName() + " received this - " + text));
|
||||
//sendPacket(PacketCreator.sendPolice(text));
|
||||
//this.isbanned = true;
|
||||
@@ -10694,8 +10691,7 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e, "Failed to register name change for character " + getName() + ".");
|
||||
log.error("Failed to register name change for chr {}", getName(), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10707,12 +10703,10 @@ public class Character extends AbstractCharacterObject {
|
||||
this.pendingNameChange = true;
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e, "Failed to register name change for character " + getName() + ".");
|
||||
log.error("Failed to register name change for chr {}", getName(), e);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e, "Failed to get DB connection.");
|
||||
log.error("Failed to get DB connection while registering name change", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -10727,8 +10721,7 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
return affectedRows > 0; //rows affected
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e, "Failed to cancel name change for character " + getName() + ".");
|
||||
log.error("Failed to cancel name change for chr {}", getName(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -10751,8 +10744,7 @@ public class Character extends AbstractCharacterObject {
|
||||
newName = rs.getString("new");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e, "Failed to retrieve pending name changes for character " + getName() + ".");
|
||||
log.error("Failed to retrieve pending name changes for chr {}", this.name, e);
|
||||
}
|
||||
|
||||
con.setAutoCommit(false);
|
||||
@@ -10760,12 +10752,11 @@ public class Character extends AbstractCharacterObject {
|
||||
if (!success) {
|
||||
con.rollback();
|
||||
} else {
|
||||
FilePrinter.print(FilePrinter.CHANGE_CHARACTER_NAME, "Name change applied : from \"" + getName() + "\" to \"" + newName + "\" at " + Calendar.getInstance().getTime());
|
||||
log.info("Name change applied: from {} to {}", this.name, newName);
|
||||
}
|
||||
con.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e, "Failed to get DB connection.");
|
||||
log.error("Failed to get DB connection for pending chr name change", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10778,8 +10769,7 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
con.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e, "Failed to get DB connection.");
|
||||
log.error("Failed to get DB connection for chr name change", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10789,8 +10779,7 @@ public class Character extends AbstractCharacterObject {
|
||||
ps.setInt(2, characterId);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e, "Character ID : " + characterId);
|
||||
log.error("Failed to perform chr name change in database for chrId {}", characterId, e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10799,8 +10788,7 @@ public class Character extends AbstractCharacterObject {
|
||||
ps.setString(2, oldName);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e, "Character ID : " + characterId);
|
||||
log.error("Failed to update rings during chr name change for chrId {}", characterId, e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10919,8 +10907,7 @@ public class Character extends AbstractCharacterObject {
|
||||
ps.setInt(2, nameChangeId);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e, "Character ID : " + characterId);
|
||||
log.error("Failed to save chr name change for chrId {}", nameChangeId, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -10968,8 +10955,7 @@ public class Character extends AbstractCharacterObject {
|
||||
return "Character is the leader of a guild.";
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e);
|
||||
log.error("Change character name", e);
|
||||
return "SQL Error";
|
||||
}
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT tempban FROM accounts WHERE id = ?")) {
|
||||
@@ -10983,8 +10969,7 @@ public class Character extends AbstractCharacterObject {
|
||||
return "Account has been banned.";
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e);
|
||||
log.error("Change character name", e);
|
||||
return "SQL Error";
|
||||
}
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) AS rowcount FROM characters WHERE accountid = ? AND world = ?")) {
|
||||
@@ -10998,8 +10983,7 @@ public class Character extends AbstractCharacterObject {
|
||||
return "Too many characters on destination world.";
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.CHANGE_CHARACTER_NAME, e);
|
||||
log.error("Change character name", e);
|
||||
return "SQL Error";
|
||||
}
|
||||
return null;
|
||||
@@ -11021,8 +11005,7 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, e, "Failed to register world transfer for character " + getName() + ".");
|
||||
log.error("Failed to register world transfer for chr {}", getName(), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11033,12 +11016,10 @@ public class Character extends AbstractCharacterObject {
|
||||
ps.executeUpdate();
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, e, "Failed to register world transfer for character " + getName() + ".");
|
||||
log.error("Failed to register world transfer for chr {}", getName(), e);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, e, "Failed to get DB connection.");
|
||||
log.error("Failed to get DB connection while registering world transfer", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -11050,8 +11031,7 @@ public class Character extends AbstractCharacterObject {
|
||||
int affectedRows = ps.executeUpdate();
|
||||
return affectedRows > 0; //rows affected
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, e, "Failed to cancel pending world transfer for character " + getName() + ".");
|
||||
log.error("Failed to cancel pending world transfer for chr {}", getName(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -11062,13 +11042,12 @@ public class Character extends AbstractCharacterObject {
|
||||
ps.setInt(1, characterId);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if (!rs.next()) {
|
||||
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, "Character data invalid? (charid " + characterId + ")");
|
||||
log.warn("Character data invalid for world transfer? chrId {}", characterId);
|
||||
return false;
|
||||
}
|
||||
mesos = rs.getInt("meso");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, e, "Character ID : " + characterId);
|
||||
log.error("Failed to do world transfer for chrId {}", characterId, e);
|
||||
return false;
|
||||
}
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET world = ?, meso = ?, guildid = ?, guildrank = ? WHERE id = ?")) {
|
||||
@@ -11079,8 +11058,7 @@ public class Character extends AbstractCharacterObject {
|
||||
ps.setInt(5, characterId);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, e, "Character ID : " + characterId);
|
||||
log.error("Failed to update chrId {} during world transfer", characterId, e);
|
||||
return false;
|
||||
}
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM buddies WHERE characterid = ? OR buddyid = ?")) {
|
||||
@@ -11088,8 +11066,7 @@ public class Character extends AbstractCharacterObject {
|
||||
ps.setInt(2, characterId);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, e, "Character ID : " + characterId);
|
||||
log.error("Failed to delete buddies for chrId {} during world transfer", characterId, e);
|
||||
return false;
|
||||
}
|
||||
if (worldTransferId != -1) {
|
||||
@@ -11098,8 +11075,7 @@ public class Character extends AbstractCharacterObject {
|
||||
ps.setInt(2, worldTransferId);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, e, "Character ID : " + characterId);
|
||||
log.error("Failed to update world transfer for chrId {}", characterId, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import net.netty.InvalidPacketHeaderException;
|
||||
import net.packet.InPacket;
|
||||
import net.packet.Packet;
|
||||
import net.packet.logging.LoggingUtil;
|
||||
import net.packet.logging.MapleLogger;
|
||||
import net.packet.logging.MonitoredChrLogger;
|
||||
import net.server.Server;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
@@ -57,13 +57,17 @@ 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;
|
||||
import server.maps.FieldLimit;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MiniDungeonInfo;
|
||||
import tools.*;
|
||||
import tools.BCrypt;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.HexTool;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import java.io.IOException;
|
||||
@@ -200,10 +204,12 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
|
||||
if (handler != null && handler.validateState(this)) {
|
||||
try {
|
||||
MapleLogger.logRecv(this, opcode, packet.getBytes());
|
||||
MonitoredChrLogger.logPacketIfMonitored(this, opcode, packet.getBytes());
|
||||
handler.handlePacket(packet, this);
|
||||
} catch (final Throwable t) {
|
||||
FilePrinter.printError(FilePrinter.PACKET_HANDLER + handler.getClass().getName() + ".txt", t, "Error for " + (getPlayer() == null ? "" : "player ; " + getPlayer() + " on map ; " + getPlayer().getMapId() + " - ") + "account ; " + getAccountName() + "\r\n" + packet);
|
||||
final String chrInfo = player != null ? player.getName() + " on map " + player.getMapId() : "?";
|
||||
log.warn("Error in packet handler {}. Chr {}, account {}. Packet: {}", handler.getClass().getSimpleName(),
|
||||
chrInfo, getAccountName(), packet, t);
|
||||
//client.sendPacket(PacketCreator.enableActions());//bugs sometimes
|
||||
}
|
||||
}
|
||||
@@ -380,7 +386,7 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
voteTime = rs.getInt("date");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError("hasVotedAlready.txt", e);
|
||||
log.error("Error getting voting time");
|
||||
return -1;
|
||||
}
|
||||
return voteTime;
|
||||
@@ -638,7 +644,7 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
if (rs.next()) {
|
||||
accId = rs.getInt("id");
|
||||
if (accId <= 0) {
|
||||
FilePrinter.printError(FilePrinter.LOGIN_EXCEPTION, "Tried to login with accid " + accId);
|
||||
log.warn("Tried to log in with accId {}", accId);
|
||||
return 15;
|
||||
}
|
||||
|
||||
@@ -937,7 +943,7 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
} catch (final Throwable t) {
|
||||
FilePrinter.printError(FilePrinter.ACCOUNT_STUCK, t);
|
||||
log.error("Account stuck", t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1010,7 +1016,7 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
FilePrinter.printError(FilePrinter.ACCOUNT_STUCK, e);
|
||||
log.error("Account stuck", e);
|
||||
} finally {
|
||||
if (!this.serverTransition) {
|
||||
if (chrg != null) {
|
||||
@@ -1225,7 +1231,7 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
for (World w : Server.getInstance().getWorlds()) {
|
||||
for (Character chr : w.getPlayerStorage().getAllCharacters()) {
|
||||
if (accid == chr.getAccountID()) {
|
||||
FilePrinter.print(FilePrinter.EXPLOITS, "Player: " + chr.getName() + " has been removed from " + GameConstants.WORLD_NAMES[w.getId()] + ". Possible Dupe attempt.");
|
||||
log.warn("Chr {} has been removed from world {}. Possible Dupe attempt.", chr.getName(), GameConstants.WORLD_NAMES[w.getId()]);
|
||||
chr.getClient().forceDisconnect();
|
||||
w.getPlayerStorage().removePlayer(chr.getId());
|
||||
}
|
||||
@@ -1263,7 +1269,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() {
|
||||
|
||||
@@ -24,8 +24,9 @@ package client;
|
||||
import net.packet.Packet;
|
||||
import net.server.Server;
|
||||
import net.server.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
@@ -34,7 +35,6 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -45,7 +45,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
* @author Ubaware
|
||||
*/
|
||||
public class Family {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Family.class);
|
||||
private static final AtomicInteger familyIDCounter = new AtomicInteger();
|
||||
|
||||
private final int id, world;
|
||||
@@ -121,8 +121,7 @@ public class Family {
|
||||
ps.setInt(2, getLeader().getChrId());
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not save new precepts for family " + getID() + ".");
|
||||
e.printStackTrace();
|
||||
log.error("Could not save new precepts for family {}", getID(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,11 +208,11 @@ public class Family {
|
||||
level = rs.getInt("level");
|
||||
jobID = rs.getInt("job");
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, "Could not load character information of " + cid + " in loadAllFamilies(). (RECORD DOES NOT EXIST)");
|
||||
log.error("Could not load character information of chrId {} in loadAllFamilies(). (RECORD DOES NOT EXIST)", cid);
|
||||
continue;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not load character information of " + cid + " in loadAllFamilies(). (SQL ERROR)");
|
||||
log.error("Could not load character information of chrId {} in loadAllFamilies(). (SQL ERROR)", cid, e);
|
||||
continue;
|
||||
}
|
||||
int familyid = rsEntries.getInt("familyid");
|
||||
@@ -261,8 +260,7 @@ public class Family {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get family_character entries.");
|
||||
e.printStackTrace();
|
||||
log.error("Could not get family_character entries", e);
|
||||
}
|
||||
// link missing ones (out of order)
|
||||
for (Pair<Pair<Integer, Integer>, FamilyEntry> unmatchedJunior : unmatchedJuniors) {
|
||||
@@ -273,7 +271,7 @@ public class Family {
|
||||
if (senior != null) {
|
||||
junior.setSenior(senior, false);
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, "Missing senior for character " + junior.getName() + " in world " + world);
|
||||
log.error("Missing senior for chr {} in world {}", junior.getName(), world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +294,7 @@ public class Family {
|
||||
}
|
||||
if (!success) {
|
||||
con.rollback();
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, "Family rep autosave failed for family " + getID() + " on " + Calendar.getInstance().getTime() + ".");
|
||||
log.error("Family rep autosave failed for family {}", getID());
|
||||
}
|
||||
con.setAutoCommit(true);
|
||||
//reset repChanged after successful save
|
||||
@@ -304,8 +302,7 @@ public class Family {
|
||||
entry.savedSuccessfully();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get connection to DB.");
|
||||
e.printStackTrace();
|
||||
log.error("Could not get connection to DB while saving all members rep", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,9 @@ package client;
|
||||
|
||||
import net.packet.Packet;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
@@ -38,6 +39,8 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public class FamilyEntry {
|
||||
private static final Logger log = LoggerFactory.getLogger(FamilyEntry.class);
|
||||
|
||||
private final int characterID;
|
||||
private volatile Family family;
|
||||
private volatile Character character;
|
||||
@@ -114,12 +117,11 @@ public class FamilyEntry {
|
||||
}
|
||||
if (!success) {
|
||||
con.rollback();
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, "Could not absorb " + oldFamily.getName() + " family into " + newFamily.getName() + " family. (SQL ERROR)");
|
||||
log.error("Could not absorb {}'s family into {}'s family. (SQL ERROR)", oldFamily.getName(), newFamily.getName());
|
||||
}
|
||||
con.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get connection to DB.");
|
||||
e.printStackTrace();
|
||||
log.error("Could not get connection to DB when joining families", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,13 +161,12 @@ public class FamilyEntry {
|
||||
}
|
||||
if (!success) {
|
||||
con.rollback();
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, "Could not fork family with new leader " + getName() + ". (Old senior : " + oldSenior.getName() + ", leader :" + oldFamily.getLeader().getName() + ")");
|
||||
log.error("Could not fork family with new leader {}. (Old senior: {}, leader: {})", getName(), oldSenior.getName(), oldFamily.getLeader().getName());
|
||||
}
|
||||
con.setAutoCommit(true);
|
||||
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get connection to DB.");
|
||||
e.printStackTrace();
|
||||
log.error("Could not get connection to DB when forking families", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,8 +194,7 @@ public class FamilyEntry {
|
||||
ps.setInt(2, cid);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not update family id in 'family_character' for character id " + cid + ". (fork)");
|
||||
e.printStackTrace();
|
||||
log.error("Could not update family id in 'family_character' for chrId {}. (fork)", cid, e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -375,8 +375,7 @@ public class FamilyEntry {
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
return updateDBChangeFamily(con, cid, familyid, seniorid);
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get connection to DB.");
|
||||
e.printStackTrace();
|
||||
log.error("Could not get connection to DB while changing family", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -388,8 +387,7 @@ public class FamilyEntry {
|
||||
ps.setInt(3, cid);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not update seniorid in 'family_character' for character id " + cid + ".");
|
||||
e.printStackTrace();
|
||||
log.error("Could not update seniorId in 'family_character' for chrId {}", cid, e);
|
||||
return false;
|
||||
}
|
||||
return updateCharacterFamilyDB(con, cid, familyid, false);
|
||||
@@ -401,8 +399,7 @@ public class FamilyEntry {
|
||||
ps.setInt(2, charid);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not update familyid in 'characters' for character id " + charid + " when changing family. " + (fork ? "(fork)" : ""));
|
||||
e.printStackTrace();
|
||||
log.error("Could not update familyId in 'characters' for chrId {} when changing family. {}", charid, fork ? "(fork)" : "", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -549,8 +546,7 @@ public class FamilyEntry {
|
||||
ps.setLong(3, System.currentTimeMillis());
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not insert new row in 'family_entitlement' for character " + getName() + ".");
|
||||
e.printStackTrace();
|
||||
log.error("Could not insert new row in 'family_entitlement' for chr {}", getName(), e);
|
||||
}
|
||||
entitlements[id]++;
|
||||
return true;
|
||||
@@ -563,8 +559,7 @@ public class FamilyEntry {
|
||||
ps.setInt(2, getChrId());
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not refund family entitlement \"" + entitlement.getName() + "\" for character " + getName() + ".");
|
||||
e.printStackTrace();
|
||||
log.error("Could not refund family entitlement \"{}\" for chr {}", entitlement.getName(), getName(), e);
|
||||
}
|
||||
entitlements[id] = 0;
|
||||
return true;
|
||||
@@ -595,8 +590,7 @@ public class FamilyEntry {
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
return saveReputation(con);
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get connection to DB.");
|
||||
e.printStackTrace();
|
||||
log.error("Could not get connection to DB while saving reputation", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -613,8 +607,7 @@ public class FamilyEntry {
|
||||
ps.setInt(5, getChrId());
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Failed to autosave rep to 'family_character' for charid " + getChrId());
|
||||
e.printStackTrace();
|
||||
log.error("Failed to autosave rep to 'family_character' for chrId {}", getChrId(), e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -24,11 +24,15 @@ package client.autoban;
|
||||
|
||||
import client.Character;
|
||||
import config.YamlConfig;
|
||||
import net.packet.logging.MapleLogger;
|
||||
import net.server.Server;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
@@ -56,6 +60,9 @@ public enum AutobanFactory {
|
||||
FAST_ATTACK(10, SECONDS.toMillis(30)),
|
||||
MPCON(25, SECONDS.toMillis(30));
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AutobanFactory.class);
|
||||
private static final Set<Integer> ignoredChrIds = new HashSet<>();
|
||||
|
||||
private final int points;
|
||||
private final long expiretime;
|
||||
|
||||
@@ -87,13 +94,14 @@ public enum AutobanFactory {
|
||||
|
||||
public void alert(Character chr, String reason) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
if (chr != null && MapleLogger.ignored.contains(chr.getId())) {
|
||||
if (chr != null && isIgnored(chr.getId())) {
|
||||
return;
|
||||
}
|
||||
Server.getInstance().broadcastGMMessage((chr != null ? chr.getWorld() : 0), PacketCreator.sendYellowTip((chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason));
|
||||
}
|
||||
if (YamlConfig.config.server.USE_AUTOBAN_LOG) {
|
||||
FilePrinter.print(FilePrinter.AUTOBAN_WARNING, (chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason);
|
||||
final String chrName = chr != null ? Character.makeMapleReadable(chr.getName()) : "";
|
||||
log.info("Autoban alert - chr {} caused {}-{}", chrName, this.name(), reason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,4 +111,28 @@ public enum AutobanFactory {
|
||||
//chr.sendPolice("You will be disconnected for (" + this.name() + ": " + value + ")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle ignored status for a character id.
|
||||
* An ignored character will not trigger GM alerts.
|
||||
*
|
||||
* @return new status. true if the chrId is now ignored, otherwise false.
|
||||
*/
|
||||
public static boolean toggleIgnored(int chrId) {
|
||||
if (ignoredChrIds.contains(chrId)) {
|
||||
ignoredChrIds.remove(chrId);
|
||||
return false;
|
||||
} else {
|
||||
ignoredChrIds.add(chrId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isIgnored(int chrId) {
|
||||
return ignoredChrIds.contains(chrId);
|
||||
}
|
||||
|
||||
public static Collection<Integer> getIgnoredChrIds() {
|
||||
return ignoredChrIds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ package client.autoban;
|
||||
import client.Character;
|
||||
import config.YamlConfig;
|
||||
import net.server.Server;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -17,6 +18,8 @@ import java.util.Map;
|
||||
* @author kevintjuh93
|
||||
*/
|
||||
public class AutobanManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(AutobanManager.class);
|
||||
|
||||
private final Character chr;
|
||||
private final Map<AutobanFactory, Integer> points = new HashMap<>();
|
||||
private final Map<AutobanFactory, Long> lastTime = new HashMap<>();
|
||||
@@ -59,7 +62,7 @@ public class AutobanManager {
|
||||
}
|
||||
if (YamlConfig.config.server.USE_AUTOBAN_LOG) {
|
||||
// Lets log every single point too.
|
||||
FilePrinter.print(FilePrinter.AUTOBAN_WARNING, Character.makeMapleReadable(chr.getName()) + " caused " + fac.name() + " " + reason);
|
||||
log.info("Autoban - chr {} caused {} {}", Character.makeMapleReadable(chr.getName()), fac.name(), reason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +122,7 @@ public class AutobanManager {
|
||||
chr.getClient().disconnect(false, false);
|
||||
}
|
||||
|
||||
FilePrinter.print(FilePrinter.EXPLOITS, "Player " + chr + " was caught spamming TYPE " + type + " and has been disconnected.");
|
||||
log.info("Autoban - Chr {} was caught spamming TYPE {} and has been disconnected", chr, type);
|
||||
}
|
||||
} else {
|
||||
this.timestamp[type] = time;
|
||||
|
||||
@@ -32,23 +32,29 @@ import client.command.commands.gm4.*;
|
||||
import client.command.commands.gm5.*;
|
||||
import client.command.commands.gm6.*;
|
||||
import constants.id.MapId;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.Pair;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandsExecutor {
|
||||
private static final Logger log = LoggerFactory.getLogger(CommandsExecutor.class);
|
||||
private static final CommandsExecutor instance = new CommandsExecutor();
|
||||
private static final char USER_HEADING = '@';
|
||||
private static final char GM_HEADING = '!';
|
||||
|
||||
public static CommandsExecutor instance = new CommandsExecutor();
|
||||
private final HashMap<String, Command> registeredCommands = new HashMap<>();
|
||||
private final List<Pair<List<String>, List<String>>> commandsNameDesc = new ArrayList<>();
|
||||
private Pair<List<String>, List<String>> levelCommandsCursor;
|
||||
|
||||
public static CommandsExecutor getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static final char USER_HEADING = '@';
|
||||
private static final char GM_HEADING = '!';
|
||||
|
||||
public static boolean isCommand(Client client, String content) {
|
||||
char heading = content.charAt(0);
|
||||
if (client.getPlayer().isGM()) {
|
||||
@@ -57,10 +63,6 @@ public class CommandsExecutor {
|
||||
return heading == USER_HEADING;
|
||||
}
|
||||
|
||||
private final HashMap<String, Command> registeredCommands = new HashMap<>();
|
||||
private Pair<List<String>, List<String>> levelCommandsCursor;
|
||||
private final List<Pair<List<String>, List<String>>> commandsNameDesc = new ArrayList<>();
|
||||
|
||||
private CommandsExecutor() {
|
||||
registerLv0Commands();
|
||||
registerLv1Commands();
|
||||
@@ -119,13 +121,7 @@ public class CommandsExecutor {
|
||||
}
|
||||
|
||||
command.execute(client, params);
|
||||
writeLog(client, message);
|
||||
}
|
||||
|
||||
private void writeLog(Client client, String command) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm");
|
||||
FilePrinter.print(FilePrinter.USED_COMMANDS, client.getPlayer().getName() + " used: " + command + " on "
|
||||
+ sdf.format(Calendar.getInstance().getTime()));
|
||||
log.info("Chr {} used command {}", client.getPlayer().getName(), command.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
private void addCommandInfo(String name, Class<? extends Command> commandClass) {
|
||||
@@ -157,7 +153,7 @@ public class CommandsExecutor {
|
||||
|
||||
private void addCommand(String syntax, int rank, Class<? extends Command> commandClass) {
|
||||
if (registeredCommands.containsKey(syntax.toLowerCase())) {
|
||||
System.out.println("Error on register command with name: " + syntax + ". Already exists.");
|
||||
log.warn("Error on register command with name: {}. Already exists.", syntax);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import net.server.Server;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.PacketCreator;
|
||||
import tools.Randomizer;
|
||||
|
||||
@@ -36,6 +37,8 @@ public class GmCommand extends Command {
|
||||
setDescription("Send a message to the game masters.");
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GmCommand.class);
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
String[] tips = {
|
||||
@@ -53,7 +56,7 @@ public class GmCommand extends Command {
|
||||
String message = player.getLastCommandMessage();
|
||||
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.sendYellowTip("[GM Message]:" + Character.makeMapleReadable(player.getName()) + ": " + message));
|
||||
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.serverNotice(1, message));
|
||||
FilePrinter.printError(FilePrinter.COMMAND_GM, Character.makeMapleReadable(player.getName()) + ": " + message);
|
||||
log.info("{}: {}", Character.makeMapleReadable(player.getName()), message);
|
||||
player.dropMessage(5, "Your message '" + message + "' was sent to GMs.");
|
||||
player.dropMessage(5, tips[Randomizer.nextInt(tips.length)]);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import net.server.Server;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public class ReportBugCommand extends Command {
|
||||
@@ -35,6 +36,8 @@ public class ReportBugCommand extends Command {
|
||||
setDescription("Send in a bug report.");
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ReportBugCommand.class);
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
@@ -46,7 +49,7 @@ public class ReportBugCommand extends Command {
|
||||
String message = player.getLastCommandMessage();
|
||||
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.sendYellowTip("[Bug]:" + Character.makeMapleReadable(player.getName()) + ": " + message));
|
||||
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.serverNotice(1, message));
|
||||
FilePrinter.printError(FilePrinter.COMMAND_BUG, Character.makeMapleReadable(player.getName()) + ": " + message);
|
||||
log.info("{}: {}", Character.makeMapleReadable(player.getName()), message);
|
||||
player.dropMessage(5, "Your bug '" + message + "' was submitted successfully to our developers. Thank you!");
|
||||
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ package client.command.commands.gm3;
|
||||
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.autoban.AutobanFactory;
|
||||
import client.command.Command;
|
||||
import net.packet.logging.MapleLogger;
|
||||
import net.server.Server;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public class IgnoreCommand extends Command {
|
||||
{
|
||||
setDescription("Toggle enable/disable ignore a player in packet logs and autoban.");
|
||||
setDescription("Toggle ignore a character from auto-ban alerts.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,14 +47,10 @@ public class IgnoreCommand extends Command {
|
||||
player.message("Player '" + params[0] + "' could not be found on this world.");
|
||||
return;
|
||||
}
|
||||
boolean monitored_ = MapleLogger.ignored.contains(victim.getId());
|
||||
if (monitored_) {
|
||||
MapleLogger.ignored.remove(victim.getId());
|
||||
} else {
|
||||
MapleLogger.ignored.add(victim.getId());
|
||||
}
|
||||
player.yellowMessage(victim.getName() + " is " + (!monitored_ ? "now being ignored." : "no longer being ignored."));
|
||||
String message_ = player.getName() + (!monitored_ ? " has started ignoring " : " has stopped ignoring ") + victim.getName() + ".";
|
||||
|
||||
boolean ignored = AutobanFactory.toggleIgnored(victim.getId());
|
||||
player.yellowMessage(victim.getName() + " is " + (ignored ? "now being ignored." : "no longer being ignored."));
|
||||
String message_ = player.getName() + (ignored ? " has started ignoring " : " has stopped ignoring ") + victim.getName() + ".";
|
||||
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.serverNotice(5, message_));
|
||||
|
||||
}
|
||||
|
||||
@@ -25,19 +25,19 @@ package client.command.commands.gm3;
|
||||
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.autoban.AutobanFactory;
|
||||
import client.command.Command;
|
||||
import net.packet.logging.MapleLogger;
|
||||
|
||||
public class IgnoredCommand extends Command {
|
||||
{
|
||||
setDescription("Show all players being ignored in logs.");
|
||||
setDescription("Show all characters being ignored in auto-ban alerts.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
for (Integer cid : MapleLogger.ignored) {
|
||||
player.yellowMessage(Character.getNameById(cid) + " is being ignored.");
|
||||
for (int chrId : AutobanFactory.getIgnoredChrIds()) {
|
||||
player.yellowMessage(Character.getNameById(chrId) + " is being ignored.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@ package client.command.commands.gm3;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import net.packet.logging.MapleLogger;
|
||||
import net.packet.logging.MonitoredChrLogger;
|
||||
import net.server.Server;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public class MonitorCommand extends Command {
|
||||
{
|
||||
setDescription("Toggle logging the packets of a player.");
|
||||
setDescription("Toggle monitored packet logging of a character.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,14 +47,9 @@ public class MonitorCommand extends Command {
|
||||
player.message("Player '" + params[0] + "' could not be found on this world.");
|
||||
return;
|
||||
}
|
||||
boolean monitored = MapleLogger.monitored.contains(victim.getId());
|
||||
if (monitored) {
|
||||
MapleLogger.monitored.remove(victim.getId());
|
||||
} else {
|
||||
MapleLogger.monitored.add(victim.getId());
|
||||
}
|
||||
player.yellowMessage(victim.getId() + " is " + (!monitored ? "now being monitored." : "no longer being monitored."));
|
||||
String message = player.getName() + (!monitored ? " has started monitoring " : " has stopped monitoring ") + victim.getId() + ".";
|
||||
boolean monitored = MonitoredChrLogger.toggleMonitored(victim.getId());
|
||||
player.yellowMessage(victim.getId() + " is " + (monitored ? "now being monitored." : "no longer being monitored."));
|
||||
String message = player.getName() + (monitored ? " has started monitoring " : " has stopped monitoring ") + victim.getId() + ".";
|
||||
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.serverNotice(5, message));
|
||||
|
||||
}
|
||||
|
||||
@@ -26,18 +26,18 @@ package client.command.commands.gm3;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import net.packet.logging.MapleLogger;
|
||||
import net.packet.logging.MonitoredChrLogger;
|
||||
|
||||
public class MonitorsCommand extends Command {
|
||||
{
|
||||
setDescription("Show all players having their packets logged.");
|
||||
setDescription("Show all characters being monitored for packet logging");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
for (Integer cid : MapleLogger.monitored) {
|
||||
player.yellowMessage(Character.getNameById(cid) + " is being monitored.");
|
||||
for (int chrId : MonitoredChrLogger.getMonitoredChrIds()) {
|
||||
player.yellowMessage(Character.getNameById(chrId) + " is being monitored.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ import net.PacketHandler;
|
||||
import net.PacketProcessor;
|
||||
import net.packet.ByteBufInPacket;
|
||||
import net.packet.InPacket;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.HexTool;
|
||||
|
||||
import java.io.FileReader;
|
||||
@@ -44,6 +45,8 @@ public class PeCommand extends Command {
|
||||
setDescription("Handle synthesized packets from file, and handle them as if sent from a client");
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PeCommand.class);
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
@@ -70,7 +73,9 @@ public class PeCommand extends Command {
|
||||
player.yellowMessage("Receiving: " + packet);
|
||||
packetHandler.handlePacket(inPacket, c);
|
||||
} catch (final Throwable t) {
|
||||
FilePrinter.printError(FilePrinter.PACKET_HANDLER + packetHandler.getClass().getName() + ".txt", t, "Error for " + (c.getPlayer() == null ? "" : "player ; " + c.getPlayer() + " on map ; " + c.getPlayer().getMapId() + " - ") + "account ; " + c.getAccountName() + "\r\n" + inPacket);
|
||||
final String chrInfo = player != null ? player.getName() + " on map " + player.getMapId() : "?";
|
||||
log.warn("Error in packet handler {}. Chr {}, account {}. Packet: {}", packetHandler.getClass().getSimpleName(),
|
||||
chrInfo, c.getAccountName(), packet, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,16 @@ import client.inventory.InventoryType;
|
||||
import client.inventory.Item;
|
||||
import config.YamlConfig;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
* @author RonanLana
|
||||
*/
|
||||
public abstract class CharacterFactory {
|
||||
private static final Logger log = LoggerFactory.getLogger(CharacterFactory.class);
|
||||
|
||||
protected synchronized static int createNewCharacter(Client c, String name, int face, int hair, int skin, int gender, CharacterFactoryRecipe recipe) {
|
||||
if (YamlConfig.config.server.COLLECTIVE_CHARSLOT ? c.getAvailableCharacterSlots() <= 0 : c.getAvailableCharacterWorldSlots() <= 0) {
|
||||
@@ -93,7 +95,7 @@ public abstract class CharacterFactory {
|
||||
|
||||
Server.getInstance().createCharacterEntry(newchar);
|
||||
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.sendYellowTip("[New Char]: " + c.getAccountName() + " has created a new character with IGN " + name));
|
||||
FilePrinter.print(FilePrinter.CREATED_CHAR + c.getAccountName() + ".txt", c.getAccountName() + " created character with IGN " + name);
|
||||
log.info("Account {} created chr with name {}", c.getAccountName(), name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import client.Client;
|
||||
import config.YamlConfig;
|
||||
import constants.game.ExpTable;
|
||||
import constants.inventory.ItemConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
@@ -36,6 +38,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Equip extends Item {
|
||||
private static final Logger log = LoggerFactory.getLogger(Equip.class);
|
||||
|
||||
public enum ScrollResult {
|
||||
|
||||
@@ -110,7 +113,7 @@ public class Equip extends Item {
|
||||
ret.itemLevel = itemLevel;
|
||||
ret.itemExp = itemExp;
|
||||
ret.level = level;
|
||||
ret.log = new LinkedList<>(log);
|
||||
ret.itemLog = new LinkedList<>(itemLog);
|
||||
ret.setOwner(getOwner());
|
||||
ret.setQuantity(getQuantity());
|
||||
ret.setExpiration(getExpiration());
|
||||
@@ -647,7 +650,8 @@ public class Equip extends Item {
|
||||
int expNeeded = ExpTable.getEquipExpNeededForLevel(itemLevel);
|
||||
|
||||
if (YamlConfig.config.server.USE_DEBUG_SHOW_INFO_EQPEXP) {
|
||||
System.out.println("'" + ii.getName(this.getItemId()) + "' -> EXP Gain: " + gain + " Mastery: " + masteryModifier + " Base gain: " + baseExpGain + " exp: " + itemExp + " / " + expNeeded + ", Kills TNL: " + expNeeded / (baseExpGain / c.getPlayer().getExpRate()));
|
||||
log.debug("{} -> EXP Gain: {}, Mastery: {}, Base gain: {}, exp: {} / {}, Kills TNL: {}", ii.getName(getItemId()),
|
||||
gain, masteryModifier, baseExpGain, itemExp, expNeeded, expNeeded / (baseExpGain / c.getPlayer().getExpRate()));
|
||||
}
|
||||
|
||||
if (itemExp >= expNeeded) {
|
||||
|
||||
@@ -27,9 +27,10 @@ import client.inventory.manipulator.InventoryManipulator;
|
||||
import constants.inventory.ItemConstants;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.ThreadManager;
|
||||
import tools.FilePrinter;
|
||||
import tools.Pair;
|
||||
|
||||
import java.util.*;
|
||||
@@ -40,6 +41,7 @@ import java.util.concurrent.locks.Lock;
|
||||
* @author Matze, Ronan
|
||||
*/
|
||||
public class Inventory implements Iterable<Item> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Inventory.class);
|
||||
protected final Map<Short, Item> inventory;
|
||||
protected final InventoryType type;
|
||||
protected final Lock lock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.INVENTORY, true);
|
||||
@@ -117,7 +119,7 @@ public class Inventory implements Iterable<Item> {
|
||||
for (Item item : list()) {
|
||||
String itemName = ii.getName(item.getItemId());
|
||||
if (itemName == null) {
|
||||
FilePrinter.printError(FilePrinter.EXCEPTION, "[CRITICAL] Item " + item.getItemId() + " has no name.");
|
||||
log.error("[CRITICAL] Item {} has no name", item.getItemId());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Item implements Comparable<Item> {
|
||||
private int petid = -1;
|
||||
private Pet pet = null;
|
||||
private String owner = "";
|
||||
protected List<String> log;
|
||||
protected List<String> itemLog;
|
||||
private short flag;
|
||||
private long expiration = -1;
|
||||
private String giftFrom = "";
|
||||
@@ -51,7 +51,7 @@ public class Item implements Comparable<Item> {
|
||||
this.id = id;
|
||||
this.position = position;
|
||||
this.quantity = quantity;
|
||||
this.log = new LinkedList<>();
|
||||
this.itemLog = new LinkedList<>();
|
||||
this.flag = 0;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class Item implements Comparable<Item> {
|
||||
}
|
||||
this.petid = petid;
|
||||
this.flag = 0;
|
||||
this.log = new LinkedList<>();
|
||||
this.itemLog = new LinkedList<>();
|
||||
}
|
||||
|
||||
public Item copy() {
|
||||
@@ -75,7 +75,7 @@ public class Item implements Comparable<Item> {
|
||||
ret.flag = flag;
|
||||
ret.owner = owner;
|
||||
ret.expiration = expiration;
|
||||
ret.log = new LinkedList<>(log);
|
||||
ret.itemLog = new LinkedList<>(itemLog);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -147,8 +147,8 @@ public class Item implements Comparable<Item> {
|
||||
return "Item: " + id + " quantity: " + quantity;
|
||||
}
|
||||
|
||||
public List<String> getLog() {
|
||||
return Collections.unmodifiableList(log);
|
||||
public List<String> getItemLog() {
|
||||
return Collections.unmodifiableList(itemLog);
|
||||
}
|
||||
|
||||
public short getFlag() {
|
||||
|
||||
@@ -29,9 +29,10 @@ import client.newyear.NewYearCardRecord;
|
||||
import config.YamlConfig;
|
||||
import constants.id.ItemId;
|
||||
import constants.inventory.ItemConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.maps.MapleMap;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -45,6 +46,7 @@ import java.util.List;
|
||||
* @author Ronan - improved check space feature and removed redundant object calls
|
||||
*/
|
||||
public class InventoryManipulator {
|
||||
private static final Logger log = LoggerFactory.getLogger(InventoryManipulator.class);
|
||||
|
||||
public static boolean addById(Client c, int itemId, short quantity) {
|
||||
return addById(c, itemId, quantity, null, -1, -1);
|
||||
@@ -269,7 +271,7 @@ public class InventoryManipulator {
|
||||
chr.setHasSandboxItem();
|
||||
}
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.ITEM, "Tried to pickup Equip id " + itemid + " containing more than 1 quantity --> " + quantity);
|
||||
log.warn("Tried to pickup Equip id {} containing more than 1 quantity --> {}", itemid, quantity);
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.showItemUnavailable());
|
||||
return false;
|
||||
|
||||
@@ -30,10 +30,11 @@ import constants.game.GameConstants;
|
||||
import constants.id.ItemId;
|
||||
import constants.inventory.ItemConstants;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.MakerItemFactory;
|
||||
import server.MakerItemFactory.MakerItemCreateEntry;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
@@ -46,7 +47,7 @@ import java.util.Map;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MakerProcessor {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MakerProcessor.class);
|
||||
private static final ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
public static void makerAction(InPacket p, Client c) {
|
||||
@@ -150,7 +151,7 @@ public class MakerProcessor {
|
||||
|
||||
switch (createStatus) {
|
||||
case -1:// non-available for Maker itemid has been tried to forge
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS, "Player " + c.getPlayer().getName() + " tried to craft itemid " + toCreate + " using the Maker skill.");
|
||||
log.warn("Chr {} tried to craft itemid {} using the Maker skill.", c.getPlayer().getName(), toCreate);
|
||||
c.sendPacket(PacketCreator.serverNotice(1, "The requested item could not be crafted on this operation."));
|
||||
c.sendPacket(PacketCreator.makerEnableActions());
|
||||
break;
|
||||
|
||||
@@ -36,11 +36,12 @@ import config.YamlConfig;
|
||||
import constants.id.ItemId;
|
||||
import constants.inventory.ItemConstants;
|
||||
import net.server.channel.Channel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.DueyPackage;
|
||||
import server.ItemInformationProvider;
|
||||
import server.Trade;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
@@ -54,6 +55,7 @@ import java.util.List;
|
||||
* @author RonanLana - synchronization of Duey modules
|
||||
*/
|
||||
public class DueyProcessor {
|
||||
private static final Logger log = LoggerFactory.getLogger(DueyProcessor.class);
|
||||
|
||||
public enum Actions {
|
||||
TOSERVER_RECV_ITEM(0x00),
|
||||
@@ -204,7 +206,7 @@ public class DueyProcessor {
|
||||
|
||||
int updateRows = ps.executeUpdate();
|
||||
if (updateRows < 1) {
|
||||
FilePrinter.printError(FilePrinter.INSERT_CHAR, "Error trying to create package [mesos: " + mesos + ", " + sender + ", quick: " + quick + ", to CharacterId: " + toCid + "]");
|
||||
log.error("Error trying to create package [mesos: {}, sender: {}, quick: {}, receiver chrId: {}]", mesos, sender, quick, toCid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -213,7 +215,7 @@ public class DueyProcessor {
|
||||
if (rs.next()) {
|
||||
packageId = rs.getInt(1);
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.INSERT_CHAR, "Failed inserting package [mesos: " + mesos + ", " + sender + ", quick: " + quick + ", to CharacterId: " + toCid + "]");
|
||||
log.error("Failed inserting package [mesos: {}, sender: {}, quick: {}, receiver chrId: {}]", mesos, sender, quick, toCid);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -287,7 +289,7 @@ public class DueyProcessor {
|
||||
fee += 5000;
|
||||
} else if (!c.getPlayer().haveItem(ItemId.QUICK_DELIVERY_TICKET)) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with Quick Delivery on duey.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to use duey with Quick Delivery, mesos " + sendMesos + " and amount " + amount);
|
||||
log.warn("Chr {} tried to use duey with Quick Delivery without a ticket, mesos {} and amount {}", c.getPlayer().getName(), sendMesos, amount);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
@@ -295,7 +297,7 @@ public class DueyProcessor {
|
||||
long finalcost = (long) sendMesos + fee;
|
||||
if (finalcost < 0 || finalcost > Integer.MAX_VALUE || (amount < 1 && sendMesos == 0)) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with duey.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to use duey with mesos " + sendMesos + " and amount " + amount);
|
||||
log.warn("Chr {} tried to use duey with mesos {} and amount {}", c.getPlayer().getName(), sendMesos, amount);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
@@ -394,7 +396,7 @@ public class DueyProcessor {
|
||||
|
||||
if (dp == null) {
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to receive package from duey with id " + packageId);
|
||||
log.warn("Chr {} tried to receive package from duey with id {}", c.getPlayer().getName(), packageId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,10 +32,11 @@ import client.inventory.ItemFactory;
|
||||
import client.inventory.manipulator.InventoryManipulator;
|
||||
import net.server.Server;
|
||||
import net.server.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.maps.HiredMerchant;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
@@ -50,7 +51,7 @@ import static java.util.concurrent.TimeUnit.DAYS;
|
||||
* @author RonanLana - synchronization of Fredrick modules and operation results
|
||||
*/
|
||||
public class FredrickProcessor {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FredrickProcessor.class);
|
||||
private static final int[] dailyReminders = new int[]{2, 5, 10, 15, 30, 60, 90, Integer.MAX_VALUE};
|
||||
|
||||
private static byte canRetrieveFromFredrick(Character chr, List<Pair<Item, InventoryType>> items) {
|
||||
@@ -293,7 +294,7 @@ public class FredrickProcessor {
|
||||
Item item = it.getLeft();
|
||||
InventoryManipulator.addFromDrop(chr.getClient(), item, false);
|
||||
String itemName = ItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.FREDRICK + chr.getName() + ".txt", chr.getName() + " gained " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")");
|
||||
log.debug("Chr {} gained {}x {} ({})", chr.getName(), item.getQuantity(), itemName, item.getItemId());
|
||||
}
|
||||
|
||||
chr.sendPacket(PacketCreator.fredrickMessage((byte) 0x1E));
|
||||
|
||||
@@ -33,9 +33,10 @@ import config.YamlConfig;
|
||||
import constants.id.ItemId;
|
||||
import constants.inventory.ItemConstants;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.Storage;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,7 @@ import tools.PacketCreator;
|
||||
* @author Ronan - inventory concurrency protection on storing items
|
||||
*/
|
||||
public class StorageProcessor {
|
||||
private static final Logger log = LoggerFactory.getLogger(StorageProcessor.class);
|
||||
|
||||
public static void storageAction(InPacket p, Client c) {
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
@@ -63,7 +65,7 @@ public class StorageProcessor {
|
||||
byte slot = p.readByte();
|
||||
if (slot < 0 || slot > storage.getSlots()) { // removal starts at zero
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to work with storage slot " + slot);
|
||||
log.warn("Chr {} tried to work with storage slot {}", c.getPlayer().getName(), slot);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +93,7 @@ public class StorageProcessor {
|
||||
InventoryManipulator.addFromDrop(c, item, false);
|
||||
|
||||
String itemName = ii.getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " took out " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")");
|
||||
log.debug("Chr {} took out {}x {} ({})", c.getPlayer().getName(), item.getQuantity(), itemName, item.getItemId());
|
||||
|
||||
storage.sendTakenOut(c, item.getInventoryType());
|
||||
} else {
|
||||
@@ -110,7 +112,7 @@ public class StorageProcessor {
|
||||
Inventory inv = chr.getInventory(invType);
|
||||
if (slot < 1 || slot > inv.getSlotLimit()) { //player inv starts at one
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to store item at slot " + slot);
|
||||
log.warn("Chr {} tried to store item at slot {}", c.getPlayer().getName(), slot);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
@@ -162,8 +164,7 @@ public class StorageProcessor {
|
||||
chr.setUsedStorage();
|
||||
|
||||
String itemName = ii.getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " stored " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")");
|
||||
|
||||
log.debug("Chr {} stored {}x {} ({})", c.getPlayer().getName(), item.getQuantity(), itemName, item.getItemId());
|
||||
storage.sendStored(c, ItemConstants.getInventoryType(itemId));
|
||||
}
|
||||
} else if (mode == 6) { // arrange items
|
||||
@@ -192,7 +193,7 @@ public class StorageProcessor {
|
||||
storage.setMeso(storageMesos - meso);
|
||||
chr.gainMeso(meso, false, true, false);
|
||||
chr.setUsedStorage();
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + (meso > 0 ? " took out " : " stored ") + Math.abs(meso) + " mesos");
|
||||
log.debug("Chr {} {} {} mesos", c.getPlayer().getName(), meso > 0 ? "took out" : "stored", Math.abs(meso));
|
||||
storage.sendMeso(c);
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
|
||||
@@ -30,13 +30,15 @@ import client.SkillFactory;
|
||||
import client.autoban.AutobanFactory;
|
||||
import constants.game.GameConstants;
|
||||
import constants.skills.Aran;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
* @author RonanLana - synchronization of SP transaction modules
|
||||
*/
|
||||
public class AssignSPProcessor {
|
||||
private static final Logger log = LoggerFactory.getLogger(AssignSPProcessor.class);
|
||||
|
||||
public static boolean canSPAssign(Client c, int skillid) {
|
||||
if (skillid == Aran.HIDDEN_FULL_DOUBLE || skillid == Aran.HIDDEN_FULL_TRIPLE || skillid == Aran.HIDDEN_OVER_DOUBLE || skillid == Aran.HIDDEN_OVER_TRIPLE) {
|
||||
@@ -47,7 +49,7 @@ public class AssignSPProcessor {
|
||||
Character player = c.getPlayer();
|
||||
if ((!GameConstants.isPqSkillMap(player.getMapId()) && GameConstants.isPqSkill(skillid)) || (!player.isGM() && GameConstants.isGMSkills(skillid)) || (!GameConstants.isInJobTree(skillid, player.getJob().getId()) && !player.isGM())) {
|
||||
AutobanFactory.PACKET_EDIT.alert(player, "tried to packet edit in distributing sp.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to use skill " + skillid + " without it being in their job.");
|
||||
log.warn("Chr {} tried to use skill {} without it being in their job.", c.getPlayer().getName(), skillid);
|
||||
|
||||
c.disconnect(true, false);
|
||||
return false;
|
||||
|
||||
@@ -28,13 +28,15 @@ import net.server.handlers.CustomPacketHandler;
|
||||
import net.server.handlers.KeepAliveHandler;
|
||||
import net.server.handlers.LoginRequiringNoOpHandler;
|
||||
import net.server.handlers.login.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class PacketProcessor {
|
||||
|
||||
private final static Map<String, PacketProcessor> instances = new LinkedHashMap<>();
|
||||
private static final Logger log = LoggerFactory.getLogger(PacketProcessor.class);
|
||||
private static final Map<String, PacketProcessor> instances = new LinkedHashMap<>();
|
||||
private PacketHandler[] handlers;
|
||||
|
||||
private PacketProcessor() {
|
||||
@@ -67,8 +69,7 @@ public final class PacketProcessor {
|
||||
try {
|
||||
handlers[code.getValue()] = handler;
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Error registering handler - " + code.name());
|
||||
log.error("Error registering handler {}", code.name(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
package net.packet.logging;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.opcodes.RecvOpcode;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class LoggingUtil {
|
||||
private static final Set<Short> ignoredDebugRecvPackets = Set.of((short) 167, (short) 197, (short) 89, (short) 91, (short) 41, (short) 188, (short) 107);
|
||||
private static final Set<Short> ignoredDebugRecvPackets = Set.of(
|
||||
(short) RecvOpcode.MOVE_PLAYER.getValue(), // 41
|
||||
(short) RecvOpcode.HEAL_OVER_TIME.getValue(), // 89
|
||||
(short) RecvOpcode.SPECIAL_MOVE.getValue(), // 91
|
||||
(short) RecvOpcode.QUEST_ACTION.getValue(), // 107
|
||||
(short) RecvOpcode.MOVE_PET.getValue(), // 167
|
||||
(short) RecvOpcode.MOVE_LIFE.getValue(), // 188
|
||||
(short) RecvOpcode.NPC_ACTION.getValue() // 197
|
||||
);
|
||||
|
||||
public static short readFirstShort(byte[] bytes) {
|
||||
return Unpooled.wrappedBuffer(bytes).readShortLE();
|
||||
|
||||
@@ -22,38 +22,61 @@ package net.packet.logging;
|
||||
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import net.jcip.annotations.NotThreadSafe;
|
||||
import net.opcodes.RecvOpcode;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.HexTool;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Logs packets to console and file.
|
||||
* Logs packets from monitored characters to a file.
|
||||
*
|
||||
* @author Alan (SharpAceX)
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class MonitoredChrLogger {
|
||||
private static final Logger log = LoggerFactory.getLogger(MonitoredChrLogger.class);
|
||||
private static final Set<Integer> monitoredChrIds = new HashSet<>();
|
||||
|
||||
public class MapleLogger {
|
||||
public static final Set<Integer> monitored = new HashSet<>();
|
||||
public static final Set<Integer> ignored = new HashSet<>();
|
||||
/**
|
||||
* Toggle monitored status for a character id
|
||||
*
|
||||
* @return new status. true if the chrId is now monitored, otherwise false.
|
||||
*/
|
||||
public static boolean toggleMonitored(int chrId) {
|
||||
if (monitoredChrIds.contains(chrId)) {
|
||||
monitoredChrIds.remove(chrId);
|
||||
return false;
|
||||
} else {
|
||||
monitoredChrIds.add(chrId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void logRecv(Client c, short packetId, byte[] packetContent) {
|
||||
public static Collection<Integer> getMonitoredChrIds() {
|
||||
return monitoredChrIds;
|
||||
}
|
||||
|
||||
public static void logPacketIfMonitored(Client c, short packetId, byte[] packetContent) {
|
||||
Character chr = c.getPlayer();
|
||||
if (chr == null) {
|
||||
return;
|
||||
}
|
||||
if (!monitored.contains(chr.getId())) {
|
||||
if (!monitoredChrIds.contains(chr.getId())) {
|
||||
return;
|
||||
}
|
||||
RecvOpcode op = getOpcodeFromValue(packetId);
|
||||
if (isRecvBlocked(op)) {
|
||||
return;
|
||||
}
|
||||
String packet = op + "\r\n" + HexTool.toString(packetContent);
|
||||
FilePrinter.printError(FilePrinter.PACKET_LOGS + c.getAccountName() + "-" + chr.getName() + ".txt", packet);
|
||||
|
||||
String packet = packetContent.length > 0 ? HexTool.toString(packetContent) : "<empty>";
|
||||
log.info("{}-{} {}-{}", c.getAccountName(), chr.getName(), packetId, packet);
|
||||
}
|
||||
|
||||
private static boolean isRecvBlocked(RecvOpcode op) {
|
||||
@@ -63,7 +63,6 @@ import server.expeditions.ExpeditionBossLog;
|
||||
import server.life.PlayerNPCFactory;
|
||||
import server.quest.Quest;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.Pair;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -304,11 +303,10 @@ public class Server {
|
||||
private void dumpData() {
|
||||
wldRLock.lock();
|
||||
try {
|
||||
System.out.println(worlds);
|
||||
System.out.println(channels);
|
||||
System.out.println(worldRecommendedList);
|
||||
System.out.println();
|
||||
System.out.println("---------------------");
|
||||
log.debug("Worlds: {}", worlds);
|
||||
log.debug("Channels: {}", channels);
|
||||
log.debug("World recommended list: {}", worldRecommendedList);
|
||||
log.debug("---------------------");
|
||||
} finally {
|
||||
wldRLock.unlock();
|
||||
}
|
||||
@@ -886,8 +884,7 @@ public class Server {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();//For those who get errors
|
||||
log.error("[SEVERE] Syntax error in 'world.ini'.");
|
||||
log.error("[SEVERE] Syntax error in 'world.ini'.", e); //For those who get errors
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -1106,7 +1103,7 @@ public class Server {
|
||||
mc.setMGC(mgc);
|
||||
mgc.setCharacter(mc);
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.GUILD_CHAR_ERROR, "Could not find " + mc.getName() + " when loading guild " + id + ".");
|
||||
log.error("Could not find chr {} when loading guild {}", mc.getName(), id);
|
||||
}
|
||||
|
||||
g.setOnline(mc.getId(), true, mc.getClient().getChannel());
|
||||
@@ -1596,7 +1593,7 @@ public class Server {
|
||||
}
|
||||
//log
|
||||
for (Pair<String, String> namePair : changedNames) {
|
||||
log.info("Name change applied - from: \"{}\" to \"{}\" at {}", namePair.getLeft(), namePair.getRight(), Instant.now());
|
||||
log.info("Name change applied - from: \"{}\" to \"{}\"", namePair.getLeft(), namePair.getRight());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.warn("Failed to retrieve list of pending name changes", e);
|
||||
@@ -1617,13 +1614,12 @@ public class Server {
|
||||
String reason = Character.checkWorldTransferEligibility(con, characterId, oldWorld, newWorld); //check if character is still eligible
|
||||
if (reason != null) {
|
||||
removedTransfers.add(nameChangeId);
|
||||
FilePrinter.print(FilePrinter.WORLD_TRANSFER, "World transfer cancelled : Character ID " + characterId + " at " + Calendar.getInstance().getTime() + ", Reason : " + reason);
|
||||
log.info("World transfer canceled: chrId {}, reason {}", characterId, reason);
|
||||
try (PreparedStatement delPs = con.prepareStatement("DELETE FROM worldtransfers WHERE id = ?")) {
|
||||
delPs.setInt(1, nameChangeId);
|
||||
delPs.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, e, "Failed to delete world transfer for character ID " + characterId);
|
||||
log.error("Failed to delete world transfer for chrId {}", characterId, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1657,7 +1653,7 @@ public class Server {
|
||||
int charId = worldTransferPair.getLeft();
|
||||
int oldWorld = worldTransferPair.getRight().getLeft();
|
||||
int newWorld = worldTransferPair.getRight().getRight();
|
||||
log.info("World transfer applied - character id {} from world {} to world {} at {}", charId, oldWorld, newWorld, Instant.now());
|
||||
log.info("World transfer applied - character id {} from world {} to world {}", charId, oldWorld, newWorld);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.warn("Failed to retrieve list of pending world transfers", e);
|
||||
@@ -1881,7 +1877,7 @@ public class Server {
|
||||
}
|
||||
|
||||
private synchronized void shutdownInternal(boolean restart) {
|
||||
System.out.println((restart ? "Restarting" : "Shutting down") + " the server!\r\n");
|
||||
log.info("{} the server!", restart ? "Restarting" : "Shutting down");
|
||||
if (getWorlds() == null) {
|
||||
return;//already shutdown
|
||||
}
|
||||
@@ -1919,8 +1915,7 @@ public class Server {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
System.err.println("FUCK MY LIFE");
|
||||
log.error("Error during shutdown sleep", ie);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1931,12 +1926,12 @@ public class Server {
|
||||
TimerManager.getInstance().purge();
|
||||
TimerManager.getInstance().stop();
|
||||
|
||||
System.out.println("Worlds + Channels are offline.");
|
||||
log.info("World and channels are offline.");
|
||||
loginServer.stop();
|
||||
if (!restart) { // shutdown hook deadlocks if System.exit() method is used within its body chores, thanks MIKE for pointing that out
|
||||
new Thread(() -> System.exit(0)).start();
|
||||
} else {
|
||||
System.out.println("\r\nRestarting the server....\r\n");
|
||||
log.info("Restarting the server...");
|
||||
try {
|
||||
instance.finalize();//FUU I CAN AND IT'S FREE
|
||||
} catch (Throwable ex) {
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
package net.server.audit;
|
||||
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.TimerManager;
|
||||
import tools.FilePrinter;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -38,6 +39,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
* This tool has the main purpose of auditing deadlocks throughout the server and must be used only for debugging. The flag is USE_THREAD_TRACKER.
|
||||
*/
|
||||
public class ThreadTracker {
|
||||
private static final Logger log = LoggerFactory.getLogger(ThreadTracker.class);
|
||||
private static ThreadTracker instance = null;
|
||||
|
||||
public static ThreadTracker getInstance() {
|
||||
@@ -147,8 +149,8 @@ public class ThreadTracker {
|
||||
dateFormat.setTimeZone(TimeZone.getDefault());
|
||||
String df = dateFormat.format(new Date());
|
||||
|
||||
FilePrinter.print(FilePrinter.DEADLOCK_LOCKS, printThreadLog(tt, df));
|
||||
FilePrinter.print(FilePrinter.DEADLOCK_STACK, printThreadStack(ste, df));
|
||||
log.debug("Thread log - {}", printThreadLog(tt, df));
|
||||
log.debug("thread stack - {}", printThreadStack(ste, df));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,7 +190,7 @@ public class ThreadTracker {
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
|
||||
dateFormat.setTimeZone(TimeZone.getDefault());
|
||||
|
||||
FilePrinter.printError(FilePrinter.DEADLOCK_STATE, printThreadTrackerState(dateFormat.format(new Date())));
|
||||
log.error("Deadlock state: {}", printThreadTrackerState(dateFormat.format(new Date())));
|
||||
//FilePrinter.printError(FilePrinter.DEADLOCK_STATE, "[" + dateFormat.format(new Date()) + "] Presenting current lock path for lockid " + lockId.name() + ".\r\n" + printLockStatus(lockId) + "\r\n-------------------------------");
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -21,12 +21,14 @@ package net.server.audit.locks.empty;
|
||||
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReadLock;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class EmptyReadLock extends AbstractEmptyLock implements MonitoredReadLock {
|
||||
private static final Logger log = LoggerFactory.getLogger(EmptyReadLock.class);
|
||||
private final MonitoredLockType id;
|
||||
|
||||
public EmptyReadLock(MonitoredLockType type) {
|
||||
@@ -35,7 +37,7 @@ public class EmptyReadLock extends AbstractEmptyLock implements MonitoredReadLoc
|
||||
|
||||
@Override
|
||||
public void lock() {
|
||||
FilePrinter.printError(FilePrinter.DISPOSED_LOCKS, "Captured locking tentative on disposed lock " + id + ":" + printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
log.warn("Captured locking tentative on disposed lock {}: {}", id, printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +45,7 @@ public class EmptyReadLock extends AbstractEmptyLock implements MonitoredReadLoc
|
||||
|
||||
@Override
|
||||
public boolean tryLock() {
|
||||
FilePrinter.printError(FilePrinter.DISPOSED_LOCKS, "Captured try-locking tentative on disposed lock " + id + ":" + printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
log.warn("Captured try-locking tentative on disposed lock {}: {}", id, printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,14 @@ package net.server.audit.locks.empty;
|
||||
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReentrantLock;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class EmptyReentrantLock extends AbstractEmptyLock implements MonitoredReentrantLock {
|
||||
private static final Logger log = LoggerFactory.getLogger(EmptyReentrantLock.class);
|
||||
private final MonitoredLockType id;
|
||||
|
||||
public EmptyReentrantLock(MonitoredLockType type) {
|
||||
@@ -35,7 +37,7 @@ public class EmptyReentrantLock extends AbstractEmptyLock implements MonitoredRe
|
||||
|
||||
@Override
|
||||
public void lock() {
|
||||
FilePrinter.printError(FilePrinter.DISPOSED_LOCKS, "Captured locking tentative on disposed lock " + id + ":" + printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
log.warn("Captured locking tentative on disposed lock {}: {}", id, printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +45,7 @@ public class EmptyReentrantLock extends AbstractEmptyLock implements MonitoredRe
|
||||
|
||||
@Override
|
||||
public boolean tryLock() {
|
||||
FilePrinter.printError(FilePrinter.DISPOSED_LOCKS, "Captured try-locking tentative on disposed lock " + id + ":" + printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
log.warn("Captured try-locking tentative on disposed lock {}: {}", id, printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,14 @@ package net.server.audit.locks.empty;
|
||||
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredWriteLock;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class EmptyWriteLock extends AbstractEmptyLock implements MonitoredWriteLock {
|
||||
private static final Logger log = LoggerFactory.getLogger(EmptyWriteLock.class);
|
||||
private final MonitoredLockType id;
|
||||
|
||||
public EmptyWriteLock(MonitoredLockType type) {
|
||||
@@ -35,7 +37,7 @@ public class EmptyWriteLock extends AbstractEmptyLock implements MonitoredWriteL
|
||||
|
||||
@Override
|
||||
public void lock() {
|
||||
FilePrinter.printError(FilePrinter.DISPOSED_LOCKS, "Captured locking tentative on disposed lock " + id + ":" + printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
log.warn("Captured locking tentative on disposed lock {}: {}", id, printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +45,7 @@ public class EmptyWriteLock extends AbstractEmptyLock implements MonitoredWriteL
|
||||
|
||||
@Override
|
||||
public boolean tryLock() {
|
||||
FilePrinter.printError(FilePrinter.DISPOSED_LOCKS, "Captured try-locking tentative on disposed lock " + id + ":" + printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
log.warn("Captured try-locking tentative on dispsoed lock {}: {}", id, printThreadStack(Thread.currentThread().getStackTrace()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,13 +164,13 @@ public final class Channel {
|
||||
eventSM = new EventScriptManager(this, getEvents());
|
||||
}
|
||||
|
||||
public final synchronized void shutdown() {
|
||||
public synchronized void shutdown() {
|
||||
try {
|
||||
if (finishedShutdown) {
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("Shutting down Channel " + channel + " on World " + world);
|
||||
log.info("Shutting down channel {} in world {}", channel, world);
|
||||
|
||||
closeAllMerchants();
|
||||
disconnectAwayPlayers();
|
||||
@@ -188,10 +188,9 @@ public final class Channel {
|
||||
channelServer.stop();
|
||||
|
||||
finishedShutdown = true;
|
||||
System.out.println("Successfully shut down Channel " + channel + " on World " + world + "\r\n");
|
||||
log.info("Successfully shut down channel {} in world {}", channel, world);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("Error while shutting down Channel " + channel + " on World " + world + "\r\n" + e);
|
||||
log.error("Error while shutting down channel {} in world {}", channel, world, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1024,26 +1023,22 @@ public final class Channel {
|
||||
}
|
||||
|
||||
public void debugMarriageStatus() {
|
||||
System.out.println(" ----- WORLD DATA -----");
|
||||
log.debug(" ----- WORLD DATA -----");
|
||||
getWorldServer().debugMarriageStatus();
|
||||
|
||||
System.out.println(" ----- CH. " + channel + " -----");
|
||||
System.out.println(" ----- CATHEDRAL -----");
|
||||
System.out.println("Current Queue: " + cathedralReservationQueue);
|
||||
System.out.println("Cancel Task: " + (cathedralReservationTask != null));
|
||||
System.out.println("Ongoing wid: " + ongoingCathedral);
|
||||
System.out.println();
|
||||
System.out.println("Ongoing wid: " + ongoingCathedral + " isPremium: " + ongoingCathedralType);
|
||||
System.out.println("Guest list: " + ongoingCathedralGuests);
|
||||
System.out.println();
|
||||
System.out.println(" ----- CHAPEL -----");
|
||||
System.out.println("Current Queue: " + chapelReservationQueue);
|
||||
System.out.println("Cancel Task: " + (chapelReservationTask != null));
|
||||
System.out.println("Ongoing wid: " + ongoingChapel);
|
||||
System.out.println();
|
||||
System.out.println("Ongoing wid: " + ongoingChapel + " isPremium: " + ongoingChapelType);
|
||||
System.out.println("Guest list: " + ongoingChapelGuests);
|
||||
System.out.println();
|
||||
System.out.println("Starttime: " + ongoingStartTime);
|
||||
log.debug(" ----- CH. {} -----", channel);
|
||||
log.debug(" ----- CATHEDRAL -----");
|
||||
log.debug("Current Queue: {}", cathedralReservationQueue);
|
||||
log.debug("Cancel Task?: {}", cathedralReservationTask != null);
|
||||
log.debug("Ongoing wid: {}", ongoingCathedral);
|
||||
log.debug("Ongoing wid: {}, isPremium: {}", ongoingCathedral, ongoingCathedralType);
|
||||
log.debug("Guest list: {}", ongoingCathedralGuests);
|
||||
log.debug(" ----- CHAPEL -----");
|
||||
log.debug("Current Queue: {}", chapelReservationQueue);
|
||||
log.debug("Cancel Task?: {}", chapelReservationTask != null);
|
||||
log.debug("Ongoing wid: {}", ongoingChapel);
|
||||
log.debug("Ongoing wid: {}, isPremium: {}", ongoingChapel, ongoingChapelType);
|
||||
log.debug("Guest list: {}", ongoingChapelGuests);
|
||||
log.debug("Starttime: {}", ongoingStartTime);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ package net.server.channel.handlers;
|
||||
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.maps.AnimatedMapObject;
|
||||
import server.movement.*;
|
||||
import tools.exceptions.EmptyMovementException;
|
||||
@@ -32,6 +34,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractMovementPacketHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractMovementPacketHandler.class);
|
||||
|
||||
protected List<LifeMovementFragment> parseMovement(InPacket p) throws EmptyMovementException {
|
||||
List<LifeMovementFragment> res = new ArrayList<>();
|
||||
@@ -136,7 +139,7 @@ public abstract class AbstractMovementPacketHandler extends AbstractPacketHandle
|
||||
break;
|
||||
}
|
||||
default:
|
||||
System.out.println("Unhandled Case:" + command);
|
||||
log.warn("Unhandled case: {}", command);
|
||||
throw new EmptyMovementException(p);
|
||||
}
|
||||
}
|
||||
@@ -235,7 +238,7 @@ public abstract class AbstractMovementPacketHandler extends AbstractPacketHandle
|
||||
break;
|
||||
}
|
||||
default:
|
||||
System.out.println("Unhandled Case:" + command);
|
||||
log.warn("Unhandled Case: {}", command);
|
||||
throw new EmptyMovementException(p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,9 @@ import net.server.coordinator.world.InviteCoordinator;
|
||||
import net.server.coordinator.world.InviteCoordinator.InviteResult;
|
||||
import net.server.coordinator.world.InviteCoordinator.InviteResultType;
|
||||
import net.server.coordinator.world.InviteCoordinator.InviteType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -45,9 +46,10 @@ import java.sql.SQLException;
|
||||
* @author Ubaware
|
||||
*/
|
||||
public final class AcceptFamilyHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(AcceptFamilyHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
if (!YamlConfig.config.server.USE_FAMILY_SYSTEM) {
|
||||
return;
|
||||
}
|
||||
@@ -134,8 +136,7 @@ public final class AcceptFamilyHandler extends AbstractPacketHandler {
|
||||
ps.setInt(3, seniorID);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not save new family record for char id " + characterID + ".");
|
||||
e.printStackTrace();
|
||||
log.error("Could not save new family record for chrId {}", characterID, e);
|
||||
}
|
||||
if (updateChar) {
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET familyid = ? WHERE id = ?")) {
|
||||
@@ -143,13 +144,11 @@ public final class AcceptFamilyHandler extends AbstractPacketHandler {
|
||||
ps.setInt(2, characterID);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not update 'characters' 'familyid' record for char id " + characterID + ".");
|
||||
e.printStackTrace();
|
||||
log.error("Could not update 'characters' 'familyid' record for chrId {}", characterID, e);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get connection to DB.");
|
||||
e.printStackTrace();
|
||||
log.error("Could not get connection to DB while inserting new family record", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package net.server.channel.handlers;
|
||||
|
||||
import client.Client;
|
||||
import config.YamlConfig;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import net.packet.Packet;
|
||||
import tools.LogHelper;
|
||||
import server.ChatLogger;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
@@ -23,25 +22,18 @@ public class AdminChatHandler extends AbstractPacketHandler {
|
||||
String message = p.readString();
|
||||
Packet packet = PacketCreator.serverNotice(p.readByte(), message);//maybe I should make a check for the slea.readByte()... but I just hope gm's don't fuck things up :)
|
||||
switch (mode) {
|
||||
case 0:// /alertall, /noticeall, /slideall
|
||||
case 0 -> {// /alertall, /noticeall, /slideall
|
||||
c.getWorldServer().broadcastPacket(packet);
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "Alert All", message);
|
||||
}
|
||||
break;
|
||||
case 1:// /alertch, /noticech, /slidech
|
||||
ChatLogger.log(c, "Alert All", message);
|
||||
}
|
||||
case 1 -> {// /alertch, /noticech, /slidech
|
||||
c.getChannelServer().broadcastPacket(packet);
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "Alert Ch", message);
|
||||
}
|
||||
break;
|
||||
case 2:// /alertm /alertmap, /noticem /noticemap, /slidem /slidemap
|
||||
ChatLogger.log(c, "Alert Ch", message);
|
||||
}
|
||||
case 2 -> {// /alertm /alertmap, /noticem /noticemap, /slidem /slidemap
|
||||
c.getPlayer().getMap().broadcastMessage(packet);
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "Alert Map", message);
|
||||
}
|
||||
break;
|
||||
|
||||
ChatLogger.log(c, "Alert Map", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import client.inventory.InventoryType;
|
||||
import client.inventory.manipulator.InventoryManipulator;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.life.LifeFactory;
|
||||
import server.life.Monster;
|
||||
@@ -41,9 +43,10 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public final class AdminCommandHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(AdminCommandHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
if (!c.getPlayer().isGM()) {
|
||||
return;
|
||||
}
|
||||
@@ -170,13 +173,13 @@ public final class AdminCommandHandler extends AbstractPacketHandler {
|
||||
break;
|
||||
case 0x77: //Testing purpose
|
||||
if (p.available() == 4) {
|
||||
System.out.println(p.readInt());
|
||||
log.debug("int: {}", p.readInt());
|
||||
} else if (p.available() == 2) {
|
||||
System.out.println(p.readShort());
|
||||
log.debug("short: {}", p.readShort());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("New GM packet encountered (MODE : " + mode + ": " + p);
|
||||
log.info("New GM packet encountered (MODE: {}): {}", mode, p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import client.Client;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import net.server.guild.GuildPackets;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.DatabaseConnection;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -34,13 +36,14 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public final class BBSOperationHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(BBSOperationHandler.class);
|
||||
|
||||
private String correctLength(String in, int maxSize) {
|
||||
return in.length() > maxSize ? in.substring(0, maxSize) : in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
if (c.getPlayer().getGuildId() < 1) {
|
||||
return;
|
||||
}
|
||||
@@ -324,10 +327,9 @@ public final class BBSOperationHandler extends AbstractPacketHandler {
|
||||
ps2.close();
|
||||
}
|
||||
} catch (SQLException se) {
|
||||
se.printStackTrace();
|
||||
log.error("Error displaying thread", se);
|
||||
} catch (RuntimeException re) {//btw we get this everytime for some reason, but replies work!
|
||||
re.printStackTrace();
|
||||
System.out.println("The number of reply rows does not match the replycount in thread.");
|
||||
log.error("The number of reply rows does not match the replycount in thread.", re);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,12 @@ import constants.inventory.ItemConstants;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.CashShop;
|
||||
import server.CashShop.CashItem;
|
||||
import server.CashShop.CashItemFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
@@ -51,9 +52,10 @@ import java.util.Map;
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
|
||||
public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(CashOperationHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
Character chr = c.getPlayer();
|
||||
CashShop cs = chr.getCashShop();
|
||||
|
||||
@@ -71,7 +73,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
final int snCS = p.readInt();
|
||||
CashItem cItem = CashItemFactory.getItem(snCS);
|
||||
if (!canBuy(chr, cItem, cs.getCash(useNX))) {
|
||||
FilePrinter.printError(FilePrinter.ITEM, "Denied to sell cash item with SN " + snCS); // preventing NPE here thanks to MedicOP
|
||||
log.error("Denied to sell cash item with SN {}", snCS); // preventing NPE here thanks to MedicOP
|
||||
c.enableCSActions();
|
||||
return;
|
||||
}
|
||||
@@ -165,7 +167,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
c.sendPacket(PacketCreator.showBoughtInventorySlots(type, chr.getSlots(type)));
|
||||
c.sendPacket(PacketCreator.showCash(chr));
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.CASHITEM_BOUGHT, "Could not add " + qty + " slots of type " + type + " for player " + Character.makeMapleReadable(chr.getName()));
|
||||
log.warn("Could not add {} slots of type {} for chr {}", qty, type, Character.makeMapleReadable(chr.getName()));
|
||||
}
|
||||
} else {
|
||||
CashItem cItem = CashItemFactory.getItem(p.readInt());
|
||||
@@ -184,7 +186,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
c.sendPacket(PacketCreator.showBoughtInventorySlots(type, chr.getSlots(type)));
|
||||
c.sendPacket(PacketCreator.showCash(chr));
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.CASHITEM_BOUGHT, "Could not add " + qty + " slots of type " + type + " for player " + Character.makeMapleReadable(chr.getName()));
|
||||
log.warn("Could not add {} slots of type {} for chr {}", qty, type, Character.makeMapleReadable(chr.getName()));
|
||||
}
|
||||
}
|
||||
} else if (action == 0x07) { // Increase Storage Slots
|
||||
@@ -203,13 +205,13 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
}
|
||||
cs.gainCash(cash, -4000);
|
||||
if (chr.getStorage().gainSlots(qty)) {
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " bought " + qty + " slots to their account storage.");
|
||||
log.debug("Chr {} bought {} slots to their account storage.", c.getPlayer().getName(), qty);
|
||||
chr.setUsedStorage();
|
||||
|
||||
c.sendPacket(PacketCreator.showBoughtStorageSlots(chr.getStorage().getSlots()));
|
||||
c.sendPacket(PacketCreator.showCash(chr));
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.CASHITEM_BOUGHT, "Could not add " + qty + " slots to " + Character.makeMapleReadable(chr.getName()) + "'s account.");
|
||||
log.warn("Could not add {} slots to {}'s account.", qty, Character.makeMapleReadable(chr.getName()));
|
||||
}
|
||||
} else {
|
||||
CashItem cItem = CashItemFactory.getItem(p.readInt());
|
||||
@@ -225,13 +227,13 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
}
|
||||
cs.gainCash(cash, cItem, chr.getWorld());
|
||||
if (chr.getStorage().gainSlots(qty)) { // thanks ABaldParrot & Thora for detecting storage issues here
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " bought " + qty + " slots to their account storage.");
|
||||
log.debug("Chr {} bought {} slots to their account storage", c.getPlayer().getName(), qty);
|
||||
chr.setUsedStorage();
|
||||
|
||||
c.sendPacket(PacketCreator.showBoughtStorageSlots(chr.getStorage().getSlots()));
|
||||
c.sendPacket(PacketCreator.showCash(chr));
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.CASHITEM_BOUGHT, "Could not add " + qty + " slots to " + Character.makeMapleReadable(chr.getName()) + "'s account.");
|
||||
log.warn("Could not add {} slots to {}'s account", qty, Character.makeMapleReadable(chr.getName()));
|
||||
}
|
||||
}
|
||||
} else if (action == 0x08) { // Increase Character Slots
|
||||
@@ -253,7 +255,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
c.sendPacket(PacketCreator.showBoughtCharacterSlot(c.getCharacterSlots()));
|
||||
c.sendPacket(PacketCreator.showCash(chr));
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.CASHITEM_BOUGHT, "Could not add a character slot to " + Character.makeMapleReadable(chr.getName()) + "'s account.");
|
||||
log.warn("Could not add a chr slot to {}'s account", Character.makeMapleReadable(chr.getName()));
|
||||
c.enableCSActions();
|
||||
return;
|
||||
}
|
||||
@@ -467,7 +469,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
}
|
||||
c.enableCSActions();
|
||||
} else {
|
||||
System.out.println("Unhandled action: " + action + "\n" + p);
|
||||
log.warn("Unhandled action: {}, packet: {}", action, p);
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
@@ -489,7 +491,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
|
||||
private static boolean canBuy(Character chr, CashItem item, int cash) {
|
||||
if (item != null && item.isOnSale() && item.getPrice() <= cash) {
|
||||
FilePrinter.print(FilePrinter.CASHITEM_BOUGHT, chr + " bought " + ItemInformationProvider.getInstance().getName(item.getItemId()) + " (SN " + item.getSN() + ") for " + item.getPrice());
|
||||
log.debug("Chr {} bought cash item {} (SN {}) for {}", chr, ItemInformationProvider.getInstance().getName(item.getItemId()), item.getSN(), item.getPrice());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -29,26 +29,27 @@ import constants.id.ItemId;
|
||||
import constants.id.MapId;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.Trade;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.Portal;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.awt.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Calendar;
|
||||
|
||||
public final class ChangeMapHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(ChangeMapHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
Character chr = c.getPlayer();
|
||||
|
||||
if (chr.isChangingMaps() || chr.isBanned()) {
|
||||
if (chr.isChangingMaps()) {
|
||||
FilePrinter.printError(FilePrinter.PORTAL_STUCK + chr.getName() + ".txt", "Player " + chr.getName() + " got stuck when changing maps. Timestamp: " + Calendar.getInstance().getTime() + " Last visited mapids: " + chr.getLastVisitedMapids());
|
||||
log.warn("Chr {} got stuck when changing maps. Last visited mapids: {}", chr.getName(), chr.getLastVisitedMapids());
|
||||
}
|
||||
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
|
||||
@@ -30,10 +30,11 @@ import client.inventory.manipulator.InventoryManipulator;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.CashShop;
|
||||
import server.ItemInformationProvider;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
@@ -49,6 +50,7 @@ import java.util.Map.Entry;
|
||||
* @author Ronan (HeavenMS)
|
||||
*/
|
||||
public final class CouponCodeHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(CouponCodeHandler.class);
|
||||
|
||||
private static List<Pair<Integer, Pair<Integer, Integer>>> getNXCodeItems(Character chr, Connection con, int codeid) throws SQLException {
|
||||
Map<Integer, Integer> couponItems = new HashMap<>();
|
||||
@@ -90,7 +92,7 @@ public final class CouponCodeHandler extends AbstractPacketHandler {
|
||||
item = 4000000;
|
||||
qty = 1;
|
||||
|
||||
FilePrinter.printError(FilePrinter.UNHANDLED_EVENT, "Error trying to redeem itemid " + item + " from codeid " + codeid + ".");
|
||||
log.warn("Error trying to redeem itemid {} from coupon codeid {}", item, codeid);
|
||||
}
|
||||
|
||||
if (!chr.canHold(item, qty)) {
|
||||
|
||||
@@ -24,13 +24,15 @@ import client.Client;
|
||||
import constants.game.GameConstants;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.life.Monster;
|
||||
import server.life.MonsterInformationProvider;
|
||||
import server.maps.MapleMap;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public class FieldDamageMobHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(FieldDamageMobHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
@@ -41,14 +43,15 @@ public class FieldDamageMobHandler extends AbstractPacketHandler {
|
||||
MapleMap map = chr.getMap();
|
||||
|
||||
if (map.getEnvironment().isEmpty()) { // no environment objects activated to actually hit the mob
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to use an obstacle on mapid " + map.getId() + " to attack.");
|
||||
log.warn("Chr {} tried to use an obstacle on mapid {} to attack", c.getPlayer().getName(), map.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
Monster mob = map.getMonsterByOid(mobOid);
|
||||
if (mob != null) {
|
||||
if (dmg < 0 || dmg > GameConstants.MAX_FIELD_MOB_DAMAGE) {
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to use an obstacle on mapid " + map.getId() + " to attack " + MonsterInformationProvider.getInstance().getMobNameFromId(mob.getId()) + " with damage " + dmg);
|
||||
log.warn("Chr {} tried to use an obstacle on mapid {} to attack {} with damage {}", c.getPlayer().getName(),
|
||||
map.getId(), MonsterInformationProvider.getInstance().getMobNameFromId(mob.getId()), dmg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,16 +25,18 @@ import client.Character;
|
||||
import client.Client;
|
||||
import client.autoban.AutobanFactory;
|
||||
import client.command.CommandsExecutor;
|
||||
import config.YamlConfig;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import tools.FilePrinter;
|
||||
import tools.LogHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ChatLogger;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public final class GeneralChatHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(GeneralChatHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
String s = p.readString();
|
||||
Character chr = c.getPlayer();
|
||||
if (chr.getAutobanManager().getLastSpam(7) + 200 > currentServerTime()) {
|
||||
@@ -43,7 +45,7 @@ public final class GeneralChatHandler extends AbstractPacketHandler {
|
||||
}
|
||||
if (s.length() > Byte.MAX_VALUE && !chr.isGM()) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit in General Chat.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to send text with length of " + s.length());
|
||||
log.warn("Chr {} tried to send text with length of {}", c.getPlayer().getName(), s.length());
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
@@ -59,14 +61,10 @@ public final class GeneralChatHandler extends AbstractPacketHandler {
|
||||
|
||||
if (!chr.isHidden()) {
|
||||
chr.getMap().broadcastMessage(PacketCreator.getChatText(chr.getId(), s, chr.getWhiteChat(), show));
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "General", s);
|
||||
}
|
||||
ChatLogger.log(c, "General", s);
|
||||
} else {
|
||||
chr.getMap().broadcastGMMessage(PacketCreator.getChatText(chr.getId(), s, chr.getWhiteChat(), show));
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "GM General", s);
|
||||
}
|
||||
ChatLogger.log(c, "GM General", s);
|
||||
}
|
||||
|
||||
chr.getAutobanManager().spam(7);
|
||||
|
||||
@@ -27,13 +27,15 @@ import client.Client;
|
||||
import client.autoban.AutobanFactory;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public final class GiveFameHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(GiveFameHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
Character target = (Character) c.getPlayer().getMap().getMapObject(p.readInt());
|
||||
int mode = p.readByte();
|
||||
int famechange = 2 * mode - 1;
|
||||
@@ -42,7 +44,7 @@ public final class GiveFameHandler extends AbstractPacketHandler {
|
||||
return;
|
||||
} else if (famechange != 1 && famechange != -1) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit fame.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to fame hack with famechange " + famechange);
|
||||
log.warn("Chr {} tried to fame hack with famechange {}", c.getPlayer().getName(), famechange);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ import constants.skills.Gunslinger;
|
||||
import constants.skills.NightWalker;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -34,6 +35,7 @@ import java.awt.*;
|
||||
* @author GabrielSin
|
||||
*/
|
||||
public class GrenadeEffectHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(GrenadeEffectHandler.class);
|
||||
|
||||
@Override
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
@@ -51,7 +53,7 @@ public class GrenadeEffectHandler extends AbstractPacketHandler {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FilePrinter.printError(FilePrinter.UNHANDLED_EVENT, "The skill id: " + skillId + " is not coded in " + this.getClass().getName() + ".");
|
||||
log.warn("The skill id: {} is not coded in {}", skillId, getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,12 +36,16 @@ import net.server.guild.GuildPackets;
|
||||
import net.server.guild.GuildResponse;
|
||||
import net.server.world.Party;
|
||||
import net.server.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class GuildOperationHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(GuildOperationHandler.class);
|
||||
|
||||
private boolean isGuildNameAcceptable(String name) {
|
||||
if (name.length() < 3 || name.length() > 12) {
|
||||
return false;
|
||||
@@ -55,7 +59,7 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
Character mc = c.getPlayer();
|
||||
byte type = p.readByte();
|
||||
int allianceId = -1;
|
||||
@@ -118,13 +122,13 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
|
||||
break;
|
||||
case 0x06:
|
||||
if (mc.getGuildId() > 0) {
|
||||
System.out.println("[Hack] " + mc.getName() + " attempted to join a guild when s/he is already in one.");
|
||||
log.warn("[Hack] Chr {} attempted to join a guild when s/he is already in one.", mc.getName());
|
||||
return;
|
||||
}
|
||||
int gid = p.readInt();
|
||||
int cid = p.readInt();
|
||||
if (cid != mc.getId()) {
|
||||
System.out.println("[Hack] " + mc.getName() + " attempted to join a guild with a different character id.");
|
||||
log.warn("[Hack] Chr {} attempted to join a guild with a different chrId", mc.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,7 +162,7 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
|
||||
cid = p.readInt();
|
||||
String name = p.readString();
|
||||
if (cid != mc.getId() || !name.equals(mc.getName()) || mc.getGuildId() <= 0) {
|
||||
System.out.println("[Hack] " + mc.getName() + " tried to quit guild under the name \"" + name + "\" and current guild id of " + mc.getGuildId() + ".");
|
||||
log.warn("[Hack] Chr {} tried to quit guild under the name {} and current guild id of {}", mc.getName(), name, mc.getGuildId());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -183,7 +187,7 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
|
||||
cid = p.readInt();
|
||||
name = p.readString();
|
||||
if (mc.getGuildRank() > 2 || mc.getGuildId() <= 0) {
|
||||
System.out.println("[Hack] " + mc.getName() + " is trying to expel without rank 1 or 2.");
|
||||
log.warn("[Hack] Chr {} is trying to expel without rank 1 or 2", mc.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -194,7 +198,7 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
|
||||
break;
|
||||
case 0x0d:
|
||||
if (mc.getGuildId() <= 0 || mc.getGuildRank() != 1) {
|
||||
System.out.println("[Hack] " + mc.getName() + " tried to change guild rank titles when s/he does not have permission.");
|
||||
log.warn("[Hack] Chr {} tried to change guild rank titles when s/he does not have permission", mc.getName());
|
||||
return;
|
||||
}
|
||||
String[] ranks = new String[5];
|
||||
@@ -208,7 +212,7 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
|
||||
cid = p.readInt();
|
||||
byte newRank = p.readByte();
|
||||
if (mc.getGuildRank() > 2 || (newRank <= 2 && mc.getGuildRank() != 1) || mc.getGuildId() <= 0) {
|
||||
System.out.println("[Hack] " + mc.getName() + " is trying to change rank outside of his/her permissions.");
|
||||
log.warn("[Hack] Chr {} is trying to change rank outside of his/her permissions.", mc.getName());
|
||||
return;
|
||||
}
|
||||
if (newRank <= 1 || newRank > 5) {
|
||||
@@ -218,7 +222,7 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
|
||||
break;
|
||||
case 0x0f:
|
||||
if (mc.getGuildId() <= 0 || mc.getGuildRank() != 1 || mc.getMapId() != MapId.GUILD_HQ) {
|
||||
System.out.println("[Hack] " + mc.getName() + " tried to change guild emblem without being the guild leader.");
|
||||
log.warn("[Hack] Chr {} tried to change guild emblem without being the guild leader", mc.getName());
|
||||
return;
|
||||
}
|
||||
if (mc.getMeso() < YamlConfig.config.server.CHANGE_EMBLEM_COST) {
|
||||
@@ -243,7 +247,7 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
|
||||
case 0x10:
|
||||
if (mc.getGuildId() <= 0 || mc.getGuildRank() > 2) {
|
||||
if (mc.getGuildId() <= 0) {
|
||||
System.out.println("[Hack] " + mc.getName() + " tried to change guild notice while not in a guild.");
|
||||
log.warn("[Hack] Chr {} tried to change guild notice while not in a guild", mc.getName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -280,7 +284,7 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
|
||||
|
||||
break;
|
||||
default:
|
||||
System.out.println("Unhandled GUILD_OPERATION packet: \n" + p);
|
||||
log.warn("Unhandled GUILD_OPERATION packet: {}", p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,9 @@ import client.Character;
|
||||
import client.Client;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.maps.MapObject;
|
||||
import tools.FilePrinter;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -35,9 +36,10 @@ import java.awt.*;
|
||||
* @author Ronan
|
||||
*/
|
||||
public final class ItemPickupHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(ItemPickupHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(final InPacket p, final Client c) {
|
||||
public void handlePacket(final InPacket p, final Client c) {
|
||||
p.readInt(); //Timestamp
|
||||
p.readByte();
|
||||
p.readPos(); //cpos
|
||||
@@ -51,7 +53,8 @@ public final class ItemPickupHandler extends AbstractPacketHandler {
|
||||
Point charPos = chr.getPosition();
|
||||
Point obPos = ob.getPosition();
|
||||
if (Math.abs(charPos.getX() - obPos.getX()) > 800 || Math.abs(charPos.getY() - obPos.getY()) > 600) {
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to pick up an item too far away. Mapid: " + chr.getMapId() + " Player pos: " + charPos + " Object pos: " + obPos);
|
||||
log.warn("Chr {} tried to pick up an item too far away. Mapid: {}, player pos: {}, object pos: {}",
|
||||
c.getPlayer().getName(), chr.getMapId(), charPos, obPos);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ import net.packet.InPacket;
|
||||
import net.packet.Packet;
|
||||
import net.server.Server;
|
||||
import net.server.channel.Channel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.MTSItemInfo;
|
||||
import tools.DatabaseConnection;
|
||||
@@ -48,9 +50,10 @@ import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public final class MTSHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(MTSHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
// TODO add karma-to-untradeable flag on sold items here
|
||||
|
||||
if (!c.getPlayer().getCashShop().isOpened()) {
|
||||
@@ -354,8 +357,7 @@ public final class MTSHandler extends AbstractPacketHandler {
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("MTS Transfer error: " + e);
|
||||
log.error("MTS Transfer error", e);
|
||||
}
|
||||
} else if (op == 9) { //add to cart
|
||||
int id = p.readInt(); //id of the item
|
||||
@@ -537,7 +539,7 @@ public final class MTSHandler extends AbstractPacketHandler {
|
||||
c.sendPacket(PacketCreator.MTSFailBuy());
|
||||
}
|
||||
} else {
|
||||
System.out.println("Unhandled OP(MTS): " + op + " Packet: " + p);
|
||||
log.warn("Unhandled OP (MTS): {}, packet: {}", op, p);
|
||||
}
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.showMTSCash(c.getPlayer()));
|
||||
|
||||
@@ -28,10 +28,11 @@ import client.status.MonsterStatus;
|
||||
import client.status.MonsterStatusEffect;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.life.Monster;
|
||||
import server.life.MonsterInformationProvider;
|
||||
import server.maps.MapleMap;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -41,8 +42,10 @@ import java.util.Map;
|
||||
* @author Ronan
|
||||
*/
|
||||
public final class MobDamageMobHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(MobDamageMobHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
int from = p.readInt();
|
||||
p.readInt();
|
||||
int to = p.readInt();
|
||||
@@ -59,8 +62,10 @@ public final class MobDamageMobHandler extends AbstractPacketHandler {
|
||||
|
||||
if (dmg > maxDmg) {
|
||||
AutobanFactory.DAMAGE_HACK.alert(c.getPlayer(), "Possible packet editing hypnotize damage exploit."); // thanks Rien dev team
|
||||
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " had hypnotized " + MonsterInformationProvider.getInstance().getMobNameFromId(attacker.getId()) + " to attack " + MonsterInformationProvider.getInstance().getMobNameFromId(damaged.getId()) + " with damage " + dmg + " (max: " + maxDmg + ")");
|
||||
String attackerName = MonsterInformationProvider.getInstance().getMobNameFromId(attacker.getId());
|
||||
String damagedName = MonsterInformationProvider.getInstance().getMobNameFromId(damaged.getId());
|
||||
log.warn("Chr {} had hypnotized {} to attack {} with damage {} (max: {})", c.getPlayer().getName(),
|
||||
attackerName, damagedName, dmg, maxDmg);
|
||||
dmg = maxDmg;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ import client.Character;
|
||||
import client.Client;
|
||||
import config.YamlConfig;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.life.MobSkill;
|
||||
import server.life.MobSkillFactory;
|
||||
import server.life.Monster;
|
||||
@@ -47,9 +49,10 @@ import java.util.List;
|
||||
* @author Ronan (HeavenMS)
|
||||
*/
|
||||
public final class MoveLifeHandler extends AbstractMovementPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(MoveLifeHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
Character player = c.getPlayer();
|
||||
MapleMap map = player.getMap();
|
||||
|
||||
@@ -165,7 +168,9 @@ public final class MoveLifeHandler extends AbstractMovementPacketHandler {
|
||||
p.seek(movementDataStart);
|
||||
|
||||
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);
|
||||
log.debug("{} castPos: {}, rawAct: {}, opt: {}, skillId: {}, skillLv: {}, allowSkill: {}, mobMp: {}",
|
||||
isSkill ? "SKILL" : (isAttack ? "ATTCK" : ""), castPos, rawActivity, pOption, useSkillId,
|
||||
useSkillLevel, nextMovementCouldBeSkill, mobMp);
|
||||
}
|
||||
|
||||
map.broadcastMessage(player, PacketCreator.moveMonster(objectid, nextMovementCouldBeSkill, rawActivity, useSkillId, useSkillLevel, pOption, startPos, p, movementDataLength), serverStartPos);
|
||||
|
||||
@@ -24,18 +24,20 @@ package net.server.channel.handlers;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.autoban.AutobanFactory;
|
||||
import config.YamlConfig;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import net.server.Server;
|
||||
import net.server.world.World;
|
||||
import tools.FilePrinter;
|
||||
import tools.LogHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ChatLogger;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public final class MultiChatHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(MultiChatHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
Character player = c.getPlayer();
|
||||
if (player.getAutobanManager().getLastSpam(7) + 200 > currentServerTime()) {
|
||||
return;
|
||||
@@ -50,33 +52,25 @@ public final class MultiChatHandler extends AbstractPacketHandler {
|
||||
String chattext = p.readString();
|
||||
if (chattext.length() > Byte.MAX_VALUE && !player.isGM()) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit chats.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to send text with length of " + chattext.length());
|
||||
log.warn("Chr {} tried to send text with length of {}", c.getPlayer().getName(), chattext.length());
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
World world = c.getWorldServer();
|
||||
if (type == 0) {
|
||||
world.buddyChat(recipients, player.getId(), player.getName(), chattext);
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "Buddy", chattext);
|
||||
}
|
||||
ChatLogger.log(c, "Buddy", chattext);
|
||||
} else if (type == 1 && player.getParty() != null) {
|
||||
world.partyChat(player.getParty(), chattext, player.getName());
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "Party", chattext);
|
||||
}
|
||||
ChatLogger.log(c, "Party", chattext);
|
||||
} else if (type == 2 && player.getGuildId() > 0) {
|
||||
Server.getInstance().guildChat(player.getGuildId(), player.getName(), player.getId(), chattext);
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "Guild", chattext);
|
||||
}
|
||||
ChatLogger.log(c, "Guild", chattext);
|
||||
} else if (type == 3 && player.getGuild() != null) {
|
||||
int allianceId = player.getGuild().getAllianceId();
|
||||
if (allianceId > 0) {
|
||||
Server.getInstance().allianceMessage(allianceId, PacketCreator.multiChat(player.getName(), chattext, 3), player.getId(), -1);
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "Ally", chattext);
|
||||
}
|
||||
ChatLogger.log(c, "Ally", chattext);
|
||||
}
|
||||
}
|
||||
player.getAutobanManager().spam(7);
|
||||
|
||||
@@ -26,13 +26,17 @@ import client.autoban.AutobanFactory;
|
||||
import constants.inventory.ItemConstants;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Matze
|
||||
*/
|
||||
public final class NPCShopHandler extends AbstractPacketHandler {
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
private static final Logger log = LoggerFactory.getLogger(NPCShopHandler.class);
|
||||
|
||||
@Override
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
byte bmode = p.readByte();
|
||||
if (bmode == 0) { // mode 0 = buy :)
|
||||
short slot = p.readShort();// slot
|
||||
@@ -40,7 +44,7 @@ public final class NPCShopHandler extends AbstractPacketHandler {
|
||||
short quantity = p.readShort();
|
||||
if (quantity < 1) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit a npc shop.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to buy quantity " + quantity + " of item id " + itemId);
|
||||
log.warn("Chr {} tried to buy quantity {} of itemid {}", c.getPlayer().getName(), quantity, itemId);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,16 +27,19 @@ import config.YamlConfig;
|
||||
import constants.id.NpcId;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.npc.NPCScriptManager;
|
||||
import server.life.NPC;
|
||||
import server.life.PlayerNPC;
|
||||
import server.maps.MapObject;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public final class NPCTalkHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(NPCTalkHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
if (!c.getPlayer().isAlive()) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
@@ -73,7 +76,7 @@ public final class NPCTalkHandler extends AbstractPacketHandler {
|
||||
boolean hasNpcScript = NPCScriptManager.getInstance().start(c, npc.getId(), oid, null);
|
||||
if (!hasNpcScript) {
|
||||
if (!npc.hasShop()) {
|
||||
FilePrinter.printError(FilePrinter.NPC_UNCODED, "NPC " + npc.getName() + "(" + npc.getId() + ") is not coded.");
|
||||
log.warn("NPC {} ({}) is not coded", npc.getName(), npc.getId());
|
||||
return;
|
||||
} else if (c.getPlayer().getShop() != null) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
|
||||
@@ -23,17 +23,18 @@ package net.server.channel.handlers;
|
||||
|
||||
import client.Client;
|
||||
import client.autoban.AutobanFactory;
|
||||
import config.YamlConfig;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import tools.FilePrinter;
|
||||
import tools.LogHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ChatLogger;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public final class PetChatHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(PetChatHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
int petId = p.readInt();
|
||||
p.readInt();
|
||||
p.readByte();
|
||||
@@ -45,13 +46,11 @@ public final class PetChatHandler extends AbstractPacketHandler {
|
||||
String text = p.readString();
|
||||
if (text.length() > Byte.MAX_VALUE) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with pets.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to send text with length of " + text.length());
|
||||
log.warn("Chr {} tried to send text with length of {}", c.getPlayer().getName(), text.length());
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), PacketCreator.petChat(c.getPlayer().getId(), pet, act, text), true);
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "Pet", text);
|
||||
}
|
||||
ChatLogger.log(c, "Pet", text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,12 @@ import constants.id.ItemId;
|
||||
import constants.inventory.ItemConstants;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.Trade;
|
||||
import server.maps.*;
|
||||
import server.maps.MiniGame.MiniGameType;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -51,6 +52,8 @@ import java.util.Arrays;
|
||||
* @author Ronan - concurrency safety and reviewed minigames
|
||||
*/
|
||||
public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(PlayerInteractionHandler.class);
|
||||
|
||||
public enum Action {
|
||||
CREATE(0),
|
||||
INVITE(2),
|
||||
@@ -484,7 +487,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
||||
byte targetSlot = p.readByte();
|
||||
|
||||
if (targetSlot < 1 || targetSlot > 9) {
|
||||
System.out.println("[Hack] " + chr.getName() + " Trying to dupe on trade slot.");
|
||||
log.warn("[Hack] Chr {} Trying to dupe on trade slot.", chr.getName());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
@@ -550,7 +553,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FilePrinter.printError(FilePrinter.TRADE_EXCEPTION, e, "Player '" + chr + "' tried to add " + ii.getName(item.getItemId()) + " qty. " + item.getQuantity() + " in trade (slot " + targetSlot + ") then exception occurred.");
|
||||
log.warn("Chr {} tried to add {}x {} in trade (slot {}), then exception occurred", chr, ii.getName(item.getItemId()), item.getQuantity(), targetSlot, e);
|
||||
} finally {
|
||||
inv.unlockInventory();
|
||||
}
|
||||
@@ -597,7 +600,8 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
||||
int price = p.readInt();
|
||||
if (perBundle <= 0 || perBundle * bundles > 2000 || bundles <= 0 || price <= 0 || price > Integer.MAX_VALUE) {
|
||||
AutobanFactory.PACKET_EDIT.alert(chr, chr.getName() + " tried to packet edit with hired merchants.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + chr.getName() + ".txt", chr.getName() + " might of possibly packet edited Hired Merchants\nperBundle: " + perBundle + "\nperBundle * bundles (This multiplied cannot be greater than 2000): " + perBundle * bundles + "\nbundles: " + bundles + "\nprice: " + price);
|
||||
log.warn("Chr {} might possibly have packet edited Hired Merchants. perBundle: {}, perBundle * bundles (This multiplied cannot be greater than 2000): {}, bundles: {}, price: {}",
|
||||
chr.getName(), perBundle, perBundle * bundles, bundles, price);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -668,7 +672,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
||||
int slot = p.readShort();
|
||||
if (slot >= shop.getItems().size() || slot < 0) {
|
||||
AutobanFactory.PACKET_EDIT.alert(chr, chr.getName() + " tried to packet edit with a player shop.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + chr.getName() + ".txt", chr.getName() + " tried to remove item at slot " + slot);
|
||||
log.warn("Chr {} tried to remove item at slot {}", chr.getName(), slot);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
@@ -734,7 +738,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
||||
short quantity = p.readShort();
|
||||
if (quantity < 1) {
|
||||
AutobanFactory.PACKET_EDIT.alert(chr, chr.getName() + " tried to packet edit with a hired merchant and or player shop.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + chr.getName() + ".txt", chr.getName() + " tried to buy item " + itemid + " with quantity " + quantity);
|
||||
log.warn("Chr {} tried to buy item {} with quantity {}", chr.getName(), itemid, quantity);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
@@ -763,7 +767,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
||||
int slot = p.readShort();
|
||||
if (slot >= merchant.getItems().size() || slot < 0) {
|
||||
AutobanFactory.PACKET_EDIT.alert(chr, chr.getName() + " tried to packet edit with a hired merchant.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + chr.getName() + ".txt", chr.getName() + " tried to remove item at slot " + slot);
|
||||
log.warn("Chr {} tried to remove item at slot {}", chr.getName(), slot);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,10 +42,11 @@ import net.server.guild.GuildPackets;
|
||||
import net.server.world.PartyCharacter;
|
||||
import net.server.world.PartyOperation;
|
||||
import net.server.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import server.life.MobSkill;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
import tools.packets.WeddingPackets;
|
||||
@@ -59,7 +60,7 @@ import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class PlayerLoggedinHandler extends AbstractPacketHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PlayerLoggedinHandler.class);
|
||||
private static final Set<Integer> attemptingLoginAccounts = new HashSet<>();
|
||||
|
||||
private boolean tryAcquireAccount(int accId) {
|
||||
@@ -257,10 +258,10 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler {
|
||||
c.sendPacket(PacketCreator.getFamilyInfo(familyEntry));
|
||||
familyEntry.announceToSenior(PacketCreator.sendFamilyLoginNotice(player.getName(), true), true);
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, "Player " + player.getName() + "'s family doesn't have an entry for them. (" + f.getID() + ")");
|
||||
log.error("Chr {}'s family doesn't have an entry for them. (familyId {})", player.getName(), f.getID());
|
||||
}
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, "Player " + player.getName() + " has an invalid family ID. (" + player.getFamilyId() + ")");
|
||||
log.error("Chr {} has an invalid family ID ({})", player.getName(), player.getFamilyId());
|
||||
c.sendPacket(PacketCreator.getFamilyInfo(null));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -35,6 +35,8 @@ import constants.inventory.ItemConstants;
|
||||
import constants.skills.*;
|
||||
import net.packet.InPacket;
|
||||
import net.packet.Packet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.StatEffect;
|
||||
import tools.PacketCreator;
|
||||
@@ -44,9 +46,10 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
|
||||
public final class RangedAttackHandler extends AbstractDealDamageHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(RangedAttackHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
Character chr = c.getPlayer();
|
||||
|
||||
/*long timeElapsed = currentServerTime() - chr.getAutobanManager().getLastSpam(8);
|
||||
@@ -171,7 +174,7 @@ public final class RangedAttackHandler extends AbstractDealDamageHandler {
|
||||
}
|
||||
|
||||
if (slot < 0) {
|
||||
System.out.println("<ERROR> Projectile to use was unable to be found.");
|
||||
log.warn("<ERROR> Projectile to use was unable to be found.");
|
||||
} else {
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.USE, slot, bulletConsume, false, true);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import net.server.channel.Channel;
|
||||
import net.server.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import server.ItemInformationProvider;
|
||||
import tools.DatabaseConnection;
|
||||
@@ -52,6 +54,7 @@ import java.sql.SQLException;
|
||||
* @author Drago (Dragohe4rt) - on Wishlist
|
||||
*/
|
||||
public final class RingActionHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(RingActionHandler.class);
|
||||
|
||||
private static int getEngagementBoxId(int useItemId) {
|
||||
return switch (useItemId) {
|
||||
@@ -175,7 +178,7 @@ public final class RingActionHandler extends AbstractPacketHandler {
|
||||
|
||||
eraseEngagementOffline(characterId, con);
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error updating offline breakup " + ex.getMessage());
|
||||
log.error("Error updating offline breakup", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +364,7 @@ public final class RingActionHandler extends AbstractPacketHandler {
|
||||
source.sendPacket(WeddingPackets.OnNotifyWeddingPartnerTransfer(target.getId(), target.getMapId()));
|
||||
target.sendPacket(WeddingPackets.OnNotifyWeddingPartnerTransfer(source.getId(), source.getMapId()));
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error with engagement " + e.getMessage());
|
||||
log.error("Error with engagement", e);
|
||||
}
|
||||
} else {
|
||||
source.dropMessage(1, "She has politely declined your engagement request.");
|
||||
@@ -509,7 +512,7 @@ public final class RingActionHandler extends AbstractPacketHandler {
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.println("Unhandled RING_ACTION Mode: " + p);
|
||||
log.warn("Unhandled RING_ACTION mode. Packet: {}", p);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,15 @@ import client.Client;
|
||||
import constants.skills.*;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public final class SkillEffectHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(SkillEffectHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
int skillId = p.readInt();
|
||||
int level = p.readByte();
|
||||
byte flags = p.readByte();
|
||||
@@ -57,7 +61,7 @@ public final class SkillEffectHandler extends AbstractPacketHandler {
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), PacketCreator.skillEffect(c.getPlayer(), skillId, level, flags, speed, aids), false);
|
||||
return;
|
||||
default:
|
||||
System.out.println(c.getPlayer() + " entered SkillEffectHandler without being handled using " + skillId + ".");
|
||||
log.warn("Chr {} entered SkillEffectHandler without being handled using {}", c.getPlayer(), skillId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,9 @@ package net.server.channel.handlers;
|
||||
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import config.YamlConfig;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import tools.LogHelper;
|
||||
import server.ChatLogger;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public final class SpouseChatHandler extends AbstractPacketHandler {
|
||||
@@ -41,9 +40,7 @@ public final class SpouseChatHandler extends AbstractPacketHandler {
|
||||
if (spouse != null) {
|
||||
spouse.sendPacket(PacketCreator.OnCoupleMessage(c.getPlayer().getName(), msg, true));
|
||||
c.sendPacket(PacketCreator.OnCoupleMessage(c.getPlayer().getName(), msg, true));
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(c, "Spouse", msg);
|
||||
}
|
||||
ChatLogger.log(c, "Spouse", msg);
|
||||
} else {
|
||||
c.getPlayer().dropMessage(5, "Your spouse is currently offline.");
|
||||
}
|
||||
|
||||
@@ -32,18 +32,20 @@ import client.inventory.WeaponType;
|
||||
import client.status.MonsterStatusEffect;
|
||||
import constants.skills.Outlaw;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.StatEffect;
|
||||
import server.life.Monster;
|
||||
import server.life.MonsterInformationProvider;
|
||||
import server.maps.Summon;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class SummonDamageHandler extends AbstractDealDamageHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(SummonDamageHandler.class);
|
||||
|
||||
public final class SummonAttackEntry {
|
||||
|
||||
@@ -108,8 +110,9 @@ public final class SummonDamageHandler extends AbstractDealDamageHandler {
|
||||
if (target != null) {
|
||||
if (damage > maxDmg) {
|
||||
AutobanFactory.DAMAGE_HACK.alert(c.getPlayer(), "Possible packet editing summon damage exploit.");
|
||||
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " used a summon of skillid " + summon.getSkill() + " to attack " + MonsterInformationProvider.getInstance().getMobNameFromId(target.getId()) + " with damage " + damage + " (max: " + maxDmg + ")");
|
||||
final String mobName = MonsterInformationProvider.getInstance().getMobNameFromId(target.getId());
|
||||
log.info("Possible exploit - chr {} used a summon of skillId {} to attack {} with damage {} (max: {})",
|
||||
c.getPlayer().getName(), summon.getSkill(), mobName, damage, maxDmg);
|
||||
damage = maxDmg;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,12 +35,13 @@ import constants.inventory.ItemConstants;
|
||||
import constants.skills.Aran;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.StatEffect;
|
||||
import server.life.LifeFactory.loseItem;
|
||||
import server.life.*;
|
||||
import server.maps.MapObject;
|
||||
import server.maps.MapleMap;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Randomizer;
|
||||
|
||||
@@ -50,9 +51,10 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class TakeDamageHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(TakeDamageHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
List<Character> banishPlayers = new ArrayList<>();
|
||||
|
||||
Character chr = c.getPlayer();
|
||||
@@ -135,10 +137,7 @@ public final class TakeDamageHandler extends AbstractPacketHandler {
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
//this happens due to mob on last map damaging player just before changing maps
|
||||
|
||||
e.printStackTrace();
|
||||
FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, "Attacker is not a mob-type, rather is a " + map.getMapObject(oid).getClass().getName() + " entity.");
|
||||
|
||||
log.warn("Attack is not a mob-type, rather is a {} entity", map.getMapObject(oid).getClass().getSimpleName(), e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ import constants.inventory.ItemConstants;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import server.Shop;
|
||||
import server.ShopFactory;
|
||||
@@ -56,9 +58,10 @@ import static java.util.concurrent.TimeUnit.DAYS;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public final class UseCashItemHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(UseCashItemHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
final Character player = c.getPlayer();
|
||||
|
||||
long timeNow = currentServerTime();
|
||||
@@ -601,7 +604,7 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
|
||||
client.sendPacket(PacketCreator.enableActions());
|
||||
}, SECONDS.toMillis(3));
|
||||
} else {
|
||||
System.out.println("NEW CASH ITEM: " + itemType + "\n" + p);
|
||||
log.warn("NEW CASH ITEM TYPE: {}, packet: {}", itemType, p);
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import config.YamlConfig;
|
||||
import constants.inventory.ItemConstants;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.Marriage;
|
||||
import tools.PacketCreator;
|
||||
import tools.packets.WeddingPackets;
|
||||
@@ -29,9 +31,10 @@ import java.util.List;
|
||||
* @author Drago (Dragohe4rt)
|
||||
*/
|
||||
public final class WeddingHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(WeddingHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
@@ -151,7 +154,7 @@ public final class WeddingHandler extends AbstractPacketHandler {
|
||||
} else if (mode == 8) { // out of Wedding Registry
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
} else {
|
||||
System.out.println(mode);
|
||||
log.warn("Unhandled wedding mode: {}", mode);
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
|
||||
@@ -24,11 +24,11 @@ package net.server.channel.handlers;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.autoban.AutobanFactory;
|
||||
import config.YamlConfig;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import tools.FilePrinter;
|
||||
import tools.LogHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ChatLogger;
|
||||
import tools.PacketCreator;
|
||||
import tools.PacketCreator.WhisperFlag;
|
||||
|
||||
@@ -36,6 +36,7 @@ import tools.PacketCreator.WhisperFlag;
|
||||
* @author Chronos
|
||||
*/
|
||||
public final class WhisperHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(WhisperHandler.class);
|
||||
|
||||
// result types, not sure if there are proper names for these
|
||||
public static final byte RT_ITC = 0x00;
|
||||
@@ -66,7 +67,7 @@ public final class WhisperHandler extends AbstractPacketHandler {
|
||||
handleFind(c.getPlayer(), target, WhisperFlag.LOCATION_FRIEND);
|
||||
break;
|
||||
default:
|
||||
FilePrinter.printError(FilePrinter.PACKET_HANDLER + c.getPlayer().getName() + ".txt", "Unknown request " + request + " triggered by " + c.getPlayer().getName());
|
||||
log.warn("Unknown request {} triggered by {}", request, c.getPlayer().getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -94,14 +95,12 @@ public final class WhisperHandler extends AbstractPacketHandler {
|
||||
|
||||
if (message.length() > Byte.MAX_VALUE) {
|
||||
AutobanFactory.PACKET_EDIT.alert(user, user.getName() + " tried to packet edit with whispers.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + user.getName() + ".txt", user.getName() + " tried to send text with length of " + message.length());
|
||||
log.warn("Chr {} tried to send text with length of {}", user.getName(), message.length());
|
||||
user.getClient().disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
LogHelper.logChat(user.getClient(), "Whisper To " + target.getName(), message);
|
||||
}
|
||||
ChatLogger.log(user.getClient(), "Whisper To " + target.getName(), message);
|
||||
|
||||
target.sendPacket(PacketCreator.getWhisperReceive(user.getName(), user.getClient().getChannel() - 1, user.isGM(), message));
|
||||
|
||||
|
||||
@@ -344,27 +344,26 @@ public class SessionCoordinator {
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.joining(", "));
|
||||
|
||||
System.out.println("Current online clients: " + commaSeparatedClients);
|
||||
log.debug("Current online clients: {}", commaSeparatedClients);
|
||||
}
|
||||
|
||||
if (!onlineRemoteHwids.isEmpty()) {
|
||||
List<Hwid> hwids = new ArrayList<>(onlineRemoteHwids);
|
||||
hwids.sort(Comparator.comparing(Hwid::hwid));
|
||||
|
||||
System.out.println("Current online HWIDs: ");
|
||||
for (Hwid s : hwids) {
|
||||
System.out.println(" " + s);
|
||||
}
|
||||
log.debug("Current online HWIDs: {}", hwids.stream()
|
||||
.map(Hwid::hwid)
|
||||
.collect(Collectors.joining(" ")));
|
||||
}
|
||||
|
||||
if (!loginRemoteHosts.isEmpty()) {
|
||||
List<Entry<String, Client>> elist = new ArrayList<>(loginRemoteHosts.entrySet());
|
||||
elist.sort(Entry.comparingByKey());
|
||||
|
||||
System.out.println("Current login sessions: ");
|
||||
for (Entry<String, Client> e : elist) {
|
||||
System.out.println(" " + e.getKey() + ", client: " + e.getValue());
|
||||
}
|
||||
log.debug("Current login sessions: {}", loginRemoteHosts.entrySet().stream()
|
||||
.sorted(Entry.comparingByKey())
|
||||
.map(entry -> "(" + entry.getKey() + ", client: " + entry.getValue())
|
||||
.collect(Collectors.joining(", ")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ import net.server.coordinator.matchchecker.MatchCheckerCoordinator;
|
||||
import net.server.coordinator.world.InviteCoordinator;
|
||||
import net.server.coordinator.world.InviteCoordinator.InviteResult;
|
||||
import net.server.coordinator.world.InviteCoordinator.InviteType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.PacketCreator;
|
||||
|
||||
@@ -45,6 +47,7 @@ import java.util.*;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
public class Guild {
|
||||
private static final Logger log = LoggerFactory.getLogger(Guild.class);
|
||||
|
||||
private enum BCOp {
|
||||
NONE, DISBAND, EMBLEMCHANGE
|
||||
@@ -102,8 +105,7 @@ public class Guild {
|
||||
}
|
||||
}
|
||||
} catch (SQLException se) {
|
||||
se.printStackTrace();
|
||||
System.out.println("Unable to read guild information from sql: " + se);
|
||||
log.error("Unable to read guild information from sql", se);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,8 +342,7 @@ public class Guild {
|
||||
}
|
||||
}
|
||||
} catch (Exception re) {
|
||||
re.printStackTrace();
|
||||
System.out.println("Failed to contact channel(s) for broadcast.");//fu?
|
||||
log.error("Failed to contact channel(s) for broadcast.", re);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@@ -520,8 +521,7 @@ public class Guild {
|
||||
ps.setLong(4, System.currentTimeMillis());
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("expelMember - Guild " + e);
|
||||
log.error("expelMember - Guild", e);
|
||||
}
|
||||
Server.getInstance().getWorld(mgc.getWorld()).setOfflineGuildStatus((short) 0, (byte) 5, cid);
|
||||
}
|
||||
@@ -532,7 +532,7 @@ public class Guild {
|
||||
return;
|
||||
}
|
||||
}
|
||||
System.out.println("Unable to find member with name " + name + " and id " + cid);
|
||||
log.warn("Unable to find member with name {} and id {}", name, cid);
|
||||
} finally {
|
||||
membersLock.unlock();
|
||||
}
|
||||
@@ -768,8 +768,7 @@ public class Guild {
|
||||
ResultSet rs = ps.executeQuery()) {
|
||||
c.sendPacket(GuildPackets.showGuildRanks(npcid, rs));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("failed to display guild ranks. " + e);
|
||||
log.error("Failed to display guild ranks.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ import client.creator.novice.NoblesseCreator;
|
||||
import constants.id.ItemId;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -36,6 +37,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class CreateCharHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(CreateCharHandler.class);
|
||||
|
||||
private final static Set<Integer> IDs = new HashSet<>(Arrays.asList(
|
||||
ItemId.SWORD, ItemId.HAND_AXE, ItemId.WOODEN_CLUB, ItemId.BASIC_POLEARM,// weapons
|
||||
@@ -77,7 +79,7 @@ public final class CreateCharHandler extends AbstractPacketHandler {
|
||||
int[] items = new int[]{weapon, top, bottom, shoes, hair, face};
|
||||
for (int item : items) {
|
||||
if (!isLegal(item)) {
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + name + ".txt", "Owner from account '" + c.getAccountName() + "' tried to packet edit in char creation.");
|
||||
log.warn("Owner from account {} tried to packet edit in chr creation", c.getAccountName());
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@ import client.Family;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -36,9 +37,10 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public final class DeleteCharHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(DeleteCharHandler.class);
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
String pic = p.readString();
|
||||
int cid = p.readInt();
|
||||
if (c.checkPic(pic)) {
|
||||
@@ -77,12 +79,12 @@ public final class DeleteCharHandler extends AbstractPacketHandler {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
log.error("Failed to delete chrId {}", cid, e);
|
||||
c.sendPacket(PacketCreator.deleteCharResponse(cid, 0x09));
|
||||
return;
|
||||
}
|
||||
if (c.deleteCharacter(cid, c.getAccID())) {
|
||||
FilePrinter.print(FilePrinter.DELETED_CHAR + c.getAccountName() + ".txt", c.getAccountName() + " deleted CID: " + cid);
|
||||
log.info("Account {} deleted chrId {}", c.getAccountName(), cid);
|
||||
c.sendPacket(PacketCreator.deleteCharResponse(cid, 0));
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.deleteCharResponse(cid, 0x09));
|
||||
|
||||
@@ -2,8 +2,9 @@ package net.server.task;
|
||||
|
||||
import client.Family;
|
||||
import net.server.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -11,7 +12,7 @@ import java.sql.SQLException;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class FamilyDailyResetTask implements Runnable {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FamilyDailyResetTask.class);
|
||||
private final World world;
|
||||
|
||||
public FamilyDailyResetTask(World world) {
|
||||
@@ -38,19 +39,16 @@ public class FamilyDailyResetTask implements Runnable {
|
||||
ps.setLong(1, resetTime.getTimeInMillis());
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not reset daily rep for families. On " + Calendar.getInstance().getTime());
|
||||
e.printStackTrace();
|
||||
log.error("Could not reset daily rep for families", e);
|
||||
}
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM family_entitlement WHERE timestamp <= ?")) {
|
||||
ps.setLong(1, resetTime.getTimeInMillis());
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not do daily reset for family entitlements. On " + Calendar.getInstance().getTime());
|
||||
e.printStackTrace();
|
||||
log.error("Could not do daily reset for family entitlements", e);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get connection to DB.");
|
||||
e.printStackTrace();
|
||||
log.error("Could not get connection to DB", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@ package net.server.task;
|
||||
import client.Character;
|
||||
import config.YamlConfig;
|
||||
import net.server.world.World;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -11,13 +12,15 @@ import java.util.Collection;
|
||||
* @author Shavit
|
||||
*/
|
||||
public class TimeoutTask extends BaseTask implements Runnable {
|
||||
private static final Logger log = LoggerFactory.getLogger(TimeoutTask.class);
|
||||
|
||||
@Override
|
||||
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) {
|
||||
FilePrinter.print(FilePrinter.DCS + chr.getClient().getAccountName(), chr.getName() + " auto-disconnected due to inactivity.");
|
||||
log.info("Chr {} auto-disconnected due to inactivity", chr.getName());
|
||||
chr.getClient().disconnect(true, chr.getCashShop().isOpened());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ import net.server.services.BaseService;
|
||||
import net.server.services.ServicesManager;
|
||||
import net.server.services.type.WorldServices;
|
||||
import net.server.task.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import server.Storage;
|
||||
import server.TimerManager;
|
||||
@@ -75,6 +77,7 @@ import static java.util.concurrent.TimeUnit.*;
|
||||
* @author Ronan - thread-oriented (world schedules + guild queue + marriages + party chars)
|
||||
*/
|
||||
public class World {
|
||||
private static final Logger log = LoggerFactory.getLogger(World.class);
|
||||
|
||||
private final int id;
|
||||
private int flag;
|
||||
@@ -834,8 +837,8 @@ public class World {
|
||||
}
|
||||
|
||||
public void debugMarriageStatus() {
|
||||
System.out.println("Queued marriages: " + queuedMarriages);
|
||||
System.out.println("Guest list: " + marriageGuests);
|
||||
log.debug("Queued marriages: {}", queuedMarriages);
|
||||
log.debug("Guest list: {}", marriageGuests);
|
||||
}
|
||||
|
||||
private void registerCharacterParty(Integer chrid, Integer partyid) {
|
||||
@@ -1004,7 +1007,7 @@ public class World {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("Unhandled updateParty operation " + operation.name());
|
||||
log.warn("Unhandled updateParty operation: {}", operation.name());
|
||||
}
|
||||
updateParty(party, operation, target);
|
||||
}
|
||||
@@ -2151,6 +2154,6 @@ public class World {
|
||||
players = null;
|
||||
|
||||
clearWorldData();
|
||||
System.out.println("Finished shutting down world " + id + "\r\n");
|
||||
log.info("Finished shutting down world {}", id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ package scripting;
|
||||
import client.Client;
|
||||
import com.oracle.truffle.js.scriptengine.GraalJSScriptEngine;
|
||||
import constants.string.CharsetConstants;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.script.*;
|
||||
import java.io.File;
|
||||
@@ -35,6 +36,7 @@ import java.io.IOException;
|
||||
* @author Matze
|
||||
*/
|
||||
public abstract class AbstractScriptManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractScriptManager.class);
|
||||
private final ScriptEngineFactory sef;
|
||||
|
||||
protected AbstractScriptManager() {
|
||||
@@ -58,7 +60,7 @@ public abstract class AbstractScriptManager {
|
||||
try (FileReader fr = new FileReader(scriptFile, CharsetConstants.CHARSET)) {
|
||||
engine.eval(fr);
|
||||
} catch (final ScriptException | IOException t) {
|
||||
FilePrinter.printError(FilePrinter.INVOCABLE + path.substring(12), t, path);
|
||||
log.warn("Exception during script eval for file: {}", path, t);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ import net.server.audit.locks.factory.MonitoredWriteLockFactory;
|
||||
import net.server.coordinator.world.EventRecallCoordinator;
|
||||
import net.server.world.Party;
|
||||
import net.server.world.PartyCharacter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
import scripting.event.scheduler.EventScriptScheduler;
|
||||
import server.ItemInformationProvider;
|
||||
@@ -56,8 +58,6 @@ import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
@@ -66,6 +66,7 @@ import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class EventInstanceManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(EventInstanceManager.class);
|
||||
private final Map<Integer, Character> chars = new HashMap<>();
|
||||
private int leaderId = -1;
|
||||
private final List<Monster> mobs = new LinkedList<>();
|
||||
@@ -298,7 +299,7 @@ public class EventInstanceManager {
|
||||
try {
|
||||
invokeScriptFunction("scheduledTimeout", EventInstanceManager.this);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, "Event '" + em.getName() + "' does not implement scheduledTimeout function.", ex);
|
||||
log.error("Event script {} does not implement the scheduledTimeout function", em.getName(), ex);
|
||||
}
|
||||
}, time);
|
||||
}
|
||||
@@ -315,7 +316,7 @@ public class EventInstanceManager {
|
||||
try {
|
||||
invokeScriptFunction("scheduledTimeout", EventInstanceManager.this);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, "Event '" + em.getName() + "' does not implement scheduledTimeout function.", ex);
|
||||
log.error("Event script {} does not implement the scheduledTimeout function", em.getName(), ex);
|
||||
}
|
||||
}, nextTime);
|
||||
}
|
||||
@@ -387,7 +388,7 @@ public class EventInstanceManager {
|
||||
try {
|
||||
invokeScriptFunction("playerUnregistered", EventInstanceManager.this, chr);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, "Event '" + em.getName() + "' does not implement playerUnregistered function.", ex);
|
||||
log.error("Event script {} does not implement the playerUnregistered function", em.getName(), ex);
|
||||
}
|
||||
|
||||
wL.lock();
|
||||
|
||||
@@ -34,6 +34,8 @@ import net.server.guild.Guild;
|
||||
import net.server.world.Party;
|
||||
import net.server.world.PartyCharacter;
|
||||
import net.server.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.event.scheduler.EventScriptScheduler;
|
||||
import server.Marriage;
|
||||
import server.ThreadManager;
|
||||
@@ -48,8 +50,6 @@ import javax.script.Invocable;
|
||||
import javax.script.ScriptException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
@@ -60,6 +60,7 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class EventManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(EventManager.class);
|
||||
private Invocable iv;
|
||||
private Channel cserv;
|
||||
private World wserv;
|
||||
@@ -183,7 +184,7 @@ public class EventManager {
|
||||
try {
|
||||
iv.invokeFunction(methodName, eim);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
log.error("Event script schedule", ex);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -198,7 +199,7 @@ public class EventManager {
|
||||
try {
|
||||
iv.invokeFunction(methodName, (Object) null);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
log.error("Event script scheduleAtTimestamp", ex);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -432,7 +433,7 @@ public class EventManager {
|
||||
|
||||
eim.startEvent();
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
log.error("Event script startInstance", ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -504,7 +505,7 @@ public class EventManager {
|
||||
|
||||
eim.startEvent();
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
log.error("Event script startInstance", ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -576,7 +577,7 @@ public class EventManager {
|
||||
|
||||
eim.startEvent();
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
log.error("Event script startInstance", ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -648,7 +649,7 @@ public class EventManager {
|
||||
|
||||
eim.startEvent();
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
log.error("Event script startInstance", ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -715,7 +716,7 @@ public class EventManager {
|
||||
|
||||
eim.startEvent();
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
log.error("Event script startInstance", ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -755,7 +756,7 @@ public class EventManager {
|
||||
try {
|
||||
iv.invokeFunction("clearPQ", eim);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
log.error("Event script clearPQ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,7 +764,7 @@ public class EventManager {
|
||||
try {
|
||||
iv.invokeFunction("clearPQ", eim, toMap);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
log.error("Event script clearPQ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
package scripting.event;
|
||||
|
||||
import net.server.channel.Channel;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.AbstractScriptManager;
|
||||
import scripting.SynchronizedInvocable;
|
||||
|
||||
@@ -32,13 +33,12 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Matze
|
||||
*/
|
||||
public class EventScriptManager extends AbstractScriptManager {
|
||||
private static final org.slf4j.Logger log = LoggerFactory.getLogger(EventScriptManager.class);
|
||||
private static final String INJECTED_VARIABLE_NAME = "em";
|
||||
private static EventEntry fallback;
|
||||
private final Map<String, EventEntry> events = new ConcurrentHashMap<>();
|
||||
@@ -83,8 +83,7 @@ public class EventScriptManager extends AbstractScriptManager {
|
||||
try {
|
||||
entry.iv.invokeFunction("init", (Object) null);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(EventScriptManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
System.out.println("Error on script: " + entry.em.getName());
|
||||
log.error("Error on script: {}", entry.em.getName(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@ package scripting.map;
|
||||
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.AbstractScriptManager;
|
||||
import tools.FilePrinter;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptException;
|
||||
@@ -32,6 +33,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MapScriptManager extends AbstractScriptManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(MapScriptManager.class);
|
||||
private static final MapScriptManager instance = new MapScriptManager();
|
||||
|
||||
private final Map<String, Invocable> scripts = new HashMap<>();
|
||||
@@ -75,7 +77,7 @@ public class MapScriptManager extends AbstractScriptManager {
|
||||
iv.invokeFunction("start", new MapScriptMethods(c));
|
||||
return true;
|
||||
} catch (final Exception e) {
|
||||
FilePrinter.printError(FilePrinter.MAP_SCRIPT + mapScriptPath + ".txt", e);
|
||||
log.error("Error running map script {}", mapScriptPath, e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -40,6 +40,8 @@ import net.server.guild.Guild;
|
||||
import net.server.guild.GuildPackets;
|
||||
import net.server.world.Party;
|
||||
import net.server.world.PartyCharacter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import provider.Data;
|
||||
import provider.DataProviderFactory;
|
||||
import provider.wz.WZFiles;
|
||||
@@ -61,8 +63,6 @@ import server.partyquest.AriantColiseum;
|
||||
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;
|
||||
|
||||
@@ -77,6 +77,7 @@ import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
* @author Matze
|
||||
*/
|
||||
public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
private static final Logger log = LoggerFactory.getLogger(NPCConversationManager.class);
|
||||
|
||||
private final int npc;
|
||||
private int npcOid;
|
||||
@@ -381,7 +382,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
if (shop != null) {
|
||||
shop.sendShop(c);
|
||||
} else { // check for missing shopids thanks to resinate
|
||||
FilePrinter.printError(FilePrinter.NPC_UNCODED, "Shop ID: " + id + " is missing from database.");
|
||||
log.warn("Shop ID: {} is missing from database.", id);
|
||||
ShopFactory.getInstance().getShop(11000).sendShop(c);
|
||||
}
|
||||
}
|
||||
@@ -413,7 +414,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
(getNpc() - NpcId.GACHAPON_HENESYS) : getNpc() == NpcId.GACHAPON_NLC ? 8 : 9];
|
||||
String map = c.getChannelServer().getMapFactory().getMap(mapId).getMapName();
|
||||
|
||||
LogHelper.logGacha(getPlayer(), item.getId(), map);
|
||||
Gachapon.log(getPlayer(), item.getId(), map);
|
||||
|
||||
if (item.getTier() > 0) { //Uncommon and Rare
|
||||
Server.getInstance().broadcastMessage(c.getWorld(), PacketCreator.gachaponMessage(itemGained, map, getPlayer()));
|
||||
@@ -492,7 +493,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
|
||||
|
||||
@@ -24,9 +24,10 @@ package scripting.npc;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import net.server.world.PartyCharacter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.AbstractScriptManager;
|
||||
import server.ItemInformationProvider.ScriptedItem;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import javax.script.Invocable;
|
||||
@@ -40,6 +41,7 @@ import java.util.Map;
|
||||
* @author Matze
|
||||
*/
|
||||
public class NPCScriptManager extends AbstractScriptManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(NPCScriptManager.class);
|
||||
private static final NPCScriptManager instance = new NPCScriptManager();
|
||||
|
||||
private final Map<Client, NPCConversationManager> cms = new HashMap<>();
|
||||
@@ -104,7 +106,7 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
|
||||
} catch (final Exception e) {
|
||||
FilePrinter.printError(FilePrinter.NPC + npc + ".txt", e);
|
||||
log.error("Error starting NPC script: {}", npc, e);
|
||||
dispose(c);
|
||||
}
|
||||
}
|
||||
@@ -154,7 +156,7 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
return true;
|
||||
} catch (final Exception ute) {
|
||||
FilePrinter.printError(FilePrinter.NPC + npc + ".txt", ute);
|
||||
log.error("Error starting NPC script: {}", npc);
|
||||
dispose(c);
|
||||
|
||||
return false;
|
||||
@@ -169,7 +171,7 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
iv.invokeFunction("action", mode, type, selection);
|
||||
} catch (ScriptException | NoSuchMethodException t) {
|
||||
if (getCM(c) != null) {
|
||||
FilePrinter.printError(FilePrinter.NPC + getCM(c).getNpc() + ".txt", t);
|
||||
log.error("Error performing NPC script action for npc: {}", getCM(c).getNpc(), t);
|
||||
}
|
||||
dispose(c);
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ package scripting.quest;
|
||||
import client.Client;
|
||||
import client.QuestStatus;
|
||||
import constants.game.GameConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.AbstractScriptManager;
|
||||
import server.quest.Quest;
|
||||
import tools.FilePrinter;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -38,6 +38,7 @@ import java.util.Map;
|
||||
* @author RMZero213
|
||||
*/
|
||||
public class QuestScriptManager extends AbstractScriptManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(QuestScriptManager.class);
|
||||
private static final QuestScriptManager instance = new QuestScriptManager();
|
||||
|
||||
private final Map<Client, QuestActionManager> qms = new HashMap<>();
|
||||
@@ -73,7 +74,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
|
||||
ScriptEngine engine = getQuestScriptEngine(c, questid);
|
||||
if (engine == null) {
|
||||
FilePrinter.printError(FilePrinter.QUEST_UNCODED, "START Quest " + questid + " is uncoded.");
|
||||
log.warn("START Quest {} is uncoded.", questid);
|
||||
qm.dispose();
|
||||
return;
|
||||
}
|
||||
@@ -85,11 +86,8 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
c.setClickedNPC();
|
||||
iv.invokeFunction("start", (byte) 1, (byte) 0, 0);
|
||||
}
|
||||
} catch (final UndeclaredThrowableException ute) {
|
||||
FilePrinter.printError(FilePrinter.QUEST + questid + ".txt", ute);
|
||||
dispose(c);
|
||||
} catch (final Throwable t) {
|
||||
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", t);
|
||||
log.error("Error starting quest script: {}", questid, t);
|
||||
dispose(c);
|
||||
}
|
||||
}
|
||||
@@ -101,7 +99,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
c.setClickedNPC();
|
||||
iv.invokeFunction("start", mode, type, selection);
|
||||
} catch (final Exception e) {
|
||||
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", e);
|
||||
log.error("Error starting quest script: {}", getQM(c).getQuest(), e);
|
||||
dispose(c);
|
||||
}
|
||||
}
|
||||
@@ -128,7 +126,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
|
||||
ScriptEngine engine = getQuestScriptEngine(c, questid);
|
||||
if (engine == null) {
|
||||
FilePrinter.printError(FilePrinter.QUEST_UNCODED, "END Quest " + questid + " is uncoded.");
|
||||
log.warn("END Quest {} is uncoded.", questid);
|
||||
qm.dispose();
|
||||
return;
|
||||
}
|
||||
@@ -140,11 +138,8 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
c.setClickedNPC();
|
||||
iv.invokeFunction("end", (byte) 1, (byte) 0, 0);
|
||||
}
|
||||
} catch (final UndeclaredThrowableException ute) {
|
||||
FilePrinter.printError(FilePrinter.QUEST + questid + ".txt", ute);
|
||||
dispose(c);
|
||||
} catch (final Throwable t) {
|
||||
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", t);
|
||||
log.error("Error starting quest script: {}", questid, t);
|
||||
dispose(c);
|
||||
}
|
||||
}
|
||||
@@ -156,7 +151,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
c.setClickedNPC();
|
||||
iv.invokeFunction("end", mode, type, selection);
|
||||
} catch (final Exception e) {
|
||||
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", e);
|
||||
log.error("Error ending quest script: {}", getQM(c).getQuest(), e);
|
||||
dispose(c);
|
||||
}
|
||||
}
|
||||
@@ -185,11 +180,8 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
c.setClickedNPC();
|
||||
iv.invokeFunction("raiseOpen");
|
||||
}
|
||||
} catch (final UndeclaredThrowableException ute) {
|
||||
FilePrinter.printError(FilePrinter.QUEST + questid + ".txt", ute);
|
||||
dispose(c);
|
||||
} catch (final Throwable t) {
|
||||
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", t);
|
||||
log.error("Error during quest script raiseOpen for quest: {}", questid, t);
|
||||
dispose(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package scripting.reactor;
|
||||
|
||||
import client.Client;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.AbstractScriptManager;
|
||||
import server.maps.Reactor;
|
||||
import server.maps.ReactorDropEntry;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
@@ -43,6 +44,7 @@ import java.util.Map;
|
||||
* @author Lerk
|
||||
*/
|
||||
public class ReactorScriptManager extends AbstractScriptManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(ReactorScriptManager.class);
|
||||
private static final ReactorScriptManager instance = new ReactorScriptManager();
|
||||
|
||||
private final Map<Integer, List<ReactorDropEntry>> drops = new HashMap<>();
|
||||
@@ -60,10 +62,9 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
|
||||
iv.invokeFunction("hit");
|
||||
} catch (final NoSuchMethodException e) {
|
||||
} //do nothing, hit is OPTIONAL
|
||||
|
||||
catch (final ScriptException | NullPointerException e) {
|
||||
FilePrinter.printError(FilePrinter.REACTOR + reactor.getId() + ".txt", e);
|
||||
//do nothing, hit is OPTIONAL
|
||||
} catch (final ScriptException | NullPointerException e) {
|
||||
log.error("Error during onHit script for reactor: {}", reactor.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,17 +77,17 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
|
||||
iv.invokeFunction("act");
|
||||
} catch (final ScriptException | NoSuchMethodException | NullPointerException e) {
|
||||
FilePrinter.printError(FilePrinter.REACTOR + reactor.getId() + ".txt", e);
|
||||
log.error("Error during act script for reactor: {}", reactor.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<ReactorDropEntry> getDrops(int rid) {
|
||||
List<ReactorDropEntry> ret = drops.get(rid);
|
||||
public List<ReactorDropEntry> getDrops(int reactorId) {
|
||||
List<ReactorDropEntry> ret = drops.get(reactorId);
|
||||
if (ret == null) {
|
||||
ret = new LinkedList<>();
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT itemid, chance, questid FROM reactordrops WHERE reactorid = ? AND chance >= 0")) {
|
||||
ps.setInt(1, rid);
|
||||
ps.setInt(1, reactorId);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
ret.add(new ReactorDropEntry(rs.getInt("itemid"), rs.getInt("chance"), rs.getInt("questid")));
|
||||
@@ -94,9 +95,9 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
FilePrinter.printError(FilePrinter.REACTOR + rid + ".txt", e);
|
||||
log.error("Error getting drops for reactor: {}", reactorId);
|
||||
}
|
||||
drops.put(rid, ret);
|
||||
drops.put(reactorId, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -114,19 +115,16 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
|
||||
private void touching(Client c, Reactor reactor, boolean touching) {
|
||||
final String functionName = touching ? "touch" : "untouch";
|
||||
try {
|
||||
Invocable iv = initializeInvocable(c, reactor);
|
||||
if (iv == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (touching) {
|
||||
iv.invokeFunction("touch");
|
||||
} else {
|
||||
iv.invokeFunction("untouch");
|
||||
}
|
||||
} catch (final ScriptException | NoSuchMethodException | NullPointerException ute) {
|
||||
FilePrinter.printError(FilePrinter.REACTOR + reactor.getId() + ".txt", ute);
|
||||
iv.invokeFunction(functionName);
|
||||
} catch (final ScriptException | NoSuchMethodException | NullPointerException e) {
|
||||
log.error("Error during {} script for reactor: {}", functionName, reactor.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
19
src/main/java/server/ChatLogger.java
Normal file
19
src/main/java/server/ChatLogger.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package server;
|
||||
|
||||
import client.Client;
|
||||
import config.YamlConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ChatLogger {
|
||||
private static final Logger log = LoggerFactory.getLogger(ChatLogger.class);
|
||||
|
||||
/**
|
||||
* Log a chat message (if enabled in the config)
|
||||
*/
|
||||
public static void log(Client c, String chatType, String message) {
|
||||
if (YamlConfig.config.server.USE_ENABLE_CHAT_LOG) {
|
||||
log.info("({}) {}: {}", chatType, c.getPlayer().getName(), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ import constants.skills.Assassin;
|
||||
import constants.skills.Gunslinger;
|
||||
import constants.skills.NightWalker;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import provider.*;
|
||||
import provider.wz.WZFiles;
|
||||
import server.MakerItemFactory.MakerItemCreateEntry;
|
||||
@@ -51,6 +53,7 @@ import java.util.Map.Entry;
|
||||
* @author Matze
|
||||
*/
|
||||
public class ItemInformationProvider {
|
||||
private static final Logger log = LoggerFactory.getLogger(ItemInformationProvider.class);
|
||||
private final static ItemInformationProvider instance = new ItemInformationProvider();
|
||||
|
||||
public static ItemInformationProvider getInstance() {
|
||||
@@ -1799,7 +1802,7 @@ public class ItemInformationProvider {
|
||||
String itemName = ItemInformationProvider.getInstance().getName(equip.getItemId());
|
||||
Server.getInstance().broadcastGMMessage(chr.getWorld(), PacketCreator.sendYellowTip("[Warning]: " + chr.getName() + " tried to equip " + itemName + " into slot " + dst + "."));
|
||||
AutobanFactory.PACKET_EDIT.alert(chr, chr.getName() + " tried to forcibly equip an item.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + chr.getName() + ".txt", chr.getName() + " tried to equip " + itemName + " into " + dst + " slot.");
|
||||
log.warn("Chr {} tried to equip {} into slot {}", chr.getName(), itemName, dst);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,8 @@ import client.inventory.Pet;
|
||||
import client.inventory.manipulator.InventoryManipulator;
|
||||
import constants.id.ItemId;
|
||||
import constants.inventory.ItemConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.PacketCreator;
|
||||
|
||||
@@ -44,7 +46,9 @@ import java.util.Set;
|
||||
* @author Matze
|
||||
*/
|
||||
public class Shop {
|
||||
private static final Logger log = LoggerFactory.getLogger(Shop.class);
|
||||
private static final Set<Integer> rechargeableItems = new LinkedHashSet<>();
|
||||
|
||||
private final int id;
|
||||
private final int npcId;
|
||||
private final List<ShopItem> items;
|
||||
@@ -83,7 +87,7 @@ public class Shop {
|
||||
ShopItem item = findBySlot(slot);
|
||||
if (item != null) {
|
||||
if (item.getItemId() != itemId) {
|
||||
System.out.println("Wrong slot number in shop " + id);
|
||||
log.warn("Wrong slot number in shop {}", id);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
package server;
|
||||
|
||||
import client.Character;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import provider.Data;
|
||||
import provider.DataProvider;
|
||||
import provider.DataProviderFactory;
|
||||
@@ -45,6 +47,7 @@ import java.util.regex.Pattern;
|
||||
* Only used in 1 script that gives players information about where skillbooks can be found
|
||||
*/
|
||||
public class SkillbookInformationProvider {
|
||||
private static final Logger log = LoggerFactory.getLogger(SkillbookInformationProvider.class);
|
||||
private static volatile Map<Integer, SkillBookEntry> foundSkillbooks = new HashMap<>();
|
||||
|
||||
public enum SkillBookEntry {
|
||||
@@ -242,8 +245,7 @@ public class SkillbookInformationProvider {
|
||||
scriptFileSkillbooks.put(skillbookId, SkillBookEntry.SCRIPT);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
System.out.println("Failed to read " + file.getName() + ".");
|
||||
ioe.printStackTrace();
|
||||
log.error("Failed to read file:{}", file.getName(), ioe);
|
||||
}
|
||||
|
||||
return scriptFileSkillbooks;
|
||||
|
||||
@@ -25,13 +25,14 @@ import client.inventory.ItemFactory;
|
||||
import constants.game.GameConstants;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import provider.Data;
|
||||
import provider.DataProvider;
|
||||
import provider.DataProviderFactory;
|
||||
import provider.DataTool;
|
||||
import provider.wz.WZFiles;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
@@ -46,6 +47,7 @@ import java.util.concurrent.locks.Lock;
|
||||
* @author Matze
|
||||
*/
|
||||
public class Storage {
|
||||
private static final Logger log = LoggerFactory.getLogger(Storage.class);
|
||||
private static final Map<Integer, Integer> trunkGetCache = new HashMap<>();
|
||||
private static final Map<Integer, Integer> trunkPutCache = new HashMap<>();
|
||||
|
||||
@@ -94,7 +96,7 @@ public class Storage {
|
||||
|
||||
return ret;
|
||||
} catch (SQLException ex) { // exceptions leading to deploy null storages found thanks to Jefe
|
||||
FilePrinter.printError(FilePrinter.STORAGE, ex, "SQL error occurred when trying to load storage for accountid " + id + ", world " + GameConstants.WORLD_NAMES[world]);
|
||||
log.error("SQL error occurred when trying to load storage for accId {}, world {}", id, GameConstants.WORLD_NAMES[world], ex);
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
package server;
|
||||
|
||||
import net.server.Server;
|
||||
import tools.FilePrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
@@ -36,6 +37,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
public class TimerManager implements TimerManagerMBean {
|
||||
private static final Logger log = LoggerFactory.getLogger(TimerManager.class);
|
||||
private static final TimerManager instance = new TimerManager();
|
||||
|
||||
public static TimerManager getInstance() {
|
||||
@@ -147,7 +149,7 @@ public class TimerManager implements TimerManagerMBean {
|
||||
try {
|
||||
r.run();
|
||||
} catch (Throwable t) {
|
||||
FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, t);
|
||||
log.error("Error in scheduled task", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,15 @@ import net.server.coordinator.world.InviteCoordinator;
|
||||
import net.server.coordinator.world.InviteCoordinator.InviteResult;
|
||||
import net.server.coordinator.world.InviteCoordinator.InviteResultType;
|
||||
import net.server.coordinator.world.InviteCoordinator.InviteType;
|
||||
import tools.LogHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
@@ -47,6 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* @author Ronan - concurrency safety + check available slots + trade results
|
||||
*/
|
||||
public class Trade {
|
||||
private static final Logger log = LoggerFactory.getLogger(Trade.class);
|
||||
|
||||
public enum TradeResult {
|
||||
NO_RESPONSE(1),
|
||||
@@ -179,7 +182,7 @@ public class Trade {
|
||||
throw new RuntimeException("Trade is locked.");
|
||||
}
|
||||
if (meso < 0) {
|
||||
System.out.println("[Hack] " + chr.getName() + " Trying to trade < 0 mesos");
|
||||
log.warn("[Hack] Chr {} is trying to trade negative mesos", chr.getName());
|
||||
return;
|
||||
}
|
||||
if (chr.getMeso() >= meso) {
|
||||
@@ -348,7 +351,7 @@ public class Trade {
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.logTrade(local, partner);
|
||||
logTrade(local, partner);
|
||||
local.completeTrade();
|
||||
partner.completeTrade();
|
||||
|
||||
@@ -521,4 +524,30 @@ public class Trade {
|
||||
public void setFullTrade(boolean fullTrade) {
|
||||
this.fullTrade = fullTrade;
|
||||
}
|
||||
|
||||
private static void logTrade(Trade trade1, Trade trade2) {
|
||||
String name1 = trade1.getChr().getName();
|
||||
String name2 = trade2.getChr().getName();
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append(String.format("Committing trade between %s and %s%n", name1, name2));
|
||||
//Trade 1 to trade 2
|
||||
message.append(String.format("Trading %s -> %s: %d mesos, items: %s%n", name1, name2,
|
||||
trade1.getExchangeMesos(), getFormattedItemLogMessage(trade1.getItems())));
|
||||
|
||||
//Trade 2 to trade 1
|
||||
message.append(String.format("Trading %s -> %s: %d mesos, items: %s%n", name2, name1,
|
||||
trade2.getExchangeMesos(), getFormattedItemLogMessage(trade2.getItems())));
|
||||
|
||||
log.info(message.toString());
|
||||
}
|
||||
|
||||
private static String getFormattedItemLogMessage(List<Item> items) {
|
||||
StringJoiner sj = new StringJoiner(", ", "[", "]");
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
for (Item item : items) {
|
||||
String itemName = ii.getName(item.getItemId());
|
||||
sj.add(String.format("%dx %s (%d)", item.getQuantity(), itemName, item.getItemId()));
|
||||
}
|
||||
return sj.toString();
|
||||
}
|
||||
}
|
||||
@@ -32,10 +32,11 @@ import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReentrantLock;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import net.server.channel.Channel;
|
||||
import org.slf4j.Logger;
|
||||
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;
|
||||
@@ -46,11 +47,13 @@ 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)
|
||||
*/
|
||||
public class Expedition {
|
||||
private static final Logger log = LoggerFactory.getLogger(Expedition.class);
|
||||
|
||||
private static final int[] EXPEDITION_BOSSES = {
|
||||
MobId.ZAKUM_1,
|
||||
@@ -151,10 +154,36 @@ public class Expedition {
|
||||
schedule.cancel(false);
|
||||
}
|
||||
if (log && !registering) {
|
||||
LogHelper.logExpedition(this);
|
||||
log();
|
||||
}
|
||||
}
|
||||
|
||||
private void log() {
|
||||
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 += getTimeString(startTime) + "\r\n";
|
||||
|
||||
for (String memberName : getMembers().values()) {
|
||||
log += ">>" + memberName + "\r\n";
|
||||
}
|
||||
log += "BOSS KILLS\r\n";
|
||||
for (String message : bossLogs) {
|
||||
log += message;
|
||||
}
|
||||
log += "\r\n";
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -267,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
*/
|
||||
package server.gachapon;
|
||||
|
||||
import client.Character;
|
||||
import constants.id.NpcId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import tools.Randomizer;
|
||||
|
||||
@@ -29,7 +32,7 @@ import tools.Randomizer;
|
||||
* @author Alan (SharpAceX)
|
||||
*/
|
||||
public class Gachapon {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Gachapon.class);
|
||||
private static final Gachapon instance = new Gachapon();
|
||||
|
||||
public static Gachapon getInstance() {
|
||||
@@ -162,4 +165,9 @@ public class Gachapon {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
public static void log(Character player, int itemId, String map) {
|
||||
String itemName = ItemInformationProvider.getInstance().getName(itemId);
|
||||
log.info("{} got a {} ({}) from the {} gachapon.", player.getName(), itemName, itemId, map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.life;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import provider.Data;
|
||||
import provider.DataProvider;
|
||||
import provider.DataProviderFactory;
|
||||
@@ -35,6 +37,7 @@ import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class LifeFactory {
|
||||
private static final Logger log = LoggerFactory.getLogger(LifeFactory.class);
|
||||
private static final DataProvider data = DataProviderFactory.getDataProvider(WZFiles.MOB);
|
||||
private final static DataProvider stringDataWZ = DataProviderFactory.getDataProvider(WZFiles.STRING);
|
||||
private static final Data mobStringData = stringDataWZ.getData("Mob.img");
|
||||
@@ -59,7 +62,7 @@ public class LifeFactory {
|
||||
} else if (type.equalsIgnoreCase("m")) {
|
||||
return getMonster(id);
|
||||
} else {
|
||||
System.out.println("Unknown Life type: " + type);
|
||||
log.warn("Unknown Life type: {}", type);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -247,12 +250,9 @@ public class LifeFactory {
|
||||
|
||||
monsterStats.put(mid, stats);
|
||||
}
|
||||
Monster ret = new Monster(mid, stats);
|
||||
return ret;
|
||||
return new Monster(mid, stats);
|
||||
} catch (NullPointerException npe) {
|
||||
System.out.println("[SEVERE] MOB " + mid + " failed to load. Issue: " + npe.getMessage() + "\n\n");
|
||||
npe.printStackTrace();
|
||||
|
||||
log.error("[SEVERE] MOB {} failed to load.", mid, npe);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -271,8 +271,7 @@ public class LifeFactory {
|
||||
return stats.getLevel();
|
||||
}
|
||||
} catch (NullPointerException npe) {
|
||||
System.out.println("[SEVERE] MOB " + mid + " failed to load. Issue: " + npe.getMessage() + "\n\n");
|
||||
npe.printStackTrace();
|
||||
log.error("[SEVERE] MOB {} failed to load.", mid, npe);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
@@ -28,6 +28,8 @@ import constants.id.MapId;
|
||||
import constants.id.MobId;
|
||||
import net.server.services.task.channel.OverallService;
|
||||
import net.server.services.type.ChannelServices;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.maps.MapObject;
|
||||
import server.maps.MapObjectType;
|
||||
import server.maps.MapleMap;
|
||||
@@ -43,6 +45,7 @@ import java.util.*;
|
||||
* @author Danny (Leifde)
|
||||
*/
|
||||
public class MobSkill {
|
||||
private static final Logger log = LoggerFactory.getLogger(MobSkill.class);
|
||||
|
||||
private final int skillId;
|
||||
private final int skillLevel;
|
||||
@@ -314,7 +317,7 @@ public class MobSkill {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("Unhandled Mob skill: " + skillId);
|
||||
log.warn("Unhandled Mob skill: {}", skillId);
|
||||
break;
|
||||
}
|
||||
if (stats.size() > 0) {
|
||||
|
||||
@@ -42,6 +42,8 @@ import net.server.services.task.channel.OverallService;
|
||||
import net.server.services.type.ChannelServices;
|
||||
import net.server.world.Party;
|
||||
import net.server.world.PartyCharacter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import server.StatEffect;
|
||||
import server.TimerManager;
|
||||
@@ -66,6 +68,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class Monster extends AbstractLoadedLife {
|
||||
private static final Logger log = LoggerFactory.getLogger(Monster.class);
|
||||
|
||||
private ChangeableStats ostats = null; //unused, v83 WZs offers no support for changeable stats.
|
||||
private MonsterStats stats;
|
||||
@@ -823,7 +826,7 @@ public class Monster extends AbstractLoadedLife {
|
||||
}, getAnimationTime("die1"));
|
||||
}
|
||||
} else { // is this even necessary?
|
||||
System.out.println("[CRITICAL LOSS] toSpawn is null for " + this.getName());
|
||||
log.warn("[CRITICAL LOSS] toSpawn is null for {}", getName());
|
||||
}
|
||||
|
||||
Character looter = map.getCharacterById(getHighestDamagerId());
|
||||
@@ -1124,7 +1127,7 @@ public class Monster extends AbstractLoadedLife {
|
||||
case WEAK:
|
||||
break;
|
||||
default: {
|
||||
System.out.println("Unknown elemental effectiveness: " + getMonsterEffectiveness(status.getSkill().getElement()));
|
||||
log.warn("Unknown elemental effectiveness: {}", getMonsterEffectiveness(status.getSkill().getElement()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ package server.life;
|
||||
|
||||
import config.YamlConfig;
|
||||
import constants.inventory.ItemConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import provider.Data;
|
||||
import provider.DataProvider;
|
||||
import provider.DataProviderFactory;
|
||||
@@ -39,6 +41,7 @@ import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
public class MonsterInformationProvider {
|
||||
private static final Logger log = LoggerFactory.getLogger(MonsterInformationProvider.class);
|
||||
// Author : LightPepsi
|
||||
|
||||
private static final MonsterInformationProvider instance = new MonsterInformationProvider();
|
||||
@@ -100,7 +103,7 @@ public class MonsterInformationProvider {
|
||||
rs.getShort("questid")));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Error retrieving drop" + e);
|
||||
log.error("Error retrieving global drops", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,8 +257,7 @@ public class MonsterInformationProvider {
|
||||
} catch (Exception e) { //nonexistant mob
|
||||
boss = false;
|
||||
|
||||
e.printStackTrace();
|
||||
System.err.println("Nonexistant mob id " + id);
|
||||
log.warn("Non-existent mob id {}", id, e);
|
||||
}
|
||||
|
||||
mobBossCache.put(id, boss);
|
||||
|
||||
@@ -31,6 +31,8 @@ import constants.id.NpcId;
|
||||
import net.server.Server;
|
||||
import net.server.channel.Channel;
|
||||
import net.server.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.life.positioner.PlayerNPCPodium;
|
||||
import server.life.positioner.PlayerNPCPositioner;
|
||||
import server.maps.AbstractMapObject;
|
||||
@@ -52,6 +54,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class PlayerNPC extends AbstractMapObject {
|
||||
private static final Logger log = LoggerFactory.getLogger(PlayerNPC.class);
|
||||
private static final Map<Byte, List<Integer>> availablePlayerNpcScriptIds = new HashMap<>();
|
||||
private static final AtomicInteger runningOverallRank = new AtomicInteger();
|
||||
private static final List<AtomicInteger> runningWorldRank = new ArrayList<>();
|
||||
@@ -400,7 +403,7 @@ public class PlayerNPC extends AbstractMapObject {
|
||||
}
|
||||
|
||||
if (YamlConfig.config.server.USE_DEBUG) {
|
||||
System.out.println("GOT SID " + scriptId + " POS " + pos);
|
||||
log.debug("GOT SID {}, POS {}", scriptId, pos);
|
||||
}
|
||||
|
||||
int worldId = chr.getWorld();
|
||||
|
||||
@@ -22,6 +22,8 @@ package server.life.positioner;
|
||||
import config.YamlConfig;
|
||||
import net.server.Server;
|
||||
import net.server.channel.Channel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.life.PlayerNPC;
|
||||
import server.maps.MapObject;
|
||||
import server.maps.MapObjectType;
|
||||
@@ -40,6 +42,8 @@ import java.util.List;
|
||||
* Podium system will implement increase-by-7 to negate that behaviour.
|
||||
*/
|
||||
public class PlayerNPCPodium {
|
||||
private static final Logger log = LoggerFactory.getLogger(PlayerNPCPodium.class);
|
||||
|
||||
private static int getPlatformPosX(int platform) {
|
||||
return switch (platform) {
|
||||
case 0 -> -50;
|
||||
@@ -76,7 +80,7 @@ public class PlayerNPCPodium {
|
||||
private static Point reorganizePlayerNpcs(MapleMap map, int newStep, List<MapObject> mmoList) {
|
||||
if (!mmoList.isEmpty()) {
|
||||
if (YamlConfig.config.server.USE_DEBUG) {
|
||||
System.out.println("Reorganizing pnpc map, step " + newStep);
|
||||
log.debug("Re-organizing pnpc map, step {}", newStep);
|
||||
}
|
||||
|
||||
List<PlayerNPC> playerNpcs = new ArrayList<>(mmoList.size());
|
||||
|
||||
@@ -22,6 +22,8 @@ package server.life.positioner;
|
||||
import config.YamlConfig;
|
||||
import net.server.Server;
|
||||
import net.server.channel.Channel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.life.PlayerNPC;
|
||||
import server.maps.MapObject;
|
||||
import server.maps.MapObjectType;
|
||||
@@ -38,6 +40,7 @@ import java.util.List;
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class PlayerNPCPositioner {
|
||||
private static final Logger log = LoggerFactory.getLogger(PlayerNPCPositioner.class);
|
||||
|
||||
private static boolean isPlayerNpcNearby(List<Point> otherPos, Point searchPos, int xLimit, int yLimit) {
|
||||
int xLimit2 = xLimit / 2, yLimit2 = yLimit / 2;
|
||||
@@ -135,7 +138,7 @@ public class PlayerNPCPositioner {
|
||||
private static Point reorganizePlayerNpcs(MapleMap map, int newStep, List<MapObject> mmoList) {
|
||||
if (!mmoList.isEmpty()) {
|
||||
if (YamlConfig.config.server.USE_DEBUG) {
|
||||
System.out.println("Reorganizing pnpc map, step " + newStep);
|
||||
log.debug("Re-organizing pnpc map, step {}", newStep);
|
||||
}
|
||||
|
||||
List<PlayerNPC> playerNpcs = new ArrayList<>(mmoList.size());
|
||||
|
||||
@@ -53,6 +53,8 @@ import net.server.services.task.channel.OverallService;
|
||||
import net.server.services.type.ChannelServices;
|
||||
import net.server.world.Party;
|
||||
import net.server.world.World;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import scripting.map.MapScriptManager;
|
||||
import server.ItemInformationProvider;
|
||||
@@ -64,7 +66,6 @@ import server.life.LifeFactory.selfDestruction;
|
||||
import server.partyquest.CarnivalFactory;
|
||||
import server.partyquest.CarnivalFactory.MCSkill;
|
||||
import server.partyquest.GuardianSpawnPoint;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
import tools.Randomizer;
|
||||
@@ -83,7 +84,7 @@ import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public class MapleMap {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MapleMap.class);
|
||||
private static final List<MapObjectType> rangedMapobjectTypes = Arrays.asList(MapObjectType.SHOP, MapObjectType.ITEM, MapObjectType.NPC, MapObjectType.MONSTER, MapObjectType.DOOR, MapObjectType.SUMMON, MapObjectType.REACTOR);
|
||||
private static final Map<Integer, Pair<Integer, Integer>> dropBoundsCache = new HashMap<>(100);
|
||||
|
||||
@@ -1985,7 +1986,7 @@ public class MapleMap {
|
||||
} else if (monster.getId() == MobId.GIANT_SNOWMAN_LV5_EASY || monster.getId() == MobId.GIANT_SNOWMAN_LV5_MEDIUM || monster.getId() == MobId.GIANT_SNOWMAN_LV5_HARD) {
|
||||
monsterItemDrop(monster, monster.getDropPeriodTime());
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.UNHANDLED_EVENT, "UNCODED TIMED MOB DETECTED: " + monster.getId());
|
||||
log.error("UNCODED TIMED MOB DETECTED: {}", monster.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2059,7 +2060,7 @@ public class MapleMap {
|
||||
public Portal getDoorPortal(int doorid) {
|
||||
Portal doorPortal = portals.get(0x80 + doorid);
|
||||
if (doorPortal == null) {
|
||||
FilePrinter.printError(FilePrinter.EXCEPTION, "[Door] " + mapName + "(" + mapid + ") does not contain door portalid " + doorid);
|
||||
log.warn("[Door] {} ({}) does not contain door portalid {}", mapName, mapid, doorid);
|
||||
return portals.get(0x80);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user