help code run

Discussion in 'Plugin Development' started by IsHashing, Nov 7, 2020.

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

    IsHashing

    Code:
    public void onEnable() {
            plugin = this;
            Config.saveDefaultConfig();
            if(Save.existeConfig()) {
               
            }else {
                Save.saveConfig();
            }
            getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
            Set<String> keys = Home.getPlugin().Config.getConfig().getConfigurationSection("a").getKeys(false);
            for(String key : keys){
                    @Override
                    public void run() {
                              }
                    }
                }, aa(secunds) );
        }
     
  2. Offline

    KarimAKL

  3. Offline

    IsHashing

    ta giving error in the set<string> and public void run() { +
    }, aa(secunds) ); erros

    ?

    erro help me please
    Code:
        public void onEnable() {
            if(Save.existeConfig()) {
              
            }else {
                Save.saveConfig();
            }
            getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
            Set<String> keys = Home.getPlugin().Config.getConfig().getConfigurationSection("a").getKeys(false);
            for(String key : keys){
                int secunds =  2;
                    @Override
                    public void run() {
                      
                        
                        }
                    }
                }, aa(secunds) );
        }
        public int aa(int secunds) {
            int count = 2;
            secunds = count * 20;
            return aa(secunds);
        }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 7, 2020
  4. Offline

    KarimAKL

    @IsHashing What does the errors say? Also, i noticed that your aa(int) method returns an integer instead of a long.
     
  5. Offline

    IsHashing

    1 error
    Multiple markers at this line
    - Syntax error, insert ")" to complete
    MethodInvocation
    - Syntax error, insert "}" to complete ClassBody
    - Syntax error, insert ";" to complete Statement
    Code:
    Set<String> keys = Home.getPlugin().Config.getConfig().getConfigurationSection("a").getKeys(false);
    2 error
    Multiple markers at this line
    - Syntax error on token "run", AnnotationName expected after
    this token
    - Syntax error, insert ";" to complete
    LocalVariableDeclarationStatement
    - Syntax error, insert "[ ]" to complete Dimension
    Code:
    public void run() 
    3 error
    Multiple markers at this line
    - Syntax error on tokens, ( expected instead
    - Syntax error, insert "AssignmentOperator Expression" to complete
    Expression
    - Syntax error on token ",", invalid (
    Code:
    }, aa(secunds) );
    convert int to long
    Code:
    public long aa(long secunds) {
            long count = 2;
            secunds = count * 20;
            return aa(secunds);
        }


    Imports
    Code:
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.inventory.ItemFlag;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    ?
     
    Last edited: Nov 7, 2020
  6. Offline

    KarimAKL

    The errors are pretty detailed, why do you not try doing what they say?

    You probably also want to move your loop & set inside of the run() method.
     
  7. Offline

    IsHashing

    i don't speak english i'm using translation my language is portuguese which makes my understanding difficult por favor me ajude resolver I have no idea how to solve

    I made my plugin a long time ago and when I came back I came across these 3 errors and I haven't programmed in a while

    Code:
    public class Home extends JavaPlugin implements Listener{
        public C_Config cconfig = new C_Config(this, "config.yml");
        public C_Config csave = new C_Config(this, "a/a.save");
        private static Home plugin;
        public static Home getInstance() {
            return plugin;
        }
        public static Home getPlugin() {
            return JavaPlugin.getPlugin(Home.class);
        }
        protected void Eventos() {
        }
      
        public void onEnable() {
            plugin = this;
            Bukkit.getPluginManager().registerEvents(this, this);
            cconfig.saveDefaultConfig();
            if(csave.existeConfig()) {
              
            }else {
                csave.saveConfig();
            }
            getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                Set<String> keys = Home.getPlugin().Config.getConfig().getConfigurationSection("a").getKeys(false);
                for(String key : keys){
                    long secunds =  2;
                        @Override
                        public void run() {
                      
                        
                            }
                        }
                    }, aa(secunds) );
            }
     
    Last edited: Nov 8, 2020
  8. Offline

    KarimAKL

    The errors are telling you to add the characters in quotation marks.
     
  9. Offline

    IsHashing

    there's nowhere to put quotes
     
    Last edited by a moderator: Nov 8, 2020
  10. Offline

    KarimAKL

    This means that you need to add the character ")".
     
  11. Offline

    IsHashing

    Code:
    edit:
        public void onEnable() {
            plugin = this;
            Bukkit.getPluginManager().registerEvents(this, this);
            Config.saveDefaultConfig();
            if(Save.existeConfig()) {
             
            }else {
                Save.saveConfig();
            }
            getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
            Set<String> keys = Home.getPlugin().Config.getConfig().getConfigurationSection("aa").getKeys(false);
            for(String key : keys){
                int secunds =  Config.getConfig().getInt("aa."+key+".delay");
                    @Override
                    public void run() {
                     
                    }
                }
          }, aa(secunds) );
    }
    
    EDITED

    for(String key : keys) have poblem remove
    Code:
        public void onEnable() {
            plugin = this;
            Bukkit.getPluginManager().registerEvents(new MachineBlockBreakEvent(), this);
            Bukkit.getPluginManager().registerEvents(this, this);
            Config.saveDefaultConfig();
            if(Save.existeConfig()) {
               
            }else {
                Save.saveConfig();
            }
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                   for(String key : Home.getPlugin().Config.getConfig().getConfigurationSection("aa").getKeys(false))
                   {
                       @Override
                       public void run() {
                           
                       }
                   }
            }, aa(2));
    }

    I did 1 test and if I change this for this

    Code:
    public void onEnable() {
            plugin = this;
            Bukkit.getPluginManager().registerEvents(new MachineBlockBreakEvent(), this);
            Bukkit.getPluginManager().registerEvents(this, this);
            Config.saveDefaultConfig();
            if(Save.existeConfig()) {
               
            }else {
                Save.saveConfig();
            }
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                       @Override
                       public void run() {
                       
                       }
                           
            }, aa(2));
    }
    
    there is no error and this is essential for the functioning of plugin

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 8, 2020
Thread Status:
Not open for further replies.

Share This Page