Created
December 29, 2014 08:46
-
-
Save JCThePants/a8b23b28304a7c4bca9a to your computer and use it in GitHub Desktop.
Nucleus plugin messenger helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.jcwhatever.nucleus.messaging.ChatPaginator; | |
import com.jcwhatever.nucleus.messaging.IMessenger; | |
import org.bukkit.Bukkit; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.entity.Player; | |
import java.util.Collection; | |
import java.util.List; | |
import java.util.UUID; | |
/** | |
* Player chat and console logging utilities. | |
*/ | |
public class Msg { | |
private Msg() {} | |
/** | |
* Tell a command sender a message. | |
* | |
* @param sender The sender. | |
* @param message The message to tell. | |
* @param args Optional format arguments. | |
*/ | |
public static void tell(CommandSender sender, String message, Object...args) { | |
msg().tell(sender, message, params); | |
} | |
/** | |
* Tell a player an important message that will be stored if the player is not online. | |
* | |
* @param playerId The id of the player. | |
* @param context The context of the message. | |
* @param message The message to tell. | |
* @param args Optional format arguments. | |
*/ | |
public static void tellImportant(UUID playerId, String context, String message, Object...args) { | |
msg().tellImportant(playerId, context, message, params); | |
} | |
/** | |
* Broadcast a message to all players on the server. | |
* | |
* @param message The message to broadcast. | |
* @param args Optional format arguments. | |
*/ | |
public static void broadcast(String message, Object... args) { | |
msg().broadcast(message, params); | |
} | |
/** | |
* Broadcast a message to all players on the server, excluding | |
* the specified players. | |
* | |
* @param message The message to broadcast. | |
* @param exclude The player to exclude from the broadcast. | |
* @param args Optional format arguments. | |
*/ | |
public static void broadcast(String message, Collection<Player> exclude, Object...args) { | |
msg().broadcast(exclude, message, params); | |
} | |
/** | |
* Get a paginator for listing things in chat. | |
* | |
* @param title The title of the paginator. | |
* @param args Optional format arguments. | |
*/ | |
public static ChatPaginator getPaginator(String title, Object...args) { | |
return new ChatPaginator(MyPlugin.getInstance(), 6, title, args); | |
} | |
/** | |
* Write a debug message to the console and log. Message is | |
* disregarded unless debugging is turned on. | |
* | |
* @param message The message to write. | |
* @param args Optional format arguments. | |
*/ | |
public static void debug(String message, Object...args) { | |
msg().debug(message, args); | |
} | |
/** | |
* Write an info message to the console and log. | |
* | |
* @param message The message to write. | |
* @param args Optional format arguments. | |
*/ | |
public static void info(String message, Object...args) { | |
msg().info(message, params); | |
} | |
/** | |
* Write a warning message to the console and log. | |
* | |
* @param message The message to write. | |
* @param args Optional format arguments. | |
*/ | |
public static void warning(String message, Object...args) { | |
msg().warning(message, args); | |
} | |
/** | |
* Write a severe error message to the console and log. | |
* | |
* @param message The message to write. | |
* @param args Optional format arguments. | |
*/ | |
public static void severe(String message, Object... args) { | |
msg().severe(message, params); | |
} | |
private static IMessenger msg() { | |
return MyPlugin.getInstance().getMessenger(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment