0
This repository has been archived on 2024-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ModuleLoader/src/com/redstoner/modules/motd/Motd.java
Pepich ca849074aa Updated API
API Version 2.0.0

Modules no longer have to keep track of their enabled status, the
ModuleLoader is now responsible for this. This allows for easier module
development and finer control over modules through the loader and the
debugger. More features to follow in a future update.
2017-03-02 20:07:44 +01:00

76 lines
1.7 KiB
Java

package com.redstoner.modules.motd;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.event.server.ServerListPingEvent;
import com.nemez.cmdmgr.Command;
import com.redstoner.annotations.AutoRegisterListener;
import com.redstoner.annotations.Version;
import com.redstoner.misc.Utils;
import com.redstoner.modules.Module;
@AutoRegisterListener
@Version(major = 2, minor = 0, revision = 0, compatible = 2)
public class Motd implements Module
{
private String default_motd, motd;
@Command(hook = "setmotd")
public boolean setMotd(CommandSender sender, String motd)
{
if (motd.equals("--reset"))
this.motd = default_motd;
else
this.motd = motd;
Utils.sendMessage(sender, null, "The new motd is:\n" + this.motd, '&');
return true;
}
@Command(hook = "getmotd")
public boolean getMotd(CommandSender sender)
{
Utils.sendMessage(sender, null, motd, '&');
return true;
}
@EventHandler
public void onServerPing(ServerListPingEvent event)
{
event.setMotd(motd);
}
@Override
public boolean onEnable()
{
default_motd = Bukkit.getMotd();
return true;
}
@Override
public void onDisable()
{}
// @noformat
@Override
public String getCommandString()
{
return "command setmotd {\n" +
" [string:motd...] {\n" +
" help Sets the motd. Use --reset to reset to default;\n" +
" run setmotd motd;\n" +
" perm utils.setmotd;" +
" }\n" +
"}\n" +
"command getmotd {\n" +
" [empty] {\n" +
" help Returns the motd;\n" +
" run getmotd;\n" +
" perm utils.getmotd;" +
" }\n" +
"}";
}
// @format
}