1- package net .onelitefeather .antiredstoneclockremastered .service ;
1+ package net .onelitefeather .antiredstoneclockremastered .service . impl ;
22
33import net .kyori .adventure .text .Component ;
44import net .kyori .adventure .text .event .ClickEvent ;
5- import net .kyori .adventure .text .minimessage .MiniMessage ;
65import net .onelitefeather .antiredstoneclockremastered .AntiRedstoneClockRemastered ;
76import net .onelitefeather .antiredstoneclockremastered .model .RedstoneClock ;
7+ import net .onelitefeather .antiredstoneclockremastered .service .api .RedstoneClockService ;
88import net .onelitefeather .antiredstoneclockremastered .utils .Constants ;
99import org .bukkit .Bukkit ;
1010import org .bukkit .Location ;
2323import java .util .concurrent .ConcurrentHashMap ;
2424import java .util .logging .Level ;
2525
26- public final class RedstoneClockService {
26+ /**
27+ * Bukkit/Paper implementation of the RedstoneClockService.
28+ * This implementation uses the standard Bukkit scheduler and APIs.
29+ */
30+ public final class BukkitRedstoneClockService implements RedstoneClockService {
2731
2832 private final @ NotNull AntiRedstoneClockRemastered antiRedstoneClockRemastered ;
2933 private int endTimeDelay ;
@@ -37,7 +41,7 @@ public final class RedstoneClockService {
3741 private final ConcurrentHashMap <Location , RedstoneClock > activeClockTesters = new ConcurrentHashMap <>();
3842 private final ItemStack SILK_TOUCH_PICKAXE = new ItemStack (Material .DIAMOND_PICKAXE );
3943
40- public RedstoneClockService (@ NotNull AntiRedstoneClockRemastered antiRedstoneClockRemastered ) {
44+ public BukkitRedstoneClockService (@ NotNull AntiRedstoneClockRemastered antiRedstoneClockRemastered ) {
4145 this .antiRedstoneClockRemastered = antiRedstoneClockRemastered ;
4246 this .endTimeDelay = antiRedstoneClockRemastered .getConfig ().getInt ("clock.endDelay" , 300 );
4347 this .maxClockCount = antiRedstoneClockRemastered .getConfig ().getInt ("clock.maxCount" , 150 );
@@ -49,6 +53,7 @@ public RedstoneClockService(@NotNull AntiRedstoneClockRemastered antiRedstoneClo
4953 SILK_TOUCH_PICKAXE .addEnchantment (Enchantment .SILK_TOUCH , 1 );
5054 }
5155
56+ @ Override
5257 public void checkAndUpdateClockStateWithActiveManual (@ NotNull Location location , boolean state ) {
5358 if (this .ignoredWorlds .contains (location .getWorld ().getName ())) return ;
5459 if (this .antiRedstoneClockRemastered .getWorldGuardSupport () != null && this .antiRedstoneClockRemastered .getWorldGuardSupport ().isRegionAllowed (location ))
@@ -76,14 +81,17 @@ public void checkAndUpdateClockStateWithActiveManual(@NotNull Location location,
7681 addRedstoneClockTest (location );
7782 }
7883
84+ @ Override
7985 public void checkAndUpdateClockStateWithActiveManual (@ NotNull Block block , boolean state ) {
8086 checkAndUpdateClockStateWithActiveManual (block .getLocation (), state );
8187 }
8288
89+ @ Override
8390 public void checkAndUpdateClockStateWithActive (@ NotNull Block block ) {
8491 checkAndUpdateClockStateWithActive (block .getLocation ());
8592 }
8693
94+ @ Override
8795 public void checkAndUpdateClockStateWithActive (@ NotNull Location location ) {
8896 if (this .ignoredWorlds .contains (location .getWorld ().getName ())) return ;
8997 if (this .antiRedstoneClockRemastered .getWorldGuardSupport () != null && this .antiRedstoneClockRemastered .getWorldGuardSupport ().isRegionAllowed (location ))
@@ -111,10 +119,12 @@ public void checkAndUpdateClockStateWithActive(@NotNull Location location) {
111119 addRedstoneClockTest (location );
112120 }
113121
122+ @ Override
114123 public void checkAndUpdateClockState (@ NotNull Block block ) {
115124 checkAndUpdateClockState (block .getLocation ());
116125 }
117126
127+ @ Override
118128 public void checkAndUpdateClockState (@ NotNull Location location ) {
119129 if (this .ignoredWorlds .contains (location .getWorld ().getName ())) return ;
120130 if (this .antiRedstoneClockRemastered .getWorldGuardSupport () != null && this .antiRedstoneClockRemastered .getWorldGuardSupport ().isRegionAllowed (location ))
@@ -181,10 +191,12 @@ private void breakBlock(@NotNull Location location) {
181191
182192 }
183193
194+ @ Override
184195 public void addRedstoneClockTest (@ NotNull Location location ) {
185196 this .activeClockTesters .putIfAbsent (location , new RedstoneClock (location , (System .currentTimeMillis () / 1000 ) + endTimeDelay ));
186197 }
187198
199+ @ Override
188200 public void reload () {
189201 this .antiRedstoneClockRemastered .reloadConfig ();
190202 this .endTimeDelay = antiRedstoneClockRemastered .getConfig ().getInt ("clock.endDelay" , 300 );
@@ -196,36 +208,42 @@ public void reload() {
196208 this .ignoredWorlds = antiRedstoneClockRemastered .getConfig ().getStringList ("check.ignoredWorlds" );
197209 }
198210
211+ @ Override
199212 public void removeClockByLocation (@ NotNull Location location ) {
200213 this .activeClockTesters .remove (location );
201214 }
202215
216+ @ Override
203217 public void removeClockByClock (@ NotNull RedstoneClock redstoneClock ) {
204218 removeClockByLocation (redstoneClock .getLocation ());
205219 }
206220
221+ @ Override
207222 public boolean containsLocation (@ NotNull Location location ) {
208223 return this .activeClockTesters .containsKey (location );
209224 }
210225
226+ @ Override
211227 @ Nullable
212228 public RedstoneClock getClockByLocation (@ NotNull Location location ) {
213229 return this .activeClockTesters .get (location );
214230 }
215231
232+ @ Override
216233 @ NotNull
217234 public Collection <RedstoneClock > getRedstoneClocks () {
218235 return Collections .unmodifiableCollection (this .activeClockTesters .values ());
219236 }
220237
238+ @ Override
221239 @ NotNull
222240 public Collection <Location > getRedstoneClockLocations () {
223241 return Collections .unmodifiableCollection (this .activeClockTesters .keySet ());
224242 }
225243
244+ @ Override
226245 @ NotNull
227246 public Map <Location , RedstoneClock > getActiveTester () {
228247 return Map .copyOf (this .activeClockTesters );
229248 }
230-
231- }
249+ }
0 commit comments