mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Add HomeListEvent and WarpListEvent
This commit is contained in:
1 parent
fbe82a46a0
commit
5f3958bb5b
14 files changed
+310
-70
No files matched your search
@@ -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 -> {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user