Tiny code cleanup

This commit is contained in:
libraryaddict 2020-06-13 17:24:46 +12:00
parent c4717d7453
commit 929f705d0e
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
3 changed files with 36 additions and 57 deletions

View File

@ -46,7 +46,7 @@ public class FlagWatcher {
@Getter(value = AccessLevel.PROTECTED)
private HashMap<Integer, Object> entityValues = new HashMap<>();
private LibsEquipment equipment;
private boolean hasDied;
private transient boolean hasDied;
@Getter
private boolean[] modifiedEntityAnimations = new boolean[8];
private transient List<WrappedWatchableObject> watchableObjects;

View File

@ -3,36 +3,29 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
public class AgeableWatcher extends InsentientWatcher
{
public AgeableWatcher(Disguise disguise)
{
public class AgeableWatcher extends InsentientWatcher {
public AgeableWatcher(Disguise disguise) {
super(disguise);
}
public boolean isAdult()
{
public boolean isAdult() {
return !isBaby();
}
public boolean isBaby()
{
public boolean isBaby() {
return getData(MetaIndex.AGEABLE_BABY);
}
public void setAdult()
{
setBaby(false);
}
public void setBaby()
{
setBaby(true);
}
public void setBaby(boolean isBaby)
{
public void setBaby(boolean isBaby) {
setData(MetaIndex.AGEABLE_BABY, isBaby);
sendData(MetaIndex.AGEABLE_BABY);
}
public void setAdult() {
setBaby(false);
}
public void setBaby() {
setBaby(true);
}
}

View File

@ -6,63 +6,49 @@ import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import java.util.Optional;
import java.util.UUID;
public class TameableWatcher extends AgeableWatcher
{
public TameableWatcher(Disguise disguise)
{
public class TameableWatcher extends AgeableWatcher {
public TameableWatcher(Disguise disguise) {
super(disguise);
}
public Optional<UUID> getOwner()
{
public Optional<UUID> getOwner() {
return getData(MetaIndex.TAMEABLE_OWNER);
}
public boolean isSitting()
{
public void setOwner(UUID owner) {
setData(MetaIndex.TAMEABLE_OWNER, Optional.of(owner));
sendData(MetaIndex.TAMEABLE_OWNER);
}
public boolean isSitting() {
return isTameableFlag(1);
}
public boolean isTamed()
{
public void setSitting(boolean sitting) {
setTameableFlag(1, sitting);
}
public boolean isTamed() {
return isTameableFlag(4);
}
protected boolean isTameableFlag(int no)
{
public void setTamed(boolean tamed) {
setTameableFlag(4, tamed);
}
protected boolean isTameableFlag(int no) {
return (getData(MetaIndex.TAMEABLE_META) & no) != 0;
}
protected void setTameableFlag(int no, boolean flag)
{
protected void setTameableFlag(int no, boolean flag) {
byte value = getData(MetaIndex.TAMEABLE_META);
if (flag)
{
if (flag) {
setData(MetaIndex.TAMEABLE_META, (byte) (value | no));
}
else
{
} else {
setData(MetaIndex.TAMEABLE_META, (byte) (value & -(no + 1)));
}
sendData(MetaIndex.TAMEABLE_META);
}
public void setOwner(UUID owner)
{
setData(MetaIndex.TAMEABLE_OWNER, Optional.of(owner));
sendData(MetaIndex.TAMEABLE_OWNER);
}
public void setSitting(boolean sitting)
{
setTameableFlag(1, sitting);
}
public void setTamed(boolean tamed)
{
setTameableFlag(4, tamed);
}
}