Illuminatiiiiii
12/27/2018 - 12:21 PM

Commands Part 1

package me.illuminatiproductions.spigotsandboxproject;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

public final class SpigotSandboxProject extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        // Plugin startup logic
        System.out.println("The plugin has started UP.");

    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
        System.out.println("Plugin shutdown.");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        //First command
        if(command.getName().equalsIgnoreCase("die") && sender instanceof Player){
            Player player = (Player) sender;
            player.sendMessage(ChatColor.BLACK + "DIE");
            player.setHealth(0);
        }else if(command.getName().equalsIgnoreCase("die") && !(sender instanceof Player)){
            System.out.println("You need to be a player to execute this command, dummy.");
        }

        //Second command
        if(command.getName().equalsIgnoreCase("healthplease") && sender instanceof Player){
            Player player = (Player) sender;
            player.sendMessage(ChatColor.DARK_PURPLE + "There u go");
            player.setHealth(player.getHealth() + 1);
        }else if(command.getName().equalsIgnoreCase("die") && !(sender instanceof Player)){
            System.out.println("You need to be a player to execute this command, dummy.");
        }

        return true;
    }
}
name: SpigotSandboxProject
version: ${project.version}
main: me.illuminatiproductions.spigotsandboxproject.SpigotSandboxProject
api-version: 1.13
description: Plugin for testing and such
commands:
  die:
    description: Die fool.
    usage: /<command>
  healthplease:
    description: Get some health
    usage: /<command>