diff --git a/src/main/java/org/geysermc/connect/MasterServer.java b/src/main/java/org/geysermc/connect/MasterServer.java index 2cbdeb4..c64b8e7 100644 --- a/src/main/java/org/geysermc/connect/MasterServer.java +++ b/src/main/java/org/geysermc/connect/MasterServer.java @@ -29,6 +29,7 @@ import com.nukkitx.protocol.bedrock.*; import com.nukkitx.protocol.bedrock.v408.Bedrock_v408; import lombok.Getter; import lombok.Setter; +import org.geysermc.connect.storage.DisabledStorageManager; import org.geysermc.connector.network.BedrockProtocol; import org.geysermc.connector.utils.FileUtils; import org.geysermc.connect.proxy.GeyserProxyBootstrap; @@ -99,18 +100,22 @@ public class MasterServer { this.generalThreadPool = Executors.newScheduledThreadPool(32); - boolean enableShutdownTimer = geyserConnectConfig.getGeyser().getShutdownTime() != -1; - // Start a timer to keep the thread running timer = new Timer(); TimerTask task = new TimerTask() { public void run() { } }; timer.scheduleAtFixedRate(task, 0L, 1000L); - try { - storageManager = geyserConnectConfig.getCustomServers().getStorageType().getStorageManager().newInstance(); - } catch (Exception e) { - logger.severe("Invalid storage manager class!", e); - return; + if (!geyserConnectConfig.getCustomServers().isEnabled()) { + // Force the storage manager if we have it disabled + storageManager = new DisabledStorageManager(); + logger.info("Disabled custom player servers"); + } else { + try { + storageManager = geyserConnectConfig.getCustomServers().getStorageType().getStorageManager().newInstance(); + } catch (Exception e) { + logger.severe("Invalid storage manager class!", e); + return; + } } storageManager.setupStorage(); diff --git a/src/main/java/org/geysermc/connect/storage/DisabledStorageManager.java b/src/main/java/org/geysermc/connect/storage/DisabledStorageManager.java new file mode 100644 index 0000000..8ca6eb8 --- /dev/null +++ b/src/main/java/org/geysermc/connect/storage/DisabledStorageManager.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/GeyserConnect + */ + +package org.geysermc.connect.storage; + +import org.geysermc.connect.utils.Player; +import org.geysermc.connect.utils.Server; + +import java.util.ArrayList; +import java.util.List; + +public class DisabledStorageManager extends AbstractStorageManager { + + @Override + public void setupStorage() { + } + + @Override + public void saveServers(Player player) { + + } + + @Override + public List loadServers(Player player) { + return new ArrayList<>(); + } +}