Sync with L2JServer Jan 28th 2015.

This commit is contained in:
mobius
2015-01-29 05:18:04 +00:00
parent 59e1db4a68
commit 2cb3a52ed2
224 changed files with 4690 additions and 835 deletions

View File

@@ -23,13 +23,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
import javolution.util.FastMap;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.interfaces.IDeletable;
import com.l2jserver.gameserver.model.interfaces.IRestorable;
import com.l2jserver.gameserver.model.interfaces.IStorable;
/**
* @author UnAfraid
*/
public abstract class AbstractVariables extends StatsSet implements IRestorable, IStorable
public abstract class AbstractVariables extends StatsSet implements IRestorable, IStorable, IDeletable
{
private final AtomicBoolean _hasChanges = new AtomicBoolean(false);
@@ -84,6 +85,21 @@ public abstract class AbstractVariables extends StatsSet implements IRestorable,
super.set(name, value);
}
/**
* Put's entry to the variables and marks as changed if required (<i>Useful when restoring to do not save them again</i>).
* @param name
* @param value
* @param markAsChanged
*/
public final void set(String name, String value, boolean markAsChanged)
{
if (markAsChanged)
{
_hasChanges.compareAndSet(false, true);
}
super.set(name, value);
}
/**
* Return true if there exists a record for the variable name.
* @param name

View File

@@ -118,4 +118,27 @@ public class AccountVariables extends AbstractVariables
}
return true;
}
@Override
public boolean deleteMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
{
st.setString(1, _accountName);
st.execute();
}
// Clear all entries
getSet().clear();
}
catch (Exception e)
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't delete variables for: " + _accountName, e);
return false;
}
return true;
}
}

View File

@@ -44,4 +44,10 @@ public class NpcVariables extends AbstractVariables
{
return true;
}
@Override
public boolean deleteMe()
{
return true;
}
}

View File

@@ -121,6 +121,29 @@ public class PlayerVariables extends AbstractVariables
return true;
}
@Override
public boolean deleteMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
{
st.setInt(1, _objectId);
st.execute();
}
// Clear all entries
getSet().clear();
}
catch (Exception e)
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't delete variables for: " + getPlayer(), e);
return false;
}
return true;
}
public L2PcInstance getPlayer()
{
return L2World.getInstance().getPlayer(_objectId);