forked from shixinzia/Networks-Changed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'shixinzia:master' into master
- Loading branch information
Showing
86 changed files
with
8,334 additions
and
441 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
38 changes: 38 additions & 0 deletions
38
src/main/java/io/github/sefiraat/networks/listeners/BlockListener.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,38 @@ | ||
package io.github.sefiraat.networks.listeners; | ||
|
||
import io.github.sefiraat.networks.NetworkStorage; | ||
import io.github.sefiraat.networks.network.NetworkNode; | ||
import io.github.sefiraat.networks.network.NodeDefinition; | ||
import io.github.sefiraat.networks.network.NodeType; | ||
import io.github.sefiraat.networks.slimefun.network.NetworkController; | ||
import org.bukkit.Location; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.BlockBreakEvent; | ||
import org.bukkit.event.block.BlockPlaceEvent; | ||
|
||
public class BlockListener implements Listener { | ||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) | ||
public void onBlockBreak(BlockBreakEvent e) { | ||
removeNetwork(e.getBlock().getLocation()); | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
public void onBlockPlace(BlockPlaceEvent e) { | ||
removeNetwork(e.getBlock().getLocation()); | ||
} | ||
|
||
private void removeNetwork(Location location) { | ||
NodeDefinition definition = NetworkStorage.getAllNetworkObjects().get(location); | ||
if (definition == null) return; | ||
if (definition.getNode() == null) return; | ||
NetworkStorage.removeNode(location); | ||
|
||
NetworkNode node = definition.getNode(); | ||
if (node != null && node.getNodeType() == NodeType.CONTROLLER) { | ||
NetworkController.wipeNetwork(location); | ||
} | ||
NetworkStorage.removeNode(location); | ||
} | ||
} |
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
2 changes: 2 additions & 0 deletions
2
src/main/java/io/github/sefiraat/networks/managers/ListenerManager.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
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
Oops, something went wrong.