Skip to content

Commit

Permalink
Improve VisitEvent.
Browse files Browse the repository at this point in the history
Add ability to get User object.
  • Loading branch information
BONNe committed Feb 3, 2022
1 parent 0fa39ed commit f1e00d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
32 changes: 11 additions & 21 deletions src/main/java/world/bentobox/visit/events/VisitEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.UUID;

import world.bentobox.bentobox.api.events.BentoBoxEvent;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;


Expand All @@ -31,7 +32,7 @@ public class VisitEvent extends BentoBoxEvent implements Cancellable
* @param player of type UUID
* @param island of type Island
*/
public VisitEvent(UUID player, Island island)
public VisitEvent(User player, Island island)
{
this.player = player;
this.island = island;
Expand Down Expand Up @@ -74,40 +75,29 @@ public void setCancelled(boolean cancelled)
*/
public Island getIsland()
{
return island;
return this.island;
}


/**
* This method sets the island value.
* This method returns the player UUID.
*
* @param island the island new value.
*/
public void setIsland(Island island)
{
this.island = island;
}


/**
* This method returns the player value.
*
* @return the value of player.
* @return the UUID of player.
*/
public UUID getPlayer()
{
return player;
return this.player.getUniqueId();
}


/**
* This method sets the player value.
* This method returns the player.
*
* @param player the player new value.
* @return the user
*/
public void setPlayer(UUID player)
public User getUser()
{
this.player = player;
return this.player;
}


Expand Down Expand Up @@ -156,7 +146,7 @@ public static HandlerList getHandlerList()
/**
* Variable that stores player who wants to visit an island.
*/
private UUID player;
private User player;

/**
* Event listener list for current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ else if (value)
private void startTeleportation(User user, Island island)
{
// Call visit event.
VisitEvent event = new VisitEvent(user.getUniqueId(), island);
VisitEvent event = new VisitEvent(user, island);
Bukkit.getPluginManager().callEvent(event);

// If event is not cancelled, then teleport player.
Expand Down

0 comments on commit f1e00d8

Please sign in to comment.