Developers - PlayerNguyen/OptEco GitHub Wiki
OptEco is using Gradle (Java Build Tools) to build itself and the patch is hosting by JitPack.io. Obviously, it'll work with Gradle & Maven.
- Add the dependency into your server
Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.PlayerNguyen</groupId>
<artifactId>OptEco</artifactId>
<version>2.0b</version>
</dependency>
Gradle
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.PlayerNguyen:OptEco:2.0b'
}
- Require OptEco
Plugin optEco = Bukkit.getPluginManager().getPlugin("OptEco");
if (optEco == null) {
Bukkit.getLogger().severe("OptEco not found, please download & install at" +
" https://www.spigotmc.org/resources/76179/");
// Disable plugin if require
Bukkit.getPluginManager().disablePlugin(this);
}
- Define API with Player UUID
Player player = event.getPlayer();
// Get OptEcoAPI with UUID
OptEcoAPI optEcoAPI = new OptEcoAPI(player.getUniqueId());
This is an example plugin to add 100 points when a player's chatting
public final class OptEcoTestPlugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Plugin startup logic
Plugin optEco = Bukkit.getPluginManager().getPlugin("OptEco");
if (optEco == null) {
Bukkit.getLogger().severe("OptEco not found, please download & install at" +
" https://www.spigotmc.org/resources/76179/");
// Disable plugin if require
Bukkit.getPluginManager().disablePlugin(this);
}
// Register event
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onTalk(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
// Get OptEcoAPI with UUID
OptEcoAPI optEcoAPI = new OptEcoAPI(player.getUniqueId());
// Add 100 points when player chatting
if (optEcoAPI.addPoints(100)) {
player.sendMessage(ChatColor.DARK_GREEN + "Succeed add 100 points to your account.");
} else {
player.sendMessage(ChatColor.RED + "Failed add 100 points to your account.");
}
}
}
Want to see more about OptEcoAPI class? Read the JavaDoc here!