Skip to content

Commit

Permalink
option to disable nick/skin disguise
Browse files Browse the repository at this point in the history
  • Loading branch information
InventivetalentDev committed Mar 27, 2021
1 parent 219bac3 commit 6e53aec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private GameProfileWrapper disguiseProfile(final Player observer, final GameProf
final OfflinePlayer toDisguise = Bukkit.getOfflinePlayer(id);

if (toDisguise == null /*|| !toDisguise.isOnline()*/) {
return profileWrapper;//Player to disguise doesn't exist
return null;//Player to disguise doesn't exist
}

boolean async = !getPlugin().getServer().isPrimaryThread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public class NickNamerPlugin extends JavaPlugin implements Listener, PluginMessa
final Executor storageExecutor = Executors.newSingleThreadExecutor();

// @ConfigValue(path = "replace.tab") boolean replaceTab;
@ConfigValue(path = "disguise.nick", defaultsTo = "true") boolean disguiseNick;
@ConfigValue(path = "disguise.skin", defaultsTo = "true") boolean disguiseSkin;

@ConfigValue(path = "replace.chat.player") boolean replaceChatPlayer;
@ConfigValue(path = "replace.chat.out") boolean replaceChatOut;
@ConfigValue(path = "replace.chat.in.general") boolean replaceChatInGeneral;
Expand Down Expand Up @@ -461,6 +464,10 @@ void parseListOrCategories(String path, Map<String, Collection<String>> target)
@EventHandler(priority = EventPriority.LOWEST)
public void on(final NickDisguiseEvent event) {
if (event.isCancelled()) { return; }
if (!disguiseNick) {
event.setCancelled(true);
return;
}
if (getAPI().isNicked(event.getDisguised().getUniqueId())) {
event.setNick(getAPI().getNick(event.getDisguised().getUniqueId()));

Expand All @@ -480,6 +487,10 @@ public void provide(@Nullable String nick) {
@EventHandler(priority = EventPriority.LOWEST)
public void on(final SkinDisguiseEvent event) {
if (event.isCancelled()) { return; }
if (!disguiseSkin) {
event.setCancelled(true);
return;
}
if (getAPI().hasSkin(event.getDisguised().getUniqueId())) {
event.setSkin(getAPI().getSkin(event.getDisguised().getUniqueId()));

Expand Down
4 changes: 4 additions & 0 deletions Plugin/src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
disguise:
# Disguise nick & skin; disable both to prevent GameProfile packets from being modified
nick: true
skin: true
replace:
chat:
# Replace names in messages sent by players
Expand Down

0 comments on commit 6e53aec

Please sign in to comment.