Fixed error when nobody is online
This commit is contained in:
parent
1e95f3773a
commit
dfdd6eec87
2 changed files with 76 additions and 61 deletions
Binary file not shown.
|
@ -104,65 +104,20 @@ public class ChatProcessing {
|
||||||
* , colormode, url, colormode, url));
|
* , colormode, url, colormode, url));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
if (PluginMain.GetPlayers().size() > 0) {
|
||||||
sb.append("(?i)(");
|
StringBuilder sb = new StringBuilder();
|
||||||
for (Player p : PluginMain.GetPlayers())
|
sb.append("(?i)(");
|
||||||
sb.append(p.getName()).append("|");
|
for (Player p : PluginMain.GetPlayers())
|
||||||
sb.deleteCharAt(sb.length() - 1);
|
sb.append(p.getName()).append("|");
|
||||||
sb.append(")");
|
sb.deleteCharAt(sb.length() - 1);
|
||||||
|
sb.append(")");
|
||||||
|
|
||||||
formatters.add(new ChatFormatter(Pattern.compile(sb.toString()),
|
formatters
|
||||||
ChatFormatter.Color.Aqua, (String match) -> {
|
.add(new ChatFormatter(
|
||||||
Player p = Bukkit.getPlayer(match);
|
Pattern.compile(sb.toString()),
|
||||||
if (p == null) {
|
ChatFormatter.Color.Aqua,
|
||||||
System.out.println("Error: Can't find player " + match
|
(String match) -> {
|
||||||
+ " but it was reported as online.");
|
Player p = Bukkit.getPlayer(match);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
MaybeOfflinePlayer mpp = MaybeOfflinePlayer
|
|
||||||
.AddPlayerIfNeeded(p.getUniqueId());
|
|
||||||
if (PlayerListener.NotificationSound == null)
|
|
||||||
p.playSound(p.getLocation(),
|
|
||||||
Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO:
|
|
||||||
// Airhorn
|
|
||||||
else
|
|
||||||
p.playSound(p.getLocation(), PlayerListener.NotificationSound,
|
|
||||||
1.0f, (float) PlayerListener.NotificationPitch);
|
|
||||||
String color = String.format("§%x",
|
|
||||||
(mpp.GetFlairColor() == 0x00 ? 0xb : mpp.GetFlairColor()));
|
|
||||||
return true; // TODO
|
|
||||||
}, Priority.High));
|
|
||||||
|
|
||||||
formatters
|
|
||||||
.add(new ChatFormatter(
|
|
||||||
Pattern.compile(sb.toString()),
|
|
||||||
ChatFormatter.Color.Aqua,
|
|
||||||
(String match) -> {
|
|
||||||
for (String n : PlayerListener.nicknames.keySet()) {
|
|
||||||
String nwithoutformatting = new String(n);
|
|
||||||
int index;
|
|
||||||
while ((index = nwithoutformatting
|
|
||||||
.indexOf("§k")) != -1)
|
|
||||||
nwithoutformatting = nwithoutformatting.replace(
|
|
||||||
"§k"
|
|
||||||
+ nwithoutformatting
|
|
||||||
.charAt(index + 2),
|
|
||||||
""); // Support
|
|
||||||
// for
|
|
||||||
// one
|
|
||||||
// random
|
|
||||||
// char
|
|
||||||
while ((index = nwithoutformatting.indexOf('§')) != -1)
|
|
||||||
nwithoutformatting = nwithoutformatting.replace(
|
|
||||||
"§"
|
|
||||||
+ nwithoutformatting
|
|
||||||
.charAt(index + 1),
|
|
||||||
"");
|
|
||||||
if (!match.equalsIgnoreCase(nwithoutformatting))
|
|
||||||
return false; // TODO
|
|
||||||
Player p = Bukkit
|
|
||||||
.getPlayer(PlayerListener.nicknames
|
|
||||||
.get(n));
|
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
System.out
|
System.out
|
||||||
.println("Error: Can't find player "
|
.println("Error: Can't find player "
|
||||||
|
@ -186,9 +141,69 @@ public class ChatProcessing {
|
||||||
String color = String.format("§%x",
|
String color = String.format("§%x",
|
||||||
(mpp.GetFlairColor() == 0x00 ? 0xb
|
(mpp.GetFlairColor() == 0x00 ? 0xb
|
||||||
: mpp.GetFlairColor()));
|
: mpp.GetFlairColor()));
|
||||||
}
|
return true; // TODO
|
||||||
return true; // TODO
|
}, Priority.High));
|
||||||
}, Priority.High));
|
|
||||||
|
formatters
|
||||||
|
.add(new ChatFormatter(
|
||||||
|
Pattern.compile(sb.toString()),
|
||||||
|
ChatFormatter.Color.Aqua,
|
||||||
|
(String match) -> {
|
||||||
|
for (String n : PlayerListener.nicknames
|
||||||
|
.keySet()) {
|
||||||
|
String nwithoutformatting = new String(n);
|
||||||
|
int index;
|
||||||
|
while ((index = nwithoutformatting
|
||||||
|
.indexOf("§k")) != -1)
|
||||||
|
nwithoutformatting = nwithoutformatting.replace(
|
||||||
|
"§k"
|
||||||
|
+ nwithoutformatting
|
||||||
|
.charAt(index + 2),
|
||||||
|
""); // Support
|
||||||
|
// for
|
||||||
|
// one
|
||||||
|
// random
|
||||||
|
// char
|
||||||
|
while ((index = nwithoutformatting
|
||||||
|
.indexOf('§')) != -1)
|
||||||
|
nwithoutformatting = nwithoutformatting.replace(
|
||||||
|
"§"
|
||||||
|
+ nwithoutformatting
|
||||||
|
.charAt(index + 1),
|
||||||
|
"");
|
||||||
|
if (!match
|
||||||
|
.equalsIgnoreCase(nwithoutformatting))
|
||||||
|
return false; // TODO
|
||||||
|
Player p = Bukkit
|
||||||
|
.getPlayer(PlayerListener.nicknames
|
||||||
|
.get(n));
|
||||||
|
if (p == null) {
|
||||||
|
System.out
|
||||||
|
.println("Error: Can't find player "
|
||||||
|
+ match
|
||||||
|
+ " but it was reported as online.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MaybeOfflinePlayer mpp = MaybeOfflinePlayer
|
||||||
|
.AddPlayerIfNeeded(p.getUniqueId());
|
||||||
|
if (PlayerListener.NotificationSound == null)
|
||||||
|
p.playSound(p.getLocation(),
|
||||||
|
Sound.ENTITY_ARROW_HIT_PLAYER,
|
||||||
|
1.0f, 0.5f); // TODO:
|
||||||
|
// Airhorn
|
||||||
|
else
|
||||||
|
p.playSound(
|
||||||
|
p.getLocation(),
|
||||||
|
PlayerListener.NotificationSound,
|
||||||
|
1.0f,
|
||||||
|
(float) PlayerListener.NotificationPitch);
|
||||||
|
String color = String.format("§%x", (mpp
|
||||||
|
.GetFlairColor() == 0x00 ? 0xb
|
||||||
|
: mpp.GetFlairColor()));
|
||||||
|
}
|
||||||
|
return true; // TODO
|
||||||
|
}, Priority.High));
|
||||||
|
}
|
||||||
|
|
||||||
pingedconsole = false;
|
pingedconsole = false;
|
||||||
formatters.add(new ChatFormatter(Pattern.compile("(?i)"
|
formatters.add(new ChatFormatter(Pattern.compile("(?i)"
|
||||||
|
|
Loading…
Reference in a new issue