-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
401 additions
and
132 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
addons/OreGenerator/src/main/java/fr/euphyllia/skylliaore/database/MariaDBInit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
api/src/main/java/fr/euphyllia/skyllia/api/database/DatabaseInitializeQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package fr.euphyllia.skyllia.api.database; | ||
|
||
import fr.euphyllia.skyllia.sgbd.exceptions.DatabaseException; | ||
|
||
/** | ||
* The {@code DatabaseInitializeQuery} class provides an abstract definition | ||
* of an initialization query for a database. | ||
* <p> | ||
* Classes extending this abstract class should implement the {@link #init()} method | ||
* to perform any necessary setup or configuration tasks, such as creating tables or | ||
* verifying the database schema. | ||
*/ | ||
public abstract class DatabaseInitializeQuery { | ||
|
||
/** | ||
* Initializes the database schema or performs any required setup operations. | ||
* | ||
* @return {@code true} if the initialization is successful, {@code false} otherwise | ||
* @throws DatabaseException if an error occurs during the database initialization | ||
*/ | ||
public abstract boolean init() throws DatabaseException; | ||
} |
61 changes: 61 additions & 0 deletions
61
api/src/main/java/fr/euphyllia/skyllia/api/database/IslandDataQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package fr.euphyllia.skyllia.api.database; | ||
|
||
import fr.euphyllia.skyllia.api.skyblock.Island; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.UUID; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* The {@code IslandDataQuery} class defines an abstract set of methods | ||
* for querying and manipulating island data in a SkyBlock context. | ||
* <p> | ||
* Implementations should handle operations such as retrieving islands | ||
* by owner or player, creating new islands, and obtaining island details. | ||
*/ | ||
public abstract class IslandDataQuery { | ||
|
||
/** | ||
* Retrieves an {@link Island} by the UUID of its owner. | ||
* | ||
* @param playerId the UUID of the island owner | ||
* @return a {@link CompletableFuture} that will complete with the retrieved {@link Island}, | ||
* or {@code null} if no matching island is found | ||
*/ | ||
public abstract CompletableFuture<@Nullable Island> getIslandByOwnerId(UUID playerId); | ||
|
||
/** | ||
* Retrieves an {@link Island} by the UUID of a player who is a member of the island. | ||
* | ||
* @param playerId the UUID of the player | ||
* @return a {@link CompletableFuture} that will complete with the retrieved {@link Island}, | ||
* or {@code null} if no matching island is found | ||
*/ | ||
public abstract CompletableFuture<@Nullable Island> getIslandByPlayerId(UUID playerId); | ||
|
||
/** | ||
* Inserts a new island into the data source. | ||
* | ||
* @param futurIsland the {@link Island} to be inserted | ||
* @return a {@link CompletableFuture} that will complete with {@code true} if the insertion | ||
* was successful, or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> insertIslands(Island futurIsland); | ||
|
||
/** | ||
* Retrieves an {@link Island} by its UUID. | ||
* | ||
* @param islandId the UUID of the island | ||
* @return a {@link CompletableFuture} that will complete with the retrieved {@link Island}, | ||
* or {@code null} if no island with the specified UUID is found | ||
*/ | ||
public abstract CompletableFuture<@Nullable Island> getIslandByIslandId(UUID islandId); | ||
|
||
/** | ||
* Retrieves the maximum number of members allowed in the specified {@link Island}. | ||
* | ||
* @param island the {@link Island} to check | ||
* @return a {@link CompletableFuture} that will complete with the maximum number of members | ||
*/ | ||
public abstract CompletableFuture<Integer> getMaxMemberInIsland(Island island); | ||
} |
107 changes: 107 additions & 0 deletions
107
api/src/main/java/fr/euphyllia/skyllia/api/database/IslandMemberQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package fr.euphyllia.skyllia.api.database; | ||
|
||
import fr.euphyllia.skyllia.api.skyblock.Island; | ||
import fr.euphyllia.skyllia.api.skyblock.Players; | ||
import fr.euphyllia.skyllia.api.skyblock.enums.RemovalCause; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.UUID; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
/** | ||
* The {@code IslandMemberQuery} class defines an abstract set of methods | ||
* for managing island members in a SkyBlock context. | ||
* <p> | ||
* Implementations should handle operations such as adding, updating, | ||
* and removing members, as well as retrieving specific members or owners. | ||
*/ | ||
public abstract class IslandMemberQuery { | ||
|
||
/** | ||
* Updates the membership information of a given player within the specified {@link Island}. | ||
* | ||
* @param island the {@link Island} the player belongs to | ||
* @param players the player's membership details | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the update succeeds, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> updateMember(Island island, Players players); | ||
|
||
/** | ||
* Retrieves the {@link Players} object associated with a specified island and player UUID. | ||
* | ||
* @param island the {@link Island} to search | ||
* @param playerId the UUID of the player | ||
* @return a {@link CompletableFuture} that completes with the {@link Players} object | ||
*/ | ||
public abstract CompletableFuture<Players> getPlayersIsland(Island island, UUID playerId); | ||
|
||
/** | ||
* Retrieves the {@link Players} object associated with a specified island and player name. | ||
* | ||
* @param island the {@link Island} to search | ||
* @param playerName the player's name | ||
* @return a {@link CompletableFuture} that completes with the {@link Players} object, | ||
* or {@code null} if the player is not found | ||
*/ | ||
public abstract CompletableFuture<@Nullable Players> getPlayersIsland(Island island, String playerName); | ||
|
||
/** | ||
* Retrieves all members in the specified {@link Island}. | ||
* | ||
* @param island the {@link Island} whose members are to be retrieved | ||
* @return a {@link CompletableFuture} that completes with a list of {@link Players}, | ||
* or {@code null} if no members are found | ||
*/ | ||
public abstract CompletableFuture<@Nullable CopyOnWriteArrayList<Players>> getMembersInIsland(Island island); | ||
|
||
/** | ||
* Retrieves the owner of the specified {@link Island}. | ||
* | ||
* @param island the {@link Island} to query | ||
* @return a {@link CompletableFuture} that completes with the owner as a {@link Players} object, | ||
* or {@code null} if no owner is found | ||
*/ | ||
public abstract CompletableFuture<@Nullable Players> getOwnerInIslandId(Island island); | ||
|
||
/** | ||
* Adds a "member clear" record to track a player's removal cause. | ||
* | ||
* @param playerId the UUID of the player | ||
* @param cause the {@link RemovalCause} for the removal | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the operation succeeds, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> addMemberClear(UUID playerId, RemovalCause cause); | ||
|
||
/** | ||
* Deletes a "member clear" record for the specified player and removal cause. | ||
* | ||
* @param playerId the UUID of the player | ||
* @param cause the {@link RemovalCause} for the removal | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the deletion succeeds, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> deleteMemberClear(UUID playerId, RemovalCause cause); | ||
|
||
/** | ||
* Checks if a "member clear" record exists for the specified player and removal cause. | ||
* | ||
* @param playerId the UUID of the player | ||
* @param cause the {@link RemovalCause} for the removal | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the record exists, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> checkClearMemberExist(UUID playerId, RemovalCause cause); | ||
|
||
/** | ||
* Deletes a member from the specified {@link Island}. | ||
* | ||
* @param island the {@link Island} from which the member will be removed | ||
* @param oldMember the {@link Players} object representing the member to be removed | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the removal succeeds, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> deleteMember(Island island, Players oldMember); | ||
} |
71 changes: 71 additions & 0 deletions
71
api/src/main/java/fr/euphyllia/skyllia/api/database/IslandPermissionQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package fr.euphyllia.skyllia.api.database; | ||
|
||
import fr.euphyllia.skyllia.api.skyblock.Island; | ||
import fr.euphyllia.skyllia.api.skyblock.model.PermissionRoleIsland; | ||
import fr.euphyllia.skyllia.api.skyblock.model.RoleType; | ||
import fr.euphyllia.skyllia.api.skyblock.model.permissions.PermissionsType; | ||
|
||
import java.util.UUID; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* The {@code IslandPermissionQuery} class defines an abstract set of methods | ||
* for managing island permissions in a SkyBlock context. | ||
* <p> | ||
* Implementations should handle permission updates and retrieval for different | ||
* roles and game rule configurations. | ||
*/ | ||
public abstract class IslandPermissionQuery { | ||
|
||
/** | ||
* Updates the permissions for a specific {@link PermissionsType} and {@link RoleType} | ||
* on the given island. | ||
* | ||
* @param island the {@link Island} whose permissions are to be updated | ||
* @param permissionsType the type of permission to update | ||
* @param roleType the role type (e.g., OWNER, MEMBER) for which permissions are updated | ||
* @param permissions the new permission flags as a {@code long} value | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the update succeeds, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> updateIslandsPermission( | ||
Island island, | ||
PermissionsType permissionsType, | ||
RoleType roleType, | ||
long permissions | ||
); | ||
|
||
/** | ||
* Retrieves the {@link PermissionRoleIsland} object representing permissions | ||
* for the specified {@link PermissionsType} and {@link RoleType} on the given island. | ||
* | ||
* @param islandId the UUID of the island | ||
* @param permissionsType the type of permission to retrieve | ||
* @param roleType the role type (e.g., OWNER, MEMBER) | ||
* @return a {@link CompletableFuture} that completes with the corresponding | ||
* {@link PermissionRoleIsland} object | ||
*/ | ||
public abstract CompletableFuture<PermissionRoleIsland> getIslandPermission( | ||
UUID islandId, | ||
PermissionsType permissionsType, | ||
RoleType roleType | ||
); | ||
|
||
/** | ||
* Retrieves the game rule value (usually represented as a long) for the specified island. | ||
* | ||
* @param island the {@link Island} whose game rule is to be retrieved | ||
* @return a {@link CompletableFuture} that completes with the game rule value | ||
*/ | ||
public abstract CompletableFuture<Long> getIslandGameRule(Island island); | ||
|
||
/** | ||
* Updates the game rule value for the specified island. | ||
* | ||
* @param island the {@link Island} whose game rule is to be updated | ||
* @param value the new game rule value as a {@code long} | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the update succeeds, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> updateIslandGameRule(Island island, long value); | ||
} |
73 changes: 73 additions & 0 deletions
73
api/src/main/java/fr/euphyllia/skyllia/api/database/IslandUpdateQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package fr.euphyllia.skyllia.api.database; | ||
|
||
import fr.euphyllia.skyllia.api.skyblock.Island; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* The {@code IslandUpdateQuery} class defines an abstract set of methods | ||
* for updating various properties of an {@link Island} in a SkyBlock context. | ||
* <p> | ||
* Implementations should handle operations such as toggling the island status | ||
* (disable/private), adjusting maximum members, and resizing the island. | ||
*/ | ||
public abstract class IslandUpdateQuery { | ||
|
||
/** | ||
* Updates the disabled status of the specified island. | ||
* | ||
* @param island the {@link Island} to update | ||
* @param disable {@code true} to disable the island, {@code false} to enable it | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the update succeeds, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> updateDisable(Island island, boolean disable); | ||
|
||
/** | ||
* Updates the private status of the specified island. | ||
* | ||
* @param island the {@link Island} to update | ||
* @param privateIsland {@code true} to set the island as private, {@code false} to make it public | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the update succeeds, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> updatePrivate(Island island, boolean privateIsland); | ||
|
||
/** | ||
* Checks if the specified island is disabled. | ||
* | ||
* @param island the {@link Island} to check | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the island is disabled, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> isDisabledIsland(Island island); | ||
|
||
/** | ||
* Checks if the specified island is set to private. | ||
* | ||
* @param island the {@link Island} to check | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the island is private, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> isPrivateIsland(Island island); | ||
|
||
/** | ||
* Sets the maximum number of members for the specified island. | ||
* | ||
* @param island the {@link Island} to update | ||
* @param newValue the new maximum number of members | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the update succeeds, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> setMaxMemberInIsland(Island island, int newValue); | ||
|
||
/** | ||
* Sets the size of the specified island. | ||
* | ||
* @param island the {@link Island} to update | ||
* @param newValue the new size of the island (e.g., radius or diameter, depending on implementation) | ||
* @return a {@link CompletableFuture} that completes with {@code true} if the update succeeds, | ||
* or {@code false} otherwise | ||
*/ | ||
public abstract CompletableFuture<Boolean> setSizeIsland(Island island, double newValue); | ||
} |
Oops, something went wrong.