Skip to content

Commit

Permalink
Allow toggling reminder message
Browse files Browse the repository at this point in the history
  • Loading branch information
x86-39 committed Dec 2, 2022
1 parent a11e556 commit eb299ba
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/me/diademiemi/adventageous/AdventIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static void writeConfig() {
data.set("offset", Advent.getOffset());
data.set("claimSound", Advent.getClaimSound());
data.set("claimParticle", Advent.getClaimParticle());
data.set("sendDailyReminder", Advent.getSendDailyReminder());
try {
data.save(dataFile);
} catch (Exception e) {
Expand All @@ -52,6 +53,9 @@ public static void loadConfig() {
if (data.getString("claimParticle") != null) {
Advent.setClaimParticle(data.getString("claimParticle"));
}
if (data.getString("sendDailyReminder") != null) {
Advent.setSendDailyReminder(data.getBoolean("sendDailyReminder"));
}
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/me/diademiemi/adventageous/advent/Advent.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class Advent {

public static String claimParticle = "VILLAGER_HAPPY";

public static Boolean sendDailyReminder = true;

public static void addYear(Year year) {
years.put(year.getYear(), year);
}
Expand Down Expand Up @@ -120,5 +122,12 @@ public static boolean setClaimParticle(String claimParticle) {
}
}

public static Boolean getSendDailyReminder() {
return sendDailyReminder;
}

public static void setSendDailyReminder(Boolean sendDailyReminder) {
Advent.sendDailyReminder = sendDailyReminder;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class AdventListener implements Listener {

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (!Advent.getSendDailyReminder()) return;
Player player = event.getPlayer();
LocalDateTime date = LocalDateTime.now();
if (Advent.getOffset() != null && Advent.getOffset() != "-0" && Advent.getOffset() != "+0") {
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/me/diademiemi/adventageous/dialogs/AdminMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,30 @@ public void onLeftClick(Player p) {
}
}, 6);

if (Advent.getSendDailyReminder()) {
builder.addButton(new GUIButton(Material.LIME_WOOL, 1, Button.get("admin-toggle-reminder", "state", "enabled")) {
@Override
public void onLeftClick(Player p) {
Advent.setSendDailyReminder(false);
new AdminMenu().show(p);
}
}, 7);
} else {
builder.addButton(new GUIButton(Material.RED_WOOL, 1, Button.get("admin-toggle-reminder", "state", "disabled")) {
@Override
public void onLeftClick(Player p) {
Advent.setSendDailyReminder(true);
new AdminMenu().show(p);
}
}, 7);
}

builder.addButton(new GUIButton(Material.WRITABLE_BOOK, 1, Button.get("admin-write-data")) {
@Override
public void onLeftClick(Player p) {
AdventIO.writeConfig();
}
}, 7);
}, 8);

return builder.build(p);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/lang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ buttons:
lore:
- "Set the particle to play when a player claims a reward"
- "Current particle: {{ particle }}"
admin-toggle-reminder:
title: "Toggle new reward available message"
lore:
- "Send a message when a player logs in and a reward is available"
- "Current state: {{ state }}"
# Player
claim-day:
title: "Claim {{ day }}"
Expand Down

0 comments on commit eb299ba

Please sign in to comment.