updated with null contracts, immutability, and early returns.

This commit is contained in:
Sxtanna 2020-07-20 18:22:08 -04:00
parent 45b3ebfbc2
commit 42992de312

View File

@ -23,21 +23,37 @@ package me.clip.placeholderapi.util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public final class Msg { public final class Msg
public static void msg(CommandSender s, String... msg) { {
s.sendMessage(Arrays.stream(msg).filter(Objects::nonNull).map(Msg::color).collect(Collectors.joining("\n")));
}
public static void broadcast(String... msg) { public static void msg(@NotNull final CommandSender sender, @NotNull final String... messages)
Arrays.stream(msg).filter(Objects::nonNull).map(Msg::color).forEach(Bukkit::broadcastMessage); {
} if (messages.length == 0)
{
return;
}
sender.sendMessage(Arrays.stream(messages).map(Msg::color).collect(Collectors.joining("\n")));
}
public static void broadcast(@NotNull final String... messages)
{
if (messages.length == 0)
{
return;
}
Bukkit.broadcastMessage(Arrays.stream(messages).map(Msg::color).collect(Collectors.joining("\n")));
}
public static String color(@NotNull final String text)
{
return ChatColor.translateAlternateColorCodes('&', text);
}
public static String color(String text) {
return ChatColor.translateAlternateColorCodes('&', text);
}
} }