Подпишитесь на наш Telegram-канал, чтобы всегда быть в курсе важных обновлений! Перейти

Часть функционала CloudConfig | exp 3.1 ready

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
6 Окт 2024
Сообщения
179
Реакции
0
Выберите загрузчик игры
  1. Прочие моды
Привет Yougameee:catjam:
Сливаю вам клауд конфиг ( или это не совсем клауд конфиг ) ну не важно
Как оно работает?
Пишите команду .cloudconfig <конфиг> и у вас качаеться конфиг с дроп бокса!
Пожалуйста, авторизуйтесь для просмотра ссылки.

Сама команда:

Я жду новый год:
Expand Collapse Copy
package yume.fun.command.impl.feature;

import yume.fun.command.*;
import yume.fun.command.impl.CommandException;
import yume.fun.config.ConfigStorage;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.text.TextFormatting;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public class CloudConfigCommand implements Command, CommandWithAdvice {

    final ConfigStorage configStorage;
    final Prefix prefix;
    final Logger logger;

    private static final Map<String, String> CONFIG_URLS = Map.of(
        "hw", "https://dl.dropboxusercontent.com/s/your_hw_config_link/hw.cfg?dl=1",
        "ft", "https://dl.dropboxusercontent.com/s/your_ft_config_link/ft.cfg?dl=1",
        "rw", "https://dl.dropboxusercontent.com/s/your_rw_config_link/rw.cfg?dl=1",
        "sp", "https://dl.dropboxusercontent.com/s/your_sp_config_link/sp.cfg?dl=1"
    );

    @Override
    public void execute(Parameters parameters) {
        String configType = parameters.asString(0)
                .orElseThrow(() -> new CommandException(TextFormatting.RED + "Укажите тип конфига: " + TextFormatting.GRAY + "hw, ft, rw, sp"));

        String configUrl = CONFIG_URLS.get(configType.toLowerCase());
        if (configUrl == null) {
            throw new CommandException(TextFormatting.RED + "Неизвестный тип конфига: " + TextFormatting.GRAY + configType +
                TextFormatting.RED + ". Доступные: " + TextFormatting.GRAY + "hw, ft, rw, sp");
        }

        downloadConfig(configType.toLowerCase(), configUrl);
    }

    @Override
    public String name() {
        return "cloudconfig";
    }

    @Override
    public String description() {
        return "Скачивает конфиги с Dropbox";
    }

    @Override
    public List<String> adviceMessage() {
        String commandPrefix = prefix.get();
        
        return List.of(
            commandPrefix + name() + " <config_type> - Скачать конфиг с Dropbox",
            "Доступные типы конфигов: " + TextFormatting.GRAY + "hw, ft, rw, sp",
            "Пример: " + TextFormatting.RED + commandPrefix + "cloudconfig hw",
            "Пример: " + TextFormatting.RED + commandPrefix + "cloudconfig ft"
        );
    }

    public List<String> aliases() {
        return List.of("ccfg", "cloud");
    }

    private void downloadConfig(String configType, String configUrl) {
        logger.log(TextFormatting.YELLOW + "Начинаю скачивание конфига: " + TextFormatting.RED + configType);
        
        CompletableFuture.runAsync(() -> {
            try {
                Path configDir = configStorage.CONFIG_DIR.toPath();
                if (!Files.exists(configDir)) {
                    Files.createDirectories(configDir);
                }

                File configFile = new File(configStorage.CONFIG_DIR, configType + ".cfg");
                Path tempFile = Files.createTempFile("cloudconfig_", ".tmp");

                logger.log(TextFormatting.GRAY + "Скачиваю файл с Dropbox...");
                
                try (InputStream in = new URL(configUrl).openStream()) {
                    Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
                }

                Files.move(tempFile, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
                
                logger.log(TextFormatting.GREEN + "Конфиг " + TextFormatting.RED + configType +
                    TextFormatting.GREEN + " успешно скачан и сохранен как " + TextFormatting.RED + configFile.getName());
                
                logger.log(TextFormatting.GRAY + "Используйте " + TextFormatting.RED + prefix.get() + "config load " + configType +
                    TextFormatting.GRAY + " для загрузки конфига");

            } catch (IOException e) {
                logger.log(TextFormatting.RED + "Ошибка при скачивании конфига: " + TextFormatting.GRAY + e.getMessage());
                logger.log(TextFormatting.RED + "Проверьте подключение к интернету и правильность ссылки");
            } catch (Exception e) {
                logger.log(TextFormatting.RED + "Неожиданная ошибка: " + TextFormatting.GRAY + e.getMessage());
            }
        });
    }
}

На этом все!
 
Привет Yougameee:catjam:
Сливаю вам клауд конфиг ( или это не совсем клауд конфиг ) ну не важно
Как оно работает?
Пишите команду .cloudconfig <конфиг> и у вас качаеться конфиг с дроп бокса!
Пожалуйста, авторизуйтесь для просмотра ссылки.

Сама команда:

Я жду новый год:
Expand Collapse Copy
package yume.fun.command.impl.feature;

import yume.fun.command.*;
import yume.fun.command.impl.CommandException;
import yume.fun.config.ConfigStorage;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.text.TextFormatting;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public class CloudConfigCommand implements Command, CommandWithAdvice {

    final ConfigStorage configStorage;
    final Prefix prefix;
    final Logger logger;

    private static final Map<String, String> CONFIG_URLS = Map.of(
        "hw", "https://dl.dropboxusercontent.com/s/your_hw_config_link/hw.cfg?dl=1",
        "ft", "https://dl.dropboxusercontent.com/s/your_ft_config_link/ft.cfg?dl=1",
        "rw", "https://dl.dropboxusercontent.com/s/your_rw_config_link/rw.cfg?dl=1",
        "sp", "https://dl.dropboxusercontent.com/s/your_sp_config_link/sp.cfg?dl=1"
    );

    @Override
    public void execute(Parameters parameters) {
        String configType = parameters.asString(0)
                .orElseThrow(() -> new CommandException(TextFormatting.RED + "Укажите тип конфига: " + TextFormatting.GRAY + "hw, ft, rw, sp"));

        String configUrl = CONFIG_URLS.get(configType.toLowerCase());
        if (configUrl == null) {
            throw new CommandException(TextFormatting.RED + "Неизвестный тип конфига: " + TextFormatting.GRAY + configType +
                TextFormatting.RED + ". Доступные: " + TextFormatting.GRAY + "hw, ft, rw, sp");
        }

        downloadConfig(configType.toLowerCase(), configUrl);
    }

    @Override
    public String name() {
        return "cloudconfig";
    }

    @Override
    public String description() {
        return "Скачивает конфиги с Dropbox";
    }

    @Override
    public List<String> adviceMessage() {
        String commandPrefix = prefix.get();
       
        return List.of(
            commandPrefix + name() + " <config_type> - Скачать конфиг с Dropbox",
            "Доступные типы конфигов: " + TextFormatting.GRAY + "hw, ft, rw, sp",
            "Пример: " + TextFormatting.RED + commandPrefix + "cloudconfig hw",
            "Пример: " + TextFormatting.RED + commandPrefix + "cloudconfig ft"
        );
    }

    public List<String> aliases() {
        return List.of("ccfg", "cloud");
    }

    private void downloadConfig(String configType, String configUrl) {
        logger.log(TextFormatting.YELLOW + "Начинаю скачивание конфига: " + TextFormatting.RED + configType);
       
        CompletableFuture.runAsync(() -> {
            try {
                Path configDir = configStorage.CONFIG_DIR.toPath();
                if (!Files.exists(configDir)) {
                    Files.createDirectories(configDir);
                }

                File configFile = new File(configStorage.CONFIG_DIR, configType + ".cfg");
                Path tempFile = Files.createTempFile("cloudconfig_", ".tmp");

                logger.log(TextFormatting.GRAY + "Скачиваю файл с Dropbox...");
               
                try (InputStream in = new URL(configUrl).openStream()) {
                    Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
                }

                Files.move(tempFile, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
               
                logger.log(TextFormatting.GREEN + "Конфиг " + TextFormatting.RED + configType +
                    TextFormatting.GREEN + " успешно скачан и сохранен как " + TextFormatting.RED + configFile.getName());
               
                logger.log(TextFormatting.GRAY + "Используйте " + TextFormatting.RED + prefix.get() + "config load " + configType +
                    TextFormatting.GRAY + " для загрузки конфига");

            } catch (IOException e) {
                logger.log(TextFormatting.RED + "Ошибка при скачивании конфига: " + TextFormatting.GRAY + e.getMessage());
                logger.log(TextFormatting.RED + "Проверьте подключение к интернету и правильность ссылки");
            } catch (Exception e) {
                logger.log(TextFormatting.RED + "Неожиданная ошибка: " + TextFormatting.GRAY + e.getMessage());
            }
        });
    }
}

На этом все!
говнище
 
Привет Yougameee:catjam:
Сливаю вам клауд конфиг ( или это не совсем клауд конфиг ) ну не важно
Как оно работает?
Пишите команду .cloudconfig <конфиг> и у вас качаеться конфиг с дроп бокса!
Пожалуйста, авторизуйтесь для просмотра ссылки.

Сама команда:

Я жду новый год:
Expand Collapse Copy
package yume.fun.command.impl.feature;

import yume.fun.command.*;
import yume.fun.command.impl.CommandException;
import yume.fun.config.ConfigStorage;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.text.TextFormatting;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public class CloudConfigCommand implements Command, CommandWithAdvice {

    final ConfigStorage configStorage;
    final Prefix prefix;
    final Logger logger;

    private static final Map<String, String> CONFIG_URLS = Map.of(
        "hw", "https://dl.dropboxusercontent.com/s/your_hw_config_link/hw.cfg?dl=1",
        "ft", "https://dl.dropboxusercontent.com/s/your_ft_config_link/ft.cfg?dl=1",
        "rw", "https://dl.dropboxusercontent.com/s/your_rw_config_link/rw.cfg?dl=1",
        "sp", "https://dl.dropboxusercontent.com/s/your_sp_config_link/sp.cfg?dl=1"
    );

    @Override
    public void execute(Parameters parameters) {
        String configType = parameters.asString(0)
                .orElseThrow(() -> new CommandException(TextFormatting.RED + "Укажите тип конфига: " + TextFormatting.GRAY + "hw, ft, rw, sp"));

        String configUrl = CONFIG_URLS.get(configType.toLowerCase());
        if (configUrl == null) {
            throw new CommandException(TextFormatting.RED + "Неизвестный тип конфига: " + TextFormatting.GRAY + configType +
                TextFormatting.RED + ". Доступные: " + TextFormatting.GRAY + "hw, ft, rw, sp");
        }

        downloadConfig(configType.toLowerCase(), configUrl);
    }

    @Override
    public String name() {
        return "cloudconfig";
    }

    @Override
    public String description() {
        return "Скачивает конфиги с Dropbox";
    }

    @Override
    public List<String> adviceMessage() {
        String commandPrefix = prefix.get();
       
        return List.of(
            commandPrefix + name() + " <config_type> - Скачать конфиг с Dropbox",
            "Доступные типы конфигов: " + TextFormatting.GRAY + "hw, ft, rw, sp",
            "Пример: " + TextFormatting.RED + commandPrefix + "cloudconfig hw",
            "Пример: " + TextFormatting.RED + commandPrefix + "cloudconfig ft"
        );
    }

    public List<String> aliases() {
        return List.of("ccfg", "cloud");
    }

    private void downloadConfig(String configType, String configUrl) {
        logger.log(TextFormatting.YELLOW + "Начинаю скачивание конфига: " + TextFormatting.RED + configType);
       
        CompletableFuture.runAsync(() -> {
            try {
                Path configDir = configStorage.CONFIG_DIR.toPath();
                if (!Files.exists(configDir)) {
                    Files.createDirectories(configDir);
                }

                File configFile = new File(configStorage.CONFIG_DIR, configType + ".cfg");
                Path tempFile = Files.createTempFile("cloudconfig_", ".tmp");

                logger.log(TextFormatting.GRAY + "Скачиваю файл с Dropbox...");
               
                try (InputStream in = new URL(configUrl).openStream()) {
                    Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
                }

                Files.move(tempFile, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
               
                logger.log(TextFormatting.GREEN + "Конфиг " + TextFormatting.RED + configType +
                    TextFormatting.GREEN + " успешно скачан и сохранен как " + TextFormatting.RED + configFile.getName());
               
                logger.log(TextFormatting.GRAY + "Используйте " + TextFormatting.RED + prefix.get() + "config load " + configType +
                    TextFormatting.GRAY + " для загрузки конфига");

            } catch (IOException e) {
                logger.log(TextFormatting.RED + "Ошибка при скачивании конфига: " + TextFormatting.GRAY + e.getMessage());
                logger.log(TextFormatting.RED + "Проверьте подключение к интернету и правильность ссылки");
            } catch (Exception e) {
                logger.log(TextFormatting.RED + "Неожиданная ошибка: " + TextFormatting.GRAY + e.getMessage());
            }
        });
    }
}

На этом все!
Похоже на чат гпт а так лан мб солью свою доработку до норм вида
 
Назад
Сверху Снизу