mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
New lists via PagineDown, update edithome locales
This commit is contained in:
1 parent
3651e1ea90
commit
423f18b2c3
20 files changed
+170
-413
No files matched your search
@@ -270,7 +270,9 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
.ifPresent(this::add);
|
||||
|
||||
if (home.meta.description.length() > 0) {
|
||||
final String escapedDescription = MineDown.escape(home.meta.description);
|
||||
final String escapedDescription = MineDown.escape(home.meta.description
|
||||
.replaceAll(Pattern.quote("("), "\\(")
|
||||
.replaceAll(Pattern.quote(")"), "\\)"));
|
||||
plugin.getLocales().getLocale("edit_home_menu_description",
|
||||
escapedDescription.length() > 50
|
||||
? escapedDescription.substring(0, 49).trim() + "…" : escapedDescription,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.list.PrivateHomeList;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import net.william278.huskhomes.util.RegexUtil;
|
||||
@@ -21,20 +20,12 @@ public class HomeCommand extends CommandBase implements TabCompletable, ConsoleE
|
||||
switch (args.length) {
|
||||
case 0 -> plugin.getDatabase().getHomes(onlineUser).thenAccept(homes -> {
|
||||
// Send the home list if they have homes set. If they have just one home set, teleport the player
|
||||
try {
|
||||
switch (homes.size()) {
|
||||
case 0 ->
|
||||
plugin.getLocales().getLocale("error_no_homes_set").ifPresent(onlineUser::sendMessage);
|
||||
case 1 -> plugin.getTeleportManager().teleport(onlineUser, homes.get(0)).thenAccept(result ->
|
||||
plugin.getTeleportManager().finishTeleport(onlineUser, result)).join();
|
||||
default -> {
|
||||
final PrivateHomeList homeList = new PrivateHomeList(homes, onlineUser, plugin);
|
||||
plugin.getCache().positionLists.put(onlineUser.uuid, homeList);
|
||||
homeList.getDisplay(1).forEach(onlineUser::sendMessage);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
switch (homes.size()) {
|
||||
case 0 -> plugin.getLocales().getLocale("error_no_homes_set").ifPresent(onlineUser::sendMessage);
|
||||
case 1 -> plugin.getTeleportManager().teleport(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));
|
||||
}
|
||||
});
|
||||
case 1 -> {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.list.PrivateHomeList;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -41,16 +40,14 @@ public class HomeListCommand extends CommandBase implements ConsoleExecutable {
|
||||
/**
|
||||
* Show a (cached) list of a {@link OnlineUser}'s homes
|
||||
*
|
||||
* @param onlineUser the user to display the homes to
|
||||
* @param onlineUser the user to display the homes to
|
||||
* @param homeOwner the user whose homes should be displayed
|
||||
* @param pageNumber page number to display
|
||||
*/
|
||||
private void showHomeList(@NotNull OnlineUser onlineUser, @NotNull String homeOwner, int pageNumber) {
|
||||
if (plugin.getCache().positionLists.containsKey(onlineUser.uuid)) {
|
||||
if (plugin.getCache().positionLists.get(onlineUser.uuid) instanceof PrivateHomeList privateHomeList) {
|
||||
privateHomeList.getDisplay(pageNumber).forEach(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
if (plugin.getCache().privateHomeLists.containsKey(onlineUser.uuid)) {
|
||||
onlineUser.sendMessage(plugin.getCache().privateHomeLists.get(onlineUser.uuid).getNearestValidPage(pageNumber));
|
||||
return;
|
||||
}
|
||||
plugin.getDatabase().getUserDataByName(homeOwner).thenAccept(optionalUser -> optionalUser.ifPresentOrElse(userData -> {
|
||||
if (!userData.getUserUuid().equals(onlineUser.uuid)) {
|
||||
@@ -64,9 +61,8 @@ public class HomeListCommand extends CommandBase implements ConsoleExecutable {
|
||||
plugin.getLocales().getLocale("error_no_homes_set").ifPresent(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
final PrivateHomeList homeList = new PrivateHomeList(homes, userData.user(), plugin);
|
||||
plugin.getCache().positionLists.put(onlineUser.uuid, homeList);
|
||||
homeList.getDisplay(pageNumber).forEach(onlineUser::sendMessage);
|
||||
onlineUser.sendMessage(plugin.getCache().getHomeList(onlineUser, userData.user(),
|
||||
plugin.getLocales(), homes, plugin.getSettings().listItemsPerPage, pageNumber));
|
||||
});
|
||||
}, () -> plugin.getLocales().getLocale("error_invalid_player").ifPresent(onlineUser::sendMessage)));
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.list.PublicHomeList;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
@@ -29,9 +28,8 @@ public class PublicHomeCommand extends CommandBase implements TabCompletable, Co
|
||||
return;
|
||||
}
|
||||
|
||||
final PublicHomeList homeList = new PublicHomeList(publicHomes, plugin);
|
||||
plugin.getCache().positionLists.put(onlineUser.uuid, homeList);
|
||||
homeList.getDisplay(1).forEach(onlineUser::sendMessage);
|
||||
onlineUser.sendMessage(plugin.getCache().getPublicHomeList(onlineUser, plugin.getLocales(), publicHomes,
|
||||
plugin.getSettings().listItemsPerPage,1));
|
||||
});
|
||||
case 1 -> {
|
||||
final String homeName = args[0];
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.list.PublicHomeList;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -37,21 +36,18 @@ public class PublicHomeListCommand extends CommandBase implements ConsoleExecuta
|
||||
* @param pageNumber page number to display
|
||||
*/
|
||||
private void showPublicHomeList(@NotNull OnlineUser onlineUser, int pageNumber) {
|
||||
if (plugin.getCache().positionLists.containsKey(onlineUser.uuid)) {
|
||||
if (plugin.getCache().positionLists.get(onlineUser.uuid) instanceof PublicHomeList publicHomeList) {
|
||||
publicHomeList.getDisplay(pageNumber).forEach(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
if (plugin.getCache().publicHomeLists.containsKey(onlineUser.uuid)) {
|
||||
onlineUser.sendMessage(plugin.getCache().publicHomeLists.get(onlineUser.uuid).getNearestValidPage(pageNumber));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getDatabase().getPublicHomes().thenAccept(warps -> {
|
||||
if (warps.isEmpty()) {
|
||||
plugin.getDatabase().getPublicHomes().thenAccept(publicHomes -> {
|
||||
if (publicHomes.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_no_public_homes_set").ifPresent(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
final PublicHomeList warpList = new PublicHomeList(warps, plugin);
|
||||
plugin.getCache().positionLists.put(onlineUser.uuid, warpList);
|
||||
warpList.getDisplay(pageNumber).forEach(onlineUser::sendMessage);
|
||||
onlineUser.sendMessage(plugin.getCache().getPublicHomeList(onlineUser, plugin.getLocales(), publicHomes,
|
||||
plugin.getSettings().listItemsPerPage, pageNumber));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.list.WarpList;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -23,9 +22,8 @@ public class WarpCommand extends CommandBase implements TabCompletable, ConsoleE
|
||||
plugin.getLocales().getLocale("error_no_warps_set").ifPresent(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
final WarpList warpList = new WarpList(warps, plugin);
|
||||
plugin.getCache().positionLists.put(onlineUser.uuid, warpList);
|
||||
warpList.getDisplay(1).forEach(onlineUser::sendMessage);
|
||||
onlineUser.sendMessage(plugin.getCache().getWarpList(onlineUser, plugin.getLocales(), warps,
|
||||
plugin.getSettings().listItemsPerPage, 1));
|
||||
});
|
||||
case 1 -> {
|
||||
final String warpName = args[0];
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.list.WarpList;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -37,11 +36,9 @@ public class WarpListCommand extends CommandBase implements ConsoleExecutable {
|
||||
* @param pageNumber page number to display
|
||||
*/
|
||||
private void showWarpList(@NotNull OnlineUser onlineUser, int pageNumber) {
|
||||
if (plugin.getCache().positionLists.containsKey(onlineUser.uuid)) {
|
||||
if (plugin.getCache().positionLists.get(onlineUser.uuid) instanceof WarpList warpList) {
|
||||
warpList.getDisplay(pageNumber).forEach(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
if (plugin.getCache().warpLists.containsKey(onlineUser.uuid)) {
|
||||
onlineUser.sendMessage(plugin.getCache().warpLists.get(onlineUser.uuid).getNearestValidPage(pageNumber));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getDatabase().getWarps().thenAccept(warps -> {
|
||||
@@ -49,9 +46,8 @@ public class WarpListCommand extends CommandBase implements ConsoleExecutable {
|
||||
plugin.getLocales().getLocale("error_no_warps_set").ifPresent(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
final WarpList warpList = new WarpList(warps, plugin);
|
||||
plugin.getCache().positionLists.put(onlineUser.uuid, warpList);
|
||||
warpList.getDisplay(pageNumber).forEach(onlineUser::sendMessage);
|
||||
onlineUser.sendMessage(plugin.getCache().getWarpList(onlineUser, plugin.getLocales(), warps,
|
||||
plugin.getSettings().listItemsPerPage, pageNumber));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user