Skip to content

Commit

Permalink
extend status command, documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifiht committed Nov 8, 2024
1 parent 1b354a9 commit 19045f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'org.evlis'
version = '0.4.0'
version = '0.4.1'

def targetJavaVersion = 21

Expand Down
25 changes: 17 additions & 8 deletions src/main/java/org/evlis/lunamatic/commands/LumaCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import io.papermc.paper.world.MoonPhase;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.evlis.lunamatic.GlobalVars;
import org.jetbrains.annotations.NotNull;

@CommandAlias("luma")
public class LumaCommand extends BaseCommand {
Expand Down Expand Up @@ -37,14 +41,19 @@ public void onReload(CommandSender sender) {
@Subcommand("status")
@CommandPermission("luma.command.status")
@Description("Displays the status of plugin variables")
public void onStatus(CommandSender sender) {
public void onStatus(Player player) {
// this command is player only!!!
// get the current world & moon state:
World world = player.getWorld();
@NotNull MoonPhase moonPhase = world.getMoonPhase();
// Display GlobalVars status
sender.sendMessage("Blood Moon Enabled: " + GlobalVars.bloodMoonEnabled);
sender.sendMessage("Blood Moon Now: " + GlobalVars.bloodMoonNow);
sender.sendMessage("Blood Moon Today: " + GlobalVars.bloodMoonToday);
sender.sendMessage("Harvest Moon Enabled: " + GlobalVars.harvestMoonEnabled);
sender.sendMessage("Harvest Moon Now: " + GlobalVars.harvestMoonNow);
sender.sendMessage("Harvest Moon Today: " + GlobalVars.harvestMoonToday);
sender.sendMessage("Disabled worlds: " + String.join(", ", GlobalVars.disabledWorlds));
player.sendMessage("Blood Moon Enabled: " + GlobalVars.bloodMoonEnabled);
player.sendMessage("Blood Moon Now: " + GlobalVars.bloodMoonNow);
player.sendMessage("Blood Moon Today: " + GlobalVars.bloodMoonToday);
player.sendMessage("Harvest Moon Enabled: " + GlobalVars.harvestMoonEnabled);
player.sendMessage("Harvest Moon Now: " + GlobalVars.harvestMoonNow);
player.sendMessage("Harvest Moon Today: " + GlobalVars.harvestMoonToday);
player.sendMessage("Disabled worlds: " + String.join(", ", GlobalVars.disabledWorlds));
player.sendMessage("Current moon phase for world " + world.getName() + ": " + moonPhase);
}
}
6 changes: 5 additions & 1 deletion src/main/java/org/evlis/lunamatic/events/PlayerJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
World world = player.getWorld();
if (world.getPlayers().isEmpty()) {
// If the world was empty, there is a chance flags are stuck from
// the world state the last player left at. Clear all flags to
// prevent invalid moon states.
ResetFlags.resetAll();
} else {
@NotNull MoonPhase moonPhase = world.getMoonPhase();

long time = world.getTime();
// harvest moon & blood moon are subsets of the full and new moons,
// currently cannot be separated without a code rewrite.
if (moonPhase == MoonPhase.FULL_MOON) {
if (GlobalVars.harvestMoonToday) {
PlayerMessage.Send(player, "Harvest moon tonight.", NamedTextColor.GOLD);
Expand Down

0 comments on commit 19045f3

Please sign in to comment.