Rename and clean up AbstractMapleCharacterObject

This commit is contained in:
P0nk
2021-09-09 21:11:53 +02:00
parent 7dc3a2159a
commit da8837710a
2 changed files with 120 additions and 105 deletions

View File

@@ -37,10 +37,9 @@ import java.util.Map;
import java.util.concurrent.locks.Lock;
/**
*
* @author RonanLana
*/
public abstract class AbstractMapleCharacterObject extends AbstractAnimatedMapleMapObject {
public abstract class AbstractCharacterObject extends AbstractAnimatedMapleMapObject {
protected MapleMap map;
protected int str, dex, luk, int_, hp, maxhp, mp, maxmp;
protected int hpMpApUsed, remainingAp;
@@ -55,7 +54,7 @@ public abstract class AbstractMapleCharacterObject extends AbstractAnimatedMaple
protected MonitoredReadLock statRlock;
protected MonitoredWriteLock statWlock;
protected AbstractMapleCharacterObject() {
protected AbstractCharacterObject() {
MonitoredReentrantReadWriteLock locks = new MonitoredReentrantReadWriteLock(MonitoredLockType.CHARACTER_STA, true);
statRlock = MonitoredReadLockFactory.createLock(locks);
statWlock = MonitoredWriteLockFactory.createLock(locks);
@@ -240,7 +239,9 @@ public abstract class AbstractMapleCharacterObject extends AbstractAnimatedMaple
thp = localmaxhp;
}
if (this.hp != thp) this.transienthp = Float.NEGATIVE_INFINITY;
if (this.hp != thp) {
this.transienthp = Float.NEGATIVE_INFINITY;
}
this.hp = thp;
dispatchHpChanged(oldHp);
@@ -254,7 +255,9 @@ public abstract class AbstractMapleCharacterObject extends AbstractAnimatedMaple
tmp = localmaxmp;
}
if (this.mp != tmp) this.transientmp = Float.NEGATIVE_INFINITY;
if (this.mp != tmp) {
this.transientmp = Float.NEGATIVE_INFINITY;
}
this.mp = tmp;
}
@@ -267,13 +270,17 @@ public abstract class AbstractMapleCharacterObject extends AbstractAnimatedMaple
}
protected void setMaxHp(int hp_) {
if (this.maxhp < hp_) this.transienthp = Float.NEGATIVE_INFINITY;
if (this.maxhp < hp_) {
this.transienthp = Float.NEGATIVE_INFINITY;
}
this.maxhp = hp_;
this.clientmaxhp = Math.min(30000, hp_);
}
protected void setMaxMp(int mp_) {
if (this.maxmp < mp_) this.transientmp = Float.NEGATIVE_INFINITY;
if (this.maxmp < mp_) {
this.transientmp = Float.NEGATIVE_INFINITY;
}
this.maxmp = mp_;
this.clientmaxmp = Math.min(30000, mp_);
}
@@ -654,10 +661,18 @@ public abstract class AbstractMapleCharacterObject extends AbstractAnimatedMaple
}
int newStr = str, newDex = dex, newInt = int_, newLuk = luk;
if (deltaStr != null) newStr += deltaStr; // thanks Rohenn for noticing an NPE case after "null" started being used
if (deltaDex != null) newDex += deltaDex;
if (deltaInt != null) newInt += deltaInt;
if (deltaLuk != null) newLuk += deltaLuk;
if (deltaStr != null) {
newStr += deltaStr; // thanks Rohenn for noticing an NPE case after "null" started being used
}
if (deltaDex != null) {
newDex += deltaDex;
}
if (deltaInt != null) {
newInt += deltaInt;
}
if (deltaLuk != null) {
newLuk += deltaLuk;
}
if (newStr < 4 || newStr > YamlConfig.config.server.MAX_AP) {
return false;

View File

@@ -93,7 +93,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.regex.Pattern;
public class Character extends AbstractMapleCharacterObject {
public class Character extends AbstractCharacterObject {
private static final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
private static final String LEVEL_200 = "[Congrats] %s has reached Level %d! Congratulate %s on such an amazing achievement!";
private static final String[] BLOCKED_NAMES = {"admin", "owner", "moderator", "intern", "donor", "administrator", "FREDRICK", "help", "helper", "alert", "notice", "maplestory", "fuck", "wizet", "fucking", "negro", "fuk", "fuc", "penis", "pussy", "asshole", "gay",