Solved Plugin Implements into game but there is no command

Discussion in 'Plugin Development' started by puppet172X, May 24, 2020.

  1. Offline

    puppet172X

    Hi,
    i am creating a DeathSwap plugin and i am able to get it implemented into the game but when i go the run the command, it says there is no command. thanks for any hlep.

    Heres my Main:
    Code:
    package me.puppet172.death;
    
    import org.bukkit.plugin.java.JavaPlugin;
    import me.puppet172.death.commands.*;
    
    public class Main extends JavaPlugin
    {
      
        @Override
        public void onEnable()
        {
            new DeathCommand(this);
        }
    }
    Command file:
    Code:
    package me.puppet172.death.commands;
    
    import org.bukkit.command.CommandExecutor;
    import me.puppet172.death.Main;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import java.util.Timer;
    import java.util.TimerTask;
    
    public class DeathCommand implements CommandExecutor
    {
    @SuppressWarnings("unused")
    private Main plugin;
    
    private int pX= 0;
    private int pY = 0;
    private int pZ = 0;
    
    private int p1X= 0;
    private int p1Y = 0;
    private int p1Z = 0;
    private Player p;
    private Player p1;
    private int secondspassed= 0;
    private Timer time = new Timer();
    private TimerTask task = new TimerTask()
    {
    
        @Override
        public void run()
        {
        secondspassed++;  
          
        }
      
    };
    public void start()
    {
        time.scheduleAtFixedRate(task, 1000, 1000);
    }
      
        public DeathCommand(Main plugin)
        {
            this.plugin = plugin;
            plugin.getCommand("death").setExecutor(this);
        }
        @Override
        public boolean onCommand(CommandSender send, Command cmd,String label, String[] args) {
        {
            send.sendMessage("The game has Started");
            p = (Player) send;
            p1= Bukkit.getPlayer(args[0]);
            while(p.getHealth()>0 && p1.getHealth()>0)
            {
            start();
              
                while((secondspassed == 30000))
                {
                    secondspassed = 0;
                    location();
                    p.teleport(new Location(p1.getWorld(),p1X,p1Y,p1Z));
                    p1.teleport(new Location(p.getWorld(),pX,pY,pZ));
              
                }
            }
            if(p.getHealth()==0)
            {
                p.sendMessage("You Lost");
                p1.sendMessage("You Won");
            }else
            {
                p.sendMessage("You Won");
                p1.sendMessage("You Lost");
              
            }
          
            return true;
        }
      
    }
        public void location()
        {
            pX = p.getLocation().getBlockX();
            pY = p.getLocation().getBlockY();
            pZ = p.getLocation().getBlockZ();
          
            p1X = p1.getLocation().getBlockX();
            p1Y = p1.getLocation().getBlockY();
            p1Z = p1.getLocation().getBlockZ();
          
        }
    }

    Here is my plugin.yml:
    name: DeathS
    version: 1.15.2
    main: me.puppet172.death.Main
     
  2. Online

    timtower Moderator Moderator

    @puppet172X You did not register the command in the plugin.yml
     
  3. Offline

    puppet172X

    How would i do the because everytime i add a commands: line it doesn't implement into the game anymore.
    @timtower
     
  4. Online

    timtower Moderator Moderator

    Are you updating the jar then?
     
  5. Offline

    puppet172X

    if you mean updating by re-exporting the file then yes. This is one of my first times making a plugin. So having a little bit of trouble.

    i made this one before and this one works fine:
    Code:
    name: HelloWorld
    version: 1.15.2
    author: puppet172
    main: me.puppet172.helloworld.Main
    description: Our first minecraft spitogt plugin
    
    commands:
       hello:
        aliasis: [hi]
        description: this is the hello command
    but i tried making the plugin.yml this and it doesnt work
    Code:
    name: DeathS
    version: 1.15.2
    main: me.puppet172.death.Main
    
    commands:
          death:
          aliasis: [swap]
          description: death swap command
    @timtower
     
    Last edited by a moderator: May 24, 2020
  6. Online

    timtower Moderator Moderator

    @puppet172X Is not a valid yml.
    2 spaces before death.
    4 before "aliases" and description.
     
  7. Offline

    puppet172X

    so like this:
    Code:
    name: DeathS
    version: 1.15.2
    main: me.puppet172.death.Main
    
    commands: 
      death:
        aliasis: [death]
        description: DeathSwap Plugin

    @timtower

    never mind that didn't format correctly after i posted it
    @timtower

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  8. Online

    timtower Moderator Moderator

  9. Offline

    puppet172X

    got it working, Thanks for your help
    @timtower
     

Share This Page