1.16.5 The constructor Game(int, int, String, String, JavaPlugin) refers to the missing type JavaPlugin

Discussion in 'Spigot Plugin Development' started by Deimos_22, Feb 14, 2021.

  1. Hi, I'm developing a minigames framework for my Minecraft server, and I already have the base written. I'm trying to make a simple minigame, and when I try to extend my Game class I get this error:
    The constructor Game(int, int, String, String, JavaPlugin) refers to the missing type JavaPlugin
    I have JavaPlugin imported, and what I'm doing is calling the constructor of the super class:
    package org.burgercraft.spleef;

    import org.bukkit.plugin.java.JavaPlugin;
    import org.burgercraft.minigamesframework.Game;

    public class SpleefGame extends Game {

    public SpleefGame(JavaPlugin plugin) {
    super(2, 20, "spleef", "spleefMap", plugin);

    public void GameStart() {



    Any ideas? Thanks!
  2. can we see the Game class?
  3. Can you send your Game class for us to take a look?
  4. I don't use Eclipse but pretty sure it refers to the type not being imported.

    Try importing JavaPlugin, it should work, provided you have successfully set up Maven/Gradle or the spigot-api library.
  5. package org.burgercraft.minigamesframework;

    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.*;

    import org.bukkit.World;
    import org.bukkit.WorldCreator;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.plugin.*;

    public class Game {

    final String template_;
    public int playercount_;
    final int minPlayers_;
    public final int maxPlayers_;
    public String name_;
    private int randomId;
    public World world;
    public boolean canStart;
    public JavaPlugin plugin;

    public Game(int minPlayers, int maxPlayers, String name, String template, final Plugin plugin) {
    this.template_ = template;
    this.minPlayers_ = minPlayers;
    this.maxPlayers_ = maxPlayers;
    this.name_ = name;
    this.randomId = new Random().nextInt(999);
    this.playercount_ = 0;
    this.plugin = (JavaPlugin) plugin;
    final File worldTemplateFolder = new File(plugin.getDataFolder().getAbsoluteFile() + "/maps/" + template + "/");
    final File worldFolder = new File(plugin.getDataFolder().getAbsoluteFile().getParentFile().getParentFile() + "/" + this.name_ + String.valueOf(randomId) + "/");
    if (plugin.isEnabled()) {
    plugin.getServer().unloadWorld(this.name_ + String.valueOf(randomId), false);
    try {
    DirectoryTools.copyFolder(worldTemplateFolder, worldFolder);
    catch (IOException e) {
    System.out.println("Creation of world '" + this.name_ + "' failed! The plugin '" + plugin.getName() + "' was trying to make the world.");
    this.world = null;

    final WorldCreator wc = new WorldCreator(this.name_);
    this.world = wc.createWorld();
    if (this.world == null) {
    System.out.println("Creation of world '" + this.name_ + String.valueOf(randomId) + "' failed! The plugin '" + plugin.getName() + "' was trying to make the world.");


    public void OnPlayerJoin() {
    if(playercount_ >= minPlayers_) {
    public void OnPlayerLeave() {
    if(playercount_ < minPlayers_) {

    public void GameStart() {


  6. Sorry that should say JavaPlugin, not Plugin in the constructor params
  7. Your game class needs to extend JavaPlugin and should be abstract if it is only going to be extended.
  8. I only need the javaplugin to get it's configuration directory, would game extending JavaPlugin still be a good idea?
  9. If you want your plugin to work, at least with spigot, it must extend JavaPlugin. I'd recommend taking a look at this resource for Eclipse or this resource for IntelliJ to learn how to get started with a plugin.
  10. Game isn't standalone, it's part of another package. Basically, other plugins import my .jar and extend the Game class to create custom minigames. Then on enable, they add their extended class to a list of games in the LobbyManager. My MinigamesFramework has a main class that extends JavaPlugin, and so does my Spleef plugin
  11. Ah, I see. My apologies for assuming otherwise.

    First off, is it a runtime error or a syntax error? And if it is runtime, could you send the entire stack trace, preferably in a code paste like https://pastebin.com/?
  12. All good! I don't get a stack trace since I can't even build, I only get that singular error when trying to build, and also in the IDE.
  13. Do you have JavaPlugin imported in your Game class?
  14. Yeah.
  15. Try passing whatever your plugin's main class is into the JavaPlugin argument.
  16. Tried, same error...
  17. You are taking Plugin in the constructor but passing JavaPlugin, then casting it back to JavaPlugin anyway. Why not make the constructor take JavaPlugin?
    • Like Like x 1
  18. It does take JavaPlugin now, I had that old code copied when I did that, sadly same error when just having straight JavaPlugin.
    Strangely, Eclipse doesn't show an error sign next to the class, even though it has the error in it.
  19. Does it need to be JavaPlugin instead of just Plugin? I don't see any methods you are using from JavaPlugin that aren't implemented from Plugin, try changing all cases of JavaPlugin to Plugin