Re-added nickname map... Fixes
This commit is contained in:
parent
71242cc0ac
commit
ef2328e126
4 changed files with 47 additions and 39 deletions
|
@ -128,7 +128,7 @@ public class ChatPlayer extends TBMCPlayerBase {
|
||||||
return 0x6;
|
return 0x6;
|
||||||
else if (flairTime <= 11 && flairTime >= 0)
|
else if (flairTime <= 11 && flairTime >= 0)
|
||||||
return 0xc;
|
return 0xc;
|
||||||
return 0xf;
|
return 0x00; //Return 0 if none or too high, so names will get aqua default color, not white
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getF() {
|
public double getF() {
|
||||||
|
|
|
@ -276,11 +276,11 @@ public class ChatProcessing {
|
||||||
if (addNickFormatter)
|
if (addNickFormatter)
|
||||||
formatters.add(ChatFormatter.builder().regex((Pattern.compile(nicksb.toString()))).color(Color.Aqua)
|
formatters.add(ChatFormatter.builder().regex((Pattern.compile(nicksb.toString()))).color(Color.Aqua)
|
||||||
.onmatch((match, builder) -> {
|
.onmatch((match, builder) -> {
|
||||||
if (PlayerListener.nicknames.containsKey(match)) {
|
if (PlayerListener.nicknames.containsKey(match.toLowerCase())) { //Made a stream and all that but I can actually store it lowercased
|
||||||
Player p = Bukkit.getPlayer(PlayerListener.nicknames.get(match));
|
Player p = Bukkit.getPlayer(PlayerListener.nicknames.get(match.toLowerCase()));
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
PluginMain.Instance.getLogger().warning("Error: Can't find player nicknamed "
|
PluginMain.Instance.getLogger().warning("Error: Can't find player nicknamed "
|
||||||
+ match + " but was reported as online.");
|
+ match.toLowerCase() + " but was reported as online.");
|
||||||
return "§c" + match + "§r";
|
return "§c" + match + "§r";
|
||||||
}
|
}
|
||||||
if (PlayerListener.NotificationSound == null)
|
if (PlayerListener.NotificationSound == null)
|
||||||
|
@ -290,7 +290,7 @@ public class ChatProcessing {
|
||||||
(float) PlayerListener.NotificationPitch);
|
(float) PlayerListener.NotificationPitch);
|
||||||
return PluginMain.essentials.getUser(p).getNickname();
|
return PluginMain.essentials.getUser(p).getNickname();
|
||||||
}
|
}
|
||||||
Bukkit.getServer().getLogger().warning("Player nicknamed " + match
|
Bukkit.getServer().getLogger().warning("Player nicknamed " + match.toLowerCase()
|
||||||
+ " not found in nickname map but was reported as online.");
|
+ " not found in nickname map but was reported as online.");
|
||||||
return "§c" + match + "§r";
|
return "§c" + match + "§r";
|
||||||
}).priority(Priority.High).build());
|
}).priority(Priority.High).build());
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class PlayerJoinLeaveListener implements Listener {
|
||||||
nwithoutformatting = nwithoutformatting.replace("§" + nwithoutformatting.charAt(index + 1), "");
|
nwithoutformatting = nwithoutformatting.replace("§" + nwithoutformatting.charAt(index + 1), "");
|
||||||
} else
|
} else
|
||||||
nwithoutformatting = p.getName();
|
nwithoutformatting = p.getName();
|
||||||
PlayerListener.nicknames.put(nwithoutformatting, p.getUniqueId());
|
PlayerListener.nicknames.forcePut(nwithoutformatting.toLowerCase(), p.getUniqueId());
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(PluginMain.Instance, () -> {
|
Bukkit.getScheduler().runTaskLater(PluginMain.Instance, () -> {
|
||||||
updatePlayerColors(p, cp); //TODO: Doesn't have effect
|
updatePlayerColors(p, cp); //TODO: Doesn't have effect
|
||||||
|
|
|
@ -12,6 +12,8 @@ import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
import buttondevteam.lib.player.ChromaGamerBase.InfoTarget;
|
import buttondevteam.lib.player.ChromaGamerBase.InfoTarget;
|
||||||
import buttondevteam.lib.player.TBMCPlayer;
|
import buttondevteam.lib.player.TBMCPlayer;
|
||||||
import buttondevteam.lib.player.TBMCPlayerGetInfoEvent;
|
import buttondevteam.lib.player.TBMCPlayerGetInfoEvent;
|
||||||
|
import com.google.common.collect.BiMap;
|
||||||
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.vexsoftware.votifier.model.Vote;
|
import com.vexsoftware.votifier.model.Vote;
|
||||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||||
import net.ess3.api.events.NickChangeEvent;
|
import net.ess3.api.events.NickChangeEvent;
|
||||||
|
@ -31,11 +33,17 @@ import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
|
/**
|
||||||
|
* Does not contain format codes, lowercased
|
||||||
|
*/
|
||||||
|
public static BiMap<String, UUID> nicknames = HashBiMap.create();
|
||||||
|
|
||||||
public static boolean Enable = false;
|
public static boolean Enable = false;
|
||||||
|
|
||||||
public static int LoginWarningCountTotal = 5;
|
public static int LoginWarningCountTotal = 5;
|
||||||
|
@ -162,10 +170,9 @@ public class PlayerListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTabComplete(PlayerChatTabCompleteEvent e) {
|
public void onTabComplete(PlayerChatTabCompleteEvent e) {
|
||||||
String name = e.getLastToken();
|
String name = e.getLastToken();
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Entry<String, UUID> nicknamekv : nicknames.entrySet()) {
|
||||||
String displayName = ChatColor.stripColor(p.getDisplayName());
|
if (nicknamekv.getKey().startsWith(name.toLowerCase()))
|
||||||
if (displayName.startsWith(name))
|
e.getTabCompletions().add(Bukkit.getPlayer(nicknamekv.getValue()).getName()); //Tabcomplete with the correct case
|
||||||
e.getTabCompletions().add(displayName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,6 +293,7 @@ public class PlayerListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onNickChange(NickChangeEvent e) {
|
public void onNickChange(NickChangeEvent e) {
|
||||||
|
nicknames.inverse().forcePut(e.getAffected().getBase().getUniqueId(), ChatColor.stripColor(e.getValue()).toLowerCase());
|
||||||
//PlayerJoinLeaveListener.updatePlayerColors(e.getAffected().getBase()); //Won't fire this event again
|
//PlayerJoinLeaveListener.updatePlayerColors(e.getAffected().getBase()); //Won't fire this event again
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(PluginMain.Instance, () -> {
|
Bukkit.getScheduler().runTaskLater(PluginMain.Instance, () -> {
|
||||||
|
|
Loading…
Reference in a new issue