Add better updating, add %user-displayname% and target

This commit is contained in:
libraryaddict
2020-08-11 08:28:43 +12:00
parent 9ffbd9e272
commit e5304f19e2
4 changed files with 50 additions and 19 deletions

View File

@@ -9,6 +9,7 @@ import me.libraryaddict.disguise.commands.modify.DisguiseModifyEntityCommand;
import me.libraryaddict.disguise.commands.modify.DisguiseModifyPlayerCommand;
import me.libraryaddict.disguise.commands.modify.DisguiseModifyRadiusCommand;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.params.ParamInfo;
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
@@ -210,17 +211,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
}
protected String getDisplayName(CommandSender player) {
Team team = ((Player) player).getScoreboard().getEntryTeam(player.getName());
if (team == null) {
team = ((Player) player).getScoreboard().getEntryTeam(((Player) player).getUniqueId().toString());
}
if (team == null || (StringUtils.isEmpty(team.getPrefix()) && StringUtils.isEmpty(team.getSuffix()))) {
return ((Player) player).getDisplayName();
}
return team.getPrefix() + team.getColor() + player.getName() + team.getSuffix();
return DisguiseUtilities.getDisplayName(player);
}
protected ArrayList<String> getAllowedDisguises(DisguisePermissions permissions) {

View File

@@ -40,10 +40,12 @@ public class LDUpdate implements LDCommand {
}
boolean releaseBuilds = checker.isUsingReleaseBuilds();
boolean forceUpdate = args[0].endsWith("!");
boolean forceCheck = args[0].endsWith("?") || args.length > 1 || forceUpdate;
boolean wantsDownload = args[0].endsWith("!");
boolean wantsCheck = args[0].endsWith("?");
if (args.length > 1) {
boolean previous = releaseBuilds;
if (args[1].equalsIgnoreCase("dev")) {
releaseBuilds = false;
} else if (args[1].equalsIgnoreCase("release")) {
@@ -53,11 +55,16 @@ public class LDUpdate implements LDCommand {
return;
}
if (previous != releaseBuilds && !wantsCheck) {
wantsDownload = true;
}
wantsCheck = true;
DisguiseConfig.setUsingReleaseBuilds(releaseBuilds);
}
if (checker.getUpdate() != null && checker.getUpdate().isReleaseBuild() == releaseBuilds && args.length <= 1 &&
!forceCheck) {
if (checker.getUpdate() != null && checker.getUpdate().isReleaseBuild() == releaseBuilds && !wantsCheck) {
if (checker.isServerLatestVersion()) {
LibsMsg.UPDATE_ON_LATEST.send(sender);
return;
@@ -69,12 +76,15 @@ public class LDUpdate implements LDCommand {
}
}
boolean finalWantsCheck = wantsCheck;
boolean finalWantsDownload = wantsDownload;
new BukkitRunnable() {
@Override
public void run() {
LibsMsg updateResult = null;
if (checker.getUpdate() == null || args.length > 1 || checker.isOldUpdate() || forceCheck) {
if (checker.getUpdate() == null || args.length > 1 || checker.isOldUpdate() || finalWantsCheck) {
updateResult = checker.doUpdateCheck();
}
@@ -83,7 +93,7 @@ public class LDUpdate implements LDCommand {
return;
}
if (checker.isOnLatestUpdate(true)) {
if (checker.isOnLatestUpdate(true) && !finalWantsDownload) {
if (checker.getLastDownload() != null) {
LibsMsg.UPDATE_ALREADY_DOWNLOADED.send(sender);
} else {
@@ -93,7 +103,7 @@ public class LDUpdate implements LDCommand {
return;
}
if (!forceUpdate) {
if (!finalWantsDownload) {
if (updateResult != null) {
updateResult.send(sender);
} else {