Add moon phase command
parent
fa2f79239e
commit
3f7a4c2d88
4
pom.xml
4
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<groupId>xyz.etztech</groupId>
|
||||
<artifactId>QoL</artifactId>
|
||||
<!-- Version is used in plugin.yml -->
|
||||
<version>1.13</version>
|
||||
<version>1.14</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<!-- Plugin Information -->
|
||||
|
@ -161,4 +161,4 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<Integer, String> 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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue