Skip to content

Commit

Permalink
feat: add config
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolLoong committed Mar 2, 2024
1 parent 69db088 commit 1e5905d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/main/java/cn/nukkit/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,17 @@ public void start() {

ServerStartedEvent serverStartedEvent = new ServerStartedEvent();
getPluginManager().callEvent(serverStartedEvent);
Convert.start();

Server instance1 = Server.getInstance();
List<String> convert = instance1.getConfig().getStringList("convert");
for (var w : convert) {
if (!instance1.isLevelLoaded(w)) {
instance1.loadLevel(w);
}
Level level = instance1.getLevelByName(w);
Convert.start(level);
log.info("Level {} convert Done!", w);
}
System.exit(0);
// this.tickProcessor();
this.forceShutdown();
Expand Down Expand Up @@ -1211,7 +1221,7 @@ private void checkTickUpdates(int currentTick, long tickTime) {
try {
long levelTime = System.currentTimeMillis();
//Ensures that the server won't try to tick a level without providers.
if(level.getProvider().getLevel() == null) {
if (level.getProvider().getLevel() == null) {
log.warn("Tried to tick Level " + level.getName() + " without a provider!");
continue;
}
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/cn/nukkit/convert/Convert.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package cn.nukkit.convert;

import cn.nukkit.Server;
import cn.nukkit.convert.leveldb.LevelDBStorage;
import cn.nukkit.convert.leveldb.LevelDat;
import cn.nukkit.convert.task.ConvertTask;
Expand All @@ -24,16 +23,15 @@

@Slf4j
public class Convert {
public static String world = "world";
public static PluginI18n I18N;
public static ForkJoinPool THREAD_POOL_EXECUTOR = (ForkJoinPool) Executors.newWorkStealingPool();

public static void start() {
public static void start(Level level) {
PlayerDataConvert.start();
log.info("convert player data complete!");

File file = new File("worlds", world + "/region");
Level level = Server.getInstance().getLevelByName(world);
String levelName = level.getName();
File file = new File("worlds", levelName + "/region");
Anvil levelProvider = (Anvil) level.requireProvider();

try {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/default-nukkit.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
convert: [ "world" ]

settings:
language: "eng"
force-language: false
Expand Down

0 comments on commit 1e5905d

Please sign in to comment.