@@ -0,0 +1,3936 @@
+/*%0A * This file is part of Orbit, licenced under the MIT Licence (MIT)%0A *%0A * Copyright (c) Vayzd Network %3Chttps://www.vayzd.net/%3E%0A * Copyright (c) contributors%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy%0A * of this software and associated documentation files (the %22Software%22), to deal%0A * in the Software without restriction, including without limitation the rights%0A * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A * copies of the Software, and to permit persons to whom the Software is%0A * furnished to do so, subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in all%0A * copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE%0A * SOFTWARE.%0A */%0Apackage net.vayzd.orbit.proxy;%0A%0Aimport com.google.common.io.*;%0Aimport lombok.*;%0Aimport net.md_5.bungee.api.plugin.*;%0Aimport net.md_5.bungee.config.*;%0Aimport net.vayzd.orbit.datastore.*;%0A%0Aimport java.io.*;%0Aimport java.util.logging.*;%0A%0Apublic class OrbitProxyPlugin extends Plugin %7B%0A%0A    @Getter%0A    private Datastore datastore;%0A%0A    @Override%0A    public void onEnable() %7B%0A        saveDefaultConfig();%0A        getLogger().info(%22Connecting to database...%22);%0A        try %7B%0A            Configuration configuration = YamlConfiguration.getProvider(ConfigurationProvider.class).load(%0A                    new File(getDataFolder(), %22config.yml%22)%0A            );%0A            datastore = OrbitDatastore.createDatastore(%0A                    getLogger(),%0A                    new DatastoreCredentials(%0A                            configuration.getString(%22database.hostname%22),%0A                            configuration.getInt(%22database.port%22),%0A                            configuration.getString(%22database.username%22),%0A                            configuration.getString(%22database.password%22),%0A                            configuration.getString(%22database.defaultDatabase%22)%0A                    ),%0A                    Thread.currentThread(),%0A                    configuration.getInt(%22pool-size%22)%0A            );%0A            datastore.connect((result, error) -%3E %7B%0A                if (error == null) %7B%0A                    datastore.fetchAndCacheGroups();%0A                %7D else %7B%0A                    shutdownDueToDatastoreFailure(error);%0A                %7D%0A            %7D);%0A            getLogger().info(%22Successfully connected!%22);%0A        %7D catch (Exception error) %7B%0A            shutdownDueToDatastoreFailure(error);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void onDisable() %7B%0A        datastore.disconnect((success, error) -%3E %7B%0A        %7D);%0A    %7D%0A%0A    private void saveDefaultConfig() %7B%0A        if (!getDataFolder().exists()) %7B%0A            if (getDataFolder().mkdir()) %7B%0A                File defaultFile = new File(getDataFolder(), %22config.yml%22);%0A                if (!defaultFile.exists()) %7B%0A                    try (InputStream input = getResourceAsStream(%22config.yml%22);%0A                         OutputStream output = new FileOutputStream(defaultFile)) %7B%0A                        ByteStreams.copy(input, output);%0A                    %7D catch (IOException error) %7B%0A                        error.printStackTrace();%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    private void shutdownDueToDatastoreFailure(Throwable error) %7B%0A        getLogger().log(Level.WARNING, %22Unable to construct datastore instance%22, error);%0A        getLogger().warning(%22Shutting down...%22);%0A        getProxy().stop();%0A    %7D%0A%7D%0A

Add OrbitProxyPlugin class