Skip to content

Commit

Permalink
Call VisitEvent before teleportation.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Jun 17, 2020
1 parent 4aae218 commit abc1d34
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main/java/world/bentobox/visit/managers/VisitAddonManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package world.bentobox.visit.managers;


import org.bukkit.Bukkit;
import org.bukkit.World;
import org.eclipse.jdt.annotation.NonNull;
import java.util.*;
Expand All @@ -12,6 +13,7 @@
import world.bentobox.bentobox.util.Util;
import world.bentobox.visit.VisitAddon;
import world.bentobox.visit.database.object.IslandVisitSettings;
import world.bentobox.visit.events.VisitEvent;


/**
Expand Down Expand Up @@ -372,9 +374,17 @@ else if (settings.getPayment() > 0 && !this.depositCredits(User.getInstance(isla
}
else
{
// Teleport player async to island spawn point.
Util.teleportAsync(user.getPlayer(),
Objects.requireNonNull(island.getSpawnPoint(World.Environment.NORMAL)));
// Call visit event.
VisitEvent event = new VisitEvent(user.getUniqueId(), island);
Bukkit.getPluginManager().callEvent(event);

// If event is not cancelled, then teleport player.
if (!event.isCancelled())
{
// Teleport player async to island spawn point.
Util.teleportAsync(user.getPlayer(),
Objects.requireNonNull(island.getSpawnPoint(World.Environment.NORMAL)));
}
}
}
}

0 comments on commit abc1d34

Please sign in to comment.