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.
Listen for world load changes, and update available portals from that
- Loading branch information
1 parent
8db75a9
commit f23874d
Showing
16 changed files
with
194 additions
and
74 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
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
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
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
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
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
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
30 changes: 30 additions & 0 deletions
30
src/main/java/org/sgrewritten/stargate/listener/WorldEventListener.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,30 @@ | ||
package org.sgrewritten.stargate.listener; | ||
|
||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.world.WorldLoadEvent; | ||
import org.bukkit.event.world.WorldUnloadEvent; | ||
import org.sgrewritten.stargate.api.StargateAPI; | ||
import org.sgrewritten.stargate.api.network.portal.RealPortal; | ||
|
||
public class WorldEventListener implements Listener { | ||
|
||
private final StargateAPI stargateAPI; | ||
|
||
public WorldEventListener(StargateAPI stargateAPI) { | ||
this.stargateAPI = stargateAPI; | ||
} | ||
|
||
@EventHandler | ||
void onWordUnload(WorldUnloadEvent event) { | ||
stargateAPI.getRegistry().getAllPortals().filter(portal -> portal instanceof RealPortal) | ||
.map(portal -> (RealPortal) portal) | ||
.filter(realPortal -> realPortal.getExit().getWorld().equals(event.getWorld())) | ||
.forEach(stargateAPI.getRegistry()::unregisterPortal); | ||
} | ||
|
||
@EventHandler | ||
void onWorldLoad(WorldLoadEvent event) { | ||
stargateAPI.getNetworkManager().loadWorld(event.getWorld(), stargateAPI); | ||
} | ||
} |
Oops, something went wrong.