# For developer

For developers who want to integrate with **AdvancementsCore**, you can use the custom event :&#x20;

#### Example Usage

[**Github - AdvancementsGain**](https://github.com/SoimKiyo/AdvancementsGain)

#### 📌 Maven (You need to use the local jar directly)

```xml
<dependency>
    <groupId>com.forgotdot</groupId>
    <artifactId>AdvancementsCore</artifactId>
    <version>1.4</version>
    <scope>system</scope>
    <systemPath>C:/PathToAdvancementsCore.jar</systemPath>
</dependency>
```

#### 📌 CustomAchievementCompleteEvent

```java
package com.forgotdot.advancementscore.events;

import com.forgotdot.advancementscore.data.Achievement;
import com.forgotdot.advancementscore.data.Team;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

/**
 * Custom event triggered when a player completes an achievement.
 */
public class CustomAchievementCompleteEvent extends Event {

    // Handler list required for Bukkit event management
    private static final HandlerList HANDLERS = new HandlerList();

    // The player who completed the achievement
    private final Player player;

    // The completed achievement
    private final Achievement achievement;

    // The player's team (can be null if the player has no team)
    private final Team team;

    /**
     * Constructor for `CustomAchievementCompleteEvent`
     *
     * @param player      The player who completed the achievement.
     * @param achievement The achievement that was completed.
     * @param team        The player's team (can be null if the player has no team).
     */
    public CustomAchievementCompleteEvent(Player player, Achievement achievement, Team team) {
        this.player = player;
        this.achievement = achievement;
        this.team = team;
    }

    /**
     * Gets the player who completed the achievement.
     *
     * @return The player instance.
     */
    public Player getPlayer() {
        return player;
    }

    /**
     * Gets the completed achievement.
     *
     * @return The achievement instance.
     */
    public Achievement getAchievement() {
        return achievement;
    }

    /**
     * Gets the player's team (can be null if the player has no team).
     *
     * @return The `Team` instance or null.
     */
    public Team getTeam() {
        return team;
    }

    /**
     * Returns the handler list for event management.
     *
     * @return The `HandlerList` instance.
     */
    @Override
    public HandlerList getHandlers() {
        return HANDLERS;
    }

    /**
     * Returns the handler list for Bukkit event system.
     *
     * @return The `HandlerList` instance.
     */
    public static HandlerList getHandlerList() {
        return HANDLERS;
    }
}

```

#### 📌 CustomAchievementProgressEvent

```java
package com.forgotdot.advancementscore.events;

import com.forgotdot.advancementscore.data.Achievement;
import com.forgotdot.advancementscore.data.Team;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

/**
 * Custom event triggered when a player progresses in an achievement.
 */
public class CustomAchievementProgressEvent extends Event {

    private static final HandlerList HANDLERS = new HandlerList();

    private final Player player;
    private final Achievement achievement;
    private final Team team;
    private final int newProgress;
    private final int oldProgress;

    /**
     * Constructor for CustomAchievementProgressEvent.
     *
     * @param player      The player making progress in the achievement.
     * @param achievement The achievement being progressed.
     * @param team        The player's team (can be null if solo).
     * @param newProgress The new progress value.
     * @param oldProgress The previous progress value.
     */
    public CustomAchievementProgressEvent(Player player, Achievement achievement, Team team, int newProgress, int oldProgress) {
        this.player = player;
        this.achievement = achievement;
        this.team = team;
        this.newProgress = newProgress;
        this.oldProgress = oldProgress;
    }

    /**
     * Gets the player who made progress.
     *
     * @return The player instance.
     */
    public Player getPlayer() {
        return player;
    }

    /**
     * Gets the achievement being progressed.
     *
     * @return The achievement instance.
     */
    public Achievement getAchievement() {
        return achievement;
    }

    /**
     * Gets the player's team (can be null if solo).
     *
     * @return The team instance or null.
     */
    public Team getTeam() {
        return team;
    }

    /**
     * Gets the new progress value.
     *
     * @return The new progress amount.
     */
    public int getNewProgress() {
        return newProgress;
    }

    /**
     * Gets the old progress value before this update.
     *
     * @return The previous progress amount.
     */
    public int getOldProgress() {
        return oldProgress;
    }

    /**
     * Returns the handler list for event management.
     *
     * @return The HandlerList instance.
     */
    @Override
    public HandlerList getHandlers() {
        return HANDLERS;
    }

    /**
     * Returns the static handler list for Bukkit event system.
     *
     * @return The HandlerList instance.
     */
    public static HandlerList getHandlerList() {
        return HANDLERS;
    }
}

```

#### 📌 CustomTeamCreateEvent

```java
package com.forgotdot.advancementscore.events;

import com.forgotdot.advancementscore.data.Team;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

/**
 * Event triggered when a team is created.
 */
public class CustomTeamCreateEvent extends Event {

    private static final HandlerList HANDLERS = new HandlerList();

    private final Player player; // The player who created the team.
    private final Team team;     // The team that was created.

    public CustomTeamCreateEvent(Player player, Team team) {
        this.player = player;
        this.team = team;
    }

    public Player getPlayer() {
        return player;
    }

    public Team getTeam() {
        return team;
    }

    @Override
    public HandlerList getHandlers() {
        return HANDLERS;
    }

    public static HandlerList getHandlerList() {
        return HANDLERS;
    }
}

```

#### 📌 CustomTeamJoinEvent

```java
package com.forgotdot.advancementscore.events;

import com.forgotdot.advancementscore.data.Team;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

/**
 * Event triggered when a player joins a team.
 */
public class CustomTeamJoinEvent extends Event {

    private static final HandlerList HANDLERS = new HandlerList();

    private final Player player; // The player who joined the team.
    private final Team team;     // The team that the player joined.

    public CustomTeamJoinEvent(Player player, Team team) {
        this.player = player;
        this.team = team;
    }

    public Player getPlayer() {
        return player;
    }

    public Team getTeam() {
        return team;
    }

    @Override
    public HandlerList getHandlers() {
        return HANDLERS;
    }

    public static HandlerList getHandlerList() {
        return HANDLERS;
    }
}

```

#### 📌 CustomTeamLeaveEvent

```java
package com.forgotdot.advancementscore.events;

import com.forgotdot.advancementscore.data.Team;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

/**
 * Event triggered when a player leaves a team.
 */
public class CustomTeamLeaveEvent extends Event {

    private static final HandlerList HANDLERS = new HandlerList();

    private final Player player; // The player who left the team.
    private final Team team;     // The team the player left.

    public CustomTeamLeaveEvent(Player player, Team team) {
        this.player = player;
        this.team = team;
    }

    public Player getPlayer() {
        return player;
    }

    public Team getTeam() {
        return team;
    }

    @Override
    public HandlerList getHandlers() {
        return HANDLERS;
    }

    public static HandlerList getHandlerList() {
        return HANDLERS;
    }
}

```



#### 📌 Achievement

```java
package com.forgotdot.advancementscore.data;

import org.bukkit.Material;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Represents an achievement that players can complete.
 */
public class Achievement {
    private final String id;
    private final String name;
    private final String description;
    private final Material material;
    private final String type;
    private final Set<String> arguments;
    private final int threshold;
    private final int points;
    private final String world;
    private final int day;
    private int currentProgress;

    /**
     * Constructor for an achievement.
     *
     * @param id          Unique identifier for the achievement.
     * @param name        The name of the achievement.
     * @param description A brief description of the achievement.
     * @param material    The material/icon representing the achievement.
     * @param type        The type of achievement (e.g., "BLOCK_BREAK", "ENTITY_KILL").
     * @param arguments   Additional arguments related to the achievement.
     * @param threshold   The required progress to complete the achievement.
     * @param points      The number of points awarded upon completion.
     * @param world       The world where this achievement is valid.
     * @param day         The in-game day when the achievement can be completed.
     */
    public Achievement(String id, String name, String description, Material material, String type, List<String> arguments, int threshold, int points, String world, int day) {
        this.id = id;
        this.name = name;
        this.description = description;
        this.material = material;
        this.type = type;
        this.arguments = new HashSet<>(arguments); // Convert List to Set for faster lookups
        this.threshold = threshold;
        this.points = points;
        this.world = world;
        this.day = day;
        this.currentProgress = 0; // Initial progress starts at 0
    }

    /**
     * Gets the unique identifier of the achievement.
     *
     * @return The achievement ID.
     */
    public String getId() {
        return id;
    }

    /**
     * Gets the name of the achievement.
     *
     * @return The achievement name.
     */
    public String getName() {
        return name;
    }

    /**
     * Gets the description of the achievement.
     *
     * @return The achievement description.
     */
    public String getDescription() {
        return description;
    }

    /**
     * Gets the material associated with this achievement.
     *
     * @return The material representing the achievement.
     */
    public Material getMaterial() {
        return material;
    }

    /**
     * Gets the type of achievement (e.g., "BLOCK_BREAK", "ENTITY_KILL").
     *
     * @return The achievement type.
     */
    public String getType() {
        return type;
    }

    /**
     * Gets the arguments required for this achievement (e.g., specific block types, entities, etc.).
     *
     * @return A set of arguments related to the achievement.
     */
    public Set<String> getArguments() {
        return arguments;
    }

    /**
     * Gets the required progress threshold to complete the achievement.
     *
     * @return The required amount to complete the achievement.
     */
    public int getThreshold() {
        return threshold;
    }

    /**
     * Gets the number of points awarded when completing the achievement.
     *
     * @return The points granted upon completion.
     */
    public int getPoints() {
        return points;
    }

    /**
     * Gets the world in which this achievement is valid.
     *
     * @return The world name.
     */
    public String getWorld() {
        return world;
    }

    /**
     * Gets the in-game day when this achievement can be completed.
     *
     * @return The day number.
     */
    public int getDay() {
        return day;
    }

    /**
     * Gets the player's current progress towards completing this achievement.
     *
     * @return The current progress value.
     */
    public int getCurrentProgress() {
        return currentProgress;
    }

    /**
     * Sets the player's current progress towards this achievement.
     *
     * @param currentProgress The new progress value.
     */
    public void setCurrentProgress(int currentProgress) {
        this.currentProgress = currentProgress;
    }

    /**
     * Checks if the achievement has been completed.
     *
     * @return True if the current progress meets or exceeds the required threshold.
     */
    public boolean isCompleted() {
        return currentProgress >= threshold;
    }

    /**
     * Provides a string representation of the achievement for debugging purposes.
     *
     * @return A formatted string containing achievement details.
     */
    @Override
    public String toString() {
        return "Achievement{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", material=" + material +
                ", type='" + type + '\'' +
                ", arguments=" + arguments +
                ", threshold=" + threshold +
                ", points=" + points +
                ", world='" + world + '\'' +
                ", day=" + day +
                ", currentProgress=" + currentProgress +
                '}';
    }
}

```



#### 📌 Team

```java
package com.forgotdot.advancementscore.data;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

/**
 * Represents a team of players who can progress and earn points together.
 */
public class Team {
    private final String id;
    private final String name;
    private final Set<UUID> members;
    private int points;

    /**
     * Constructor for a team.
     *
     * @param id   Unique identifier for the team.
     * @param name Name of the team.
     */
    public Team(String id, String name) {
        this.id = id;
        this.name = name;
        this.members = new HashSet<>();
        this.points = 0;
    }

    /**
     * Gets the team's unique ID.
     *
     * @return The team ID.
     */
    public String getId() {
        return id;
    }

    /**
     * Gets the team's name.
     *
     * @return The team name.
     */
    public String getName() {
        return name;
    }

    /**
     * Gets the set of player UUIDs who are members of the team.
     *
     * @return A set of player UUIDs.
     */
    public Set<UUID> getMembers() {
        return members;
    }

    /**
     * Gets the current points of the team.
     *
     * @return The team's point total.
     */
    public int getPoints() {
        return points;
    }

    /**
     * Adds a player to the team.
     *
     * @param playerId The UUID of the player to add.
     */
    public void addMember(UUID playerId) {
        members.add(playerId);
    }

    /**
     * Removes a player from the team.
     *
     * @param playerId The UUID of the player to remove.
     */
    public void removeMember(UUID playerId) {
        members.remove(playerId);
    }

    /**
     * Adds points to the team.
     *
     * @param points The number of points to add.
     */
    public void addPoints(int points) {
        this.points = Math.max(this.points + points, 0);
    }

    /**
     * Removes points from the team.
     *
     * @param points The number of points to subtract.
     */
    public void removePoints(int points) {
        this.points = Math.max(this.points - points, 0);
    }

    /**
     * Sets the team's points to a specific value.
     *
     * @param points The new point total.
     */
    public void setPoints(int points) {
        this.points = Math.max(points, 0);
    }

    /**
     * Debugging method to display team details.
     *
     * @return A string representation of the team.
     */
    @Override
    public String toString() {
        return "Team{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", members=" + members +
                ", points=" + points +
                '}';
    }
}

```
