Files
src
build.gradle
Code
14 988
src/main/java/com/bountysystem/BountyPlugin.java
package com.bountysystem;
import com.bountysystem.commands.BountyAdminCommand;
import com.bountysystem.inventory.gui.GUIListener;
import com.bountysystem.inventory.gui.GUIManager;
import com.bountysystem.tasks.ActionBarTask;
import com.bountysystem.tasks.CompassTask;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class BountyPlugin extends JavaPlugin {
@Getter
private BountyManager bountyManager;
@Getter
private ItemManager itemManager;
@Getter
private GUIManager guiManager;
@Override
public void onEnable() {
bountyManager = new BountyManager(this);
itemManager = new ItemManager(this);
guiManager = new GUIManager();
bountyManager.loadData();
itemManager.registerRecipes();
GUIListener guiListener = new GUIListener(guiManager);
BountyListener bountyListener = new BountyListener(this);
Bukkit.getPluginManager().registerEvents(guiListener, this);
Bukkit.getPluginManager().registerEvents(bountyListener, this);
BountyAdminCommand adminCommand = new BountyAdminCommand(this);
getCommand("bountyadmin").setExecutor(adminCommand);
getCommand("bountyadmin").setTabCompleter(adminCommand);
new ActionBarTask(this).runTaskTimerAsynchronously(this, 20L, 20L);
new CompassTask(this).runTaskTimer(this, 300L, 300L);
startPassiveAccumulator();
}
@Override
public void onDisable() {
bountyManager.saveData();
}
private void startPassiveAccumulator() {
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
if (Bukkit.getOnlinePlayers().isEmpty()) return;
Bukkit.getScheduler().runTask(this, () -> {
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
double amount = bountyManager.isPacifist(player.getUniqueId()) ? 20.0 : 10.0;
bountyManager.addBounty(player.getUniqueId(), amount);
bountyManager.checkAndApplyGlowing(player);
com.cryptomorin.xseries.XSound.matchXSound("ENTITY_EXPERIENCE_ORB_PICKUP")
.ifPresent(s -> s.play(player));
}
});
}, 1200L, 1200L);
}
}