Rework sending notes to chr, get rid of the first method

Sending notes should not be the handled by Character
This commit is contained in:
P0nk
2022-12-26 17:03:40 +01:00
parent 1f4ce98998
commit 4d480660b5
3 changed files with 28 additions and 16 deletions

View File

@@ -30,6 +30,9 @@ import client.inventory.InventoryType;
import client.inventory.Item;
import client.inventory.ItemFactory;
import client.inventory.manipulator.InventoryManipulator;
import database.DaoException;
import database.NoteDao;
import model.Note;
import net.server.Server;
import net.server.world.World;
import org.slf4j.Logger;
@@ -241,7 +244,7 @@ public class FredrickProcessor {
ps.addBatch();
String msg = fredrickReminderMessage(cid.getRight() - 1);
Character.sendNote(cid.getLeft().getRight(), "FREDRICK", msg, (byte) 0);
saveFredrickReminderNote(msg, cid.getLeft().getRight());
}
ps.executeBatch();
@@ -252,6 +255,15 @@ public class FredrickProcessor {
}
}
private static void saveFredrickReminderNote(String message, String to) {
Note reminderNote = Note.createNormal(message, "FREDRICK", to, Server.getInstance().getCurrentTime());
try {
NoteDao.save(reminderNote);
} catch (DaoException e) {
log.error("Failed to save Fredrick reminder note", e);
}
}
private static boolean deleteFredrickItems(int cid) {
try (Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM `inventoryitems` WHERE `type` = ? AND `characterid` = ?")) {