mirror of
https://github.com/GeyserMC/GeyserConnect.git
synced 2025-06-26 14:15:22 +02:00
Add disabled storage manager to prevent empty data (fixes #13)
This commit is contained in:
parent
883f752944
commit
efe9fc4a80
2 changed files with 61 additions and 7 deletions
|
@ -29,6 +29,7 @@ import com.nukkitx.protocol.bedrock.*;
|
||||||
import com.nukkitx.protocol.bedrock.v408.Bedrock_v408;
|
import com.nukkitx.protocol.bedrock.v408.Bedrock_v408;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.geysermc.connect.storage.DisabledStorageManager;
|
||||||
import org.geysermc.connector.network.BedrockProtocol;
|
import org.geysermc.connector.network.BedrockProtocol;
|
||||||
import org.geysermc.connector.utils.FileUtils;
|
import org.geysermc.connector.utils.FileUtils;
|
||||||
import org.geysermc.connect.proxy.GeyserProxyBootstrap;
|
import org.geysermc.connect.proxy.GeyserProxyBootstrap;
|
||||||
|
@ -99,18 +100,22 @@ public class MasterServer {
|
||||||
|
|
||||||
this.generalThreadPool = Executors.newScheduledThreadPool(32);
|
this.generalThreadPool = Executors.newScheduledThreadPool(32);
|
||||||
|
|
||||||
boolean enableShutdownTimer = geyserConnectConfig.getGeyser().getShutdownTime() != -1;
|
|
||||||
|
|
||||||
// Start a timer to keep the thread running
|
// Start a timer to keep the thread running
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
TimerTask task = new TimerTask() { public void run() { } };
|
TimerTask task = new TimerTask() { public void run() { } };
|
||||||
timer.scheduleAtFixedRate(task, 0L, 1000L);
|
timer.scheduleAtFixedRate(task, 0L, 1000L);
|
||||||
|
|
||||||
try {
|
if (!geyserConnectConfig.getCustomServers().isEnabled()) {
|
||||||
storageManager = geyserConnectConfig.getCustomServers().getStorageType().getStorageManager().newInstance();
|
// Force the storage manager if we have it disabled
|
||||||
} catch (Exception e) {
|
storageManager = new DisabledStorageManager();
|
||||||
logger.severe("Invalid storage manager class!", e);
|
logger.info("Disabled custom player servers");
|
||||||
return;
|
} else {
|
||||||
|
try {
|
||||||
|
storageManager = geyserConnectConfig.getCustomServers().getStorageType().getStorageManager().newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.severe("Invalid storage manager class!", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
storageManager.setupStorage();
|
storageManager.setupStorage();
|
||||||
|
|
|
@ -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<Server> loadServers(Player player) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue