Problem / tpyes command: an internal error occurred while attempting to perform this command

Discussion in 'Plugin Development' started by Notix_One, Jul 29, 2021.

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

    Notix_One

    I wanted to create a system so that each Team is teleported to its Spawn with the / tpyes command but it doesn't work, when I use the in-game command it sends me back "an internal error occurred while attempting to perform this command " Can you help me ? (Sorry for bad English)

    My code:

    public class CommandTest implements CommandExecutor {
    private Main main;

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String msg, String[] arg) {



    if(sender instanceof Player) {
    Player player = (Player)sender;

    Location BlueSpawn = new Location(Bukkit.getWorld("world"), 84.687, 58.0, -88.526, 90.0f, -1.6f);
    Location YellowSpawn = new Location(Bukkit.getWorld("world"), 72.499, 58.0, -72.300, -179.6f, -1.6f);
    Location RedSpawn = new Location(Bukkit.getWorld("world"), 60.300, 58.0, -88.471, 90.3f, -1.6f);
    Location GreenSpawn = new Location(Bukkit.getWorld("world"), 72.483, 58.0, -104.700, -0.0f, -1.6f);

    if(cmd.getName().equalsIgnoreCase("tpyes")) {

    if(main.getBlueteam().contains(player)) {

    ((Entity) main.getBlueteam()).teleport(BlueSpawn);
    ((CommandSender) main.getBlueteam()).sendMessage("§5Vous avez été téléporté !");

    } else if(main.getYellowteam().contains(player)) {

    ((Entity) main.getYellowteam()).teleport(YellowSpawn);
    ((CommandSender) main.getYellowteam()).sendMessage("§5Vous avez été téléporté !");

    } else if(main.getRedteam().contains(player)) {

    ((Entity) main.getRedteam()).teleport(RedSpawn);
    ((CommandSender) main.getRedteam()).sendMessage("§5Vous avez été téléporté !");

    } else if(main.getGreenteam().contains(player)) {

    ((Entity) main.getGreenteam()).teleport(GreenSpawn);
    ((CommandSender) main.getGreenteam()).sendMessage("§5Vous avez été téléporté !");

    }
    return true;
    }
     
  2. Offline

    Kars

    Show the error.
     
  3. Offline

    davidclue

    Code:
    if(main.getBlueteam().contains(player)) {
    
    ((Entity) main.getBlueteam()).teleport(BlueSpawn);
    You are casting a list to an Entity, you cannot do that..
     
Thread Status:
Not open for further replies.

Share This Page