diff options
author | David <david@panic.tk> | 2018-11-07 23:50:06 +0100 |
---|---|---|
committer | David <david@panic.tk> | 2018-11-07 23:50:06 +0100 |
commit | 604cf01967ede98bf5024e4926bb0777fc4e8eee (patch) | |
tree | e2fa63d7e683769ee3bf3eddc75280648e92eb04 /src/main/java/com/redstoner/modules/motd | |
parent | e86c52ef7c0e1e33c6af0e8674b038976bec11cc (diff) |
Converted Modules to gradle
Diffstat (limited to 'src/main/java/com/redstoner/modules/motd')
-rw-r--r-- | src/main/java/com/redstoner/modules/motd/Motd.cmd | 14 | ||||
-rw-r--r-- | src/main/java/com/redstoner/modules/motd/Motd.java | 59 |
2 files changed, 73 insertions, 0 deletions
diff --git a/src/main/java/com/redstoner/modules/motd/Motd.cmd b/src/main/java/com/redstoner/modules/motd/Motd.cmd new file mode 100644 index 0000000..987d1fe --- /dev/null +++ b/src/main/java/com/redstoner/modules/motd/Motd.cmd @@ -0,0 +1,14 @@ +command setmotd { + [string:motd...] { + help Sets the motd. Use --reset to reset to default; + run setmotd motd; + perm utils.setmotd; + } +} +command getmotd { + [empty] { + help Returns the motd; + run getmotd; + perm utils.getmotd; + } +}
\ No newline at end of file diff --git a/src/main/java/com/redstoner/modules/motd/Motd.java b/src/main/java/com/redstoner/modules/motd/Motd.java new file mode 100644 index 0000000..1334e1a --- /dev/null +++ b/src/main/java/com/redstoner/modules/motd/Motd.java @@ -0,0 +1,59 @@ +package com.redstoner.modules.motd; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.server.ServerListPingEvent; + +import com.nemez.cmdmgr.Command; +import com.nemez.cmdmgr.Command.AsyncType; +import com.redstoner.annotations.AutoRegisterListener; +import com.redstoner.annotations.Commands; +import com.redstoner.annotations.Version; +import com.redstoner.misc.CommandHolderType; +import com.redstoner.modules.Module; + +@Commands(CommandHolderType.File) +@AutoRegisterListener +@Version(major = 4, minor = 1, revision = 0, compatible = 4) +public class Motd implements Module, Listener +{ + private String default_motd, motd; + + @Command(hook = "setmotd", async = AsyncType.ALWAYS) + public boolean setMotd(CommandSender sender, String motd) + { + if (motd.equals("--reset")) + this.motd = default_motd; + else + this.motd = motd; + getLogger().message(sender, "The new motd is:\n" + this.motd); + return true; + } + + @Command(hook = "getmotd", async = AsyncType.ALWAYS) + public boolean getMotd(CommandSender sender) + { + getLogger().message(sender, motd == null ? default_motd : motd); + return true; + } + + @EventHandler + public void onServerPing(ServerListPingEvent event) + { + event.setMotd(motd); + } + + @Override + public boolean onEnable() + { + default_motd = Bukkit.getMotd(); + if (default_motd == null) + { + default_motd = "§6Sample text\n§4FIX YOUR SERVER!"; + } + motd = default_motd; + return true; + } +} |