getLogger error

Discussion in 'Spigot Plugin Development' started by Tomdaarom, Apr 14, 2017.

  1. Hello, I get an Error in

    public void onEnable(){
    getLogger().log(Level, INFO, "BizzCraft First Join plugin enabled");
    }
    public void onDisable(){
    getLogger().log(Level, INFO, "BizzCraft First Join plugin disabled");

    I have no Idea how to fix this. This is my code :
    Code (Text):
    package me.officialnl.main;

    import net.md_5.bungee.api.ChatColor;
    import java.util.logging.level;

    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.player.PlayerLoginEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin{
       
        public void onEnable(){
            getLogger().log(Level, INFO, "BizzCraft First Join plugin enabled");
        }
       
        public void onDisable(){
            getLogger().log(Level, INFO, "BizzCraft First Join plugin disabled");
        }
       
        private void teleportInWorld(Player p, int x, int y, int z){
            p.teleport(new Location(p.getWorld(), x, y, z));
        }
       
        @EventHandler
        public void PlayerJoin(PlayerLoginEvent event) {
        Player p = event.getPlayer();
        if(!p.hasPlayedBefore()) {
        teleportInWorld(p, 149,33,170);
        p.sendMessage("You have to accept the rules before you can play");
        }
      }
       
        public boolean onCommand(CommandSender s, Command cmd, String label, String[] args){
            if(cmd.getName().equalsIgnoreCase("AcceptRules")){
                if (!(s instanceof Player)){
                    getLogger().log(Level, SEVERE, "Only players are allowed to use this command");
                    return true;
                }
                Player p = (Player) s;
                p.performCommand("Spawn");
                p.sendMessage(ChatColor.GREEN + "You accepted the rules");
                }
            return false;
            }
        }
     
  2. I also get the error here : getLogger().log(Level, SEVERE, "Only players are allowed to use this command");
     
  3. Use getLogger().info(#String); instead.
     
    • Informative Informative x 1
  4. thenkyou thenkyou
    This fixed my problem
     
  5. Use
    Code (Java):
    Level.INFO
    NOT
    Code (Java):
    Level, INFO