πStep
This module aims to record player statistics when they reach significant milestones on your server. The goal is to analyze player progression and understand the actions they take to achieve these milestones.
When a step (milestone) is reached, all player statistics are saved, including blocks mined, items used, and entities killed. You can also add your own data using the API.
Currently, zEssentials does not provide tools for data analysis. Therefore, you must create your own analysis tools or directly examine the database.
To save a player's step, execute the command /step <player> <milestone name>
. All steps must be registered in the module's config.yml
file.
Data is stored in JSON format, allowing for easy manipulation by other plugins or websites.
Configuration
config.yml
config.yml
########################################################################################################################
#
# βββββββββββββββββββββββββββββββββββββββββ
# βββββββββββββββββββββββββββββββββββββββββ
# βββββββββββββββββββββββββββββββββββββββββ
# βββββββββββββββββββββββββββββββββββββββββ
# βββββββββββββββββββββββββββββββββββββββββ
# βββββββββββββββββββββββββββββββββββββββββ
#
# Documentation: https://zessentials.groupez.dev/modules/steps
#
########################################################################################################################
enable: true
steps:
- name: "step-1"
- name: "step-2"
- name: "step-3"
- name: "step-4"
API
Create a CustomStep
To create a custom step, you must use the CustomStep
interface. You need to return a Map
containing all your information.
package fr.maxlego08.example.steps;
import fr.maxlego08.example.api.dto.ShopLogDTO;
import fr.maxlego08.essentials.api.steps.CustomStep;
import fr.maxlego08.example.CorePlugin;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ShopStep implements CustomStep {
private final CorePlugin plugin;
public ShopStep(CorePlugin plugin) {
this.plugin = plugin;
}
@Override
public String getServiceName() {
return "shop";
}
@Override
public Map<String, Object> register(Player player, Date date) {
var shops = this.plugin.getStorageManager().getShops(player.getUniqueId(), date);
if (shops.isEmpty()) return Map.of();
Map<String, Object> results = new HashMap<>();
for (ShopLogDTO shop : shops) {
List<Map<String, Object>> elements = (List<Map<String, Object>>) results.computeIfAbsent(shop.material(), k -> new ArrayList<>());
elements.add(Map.of(
"material", shop.material(),
"amount", shop.amount(),
"price", shop.price(),
"action", shop.action(),
"date", shop.created_at().getTime()
));
}
return results;
}
}
This example retrieves logs from a shop plugin based on a date and a player. We will then save the information about each item sold or purchased into a map.
Last updated