Skip to content

Commit

Permalink
added config option to disable anti-override for nicknames
Browse files Browse the repository at this point in the history
  • Loading branch information
NEZNAMY committed Mar 29, 2021
1 parent 88d3c94 commit ae259a8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/main/java/me/neznamy/tab/shared/features/Playerlist.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ public class Playerlist implements JoinEventListener, Loadable, WorldChangeListe
private TAB tab;
private List<String> usedPlaceholders;
public List<String> disabledWorlds;
private boolean antiOverrideNames;

public Playerlist(TAB tab) {
this.tab = tab;
disabledWorlds = tab.getConfiguration().config.getStringList("disable-features-in-"+tab.getPlatform().getSeparatorType()+"s.tablist-names", Arrays.asList("disabled" + tab.getPlatform().getSeparatorType()));
antiOverrideNames = tab.getConfiguration().config.getBoolean("anti-override.usernames", true);
refreshUsedPlaceholders();
if (tab.getConfiguration().config.getBoolean("anti-override.tablist-names", true)) {
tab.getFeatureManager().registerFeature("playerlist_info", new PlayerInfoPacketListener() {
Expand All @@ -49,8 +51,8 @@ public void onPacketSend(TabPlayer receiver, PacketPlayOutPlayerInfo info) {
if (packetPlayer != null && !isDisabledWorld(disabledWorlds, packetPlayer.getWorldName())) {
playerInfoData.displayName = getTabFormat(packetPlayer, receiver);
//preventing plugins from changing player name as nametag feature would not work correctly
if (ADD && tab.getFeatureManager().getNameTagFeature() != null && !playerInfoData.name.equals(packetPlayer.getName())) {
tab.getErrorManager().printError("Blocking name change of player " + packetPlayer.getName() + " to \"" + playerInfoData.name + "\" for viewer " + receiver.getName(), null, false, tab.getErrorManager().antiOverrideLog);
if (ADD && tab.getFeatureManager().getNameTagFeature() != null && !playerInfoData.name.equals(packetPlayer.getName()) && antiOverrideNames) {
tab.getErrorManager().printError("A plugin tried to change name of " + packetPlayer.getName() + " to \"" + playerInfoData.name + "\" for viewer " + receiver.getName(), null, false, tab.getErrorManager().antiOverrideLog);
playerInfoData.name = packetPlayer.getName();
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/bukkitconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,5 @@ anti-override:
scoreboard-teams: true
scoreboard-objectives: true
tablist-names: true
header-footer: true
header-footer: true
usernames: true
3 changes: 2 additions & 1 deletion src/main/resources/bungeeconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,5 @@ anti-override:
scoreboard-teams: true
scoreboard-objectives: true
tablist-names: true
header-footer: true
header-footer: true
usernames: true

0 comments on commit ae259a8

Please sign in to comment.