Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.thebukkitarea.motd;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.server.ServerListPingEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin implements Listener {
- private String motd;
- @Override
- public void onEnable() {
- getServer().getPluginManager().registerEvents(this, this);
- this.motd = getConfig().getString("motd");
- }
- @EventHandler
- public void onServerListPing(ServerListPingEvent event) {
- if (this.motd != null) {
- event.setMotd(ChatColor.translateAlternateColorCodes('&', this.motd));
- }
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd,
- String cmdLabel, String[] args) {
- if (cmd.getName().equalsIgnoreCase("motd")) {
- if (args.length < 1) {
- return false;
- }
- String motd = "";
- for (String arg : args) {
- if (motd.length() > 0) {
- motd += " ";
- }
- motd += arg;
- }
- this.motd = motd;
- getConfig().set("motd", motd);
- saveConfig();
- sender.sendMessage("Motd was changed to");
- sender.sendMessage(ChatColor.translateAlternateColorCodes('&', motd));
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement