Setting viewSelfDisguise on the disguise now updates it
This commit is contained in:
parent
c56972d7dd
commit
8ebd632363
2
pom.xml
2
pom.xml
@ -64,7 +64,7 @@
|
|||||||
<version>2.5.0</version>
|
<version>2.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<version>7.3</version>
|
<version>7.3-SNAPSHOT</version>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
|
@ -382,4 +382,8 @@ public class DisguiseAPI {
|
|||||||
public void removeVisibleDisguise(Player player) {
|
public void removeVisibleDisguise(Player player) {
|
||||||
removeSelfDisguise(player);
|
removeSelfDisguise(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setupFakeDisguise(Disguise disguise) {
|
||||||
|
setupPlayerFakeDisguise(disguise);
|
||||||
|
}
|
||||||
}
|
}
|
@ -204,45 +204,6 @@ public class Disguise {
|
|||||||
return disguise;
|
return disguise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the disguise and undisguises the entity if its using this disguise. This doesn't fire a UndisguiseEvent
|
|
||||||
*/
|
|
||||||
public void removeDisguise() {
|
|
||||||
// Why the hell can't I safely check if its running?!?!
|
|
||||||
try {
|
|
||||||
runnable.cancel();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
HashMap<Integer, Disguise> disguises = disguiseAPI.getDisguises();
|
|
||||||
// If this disguise has a entity set
|
|
||||||
if (getEntity() != null) {
|
|
||||||
// If the entity is valid
|
|
||||||
if (((CraftEntity) getEntity()).getHandle().valid) {
|
|
||||||
// If this disguise is active
|
|
||||||
if (disguises.containsKey(getEntity().getEntityId()) && disguises.get(getEntity().getEntityId()) == this) {
|
|
||||||
// Now remove the disguise from the current disguises.
|
|
||||||
disguises.remove(getEntity().getEntityId());
|
|
||||||
// Gotta do reflection, copy code or open up calls.
|
|
||||||
// Reflection is the cleanest?
|
|
||||||
if (entity instanceof Player) {
|
|
||||||
disguiseAPI.removeVisibleDisguise((Player) entity);
|
|
||||||
}
|
|
||||||
// Better refresh the entity to undisguise it
|
|
||||||
disguiseAPI.refreshWatchingPlayers(getEntity());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Loop through the disguises because it could be used with a unknown entity id.
|
|
||||||
Iterator<Integer> itel = disguises.keySet().iterator();
|
|
||||||
while (itel.hasNext()) {
|
|
||||||
int id = itel.next();
|
|
||||||
if (disguises.get(id) == this) {
|
|
||||||
itel.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj)
|
||||||
@ -317,6 +278,45 @@ public class Disguise {
|
|||||||
return velocitySent;
|
return velocitySent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the disguise and undisguises the entity if its using this disguise. This doesn't fire a UndisguiseEvent
|
||||||
|
*/
|
||||||
|
public void removeDisguise() {
|
||||||
|
// Why the hell can't I safely check if its running?!?!
|
||||||
|
try {
|
||||||
|
runnable.cancel();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
|
HashMap<Integer, Disguise> disguises = disguiseAPI.getDisguises();
|
||||||
|
// If this disguise has a entity set
|
||||||
|
if (getEntity() != null) {
|
||||||
|
// If the entity is valid
|
||||||
|
if (((CraftEntity) getEntity()).getHandle().valid) {
|
||||||
|
// If this disguise is active
|
||||||
|
if (disguises.containsKey(getEntity().getEntityId()) && disguises.get(getEntity().getEntityId()) == this) {
|
||||||
|
// Now remove the disguise from the current disguises.
|
||||||
|
disguises.remove(getEntity().getEntityId());
|
||||||
|
// Gotta do reflection, copy code or open up calls.
|
||||||
|
// Reflection is the cleanest?
|
||||||
|
if (entity instanceof Player) {
|
||||||
|
disguiseAPI.removeVisibleDisguise((Player) entity);
|
||||||
|
}
|
||||||
|
// Better refresh the entity to undisguise it
|
||||||
|
disguiseAPI.refreshWatchingPlayers(getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Loop through the disguises because it could be used with a unknown entity id.
|
||||||
|
Iterator<Integer> itel = disguises.keySet().iterator();
|
||||||
|
while (itel.hasNext()) {
|
||||||
|
int id = itel.next();
|
||||||
|
if (disguises.get(id) == this) {
|
||||||
|
itel.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean replaceSounds() {
|
public boolean replaceSounds() {
|
||||||
return replaceSounds;
|
return replaceSounds;
|
||||||
}
|
}
|
||||||
@ -424,7 +424,17 @@ public class Disguise {
|
|||||||
* Can the disguised view himself as the disguise
|
* Can the disguised view himself as the disguise
|
||||||
*/
|
*/
|
||||||
public void setViewSelfDisguise(boolean viewSelfDisguise) {
|
public void setViewSelfDisguise(boolean viewSelfDisguise) {
|
||||||
|
if (this.viewSelfDisguise != viewSelfDisguise) {
|
||||||
this.viewSelfDisguise = viewSelfDisguise;
|
this.viewSelfDisguise = viewSelfDisguise;
|
||||||
|
if (getEntity() != null && getEntity() instanceof Player) {
|
||||||
|
if (DisguiseAPI.getDisguise(getEntity()) == this) {
|
||||||
|
if (viewSelfDisguise) {
|
||||||
|
disguiseAPI.setupFakeDisguise(this);
|
||||||
|
} else
|
||||||
|
disguiseAPI.removeVisibleDisguise((Player) getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWatcher(FlagWatcher newWatcher) {
|
public void setWatcher(FlagWatcher newWatcher) {
|
||||||
|
Loading…
Reference in New Issue
Block a user