Fixed the no nick case and other stuff
This commit is contained in:
parent
0883739861
commit
ed858502f4
1 changed files with 13 additions and 24 deletions
|
@ -1,6 +1,7 @@
|
||||||
package buttondevteam.chat;
|
package buttondevteam.chat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
@ -107,6 +108,7 @@ public class PlayerListener implements Listener {
|
||||||
cp.SetFlair(ChatPlayer.FlairTimeNone);
|
cp.SetFlair(ChatPlayer.FlairTimeNone);
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Player player = Bukkit.getPlayer(mp.PlayerName);
|
Player player = Bukkit.getPlayer(mp.PlayerName);
|
||||||
|
@ -131,14 +133,13 @@ public class PlayerListener implements Listener {
|
||||||
|
|
||||||
String nwithoutformatting = essentials.getUser(p).getNickname();
|
String nwithoutformatting = essentials.getUser(p).getNickname();
|
||||||
int index;
|
int index;
|
||||||
|
if (nwithoutformatting != null) {
|
||||||
while ((index = nwithoutformatting.indexOf("§k")) != -1)
|
while ((index = nwithoutformatting.indexOf("§k")) != -1)
|
||||||
nwithoutformatting = nwithoutformatting.replace("§k" + nwithoutformatting.charAt(index + 2), ""); // Support
|
nwithoutformatting = nwithoutformatting.replace("§k" + nwithoutformatting.charAt(index + 2), ""); // Support for one random char
|
||||||
// for
|
|
||||||
// one
|
|
||||||
// random
|
|
||||||
// char
|
|
||||||
while ((index = nwithoutformatting.indexOf('§')) != -1)
|
while ((index = nwithoutformatting.indexOf('§')) != -1)
|
||||||
nwithoutformatting = nwithoutformatting.replace("§" + nwithoutformatting.charAt(index + 1), "");
|
nwithoutformatting = nwithoutformatting.replace("§" + nwithoutformatting.charAt(index + 1), "");
|
||||||
|
} else
|
||||||
|
nwithoutformatting = p.getName();
|
||||||
nicknames.put(nwithoutformatting, p.getUniqueId());
|
nicknames.put(nwithoutformatting, p.getUniqueId());
|
||||||
|
|
||||||
cp.RPMode = true;
|
cp.RPMode = true;
|
||||||
|
@ -365,22 +366,10 @@ 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 (String nickname : nicknames.keySet()) {
|
for (Entry<String, UUID> nicknamekv : nicknames.entrySet()) {
|
||||||
if (nickname.startsWith(name) && !nickname.equals(Bukkit.getPlayer(nicknames.get(nickname)).getName()))
|
if (nicknamekv.getKey().startsWith(name)
|
||||||
e.getTabCompletions().add(nickname);
|
&& !nicknamekv.getKey().equals(Bukkit.getPlayer(nicknamekv.getValue()).getName()))
|
||||||
}
|
e.getTabCompletions().add(nicknamekv.getKey());
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean DebugMode = false;
|
|
||||||
|
|
||||||
public void SendForDebug(String message) {
|
|
||||||
if (DebugMode) {
|
|
||||||
for (Player player : PluginMain.GetPlayers()) {
|
|
||||||
if (player.getName().equals("NorbiPeti")) {
|
|
||||||
player.sendMessage("[DEBUG] " + message);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue