diff --git a/src/main/java/us/camin/JoinListener.java b/src/main/java/us/camin/JoinListener.java
index 55350ad..e819418 100644
--- a/src/main/java/us/camin/JoinListener.java
+++ b/src/main/java/us/camin/JoinListener.java
@@ -64,17 +64,6 @@ public class JoinListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
- Player p = event.getPlayer();
- String[] motd = null;
- try {
- motd = m_plugin.api().fetchMOTD(p.getName());
- } catch (IOException e) {
- p.sendMessage("Could not fetch MOTD: Communication error");
- }
- if (motd != null) {
- for(String msg : motd) {
- p.sendMessage(msg);
- }
- }
+ m_plugin.sendMOTD(event.getPlayer());
}
}
diff --git a/src/main/java/us/camin/MOTDCommand.java b/src/main/java/us/camin/MOTDCommand.java
new file mode 100644
index 0000000..0ab5a21
--- /dev/null
+++ b/src/main/java/us/camin/MOTDCommand.java
@@ -0,0 +1,35 @@
+package us.camin;
+
+/*
+ This file is part of Caminus
+
+ Caminus is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Caminus is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Caminus. If not, see .
+ */
+
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+
+public class MOTDCommand implements CommandExecutor {
+ private Plugin m_plugin;
+
+ public MOTDCommand(Plugin p) {
+ m_plugin = p;
+ }
+
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
+ m_plugin.sendMOTD(sender);
+ return true;
+ }
+}
diff --git a/src/main/java/us/camin/Plugin.java b/src/main/java/us/camin/Plugin.java
index 43622d4..374f35d 100644
--- a/src/main/java/us/camin/Plugin.java
+++ b/src/main/java/us/camin/Plugin.java
@@ -17,6 +17,8 @@ package us.camin;
along with Caminus. If not, see .
*/
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
import org.bukkit.configuration.Configuration;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
@@ -24,6 +26,7 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.logging.Logger;
+import java.io.IOException;
import us.camin.api.Server;
@@ -32,6 +35,7 @@ public class Plugin extends JavaPlugin {
Logger log = Logger.getLogger("Caminus");//Define your logger
private Server m_api;
private JoinListener m_listener;
+ private MOTDCommand m_motdCommand;
public Server api() {
return m_api;
@@ -43,14 +47,32 @@ public class Plugin extends JavaPlugin {
}
public void onEnable() {
- log.info("[Caminus] Plugin enabled");
-
PluginManager pm = this.getServer().getPluginManager();
+ m_motdCommand = new MOTDCommand(this);
m_listener = new JoinListener(this);
Configuration conf = getConfig();
conf.addDefault("url", "http://camin.us/api/");
String url = conf.getString("url");
m_api = new Server(url);
pm.registerEvents(m_listener, this);
+
+ m_motdCommand = new MOTDCommand(this);
+ getCommand("motd").setExecutor(m_motdCommand);
+
+ log.info("[Caminus] Plugin enabled");
}
+
+ public void sendMOTD(CommandSender sender) {
+ String[] motd = null;
+ try {
+ motd = m_api.fetchMOTD(sender.getName());
+ } catch (IOException e) {
+ sender.sendMessage("Could not fetch MOTD: Communication error");
+ }
+ if (motd != null) {
+ for(String msg : motd) {
+ sender.sendMessage(msg);
+ }
+ }
+ }
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index efca834..6827040 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,3 +1,19 @@
name: Caminus
main: us.camin.Plugin
-version: 0.2
+author: Trever Fischer
+website: http://camin.us/
+version: ${version}
+commands:
+ motd:
+ description: Displays the MOTD
+ usage: /
+permissions:
+ caminus.*:
+ default: op
+ description: Allows use of all caminus permissions
+ children:
+ caminus.whitelisted: true
+ caminus.whitelisted:
+ default: op
+ description: Allows user to bypass caminus API whitelisting
+