Skip to content
Open
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
53 changes: 45 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
# DevoteMe-Minecraft

The DevoteMe Minecraft module is a Paper plugin that connects to your DevoteMe API and provides a daily "Verse of the Day" (VOTD) and a daily devotional experience directly in-game.
The DevoteMe Minecraft module is a Paper plugin that connects to your DevoteMe API and provides a daily "Verse of the Day" (VOTD), a daily devotional experience, and a full interactive Bible directly in-game.

## Features

- **Verse of the Day (VOTD):** Automatically sent to players on login and viewable on-demand via `/votd`.
- **Daily Devotion:** Opens a rich, paginated book GUI using `/devotion`.
- **Interactive Bible:** Complete Bible access (66 books) in-game using interactive written books via `/bible`.
- **Bible Versions:** Supports CSB, NIV, KJV, and ESV translations with per-player preferences.
- **Public API:** A structured API for other plugins to request VOTD, devotions, and Bible content.
- **MiniMessage Formatting:** Full support for modern Minecraft text formatting, including gradients, bold text, and hover/click events.
- **Caching & Reliability:** Fetches content from the DevoteMe API and caches it in memory. If the API is down, the plugin continues to serve the last successful result.
- **Automated Refreshes:** Refreshes content every 12 hours (configurable) to keep the experience fresh.
- **Caching & Reliability:** Fetches content from APIs and caches it locally. If an API is down, the plugin continues to serve the last successful result.
- **Automated Refreshes:** Refreshes VOTD/Devotion content every 12 hours (configurable).
- **Hologram Support:** Integrated with **DecentHolograms** to display the VOTD at multiple locations across your server.
- **Hologram Management:** In-game commands to create, list, and remove VOTD holograms without editing configuration files.

## Installation

1. Download the latest `DevoteMeMC.jar`.
2. Place the jar in your server's `plugins` folder.
3. Restart the server to generate the default configuration.
4. Edit `plugins/DevoteMeMC/config.yml` to set your `baseUrl` and optional `apiKey`.
4. Edit `plugins/DevoteMeMC/config.yml`:
- Set your `devoteme.baseUrl` and optional `apiKey`.
- **(Required for Bible)** Set your `bible.api.api-key` from [scripture.api.bible](https://scripture.api.bible).
5. (Optional) Install **DecentHolograms** if you wish to use the hologram features.
6. Run `/votd manage refresh` to fetch the initial content.

Expand All @@ -26,6 +30,8 @@ The DevoteMe Minecraft module is a Paper plugin that connects to your DevoteMe A
### Player Commands
- `/votd` - View the current Verse of the Day.
- `/devotion` - Open today's devotion in a book GUI.
- `/bible` - Opens the main Bible index.
- `/bibledefault <version>` - Set your preferred Bible version (CSB, NIV, KJV, ESV).

### Admin Commands
- `/votd manage add <name>` - Create a VOTD hologram at your current location.
Expand All @@ -39,18 +45,49 @@ The DevoteMe Minecraft module is a Paper plugin that connects to your DevoteMe A

- `devoteme.votd` - Allows viewing the Verse of the Day (Default: true).
- `devoteme.devotion` - Allows viewing the daily devotion (Default: true).
- `devoteme.bible` - Allows access to the Bible books (Default: true).
- `devoteme.bibledefault` - Allows setting a preferred Bible version (Default: true).
- `devoteme.votd.manage` - Allows access to all `/votd manage` subcommands (Default: op).

## Developer API

Other plugins can hook into DevoteMe to retrieve spiritual content.

### Maven Dependency
(Add your repository and dependency information here)

### Accessing the API
Ensure your plugin has `softdepend: [DevoteMeMC]` in `plugin.yml`.

```java
import com.devoteme.minecraft.api.DevoteMeAPI;
import com.devoteme.minecraft.api.DevoteMeAPIProvider;

public void myMethod() {
DevoteMeAPI api = DevoteMeAPIProvider.get();

// Get VOTD
Votd votd = api.getVotd();

// Get Bible Chapter
api.getBibleChapter(BibleVersion.KJV, BibleBook.JOHN, 3).thenAccept(chapter -> {
getLogger().info("John 3 text: " + chapter.getContent());
});
}
```

## Configuration

The plugin uses **Adventure MiniMessage** for all messages. You can use tags like `<gold>`, `<bold>`, `<hover:show_text:'Tooltip'>`, and `<click:open_url:'https://...'>`.
The plugin uses **Adventure MiniMessage** for VOTD messages. Bible features use standard legacy color codes.

### Placeholders
### Placeholders (VOTD)
In `config.yml`, you can use the following placeholders in VOTD-related messages and holograms:
- `<reference>` - The scripture reference (e.g., John 3:16).
- `<verse>` - The text of the verse.
- `<date>` - The display date for the content.
- `<link>` - A URL to the full passage.

## Data Storage
Hologram locations are stored in `plugins/DevoteMeMC/votd-locations.yml`. This file is managed automatically via commands, but can be manually edited if necessary.
- **Holograms**: `plugins/DevoteMeMC/votd-locations.yml`.
- **Player Data**: `plugins/DevoteMeMC/player-data.yml` (VOTD login history and Bible preferences).
- **Bible Cache**: `plugins/DevoteMeMC/bible_cache/`.
37 changes: 37 additions & 0 deletions src/main/java/com/devoteme/minecraft/DevoteMePlugin.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.devoteme.minecraft;

import com.devoteme.minecraft.api.DevoteMeAPIImpl;
import com.devoteme.minecraft.api.DevoteMeAPIProvider;
import com.devoteme.minecraft.api.DevoteMeApiClient;
import com.devoteme.minecraft.api.DevoteMeParser;
import com.devoteme.minecraft.api.bible.BibleApiClient;
import com.devoteme.minecraft.cache.BibleCacheManager;
import com.devoteme.minecraft.cache.ContentCache;
import com.devoteme.minecraft.commands.BibleCommand;
import com.devoteme.minecraft.commands.BibleDefaultCommand;
import com.devoteme.minecraft.commands.DevotionCommand;
import com.devoteme.minecraft.commands.VotdCommand;
import com.devoteme.minecraft.holograms.DecentHologramsService;
Expand All @@ -23,6 +29,8 @@ public class DevoteMePlugin extends JavaPlugin {

private DevoteMeApiClient api;
private ContentCache cache;
private BibleCacheManager bibleCacheManager;
private BibleApiClient bibleApiClient;
private VotdLocationStore locationStore;
private PlayerDataStore playerDataStore;
private HologramService holograms;
Expand All @@ -38,6 +46,11 @@ public void onEnable() {
);
this.locationStore = new VotdLocationStore(this);
this.playerDataStore = new PlayerDataStore(this);
this.bibleApiClient = new BibleApiClient(this);
this.bibleCacheManager = new BibleCacheManager(this, bibleApiClient);

// Register API
DevoteMeAPIProvider.register(new DevoteMeAPIImpl(this));

// Holograms (soft)
this.holograms = new DecentHologramsService(this, cache, locationStore);
Expand All @@ -59,6 +72,20 @@ public void onEnable() {
devotion.setExecutor(cmd);
}

PluginCommand bible = getCommand("bible");
if (bible != null) {
BibleCommand cmd = new BibleCommand(this);
bible.setExecutor(cmd);
bible.setTabCompleter(cmd);
}

PluginCommand bibleDefault = getCommand("bibledefault");
if (bibleDefault != null) {
BibleDefaultCommand cmd = new BibleDefaultCommand(this);
bibleDefault.setExecutor(cmd);
bibleDefault.setTabCompleter(cmd);
}

// Load stored data
locationStore.load();
playerDataStore.load();
Expand Down Expand Up @@ -112,11 +139,21 @@ public void sendVotdTo(Player p) {
}
}

@Override
public void onDisable() {
DevoteMeAPIProvider.unregister();
}

public void sendNoPerm(org.bukkit.command.CommandSender sender) {
sender.sendMessage(Text.render(getConfig().getString("messages.noPermission", "<red>No permission.</red>")));
}

public String getMessage(String path) {
return getConfig().getString("messages." + path, "").replace("&", "§");
}

public ContentCache getCache() { return cache; }
public BibleCacheManager getBibleCacheManager() { return bibleCacheManager; }
public VotdLocationStore getLocationStore() { return locationStore; }
public PlayerDataStore getPlayerDataStore() { return playerDataStore; }
public HologramService getHolograms() { return holograms; }
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/com/devoteme/minecraft/api/DevoteMeAPI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.devoteme.minecraft.api;

import com.devoteme.minecraft.api.bible.BibleApiClient;
import com.devoteme.minecraft.model.Devotion;
import com.devoteme.minecraft.model.Votd;
import com.devoteme.minecraft.model.bible.BibleBook;
import com.devoteme.minecraft.model.bible.BibleVersion;

import java.util.concurrent.CompletableFuture;

/**
* Public API for DevoteMe plugin.
*/
public interface DevoteMeAPI {

/**
* Get the current Verse of the Day.
* @return A CompletableFuture containing the VOTD.
*/
Votd getVotd();

/**
* Get today's devotional.
* @return A CompletableFuture containing the Devotion.
*/
Devotion getDevotion();

/**
* Fetch a Bible chapter from the configured API.
* @param version The Bible version.
* @param book The Bible book.
* @param chapter The chapter number.
* @return A CompletableFuture containing the chapter content.
*/
CompletableFuture<BibleApiClient.ChapterContent> getBibleChapter(BibleVersion version, BibleBook book, int chapter);
}
34 changes: 34 additions & 0 deletions src/main/java/com/devoteme/minecraft/api/DevoteMeAPIImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.devoteme.minecraft.api;

import com.devoteme.minecraft.DevoteMePlugin;
import com.devoteme.minecraft.api.bible.BibleApiClient;
import com.devoteme.minecraft.model.Devotion;
import com.devoteme.minecraft.model.Votd;
import com.devoteme.minecraft.model.bible.BibleBook;
import com.devoteme.minecraft.model.bible.BibleVersion;

import java.util.concurrent.CompletableFuture;

public class DevoteMeAPIImpl implements DevoteMeAPI {

private final DevoteMePlugin plugin;

public DevoteMeAPIImpl(DevoteMePlugin plugin) {
this.plugin = plugin;
}

@Override
public Votd getVotd() {
return plugin.getCache().getVotd();
}

@Override
public Devotion getDevotion() {
return plugin.getCache().getDevotion();
}

@Override
public CompletableFuture<BibleApiClient.ChapterContent> getBibleChapter(BibleVersion version, BibleBook book, int chapter) {
return plugin.getBibleCacheManager().getChapter(version, book, chapter);
}
}
38 changes: 38 additions & 0 deletions src/main/java/com/devoteme/minecraft/api/DevoteMeAPIProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.devoteme.minecraft.api;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

/**
* Provider for the DevoteMe API.
*/
public final class DevoteMeAPIProvider {

private static DevoteMeAPI api;

private DevoteMeAPIProvider() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}

/**
* Get the DevoteMe API instance.
* @return The API instance.
* @throws IllegalStateException If the API has not been initialized.
*/
public static @NotNull DevoteMeAPI get() {
if (api == null) {
throw new IllegalStateException("DevoteMe API has not been initialized yet!");
}
return api;
}

@ApiStatus.Internal
public static void register(DevoteMeAPI instance) {
api = instance;
}

@ApiStatus.Internal
public static void unregister() {
api = null;
}
}
Loading