mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-06 07:32:46 +00:00
Implements item dropping and pickup stacking
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
*/
|
||||
package com.l2jserver.model;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.l2jserver.model.id.ID;
|
||||
|
||||
@@ -28,6 +32,8 @@ import com.l2jserver.model.id.ID;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class AbstractModel<T extends ID<?>> implements Model<T> {
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The object id
|
||||
*/
|
||||
@@ -58,6 +64,7 @@ public abstract class AbstractModel<T extends ID<?>> implements Model<T> {
|
||||
public void setObjectDesire(ObjectDesire desire) {
|
||||
if (desire == null)
|
||||
desire = ObjectDesire.NONE;
|
||||
log.debug("{} set desire to {}", this, desire);
|
||||
this.desire = desire;
|
||||
}
|
||||
|
||||
@@ -69,8 +76,10 @@ public abstract class AbstractModel<T extends ID<?>> implements Model<T> {
|
||||
@SuppressWarnings("javadoc")
|
||||
protected void desireUpdate() {
|
||||
if (this.desire != ObjectDesire.INSERT
|
||||
&& this.desire != ObjectDesire.DELETE)
|
||||
&& this.desire != ObjectDesire.DELETE) {
|
||||
log.debug("{} desires an update", this);
|
||||
this.desire = ObjectDesire.UPDATE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,8 +88,10 @@ public abstract class AbstractModel<T extends ID<?>> implements Model<T> {
|
||||
*/
|
||||
@SuppressWarnings("javadoc")
|
||||
protected void desireInsert() {
|
||||
if (this.desire != ObjectDesire.DELETE)
|
||||
if (this.desire != ObjectDesire.DELETE) {
|
||||
log.debug("{} desires an insert", this);
|
||||
this.desire = ObjectDesire.INSERT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -515,7 +515,7 @@ public abstract class AbstractJDBCDatabaseService extends AbstractService
|
||||
this.parametize(st, object);
|
||||
|
||||
log.debug("Sending query to database for {}", object);
|
||||
rows += st.executeUpdate();
|
||||
rows = st.executeUpdate();
|
||||
log.debug("Query inserted or updated {} rows for {}", rows,
|
||||
object);
|
||||
|
||||
@@ -616,9 +616,7 @@ public abstract class AbstractJDBCDatabaseService extends AbstractService
|
||||
continue;
|
||||
}
|
||||
if (obj instanceof Model) {
|
||||
if (((Model<?>) obj).getObjectDesire() == ObjectDesire.INSERT) {
|
||||
((Model<?>) obj).setObjectDesire(ObjectDesire.NONE);
|
||||
}
|
||||
((Model<?>) obj).setObjectDesire(ObjectDesire.NONE);
|
||||
}
|
||||
log.debug("Mapper {} returned {}", mapper, obj);
|
||||
list.add(obj);
|
||||
@@ -695,9 +693,7 @@ public abstract class AbstractJDBCDatabaseService extends AbstractService
|
||||
log.debug("Mapping row {} with {}", rs, mapper);
|
||||
final T object = mapper.map(rs);
|
||||
if (object instanceof Model) {
|
||||
if (((Model<?>) object).getObjectDesire() == ObjectDesire.INSERT) {
|
||||
((Model<?>) object).setObjectDesire(ObjectDesire.NONE);
|
||||
}
|
||||
((Model<?>) object).setObjectDesire(ObjectDesire.NONE);
|
||||
}
|
||||
log.debug("Mapper {} returned {}", mapper, object);
|
||||
return object;
|
||||
|
||||
@@ -120,6 +120,17 @@ public class Point3D extends Point {
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Point3D [" + coordinate.getX() + "," + coordinate.getY() + ","
|
||||
+ coordinate.getZ() + "," + angle + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance from the 3 points and an angle
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user