Fixed error when nobody is online

This commit is contained in:
Norbi Peti 2016-07-01 00:31:10 +02:00
parent 1e95f3773a
commit dfdd6eec87
2 changed files with 76 additions and 61 deletions

Binary file not shown.

View file

@ -104,6 +104,7 @@ public class ChatProcessing {
* , colormode, url, colormode, url)); * , colormode, url, colormode, url));
*/ */
if (PluginMain.GetPlayers().size() > 0) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("(?i)("); sb.append("(?i)(");
for (Player p : PluginMain.GetPlayers()) for (Player p : PluginMain.GetPlayers())
@ -111,11 +112,16 @@ public class ChatProcessing {
sb.deleteCharAt(sb.length() - 1); sb.deleteCharAt(sb.length() - 1);
sb.append(")"); sb.append(")");
formatters.add(new ChatFormatter(Pattern.compile(sb.toString()), formatters
ChatFormatter.Color.Aqua, (String match) -> { .add(new ChatFormatter(
Pattern.compile(sb.toString()),
ChatFormatter.Color.Aqua,
(String match) -> {
Player p = Bukkit.getPlayer(match); Player p = Bukkit.getPlayer(match);
if (p == null) { if (p == null) {
System.out.println("Error: Can't find player " + match System.out
.println("Error: Can't find player "
+ match
+ " but it was reported as online."); + " but it was reported as online.");
return false; return false;
} }
@ -123,13 +129,18 @@ public class ChatProcessing {
.AddPlayerIfNeeded(p.getUniqueId()); .AddPlayerIfNeeded(p.getUniqueId());
if (PlayerListener.NotificationSound == null) if (PlayerListener.NotificationSound == null)
p.playSound(p.getLocation(), p.playSound(p.getLocation(),
Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO: Sound.ENTITY_ARROW_HIT_PLAYER,
1.0f, 0.5f); // TODO:
// Airhorn // Airhorn
else else
p.playSound(p.getLocation(), PlayerListener.NotificationSound, p.playSound(
1.0f, (float) PlayerListener.NotificationPitch); p.getLocation(),
PlayerListener.NotificationSound,
1.0f,
(float) PlayerListener.NotificationPitch);
String color = String.format("§%x", String color = String.format("§%x",
(mpp.GetFlairColor() == 0x00 ? 0xb : mpp.GetFlairColor())); (mpp.GetFlairColor() == 0x00 ? 0xb
: mpp.GetFlairColor()));
return true; // TODO return true; // TODO
}, Priority.High)); }, Priority.High));
@ -138,7 +149,8 @@ public class ChatProcessing {
Pattern.compile(sb.toString()), Pattern.compile(sb.toString()),
ChatFormatter.Color.Aqua, ChatFormatter.Color.Aqua,
(String match) -> { (String match) -> {
for (String n : PlayerListener.nicknames.keySet()) { for (String n : PlayerListener.nicknames
.keySet()) {
String nwithoutformatting = new String(n); String nwithoutformatting = new String(n);
int index; int index;
while ((index = nwithoutformatting while ((index = nwithoutformatting
@ -152,13 +164,15 @@ public class ChatProcessing {
// one // one
// random // random
// char // char
while ((index = nwithoutformatting.indexOf('§')) != -1) while ((index = nwithoutformatting
.indexOf('§')) != -1)
nwithoutformatting = nwithoutformatting.replace( nwithoutformatting = nwithoutformatting.replace(
"§" "§"
+ nwithoutformatting + nwithoutformatting
.charAt(index + 1), .charAt(index + 1),
""); "");
if (!match.equalsIgnoreCase(nwithoutformatting)) if (!match
.equalsIgnoreCase(nwithoutformatting))
return false; // TODO return false; // TODO
Player p = Bukkit Player p = Bukkit
.getPlayer(PlayerListener.nicknames .getPlayer(PlayerListener.nicknames
@ -183,12 +197,13 @@ public class ChatProcessing {
PlayerListener.NotificationSound, PlayerListener.NotificationSound,
1.0f, 1.0f,
(float) PlayerListener.NotificationPitch); (float) PlayerListener.NotificationPitch);
String color = String.format("§%x", String color = String.format("§%x", (mpp
(mpp.GetFlairColor() == 0x00 ? 0xb .GetFlairColor() == 0x00 ? 0xb
: mpp.GetFlairColor())); : mpp.GetFlairColor()));
} }
return true; // TODO return true; // TODO
}, Priority.High)); }, Priority.High));
}
pingedconsole = false; pingedconsole = false;
formatters.add(new ChatFormatter(Pattern.compile("(?i)" formatters.add(new ChatFormatter(Pattern.compile("(?i)"