Skip to content

Commit 9078376

Browse files
JoltrastheEvilReaperrenovate[bot]
authored
Prepare release of version v0.3.0 (#17)
* Add license file * Update license file * Allow auto updates for patches * Update dependency gradle to v8.14.1 (#12) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency gradle to v8.14.2 (#13) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Remove final usage to allow custom implementations of the given event classes * Trigger Build * Update dependency gradle to v8.14.3 (#14) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Add support for Minecrat 1.21.5 (#15) * Update bom and aves version * Update artifact from Minestom --------- Co-authored-by: theEvilReaper <[email protected]> * Remove generic usage (#16) * Remove generic value usage * Update test base to reflect the flattened structure * Rename class to reflect their context usage * Add new methods * Override equals and hashcode * Rename class * Add tests for the service class * Remove generic mention in the documentation * Update version number --------- Co-authored-by: theEvilReaper <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 89d687b commit 9078376

File tree

15 files changed

+203
-92
lines changed

15 files changed

+203
-92
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
group = "net.onelitefeather"
10-
version = "0.2.0"
10+
version = "0.3.0"
1111

1212
java {
1313
toolchain {

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

renovate.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,13 @@
66
"rebaseWhen": "conflicted",
77
"labels": [
88
"renovate"
9+
],
10+
"packageRules": [
11+
{
12+
"matchUpdateTypes": [
13+
"patch"
14+
],
15+
"automerge": true
16+
}
917
]
1018
}

settings.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ dependencyResolutionManagement {
2828
}
2929
versionCatalogs {
3030
create("libs") {
31-
version("aves", "1.8.0")
31+
version("aves", "1.9.0")
3232
version("publishdata", "1.4.0")
33-
version("bom", "1.2.3")
33+
version("bom", "1.3.0")
3434

3535
library("mycelium.bom", "net.onelitefeather", "mycelium-bom").versionRef("bom")
3636

37-
library("minestom","net.minestom", "minestom-snapshots").withoutVersion()
37+
library("minestom","net.minestom", "minestom").withoutVersion()
3838
library("cyano", "net.onelitefeather", "cyano").withoutVersion()
3939

4040
library("aves", "net.theevilreaper", "aves").versionRef("aves")
Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package net.onelitefeather.guira;
22

3-
import net.theevilreaper.aves.map.BaseMap;
43
import net.onelitefeather.guira.data.SetupData;
54
import org.jetbrains.annotations.Contract;
65
import org.jetbrains.annotations.NotNull;
@@ -12,50 +11,62 @@
1211
import java.util.UUID;
1312

1413
/**
15-
* The (@link SetupDataService} is responsible for managing setup data during a runtime session.
14+
* The {@link SetupDataService} is responsible for managing setup data during a runtime session.
1615
* It allows adding, removing, and retrieving setup data associated with a unique identifier (UUID).
1716
*
18-
* @param <T> the type of setup data
17+
1918
* @author thEvilReaper
2019
* @version 1.0.0
2120
* @since 0.1.0
2221
*/
23-
public interface SetupDataService<T extends SetupData<? extends BaseMap>> {
22+
public interface SetupDataService {
2423

2524
/**
2625
* Creates a new instance of SetupDataService.
2726
*
28-
* @param <T> the type of setup data
2927
* @return a new instance of SetupDataService
3028
*/
3129
@Contract(pure = true)
32-
static @NotNull <T extends SetupData<? extends BaseMap>> SetupDataService<T> create() {
33-
return new SetupDataServiceImpl<>();
30+
static @NotNull SetupDataService create() {
31+
return new SetupDataServiceImpl();
3432
}
3533

3634
/**
37-
* Adds a new setup data to the service.
35+
* Checks if the service contains any setup data.
36+
*
37+
* @return true if the service is empty, false otherwise
38+
*/
39+
boolean isEmpty();
40+
41+
/**
42+
* Clears all setup data from the service.
43+
* This method removes all entries from the setup data map.
44+
*/
45+
void clear();
46+
47+
/**
48+
* Adds new setup data to the service.
3849
*
3950
* @param uuid the unique identifier for the setup data
4051
* @param data the setup data to add
4152
*/
42-
void add(@NotNull UUID uuid, @NotNull T data);
53+
void add(@NotNull UUID uuid, @NotNull SetupData data);
4354

4455
/**
4556
* Removes the setup data associated with the given UUID.
4657
*
4758
* @param uuid the unique identifier for the setup data
4859
* @return an optional containing the removed setup data, or empty if not found
4960
*/
50-
@NotNull Optional<@Nullable T> remove(@NotNull UUID uuid);
61+
@NotNull Optional<@Nullable SetupData> remove(@NotNull UUID uuid);
5162

5263
/**
5364
* Retrieves the setup data associated with the given UUID.
5465
*
5566
* @param uuid the unique identifier for the setup data
5667
* @return an optional containing the setup data, or empty if not found
5768
*/
58-
@NotNull Optional<@Nullable T> get(@NotNull UUID uuid);
69+
@NotNull Optional<@Nullable SetupData> get(@NotNull UUID uuid);
5970

6071
/**
6172
* Returns an unmodifiable view of the setup data map.
@@ -64,5 +75,5 @@ public interface SetupDataService<T extends SetupData<? extends BaseMap>> {
6475
*/
6576
@NotNull
6677
@UnmodifiableView
67-
Map<UUID, T> getView();
78+
Map<UUID, SetupData> getView();
6879
}
Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package net.onelitefeather.guira;
22

3-
import net.theevilreaper.aves.map.BaseMap;
43
import net.onelitefeather.guira.data.SetupData;
54
import org.jetbrains.annotations.NotNull;
65
import org.jetbrains.annotations.UnmodifiableView;
@@ -11,31 +10,57 @@
1110
import java.util.Optional;
1211
import java.util.UUID;
1312

14-
public final class SetupDataServiceImpl<T extends SetupData<? extends BaseMap>> implements SetupDataService<T> {
13+
public final class SetupDataServiceImpl implements SetupDataService {
1514

16-
private final Map<UUID, T> dataMap;
15+
private final Map<UUID, SetupData> dataMap;
1716

1817
SetupDataServiceImpl() {
1918
this.dataMap = new HashMap<>();
2019
}
2120

2221
@Override
23-
public void add(@NotNull UUID uuid, @NotNull T data) {
22+
public void clear() {
23+
if (this.dataMap.isEmpty()) return;
24+
this.dataMap.clear();
25+
}
26+
27+
/**
28+
* {@inheritDoc}
29+
*/
30+
@Override
31+
public boolean isEmpty() {
32+
return this.dataMap.isEmpty();
33+
}
34+
35+
/**
36+
* {@inheritDoc}
37+
*/
38+
@Override
39+
public void add(@NotNull UUID uuid, @NotNull SetupData data) {
2440
dataMap.put(uuid, data);
2541
}
2642

43+
/**
44+
* {@inheritDoc}
45+
*/
2746
@Override
28-
public @NotNull Optional<T> remove(@NotNull UUID uuid) {
47+
public @NotNull Optional<SetupData> remove(@NotNull UUID uuid) {
2948
return Optional.ofNullable(this.dataMap.remove(uuid));
3049
}
3150

51+
/**
52+
* {@inheritDoc}
53+
*/
3254
@Override
33-
public @NotNull Optional<T> get(@NotNull UUID uuid) {
55+
public @NotNull Optional<SetupData> get(@NotNull UUID uuid) {
3456
return Optional.ofNullable(this.dataMap.get(uuid));
3557
}
3658

59+
/**
60+
* {@inheritDoc}
61+
*/
3762
@Override
38-
public @NotNull @UnmodifiableView Map<UUID, T> getView() {
63+
public @NotNull @UnmodifiableView Map<UUID, SetupData> getView() {
3964
return Collections.unmodifiableMap(this.dataMap);
4065
}
4166
}

src/main/java/net/onelitefeather/guira/data/BaseSetupData.java renamed to src/main/java/net/onelitefeather/guira/data/MapSetupData.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@
99
import java.util.UUID;
1010

1111
/**
12-
* The {@link BaseSetupData} is a generic implementation of the {@link SetupData} interface.
12+
* The {@link MapSetupData} is a generic implementation of the {@link SetupData} interface.
1313
* It provides a basic implementation and needs to be extended by a specific setup data class.
1414
* @param <T> the reference type of the map
1515
* @version 1.0.0
1616
* @since 0.1.0
1717
* @author theEvilReaper
1818
*/
19-
public abstract non-sealed class BaseSetupData<T extends BaseMap> implements SetupData<T> {
19+
public abstract class MapSetupData<T extends BaseMap> implements SetupData {
2020

2121
protected final UUID uuid;
2222
protected final MapEntry mapEntry;
2323
protected T map;
2424

25-
protected BaseSetupData(@NotNull UUID uuid, @NotNull MapEntry mapEntry) {
25+
protected MapSetupData(@NotNull UUID uuid, @NotNull MapEntry mapEntry) {
2626
this.uuid = uuid;
2727
this.mapEntry = mapEntry;
2828
}
2929

3030
@Override
3131
public boolean equals(Object o) {
32-
if (!(o instanceof BaseSetupData<?> that)) return false;
32+
if (!(o instanceof MapSetupData<?> that)) return false;
3333
return Objects.equals(uuid, that.uuid);
3434
}
3535

@@ -38,22 +38,33 @@ public int hashCode() {
3838
return Objects.hashCode(uuid);
3939
}
4040

41-
@Override
41+
/**
42+
* Returns if the setup data has a map file.
43+
*
44+
* @return {@code true} if the setup data has a map
45+
*/
4246
public boolean hasMapFile() {
4347
return this.mapEntry.hasMapFile();
4448
}
4549

46-
@Override
50+
/**
51+
* Returns the map entry of the setup data.
52+
*
53+
* @return the map entry as {@link MapEntry}
54+
*/
4755
public @NotNull MapEntry getEntry() {
4856
return this.mapEntry;
4957
}
5058

51-
@Override
59+
/**
60+
* Returns the map of the setup data.
61+
*
62+
* @return the map as {@link BaseMap}
63+
*/
5264
public @NotNull UUID getId() {
5365
return this.uuid;
5466
}
5567

56-
@Override
5768
public @NotNull Optional<T> getMap() {
5869
return Optional.ofNullable(this.map);
5970
}
Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package net.onelitefeather.guira.data;
22

3-
import net.theevilreaper.aves.map.BaseMap;
4-
import net.theevilreaper.aves.map.MapEntry;
53
import org.jetbrains.annotations.NotNull;
64

7-
import java.util.Optional;
85
import java.util.UUID;
96

107
/**
118
* The {@link SetupData} interface defines an object which contains all relevant values about a setup instance.
129
*
13-
* @param <T> the reference type of the map
10+
* @author theEvilReaper
11+
* @version 1.2.0
12+
* @since 0.1.0
1413
*/
15-
public sealed interface SetupData<T extends BaseMap> permits BaseSetupData {
14+
public interface SetupData {
1615

1716
/**
1817
* Can be used to save the data from the setup into another format.
@@ -29,31 +28,10 @@ public sealed interface SetupData<T extends BaseMap> permits BaseSetupData {
2928
*/
3029
void loadData();
3130

32-
/**
33-
* Returns if the setup data has a map file.
34-
*
35-
* @return {@code true} if the setup data has a map
36-
*/
37-
boolean hasMapFile();
38-
3931
/**
4032
* Returns the owner of the setup data.
4133
*
4234
* @return the owner as {@link UUID}
4335
*/
4436
@NotNull UUID getId();
45-
46-
/**
47-
* Returns the map of the setup data.
48-
*
49-
* @return the map as {@link BaseMap}
50-
*/
51-
@NotNull Optional<T> getMap();
52-
53-
/**
54-
* Returns the map entry of the setup data.
55-
*
56-
* @return the map entry as {@link MapEntry}
57-
*/
58-
@NotNull MapEntry getEntry();
5937
}

src/main/java/net/onelitefeather/guira/event/SetupCreateEvent.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package net.onelitefeather.guira.event;
22

3-
import net.theevilreaper.aves.map.BaseMap;
43
import net.minestom.server.event.Event;
54
import net.minestom.server.event.trait.CancellableEvent;
65
import net.onelitefeather.guira.data.SetupData;
@@ -10,17 +9,16 @@
109
* The {@link SetupCreateEvent} can be used to indicate that a setup has started by the owner.
1110
* You need to call it on your own and the handling of it.
1211
*
13-
* @param <T> the reference from the data
1412
* @author thEvilReaper
1513
* @version 1.0.0
1614
* @since 0.1.0
1715
*/
18-
public final class SetupCreateEvent<T extends SetupData<? extends BaseMap>> implements Event, CancellableEvent {
16+
public class SetupCreateEvent implements Event, CancellableEvent {
1917

2018
private boolean cancelled;
21-
private final T data;
19+
private final SetupData data;
2220

23-
public SetupCreateEvent(@NotNull T data) {
21+
public SetupCreateEvent(@NotNull SetupData data) {
2422
this.data = data;
2523
}
2624

@@ -29,7 +27,7 @@ public SetupCreateEvent(@NotNull T data) {
2927
*
3028
* @return the reference
3129
*/
32-
public T getData() {
30+
public SetupData getData() {
3331
return data;
3432
}
3533

0 commit comments

Comments
 (0)