Added setUpsideDown to PlayerDisguise
This commit is contained in:
parent
66a66b3638
commit
71dbaeebf5
@ -35,6 +35,8 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
@Setter
|
@Setter
|
||||||
private boolean dynamicName;
|
private boolean dynamicName;
|
||||||
private volatile DisguiseUtilities.DScoreTeam scoreboardName;
|
private volatile DisguiseUtilities.DScoreTeam scoreboardName;
|
||||||
|
@Getter
|
||||||
|
private boolean upsideDown;
|
||||||
|
|
||||||
private PlayerDisguise() {
|
private PlayerDisguise() {
|
||||||
super(DisguiseType.PLAYER);
|
super(DisguiseType.PLAYER);
|
||||||
@ -103,8 +105,12 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scoreboardName == null) {
|
if (scoreboardName == null) {
|
||||||
|
if (isUpsideDown()) {
|
||||||
|
scoreboardName = new DisguiseUtilities.DScoreTeam(new String[]{"", getProfileName(), ""});
|
||||||
|
} else {
|
||||||
scoreboardName = DisguiseUtilities.createExtendedName(getName());
|
scoreboardName = DisguiseUtilities.createExtendedName(getName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return scoreboardName;
|
return scoreboardName;
|
||||||
}
|
}
|
||||||
@ -126,7 +132,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return hasScoreboardName() ? getScoreboardName().getPlayer() : getName();
|
return isUpsideDown() ? "Dinnerbone" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUUID() {
|
public UUID getUUID() {
|
||||||
@ -185,6 +191,22 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
return (PlayerDisguise) super.addPlayer(playername);
|
return (PlayerDisguise) super.addPlayer(playername);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerDisguise setUpsideDown(boolean upsideDown) {
|
||||||
|
if (isUpsideDown() == upsideDown) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.upsideDown = upsideDown;
|
||||||
|
|
||||||
|
if (isDisguiseInUse()) {
|
||||||
|
resendDisguise(getName(), true);
|
||||||
|
} else {
|
||||||
|
scoreboardName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlayerDisguise clone() {
|
public PlayerDisguise clone() {
|
||||||
PlayerDisguise disguise = new PlayerDisguise();
|
PlayerDisguise disguise = new PlayerDisguise();
|
||||||
@ -201,6 +223,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
disguise.nameVisible = isNameVisible();
|
disguise.nameVisible = isNameVisible();
|
||||||
disguise.explicitNameVisible = explicitNameVisible;
|
disguise.explicitNameVisible = explicitNameVisible;
|
||||||
disguise.setDynamicName(isDynamicName());
|
disguise.setDynamicName(isDynamicName());
|
||||||
|
disguise.setUpsideDown(isUpsideDown());
|
||||||
|
|
||||||
clone(disguise);
|
clone(disguise);
|
||||||
|
|
||||||
@ -283,26 +306,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
resendDisguise;
|
resendDisguise;
|
||||||
|
|
||||||
if (resendDisguise) {
|
if (resendDisguise) {
|
||||||
if (stopDisguise()) {
|
resendDisguise(name, false);
|
||||||
if (getName().isEmpty() && !name.isEmpty()) {
|
|
||||||
setNameVisible(true, true);
|
|
||||||
} else if (!getName().isEmpty() && name.isEmpty()) {
|
|
||||||
setNameVisible(false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
playerName = name;
|
|
||||||
|
|
||||||
if (gameProfile != null) {
|
|
||||||
gameProfile = ReflectionManager
|
|
||||||
.getGameProfileWithThisSkin(uuid, getProfileName(), getGameProfile());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!startDisguise()) {
|
|
||||||
throw new IllegalStateException("Unable to restart disguise");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("Unable to restart disguise");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (getName().isEmpty() && !name.isEmpty() && !isNameVisible()) {
|
if (getName().isEmpty() && !name.isEmpty() && !isNameVisible()) {
|
||||||
setNameVisible(true, true);
|
setNameVisible(true, true);
|
||||||
@ -352,6 +356,32 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resendDisguise(String name, boolean updateTeams) {
|
||||||
|
if (stopDisguise()) {
|
||||||
|
if (getName().isEmpty() && !name.isEmpty()) {
|
||||||
|
setNameVisible(true, true);
|
||||||
|
} else if (!getName().isEmpty() && name.isEmpty()) {
|
||||||
|
setNameVisible(false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerName = name;
|
||||||
|
|
||||||
|
if (updateTeams) {
|
||||||
|
scoreboardName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameProfile != null) {
|
||||||
|
gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, getProfileName(), getGameProfile());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!startDisguise()) {
|
||||||
|
throw new IllegalStateException("Unable to restart disguise");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Unable to restart disguise");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getSkin() {
|
public String getSkin() {
|
||||||
return skinToUse;
|
return skinToUse;
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,10 @@ public class ParamInfoManager {
|
|||||||
if (watcherClass == PlayerWatcher.class) {
|
if (watcherClass == PlayerWatcher.class) {
|
||||||
try {
|
try {
|
||||||
methods.add(PlayerDisguise.class.getMethod("setDynamicName", boolean.class));
|
methods.add(PlayerDisguise.class.getMethod("setDynamicName", boolean.class));
|
||||||
|
|
||||||
|
if (DisguiseConfig.isArmorstandsName()) {
|
||||||
|
methods.add(PlayerDisguise.class.getMethod("setUpsideDown", boolean.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (NoSuchMethodException e) {
|
catch (NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user