Хостинг серверов Minecraft playvds.com
  1. Вы находитесь в русском сообществе Bukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на русский язык плагины наших собратьев из других стран.
    Dismiss Notice

Помогите Конфиг

Discussion in 'Разработка плагинов для новичков' started by Левый, Mar 30, 2014.

  1. Автор темы
    Левый

    Левый Старожил Пользователь

    Trophy Points:
    173
    Skype:
    malhenko26
    Имя в Minecraft:
    Lefty
    Мне нужно открыть конфиг, чтобы вписывать id предметов, которые будут даваться из сундука-сюрприза.
    Правильный ли код:
    Code:
    public static void save(){
    try {
    YamlConfiguration cfg = new YamlConfiguration();
    File f = new File (ReActions.instance.getDataFolder()+File.separator+"variables.yml");
    if (f.exists()) f.delete();
    f.createNewFile();
    for (String key : vars.keySet())
    cfg.set(key, vars.get(key));
    cfg.save(f);
    } catch (Exception e){
    }
    }
    
    public static void load(){
    vars.clear();
    try {
    YamlConfiguration cfg = new YamlConfiguration();
    File f = new File (ReActions.instance.getDataFolder()+File.separator+"variables.yml");
    if (!f.exists()) return;
    cfg.load(f);
    for (String key : cfg.getKeys(true)){
    if (!key.contains(".")) continue;
    vars.put(key,cfg.getString(key));
    }
    } catch (Exception e){
    }
    }
    protected void saveCfg(){
    getConfig().set("general.language",language);
    getConfig().set("general.check-updates",checkUpdates);
    getConfig().set("reactions.show-messages-for-actions",actionMsg);
    getConfig().set("reactions.center-player-teleport",centerTpCoords);
    getConfig().set("reactions.region-recheck-delay",worlduardRecheck);
    getConfig().set("reactions.item-hold-recheck-delay",itemHoldRecheck);
    getConfig().getInt("reactions.item-wear-recheck-delay",itemWearRecheck);
    getConfig().set("reactions.horizontal-pushback-action",horizontalPushback );
    getConfig().set("reactions.need-file-update", needUpdate);
    getConfig().set("actions.shoot.break-block",Shoot.actionShootBreak);
    getConfig().set("actions.shoot.penetrable",Shoot.actionShootThrough);
    saveConfig();
    }
    
    protected void loadCfg(){
    language= getConfig().getString("general.language","english");
    checkUpdates = getConfig().getBoolean("general.check-updates",true);
    languageSave = getConfig().getBoolean("general.language-save",false);
    centerTpCoords = getConfig().getBoolean("reactions.center-player-teleport",true);
    actionMsg= getConfig().getString("reactions.show-messages-for-actions","tp,grpadd,grprmv,townset,townkick,itemrmv,itemgive,moneypay,moneygive");
    worlduardRecheck = getConfig().getInt("reactions.region-recheck-delay",2);
    itemHoldRecheck = getConfig().getInt("reactions.item-hold-recheck-delay",2);
    itemWearRecheck = getConfig().getInt("reactions.item-wear-recheck-delay",2);;
    horizontalPushback = getConfig().getBoolean("reactions.horizontal-pushback-action", false);
    needUpdate= getConfig().getBoolean("reactions.need-file-update", true);
    Shoot.actionShootBreak = getConfig().getString("actions.shoot.break-block",Shoot.actionShootBreak);
    Shoot.actionShootThrough = getConfig().getString("actions.shoot.penetrable",Shoot.actionShootThrough);
    }
    
    public static void save(){
    try {
    YamlConfiguration cfg = new YamlConfiguration();
    File f = new File (ReActions.instance.getDataFolder()+File.separator+"variables.yml");
    if (f.exists()) f.delete();
    f.createNewFile();
    for (String key : vars.keySet())
    cfg.set(key, vars.get(key));
    cfg.save(f);
    } catch (Exception e){
    }
    }
    
    public static void load(){
    vars.clear();
    try {
    YamlConfiguration cfg = new YamlConfiguration();
    File f = new File (ReActions.instance.getDataFolder()+File.separator+"variables.yml");
    if (!f.exists()) return;
    cfg.load(f);
    for (String key : cfg.getKeys(true)){
    if (!key.contains(".")) continue;
    vars.put(key,cfg.getString(key));
    }
    } catch (Exception e){
    }
    }
    Или что-то не то?
     
  2. Хостинг MineCraft
    <
  3. Автор темы
    Левый

    Левый Старожил Пользователь

    Trophy Points:
    173
    Skype:
    malhenko26
    Имя в Minecraft:
    Lefty
  4. Jampire

    Jampire Старожил Пользователь

    Trophy Points:
    173
    Skype:
    jampire-h
    Имя в Minecraft:
    Jampire
    выдрал кусок кода из чужого плагина и не понимаешь как он работает?
     
    Левый likes this.
  5. Автор темы
    Левый

    Левый Старожил Пользователь

    Trophy Points:
    173
    Skype:
    malhenko26
    Имя в Minecraft:
    Lefty
    :oops:
    понимаю, но не всё. Где-то лишь 40%
     
  6. Den_Abr

    Den_Abr Старожил Девелопер Пользователь

    Trophy Points:
    173
    Skype:
    Den_Abr
    Имя в Minecraft:
    Den_Abr
    40% понимания обеспечивает отсутствие форматирования.
     
    karolize likes this.
  7. Автор темы
    Левый

    Левый Старожил Пользователь

    Trophy Points:
    173
    Skype:
    malhenko26
    Имя в Minecraft:
    Lefty
    я только начал учиться создавать плагины...
     
  8. kirill2011s

    kirill2011s Старожил Пользователь

    Trophy Points:
    103
    Давно я не видел подобного....
    Форматирование в eclipse: Ctrl + Shift + F.
     
  9. Автор темы
    Левый

    Левый Старожил Пользователь

    Trophy Points:
    173
    Skype:
    malhenko26
    Имя в Minecraft:
    Lefty
    что это? Что за форматирование?
     
  10. 0bsid1

    0bsid1 Старожил Пользователь

    Trophy Points:
    123
    Имя в Minecraft:
    Artarious_Empiroo
    Нажми и всё поймёшь
     
  11. serega6531

    serega6531 Старожил Девелопер Пользователь

    Trophy Points:
    173
    Skype:
    shkurovs
    Вот отформатированный текст:
    Code:
    public static void save(){
        try {
            YamlConfiguration cfg = new YamlConfiguration();
            File f = new File (ReActions.instance.getDataFolder()+File.separator+"variables.yml");
            if (f.exists()) f.delete();
            f.createNewFile();
            for (String key : vars.keySet())
            cfg.set(key, vars.get(key));
            cfg.save(f);
            } catch (Exception e){
        }
    }
    
    public static void load(){
        vars.clear();
        try {
            YamlConfiguration cfg = new YamlConfiguration();
            File f = new File (ReActions.instance.getDataFolder()+File.separator+"variables.yml");
            if (!f.exists()) return;
            cfg.load(f);
            for (String key : cfg.getKeys(true)){
                if (!key.contains(".")) continue;
                vars.put(key,cfg.getString(key));
            }
            } catch (Exception e){
        }
    }
    protected void saveCfg(){
        getConfig().set("general.language",language);
        getConfig().set("general.check-updates",checkUpdates);
        getConfig().set("reactions.show-messages-for-actions",actionMsg);
        getConfig().set("reactions.center-player-teleport",centerTpCoords);
        getConfig().set("reactions.region-recheck-delay",worlduardRecheck);
        getConfig().set("reactions.item-hold-recheck-delay",itemHoldRecheck);
        getConfig().getInt("reactions.item-wear-recheck-delay",itemWearRecheck);
        getConfig().set("reactions.horizontal-pushback-action",horizontalPushback );
        getConfig().set("reactions.need-file-update", needUpdate);
        getConfig().set("actions.shoot.break-block",Shoot.actionShootBreak);
        getConfig().set("actions.shoot.penetrable",Shoot.actionShootThrough);
        saveConfig();
    }
    
    protected void loadCfg(){
        language= getConfig().getString("general.language","english");
        checkUpdates = getConfig().getBoolean("general.check-updates",true);
        languageSave = getConfig().getBoolean("general.language-save",false);
        centerTpCoords = getConfig().getBoolean("reactions.center-player-teleport",true);
        actionMsg= getConfig().getString("reactions.show-messages-for-actions","tp,grpadd,grprmv,townset,townkick,itemrmv,itemgive,moneypay,moneygive");
        worlduardRecheck = getConfig().getInt("reactions.region-recheck-delay",2);
        itemHoldRecheck = getConfig().getInt("reactions.item-hold-recheck-delay",2);
        itemWearRecheck = getConfig().getInt("reactions.item-wear-recheck-delay",2);;
        horizontalPushback = getConfig().getBoolean("reactions.horizontal-pushback-action", false);
        needUpdate= getConfig().getBoolean("reactions.need-file-update", true);
        Shoot.actionShootBreak = getConfig().getString("actions.shoot.break-block",Shoot.actionShootBreak);
        Shoot.actionShootThrough = getConfig().getString("actions.shoot.penetrable",Shoot.actionShootThrough);
    }
    
    public static void save(){
        try {
            YamlConfiguration cfg = new YamlConfiguration();
            File f = new File (ReActions.instance.getDataFolder()+File.separator+"variables.yml");
            if (f.exists()) f.delete();
            f.createNewFile();
            for (String key : vars.keySet())
            cfg.set(key, vars.get(key));
            cfg.save(f);
            } catch (Exception e){
        }
    }
    
    public static void load(){
        vars.clear();
        try {
            YamlConfiguration cfg = new YamlConfiguration();
            File f = new File (ReActions.instance.getDataFolder()+File.separator+"variables.yml");
            if (!f.exists()) return;
            cfg.load(f);
            for (String key : cfg.getKeys(true)){
                if (!key.contains(".")) continue;
                vars.put(key,cfg.getString(key));
            }
            } catch (Exception e){
        }
    }
     
    Левый and musel70 like this.
  12. Автор темы
    Левый

    Левый Старожил Пользователь

    Trophy Points:
    173
    Skype:
    malhenko26
    Имя в Minecraft:
    Lefty
    Спасибо, но я уже понял, что этот код мне не подойдёт
     

Share This Page