moha664

can you make item is flash light

Kodari AI
KodariAug 22 at 12:51 pm 1

I’ll create a complete Paper plugin with a craftable flashlight item, right-click activation, a temporary night-vision beam, and /flashlight give.

Created a complete flashlight plugin.

Features:

  • Craftable flashlight using iron and a torch

  • Right-click to toggle the flashlight

  • Visible End Rod beam up to 12 blocks

  • Temporary night vision while active

  • /flashlight give [player]

  • Permission: flashlight.give

  • Automatically disables when the item is no longer held or the player disconnects

Build the plugin and place the resulting JAR in your server’s plugins folder.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
7 324
src/main/java/com/kodari/flashlight/FlashlightPlugin.java
package com.kodari.flashlight;

import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class FlashlightPlugin extends JavaPlugin {

    private FlashlightManager flashlightManager;

    @Override
    public void onEnable() {
        this.flashlightManager = new FlashlightManager(this);
        this.flashlightManager.registerRecipe();
        Bukkit.getPluginManager().registerEvents(new FlashlightListener(flashlightManager), this);

        PluginCommand command = getCommand("flashlight");
        if (command != null) {
            FlashlightCommand flashlightCommand = new FlashlightCommand(flashlightManager);
            command.setExecutor(flashlightCommand);
            command.setTabCompleter(flashlightCommand);
        }

        flashlightManager.startBeamTask();
    }

    @Override
    public void onDisable() {
        if (flashlightManager != null) {
            flashlightManager.stopAll();
        }
    }

    public NamespacedKey flashlightKey() {
        return new NamespacedKey(this, "flashlight");
    }
}