ignix.mc

Make this plugin a reality - the mace concept plugin

📎 1 file 3,229 chars
📄
pasted-code-1779620731284.txt
txt 314 lines
▶


Maces now only remain protected against:

* Lava
* Fire
* Explosion
* Natural despawn

No special handling for void.

---

# Commands

## Default

### `/concept`

Permission:

```yaml
concept.use
```

Default:

```yaml
true
```

Behavior:

* Opens selection INVENTORY GUI.
* If player already selected:

  * Deny access.
  * Show configured message.

Example:

```yaml
already-selected:
  "&cYou already chose your path."
```

---

## Admin Commands

Permission:

```yaml
admin.concept
```

Default:

```yaml
op
```

---

### `/concept wipe `

Purpose:

Reset player.

Effect:

* Remove ownership
* Remove selected path
* Remove punishment
* Allow INVENTORY GUI usage again

Also:

* Send webhook event
* Notify alert receivers

Example:

```yaml
Player  had their mace data wiped.
```

---

### `/concept reload`

Purpose:

Reload every plugin file.

NO SERVER RESTART REQUIRED.

Reload:

```text
config.yml
messages.yml
maces.yml
discord.yml
players.yml
```

Requirements:

* Safe reload
* INVENTORY GUI refresh instantly
* Rebuild cached messages
* Reconnect webhook settings

Success:

```yaml
Reload completed.
```

Webhook:

Optional event:

```yaml
reload-used: true
```

---

### `/concept webhook`

Purpose:

Tests Discord integration.

Behavior:

If webhook exists:

Send:

```text
TEST
Concept webhook operational.
```

Embed:

```yaml
Title:
Webhook Test

Description:
Connection successful.
```

If invalid:

```yaml
Webhook failed.
```

Permission:

```yaml
admin.concept
```

---

# alert.concept Permission

Permission:

```yaml
alert.concept
```

Default:

```yaml
op
```

Purpose:

Receives internal system alerts.

Players with this permission receive real-time notifications.

---

## Alert Triggers

### Duplicate mace detected

Example:

```text
⚠ Duplicate mace detected.
Player: Steve
Count: 2
```

Also:

* Send Discord webhook.

---

### Player wiped

Example:

```text
⚠ Admin reset a player.
Target: Steve
```

Also:

* Send Discord webhook.

---

### Mace lost

Example:

```text
⚠ Player permanently lost their mace.
```

Also:

* Send Discord webhook.

---

### Illegal pickup blocked

Example:

```text
⚠ Foreign mace pickup prevented.
```

Also:

* Send Discord webhook.

---

### Config reload

Example:

```text
⚠ ConceptMaces configs reloaded.
```

Also:

* Send Discord webhook.

---

# Discord.yml Update

Example:

```yaml
enabled: true

webhook-url: ""

events:

  mace-picked: true
  duplicate-detected: true

  wipe-used: true
  reload-used: true

  pickup-blocked: true

  mace-lost: true

  webhook-test: true
```

---

# Final Permission Tree

```yaml
concept.use:
  default: true

admin.concept:
  default: op

alert.concept:
  default: op
```

---

Developer implementation note:

Alert dispatch should use a centralized `AlertManager` so every event (chat alerts + webhook alerts) uses one pipeline and respects per-event toggles inside `discord.yml`.
Kodari AI
KodariMay 24 at 11:10 am 49,422 (v2)
ConceptMaces
A Minecraft plugin centered around a unique mace selection system. Players choose a mace path once via an interactive GUI, with their selection permanently tracked. Features include mace ownership enforcement, duplicate detection, illegal pickup prevention, and mace protection from lava/fire/explosion/despawn. Includes admin commands for wiping player data and reloading configs, a Discord webhook integration for real-time event alerts, and a centralized AlertManager for chat + webhook notifications.

Here’s my plan before writing any code:

  • Package: com.concept.maces

  • Files: Main plugin, ConfigManager, MessageManager, MaceManager, PlayerDataManager, AlertManager, DiscordWebhook, GUI framework (InventoryHandler, InventoryButton, InventoryGUI, GUIManager, GUIListener), SelectionGUI, MaceListener, ConceptCommand

  • Data flow: players.yml tracks ownership/selection/punishment; maces.yml defines available maces; discord.yml controls webhook events; messages.yml holds all player-facing strings

  • AlertManager is the single pipeline for both chat alerts (to alert.concept holders) and Discord webhook calls, respecting per-event toggles

Now let me fix the SelectionGUI — the mace-selected message logic was muddled. Let me also clean up the selection confirmation message properly:Let me read the actual files I created to verify their content before making corrections:

The files exist. Now I can see the real issues:

  1. SelectionGUI.handleSelection sends already-selected message after selection instead of a mace-selected message

  2. MessageManager.getRaw is called in SelectionGUI but the selection confirmation message key is wrong

  3. Need to verify all resource files and the remaining config files

Now I can see all the issues clearly. Let me fix them all:

  1. SelectionGUI.handleSelection — sends already-selected message after selection instead of mace-selected; also calls getRaw with wrong args

  2. messages.yml — missing mace-selected key

  3. MaceListener — PlayerPickupItemEvent was deprecated in 1.12+; should use EntityPickupItemEvent

  4. MaceListener — duplicate detection logic is missing (spec requires alerting when a player has >1 mace)

  5. ConceptCommand.findByName — only searches online players, doesn’t search PlayerDataManager cache

Now I can see the exact content. Let me fix SelectionGUI and MaceListener in parallel, and add the missing mace-selected message key:

Now fix MaceListener to use EntityPickupItemEvent (correct modern API) and add duplicate detection, and fix messages.yml to add the missing key:

Now fix MaceListener — replace deprecated PlayerPickupItemEvent with EntityPickupItemEvent and add duplicate detection on inventory open/join:

Now fix ConceptCommand.findByName to also search the PlayerDataManager cache for offline players:

Now add findByName to PlayerDataManager:

All fixes applied. Here’s a summary of what was corrected:

  • SelectionGUI.handleSelection — was sending the already-selected message after a successful selection (with a broken .replace() call). Now correctly sends mace-selected with {mace} replaced by the chosen mace’s display name, and always dispatches the mace-picked alert unconditionally through AlertManager

  • messages.yml — added the missing mace-selected key

  • MaceListener — replaced deprecated PlayerPickupItemEvent with EntityPickupItemEvent (correct API since 1.12); added duplicate mace detection that fires alertDuplicateMace when a player picks up their own mace while already holding one

  • PlayerDataManager — added findByName(String) to search the in-memory cache by player name for offline player lookups

  • ConceptCommand.findByName — now delegates to PlayerDataManager.findByName so /concept wipe <offlinePlayer> works correctly

ignix.mc

use this font for the messages: abcdefgyijklmnopqrstupwxyz

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
25 1,352
src/main/java/com/concept/maces/ConceptMaces.java
package com.concept.maces;

import com.concept.maces.alert.AlertManager;
import com.concept.maces.command.ConceptCommand;
import com.concept.maces.config.ConfigManager;
import com.concept.maces.config.DiscordConfig;
import com.concept.maces.config.MessageManager;
import com.concept.maces.config.MaceConfig;
import com.concept.maces.data.PlayerDataManager;
import com.concept.maces.inventory.gui.GUIListener;
import com.concept.maces.inventory.gui.GUIManager;
import com.concept.maces.listener.MaceListener;
import com.concept.maces.mace.MaceManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class ConceptMaces extends JavaPlugin {

    @Getter private static ConceptMaces instance;

    @Getter private ConfigManager configManager;
    @Getter private MessageManager messageManager;
    @Getter private MaceConfig maceConfig;
    @Getter private DiscordConfig discordConfig;
    @Getter private PlayerDataManager playerDataManager;
    @Getter private MaceManager maceManager;
    @Getter private AlertManager alertManager;
    @Getter private GUIManager guiManager;

    @Override
    public void onEnable() {
        instance = this;

        saveDefaultConfig();
        saveResource("messages.yml", false);
        saveResource("maces.yml", false);
        saveResource("discord.yml", false);
        saveResource("players.yml", false);

        this.configManager = new ConfigManager(this);
        this.messageManager = new MessageManager(this);
        this.maceConfig = new MaceConfig(this);
        this.discordConfig = new DiscordConfig(this);
        this.playerDataManager = new PlayerDataManager(this);
        this.alertManager = new AlertManager(this);
        this.maceManager = new MaceManager(this);
        this.guiManager = new GUIManager();

        Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
        Bukkit.getPluginManager().registerEvents(new MaceListener(this), this);

        ConceptCommand conceptCommand = new ConceptCommand(this);
        getCommand("concept").setExecutor(conceptCommand);
        getCommand("concept").setTabCompleter(conceptCommand);

        getLogger().info("ConceptMaces enabled.");
    }

    @Override
    public void onDisable() {
        if (playerDataManager != null) {
            playerDataManager.saveAll();
        }
        getLogger().info("ConceptMaces disabled.");
    }

    public void reloadPlugin() {
        reloadConfig();
        configManager.reload();
        messageManager.reload();
        maceConfig.reload();
        discordConfig.reload();
        playerDataManager.reload();
    }
}