Skip to content

Commit

Permalink
Merge pull request #590 from Multiverse/missing_conditions_and_npe
Browse files Browse the repository at this point in the history
Missing Conditions and NPE Fix
  • Loading branch information
dumptruckman authored Nov 15, 2020
2 parents 5462c1b + 0a8d21d commit b21215b
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ public class MVPPlayerListener implements Listener {
public MVPPlayerListener(MultiversePortals plugin, PlayerListenerHelper helper) {
this.plugin = plugin;
this.helper = helper;
this.portalManager = plugin.getPortalManager();
this.filler = new PortalFiller(plugin.getCore());
}

@EventHandler(priority = EventPriority.MONITOR)
public void playerTeleport(PlayerTeleportEvent event) {
if (event.isCancelled()) {
this.plugin.log(Level.FINE, "The PlayerTeleportEvent was already cancelled. Doing nothing.");
return;
}
PortalPlayerSession ps = this.plugin.getPortalSession(event.getPlayer());
Expand All @@ -63,6 +65,11 @@ public void playerTeleport(PlayerTeleportEvent event) {

@EventHandler(priority = EventPriority.LOW)
public void playerBucketFill(PlayerBucketFillEvent event) {
if (event.isCancelled()) {
this.plugin.log(Level.FINE, "The PlayerBucketFillEvent was already cancelled. Doing nothing.");
return;
}

this.plugin.log(Level.FINER, "Fill: ");
this.plugin.log(Level.FINER, "Block Clicked: " + event.getBlockClicked() + ":" + event.getBlockClicked().getType());

Expand All @@ -82,6 +89,11 @@ public void playerBucketFill(PlayerBucketFillEvent event) {

@EventHandler(priority = EventPriority.LOW)
public void playerBucketEmpty(PlayerBucketEmptyEvent event) {
if (event.isCancelled()) {
this.plugin.log(Level.FINE, "The PlayerBucketEmptyEvent was already cancelled. Doing nothing.");
return;
}

Location translatedLocation = this.getTranslatedLocation(event.getBlockClicked(), event.getBlockFace());
this.plugin.log(Level.FINER, "Fill: ");
this.plugin.log(Level.FINER, "Block Clicked: " + event.getBlockClicked() + ":" + event.getBlockClicked().getType());
Expand Down Expand Up @@ -111,6 +123,11 @@ public void playerBucketEmpty(PlayerBucketEmptyEvent event) {

@EventHandler(priority = EventPriority.LOW)
public void playerInteract(PlayerInteractEvent event) {
if (event.isCancelled()) {
this.plugin.log(Level.FINE, "The PlayerInteractEvent was already cancelled. Doing nothing.");
return;
}

// Portal lighting stuff
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getMaterial() == Material.FLINT_AND_STEEL) {
// They're lighting somethin'
Expand Down Expand Up @@ -183,7 +200,6 @@ public void playerInteract(PlayerInteractEvent event) {
private Location getTranslatedLocation(Block clickedBlock, BlockFace face) {
Location clickedLoc = clickedBlock.getLocation();
Location newLoc = new Location(clickedBlock.getWorld(), face.getModX() + clickedLoc.getBlockX(), face.getModY() + clickedLoc.getBlockY(), face.getModZ() + clickedLoc.getBlockZ());
this.portalManager = this.plugin.getPortalManager();
this.plugin.log(Level.FINEST, "Clicked Block: " + clickedBlock.getLocation());
this.plugin.log(Level.FINEST, "Translated Block: " + newLoc);
return newLoc;
Expand All @@ -192,7 +208,7 @@ private Location getTranslatedLocation(Block clickedBlock, BlockFace face) {
@EventHandler
public void playerPortal(PlayerPortalEvent event) {
if (event.isCancelled()) {
this.plugin.log(Level.FINE, "This Portal event was already cancelled.");
this.plugin.log(Level.FINE, "The PlayerPortalEvent was already cancelled. Doing nothing.");
return;
}
this.plugin.log(Level.FINER, "onPlayerPortal called!");
Expand Down

0 comments on commit b21215b

Please sign in to comment.