Skip to content

Commit afee780

Browse files
authored
feat: Add new notification system. (#177)
2 parents 35e4320 + 29d5914 commit afee780

19 files changed

+533
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ build/
1515
out/
1616
!**/src/main/**/out/
1717
!**/src/test/**/out/
18+
.idea/*
1819

1920
### Eclipse ###
2021
.apt_generated

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# [2.4.0-beta.1](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/compare/v2.3.0...v2.4.0-beta.1) (2025-10-03)
2+
3+
4+
### Bug Fixes
5+
6+
* correct notification configuration keys and method name for clarity ([bf77855](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/commit/bf77855b6cc963b100a8cb9b86f98c182daab4ef))
7+
* enhance error logging for webhook client creation failures ([201b18e](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/commit/201b18e9d86e657b2dc9da0e1a5f6723236607fa))
8+
* update Discord notification configuration keys for consistency and improve error handling ([89c46fc](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/commit/89c46fccbe699614fcae5aac05348af1d721c8c1))
9+
10+
11+
### Features
12+
13+
* add Discord notification service with webhook integration ([c527a2e](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/commit/c527a2e9b24da2e9ff83af853802021a2b6e6401))
14+
* enhance notification system with new services and configuration options ([7b2e5ef](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/commit/7b2e5efb46dca0a3dc2bff98342b6c0e27e69425))
15+
* implement notification system for redstone clock detection ([9a42292](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/commit/9a422921687670fa53af6365fe9498d1f0f1d99a))
16+
* implement sign block break handling and metadata management ([d737be4](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/commit/d737be4be32760383b588ffd6bb9736c2b54a41a))
17+
* improve Discord webhook handling and error logging ([b9f196b](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/commit/b9f196b8bb839f96e7d3b805710150136b7f5497))
18+
119
# [2.3.0](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/compare/v2.2.8...v2.3.0) (2025-10-03)
220

321

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ dependencies {
6262
implementation(libs.cloud.command.annotations)
6363
implementation(libs.semver)
6464
implementation(libs.adventure.text.feature.pagination)
65+
implementation(libs.adventure.text.discord)
66+
implementation(libs.jda.webhook)
67+
implementation(libs.jda)
6568
implementation(libs.guice)
6669
implementation(libs.jakarta.inject)
6770
annotationProcessor(libs.cloud.command.annotations)

settings.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ dependencyResolutionManagement {
3131
version("cloudcommandExtras", "2.0.0-SNAPSHOT")
3232

3333
version("adventure-text-feature-pagination", "4.0.0-SNAPSHOT")
34+
version("adventure-text-discord-serializer", "4.3.0")
35+
version("jda", "5.6.1")
36+
version("jda-webhook", "0.8.4")
37+
3438
version("semver", "0.10.2")
3539
version("guice", "7.0.0")
3640
version("jakarta-inject", "2.0.1")
@@ -64,6 +68,9 @@ dependencyResolutionManagement {
6468

6569
library("paper", "io.papermc.paper", "paper-api").versionRef("paper")
6670
library("adventure.text.feature.pagination", "net.kyori", "adventure-text-feature-pagination").versionRef("adventure-text-feature-pagination")
71+
library("adventure.text.discord", "dev.vankka", "mcdiscordreserializer").versionRef("adventure-text-discord-serializer")
72+
library("jda", "net.dv8tion", "JDA").versionRef("jda")
73+
library("jda-webhook", "club.minnced", "discord-webhooks").versionRef("jda-webhook")
6774
library("bstats", "org.bstats", "bstats-bukkit").versionRef("bstats")
6875

6976
library("cloud.command.paper", "org.incendo", "cloud-paper").versionRef("cloudcommandPaper")

src/main/java/net/onelitefeather/antiredstoneclockremastered/AntiRedstoneClockRemastered.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public final class AntiRedstoneClockRemastered extends JavaPlugin {
3030
public void onLoad() {
3131
saveDefaultConfig();
3232
reloadConfig();
33+
saveConfig();
3334
injector = Guice.createInjector(Stage.PRODUCTION, Arrays.asList(
3435
new PlatformModule(this),
3536
new TranslationModule(),

src/main/java/net/onelitefeather/antiredstoneclockremastered/injection/ServiceModule.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
import net.onelitefeather.antiredstoneclockremastered.AntiRedstoneClockRemastered;
88
import net.onelitefeather.antiredstoneclockremastered.api.PlotsquaredSupport;
99
import net.onelitefeather.antiredstoneclockremastered.api.WorldGuardSupport;
10+
import net.onelitefeather.antiredstoneclockremastered.service.api.NotificationService;
1011
import net.onelitefeather.antiredstoneclockremastered.service.api.RedstoneClockService;
1112
import net.onelitefeather.antiredstoneclockremastered.service.api.RegionService;
1213
import net.onelitefeather.antiredstoneclockremastered.service.factory.RedstoneClockServiceFactory;
1314
import net.onelitefeather.antiredstoneclockremastered.service.UpdateService;
1415
import net.onelitefeather.antiredstoneclockremastered.service.api.TranslationService;
15-
import net.onelitefeather.antiredstoneclockremastered.service.impl.LegacyTranslationService;
16-
import net.onelitefeather.antiredstoneclockremastered.service.impl.ModernTranslationService;
16+
import net.onelitefeather.antiredstoneclockremastered.service.impl.*;
1717
import net.onelitefeather.antiredstoneclockremastered.utils.CheckTPS;
1818
import org.slf4j.Logger;
1919
import org.slf4j.LoggerFactory;
@@ -37,8 +37,24 @@ protected void configure() {
3737

3838
@Provides
3939
@Singleton
40-
public RedstoneClockService provideRedstoneClockService(AntiRedstoneClockRemastered plugin, RegionService regionService,
41-
PlotsquaredSupport plotsquaredSupport, WorldGuardSupport worldGuardSupport) {
42-
return RedstoneClockServiceFactory.createService(plugin, regionService, plotsquaredSupport, worldGuardSupport);
40+
public RedstoneClockService provideRedstoneClockService(AntiRedstoneClockRemastered plugin,
41+
RegionService regionService,
42+
PlotsquaredSupport plotsquaredSupport,
43+
WorldGuardSupport worldGuardSupport,
44+
NotificationService notificationService) {
45+
return RedstoneClockServiceFactory.createService(plugin, regionService, plotsquaredSupport, worldGuardSupport,
46+
notificationService);
4347
}
48+
49+
@Provides
50+
@Singleton
51+
public NotificationService providesNotificationService(AntiRedstoneClockRemastered antiRedstoneClockRemastered,
52+
RegionService regionService) {
53+
var adminNotifications = new AdminNotificationService(antiRedstoneClockRemastered, null);
54+
var consoleNotification = new ConsoleNotificationService(antiRedstoneClockRemastered, adminNotifications);
55+
var signNotifications = new SignNotificationService(antiRedstoneClockRemastered, consoleNotification, regionService);
56+
var discordNotification = new DiscordNotificationService(antiRedstoneClockRemastered, signNotifications);
57+
return discordNotification;
58+
}
59+
4460
}

src/main/java/net/onelitefeather/antiredstoneclockremastered/listener/PlayerListener.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,13 @@ private void onBlockBreak(BlockBreakEvent blockBreakEvent) {
4646
break recheck;
4747
}
4848
}
49+
50+
@EventHandler(priority = EventPriority.HIGHEST)
51+
private void onSignBlockBreak(BlockBreakEvent blockBreakEvent) {
52+
var block = blockBreakEvent.getBlock();
53+
var hasKey = block.hasMetadata(Constants.META_KEY_ARCR_SIGN);
54+
if (hasKey) {
55+
blockBreakEvent.setDropItems(false);
56+
}
57+
}
4958
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package net.onelitefeather.antiredstoneclockremastered.service.api;
2+
3+
import net.kyori.adventure.text.Component;
4+
import org.bukkit.Location;
5+
import org.jetbrains.annotations.Nullable;
6+
7+
/**
8+
* Service for sending notifications.
9+
*
10+
* @author TheMeinerLP
11+
* @version 1.0.0
12+
* @since 2.4.0
13+
*/
14+
public interface NotificationService {
15+
16+
/**
17+
* Get the notification message for the given location.
18+
* @param location where the notification gets sent from
19+
* @return the notification message
20+
*/
21+
@Nullable Component getNotificationMessage(Location location);
22+
23+
/**
24+
* Send a notification message to the given audience.
25+
* @param location where the notification gets sent from
26+
*/
27+
void sendNotificationMessage(Location location);
28+
29+
boolean isEnabled();
30+
}

src/main/java/net/onelitefeather/antiredstoneclockremastered/service/api/RegionService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ public interface RegionService {
1919
*/
2020
void executeInRegion(Location location, Runnable task);
2121

22+
/**
23+
* Executes a task within the context of a specific region.
24+
* @param location The location to determine the region.
25+
* @param task The task to execute.
26+
* @param delay The delay in ticks before the task is executed.
27+
*/
28+
void executeInRegion(Location location, Runnable task, long delay);
29+
2230
/**
2331
* Checks if the current server instance is the owner of the region at the specified location.
2432
*

src/main/java/net/onelitefeather/antiredstoneclockremastered/service/factory/RedstoneClockServiceFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.onelitefeather.antiredstoneclockremastered.AntiRedstoneClockRemastered;
44
import net.onelitefeather.antiredstoneclockremastered.api.PlotsquaredSupport;
55
import net.onelitefeather.antiredstoneclockremastered.api.WorldGuardSupport;
6+
import net.onelitefeather.antiredstoneclockremastered.service.api.NotificationService;
67
import net.onelitefeather.antiredstoneclockremastered.service.api.RedstoneClockService;
78
import net.onelitefeather.antiredstoneclockremastered.service.api.RegionService;
89
import net.onelitefeather.antiredstoneclockremastered.service.impl.BukkitRedstoneClockService;
@@ -35,7 +36,10 @@ private RedstoneClockServiceFactory() {
3536
* @return the appropriate RedstoneClockService implementation
3637
*/
3738
@NotNull
38-
public static RedstoneClockService createService(@NotNull AntiRedstoneClockRemastered plugin, RegionService regionService, PlotsquaredSupport plotsquaredSupport, WorldGuardSupport worldGuardSupport) {
39+
public static RedstoneClockService createService(@NotNull AntiRedstoneClockRemastered plugin,
40+
RegionService regionService, PlotsquaredSupport plotsquaredSupport,
41+
WorldGuardSupport worldGuardSupport,
42+
NotificationService notificationService) {
3943
if (FoliaHelper.isFolia()) {
4044
LOGGER.info("Folia detected - using FoliaRedstoneClockService");
4145
// Uncomment when ready to enable Folia support:
@@ -44,6 +48,6 @@ public static RedstoneClockService createService(@NotNull AntiRedstoneClockRemas
4448
}
4549

4650
LOGGER.info("Using BukkitRedstoneClockService");
47-
return new BukkitRedstoneClockService(plugin, regionService, worldGuardSupport, plotsquaredSupport);
51+
return new BukkitRedstoneClockService(plugin, regionService, worldGuardSupport, plotsquaredSupport, notificationService);
4852
}
4953
}

0 commit comments

Comments
 (0)