Skip to content

Commit

Permalink
Add flag manager
Browse files Browse the repository at this point in the history
  • Loading branch information
cjburkey01 committed Aug 12, 2024
1 parent 9969594 commit cdbb1e6
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/main/java/com/cjburkey/claimchunk/flags/PermFlag.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package com.cjburkey.claimchunk.flags;

import java.util.HashMap;
import java.util.List;

/**
* Permission flag stuff
*
* @since 0.0.26
*/
public class PermFlag {

// TODO: INCLUDE BLOCK/ENTITY PROTECTIONS


}
69 changes: 67 additions & 2 deletions src/main/java/com/cjburkey/claimchunk/flags/PermFlags.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,79 @@
package com.cjburkey.claimchunk.flags;

import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.util.HashMap;
import java.util.List;

/**
* Keeps track of loading the permission flags specified in the flags.yml
* configuration file.
*
* @since 0.0.26
*/
public class PermFlags {

private final JavaPlugin plugin;
private final File defaultFlagsFile;
private final String defaultFlagsResource;
private final File flagsFile;
private final HashMap<String, PermFlag> flagMap = new HashMap<>();
private final HashMap<String, BlockFlagData> blockControls = new HashMap<>();
private final HashMap<String, EntityFlagData> entityControls = new HashMap<>();

public PermFlags(File flagsFile) {
public PermFlags(JavaPlugin plugin, File defaultFlagsFile, String defaultFlagsResource, File flagsFile) {
this.plugin= plugin;
this.defaultFlagsFile = defaultFlagsFile;
this.defaultFlagsResource = defaultFlagsResource;
this.flagsFile = flagsFile;
}

public void load() {
// TODO:
}

// -- CLASSES -- //

public static final class FlagData {
public boolean isListInclude;
public List<String> list;

public FlagData(boolean isListInclude, List<String> list) {
this.isListInclude = isListInclude;
this.list = list;
}
}

public enum BlockFlagType {
BREAK,
PLACE,
INTERACT,
EXPLODE,
}

public static class BlockFlagData {
public BlockFlagType flagType;
public FlagData flagData;

public BlockFlagData(BlockFlagType flagType, boolean isListInclude, List<String> list) {
this.flagType = flagType;
this.flagData = new FlagData(isListInclude, list);
}
}

public enum EntityFlagType {
DAMAGE,
INTERACT,
EXPLODE,
}

public static class EntityFlagData {
public EntityFlagType flagType;
public FlagData flagData;

public EntityFlagData(EntityFlagType flagType, boolean isListInclude, List<String> list) {
this.flagType = flagType;
this.flagData = new FlagData(isListInclude, list);
}
}
}

0 comments on commit cdbb1e6

Please sign in to comment.