```java package com.example.teleport;

import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin;

public class TeleportPlugin extends JavaPlugin {

@Override
public void onEnable() {
    getLogger().info("Teleport Plugin has been enabled!");
}

@Override
public void onDisable() {
    getLogger().info("Teleport Plugin has been disabled!");
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (command.getName().equalsIgnoreCase("tp")) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only players can use this command!");
            return true;
        }

        Player player = (Player) sender;

        if (args.length != 1) {
            player.sendMessage("Usage: /tp <player>");
            return true;
        }

        Player target = Bukkit.getPlayer(args[0]);

        if (target == null) {
            player.sendMessage("Player not found!");
            return true;
        }

        player.teleport(target.getLocation());
        player.sendMessage("Teleported to " + target.getName());
        return true;
    }

    return false;
}

} ``` This is a basic teleport plugin that allows players to teleport to another player's location using the command '/tp '. The plugin will print messages when it is enabled and disabled. Please note that this is just a code example, you need to compile it into a plugin and install and enable it on your server for it to work.

Minecraft Teleport Plugin Code Example - Simple Teleportation Plugin

原文地址: https://www.cveoy.top/t/topic/pA0k 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录