mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
Add prefix/suffix toggle for playerlist. Resolves #771
This commit adds two new configurable options: - `add-prefix-in-playerlist`: enable prefix in playerlist - `add-suffix-in-playerlist`: enable suffix in playerlist These were added to prevent very long names in the playerlist.
This commit is contained in:
parent
30d5fbdf8d
commit
63b5cb9ec7
4 changed files with 31 additions and 3 deletions
|
@ -269,4 +269,8 @@ public interface ISettings extends IConf {
|
||||||
boolean isPastebinCreateKit();
|
boolean isPastebinCreateKit();
|
||||||
|
|
||||||
boolean isAllowBulkBuySell();
|
boolean isAllowBulkBuySell();
|
||||||
|
|
||||||
|
boolean isAddingPrefixInPlayerlist();
|
||||||
|
|
||||||
|
boolean isAddingSuffixInPlayerlist();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1364,4 +1364,14 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
public boolean isAllowBulkBuySell() {
|
public boolean isAllowBulkBuySell() {
|
||||||
return config.getBoolean("allow-bulk-buy-sell", false);
|
return config.getBoolean("allow-bulk-buy-sell", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAddingPrefixInPlayerlist() {
|
||||||
|
return config.getBoolean("add-prefix-in-playerlist", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAddingSuffixInPlayerlist() {
|
||||||
|
return config.getBoolean("add-suffix-in-playerlist", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,6 +253,10 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNick(final boolean longnick) {
|
public String getNick(final boolean longnick) {
|
||||||
|
return getNick(longnick, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNick(final boolean longnick, final boolean withPrefix, final boolean withSuffix) {
|
||||||
final StringBuilder prefix = new StringBuilder();
|
final StringBuilder prefix = new StringBuilder();
|
||||||
String nickname;
|
String nickname;
|
||||||
String suffix = "";
|
String suffix = "";
|
||||||
|
@ -279,12 +283,12 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||||
|
|
||||||
if (ess.getSettings().addPrefixSuffix()) {
|
if (ess.getSettings().addPrefixSuffix()) {
|
||||||
//These two extra toggles are not documented, because they are mostly redundant #EasterEgg
|
//These two extra toggles are not documented, because they are mostly redundant #EasterEgg
|
||||||
if (!ess.getSettings().disablePrefix()) {
|
if (withPrefix || !ess.getSettings().disablePrefix()) {
|
||||||
final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
|
final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
|
||||||
prefix.insert(0, ptext);
|
prefix.insert(0, ptext);
|
||||||
suffix = "§r";
|
suffix = "§r";
|
||||||
}
|
}
|
||||||
if (!ess.getSettings().disableSuffix()) {
|
if (withSuffix || !ess.getSettings().disableSuffix()) {
|
||||||
final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
|
final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
|
||||||
suffix = stext + "§r";
|
suffix = stext + "§r";
|
||||||
suffix = suffix.replace("§f§f", "§f").replace("§f§r", "§r").replace("§r§r", "§r");
|
suffix = suffix.replace("§f§f", "§f").replace("§f§r", "§r").replace("§r§r", "§r");
|
||||||
|
@ -314,7 +318,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||||
// 1.8 enabled player list-names longer than 16 characters.
|
// 1.8 enabled player list-names longer than 16 characters.
|
||||||
// If the server is on 1.8 or higher, provide that functionality. Otherwise, keep prior functionality.
|
// If the server is on 1.8 or higher, provide that functionality. Otherwise, keep prior functionality.
|
||||||
boolean higherOrEqualTo1_8 = ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_8_R1);
|
boolean higherOrEqualTo1_8 = ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_8_R1);
|
||||||
String name = getNick(higherOrEqualTo1_8);
|
String name = getNick(higherOrEqualTo1_8, ess.getSettings().isAddingPrefixInPlayerlist(), ess.getSettings().isAddingSuffixInPlayerlist());
|
||||||
try {
|
try {
|
||||||
this.getBase().setPlayerListName(name);
|
this.getBase().setPlayerListName(name);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
|
|
@ -45,6 +45,16 @@ change-displayname: true
|
||||||
# Do not edit this setting unless you know what you are doing!
|
# Do not edit this setting unless you know what you are doing!
|
||||||
#add-prefix-suffix: false
|
#add-prefix-suffix: false
|
||||||
|
|
||||||
|
# When this option is enabled, player prefixes will be shown in the playerlist.
|
||||||
|
# This feature only works for Minecraft version 1.8 and higher.
|
||||||
|
# This value of change-playerlist has to be true
|
||||||
|
#add-prefix-in-playerlist: true
|
||||||
|
|
||||||
|
# When this option is enabled, player suffixes will be shown in the playerlist.
|
||||||
|
# This feature only works for Minecraft version 1.8 and higher.
|
||||||
|
# This value of change-playerlist has to be true
|
||||||
|
#add-suffix-in-playerlist: true
|
||||||
|
|
||||||
# If the teleport destination is unsafe, should players be teleported to the nearest safe location?
|
# If the teleport destination is unsafe, should players be teleported to the nearest safe location?
|
||||||
# If this is set to true, Essentials will attempt to teleport players close to the intended destination.
|
# If this is set to true, Essentials will attempt to teleport players close to the intended destination.
|
||||||
# If this is set to false, attempted teleports to unsafe locations will be cancelled with a warning.
|
# If this is set to false, attempted teleports to unsafe locations will be cancelled with a warning.
|
||||||
|
|
Loading…
Reference in a new issue