Skip to content

Commit

Permalink
feat: Adds previous island owner to IslandOwnershipTransferEvent (#14)
Browse files Browse the repository at this point in the history
Instead of resolving the previous owner and risk a potential web/api request getting triggert,
although the previous owner might never be used, I decided on just providing the UUID we already have.

The plugins can then still find the (Offline)Player themselves when needed.
  • Loading branch information
SpraxDev committed Jan 30, 2024
1 parent 0b685b3 commit 3aa85c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,34 @@
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

import java.util.UUID;

public class IslandOwnershipTransferEvent extends IslandEvent {
private static final HandlerList HANDLERS = new HandlerList();

private final OfflinePlayer owner;
private final UUID previousOwnerId;

public IslandOwnershipTransferEvent(Island island, OfflinePlayer owner) {
public IslandOwnershipTransferEvent(Island island, OfflinePlayer owner, UUID previousOwnerId) {
super(island);
this.owner = owner;
}

public static HandlerList getHandlerList() {
return HANDLERS;
this.previousOwnerId = previousOwnerId;
}

public OfflinePlayer getOwner() {
return this.owner;
}

public UUID getPreviousOwnerId() {
return this.previousOwnerId;
}

@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}

public static HandlerList getHandlerList() {
return HANDLERS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public synchronized void giveOwnership(Island island, org.bukkit.OfflinePlayer p
removeIsland(uuid2);
this.islandStorage.put(player.getUniqueId(), island);

Bukkit.getServer().getPluginManager().callEvent(new IslandOwnershipTransferEvent(island.getAPIWrapper(), player));
Bukkit.getServer().getPluginManager().callEvent(new IslandOwnershipTransferEvent(island.getAPIWrapper(), player, uuid2));

ArrayList<UUID> islandMembers = new ArrayList<>();
islandMembers.addAll(island.getRole(IslandRole.MEMBER));
Expand Down

0 comments on commit 3aa85c7

Please sign in to comment.