T2CodeLib/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Csend.java

98 lines
3.0 KiB
Java

package net.t2code.t2codelib.SPIGOT.api.messages;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class T2Csend {
public static void console(String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleConsole(msg);
}
public static void player(Player player, String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.modulePlayer(msg, player);
}
public static void sender(CommandSender sender, String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender);
}
public static void console(Object object) {
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) continue;
T2ChoverModule.moduleConsole(msg);
}
}
public static void player(Player player, Object object) {
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) continue;
T2ChoverModule.modulePlayer(msg, player);
}
}
public static void sender(CommandSender sender, Object object) {
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender);
}
}
public static void title(Player player, @Nullable String title, @Nullable String subtitle) {
player.sendTitle(title, subtitle);
}
public static void title(Player player, @Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut) {
player.sendTitle(title, subtitle, fadeIn, stay, fadeOut);
}
public static void debug(Plugin plugin, String msg) {
debug(plugin, msg, null);
}
public static void debug(Plugin plugin, String msg, Integer stage) {
// if (!new File(Main.getPath(), "config.yml").exists()) return;
T2Cdebug.debug(plugin, msg, stage);
}
public static void debugmsg(Plugin plugin, String msg) {
T2Cdebug.debugmsg(plugin, msg);
}
public static void info(Plugin plugin, String msg) {
plugin.getLogger().log(Level.INFO, msg);
}
public static void warning(Plugin plugin, String msg) {
plugin.getLogger().log(Level.WARNING, msg);
}
public static void error(Plugin plugin, String msg) {
plugin.getLogger().log(Level.SEVERE, msg);
}
private static ArrayList<String> list(Object object){
ArrayList<String> list = new ArrayList<>();
if (object instanceof List){
list= (ArrayList<String>) object;
}
if (object instanceof String){
list.add((String) object);
}
return list;
}
}