Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Task
about: Create a new task
labels: task
assignees: ""
---

### Summary:

[Summary of the task]

### Description:

[Detailed description of the task]

---

**Estimated Ideal Time:** [Estimated time to complete the task]
15 changes: 15 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### Proposed Changes:

[Brief description of the changes made in this pull request]

### Details:

- [Detail 1]

### Related Issues:

- Resolves #[Issue nb]

### Screenshot:

[Optional section. Add UI/code screenshots if needed.]
45 changes: 45 additions & 0 deletions src/main/java/dev/deepcore/challenge/ChallengeDifficulty.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package dev.deepcore.challenge;

import java.util.Optional;

/** Represents the selectable difficulty level for a challenge run. */
public enum ChallengeDifficulty {
EASY("easy", "Easy"),
NORMAL("normal", "Normal"),
HARD("hard", "Hard");

private final String key;
private final String displayName;

ChallengeDifficulty(String key, String displayName) {
this.key = key;
this.displayName = displayName;
}

public String key() {
return key;
}

public String displayName() {
return displayName;
}

/**
* Returns the next difficulty in the cycle, wrapping from HARD back to EASY.
*
* @return next difficulty in the cycle
*/
public ChallengeDifficulty next() {
ChallengeDifficulty[] values = values();
return values[(ordinal() + 1) % values.length];
}

public static Optional<ChallengeDifficulty> fromKey(String key) {
for (ChallengeDifficulty d : values()) {
if (d.key.equalsIgnoreCase(key)) {
return Optional.of(d);
}
}
return Optional.empty();
}
}
18 changes: 17 additions & 1 deletion src/main/java/dev/deepcore/challenge/ChallengeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
import org.bukkit.plugin.java.JavaPlugin;

/**
* Stores and persists challenge enablement, mode, and component toggle state.
* Stores and persists challenge enablement, mode, component toggle state, and difficulty.
*/
public final class ChallengeManager {
private static final String ENABLED_PATH = "challenge.enabled";
private static final String MODE_PATH = "challenge.mode";
private static final String DIFFICULTY_PATH = "challenge.difficulty";
private static final String COMPONENTS_PATH = "challenge.components";
private static final String LEGACY_UNLIMITED_DEATHS_PATH = "challenge.components.unlimited_deaths";

private final JavaPlugin plugin;
private boolean enabled;
private ChallengeMode mode;
private ChallengeDifficulty difficulty;
private final Map<ChallengeComponent, Boolean> componentToggles;

/**
Expand All @@ -28,6 +30,7 @@ public ChallengeManager(JavaPlugin plugin) {
this.plugin = plugin;
this.enabled = false;
this.mode = ChallengeMode.KEEP_INVENTORY_UNLIMITED_DEATHS;
this.difficulty = ChallengeDifficulty.NORMAL;
this.componentToggles = new EnumMap<>(ChallengeComponent.class);
applyModeDefaults();
}
Expand All @@ -42,6 +45,9 @@ public void loadFromConfig() {
String configuredMode = config.getString(MODE_PATH, ChallengeMode.KEEP_INVENTORY_UNLIMITED_DEATHS.key());
mode = ChallengeMode.fromKey(configuredMode).orElse(ChallengeMode.KEEP_INVENTORY_UNLIMITED_DEATHS);

String configuredDifficulty = config.getString(DIFFICULTY_PATH, ChallengeDifficulty.NORMAL.key());
difficulty = ChallengeDifficulty.fromKey(configuredDifficulty).orElse(ChallengeDifficulty.NORMAL);

applyModeDefaults();
for (ChallengeComponent component : ChallengeComponent.values()) {
String path = componentPath(component);
Expand All @@ -65,6 +71,7 @@ public void saveToConfig() {
FileConfiguration config = plugin.getConfig();
config.set(ENABLED_PATH, enabled);
config.set(MODE_PATH, mode.key());
config.set(DIFFICULTY_PATH, difficulty.key());
for (ChallengeComponent component : ChallengeComponent.values()) {
config.set(componentPath(component), componentToggles.get(component));
}
Expand All @@ -79,6 +86,10 @@ public ChallengeMode getMode() {
return mode;
}

public ChallengeDifficulty getDifficulty() {
return difficulty;
}

public boolean isComponentEnabled(ChallengeComponent component) {
return componentToggles.getOrDefault(component, false);
}
Expand All @@ -98,6 +109,11 @@ public void setMode(ChallengeMode mode) {
saveToConfig();
}

public void setDifficulty(ChallengeDifficulty difficulty) {
this.difficulty = difficulty;
saveToConfig();
}

/**
* Enables or disables a specific challenge component and persists settings.
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/deepcore/challenge/ChallengeRuntime.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.deepcore.challenge;

import dev.deepcore.challenge.records.RunRecordsService;
import dev.deepcore.challenge.training.TrainingManager;
import dev.deepcore.challenge.world.WorldResetManager;
import dev.deepcore.records.RunRecordsService;

/**
* Holds initialized challenge runtime services for plugin lifecycle access.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package dev.deepcore.challenge;

import dev.deepcore.DeepCorePlugin;
import dev.deepcore.challenge.command.ChallengeCommand;
import dev.deepcore.challenge.command.LobbyCommand;
import dev.deepcore.challenge.records.RunRecordsService;
import dev.deepcore.challenge.training.TrainingManager;
import dev.deepcore.challenge.world.WorldResetManager;
import dev.deepcore.logging.DeepCoreLogger;
import dev.deepcore.records.RunRecordsService;
import org.bukkit.command.PluginCommand;

/**
Expand All @@ -30,7 +32,9 @@ public ChallengeRuntime initialize(DeepCorePlugin plugin, DeepCoreLogger logger)
worldResetManager.cleanupNonDefaultWorldsOnStartup();
challengeSessionManager.setWorldResetManager(worldResetManager);

RunRecordsService recordsService = new RunRecordsService(plugin);
String dbFileName = plugin.getConfig().getString("records.db-name", "records.db");
logger.info("Run records database: " + dbFileName);
RunRecordsService recordsService = new RunRecordsService(plugin, dbFileName);
recordsService.initialize();
challengeSessionManager.setRecordsService(recordsService);

Expand Down
Loading
Loading