Solved Code error, I'm new to plugin development so go easy on me

Discussion in 'Plugin Development' started by EthanGarey, Aug 27, 2022.

Thread Status:
Not open for further replies.
  1. Offline

    EthanGarey

    Code:
    package Commands;import net.md_5.bungee.api.ChatColor;import org.bukkit.Bukkit;import org.bukkit.command.Command;import org.bukkit.command.CommandExecutor;import org.bukkit.command.CommandSender;import org.bukkit.entity.Player;public class Teleport implements CommandExecutor {
    
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    
    if (!(sender instanceof Player)) {
    sender.sendMessage(ChatColor.RED + "This plugin is for players only!"); return true;}
    
    Player p = (Player) sender; if (args.length == 0) {
    p.sendMessage(ChatColor.RED + "Please specify a player."); return false;}
    Player target = Bukkit.getServer().getPlayer(args[0]); if (target == p) {
    p.sendMessage(ChatColor.RED + "You cannot teleport to your self!"); return false;}
    if (player.getServer().getPlayer(args[0]) = null) {
    p.sendMessage(ChatColor.RED + "The target player " + args[0] + "is not online");}
    if (target == null) {
    p.sendMessage(ChatColor.RED + "Could not find player " + args[0] + "!"); return false;}
    p.teleport(target.getLocation()); return true;}
    }
    
    upload_2022-8-27_11-48-26.png
    I'm mostly trying to fix the first error, if you can fix the others go for it!
    I have not imported this to my plugin list if anybody asks.

    Solved
     
    Last edited by a moderator: Aug 28, 2022
Thread Status:
Not open for further replies.

Share This Page