Files
src
build.gradle
settings.gradle
Code
4 91
src/main/java/com/verity/VerityPlugin.java
package com.verity;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.plugin.java.JavaPlugin;
public final class VerityPlugin extends JavaPlugin implements CommandExecutor {
@Override
public void onEnable() {
getCommand("verity").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player player)) {
sender.sendMessage("Only players can spawn Verity.");
return true;
}
Location spawnLocation = player.getLocation().add(0, 0.1, 0);
Slime verity = player.getWorld().spawn(spawnLocation, Slime.class);
verity.setSize(2);
verity.setAI(false);
verity.setAware(false);
verity.setInvulnerable(true);
verity.setCollidable(false);
verity.setRemoveWhenFarAway(false);
verity.setPersistent(true);
verity.setCustomName(ChatColor.YELLOW + "☺ Verity");
verity.setCustomNameVisible(true);
player.sendMessage(ChatColor.YELLOW + "☺ Verity has arrived!");
return true;
}
}