For Episode 4: https://www.youtube.com/watch?v=k0TOCzINHV8&list=PLfu_Bpi_zcDNEKmR82hnbv9UxQ16nUBF7&index=4
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>