Skip to content

Commit

Permalink
implement config in the scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifiht committed Nov 3, 2024
1 parent ea70da8 commit 1b354a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
15 changes: 9 additions & 6 deletions src/main/java/org/evlis/lunamatic/triggers/Scheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public void GetOmens(Plugin plugin) {
if (playerList.isEmpty()) {
continue; // Skip worlds with no active players
}
if (GlobalVars.disabledWorlds.contains(world.getName())) {
continue; // Skip worlds on the disabled list
}

long time = world.getTime();
// Check if it's the start of the day (0 ticks, 6am)
Expand All @@ -47,19 +50,19 @@ public void GetOmens(Plugin plugin) {
// get the moon phase tonight
@NotNull MoonPhase moonPhase = world.getMoonPhase();
// handle debugging flag
if (moonPhase == MoonPhase.FULL_MOON) {
if (moonPhase == MoonPhase.FULL_MOON && GlobalVars.fullMoonEnabled) {
// Do a dice roll to check if we're getting a harvest moon?
int chance = r.nextInt(2);
if (chance == 0) {
int chance = r.nextInt(GlobalVars.harvestMoonDieSides);
if (chance == 0 && GlobalVars.harvestMoonEnabled) {
GlobalVars.harvestMoonToday = true;
PlayerMessage.Send(playerList, "Harvest moon tonight.", NamedTextColor.GOLD);
} else {
PlayerMessage.Send(playerList, "Full moon tonight.", NamedTextColor.YELLOW);
}
} else if (moonPhase == MoonPhase.NEW_MOON) {
} else if (moonPhase == MoonPhase.NEW_MOON && GlobalVars.newMoonEnabled) {
// Do a dice roll to check if the players are THAT unlucky..
int chance = r.nextInt(2);
if (chance == 0) {
int chance = r.nextInt(GlobalVars.bloodMoonDieSides);
if (chance == 0 && GlobalVars.bloodMoonEnabled) {
GlobalVars.bloodMoonToday = true;
PlayerMessage.Send(playerList, "Blood moon tonight.", NamedTextColor.DARK_RED);
} else {
Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Lunamatic configuration
## Choose which moon effects to enable (default all true):
### Lunamatic configuration ###
# Choose which moon effects to enable,
# for blood moons, new moon must be enabled,
# and for harvest moons the full moon must be enabled.
fullMoonEnabled: true
newMoonEnabled: true
harvestMoonEnabled: true
bloodMoonEnabled: true
## Chance for Blood and Harvest Moons
### Chance for Blood and Harvest Moons ###
# This sets the number of sides in the dice roll,
# e.g. 2 = cointoss (50/50), 6 = normal die (17% chance)
bloodMoonDieSides: 2
harvestMoonDieSides: 2
## Set worlds to disable moon-effects on
### Set worlds to disable moon-effects on ###
# by default both nether & the_end cannot have moon effects
disabledWorlds:
- world
Expand Down

0 comments on commit 1b354a9

Please sign in to comment.