Skip to content

Commit

Permalink
Add untested flag saving/loading
Browse files Browse the repository at this point in the history
  • Loading branch information
cjburkey01 committed Aug 22, 2024
1 parent 16fef8c commit 446fda4
Show file tree
Hide file tree
Showing 13 changed files with 365 additions and 726 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/cjburkey/claimchunk/ClaimChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.cjburkey.claimchunk.rank.RankHandler;
import com.cjburkey.claimchunk.service.prereq.claim.*;
import com.cjburkey.claimchunk.smartcommand.CCBukkitCommand;
import com.cjburkey.claimchunk.smartcommand.sub.ply.flags.FlagHandler;
import com.cjburkey.claimchunk.transition.FromPre0023;
import com.cjburkey.claimchunk.update.*;
import com.cjburkey.claimchunk.worldguard.WorldGuardHandler;
Expand Down Expand Up @@ -102,6 +103,8 @@ public final class ClaimChunk extends JavaPlugin implements IClaimChunkPlugin {
@Getter private ChunkHandler chunkHandler;
// An instance of the player handler
@Getter private PlayerHandler playerHandler;
// An instance of the permission flag handler
@Getter private FlagHandler flagHandler;
// An instance of the rank handler
@Getter private RankHandler rankHandler;
// An instance of the world permissions manager
Expand Down Expand Up @@ -285,6 +288,7 @@ public void onEnable() {

chunkHandler = new ChunkHandler(dataHandler, this);
playerHandler = new PlayerHandler(dataHandler, this);
flagHandler = new FlagHandler(dataHandler, this);

// As of version 0.0.23, the `ranks.json` file will be located in
// `/plugins/ClaimChunk` instead of `/plugins/ClaimChunk/data` to make
Expand Down

This file was deleted.

6 changes: 3 additions & 3 deletions src/main/java/com/cjburkey/claimchunk/chunk/DataChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
public record DataChunk(
@NotNull ChunkPos chunk,
@NotNull UUID player,
@NotNull HashSet<String> defaultFlags,
@NotNull HashMap<UUID, HashSet<String>> specificFlags) {
@NotNull HashMap<String, Boolean> defaultFlags,
@NotNull HashMap<UUID, HashMap<String, Boolean>> specificFlags) {
public DataChunk(@NotNull ChunkPos chunk, @NotNull UUID player) {
this(chunk, player, new HashSet<>(), new HashMap<>());
this(chunk, player, new HashMap<>(), new HashMap<>());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.cjburkey.claimchunk.player.FullPlayerData;
import com.cjburkey.claimchunk.player.SimplePlayerData;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;
Expand Down Expand Up @@ -119,33 +120,6 @@ public interface IClaimChunkDataHandler {
*/
DataChunk[] getClaimedChunks();

/**
* Toggles whether TNT can explode in the given chunk.
*
* @param ignoredPos The position of the chunk
* @return Whether TNT is now enabled in the provided chunk
* @since 0.0.16
* @deprecated Unused.
*/
@Deprecated
default boolean toggleTnt(ChunkPos ignoredPos) {
return false;
}

/**
* Retrieves whether TNT can explode in the given chunk (regardless of whether TNT is disabled
* in the config).
*
* @param ignoredPos The position of the chunk
* @return Whether TNT is enabled in the provided chunk
* @since 0.0.16
* @deprecated Unused.
*/
@Deprecated
default boolean isTntEnabled(ChunkPos ignoredPos) {
return false;
}

// -- PLAYERS -- //

/**
Expand Down Expand Up @@ -338,85 +312,48 @@ default void addPlayer(UUID player, String lastIgn, boolean alerts, int defaultM
// -- ACCESS -- //

/**
* Enable the given permission flag(s) by default in the provided player's chunks.
*
* @param owner Owner of the chunks granting access.
* @param flagNames The name(s) of the flag(s) to grant.
* @since 0.0.26
*/
void grantPermissionFlagsGlobalDefault(UUID owner, String... flagNames);

/**
* Disable the given permission flag(s) by default in the provided player's chunks.
*
* @param owner Owner of the chunks revoking access.
* @param flagNames The name(s) of the flag(s) to revoke.
* @since 0.0.26
*/
void revokePermissionFlagsGlobalDefault(UUID owner, String... flagNames);

/**
* Enable the given permission flag(s) by default in the provided chunk.
*
* @param owner Owner of the chunks granting access.
* @param chunk Position of the chunk to grant access in.
* @param flagNames The name(s) of the flag(s) to grant.
* @since 0.0.26
*/
void grantPermissionFlagsChunkDefault(UUID owner, ChunkPos chunk, String... flagNames);

/**
* Disable the given permission flag(s) by default in the provided chunk.
*
* @param owner Owner of the chunks revoking access.
* @param chunk Position of the chunk to revoke access from.
* @param flagNames The name(s) of the flag(s) to revoke.
* @since 0.0.26
*/
void revokePermissionFlagsChunkDefault(UUID owner, ChunkPos chunk, String... flagNames);

/**
* Enable the given permission flag(s) by default for the provided player in the owner's chunks.
*
* @param owner Owner of the chunks granting access.
* @param accessor Other player having access granted to them.
* @param flagNames The name(s) of the flag(s) to grant.
* @since 0.0.26
*/
void grantPermissionFlagsPlayerDefault(UUID owner, UUID accessor, String... flagNames);

/**
* Disable the given permission flag(s) by default for the provided player in the owner's
* chunks.
* Enable the given permission flag(s) for the provided player
*
* @param owner Owner of the chunks granting access.
* @param accessor Other player having access revoked from them.
* @param flagNames The name(s) of the flag(s) to revoke.
* @param owner Owner of the chunks granting access. Cannot be null.
* @param accessor Other player having access granted to them, or null to apply defaults for all
* players.
* @param chunk The chunk to grant access to, or null to apply as defaults for all chunks.
* @param flags Mapping of flags to their allow/deny boolean value. Must not be null.
* @since 0.0.26
*/
void revokePermissionFlagsPlayerDefault(UUID owner, UUID accessor, String... flagNames);
void setPermissionFlags(
@NotNull UUID owner,
@Nullable UUID accessor,
@Nullable ChunkPos chunk,
@NotNull HashMap<String, Boolean> flags);

/**
* Enable the given permission flag(s) for the provided player in a specific chunk.
* Unset the provided permissions to defer to defaults
*
* @param owner Owner of the chunks granting access.
* @param accessor Other player having access granted to them.
* @param chunk The chunk to grant access to.
* @param flagNames The name(s) of the flag(s) to grant.
* @param owner Owner of the chunks granting access. Cannot be null
* @param accessor Other player having access revoked from them. May be null to set flags for
* all chunks.
* @param chunk Chunk to revoke access from, or null to clear the all chunk default
* @param flagNames The name(s) of the flag(s) to revoke. May be null to set flags for all
* players.
* @since 0.0.26
*/
void grantPermissionFlagsPlayerChunk(
UUID owner, UUID accessor, ChunkPos chunk, String... flagNames);
void clearPermissionFlags(
@NotNull UUID owner,
@Nullable UUID accessor,
@Nullable ChunkPos chunk,
@NotNull String... flagNames);

/**
* Disable the given permission flag(s) for the provided player in a specific chunk.
* TODO: JAVADOC
*
* @param owner Owner of the chunks revoking access.
* @param accessor Other player having access revoked from them.
* @param chunk The chunk to take access for.
* @param flagNames The name(s) of the flag(s) to revoke.
* @param owner
* @param accessor
* @param chunk
* @return
* @since 0.0.26
*/
void revokePermissionFlagsPlayerChunk(
UUID owner, UUID accessor, ChunkPos chunk, String... flagNames);
@NotNull
Map<String, Boolean> getPlyFlags(
@NotNull UUID owner, @Nullable UUID accessor, @Nullable ChunkPos chunk);
}
Loading

0 comments on commit 446fda4

Please sign in to comment.