mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Refactor event dispatch system
This commit is contained in:
27 files changed
+329
-404
No files matched your search
@@ -30,14 +30,18 @@ public class DelWarpCommand extends SavedPositionCommand<Warp> {
|
||||
.ifPresent(user::sendMessage);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
plugin.getManager().warps().deleteWarp(warp);
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(executor, plugin, warp.getName());
|
||||
return;
|
||||
}
|
||||
plugin.getLocales().getLocale("warp_deleted", warp.getName())
|
||||
.ifPresent(executor::sendMessage);
|
||||
|
||||
plugin.fireEvent(plugin.getWarpDeleteEvent(warp), (event) -> {
|
||||
try {
|
||||
plugin.getManager().warps().deleteWarp(warp);
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(executor, plugin, warp.getName());
|
||||
return;
|
||||
}
|
||||
plugin.getLocales().getLocale("warp_deleted", warp.getName())
|
||||
.ifPresent(executor::sendMessage);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private boolean handleDeleteAll(@NotNull CommandUser executor, @NotNull String[] args) {
|
||||
@@ -50,15 +54,17 @@ public class DelWarpCommand extends SavedPositionCommand<Warp> {
|
||||
return true;
|
||||
}
|
||||
|
||||
final int deleted = plugin.getManager().warps().deleteAllWarps();
|
||||
if (deleted == 0) {
|
||||
plugin.getLocales().getLocale("error_no_warps_set")
|
||||
.ifPresent(executor::sendMessage);
|
||||
return true;
|
||||
}
|
||||
plugin.fireEvent(plugin.getDeleteAllWarpsEvent(), (event) -> {
|
||||
final int deleted = plugin.getManager().warps().deleteAllWarps();
|
||||
if (deleted == 0) {
|
||||
plugin.getLocales().getLocale("error_no_warps_set")
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLocales().getLocale("delete_all_warps_success", Integer.toString(deleted))
|
||||
.ifPresent(executor::sendMessage);
|
||||
plugin.getLocales().getLocale("delete_all_warps_success", Integer.toString(deleted))
|
||||
.ifPresent(executor::sendMessage);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user