Hello, I am currently learning plugin development and am just making plugins for fun. I decided to make an AutoOp plugin as it would need to use a config file and I'd like to learn this. I've searched all over google, asked coding servers, etc. and cannot find help.
What I need to do: I need to grab the value(s) from my config.yml and insert them into
Code:
where it says Varner184 it should be whoevers name is in the config.yml.
Config.yml:
ops: Varner184
All my code:
What I need to do: I need to grab the value(s) from my config.yml and insert them into
Code:
Code:
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "op Varner184";
Bukkit.dispatchCommand(console, command);
Config.yml:
ops: Varner184
All my code:
Code:
package me.Varner184.AutoOp;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public class AutoOp extends JavaPlugin {
public void onEnable() {
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "\n\nAutoOp Has Been Enabled!\n\nDeveloped By Varner184");
int seconds = 10;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
// code to run when the time is up.
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "op Varner184";
Bukkit.dispatchCommand(console, command);
}
}, (seconds * 20)); // Always multiply by twenty because that's the amount of ticks in Minecraft
}
public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "\n\nAutoOp Has Been Disabled!\n\nDeveloped By Varner184");
}
}
