I don't know why my plugins do not working...

Discussion in 'Plugin Development' started by Kezoto, Sep 29, 2020.

  1. Offline

    Kezoto

    Hello, i write 2 plugins. One for /help and one for /spawn

    /spawn plugin idk why server dont see them
    /help plugin server see but commands not working

    please help me!

    I'm writing plugins on Eclipse
    on engine Bukkit 1.16.2

    Download:

    https://www87.zippyshare.com/v/6iEY65y7/file.html
     
  2. Online

    timtower Moderator Moderator

    @Kezoto You got an error log? Or code without posting the entire project?
     
  3. Offline

    Kezoto

    Code:
    Main:
    
    
    package main;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitRunnable;
    
    public class Main extends JavaPlugin {
       
       public void onEnable() {
         getLogger().info("Pomyslnie zaladowano plugin by Tea Studios");
         saveDefaultConfig();
         }
           @Override
           public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args) {
             Player p = (Player) sender;
             if(cmd.getName().equalsIgnoreCase("setspawn")) {
               double x = p.getLocation().getX();
               double y = p.getLocation().getY();
               double z = p.getLocation().getZ();
               String world = p.getWorld().getName();
               getConfig().set("spawn.x", x);
               getConfig().set("spawn.y", y);
               getConfig().set("spawn.z", z);
               getConfig().set("spawn.world", world);
               saveConfig();
               p.sendMessage(ChatColor.DARK_GRAY + ">>" + ChatColor.GRAY + "Spawn zostal pomyslnie" + ChatColor.GRAY + "Ustawiony");
             }
             if(cmd.getName().equalsIgnoreCase("spawn")) {
               new BukkitRunnable(){
                 double x = p.getLocation().getX();
                 double y = p.getLocation().getY();
                 double z = p.getLocation().getZ();
                 World world = p.getWorld();
                 Location last = new Location(world, x, y, z);
                 int i = 6;
                 public void run() {
                   if(i == 1) {
                     this.cancel();
                     double spawnx = getConfig().getDouble("spawn.x");
                     double spawny = getConfig().getDouble("spawn.y");
                     double spawnz = getConfig().getDouble("spawn.z");
                     String spawnworld = getConfig().getString("spawn.world");
                     p.teleport(new Location(Bukkit.getWorld(spawnworld), spawnx, spawny, spawnz));
                     p.sendMessage(ChatColor.DARK_GRAY + ">>" + ChatColor.GRAY + "Zostales przeleportowany na" + ChatColor.GRAY + "spawna!");
                   }else {
                     double x = p.getLocation().getX();
                     double y = p.getLocation().getY();
                     double z = p.getLocation().getZ();
                     World world = p.getWorld();
                     Location now = new Location(world, x, y, z);
                     if(now.equals(last)) {
                       i--;
                       p.sendMessage(ChatColor.DARK_GRAY + ">>" + ChatColor.GRAY + "Zostales przeleportowany za" + ChatColor.GRAY + i);     
                     }   else {
                       this.cancel();
                       p.sendMessage(ChatColor.DARK_GRAY + ">>" + ChatColor.GRAY + "Teleportacja przerwana, powod:" + ChatColor.GRAY + "Poruszyles sie!");
                       
                     }
                     
                     
                   }
                   
                 }
                 
               }.runTaskTimer(this, 0L, 20L);
             }
             return false;
           
         }
    
    }
    
    plugin.yml:
    Code:
    name: TW-Spawn
    version: 1.0
    main: main.Main
    
    commands:
      setspawn:
        description: Komenda na spawn napisana przez Kezoto dla Tea World.
      spawn:
      description: Komenda na spawn napisana przez Kezoto2 dla Tea World.
    ss from eclipse: https://imgur.com/gallery/2e4jrMU

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Sep 29, 2020
  4. Online

    timtower Moderator Moderator

  5. Offline

    EpicGodMC

    regarding the spawn plugin:
    1: you did not register your command in your onEnable for example
    2: your class does not implement commandExecutor
    3: consider adding a variable for the spawnpoint instead of getting/creating it from the configuration each time

    Regarding the help plugin

    for some reason you are calling onEnable() inside your onEnable?

    cant find anything else wrong in this one, hope this helps
     
  6. Offline

    Kezoto

    Code:
    
    
    [07:01:36 INFO]: Registering commands with com.sk89q.worldedit.bukkit.BukkitServerInterface
    [07:01:36 WARN]: [WorldEdit] ====================================================
    [07:01:36 WARN]: [WorldEdit]  WorldEdit works better if you use Paper 
    [07:01:36 WARN]: [WorldEdit]  as your server software. 
    [07:01:36 WARN]: [WorldEdit] ====================================================
    [07:01:36 INFO]: [Poradnik] Enabling Poradnik v1.0
    [07:01:36 INFO]: Server permissions file permissions.yml is empty, ignoring it
    [07:01:36 INFO]: CONSOLE: Reload complete.
    [07:01:53 INFO]: Unknown command. Type "help" for help.
    [07:01:54 INFO]: CONSOLE: Please note that this command is not supported and may cause issues when using some plugins.
    [07:01:54 INFO]: CONSOLE: If you encounter any issues please use the /stop command to restart your server.
    [07:01:54 INFO]: [Poradnik] Disabling Poradnik v1.0
    [07:01:54 INFO]: [WorldEdit] Disabling WorldEdit v7.1.0;8e55131
    [07:01:54 INFO]: Unregistering com.sk89q.worldedit.bukkit.BukkitServerInterface from WorldEdit
    [07:01:54 INFO]: Reloading ResourceManager: Default, bukkit
    [07:01:54 INFO]: Loaded 7 recipes
    [07:01:54 INFO]: Reloading ResourceManager: Default, bukkit
    [07:01:55 INFO]: Loaded 7 recipes
    [07:01:55 ERROR]: Could not load 'plugins\TW-Spawn.jar' in folder 'plugins'
     
    Last edited by a moderator: Sep 29, 2020
  7. Online

    timtower Moderator Moderator

    @EpicGodMC 1 and 2 are not needed for the main class.
    And he isn't calling onEnable.

    @Kezoto Full log, full content of the file. Just that doesn't tell what is wrong.
     
  8. Offline

    Kezoto

  9. Online

    timtower Moderator Moderator

    @Kezoto Description of spawn needs to have 2 extra spaces.
     
  10. Offline

    Kezoto

    yy idk what u mean
     
  11. Online

    timtower Moderator Moderator

    @Kezoto Look at the description of setspawn, the description of spawn needs to start on the same place.
     
  12. Offline

    Kezoto

    So bad in the code or plugin.yml?
     
  13. Online

    timtower Moderator Moderator

    @Kezoto plugin.yml
    Code:
    name: TW-Spawn
    version: 1.0
    main: main.Main
    
    commands:
       setspawn:
         description: Komenda na spawn napisana przez Kezoto dla Tea World.
       spawn:
         description: Komenda na spawn napisana przez Kezoto2 dla Tea World.
    Try this one instead
     
  14. Offline

    Kezoto

    WTH thank u, idk how but its working never mind u re the best ! <3

    You can close the topic

    ok

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 3, 2020

Share This Page