diff --git a/src/main/java/me/diademiemi/adventageous/AdventIO.java b/src/main/java/me/diademiemi/adventageous/AdventIO.java index 2fbdbff..3b80f64 100644 --- a/src/main/java/me/diademiemi/adventageous/AdventIO.java +++ b/src/main/java/me/diademiemi/adventageous/AdventIO.java @@ -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) { @@ -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(); } diff --git a/src/main/java/me/diademiemi/adventageous/advent/Advent.java b/src/main/java/me/diademiemi/adventageous/advent/Advent.java index 6eb867f..7d22139 100644 --- a/src/main/java/me/diademiemi/adventageous/advent/Advent.java +++ b/src/main/java/me/diademiemi/adventageous/advent/Advent.java @@ -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); } @@ -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; + } } diff --git a/src/main/java/me/diademiemi/adventageous/advent/AdventListener.java b/src/main/java/me/diademiemi/adventageous/advent/AdventListener.java index df38ce5..7406655 100644 --- a/src/main/java/me/diademiemi/adventageous/advent/AdventListener.java +++ b/src/main/java/me/diademiemi/adventageous/advent/AdventListener.java @@ -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") { diff --git a/src/main/java/me/diademiemi/adventageous/dialogs/AdminMenu.java b/src/main/java/me/diademiemi/adventageous/dialogs/AdminMenu.java index e57b072..46db53b 100644 --- a/src/main/java/me/diademiemi/adventageous/dialogs/AdminMenu.java +++ b/src/main/java/me/diademiemi/adventageous/dialogs/AdminMenu.java @@ -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); } diff --git a/src/main/resources/lang.yml b/src/main/resources/lang.yml index 7ca4b8c..e06b505 100644 --- a/src/main/resources/lang.yml +++ b/src/main/resources/lang.yml @@ -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 }}"