Skip to content

Commit eb299ba

Browse files
committed
Allow toggling reminder message
1 parent a11e556 commit eb299ba

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

src/main/java/me/diademiemi/adventageous/AdventIO.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static void writeConfig() {
2828
data.set("offset", Advent.getOffset());
2929
data.set("claimSound", Advent.getClaimSound());
3030
data.set("claimParticle", Advent.getClaimParticle());
31+
data.set("sendDailyReminder", Advent.getSendDailyReminder());
3132
try {
3233
data.save(dataFile);
3334
} catch (Exception e) {
@@ -52,6 +53,9 @@ public static void loadConfig() {
5253
if (data.getString("claimParticle") != null) {
5354
Advent.setClaimParticle(data.getString("claimParticle"));
5455
}
56+
if (data.getString("sendDailyReminder") != null) {
57+
Advent.setSendDailyReminder(data.getBoolean("sendDailyReminder"));
58+
}
5559
} catch (Exception e) {
5660
e.printStackTrace();
5761
}

src/main/java/me/diademiemi/adventageous/advent/Advent.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class Advent {
2020

2121
public static String claimParticle = "VILLAGER_HAPPY";
2222

23+
public static Boolean sendDailyReminder = true;
24+
2325
public static void addYear(Year year) {
2426
years.put(year.getYear(), year);
2527
}
@@ -120,5 +122,12 @@ public static boolean setClaimParticle(String claimParticle) {
120122
}
121123
}
122124

125+
public static Boolean getSendDailyReminder() {
126+
return sendDailyReminder;
127+
}
128+
129+
public static void setSendDailyReminder(Boolean sendDailyReminder) {
130+
Advent.sendDailyReminder = sendDailyReminder;
131+
}
123132

124133
}

src/main/java/me/diademiemi/adventageous/advent/AdventListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class AdventListener implements Listener {
1414

1515
@EventHandler
1616
public void onPlayerJoin(PlayerJoinEvent event) {
17+
if (!Advent.getSendDailyReminder()) return;
1718
Player player = event.getPlayer();
1819
LocalDateTime date = LocalDateTime.now();
1920
if (Advent.getOffset() != null && Advent.getOffset() != "-0" && Advent.getOffset() != "+0") {

src/main/java/me/diademiemi/adventageous/dialogs/AdminMenu.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,30 @@ public void onLeftClick(Player p) {
6464
}
6565
}, 6);
6666

67+
if (Advent.getSendDailyReminder()) {
68+
builder.addButton(new GUIButton(Material.LIME_WOOL, 1, Button.get("admin-toggle-reminder", "state", "enabled")) {
69+
@Override
70+
public void onLeftClick(Player p) {
71+
Advent.setSendDailyReminder(false);
72+
new AdminMenu().show(p);
73+
}
74+
}, 7);
75+
} else {
76+
builder.addButton(new GUIButton(Material.RED_WOOL, 1, Button.get("admin-toggle-reminder", "state", "disabled")) {
77+
@Override
78+
public void onLeftClick(Player p) {
79+
Advent.setSendDailyReminder(true);
80+
new AdminMenu().show(p);
81+
}
82+
}, 7);
83+
}
84+
6785
builder.addButton(new GUIButton(Material.WRITABLE_BOOK, 1, Button.get("admin-write-data")) {
6886
@Override
6987
public void onLeftClick(Player p) {
7088
AdventIO.writeConfig();
7189
}
72-
}, 7);
90+
}, 8);
7391

7492
return builder.build(p);
7593
}

src/main/resources/lang.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ buttons:
123123
lore:
124124
- "Set the particle to play when a player claims a reward"
125125
- "Current particle: {{ particle }}"
126+
admin-toggle-reminder:
127+
title: "Toggle new reward available message"
128+
lore:
129+
- "Send a message when a player logs in and a reward is available"
130+
- "Current state: {{ state }}"
126131
# Player
127132
claim-day:
128133
title: "Claim {{ day }}"

0 commit comments

Comments
 (0)