dilzz
5/11/2020 - 2:59 AM

Commands Part 2

For episode 5:

package me.illuminatiproductions.spigotsandboxproject;

import me.illuminatiproductions.spigotsandboxproject.commands.God;
import org.bukkit.plugin.java.JavaPlugin;

public final class SpigotSandboxProject extends JavaPlugin{

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

        //Register command
        getCommand("god").setExecutor(new God());
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
        System.out.println("Plugin shutdown.");
    }
}
package me.illuminatiproductions.spigotsandboxproject.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class God implements CommandExecutor {

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

        if (sender instanceof Player){
            Player player = (Player) sender;
            player.sendMessage("WOOSH");
            player.setInvulnerable(true);
        }

        return true;
    }
}
name: SpigotSandboxProject
version: ${project.version}
main: me.illuminatiproductions.spigotsandboxproject.SpigotSandboxProject
api-version: 1.13
description: Plugin for testing and such
commands:
  god:
    description: Become invincible