diff --git a/pom.xml b/pom.xml
index 84a0e37..d8ddb0f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
xyz.etztech
QoL
- 1.13
+ 1.14
jar
@@ -161,4 +161,4 @@
-
\ No newline at end of file
+
diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java
index e841f54..d4bbc59 100644
--- a/src/main/java/xyz/etztech/qol/QoL.java
+++ b/src/main/java/xyz/etztech/qol/QoL.java
@@ -122,6 +122,7 @@ public class QoL extends JavaPlugin {
new CheckupCommand(this);
new DynmapLinkCommand(this);
new WikiCommand(this);
+ new MoonCommand(this);
if (dynmap != null) {
new MarkerCommand(this);
diff --git a/src/main/java/xyz/etztech/qol/commands/MoonCommand.java b/src/main/java/xyz/etztech/qol/commands/MoonCommand.java
new file mode 100644
index 0000000..3e0aa80
--- /dev/null
+++ b/src/main/java/xyz/etztech/qol/commands/MoonCommand.java
@@ -0,0 +1,51 @@
+package xyz.etztech.qol.commands;
+
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import xyz.etztech.qol.QoL;
+import xyz.etztech.qol.EtzTechUtil;
+import xyz.etztech.qol.Lang;
+
+import java.util.Map;
+import java.lang.*;
+
+public class MoonCommand implements CommandExecutor {
+ QoL plugin;
+
+ private final Map moonPhases = Map.of(
+ 0, "Full moon",
+ 1, "Waning gibbous",
+ 2, "Third quarter",
+ 3, "Waning crescent",
+ 4, "New moon",
+ 5, "Waxing crescent",
+ 6, "First quarter",
+ 7, "Waxing gibbous"
+ );
+
+ public MoonCommand(QoL paramQoL) {
+ this.plugin = paramQoL;
+ plugin.getCommand("moon").setExecutor(this);
+ }
+
+ @Override
+ public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
+ if (!commandSender.hasPermission("qol.moon")) {
+ EtzTechUtil.sms(commandSender, Lang.NO_PERMISSION.getDef());
+ return true;
+ }
+
+ String playername = commandSender.getName();
+ long time = commandSender.getServer().getPlayer(playername).getWorld().getFullTime();
+ double day = Math.floor(time / 24000);
+ int moonPhase = (int)(day % 8);
+
+ StringBuilder message = new StringBuilder(ChatColor.GOLD + "===== Moon Phase Utility =====");
+ message.append("\n" + ChatColor.GREEN + "Current moon phase: " + moonPhases.get(moonPhase) + ".");
+ message.append("\n" + ChatColor.GREEN + "Full moon is " + (moonPhase == 0 ? "tonight." : "in " + (8 - moonPhase) + ((moonPhase == 7) ? " day." : " days.")));
+ EtzTechUtil.sms(commandSender, message.toString());
+ return true;
+ }
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 7753706..0f7467c 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -48,6 +48,8 @@ commands:
aliases: [mark]
wiki:
description: Search the Minecraft wiki
+ moon:
+ description: Get information about the current moon phase
permissions:
qol.admin:
description: Ability to reload the plugin
@@ -121,3 +123,6 @@ permissions:
qol.wiki:
description: Ability to use the wiki command
default: op
+ qol.moon:
+ description: Ability to use the moon command
+ default: op