Fixed some bad naming and configuration for scoreboards

This commit is contained in:
libraryaddict 2017-02-24 01:28:37 +13:00
parent 82db8d190b
commit 6fa6979916
2 changed files with 13 additions and 9 deletions

View File

@ -16,7 +16,7 @@ import me.libraryaddict.disguise.utilities.PacketsManager;
public class DisguiseConfig { public class DisguiseConfig {
public static enum DisguisePushing { public static enum DisguisePushing {
MODIFY, IGNORE, CREATE; MODIFY_SCOREBOARD, IGNORE_SCOREBOARD, CREATE_SCOREBOARD;
} }
private static boolean animationEnabled; private static boolean animationEnabled;
@ -146,11 +146,15 @@ public class DisguiseConfig {
setDisabledInvisibility(config.getBoolean("DisableInvisibility")); setDisabledInvisibility(config.getBoolean("DisableInvisibility"));
try { try {
disablePushing = DisguisePushing String option = config.getString("SelfDisguisesScoreboard", DisguisePushing.MODIFY_SCOREBOARD.name()).toUpperCase();
.valueOf(config.getString("DisablePushing", DisguisePushing.MODIFY.name()).toUpperCase());
if (!option.endsWith("_SCOREBOARD"))
option += "_SCOREBOARD";
disablePushing = DisguisePushing.valueOf(option);
} }
catch (Exception ex) { catch (Exception ex) {
System.out.println("[LibsDisguises] Cannot parse '" + config.getString("SelfDisguisesTeams") System.out.println("[LibsDisguises] Cannot parse '" + config.getString("SelfDisguisesScoreboard")
+ "' to a valid option for SelfDisguisesTeam"); + "' to a valid option for SelfDisguisesTeam");
} }

View File

@ -1033,7 +1033,7 @@ public class DisguiseUtilities {
String prevTeam = previousTeam.remove(player.getUniqueId()); String prevTeam = previousTeam.remove(player.getUniqueId());
if (DisguiseConfig.getPushingOption() != DisguisePushing.IGNORE) { if (DisguiseConfig.getPushingOption() != DisguisePushing.IGNORE_SCOREBOARD) {
// Code to stop player pushing in 1.9 // Code to stop player pushing in 1.9
Scoreboard scoreboard = player.getScoreboard(); Scoreboard scoreboard = player.getScoreboard();
Team team = prevTeam == null ? null : scoreboard.getTeam(prevTeam); Team team = prevTeam == null ? null : scoreboard.getTeam(prevTeam);
@ -1133,19 +1133,19 @@ public class DisguiseUtilities {
DisguisePushing pOption = DisguiseConfig.getPushingOption(); DisguisePushing pOption = DisguiseConfig.getPushingOption();
if (pOption != DisguisePushing.IGNORE) { if (pOption != DisguisePushing.IGNORE_SCOREBOARD) {
// Code to stop player pushing // Code to stop player pushing
Scoreboard scoreboard = player.getScoreboard(); Scoreboard scoreboard = player.getScoreboard();
Team prevTeam = scoreboard.getEntryTeam(player.getName()); Team prevTeam = scoreboard.getEntryTeam(player.getName());
if (prevTeam != null && pOption == DisguisePushing.CREATE) { if (prevTeam != null && pOption == DisguisePushing.CREATE_SCOREBOARD) {
previousTeam.put(player.getUniqueId(), prevTeam.getName()); previousTeam.put(player.getUniqueId(), prevTeam.getName());
} }
Team t; Team t;
String createName = null; String createName = null;
if (pOption == DisguisePushing.CREATE) { if (pOption == DisguisePushing.CREATE_SCOREBOARD) {
createName = (prevTeam == null ? "No Team" : prevTeam.getName()); createName = (prevTeam == null ? "No Team" : prevTeam.getName());
createName = createName.substring(0, Math.min(12, createName.length())); createName = createName.substring(0, Math.min(12, createName.length()));
@ -1169,7 +1169,7 @@ public class DisguiseUtilities {
if (!t.hasEntry(player.getName())) if (!t.hasEntry(player.getName()))
t.addEntry(player.getName()); t.addEntry(player.getName());
if (pOption == DisguisePushing.CREATE && prevTeam != null) { if (pOption == DisguisePushing.CREATE_SCOREBOARD && prevTeam != null) {
t.setAllowFriendlyFire(prevTeam.allowFriendlyFire()); t.setAllowFriendlyFire(prevTeam.allowFriendlyFire());
t.setCanSeeFriendlyInvisibles(prevTeam.canSeeFriendlyInvisibles()); t.setCanSeeFriendlyInvisibles(prevTeam.canSeeFriendlyInvisibles());
t.setDisplayName(prevTeam.getDisplayName()); t.setDisplayName(prevTeam.getDisplayName());