Development Assistance I think a constructor problem!

Discussion in 'Plugin Help/Development/Requests' started by FameForAim, Dec 10, 2014.

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

    FameForAim

    Hi everyone,
    i need help with my plugin. I just wanted to use the getConfig() Command in my second class. Everything works now i though when i added the constructor.
    But as soon as i started the plugin this error is there:

    Error: (open)



    This is my Main Class (varo class):
    Main Class (open)
    Code:
    package me.ffa.varo;
    
    import java.io.File;
    
    import org.bukkit.Bukkit;
    import org.bukkit.GameMode;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Varo extends JavaPlugin {   
        public static Varo plugin;
        public Varo(Eventlistener eventlistener) {
            // TODO Auto-generated constructor stub
        }
        @Override
        public void onEnable(){
            this.getServer().getPluginManager().registerEvents(new Eventlistener(), plugin);
            System.out.println("TimerPlugin started");
            loadConfig();
            plugin = this;
    
    
        }
    
        public FileConfiguration config;
    
        public void loadConfig(){           
            config = getConfig();
            config.options().copyDefaults(true);
            if(new File("plugins/Varo/config.yml").exists()){           
                System.out.println("[Varo] config.yml geladen.");   
            }else{
                this.saveDefaultConfig();
                this.getConfig().addDefault("Location.Name", "Besitzer");
                this.getConfig().addDefault("Location", "Position");
                this.getConfig().addDefault("Name.Anzahl", "Kistenanzahl");
                System.out.println("[Varo] config.yml erstellt und geladen.");
    
            }
        }
        @Override
        public void onDisable(){
            System.out.println("TimerPlugin stopped");
        }
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            final int sec = Integer.parseInt(args[0]);
            if (cmd.getName().equalsIgnoreCase("timer")) {
                Bukkit.getScheduler().runTaskAsynchronously(this, new Runnable() {
                    public void run() {
                        int count = sec;
                        while (true) {
                            Bukkit.getServer().broadcastMessage("§7[§aCount§cDown§7] §aIn " + count + " Sekunden beginnt Varo! Macht euch bereit!");
                            count--;
                            if (count == 0) {
                                Bukkit.getServer().broadcastMessage("§7[§aCount§cDown§7] §aVaro startet!");
                                for(Player allplayers : Bukkit.getOnlinePlayers()) {
                                 allplayers.setGameMode(GameMode.SURVIVAL);           
                                }
                                break;
                            }
                            try {
                                Thread.sleep(1000);
                            } catch (InterruptedException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                    }
                  
                });  return true;
            }
            return false;
        }
    }
                
    
    



    This is my second class where i want to use the getConfig() command:
    Eventlistener Class (open)
    Code:
    package me.ffa.varo;
    
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    
    public class Eventlistener implements Listener {   
        @SuppressWarnings("deprecation")
        @EventHandler
        public void onPlayerDeath(PlayerDeathEvent de) {
            Player p = de.getEntity();
            p.kickPlayer("Du bist aus Varo ausgeschieden");
            p.setBanned(true);
    
    
           
            }
        public void onsigncreate(BlockPlaceEvent bp) {
           
            Player p = bp.getPlayer();
            Block placed = bp.getBlockPlaced();
            Location blocksafe = placed.getLocation();
            if(placed.getType() == Material.SIGN) {
                Block place = bp.getBlockAgainst();
                if(place.getType() == Material.CHEST) {
                    if(Varo.plugin.getConfig().getInt("Name.Anzahl") < 1) {
                 Varo.plugin.getConfig().set("Location", place.getLocation());
                 Varo.plugin.getConfig().set("Location.Name", p);
                 Varo.plugin.getConfig().set("Name.Anzahl", Varo.plugin.getConfig().getInt("Name.Anzahl")+1);        
                    p.sendMessage("Die Kiste wurde gesichert");
                    }
                    p.sendMessage("Du hast schon eine Kiste gesichert!");                           
                }
               
            }
        }
        public void onPlayerChestopen(PlayerInteractEvent pe) {
            Player p = pe.getPlayer();
            Block interact = pe.getClickedBlock();
            Location loc = interact.getLocation();
            if(interact.getType() == Material.CHEST) {
                if(Varo.plugin.getConfig().get("Location") == loc) {
                    if(Varo.plugin.getConfig().get("Location.Name") == p) {
                        p.sendMessage("Deine gesicherte Kiste wurde geöffnet");
                    }else if(Varo.plugin.getConfig().get("Location.Name") != p) {
                        pe.setCancelled(true);
                        p.sendMessage("Dies ist nicht deine gesicherte Kiste");                   
                    }
                   
                }
    
               
            }
        }
        }
    


    Please help me:)
     
  2. Offline

    mrCookieSlime

    Moved to Alternatives Section.
     
Thread Status:
Not open for further replies.

Share This Page