mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
API: New events, move around old ones, setters
This commit is contained in:
1 parent
6a62cea52c
commit
503898a0ef
44 files changed
+538
-236
No files matched your search
@@ -31,7 +31,7 @@ public class DelHomeCommand extends SavedPositionCommand<Home> {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.fireEvent(plugin.getHomeDeleteEvent(home), (event) -> {
|
||||
plugin.fireEvent(plugin.getHomeDeleteEvent(home, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().homes().deleteHome(home);
|
||||
} catch (ValidationException e) {
|
||||
@@ -53,7 +53,7 @@ public class DelHomeCommand extends SavedPositionCommand<Home> {
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.fireEvent(plugin.getDeleteAllHomesEvent(user), (event) -> {
|
||||
plugin.fireEvent(plugin.getDeleteAllHomesEvent(user, user), (event) -> {
|
||||
final int deleted = plugin.getManager().homes().deleteAllHomes(user);
|
||||
if (deleted == 0) {
|
||||
plugin.getLocales().getLocale("error_no_homes_set")
|
||||
|
||||
@@ -31,7 +31,7 @@ public class DelWarpCommand extends SavedPositionCommand<Warp> {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.fireEvent(plugin.getWarpDeleteEvent(warp), (event) -> {
|
||||
plugin.fireEvent(plugin.getWarpDeleteEvent(warp, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().warps().deleteWarp(warp);
|
||||
} catch (ValidationException e) {
|
||||
@@ -54,7 +54,7 @@ public class DelWarpCommand extends SavedPositionCommand<Warp> {
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.fireEvent(plugin.getDeleteAllWarpsEvent(), (event) -> {
|
||||
plugin.fireEvent(plugin.getDeleteAllWarpsEvent(executor), (event) -> {
|
||||
final int deleted = plugin.getManager().warps().deleteAllWarps();
|
||||
if (deleted == 0) {
|
||||
plugin.getLocales().getLocale("error_no_warps_set")
|
||||
|
||||
@@ -34,7 +34,7 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
|
||||
final Optional<String> operation = parseStringArg(args, 0);
|
||||
if (operation.isEmpty()) {
|
||||
getHomeEditorWindow(home, true, !ownerEditing,
|
||||
getHomeEditorWindow(home, !ownerEditing,
|
||||
!ownerEditing || executor.hasPermission(getOtherPermission()),
|
||||
executor.hasPermission(getPermission("privacy")))
|
||||
.forEach(executor::sendMessage);
|
||||
@@ -42,8 +42,7 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
}
|
||||
|
||||
if (!arguments.contains(operation.get().toLowerCase())) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/edithome " + home.getName() + " <" + String.join("|", arguments) + ">")
|
||||
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
@@ -57,56 +56,61 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
}
|
||||
|
||||
private void setHomeName(@NotNull CommandUser executor, @NotNull Home home, boolean ownerEditing, @NotNull String[] args) {
|
||||
final Optional<String> newName = parseStringArg(args, 1);
|
||||
if (newName.isEmpty()) {
|
||||
final String oldName = home.getName();
|
||||
final Optional<String> optionalName = parseStringArg(args, 1);
|
||||
if (optionalName.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/edithome " + home.getName() + " rename <name>")
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.fireEvent(plugin.getHomeSaveEvent(home), (event) -> {
|
||||
home.getMeta().setName(optionalName.get());
|
||||
plugin.fireEvent(plugin.getHomeEditEvent(home, executor), (event) -> {
|
||||
final String newName = event.getHome().getName();
|
||||
try {
|
||||
plugin.getManager().homes().setHomeName(home, newName.get());
|
||||
plugin.getManager().homes().setHomeName(home, newName);
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchHomeError(executor, false, plugin, newName.get());
|
||||
e.dispatchHomeError(executor, false, plugin, newName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ownerEditing) {
|
||||
plugin.getLocales().getLocale("edit_home_update_name", home.getName(), newName.get())
|
||||
plugin.getLocales().getLocale("edit_home_update_name", oldName, newName)
|
||||
.ifPresent(executor::sendMessage);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("edit_home_update_name_other", home.getOwner().getUsername(),
|
||||
home.getName(), newName.get())
|
||||
oldName, newName)
|
||||
.ifPresent(executor::sendMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setHomeDescription(@NotNull CommandUser executor, @NotNull Home home, boolean ownerEditing, @NotNull String[] args) {
|
||||
final Optional<String> newDescription = parseGreedyString(args, 1);
|
||||
if (newDescription.isEmpty()) {
|
||||
final Optional<String> optionalDescription = parseGreedyString(args, 1);
|
||||
if (optionalDescription.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/edithome " + home.getName() + " description <text>")
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.fireEvent(plugin.getHomeSaveEvent(home), (event) -> {
|
||||
home.getMeta().setDescription(optionalDescription.get());
|
||||
plugin.fireEvent(plugin.getHomeEditEvent(home, executor), (event) -> {
|
||||
final String newDescription = event.getHome().getMeta().getDescription();
|
||||
try {
|
||||
plugin.getManager().homes().setHomeDescription(home, newDescription.get());
|
||||
plugin.getManager().homes().setHomeDescription(home, newDescription);
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchHomeError(executor, false, plugin, newDescription.get());
|
||||
e.dispatchHomeError(executor, false, plugin, newDescription);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ownerEditing) {
|
||||
plugin.getLocales().getLocale("edit_home_update_description", home.getName(), newDescription.get())
|
||||
plugin.getLocales().getLocale("edit_home_update_description", home.getName(), newDescription)
|
||||
.ifPresent(executor::sendMessage);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("edit_home_update_description_other", home.getOwner().getUsername(),
|
||||
home.getName(), newDescription.get())
|
||||
home.getName(), newDescription)
|
||||
.ifPresent(executor::sendMessage);
|
||||
}
|
||||
});
|
||||
@@ -119,9 +123,10 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.fireEvent(plugin.getHomeDeleteEvent(home), (event) -> {
|
||||
home.update(user.getPosition());
|
||||
plugin.fireEvent(plugin.getHomeEditEvent(home, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().homes().setHomePosition(home, user.getPosition());
|
||||
plugin.getManager().homes().setHomePosition(home, home);
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchHomeError(executor, false, plugin, home.getName());
|
||||
return;
|
||||
@@ -157,9 +162,10 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.fireEvent(plugin.getHomeSaveEvent(home), (event) -> {
|
||||
home.setPublic(privacyArg.get().equals("public"));
|
||||
plugin.fireEvent(plugin.getHomeEditEvent(home, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().homes().setHomePrivacy(home, privacyArg.get().equals("public"));
|
||||
plugin.getManager().homes().setHomePrivacy(home, home.isPublic());
|
||||
} catch (ValidationException e) {
|
||||
int maxHomes = executor instanceof OnlineUser user ?
|
||||
user.getMaxPublicHomes(plugin.getSettings().getMaxPublicHomes(),
|
||||
@@ -174,25 +180,16 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
plugin.performEconomyTransaction(user, EconomyHook.Action.MAKE_HOME_PUBLIC);
|
||||
}
|
||||
|
||||
final String privacy = home.isPublic() ? "public" : "private";
|
||||
if (ownerEditing) {
|
||||
plugin.getLocales().getLocale("edit_home_privacy_" + privacyArg.get() + "_success",
|
||||
plugin.getLocales().getLocale("edit_home_privacy_" + privacy + "_success",
|
||||
home.getMeta().getName())
|
||||
.ifPresent(executor::sendMessage);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("edit_home_privacy_" + privacyArg.get() + "_success_other",
|
||||
plugin.getLocales().getLocale("edit_home_privacy_" + privacy + "_success_other",
|
||||
home.getOwner().getUsername(), home.getMeta().getName())
|
||||
.ifPresent(executor::sendMessage);
|
||||
}
|
||||
|
||||
// Show the menu if the menu flag is set
|
||||
parseStringArg(args, 2).ifPresent(arg -> {
|
||||
if (arg.equalsIgnoreCase("-m")) {
|
||||
getHomeEditorWindow(home, false, !ownerEditing,
|
||||
ownerEditing || executor.hasPermission(getOtherPermission()),
|
||||
executor.hasPermission(getPermission("privacy")))
|
||||
.forEach(executor::sendMessage);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -200,24 +197,21 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
* Get a formatted home editor chat window for a supplied {@link Home}
|
||||
*
|
||||
* @param home The home to display
|
||||
* @param showTitle Whether to show the menu title
|
||||
* @param otherViewer If the viewer of the editor is not the homeowner
|
||||
* @param showTeleportButton Whether to show the teleport "use" button
|
||||
* @param showPrivacyToggleButton Whether to show the home privacy toggle button
|
||||
* @return List of {@link MineDown} messages to send to the editor that form the menu
|
||||
*/
|
||||
@NotNull
|
||||
private List<MineDown> getHomeEditorWindow(@NotNull Home home, boolean showTitle, boolean otherViewer,
|
||||
private List<MineDown> getHomeEditorWindow(@NotNull Home home, boolean otherViewer,
|
||||
boolean showTeleportButton, boolean showPrivacyToggleButton) {
|
||||
return new ArrayList<>() {{
|
||||
if (showTitle) {
|
||||
if (!otherViewer) {
|
||||
plugin.getLocales().getLocale("edit_home_menu_title", home.getMeta().getName())
|
||||
.ifPresent(this::add);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("edit_home_menu_title_other", home.getOwner().getUsername(), home.getMeta().getName())
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
if (!otherViewer) {
|
||||
plugin.getLocales().getLocale("edit_home_menu_title", home.getMeta().getName())
|
||||
.ifPresent(this::add);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("edit_home_menu_title_other", home.getOwner().getUsername(), home.getMeta().getName())
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
|
||||
plugin.getLocales().getLocale("edit_home_menu_metadata_" + (!home.isPublic() ? "private" : "public"),
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import net.william278.huskhomes.util.ValidationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -26,14 +25,12 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
||||
public void execute(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull String[] args) {
|
||||
final Optional<String> operation = parseStringArg(args, 0);
|
||||
if (operation.isEmpty()) {
|
||||
getWarpEditorWindow(warp, true, executor.hasPermission(Permission.COMMAND_WARP.node))
|
||||
.forEach(executor::sendMessage);
|
||||
getWarpEditorWindow(warp).forEach(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!arguments.contains(operation.get().toLowerCase())) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/editwarp " + warp.getName() + " <" + String.join("|", arguments) + ">")
|
||||
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
@@ -46,43 +43,50 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
||||
}
|
||||
|
||||
private void setWarpName(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull String[] args) {
|
||||
final Optional<String> newName = parseStringArg(args, 1);
|
||||
if (newName.isEmpty()) {
|
||||
final String oldName = warp.getName();
|
||||
final Optional<String> optionalName = parseStringArg(args, 1);
|
||||
if (optionalName.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/editwarp " + warp.getName() + " rename <name>")
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
plugin.getManager().warps().renameWarp(warp, newName.get());
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(executor, plugin, newName.get());
|
||||
return;
|
||||
}
|
||||
warp.getMeta().setName(optionalName.get());
|
||||
plugin.fireEvent(plugin.getWarpEditEvent(warp, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().warps().renameWarp(warp, warp.getName());
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(executor, plugin, warp.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLocales().getLocale("edit_warp_update_name", warp.getName(), newName.get())
|
||||
.ifPresent(executor::sendMessage);
|
||||
plugin.getLocales().getLocale("edit_warp_update_name", oldName, optionalName.get())
|
||||
.ifPresent(executor::sendMessage);
|
||||
});
|
||||
}
|
||||
|
||||
private void setWarpDescription(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull String[] args) {
|
||||
final Optional<String> newDescription = parseGreedyString(args, 1);
|
||||
if (newDescription.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
final Optional<String> optionalDescription = parseGreedyString(args, 1);
|
||||
if (optionalDescription.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/editwarp " + warp.getName() + " description <text>")
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
plugin.getManager().warps().setWarpDescription(warp, newDescription.get());
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(executor, plugin, newDescription.get());
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLocales().getLocale("edit_warp_update_description", warp.getName(), newDescription.get())
|
||||
.ifPresent(executor::sendMessage);
|
||||
warp.getMeta().setDescription(optionalDescription.get());
|
||||
plugin.fireEvent(plugin.getWarpEditEvent(warp, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().warps().setWarpDescription(warp, warp.getMeta().getDescription());
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(executor, plugin, warp.getMeta().getDescription());
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLocales().getLocale("edit_warp_update_description", warp.getName(), warp.getMeta().getDescription())
|
||||
.ifPresent(executor::sendMessage);
|
||||
});
|
||||
}
|
||||
|
||||
private void setWarpPosition(@NotNull CommandUser executor, @NotNull Warp warp) {
|
||||
@@ -92,32 +96,31 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
plugin.getManager().warps().relocateWarp(warp, user.getPosition());
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(executor, plugin, warp.getName());
|
||||
return;
|
||||
}
|
||||
warp.update(user.getPosition());
|
||||
plugin.fireEvent(plugin.getWarpEditEvent(warp, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().warps().relocateWarp(warp, warp);
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(executor, plugin, warp.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLocales().getLocale("edit_warp_update_location", warp.getName())
|
||||
.ifPresent(executor::sendMessage);
|
||||
plugin.getLocales().getLocale("edit_warp_update_location", warp.getName())
|
||||
.ifPresent(executor::sendMessage);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a formatted warp editor chat window for a supplied {@link Warp}
|
||||
*
|
||||
* @param warp The warp to display
|
||||
* @param showTitle Whether to show the menu title
|
||||
* @param showTeleportButton Whether to show the teleport "use" button
|
||||
* @param warp The warp to display
|
||||
* @return List of {@link MineDown} messages to send to the editor that form the menu
|
||||
*/
|
||||
@NotNull
|
||||
private List<MineDown> getWarpEditorWindow(@NotNull Warp warp, boolean showTitle, boolean showTeleportButton) {
|
||||
private List<MineDown> getWarpEditorWindow(@NotNull Warp warp) {
|
||||
return new ArrayList<>() {{
|
||||
if (showTitle) {
|
||||
plugin.getLocales().getLocale("edit_warp_menu_title", warp.getMeta().getName())
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
plugin.getLocales().getLocale("edit_warp_menu_title", warp.getMeta().getName())
|
||||
.ifPresent(this::add);
|
||||
|
||||
plugin.getLocales().getLocale("edit_warp_menu_metadata",
|
||||
DateTimeFormatter.ofPattern("MMM dd yyyy, HH:mm")
|
||||
@@ -145,10 +148,8 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
||||
String.format("%.2f", warp.getYaw()), String.format("%.2f", warp.getPitch()))
|
||||
.ifPresent(this::add);
|
||||
|
||||
if (showTeleportButton) {
|
||||
plugin.getLocales().getLocale("edit_warp_menu_use_buttons", warp.getMeta().getName())
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
plugin.getLocales().getLocale("edit_warp_menu_use_buttons", warp.getMeta().getName())
|
||||
.ifPresent(this::add);
|
||||
plugin.getLocales().getLocale("edit_warp_menu_manage_buttons", warp.getMeta().getName())
|
||||
.ifPresent(this::add);
|
||||
plugin.getLocales().getLocale("edit_warp_menu_meta_edit_buttons", warp.getMeta().getName())
|
||||
|
||||
@@ -56,7 +56,7 @@ public class PrivateHomeListCommand extends ListCommand {
|
||||
|
||||
final List<Home> homes = plugin.getDatabase().getHomes(user);
|
||||
plugin.fireEvent(plugin.getViewHomeListEvent(homes, executor, false),
|
||||
(event) -> this.generateList(executor, user, homes).ifPresent(homeList -> {
|
||||
(event) -> this.generateList(executor, user, event.getHomes()).ifPresent(homeList -> {
|
||||
cachedLists.put(user.getUuid(), homeList);
|
||||
executor.sendMessage(homeList.getNearestValidPage(pageNumber));
|
||||
}));
|
||||
|
||||
@@ -33,7 +33,7 @@ public class PublicHomeListCommand extends ListCommand {
|
||||
|
||||
final List<Home> homes = plugin.getDatabase().getPublicHomes();
|
||||
plugin.fireEvent(plugin.getViewHomeListEvent(homes, executor, true),
|
||||
(event) -> this.generateList(executor, homes).ifPresent(homeList -> {
|
||||
(event) -> this.generateList(executor, event.getHomes()).ifPresent(homeList -> {
|
||||
if (executor instanceof OnlineUser onlineUser) {
|
||||
cachedLists.put(onlineUser.getUuid(), homeList);
|
||||
}
|
||||
|
||||
@@ -26,11 +26,13 @@ public class SetHomeCommand extends SetPositionCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(@NotNull OnlineUser setter, @NotNull String name) {
|
||||
try {
|
||||
plugin.getManager().homes().createHome(setter, name, setter.getPosition());
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchHomeError(setter, false, plugin, name);
|
||||
}
|
||||
plugin.fireEvent(plugin.getHomeCreateEvent(setter, name, setter.getPosition(), setter), (event) -> {
|
||||
try {
|
||||
plugin.getManager().homes().createHome(setter, event.getName(), event.getPosition());
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchHomeError(setter, false, plugin, event.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean createDefaultHome(@NotNull OnlineUser user) {
|
||||
|
||||
@@ -13,10 +13,12 @@ public class SetWarpCommand extends SetPositionCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(@NotNull OnlineUser setter, @NotNull String name) {
|
||||
try {
|
||||
plugin.getManager().warps().createWarp(name, setter.getPosition());
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(setter, plugin, name);
|
||||
}
|
||||
plugin.fireEvent(plugin.getWarpCreateEvent(name, setter.getPosition(), setter), (event) -> {
|
||||
try {
|
||||
plugin.getManager().warps().createWarp(event.getName(), event.getPosition());
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(setter, plugin, event.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class WarpListCommand extends ListCommand {
|
||||
|
||||
final List<Warp> warps = getItems(executor);
|
||||
plugin.fireEvent(plugin.getViewWarpListEvent(warps, executor),
|
||||
(event) -> this.generateList(executor, warps).ifPresent(homeList -> {
|
||||
(event) -> this.generateList(executor, event.getWarps()).ifPresent(homeList -> {
|
||||
if (executor instanceof OnlineUser onlineUser) {
|
||||
cachedLists.put(onlineUser.getUuid(), homeList);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.teleport.Teleport;
|
||||
import net.william278.huskhomes.teleport.TimedTeleport;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -47,21 +47,25 @@ public interface EventDispatcher {
|
||||
|
||||
ITeleportWarmupEvent getTeleportWarmupEvent(@NotNull TimedTeleport teleport, int duration);
|
||||
|
||||
IHomeSaveEvent getHomeSaveEvent(@NotNull Home home);
|
||||
IHomeCreateEvent getHomeCreateEvent(@NotNull User owner, @NotNull String name, @NotNull Position position, @NotNull CommandUser creator);
|
||||
|
||||
IHomeDeleteEvent getHomeDeleteEvent(@NotNull Home home);
|
||||
IHomeEditEvent getHomeEditEvent(@NotNull Home home, @NotNull CommandUser editor);
|
||||
|
||||
IWarpSaveEvent getWarpSaveEvent(@NotNull Warp warp);
|
||||
IHomeDeleteEvent getHomeDeleteEvent(@NotNull Home home, @NotNull CommandUser deleter);
|
||||
|
||||
IWarpDeleteEvent getWarpDeleteEvent(@NotNull Warp warp);
|
||||
IWarpCreateEvent getWarpCreateEvent(@NotNull String name, @NotNull Position position, @NotNull CommandUser creator);
|
||||
|
||||
IWarpEditEvent getWarpEditEvent(@NotNull Warp warp, @NotNull CommandUser editor);
|
||||
|
||||
IWarpDeleteEvent getWarpDeleteEvent(@NotNull Warp warp, @NotNull CommandUser deleter);
|
||||
|
||||
IHomeListEvent getViewHomeListEvent(@NotNull List<Home> homes, @NotNull CommandUser listViewer, boolean publicHomeList);
|
||||
|
||||
IWarpListEvent getViewWarpListEvent(@NotNull List<Warp> homes, @NotNull CommandUser listViewer);
|
||||
|
||||
IDeleteAllHomesEvent getDeleteAllHomesEvent(@NotNull User user);
|
||||
IDeleteAllHomesEvent getDeleteAllHomesEvent(@NotNull User user, @NotNull CommandUser deleter);
|
||||
|
||||
IDeleteAllWarpsEvent getDeleteAllWarpsEvent();
|
||||
IDeleteAllWarpsEvent getDeleteAllWarpsEvent(@NotNull CommandUser deleter);
|
||||
|
||||
@NotNull
|
||||
HuskHomes getPlugin();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -16,4 +17,7 @@ public interface IDeleteAllHomesEvent extends Cancellable {
|
||||
@NotNull
|
||||
User getHomeOwner();
|
||||
|
||||
@NotNull
|
||||
CommandUser getDeleter();
|
||||
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Representation of an event that fires when all warps are deleted
|
||||
*/
|
||||
public interface IDeleteAllWarpsEvent extends Cancellable {
|
||||
|
||||
@NotNull
|
||||
CommandUser getDeleter();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface IHomeCreateEvent extends Cancellable {
|
||||
|
||||
@NotNull
|
||||
User getOwner();
|
||||
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
void setName(@NotNull String name);
|
||||
|
||||
@NotNull
|
||||
Position getPosition();
|
||||
|
||||
void setPosition(@NotNull Position position);
|
||||
|
||||
@NotNull
|
||||
CommandUser getCreator();
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -16,4 +17,7 @@ public interface IHomeDeleteEvent extends Cancellable {
|
||||
@NotNull
|
||||
Home getHome();
|
||||
|
||||
@NotNull
|
||||
CommandUser getDeleter();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Representation of an event that fires when a home is edited
|
||||
*/
|
||||
public interface IHomeEditEvent extends Cancellable {
|
||||
|
||||
/**
|
||||
* Get the home about to be saved
|
||||
*
|
||||
* @return the {@link Home} being saved
|
||||
*/
|
||||
@NotNull
|
||||
Home getHome();
|
||||
|
||||
@NotNull
|
||||
CommandUser getEditor();
|
||||
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -17,8 +16,11 @@ public interface IHomeListEvent extends Cancellable {
|
||||
*
|
||||
* @return the list of homes
|
||||
*/
|
||||
@NotNull
|
||||
List<Home> getHomes();
|
||||
|
||||
void setHomes(@NotNull List<Home> homes);
|
||||
|
||||
/**
|
||||
* Get the player viewing the home list
|
||||
*
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Representation of an event that fires when a home is created or updated
|
||||
*/
|
||||
public interface IHomeSaveEvent extends Cancellable {
|
||||
|
||||
/**
|
||||
* Get the home being created or updated
|
||||
*
|
||||
* @return the {@link Home} being saved
|
||||
*/
|
||||
@NotNull
|
||||
Home getHome();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface IWarpCreateEvent extends Cancellable {
|
||||
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
void setName(@NotNull String name);
|
||||
|
||||
@NotNull
|
||||
Position getPosition();
|
||||
|
||||
void setPosition(@NotNull Position position);
|
||||
|
||||
@NotNull
|
||||
CommandUser getCreator();
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -16,4 +17,7 @@ public interface IWarpDeleteEvent extends Cancellable {
|
||||
@NotNull
|
||||
Warp getWarp();
|
||||
|
||||
@NotNull
|
||||
CommandUser getDeleter();
|
||||
|
||||
}
|
||||
+5
-1
@@ -1,12 +1,13 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Representation of an event that fires when a warp is created or updated
|
||||
*/
|
||||
public interface IWarpSaveEvent extends Cancellable {
|
||||
public interface IWarpEditEvent extends Cancellable {
|
||||
|
||||
/**
|
||||
* Get the warp being created or updated
|
||||
@@ -16,4 +17,7 @@ public interface IWarpSaveEvent extends Cancellable {
|
||||
@NotNull
|
||||
Warp getWarp();
|
||||
|
||||
@NotNull
|
||||
CommandUser getEditor();
|
||||
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package net.william278.huskhomes.event;
|
||||
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -17,8 +16,11 @@ public interface IWarpListEvent extends Cancellable {
|
||||
*
|
||||
* @return the list of warps
|
||||
*/
|
||||
@NotNull
|
||||
List<Warp> getWarps();
|
||||
|
||||
void setWarps(@NotNull List<Warp> warps);
|
||||
|
||||
/**
|
||||
* Get the user viewing the warp list
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user