Migrate another batch of FilePrinter users to slf4j.Logger
Another FilePrinter method removed.
This commit is contained in:
@@ -8071,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();
|
||||
@@ -8361,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);
|
||||
|
||||
@@ -8775,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;
|
||||
@@ -10754,8 +10748,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);
|
||||
@@ -10763,12 +10756,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10781,8 +10773,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10792,8 +10783,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;
|
||||
}
|
||||
|
||||
@@ -10802,8 +10792,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;
|
||||
}
|
||||
|
||||
@@ -10922,8 +10911,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,10 @@ 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;
|
||||
@@ -204,7 +207,9 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -639,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;
|
||||
}
|
||||
|
||||
@@ -1226,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());
|
||||
}
|
||||
|
||||
@@ -25,7 +25,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 tools.PacketCreator;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -59,6 +60,7 @@ 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;
|
||||
@@ -98,7 +100,8 @@ public enum AutobanFactory {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -1596,7 +1596,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,7 +1617,7 @@ 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();
|
||||
@@ -1657,7 +1657,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);
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
package net.server.audit;
|
||||
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.TimerManager;
|
||||
import tools.FilePrinter;
|
||||
|
||||
@@ -38,6 +40,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 +150,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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,13 @@ import client.inventory.InventoryType;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.manipulator.InventoryManipulator;
|
||||
import constants.inventory.ItemConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import provider.Data;
|
||||
import provider.DataTool;
|
||||
import server.ItemInformationProvider;
|
||||
import server.quest.Quest;
|
||||
import server.quest.QuestActionType;
|
||||
import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
import tools.Randomizer;
|
||||
@@ -49,6 +50,7 @@ import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class ItemAction extends AbstractQuestAction {
|
||||
private static final Logger log = LoggerFactory.getLogger(ItemAction.class);
|
||||
List<ItemData> items = new ArrayList<>();
|
||||
|
||||
public ItemAction(Quest quest, Data data) {
|
||||
@@ -318,7 +320,7 @@ public class ItemAction extends AbstractQuestAction {
|
||||
}
|
||||
|
||||
InventoryManipulator.addById(chr.getClient(), item.getId(), (short) missingQty);
|
||||
FilePrinter.print(FilePrinter.QUEST_RESTORE_ITEM, chr + " obtained " + itemid + " qty. " + missingQty + " from quest " + questID);
|
||||
log.debug("Chr {} obtained {}x {} from questId {}", chr, itemid, missingQty, questID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -130,40 +130,6 @@ public class FilePrinter {
|
||||
}
|
||||
}
|
||||
|
||||
public static void print(final String name, final String s) {
|
||||
print(name, s, true);
|
||||
}
|
||||
|
||||
public static void print(final String name, final String s, boolean line) {
|
||||
System.out.println("Log: " + name);
|
||||
System.out.println(s);
|
||||
System.out.println();
|
||||
FileOutputStream out = null;
|
||||
String file = FILE_PATH + name;
|
||||
try {
|
||||
File outputFile = new File(file);
|
||||
if (outputFile.getParentFile() != null) {
|
||||
outputFile.getParentFile().mkdirs();
|
||||
}
|
||||
out = new FileOutputStream(file, true);
|
||||
out.write(s.getBytes());
|
||||
if (line) {
|
||||
out.write("\r\n---------------------------------\r\n".getBytes());
|
||||
}
|
||||
out.write("\r\n".getBytes());
|
||||
} catch (IOException ess) {
|
||||
ess.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getString(final Throwable e) {
|
||||
String retValue = null;
|
||||
StringWriter sw = null;
|
||||
|
||||
Reference in New Issue
Block a user