/**
* An implementation of {@link MemoSet} used for Player. There is a restore/save system.
*/
public class PlayerMemo extends MemoSet
{
private static final long serialVersionUID = 1L;
private static final CLogger LOGGER = new CLogger(PlayerMemo.class.getName());
private static final String SELECT_MEMOS = "SELECT * FROM character_memo WHERE charId = ?";
private static final String DELETE_MEMO = "DELETE FROM character_memo WHERE charId = ? AND var = ?";
private static final String INSERT_OR_UPDATE_MEMO = "INSERT INTO character_memo (charId, var, val) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE val = VALUES(val)";
private final int _objectId;
public PlayerMemo(int objectId)
{
_objectId = objectId;
Unlock Unlimited Access with GoProxy's Residential Proxies!
Experience seamless, secure, and unrestricted connectivity worldwide with GoProxy's Unlimited Residential Proxies.
Our service offers access to a global network of rotating residential IPs, ensuring top performance for your large-scale data collection, streaming, and more.
✔️Unlimited Traffic & IPs: Enjoy unrestricted access with our rotating residential proxies, delivering high performance through a vast global IP pool.
✔️High Success Rate: Achieve a 99.96% success rate with a rapid 0.6-second response time, ensuring efficient and reliable operations.
✔️Flexible Sessions: Customize IP rotation to fit your project needs, with options for automatic rotation and sticky sessions lasting up to 60 minutes.
✔️Global Coverage: Access IPs from over 120 countries, making it ideal for businesses requiring high bandwidth without region-specific constraints.
All plans include unlimited traffic and IPs, unlimited concurrent requests, and access to real residential IP addresses.
Elevate your online operations with GoProxy's Unlimited Residential Proxies—your smart choice for large-scale projects.
👉 Learn more and get started today: GoProxy Unlimited Proxies
Question
addx20
Hello! The only problem that i am facing is the bold line i cant find the SetVar! Need to adapt it for Acis 398.If anyone can help! Thanks
private void rewardPlayers()
{
// First Add Fixed Reward
for (Player player : players)
{
PlayerMemo.setVar(player, "dungeon_atleast1time", "true", -1);
for (Entry<Integer, Integer> itemId : template.getRewards().entrySet())
{
player.addItem("dungeon reward", itemId.getKey(), itemId.getValue(), null, true);
}
}
if (!template.getRewardHtm().equals("NULL"))
{
NpcHtmlMessage htm = new NpcHtmlMessage(0);
htm.setFile(template.getRewardHtm());
for (Player player : players)
player.sendPacket(htm);
}
else
{
for (Player player : players)
{
player.setInstance(InstanceManager.getInstance().getInstance(0), true);
player.teleportTo(82635, 148798, -3464, 25);
}
}
}
===================================================================================================================================
Here is PlayerMemo
package net.sf.l2j.gameserver.model.memo;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import net.sf.l2j.commons.data.MemoSet;
import net.sf.l2j.commons.logging.CLogger;
import net.sf.l2j.commons.pool.ConnectionPool;
/**
Edited by addx20* An implementation of {@link MemoSet} used for Player. There is a restore/save system.
*/
public class PlayerMemo extends MemoSet
{
private static final long serialVersionUID = 1L;
private static final CLogger LOGGER = new CLogger(PlayerMemo.class.getName());
private static final String SELECT_MEMOS = "SELECT * FROM character_memo WHERE charId = ?";
private static final String DELETE_MEMO = "DELETE FROM character_memo WHERE charId = ? AND var = ?";
private static final String INSERT_OR_UPDATE_MEMO = "INSERT INTO character_memo (charId, var, val) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE val = VALUES(val)";
private final int _objectId;
public PlayerMemo(int objectId)
{
_objectId = objectId;
// Restore memos.
try (Connection con = ConnectionPool.getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_MEMOS))
{
ps.setInt(1, _objectId);
try (ResultSet rs = ps.executeQuery())
{
while (rs.next())
put(rs.getString("var"), rs.getString("val"));
}
}
catch (Exception e)
{
LOGGER.error("Couldn't restore memos for player id {}.", e, _objectId);
}
}
@Override
protected void onSet(String key, String value)
{
// Insert memo, on duplicate update it.
try (Connection con = ConnectionPool.getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_OR_UPDATE_MEMO))
{
ps.setInt(1, _objectId);
ps.setString(2, key);
ps.setString(3, value);
ps.execute();
}
catch (Exception e)
{
LOGGER.error("Couldn't set {} memo for player id {}.", e, key, _objectId);
}
}
@Override
protected void onUnset(String key)
{
// Clear memo.
try (Connection con = ConnectionPool.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_MEMO))
{
ps.setInt(1, _objectId);
ps.setString(2, key);
ps.execute();
}
catch (Exception e)
{
LOGGER.error("Couldn't unset {} memo for player id {}.", e, key, _objectId);
}
}
}
3 answers to this question
Recommended Posts