Files
src
build.gradle
Code
9 772
src/main/java/com/purpur/plugin/Purpur.java
package com.purpur.plugin;
import com.purpur.plugin.item.GlowingBrush;
import com.purpur.plugin.listener.ChestInteractListener;
import com.purpur.plugin.listener.ChestInventoryListener;
import com.purpur.plugin.manager.BrushAnimationManager;
import com.purpur.plugin.manager.PaintedChestManager;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;
public class Purpur extends JavaPlugin {
private PaintedChestManager paintedChestManager;
private BrushAnimationManager brushAnimationManager;
private NamespacedKey glowingBrushKey;
private NamespacedKey paintedChestKey;
@Override
public void onEnable() {
saveDefaultConfig();
this.glowingBrushKey = new NamespacedKey(this, "glowing_brush");
this.paintedChestKey = new NamespacedKey(this, "painted_chest");
this.paintedChestManager = new PaintedChestManager(this);
this.brushAnimationManager = new BrushAnimationManager(this);
registerRecipe();
registerListeners();
getLogger().info("Purpur plugin enabled!");
}
@Override
public void onDisable() {
brushAnimationManager.cancelAll();
getLogger().info("Purpur plugin disabled!");
}
private void registerRecipe() {
ShapedRecipe recipe = GlowingBrush.createRecipe(this);
if (recipe != null) {
Bukkit.addRecipe(recipe);
getLogger().info("Glowing Brush recipe registered!");
}
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new ChestInteractListener(this), this);
Bukkit.getPluginManager().registerEvents(new ChestInventoryListener(this), this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("glowingbrush")) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can use this command!");
return true;
}
Player player = (Player) sender;
player.getInventory().addItem(GlowingBrush.create(this));
player.sendMessage("§aYou received a Glowing Brush!");
return true;
}
return false;
}
public PaintedChestManager getPaintedChestManager() {
return this.paintedChestManager;
}
public NamespacedKey getGlowingBrushKey() {
return this.glowingBrushKey;
}
public NamespacedKey getPaintedChestKey() {
return this.paintedChestKey;
}
public BrushAnimationManager getBrushAnimationManager() {
return this.brushAnimationManager;
}
}