Solved Cant get Strings From Config.yml

Discussion in 'Plugin Development' started by Zettos, Aug 18, 2020.

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


    Hello , i dont know how to fix this problem.
    I want that when i tip /poslist in minecraft, that the names of the Positions are listet in the Chat.
    Sorry for my bad English im from Germany.

    PS: Sea is the Name of the Position in the Config.

    package serverextra.cmds;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import serverextra.main.Main;
    public class Poslist implements CommandExecutor{
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player p = (Player)sender;
            if(p.hasPermission("ServerExtras.pos")) {
                if(args.length == 0) {
            String s =    Main.loc.getString("pos."+p.getName()+".");
                return true;
                }else {
                    p.sendMessage("§cBenutze: /poslist");
                    return true;
            }else {
                p.sendMessage("§cDazu hast du keine Berechtigung!");
                return true;

    package serverextra.main;
    import java.util.ArrayList;
    import java.util.HashMap;
    import org.bukkit.Location;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.entity.Player;
    import serverextra.cmds.Back;
    import serverextra.cmds.ChatClear;
    import serverextra.cmds.DelPos;
    import serverextra.cmds.Name;
    import serverextra.cmds.Pos;
    import serverextra.cmds.Poslist;
    import serverextra.cmds.Setpos;
    import serverextra.cmds.Tpa;
    import serverextra.cmds.Vanish;
    public class Main extends JavaPlugin{
        public static File locations;
        public static FileConfiguration loc;
        public static String pr = "§8[§bServerExtras§8] §a";
        public static HashMap<Player, Player> tpa = new HashMap<Player, Player>();
        public static HashMap<String, Location> back = new HashMap<>();
        public static ArrayList<String> nick = new ArrayList<String>();
        public static ArrayList<String> vanish = new ArrayList<String>();
    public void onEnable() {
        Main.locations = new File("plugins/ServerExtras", "config.yml");
        Main.loc = YamlConfiguration.loadConfiguration(Main.locations);
        public void onDisable() {
    public void registerEvents() {
        this.getServer().getPluginManager().registerEvents(new DeathEvent(), this);
    public void registerCMDS() {
        this.getCommand("tpa").setExecutor(new Tpa());
        this.getCommand("tpaccept").setExecutor(new Tpa());
        this.getCommand("tpac").setExecutor(new Tpa());
        this.getCommand("back").setExecutor(new Back());
        this.getCommand("serverchatclear").setExecutor(new ChatClear());
        this.getCommand("chatclear").setExecutor(new ChatClear());
        this.getCommand("name").setExecutor(new Name());
        this.getCommand("vanish").setExecutor(new Vanish());
        this.getCommand("setpos").setExecutor(new Setpos());
        this.getCommand("pos").setExecutor(new Pos());
        this.getCommand("delpos").setExecutor(new DelPos());
        this.getCommand("poslist").setExecutor(new Poslist());

    Attached Files:

Thread Status:
Not open for further replies.

Share This Page