forked from PseudoKnight/Stargate-Bukkit
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6dd633
commit 4d80222
Showing
3 changed files
with
95 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/org/sgrewritten/stargate/migration/MigrationWorldLoadListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.sgrewritten.stargate.migration; | ||
|
||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.world.WorldLoadEvent; | ||
import org.sgrewritten.stargate.Stargate; | ||
import org.sgrewritten.stargate.api.StargateAPI; | ||
import org.sgrewritten.stargate.util.LegacyPortalStorageLoader; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Set; | ||
|
||
public class MigrationWorldLoadListener implements Listener { | ||
private final Set<String> invalidWorlds; | ||
private final File dir; | ||
private final String defaultNetworkName; | ||
private final StargateAPI stargateAPI; | ||
|
||
|
||
public MigrationWorldLoadListener(Set<String> invalidWorlds, File dir, String defaultNetworkName, StargateAPI stargateAPI) { | ||
this.invalidWorlds = invalidWorlds; | ||
this.dir = dir; | ||
this.defaultNetworkName = defaultNetworkName; | ||
this.stargateAPI = stargateAPI; | ||
} | ||
|
||
@EventHandler | ||
void onWorldLoad(WorldLoadEvent event) { | ||
String worldDatabaseName = event.getWorld().getName() + ".db"; | ||
if (invalidWorlds.contains(worldDatabaseName)) { | ||
try { | ||
LegacyPortalStorageLoader.loadWorld(new File(dir, worldDatabaseName), defaultNetworkName, stargateAPI); | ||
} catch (IOException e) { | ||
Stargate.log(e); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters