Solved Help me with this . . .

Discussion in 'Plugin Development' started by Visur, Aug 22, 2016.

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

    Visur

    I'm aware I suck at bukkit. My problem is when I use /events reload it just says the config msg. Please explain to me my mistake(s) I'm new to this trust me.

    MAIN CLASS (ONLY CLASS) :
    Code:
    package me.corey7.upcoming;
    
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import net.md_5.bungee.api.ChatColor;
    
    public class main extends JavaPlugin implements Listener {
    
    
        public String message = getConfig().getString("Upcoming.VisurUChoose");
    
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
        {
            if ((cmd.getName().equalsIgnoreCase("upcoming")) || ((cmd.getName().equalsIgnoreCase("events")) && ((sender instanceof Player))))
            {
                if ((args.length == 1))
                {
                    if (args[0].equalsIgnoreCase("reload"))
                    {
                        reloadConfig();
                    }
                }
                Player p = (Player)sender;
                p.sendMessage(ChatColor.translateAlternateColorCodes('&', this.message));
            }
            return false;
        }
    
    
        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
            getConfig().options().copyDefaults(true);
    
            saveConfig();
            getLogger().info("oh dang dude vis n da house");
        } 
    
        public void onDisable() {}
    }
    
    
    CONFIG.YML:
    Code:
    # Made with love <3 - vis ur boi
    Upcoming:
      VisurUChoose: '&bKoth is at 6:00 so is the dp'
    
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Visur You are never returning true yet you are successfully handling the command.
     
  3. Offline

    SantaClawz69

    Another thing, you're importing
    import net.md_5.bungee.api.ChatColor;

    You might want to import the bukkit chatcolor.
     
  4. Offline

    Zombie_Striker

    @Visur
    You reload the config, but you never reload the "message" value. After reloading the config, reset the message field.
     
  5. Offline

    Visur

    So return true if the command is successful? And if you like have a no perm msg it's return false?
    Show me how, I'm a noob
     
  6. Offline

    Zombie_Striker

    @Visur
    Put this line directly under the reloadConfig() line
    Code:
    message = getConfig().getString("Upcoming.VisurUChoose");
     
  7. Offline

    Visur

    Thank you! Also, can you tell me this problem? Sorry for asking for a lot but I must start somewhere.
    Code:
        public void join(PlayerJoinEvent e) {
            if (e.getPlayer().hasPlayedBefore());
            {
                final Player p = e.getPlayer();
                Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                    public void run() {
                        p.sendMessage("");
                    }
                }, 100L); // 20 ticks = 1 second. So 100 ticks = 5 seconds.
            }
    
        }
    }
    why is this unresponsive?
     
  8. Offline

    Zombie_Striker

    @Visur
    First, are you sure you have the "@EventHandler" tag? Have you registered the class?
    Never have a semicolon after an if statement. What that means is that the if statement is useless and does nothing.
     
  9. Offline

    Visur

    Thanks boi, solved.
     
Thread Status:
Not open for further replies.

Share This Page