diff --git a/bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java b/bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java index 6b920466..5f33dc9e 100644 --- a/bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java +++ b/bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java @@ -147,10 +147,6 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes { getLoggingAdapter().log(Level.INFO, "Successfully initialized the network messenger."); } - // Initialize the cache - cache = new Cache(); - cache.initialize(database); - // Prepare the teleport manager this.teleportManager = new TeleportManager(this); @@ -160,6 +156,10 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes { // Prepare the event dispatcher this.eventDispatcher = new BukkitEventDispatcher(this); + // Initialize the cache + cache = new Cache(eventDispatcher); + cache.initialize(database); + // Prepare the home and warp position manager this.savedPositionManager = new SavedPositionManager(database, cache, eventDispatcher, settings.allowUnicodeNames, settings.allowUnicodeDescriptions); diff --git a/bukkit/src/main/java/net/william278/huskhomes/event/BukkitEventDispatcher.java b/bukkit/src/main/java/net/william278/huskhomes/event/BukkitEventDispatcher.java index a7345cd4..684c5a2b 100644 --- a/bukkit/src/main/java/net/william278/huskhomes/event/BukkitEventDispatcher.java +++ b/bukkit/src/main/java/net/william278/huskhomes/event/BukkitEventDispatcher.java @@ -1,6 +1,7 @@ package net.william278.huskhomes.event; import net.william278.huskhomes.BukkitHuskHomes; +import net.william278.huskhomes.player.OnlineUser; import net.william278.huskhomes.position.Home; import net.william278.huskhomes.position.Warp; import net.william278.huskhomes.teleport.Teleport; @@ -8,6 +9,7 @@ import net.william278.huskhomes.teleport.TimedTeleport; import org.bukkit.Bukkit; import org.jetbrains.annotations.NotNull; +import java.util.List; import java.util.concurrent.CompletableFuture; public class BukkitEventDispatcher implements EventDispatcher { @@ -19,14 +21,11 @@ public class BukkitEventDispatcher implements EventDispatcher { } @Override - public CompletableFuture dispatchTeleportEvent(@NotNull Teleport teleport) { - final CompletableFuture dispatchFuture = new CompletableFuture<>(); + public void dispatchTeleportEvent(@NotNull Teleport teleport) { Bukkit.getScheduler().runTask(plugin, () -> { final TeleportEvent event = new TeleportEvent(teleport); Bukkit.getPluginManager().callEvent(event); - dispatchFuture.complete(event); }); - return dispatchFuture; } @Override @@ -84,4 +83,27 @@ public class BukkitEventDispatcher implements EventDispatcher { return dispatchFuture; } + @Override + public CompletableFuture dispatchViewHomeListEvent(@NotNull List homes, @NotNull OnlineUser user, + boolean publicHomeList) { + final CompletableFuture dispatchFuture = new CompletableFuture<>(); + Bukkit.getScheduler().runTask(plugin, () -> { + final HomeListEvent event = new HomeListEvent(homes, user, publicHomeList); + Bukkit.getPluginManager().callEvent(event); + dispatchFuture.complete(event); + }); + return dispatchFuture; + } + + @Override + public CompletableFuture dispatchViewWarpListEvent(@NotNull List warps, @NotNull OnlineUser user) { + final CompletableFuture dispatchFuture = new CompletableFuture<>(); + Bukkit.getScheduler().runTask(plugin, () -> { + final WarpListEvent event = new WarpListEvent(warps, user); + Bukkit.getPluginManager().callEvent(event); + dispatchFuture.complete(event); + }); + return dispatchFuture; + } + } diff --git a/bukkit/src/main/java/net/william278/huskhomes/event/HomeListEvent.java b/bukkit/src/main/java/net/william278/huskhomes/event/HomeListEvent.java new file mode 100644 index 00000000..872f682b --- /dev/null +++ b/bukkit/src/main/java/net/william278/huskhomes/event/HomeListEvent.java @@ -0,0 +1,64 @@ +package net.william278.huskhomes.event; + +import net.william278.huskhomes.player.OnlineUser; +import net.william278.huskhomes.position.Home; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class HomeListEvent extends Event implements IHomeListEvent, Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + @NotNull + private final List homes; + @NotNull + private final OnlineUser onlineUser; + private final boolean isPublicHomeList; + private boolean cancelled; + + public HomeListEvent(@NotNull List homes, @NotNull OnlineUser onlineUser, boolean isPublicHomeList) { + this.homes = homes; + this.onlineUser = onlineUser; + this.isPublicHomeList = isPublicHomeList; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } + + @Override + @NotNull + public List getHomes() { + return homes; + } + + @Override + @NotNull + public OnlineUser getOnlineUser() { + return onlineUser; + } + + @Override + public boolean getIsPublicHomeList() { + return isPublicHomeList; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + @Override + public boolean isCancelled() { + return cancelled; + } +} diff --git a/bukkit/src/main/java/net/william278/huskhomes/event/WarpListEvent.java b/bukkit/src/main/java/net/william278/huskhomes/event/WarpListEvent.java new file mode 100644 index 00000000..c1d4ef43 --- /dev/null +++ b/bukkit/src/main/java/net/william278/huskhomes/event/WarpListEvent.java @@ -0,0 +1,57 @@ +package net.william278.huskhomes.event; + +import net.william278.huskhomes.player.OnlineUser; +import net.william278.huskhomes.position.Warp; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class WarpListEvent extends Event implements IWarpListEvent, Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + @NotNull + private final List warps; + @NotNull + private final OnlineUser onlineUser; + private boolean cancelled; + + public WarpListEvent(@NotNull List warps, @NotNull OnlineUser onlineUser) { + this.warps = warps; + this.onlineUser = onlineUser; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } + + @Override + @NotNull + public List getWarps() { + return warps; + } + + @Override + @NotNull + public OnlineUser getOnlineUser() { + return onlineUser; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + @Override + public boolean isCancelled() { + return cancelled; + } +} diff --git a/common/src/main/java/net/william278/huskhomes/Cache.java b/common/src/main/java/net/william278/huskhomes/Cache.java index 4ce18522..2cc89824 100644 --- a/common/src/main/java/net/william278/huskhomes/Cache.java +++ b/common/src/main/java/net/william278/huskhomes/Cache.java @@ -4,6 +4,7 @@ import de.themoep.minedown.MineDown; import net.william278.huskhomes.command.CommandBase; import net.william278.huskhomes.config.Locales; import net.william278.huskhomes.database.Database; +import net.william278.huskhomes.event.EventDispatcher; import net.william278.huskhomes.player.OnlineUser; import net.william278.huskhomes.player.User; import net.william278.huskhomes.position.Home; @@ -12,10 +13,7 @@ import net.william278.paginedown.ListOptions; import net.william278.paginedown.PaginatedList; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -59,10 +57,15 @@ public class Cache { */ public final HashMap warpLists; + /** + * Plugin event dispatcher + */ + private final EventDispatcher eventDispatcher; + /** * Create a new cache */ - public Cache() { + public Cache(@NotNull EventDispatcher eventDispatcher) { this.homes = new HashMap<>(); this.publicHomes = new HashMap<>(); this.warps = new ArrayList<>(); @@ -70,6 +73,7 @@ public class Cache { this.privateHomeLists = new HashMap<>(); this.publicHomeLists = new HashMap<>(); this.warpLists = new HashMap<>(); + this.eventDispatcher = eventDispatcher; } /** @@ -134,8 +138,11 @@ public class Cache { } @NotNull - public MineDown getHomeList(@NotNull OnlineUser onlineUser, @NotNull User listOwner, @NotNull Locales locales, - @NotNull List homes, final int itemsPerPage, final int page) { + public Optional getHomeList(@NotNull OnlineUser onlineUser, @NotNull User listOwner, @NotNull Locales locales, + @NotNull List homes, final int itemsPerPage, final int page) { + if (eventDispatcher.dispatchViewHomeListEvent(homes, onlineUser, false).join().isCancelled()) { + return Optional.empty(); + } final PaginatedList homeList = PaginatedList.of(homes.stream().map(home -> locales.getRawLocale("home_list_item", Locales.escapeMineDown(home.meta.name), @@ -147,7 +154,50 @@ public class Cache { "%last_item_on_page_index%", "%total_items%").orElse("")) .setCommand("/huskhomes:homelist").build()); this.privateHomeLists.put(onlineUser.uuid, homeList); - return homeList.getNearestValidPage(page); + return Optional.of(homeList.getNearestValidPage(page)); + } + + @NotNull + public Optional getPublicHomeList(@NotNull OnlineUser onlineUser, @NotNull Locales locales, + @NotNull List publicHomes, final int itemsPerPage, final int page) { + if (eventDispatcher.dispatchViewHomeListEvent(publicHomes, onlineUser, true).join().isCancelled()) { + return Optional.empty(); + } + final PaginatedList publicHomeList = PaginatedList.of(publicHomes.stream().map(home -> + locales.getRawLocale("public_home_list_item", + Locales.escapeMineDown(home.meta.name), + Locales.escapeMineDown(home.owner.username + "." + home.meta.name), + Locales.escapeMineDown(home.owner.username), + Locales.escapeMineDown(locales.formatDescription(home.meta.description))) + .orElse(home.meta.name)).sorted().collect(Collectors.toList()), getBaseList(locales, itemsPerPage) + .setHeaderFormat(locales.getRawLocale("public_home_list_page_title", + "%first_item_on_page_index%", "%last_item_on_page_index%", + "%total_items%").orElse("")) + .setCommand("/huskhomes:publichomelist").build()); + publicHomeLists.put(onlineUser.uuid, publicHomeList); + return Optional.of(publicHomeList.getNearestValidPage(page)); + } + + @NotNull + public Optional getWarpList(@NotNull OnlineUser onlineUser, @NotNull Locales locales, + @NotNull List warps, final boolean permissionRestrictWarps, + final int itemsPerPage, final int page) { + if (eventDispatcher.dispatchViewWarpListEvent(warps, onlineUser).join().isCancelled()) { + return Optional.empty(); + } + final PaginatedList warpList = PaginatedList.of(warps.stream() + .filter(warp -> !permissionRestrictWarps || onlineUser.hasPermission(warp.getPermissionNode())) + .map(warp -> + locales.getRawLocale("warp_list_item", + Locales.escapeMineDown(warp.meta.name), + Locales.escapeMineDown(locales.formatDescription(warp.meta.description))) + .orElse(warp.meta.name)).sorted().collect(Collectors.toList()), getBaseList(locales, itemsPerPage) + .setHeaderFormat(locales.getRawLocale("warp_list_page_title", + "%first_item_on_page_index%", "%last_item_on_page_index%", + "%total_items%").orElse("")) + .setCommand("/huskhomes:warplist").build()); + warpLists.put(onlineUser.uuid, warpList); + return Optional.of(warpList.getNearestValidPage(page)); } @NotNull @@ -169,41 +219,4 @@ public class Cache { .getNearestValidPage(page); } - @NotNull - public MineDown getPublicHomeList(@NotNull OnlineUser onlineUser, @NotNull Locales locales, - @NotNull List publicHomes, final int itemsPerPage, final int page) { - final PaginatedList publicHomeList = PaginatedList.of(publicHomes.stream().map(home -> - locales.getRawLocale("public_home_list_item", - Locales.escapeMineDown(home.meta.name), - Locales.escapeMineDown(home.owner.username + "." + home.meta.name), - Locales.escapeMineDown(home.owner.username), - Locales.escapeMineDown(locales.formatDescription(home.meta.description))) - .orElse(home.meta.name)).sorted().collect(Collectors.toList()), getBaseList(locales, itemsPerPage) - .setHeaderFormat(locales.getRawLocale("public_home_list_page_title", - "%first_item_on_page_index%", "%last_item_on_page_index%", - "%total_items%").orElse("")) - .setCommand("/huskhomes:publichomelist").build()); - publicHomeLists.put(onlineUser.uuid, publicHomeList); - return publicHomeList.getNearestValidPage(page); - } - - @NotNull - public MineDown getWarpList(@NotNull OnlineUser onlineUser, @NotNull Locales locales, - @NotNull List warps, final boolean permissionRestrictWarps, - final int itemsPerPage, final int page) { - final PaginatedList warpList = PaginatedList.of(warps.stream() - .filter(warp -> !permissionRestrictWarps || onlineUser.hasPermission(warp.getPermissionNode())) - .map(warp -> - locales.getRawLocale("warp_list_item", - Locales.escapeMineDown(warp.meta.name), - Locales.escapeMineDown(locales.formatDescription(warp.meta.description))) - .orElse(warp.meta.name)).sorted().collect(Collectors.toList()), getBaseList(locales, itemsPerPage) - .setHeaderFormat(locales.getRawLocale("warp_list_page_title", - "%first_item_on_page_index%", "%last_item_on_page_index%", - "%total_items%").orElse("")) - .setCommand("/huskhomes:warplist").build()); - warpLists.put(onlineUser.uuid, warpList); - return warpList.getNearestValidPage(page); - } - } diff --git a/common/src/main/java/net/william278/huskhomes/command/HomeCommand.java b/common/src/main/java/net/william278/huskhomes/command/HomeCommand.java index 4cab46ba..057ad820 100644 --- a/common/src/main/java/net/william278/huskhomes/command/HomeCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/HomeCommand.java @@ -31,8 +31,9 @@ public class HomeCommand extends CommandBase implements TabCompletable, ConsoleE case 0 -> plugin.getLocales().getLocale("error_no_homes_set").ifPresent(onlineUser::sendMessage); case 1 -> plugin.getTeleportManager().timedTeleport(onlineUser, homes.get(0)).thenAccept(result -> plugin.getTeleportManager().finishTeleport(onlineUser, result)).join(); - default -> onlineUser.sendMessage(plugin.getCache().getHomeList(onlineUser, onlineUser, - plugin.getLocales(), homes, plugin.getSettings().listItemsPerPage, 1)); + default -> plugin.getCache().getHomeList(onlineUser, onlineUser, + plugin.getLocales(), homes, plugin.getSettings().listItemsPerPage, 1) + .ifPresent(onlineUser::sendMessage); } }); case 1 -> { diff --git a/common/src/main/java/net/william278/huskhomes/command/HomeListCommand.java b/common/src/main/java/net/william278/huskhomes/command/HomeListCommand.java index d0b3c9bb..565a68ec 100644 --- a/common/src/main/java/net/william278/huskhomes/command/HomeListCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/HomeListCommand.java @@ -74,8 +74,10 @@ public class HomeListCommand extends CommandBase implements ConsoleExecutable { } return; } - onlineUser.sendMessage(plugin.getCache().getHomeList(onlineUser, userData.user(), - plugin.getLocales(), homes, plugin.getSettings().listItemsPerPage, pageNumber)); + plugin.getCache().getHomeList(onlineUser, userData.user(), + plugin.getLocales(), homes, + plugin.getSettings().listItemsPerPage, pageNumber) + .ifPresent(onlineUser::sendMessage); }); }, () -> plugin.getLocales().getLocale("error_player_not_found", homeOwner).ifPresent(onlineUser::sendMessage))); @@ -97,9 +99,9 @@ public class HomeListCommand extends CommandBase implements ConsoleExecutable { StringJoiner rowJoiner = new StringJoiner(" "); plugin.getLoggingAdapter().log(Level.INFO, "List of " + userData.get().user().username + "'s " - + homes.size() + " homes:"); + + homes.size() + " homes:"); for (int i = 1; i <= homes.size(); i++) { - final String home = homes.get(i-1).meta.name; + final String home = homes.get(i - 1).meta.name; rowJoiner.add(home.length() < 16 ? home + " ".repeat(16 - home.length()) : home); if (i % 3 == 0) { plugin.getLoggingAdapter().log(Level.INFO, rowJoiner.toString()); diff --git a/common/src/main/java/net/william278/huskhomes/command/PublicHomeCommand.java b/common/src/main/java/net/william278/huskhomes/command/PublicHomeCommand.java index cf32fb82..a4da23c0 100644 --- a/common/src/main/java/net/william278/huskhomes/command/PublicHomeCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/PublicHomeCommand.java @@ -33,8 +33,9 @@ public class PublicHomeCommand extends CommandBase implements TabCompletable, Co return; } - onlineUser.sendMessage(plugin.getCache().getPublicHomeList(onlineUser, plugin.getLocales(), publicHomes, - plugin.getSettings().listItemsPerPage, 1)); + plugin.getCache().getPublicHomeList(onlineUser, plugin.getLocales(), + publicHomes, plugin.getSettings().listItemsPerPage, 1) + .ifPresent(onlineUser::sendMessage); }); case 1 -> { final String homeName = args[0]; @@ -92,7 +93,7 @@ public class PublicHomeCommand extends CommandBase implements TabCompletable, Co } plugin.getLoggingAdapter().log(Level.INFO, "Teleporting " + playerToTeleport.username + " to " - + home.owner.username + "." + home.meta.name); + + home.owner.username + "." + home.meta.name); plugin.getTeleportManager().teleport(playerToTeleport, home) .thenAccept(result -> plugin.getTeleportManager().finishTeleport(playerToTeleport, result)); }); @@ -107,7 +108,7 @@ public class PublicHomeCommand extends CommandBase implements TabCompletable, Co return args.length > 1 ? Collections.emptyList() : publicHomes .stream() .filter(publicHomeIdentifier -> publicHomeIdentifier.split(Pattern.quote("."))[1].toLowerCase() - .startsWith(args.length == 1 ? args[0].toLowerCase() : "")) + .startsWith(args.length == 1 ? args[0].toLowerCase() : "")) .sorted() .collect(Collectors.toList()); } diff --git a/common/src/main/java/net/william278/huskhomes/command/PublicHomeListCommand.java b/common/src/main/java/net/william278/huskhomes/command/PublicHomeListCommand.java index 927d7f60..7ef42c5f 100644 --- a/common/src/main/java/net/william278/huskhomes/command/PublicHomeListCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/PublicHomeListCommand.java @@ -52,8 +52,10 @@ public class PublicHomeListCommand extends CommandBase implements ConsoleExecuta plugin.getLocales().getLocale("error_no_public_homes_set").ifPresent(onlineUser::sendMessage); return; } - onlineUser.sendMessage(plugin.getCache().getPublicHomeList(onlineUser, plugin.getLocales(), publicHomes, - plugin.getSettings().listItemsPerPage, pageNumber)); + plugin.getCache().getPublicHomeList(onlineUser, + plugin.getLocales(), publicHomes, + plugin.getSettings().listItemsPerPage, pageNumber) + .ifPresent(onlineUser::sendMessage); }); } diff --git a/common/src/main/java/net/william278/huskhomes/command/WarpCommand.java b/common/src/main/java/net/william278/huskhomes/command/WarpCommand.java index 505ab148..e7894370 100644 --- a/common/src/main/java/net/william278/huskhomes/command/WarpCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/WarpCommand.java @@ -26,8 +26,10 @@ public class WarpCommand extends CommandBase implements TabCompletable, ConsoleE plugin.getLocales().getLocale("error_no_warps_set").ifPresent(onlineUser::sendMessage); return; } - onlineUser.sendMessage(plugin.getCache().getWarpList(onlineUser, plugin.getLocales(), warps, - plugin.getSettings().permissionRestrictWarps, plugin.getSettings().listItemsPerPage, 1)); + plugin.getCache().getWarpList(onlineUser, plugin.getLocales(), warps, + plugin.getSettings().permissionRestrictWarps, + plugin.getSettings().listItemsPerPage, 1) + .ifPresent(onlineUser::sendMessage); }); case 1 -> { final String warpName = args[0]; diff --git a/common/src/main/java/net/william278/huskhomes/command/WarpListCommand.java b/common/src/main/java/net/william278/huskhomes/command/WarpListCommand.java index 2e6c1eac..9a16f5e4 100644 --- a/common/src/main/java/net/william278/huskhomes/command/WarpListCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/WarpListCommand.java @@ -47,13 +47,17 @@ public class WarpListCommand extends CommandBase implements ConsoleExecutable { return; } + // Dispatch the warp list event plugin.getDatabase().getWarps().thenAccept(warps -> { if (warps.isEmpty()) { plugin.getLocales().getLocale("error_no_warps_set").ifPresent(onlineUser::sendMessage); return; } - onlineUser.sendMessage(plugin.getCache().getWarpList(onlineUser, plugin.getLocales(), warps, - plugin.getSettings().permissionRestrictWarps, plugin.getSettings().listItemsPerPage, pageNumber)); + plugin.getCache().getWarpList(onlineUser, + plugin.getLocales(), warps, + plugin.getSettings().permissionRestrictWarps, + plugin.getSettings().listItemsPerPage, + pageNumber).ifPresent(onlineUser::sendMessage); }); } diff --git a/common/src/main/java/net/william278/huskhomes/event/EventDispatcher.java b/common/src/main/java/net/william278/huskhomes/event/EventDispatcher.java index 537019ce..bb95d4a0 100644 --- a/common/src/main/java/net/william278/huskhomes/event/EventDispatcher.java +++ b/common/src/main/java/net/william278/huskhomes/event/EventDispatcher.java @@ -1,11 +1,13 @@ package net.william278.huskhomes.event; +import net.william278.huskhomes.player.OnlineUser; import net.william278.huskhomes.position.Home; import net.william278.huskhomes.position.Warp; import net.william278.huskhomes.teleport.Teleport; import net.william278.huskhomes.teleport.TimedTeleport; import org.jetbrains.annotations.NotNull; +import java.util.List; import java.util.concurrent.CompletableFuture; /** @@ -13,7 +15,7 @@ import java.util.concurrent.CompletableFuture; */ public interface EventDispatcher { - CompletableFuture dispatchTeleportEvent(@NotNull Teleport teleport); + void dispatchTeleportEvent(@NotNull Teleport teleport); CompletableFuture dispatchTeleportWarmupEvent(@NotNull TimedTeleport teleport, int duration); @@ -25,4 +27,9 @@ public interface EventDispatcher { CompletableFuture dispatchWarpDeleteEvent(@NotNull Warp warp); + CompletableFuture dispatchViewHomeListEvent(@NotNull List homes, @NotNull OnlineUser user, + boolean publicHomeList); + + CompletableFuture dispatchViewWarpListEvent(@NotNull List homes, @NotNull OnlineUser user); + } diff --git a/common/src/main/java/net/william278/huskhomes/event/IHomeListEvent.java b/common/src/main/java/net/william278/huskhomes/event/IHomeListEvent.java new file mode 100644 index 00000000..15c60e8f --- /dev/null +++ b/common/src/main/java/net/william278/huskhomes/event/IHomeListEvent.java @@ -0,0 +1,36 @@ +package net.william278.huskhomes.event; + +import net.william278.huskhomes.player.OnlineUser; +import net.william278.huskhomes.position.Home; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * Represents an event that fires when a player requests to view a list of homes + */ +public interface IHomeListEvent extends CancellableEvent { + + /** + * Get the list of homes to be displayed + * + * @return the list of homes + */ + List getHomes(); + + /** + * Get the player viewing the home list + * + * @return the player viewing the home list + */ + @NotNull + OnlineUser getOnlineUser(); + + /** + * Indicates if the player has requested to view a list of public homes + * + * @return true if the player has requested to view a list of public homes + */ + boolean getIsPublicHomeList(); + +} diff --git a/common/src/main/java/net/william278/huskhomes/event/IWarpListEvent.java b/common/src/main/java/net/william278/huskhomes/event/IWarpListEvent.java new file mode 100644 index 00000000..f317b767 --- /dev/null +++ b/common/src/main/java/net/william278/huskhomes/event/IWarpListEvent.java @@ -0,0 +1,29 @@ +package net.william278.huskhomes.event; + +import net.william278.huskhomes.player.OnlineUser; +import net.william278.huskhomes.position.Warp; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * Represents an event that fires when a player requests to view a list of warps + */ +public interface IWarpListEvent extends CancellableEvent { + + /** + * Get the list of warps to be displayed + * + * @return the list of warps + */ + List getWarps(); + + /** + * Get the player viewing the warp list + * + * @return the player viewing the warp list + */ + @NotNull + OnlineUser getOnlineUser(); + +}