mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
v4.5: Bulk delete, regex customization, QoL & API work (#486)
* Improve validator error specificity, fix #481 * Add more sanity-checking to cluster IDs, close #482 * Add bulk/player-delete command, close #484, close #257 * Fix checkstyle formatting in tests * Add missing strings to other locale files * Use morepaperlib for runtime command registration on spigot * api: make creation methods return a future, close #473 * Add name/description restriction regex customization * docs: Update config file with new regex options * bump version number to 4.5 * fix typo, correct command confirmation logic * Make confirmation locales more clear * Fix confirmation checking logic
This commit is contained in:
1 parent
e2c9a52911
commit
6bfd69f232
38 files changed
+1161
-692
No files matched your search
@@ -65,6 +65,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import space.arim.morepaperlib.MorePaperLib;
|
||||
import space.arim.morepaperlib.commands.CommandRegistration;
|
||||
import space.arim.morepaperlib.scheduling.GracefulScheduling;
|
||||
|
||||
import java.io.File;
|
||||
@@ -177,11 +178,11 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
}
|
||||
});
|
||||
|
||||
// Register events
|
||||
initialize("events", (plugin) -> this.eventListener = new BukkitEventListener(this));
|
||||
// Register event listener
|
||||
initialize("events", (plugin) -> this.eventListener = registerListener());
|
||||
|
||||
// Register commands
|
||||
initialize("commands", (plugin) -> this.commands = registerCommands());
|
||||
initialize("commands", (plugin) -> this.commands = BukkitCommand.Type.getCommands(this));
|
||||
|
||||
// Initialize the API
|
||||
initialize("API", (plugin) -> HuskHomesAPI.register(this));
|
||||
@@ -191,9 +192,10 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
this.checkForUpdates();
|
||||
}
|
||||
|
||||
// Register the event listener
|
||||
@NotNull
|
||||
public List<Command> registerCommands() {
|
||||
return BukkitCommand.Type.getCommands(this);
|
||||
protected EventListener registerListener() {
|
||||
return new BukkitEventListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -242,15 +244,6 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
cancelTasks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the adventure Bukkit audiences.
|
||||
*
|
||||
* @return The adventure Bukkit audiences
|
||||
*/
|
||||
public BukkitAudiences getAudiences() {
|
||||
return audiences;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ConsoleUser getConsole() {
|
||||
@@ -482,11 +475,21 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BukkitAudiences getAudiences() {
|
||||
return audiences;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GracefulScheduling getScheduler() {
|
||||
return paperLib.scheduling();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CommandRegistration getCommandRegistrar() {
|
||||
return paperLib.commandRegistration();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public HuskHomes getPlugin() {
|
||||
|
||||
@@ -25,10 +25,7 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.teleport.TeleportRequest;
|
||||
import net.william278.huskhomes.user.BukkitUser;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
@@ -39,27 +36,27 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
public class BukkitCommand extends org.bukkit.command.Command {
|
||||
|
||||
private final BukkitHuskHomes plugin;
|
||||
private final Command command;
|
||||
|
||||
public BukkitCommand(@NotNull Command command, @NotNull BukkitHuskHomes plugin) {
|
||||
super(command.getName(), command.getDescription(), command.getUsage(), command.getAliases());
|
||||
this.command = command;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command,
|
||||
@NotNull String label, @NotNull String[] args) {
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
this.command.onExecuted(sender instanceof Player p ? BukkitUser.adapt(p, plugin) : plugin.getConsole(), args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command,
|
||||
@NotNull String alias, @NotNull String[] args) {
|
||||
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias,
|
||||
@NotNull String[] args) throws IllegalArgumentException {
|
||||
if (!(this.command instanceof TabProvider provider)) {
|
||||
return List.of();
|
||||
}
|
||||
@@ -69,37 +66,38 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
public void register() {
|
||||
// Register with bukkit
|
||||
final PluginCommand pluginCommand = plugin.getCommand(command.getName());
|
||||
if (pluginCommand == null) {
|
||||
throw new IllegalStateException("Command " + command.getName() + " not found in plugin.yml");
|
||||
}
|
||||
plugin.getCommandRegistrar().getServerCommandMap().register("huskhomes", this);
|
||||
|
||||
// Register permissions
|
||||
addPermission(
|
||||
BukkitCommand.addPermission(
|
||||
plugin,
|
||||
command.getPermission(),
|
||||
command.getUsage(),
|
||||
getPermissionDefault(command.isOperatorCommand())
|
||||
BukkitCommand.getPermissionDefault(command.isOperatorCommand())
|
||||
);
|
||||
final List<Permission> childNodes = command.getAdditionalPermissions()
|
||||
.entrySet().stream()
|
||||
.map((entry) -> addPermission(plugin, entry.getKey(), "", getPermissionDefault(entry.getValue())))
|
||||
.map((entry) -> BukkitCommand.addPermission(
|
||||
plugin,
|
||||
entry.getKey(),
|
||||
"",
|
||||
BukkitCommand.getPermissionDefault(entry.getValue()))
|
||||
)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
if (!childNodes.isEmpty()) {
|
||||
addPermission(plugin, command.getPermission("*"), command.getUsage(), PermissionDefault.FALSE,
|
||||
childNodes.toArray((plugin) -> new Permission[0]));
|
||||
BukkitCommand.addPermission(
|
||||
plugin,
|
||||
command.getPermission("*"),
|
||||
command.getUsage(),
|
||||
PermissionDefault.FALSE,
|
||||
childNodes.toArray(new Permission[0])
|
||||
);
|
||||
}
|
||||
|
||||
// Set command parameters
|
||||
pluginCommand.setExecutor(this);
|
||||
pluginCommand.setTabCompleter(this);
|
||||
pluginCommand.setDescription(command.getDescription());
|
||||
pluginCommand.setPermission(command.getPermission());
|
||||
|
||||
// Register commodore TAB completion
|
||||
if (CommodoreProvider.isSupported() && plugin.getSettings().doBrigadierTabCompletion()) {
|
||||
BrigadierUtil.registerCommodore(plugin, pluginCommand, command);
|
||||
BrigadierUtil.registerCommodore(plugin, this, command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,17 +176,12 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
@NotNull
|
||||
public static List<Command> getCommands(@NotNull BukkitHuskHomes plugin) {
|
||||
return Arrays.stream(values())
|
||||
.map((type) -> {
|
||||
Command command = type.createCommand(plugin);
|
||||
if (plugin.getSettings().isCommandDisabled(command)) {
|
||||
command = new DisabledCommand(command.getName(), plugin);
|
||||
}
|
||||
new BukkitCommand(command, plugin).register();
|
||||
return command;
|
||||
})
|
||||
.filter((command) -> !(command instanceof DisabledCommand))
|
||||
.map((type) -> type.createCommand(plugin))
|
||||
.filter((command) -> !plugin.getSettings().isCommandDisabled(command))
|
||||
.peek((command) -> new BukkitCommand(command, plugin).register())
|
||||
.toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import net.william278.huskhomes.util.BukkitAdapter;
|
||||
import net.william278.huskhomes.util.ValidationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -98,28 +99,29 @@ public class EssentialsXImporter extends Importer {
|
||||
|
||||
@NotNull
|
||||
private String normalizeName(@NotNull String name) {
|
||||
if (plugin.getValidator().isValidName(name)) {
|
||||
try {
|
||||
plugin.getValidator().validateName(name);
|
||||
return name;
|
||||
} catch (ValidationException e) {
|
||||
// Remove spaces
|
||||
name = name.replaceAll(" ", "_");
|
||||
|
||||
// Remove unicode characters
|
||||
if (plugin.getSettings().doRestrictNames()) {
|
||||
name = name.replaceAll("[^A-Za-z0-9_-]", "");
|
||||
}
|
||||
|
||||
// Ensure the name is not blank
|
||||
if (name.isBlank()) {
|
||||
name = "imported-" + UUID.randomUUID().toString().substring(0, 5);
|
||||
}
|
||||
|
||||
// Ensure name is not too long
|
||||
if (name.length() > 16) {
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
// Remove spaces
|
||||
name = name.replaceAll(" ", "_");
|
||||
|
||||
// Remove unicode characters
|
||||
if (!plugin.getSettings().doAllowUnicodeNames()) {
|
||||
name = name.replaceAll("[^A-Za-z0-9_-]", "");
|
||||
}
|
||||
|
||||
// Ensure the name is not blank
|
||||
if (name.isBlank()) {
|
||||
name = "imported-" + UUID.randomUUID().toString().substring(0, 5);
|
||||
}
|
||||
|
||||
// Ensure name is not too long
|
||||
if (name.length() > 16) {
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,5 +12,20 @@ huskhomes {
|
||||
name brigadier:string single_word;
|
||||
}
|
||||
}
|
||||
delete {
|
||||
player {
|
||||
name brigadier:string single_word;
|
||||
}
|
||||
homes {
|
||||
world brigadier:string single_word {
|
||||
server brigadier:string single_word;
|
||||
}
|
||||
}
|
||||
warps {
|
||||
world brigadier:string single_word {
|
||||
server brigadier:string single_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
update;
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import net.william278.huskhomes.util.BukkitAdapter;
|
||||
import net.william278.huskhomes.util.TransactionResolver;
|
||||
import net.william278.huskhomes.util.ValidationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
@@ -205,7 +206,7 @@ public class BukkitPluginTests {
|
||||
"ValidName", "Valid_Name", "Valid-Name", "ValidN4me", "ValidName123", "VN-123", "ValidName_123", "V"
|
||||
})
|
||||
public void testValidNameIsValid(@NotNull String name) {
|
||||
Assertions.assertTrue(plugin.getValidator().isValidName(name));
|
||||
Assertions.assertDoesNotThrow(() -> plugin.getValidator().validateName(name));
|
||||
}
|
||||
|
||||
@DisplayName("Test Validator Rejects Invalid Names")
|
||||
@@ -214,7 +215,10 @@ public class BukkitPluginTests {
|
||||
"Invalid Name", "•♣♠", "Invali♣Name", "Invalid.Name", "", " ", "\0", "InvalidName12345678901234567890"
|
||||
})
|
||||
public void testInvalidNameIsInvalid(@NotNull String name) {
|
||||
Assertions.assertFalse(plugin.getValidator().isValidName(name));
|
||||
Assertions.assertThrows(
|
||||
ValidationException.class,
|
||||
() -> plugin.getValidator().validateName(name)
|
||||
);
|
||||
}
|
||||
|
||||
@DisplayName("Test Validator Accepts Valid Descriptions")
|
||||
@@ -227,7 +231,7 @@ public class BukkitPluginTests {
|
||||
+ " description that is 255 characters long and should be accepted by the validator"
|
||||
})
|
||||
public void testValidDescriptionIsValid(@NotNull String description) {
|
||||
Assertions.assertTrue(plugin.getValidator().isValidDescription(description));
|
||||
Assertions.assertDoesNotThrow(() -> plugin.getValidator().validateDescription(description));
|
||||
}
|
||||
|
||||
@DisplayName("Test Validator Rejects Invalid Descriptions")
|
||||
@@ -239,417 +243,425 @@ public class BukkitPluginTests {
|
||||
+ "of 255 characters that are allowed for a description of a home or a warp."
|
||||
})
|
||||
public void testInvalidDescriptionIsInvalid(@NotNull String description) {
|
||||
Assertions.assertFalse(plugin.getValidator().isValidDescription(description));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("Cooldown Tests")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class CooldownTests {
|
||||
private static User player;
|
||||
private static final TransactionResolver.Action ACTION = TransactionResolver.Action.HOME_TELEPORT;
|
||||
private static final Duration DURATION = Duration.ofSeconds(100);
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
player = BukkitUser.adapt(server.addPlayer(), plugin);
|
||||
}
|
||||
|
||||
@DisplayName("Test Applying Cooldown")
|
||||
@Order(1)
|
||||
@Test
|
||||
public void testApplyingCooldown() {
|
||||
plugin.getDatabase().ensureUser(player);
|
||||
Assertions.assertTrue(plugin.getDatabase().getUserData(player.getUuid()).isPresent());
|
||||
|
||||
plugin.getDatabase().setCooldown(ACTION, player, Instant.now().plus(DURATION));
|
||||
Assertions.assertTrue(plugin.getDatabase().getCooldown(ACTION, player).isPresent());
|
||||
}
|
||||
|
||||
@DisplayName("Test Removing Cooldown")
|
||||
@Order(2)
|
||||
@Test
|
||||
public void testRemovingCooldown() {
|
||||
Assertions.assertTrue(plugin.getDatabase().getCooldown(ACTION, player).isPresent());
|
||||
plugin.getDatabase().removeCooldown(ACTION, player);
|
||||
Assertions.assertFalse(plugin.getDatabase().getCooldown(ACTION, player).isPresent());
|
||||
}
|
||||
|
||||
@DisplayName("Test Cooldown Expiration")
|
||||
@Order(3)
|
||||
@Test
|
||||
public void testCooldownExpiration() {
|
||||
Assertions.assertTrue(plugin.getDatabase().getCooldown(ACTION, player).isEmpty());
|
||||
plugin.getDatabase().setCooldown(ACTION, player, Instant.now().minus(DURATION));
|
||||
|
||||
final Optional<Instant> cooldown = plugin.getDatabase().getCooldown(ACTION, player);
|
||||
Assertions.assertTrue(cooldown.isPresent());
|
||||
Assertions.assertTrue(cooldown.get().isBefore(Instant.now()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Nested
|
||||
@DisplayName("Warp Tests")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class WarpTests {
|
||||
private static final List<String> WARP_NAMES = List.of(
|
||||
"warple",
|
||||
"example",
|
||||
"exmaination",
|
||||
"123234__44",
|
||||
"a",
|
||||
"1"
|
||||
);
|
||||
|
||||
@DisplayName("Test Warp Creation")
|
||||
@ParameterizedTest(name = "Warp Name: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(1)
|
||||
public void testWarpCreation(@NotNull String name, @NotNull Position position) {
|
||||
plugin.getManager().warps().createWarp(name, position);
|
||||
Assertions.assertTrue(plugin.getDatabase().getWarp(name).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().warps()
|
||||
.getWarps().stream()
|
||||
.anyMatch(warp -> warp.equals(name)));
|
||||
}
|
||||
|
||||
// test warp renaming
|
||||
@DisplayName("Test Warp Renaming")
|
||||
@ParameterizedTest(name = "Rename: \"{0}\" > \"{0}2\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(2)
|
||||
@SuppressWarnings("unused")
|
||||
public void testWarpRenaming(@NotNull String name, @NotNull Position position) {
|
||||
final String newName = (name + "2");
|
||||
plugin.getManager().warps().setWarpName(name, newName);
|
||||
Assertions.assertTrue(plugin.getDatabase().getWarp(newName).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().warps()
|
||||
.getWarps().stream()
|
||||
.anyMatch(warp -> warp.equals(newName)));
|
||||
|
||||
// Rename back to original name
|
||||
plugin.getManager().warps().setWarpName(newName, name);
|
||||
Assertions.assertTrue(plugin.getDatabase().getWarp(name).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().warps()
|
||||
.getWarps().stream()
|
||||
.anyMatch(warp -> warp.equals(name)));
|
||||
}
|
||||
|
||||
@DisplayName("Test Warp Edit Description")
|
||||
@ParameterizedTest(name = "Edit Description: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(3)
|
||||
@SuppressWarnings("unused")
|
||||
public void testWarpChangingDescription(@NotNull String name, @NotNull Position position) {
|
||||
final String description = "This is a test description for " + name + ".";
|
||||
plugin.getManager().warps().setWarpDescription(name, description);
|
||||
final Optional<String> warpDescription = plugin.getDatabase().getWarp(name)
|
||||
.map(Warp::getMeta)
|
||||
.map(PositionMeta::getDescription);
|
||||
Assertions.assertTrue(warpDescription.isPresent());
|
||||
Assertions.assertEquals(description, warpDescription.get());
|
||||
}
|
||||
|
||||
@DisplayName("Test Warp Relocate")
|
||||
@ParameterizedTest(name = "Relocate: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(4)
|
||||
public void testWarpRelocation(@NotNull String name, @NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
world, plugin.getServerName()
|
||||
Assertions.assertThrows(
|
||||
ValidationException.class,
|
||||
() -> plugin.getValidator().validateDescription(description)
|
||||
);
|
||||
plugin.getManager().warps().setWarpPosition(name, newPosition);
|
||||
|
||||
final Optional<Position> warpPosition = plugin.getDatabase().getWarp(name).map(warp -> warp);
|
||||
Assertions.assertTrue(warpPosition.isPresent());
|
||||
Assertions.assertEquals(newPosition.getX(), warpPosition.get().getX());
|
||||
Assertions.assertEquals(newPosition.getY(), warpPosition.get().getY());
|
||||
Assertions.assertEquals(newPosition.getZ(), warpPosition.get().getZ());
|
||||
}
|
||||
|
||||
@DisplayName("Test Warp Overwrite")
|
||||
@ParameterizedTest(name = "Overwrite: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(5)
|
||||
public void testWarpOverwrite(@NotNull String name, @NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
world, plugin.getServerName()
|
||||
@Nested
|
||||
@DisplayName("Cooldown Tests")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class CooldownTests {
|
||||
private static User player;
|
||||
private static final TransactionResolver.Action ACTION = TransactionResolver.Action.HOME_TELEPORT;
|
||||
private static final Duration DURATION = Duration.ofSeconds(100);
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
player = BukkitUser.adapt(server.addPlayer(), plugin);
|
||||
}
|
||||
|
||||
@DisplayName("Test Applying Cooldown")
|
||||
@Order(1)
|
||||
@Test
|
||||
public void testApplyingCooldown() {
|
||||
plugin.getDatabase().ensureUser(player);
|
||||
Assertions.assertTrue(plugin.getDatabase().getUserData(player.getUuid()).isPresent());
|
||||
|
||||
plugin.getDatabase().setCooldown(ACTION, player, Instant.now().plus(DURATION));
|
||||
Assertions.assertTrue(plugin.getDatabase().getCooldown(ACTION, player).isPresent());
|
||||
}
|
||||
|
||||
@DisplayName("Test Removing Cooldown")
|
||||
@Order(2)
|
||||
@Test
|
||||
public void testRemovingCooldown() {
|
||||
Assertions.assertTrue(plugin.getDatabase().getCooldown(ACTION, player).isPresent());
|
||||
plugin.getDatabase().removeCooldown(ACTION, player);
|
||||
Assertions.assertFalse(plugin.getDatabase().getCooldown(ACTION, player).isPresent());
|
||||
}
|
||||
|
||||
@DisplayName("Test Cooldown Expiration")
|
||||
@Order(3)
|
||||
@Test
|
||||
public void testCooldownExpiration() {
|
||||
Assertions.assertTrue(plugin.getDatabase().getCooldown(ACTION, player).isEmpty());
|
||||
plugin.getDatabase().setCooldown(ACTION, player, Instant.now().minus(DURATION));
|
||||
|
||||
final Optional<Instant> cooldown = plugin.getDatabase().getCooldown(ACTION, player);
|
||||
Assertions.assertTrue(cooldown.isPresent());
|
||||
Assertions.assertTrue(cooldown.get().isBefore(Instant.now()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Nested
|
||||
@DisplayName("Warp Tests")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class WarpTests {
|
||||
private static final List<String> WARP_NAMES = List.of(
|
||||
"warple",
|
||||
"example",
|
||||
"exmaination",
|
||||
"123234__44",
|
||||
"a",
|
||||
"1"
|
||||
);
|
||||
plugin.getManager().warps().createWarp(name, newPosition, true);
|
||||
|
||||
final Optional<Position> warpPosition = plugin.getDatabase().getWarp(name).map(warp -> warp);
|
||||
Assertions.assertTrue(warpPosition.isPresent());
|
||||
Assertions.assertEquals(newPosition.getX(), warpPosition.get().getX());
|
||||
Assertions.assertEquals(newPosition.getY(), warpPosition.get().getY());
|
||||
Assertions.assertEquals(newPosition.getZ(), warpPosition.get().getZ());
|
||||
@DisplayName("Test Warp Creation")
|
||||
@ParameterizedTest(name = "Warp Name: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(1)
|
||||
public void testWarpCreation(@NotNull String name, @NotNull Position position) {
|
||||
plugin.getManager().warps().createWarp(name, position);
|
||||
Assertions.assertTrue(plugin.getDatabase().getWarp(name).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().warps()
|
||||
.getWarps().stream()
|
||||
.anyMatch(warp -> warp.equals(name)));
|
||||
}
|
||||
|
||||
// test warp renaming
|
||||
@DisplayName("Test Warp Renaming")
|
||||
@ParameterizedTest(name = "Rename: \"{0}\" > \"{0}2\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(2)
|
||||
@SuppressWarnings("unused")
|
||||
public void testWarpRenaming(@NotNull String name, @NotNull Position position) {
|
||||
final String newName = (name + "2");
|
||||
plugin.getManager().warps().setWarpName(name, newName);
|
||||
Assertions.assertTrue(plugin.getDatabase().getWarp(newName).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().warps()
|
||||
.getWarps().stream()
|
||||
.anyMatch(warp -> warp.equals(newName)));
|
||||
|
||||
// Rename back to original name
|
||||
plugin.getManager().warps().setWarpName(newName, name);
|
||||
Assertions.assertTrue(plugin.getDatabase().getWarp(name).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().warps()
|
||||
.getWarps().stream()
|
||||
.anyMatch(warp -> warp.equals(name)));
|
||||
}
|
||||
|
||||
@DisplayName("Test Warp Edit Description")
|
||||
@ParameterizedTest(name = "Edit Description: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(3)
|
||||
@SuppressWarnings("unused")
|
||||
public void testWarpChangingDescription(@NotNull String name, @NotNull Position position) {
|
||||
final String description = "This is a test description for " + name + ".";
|
||||
plugin.getManager().warps().setWarpDescription(name, description);
|
||||
final Optional<String> warpDescription = plugin.getDatabase().getWarp(name)
|
||||
.map(Warp::getMeta)
|
||||
.map(PositionMeta::getDescription);
|
||||
Assertions.assertTrue(warpDescription.isPresent());
|
||||
Assertions.assertEquals(description, warpDescription.get());
|
||||
}
|
||||
|
||||
@DisplayName("Test Warp Relocate")
|
||||
@ParameterizedTest(name = "Relocate: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(4)
|
||||
public void testWarpRelocation(@NotNull String name, @NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
world, plugin.getServerName()
|
||||
);
|
||||
plugin.getManager().warps().setWarpPosition(name, newPosition);
|
||||
|
||||
final Optional<Position> warpPosition = plugin.getDatabase().getWarp(name).map(warp -> warp);
|
||||
Assertions.assertTrue(warpPosition.isPresent());
|
||||
Assertions.assertEquals(newPosition.getX(), warpPosition.get().getX());
|
||||
Assertions.assertEquals(newPosition.getY(), warpPosition.get().getY());
|
||||
Assertions.assertEquals(newPosition.getZ(), warpPosition.get().getZ());
|
||||
}
|
||||
|
||||
@DisplayName("Test Warp Overwrite")
|
||||
@ParameterizedTest(name = "Overwrite: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(5)
|
||||
public void testWarpOverwrite(@NotNull String name, @NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
world, plugin.getServerName()
|
||||
);
|
||||
plugin.getManager().warps().createWarp(name, newPosition, true);
|
||||
|
||||
final Optional<Position> warpPosition = plugin.getDatabase().getWarp(name).map(warp -> warp);
|
||||
Assertions.assertTrue(warpPosition.isPresent());
|
||||
Assertions.assertEquals(newPosition.getX(), warpPosition.get().getX());
|
||||
Assertions.assertEquals(newPosition.getY(), warpPosition.get().getY());
|
||||
Assertions.assertEquals(newPosition.getZ(), warpPosition.get().getZ());
|
||||
}
|
||||
|
||||
@DisplayName("Test Warp Deletion")
|
||||
@ParameterizedTest(name = "Delete Warp: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(6)
|
||||
@SuppressWarnings("unused")
|
||||
public void testWarpDeletion(@NotNull String name, @NotNull Position position) {
|
||||
plugin.getManager().warps().deleteWarp(name);
|
||||
Assertions.assertFalse(plugin.getDatabase().getWarp(name).isPresent());
|
||||
Assertions.assertFalse(plugin.getManager().warps()
|
||||
.getWarps().stream()
|
||||
.anyMatch(warp -> warp.equals(name)));
|
||||
|
||||
plugin.getManager().warps().createWarp(name, position);
|
||||
Assertions.assertTrue(plugin.getDatabase().getWarp(name).isPresent());
|
||||
}
|
||||
|
||||
@DisplayName("Test Querying Warps Case-Insensitively")
|
||||
@ParameterizedTest(name = "Query: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(8)
|
||||
@SuppressWarnings("unused")
|
||||
public void testWarpCaseInsensitiveQuery(@NotNull String name, @NotNull Position position) {
|
||||
final String nameUpper = name.toUpperCase();
|
||||
final Optional<Warp> nameUpperWarp = plugin.getDatabase().getWarp(nameUpper, true);
|
||||
Assertions.assertTrue(nameUpperWarp.isPresent());
|
||||
Assertions.assertEquals(name, nameUpperWarp.get().getName());
|
||||
|
||||
final String nameLower = name.toLowerCase();
|
||||
final Optional<Warp> nameLowerWarp = plugin.getDatabase().getWarp(nameLower, true);
|
||||
Assertions.assertTrue(nameLowerWarp.isPresent());
|
||||
Assertions.assertEquals(name, nameLowerWarp.get().getName());
|
||||
}
|
||||
|
||||
@DisplayName("Test Deleting All Warps")
|
||||
@Order(9)
|
||||
@Test
|
||||
public void testWarpDeleteAll() {
|
||||
final int deleted = plugin.getManager().warps().deleteAllWarps();
|
||||
Assertions.assertTrue(plugin.getManager().warps().getWarps().isEmpty());
|
||||
Assertions.assertTrue(plugin.getDatabase().getWarps().isEmpty());
|
||||
Assertions.assertEquals(WARP_NAMES.size(), deleted);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Stream<Arguments> provideWarpData() {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position position = Position.at(0, 0, 0, 0, 0, world, plugin.getServerName());
|
||||
return WARP_NAMES.stream()
|
||||
.flatMap(name -> Stream.of(Arguments.of(name, position)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@DisplayName("Test Warp Deletion")
|
||||
@ParameterizedTest(name = "Delete Warp: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(6)
|
||||
@SuppressWarnings("unused")
|
||||
public void testWarpDeletion(@NotNull String name, @NotNull Position position) {
|
||||
plugin.getManager().warps().deleteWarp(name);
|
||||
Assertions.assertFalse(plugin.getDatabase().getWarp(name).isPresent());
|
||||
Assertions.assertFalse(plugin.getManager().warps()
|
||||
.getWarps().stream()
|
||||
.anyMatch(warp -> warp.equals(name)));
|
||||
@Nested
|
||||
@DisplayName("Home Tests")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class HomeTests {
|
||||
private static final List<String> HOME_NAMES = List.of(
|
||||
"mr_home",
|
||||
"homble",
|
||||
"seaside",
|
||||
"hovel",
|
||||
"tokyo-3",
|
||||
"testington",
|
||||
"h"
|
||||
);
|
||||
private static BukkitUser homeOwner;
|
||||
|
||||
@DisplayName("Ensure User Data")
|
||||
@BeforeAll
|
||||
public static void createHomeUser() {
|
||||
homeOwner = BukkitUser.adapt(server.addPlayer("TestUser278"), plugin);
|
||||
plugin.getDatabase().ensureUser(homeOwner);
|
||||
Assertions.assertTrue(plugin.getDatabase().getUserData(homeOwner.getUuid()).isPresent());
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Creation")
|
||||
@ParameterizedTest(name = "Home Name: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(1)
|
||||
public void testHomeCreation(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
plugin.getManager().homes().createHome(owner, name, position);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.get(owner.getUsername()).stream()
|
||||
.anyMatch(home -> home.equals(name)));
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Renaming")
|
||||
@ParameterizedTest(name = "Rename: \"{1}\" > \"{1}2\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(2)
|
||||
@SuppressWarnings("unused")
|
||||
public void testHomeRenaming(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
final String newName = "new_" + name;
|
||||
plugin.getManager().homes().setHomeName(owner, name, newName);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, newName).isPresent());
|
||||
Assertions.assertFalse(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.get(owner.getUsername()).stream()
|
||||
.anyMatch(home -> home.equals(newName)));
|
||||
Assertions.assertFalse(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.get(owner.getUsername()).stream()
|
||||
.anyMatch(home -> home.equals(name)));
|
||||
|
||||
// Rename back to original name
|
||||
plugin.getManager().homes().setHomeName(owner, newName, name);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.get(owner.getUsername()).stream()
|
||||
.anyMatch(home -> home.equals(name)));
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Description")
|
||||
@ParameterizedTest(name = "Edit Description: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(3)
|
||||
@SuppressWarnings("unused")
|
||||
public void testHomeDescription(@NotNull OnlineUser owner, @NotNull String name,
|
||||
@NotNull Position position) {
|
||||
final String description = "This is a test description for the home " + name + "!";
|
||||
plugin.getManager().homes().setHomeDescription(owner, name, description);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
|
||||
final Optional<String> homeDescription = plugin.getDatabase().getHome(owner, name)
|
||||
.map(Home::getMeta)
|
||||
.map(PositionMeta::getDescription);
|
||||
Assertions.assertTrue(homeDescription.isPresent());
|
||||
Assertions.assertEquals(description, homeDescription.get());
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Relocation")
|
||||
@ParameterizedTest(name = "Relocate: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(4)
|
||||
public void testHomeRelocation(@NotNull OnlineUser owner, @NotNull String name,
|
||||
@NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
world, plugin.getServerName()
|
||||
);
|
||||
plugin.getManager().homes().setHomePosition(owner, name, newPosition);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
|
||||
final Optional<Position> homePosition = plugin.getDatabase().getHome(owner, name).map(home -> home);
|
||||
Assertions.assertTrue(homePosition.isPresent());
|
||||
Assertions.assertEquals(newPosition.getX(), homePosition.get().getX());
|
||||
Assertions.assertEquals(newPosition.getY(), homePosition.get().getY());
|
||||
Assertions.assertEquals(newPosition.getZ(), homePosition.get().getZ());
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Overwrite")
|
||||
@ParameterizedTest(name = "Overwrite: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(5)
|
||||
public void testHomeOverwrite(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
world, plugin.getServerName()
|
||||
);
|
||||
plugin.getManager().homes().setHomePosition(owner, name, newPosition);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
|
||||
final Optional<Position> homePosition = plugin.getDatabase().getHome(owner, name).map(home -> home);
|
||||
Assertions.assertTrue(homePosition.isPresent());
|
||||
Assertions.assertEquals(newPosition.getX(), homePosition.get().getX());
|
||||
Assertions.assertEquals(newPosition.getY(), homePosition.get().getY());
|
||||
Assertions.assertEquals(newPosition.getZ(), homePosition.get().getZ());
|
||||
}
|
||||
|
||||
@DisplayName("Test Making Home Public")
|
||||
@ParameterizedTest(name = "Make Public: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(6)
|
||||
@SuppressWarnings("unused")
|
||||
public void testHomeMakePublic(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position p) {
|
||||
plugin.getManager().homes().setHomePrivacy(owner, name, true);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
|
||||
final Optional<Boolean> homePrivacy = plugin.getDatabase().getHome(owner, name).map(Home::isPublic);
|
||||
Assertions.assertTrue(homePrivacy.isPresent());
|
||||
Assertions.assertTrue(homePrivacy.get());
|
||||
Assertions.assertTrue(plugin.getManager().homes().getPublicHomes()
|
||||
.get(owner.getUsername()).contains(name));
|
||||
}
|
||||
|
||||
@DisplayName("Test Making Home Private")
|
||||
@ParameterizedTest(name = "Make Private: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(7)
|
||||
@SuppressWarnings("unused")
|
||||
public void testHomeMakePrivate(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position p) {
|
||||
plugin.getManager().homes().setHomePrivacy(owner, name, false);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
|
||||
final Optional<Boolean> homePrivacy = plugin.getDatabase().getHome(owner, name).map(Home::isPublic);
|
||||
Assertions.assertTrue(homePrivacy.isPresent());
|
||||
Assertions.assertFalse(homePrivacy.get());
|
||||
Assertions.assertFalse(plugin.getManager().homes().getPublicHomes()
|
||||
.getOrDefault(owner.getUsername(), List.of())
|
||||
.contains(name));
|
||||
}
|
||||
|
||||
@DisplayName("Test Querying Homes Case-Insensitively")
|
||||
@ParameterizedTest(name = "Query: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(8)
|
||||
@SuppressWarnings("unused")
|
||||
public void testWarpCaseInsensitiveQuery(@NotNull OnlineUser owner, @NotNull String name,
|
||||
@NotNull Position p) {
|
||||
final String nameUpper = name.toUpperCase();
|
||||
final Optional<Home> nameUpperWarp = plugin.getDatabase().getHome(owner, nameUpper, true);
|
||||
Assertions.assertTrue(nameUpperWarp.isPresent());
|
||||
Assertions.assertEquals(name, nameUpperWarp.get().getName());
|
||||
|
||||
final String nameLower = name.toLowerCase();
|
||||
final Optional<Home> nameLowerWarp = plugin.getDatabase().getHome(owner, nameLower, true);
|
||||
Assertions.assertTrue(nameLowerWarp.isPresent());
|
||||
Assertions.assertEquals(name, nameLowerWarp.get().getName());
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Deletion")
|
||||
@ParameterizedTest(name = "Delete: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(9)
|
||||
public void testHomeDeletion(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
plugin.getManager().homes().deleteHome(owner, name);
|
||||
Assertions.assertFalse(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
Assertions.assertFalse(plugin.getManager().homes().getUserHomes()
|
||||
.getOrDefault(owner.getUsername(), List.of())
|
||||
.contains(name));
|
||||
|
||||
plugin.getManager().homes().createHome(owner, name, position);
|
||||
}
|
||||
|
||||
@DisplayName("Test Deleting All Homes")
|
||||
@Order(10)
|
||||
@Test
|
||||
public void testDeleteAllHomes() {
|
||||
final int deleted = plugin.getManager().homes().deleteAllHomes(homeOwner);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHomes(homeOwner).isEmpty());
|
||||
Assertions.assertTrue(plugin.getManager().homes().getUserHomes()
|
||||
.get(homeOwner.getUsername()).isEmpty());
|
||||
Assertions.assertEquals(HOME_NAMES.size(), deleted);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Stream<Arguments> provideHomeData() {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position position = Position.at(0, 0, 0, 0, 0, world, plugin.getServerName());
|
||||
return HOME_NAMES.stream()
|
||||
.flatMap(name -> Stream.of(Arguments.of(homeOwner, name, position)));
|
||||
}
|
||||
|
||||
plugin.getManager().warps().createWarp(name, position);
|
||||
Assertions.assertTrue(plugin.getDatabase().getWarp(name).isPresent());
|
||||
}
|
||||
|
||||
@DisplayName("Test Querying Warps Case-Insensitively")
|
||||
@ParameterizedTest(name = "Query: \"{0}\"")
|
||||
@MethodSource("provideWarpData")
|
||||
@Order(8)
|
||||
@SuppressWarnings("unused")
|
||||
public void testWarpCaseInsensitiveQuery(@NotNull String name, @NotNull Position position) {
|
||||
final String nameUpper = name.toUpperCase();
|
||||
final Optional<Warp> nameUpperWarp = plugin.getDatabase().getWarp(nameUpper, true);
|
||||
Assertions.assertTrue(nameUpperWarp.isPresent());
|
||||
Assertions.assertEquals(name, nameUpperWarp.get().getName());
|
||||
|
||||
final String nameLower = name.toLowerCase();
|
||||
final Optional<Warp> nameLowerWarp = plugin.getDatabase().getWarp(nameLower, true);
|
||||
Assertions.assertTrue(nameLowerWarp.isPresent());
|
||||
Assertions.assertEquals(name, nameLowerWarp.get().getName());
|
||||
}
|
||||
|
||||
@DisplayName("Test Deleting All Warps")
|
||||
@Order(9)
|
||||
@Test
|
||||
public void testWarpDeleteAll() {
|
||||
final int deleted = plugin.getManager().warps().deleteAllWarps();
|
||||
Assertions.assertTrue(plugin.getManager().warps().getWarps().isEmpty());
|
||||
Assertions.assertTrue(plugin.getDatabase().getWarps().isEmpty());
|
||||
Assertions.assertEquals(WARP_NAMES.size(), deleted);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Stream<Arguments> provideWarpData() {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position position = Position.at(0, 0, 0, 0, 0, world, plugin.getServerName());
|
||||
return WARP_NAMES.stream()
|
||||
.flatMap(name -> Stream.of(Arguments.of(name, position)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("Home Tests")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class HomeTests {
|
||||
private static final List<String> HOME_NAMES = List.of(
|
||||
"mr_home",
|
||||
"homble",
|
||||
"seaside",
|
||||
"hovel",
|
||||
"tokyo-3",
|
||||
"testington",
|
||||
"h"
|
||||
);
|
||||
private static BukkitUser homeOwner;
|
||||
|
||||
@DisplayName("Ensure User Data")
|
||||
@BeforeAll
|
||||
public static void createHomeUser() {
|
||||
homeOwner = BukkitUser.adapt(server.addPlayer("TestUser278"), plugin);
|
||||
plugin.getDatabase().ensureUser(homeOwner);
|
||||
Assertions.assertTrue(plugin.getDatabase().getUserData(homeOwner.getUuid()).isPresent());
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Creation")
|
||||
@ParameterizedTest(name = "Home Name: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(1)
|
||||
public void testHomeCreation(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
plugin.getManager().homes().createHome(owner, name, position);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.get(owner.getUsername()).stream()
|
||||
.anyMatch(home -> home.equals(name)));
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Renaming")
|
||||
@ParameterizedTest(name = "Rename: \"{1}\" > \"{1}2\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(2)
|
||||
@SuppressWarnings("unused")
|
||||
public void testHomeRenaming(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
final String newName = "new_" + name;
|
||||
plugin.getManager().homes().setHomeName(owner, name, newName);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, newName).isPresent());
|
||||
Assertions.assertFalse(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.get(owner.getUsername()).stream()
|
||||
.anyMatch(home -> home.equals(newName)));
|
||||
Assertions.assertFalse(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.get(owner.getUsername()).stream()
|
||||
.anyMatch(home -> home.equals(name)));
|
||||
|
||||
// Rename back to original name
|
||||
plugin.getManager().homes().setHomeName(owner, newName, name);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
Assertions.assertTrue(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.get(owner.getUsername()).stream()
|
||||
.anyMatch(home -> home.equals(name)));
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Description")
|
||||
@ParameterizedTest(name = "Edit Description: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(3)
|
||||
@SuppressWarnings("unused")
|
||||
public void testHomeDescription(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
final String description = "This is a test description for the home " + name + "!";
|
||||
plugin.getManager().homes().setHomeDescription(owner, name, description);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
|
||||
final Optional<String> homeDescription = plugin.getDatabase().getHome(owner, name)
|
||||
.map(Home::getMeta)
|
||||
.map(PositionMeta::getDescription);
|
||||
Assertions.assertTrue(homeDescription.isPresent());
|
||||
Assertions.assertEquals(description, homeDescription.get());
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Relocation")
|
||||
@ParameterizedTest(name = "Relocate: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(4)
|
||||
public void testHomeRelocation(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
world, plugin.getServerName()
|
||||
);
|
||||
plugin.getManager().homes().setHomePosition(owner, name, newPosition);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
|
||||
final Optional<Position> homePosition = plugin.getDatabase().getHome(owner, name).map(home -> home);
|
||||
Assertions.assertTrue(homePosition.isPresent());
|
||||
Assertions.assertEquals(newPosition.getX(), homePosition.get().getX());
|
||||
Assertions.assertEquals(newPosition.getY(), homePosition.get().getY());
|
||||
Assertions.assertEquals(newPosition.getZ(), homePosition.get().getZ());
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Overwrite")
|
||||
@ParameterizedTest(name = "Overwrite: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(5)
|
||||
public void testHomeOverwrite(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position newPosition = Position.at(
|
||||
position.getX() + 10, position.getY() + 10, position.getZ() + 10,
|
||||
0, 0,
|
||||
world, plugin.getServerName()
|
||||
);
|
||||
plugin.getManager().homes().setHomePosition(owner, name, newPosition);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
|
||||
final Optional<Position> homePosition = plugin.getDatabase().getHome(owner, name).map(home -> home);
|
||||
Assertions.assertTrue(homePosition.isPresent());
|
||||
Assertions.assertEquals(newPosition.getX(), homePosition.get().getX());
|
||||
Assertions.assertEquals(newPosition.getY(), homePosition.get().getY());
|
||||
Assertions.assertEquals(newPosition.getZ(), homePosition.get().getZ());
|
||||
}
|
||||
|
||||
@DisplayName("Test Making Home Public")
|
||||
@ParameterizedTest(name = "Make Public: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(6)
|
||||
@SuppressWarnings("unused")
|
||||
public void testHomeMakePublic(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position p) {
|
||||
plugin.getManager().homes().setHomePrivacy(owner, name, true);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
|
||||
final Optional<Boolean> homePrivacy = plugin.getDatabase().getHome(owner, name).map(Home::isPublic);
|
||||
Assertions.assertTrue(homePrivacy.isPresent());
|
||||
Assertions.assertTrue(homePrivacy.get());
|
||||
Assertions.assertTrue(plugin.getManager().homes().getPublicHomes().get(owner.getUsername()).contains(name));
|
||||
}
|
||||
|
||||
@DisplayName("Test Making Home Private")
|
||||
@ParameterizedTest(name = "Make Private: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(7)
|
||||
@SuppressWarnings("unused")
|
||||
public void testHomeMakePrivate(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position p) {
|
||||
plugin.getManager().homes().setHomePrivacy(owner, name, false);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
|
||||
final Optional<Boolean> homePrivacy = plugin.getDatabase().getHome(owner, name).map(Home::isPublic);
|
||||
Assertions.assertTrue(homePrivacy.isPresent());
|
||||
Assertions.assertFalse(homePrivacy.get());
|
||||
Assertions.assertFalse(plugin.getManager().homes().getPublicHomes()
|
||||
.getOrDefault(owner.getUsername(), List.of())
|
||||
.contains(name));
|
||||
}
|
||||
|
||||
@DisplayName("Test Querying Homes Case-Insensitively")
|
||||
@ParameterizedTest(name = "Query: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(8)
|
||||
@SuppressWarnings("unused")
|
||||
public void testWarpCaseInsensitiveQuery(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position p) {
|
||||
final String nameUpper = name.toUpperCase();
|
||||
final Optional<Home> nameUpperWarp = plugin.getDatabase().getHome(owner, nameUpper, true);
|
||||
Assertions.assertTrue(nameUpperWarp.isPresent());
|
||||
Assertions.assertEquals(name, nameUpperWarp.get().getName());
|
||||
|
||||
final String nameLower = name.toLowerCase();
|
||||
final Optional<Home> nameLowerWarp = plugin.getDatabase().getHome(owner, nameLower, true);
|
||||
Assertions.assertTrue(nameLowerWarp.isPresent());
|
||||
Assertions.assertEquals(name, nameLowerWarp.get().getName());
|
||||
}
|
||||
|
||||
@DisplayName("Test Home Deletion")
|
||||
@ParameterizedTest(name = "Delete: \"{1}\"")
|
||||
@MethodSource("provideHomeData")
|
||||
@Order(9)
|
||||
public void testHomeDeletion(@NotNull OnlineUser owner, @NotNull String name, @NotNull Position position) {
|
||||
plugin.getManager().homes().deleteHome(owner, name);
|
||||
Assertions.assertFalse(plugin.getDatabase().getHome(owner, name).isPresent());
|
||||
Assertions.assertFalse(plugin.getManager().homes().getUserHomes()
|
||||
.getOrDefault(owner.getUsername(), List.of())
|
||||
.contains(name));
|
||||
|
||||
plugin.getManager().homes().createHome(owner, name, position);
|
||||
}
|
||||
|
||||
@DisplayName("Test Deleting All Homes")
|
||||
@Order(10)
|
||||
@Test
|
||||
public void testDeleteAllHomes() {
|
||||
final int deleted = plugin.getManager().homes().deleteAllHomes(homeOwner);
|
||||
Assertions.assertTrue(plugin.getDatabase().getHomes(homeOwner).isEmpty());
|
||||
Assertions.assertTrue(plugin.getManager().homes().getUserHomes().get(homeOwner.getUsername()).isEmpty());
|
||||
Assertions.assertEquals(HOME_NAMES.size(), deleted);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Stream<Arguments> provideHomeData() {
|
||||
final World world = BukkitAdapter.adaptWorld(server.getWorld("world")).orElseThrow();
|
||||
final Position position = Position.at(0, 0, 0, 0, 0, world, plugin.getServerName());
|
||||
return HOME_NAMES.stream()
|
||||
.flatMap(name -> Stream.of(Arguments.of(homeOwner, name, position)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,10 +321,11 @@ public abstract class BaseHuskHomesAPI {
|
||||
* @param owner The {@link User} to create the home for
|
||||
* @param name The name of the home
|
||||
* @param position The {@link Position} of the home
|
||||
* @since 4.0
|
||||
* @return a {@link CompletableFuture} that will complete with the created {@link Home}
|
||||
* @since 4.5
|
||||
*/
|
||||
public void createHome(@NotNull User owner, @NotNull String name, @NotNull Position position) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().createHome(owner, name, position, false, false));
|
||||
public CompletableFuture<Home> createHome(@NotNull User owner, @NotNull String name, @NotNull Position position) {
|
||||
return plugin.supplyAsync(() -> plugin.getManager().homes().createHome(owner, name, position, false, false));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,10 +528,11 @@ public abstract class BaseHuskHomesAPI {
|
||||
*
|
||||
* @param name The name of the warp
|
||||
* @param position The {@link Position} of the warp
|
||||
* @since 4.0
|
||||
* @return A {@link CompletableFuture} that will complete with the created {@link Warp}
|
||||
* @since 4.5
|
||||
*/
|
||||
public final void createWarp(@NotNull String name, @NotNull Position position) {
|
||||
plugin.runAsync(() -> plugin.getManager().warps().createWarp(name, position));
|
||||
public final CompletableFuture<Warp> createWarp(@NotNull String name, @NotNull Position position) {
|
||||
return plugin.supplyAsync(() -> plugin.getManager().warps().createWarp(name, position));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,13 +28,13 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Locales;
|
||||
import net.william278.huskhomes.importer.Importer;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import net.william278.huskhomes.user.SavedUser;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import net.william278.paginedown.PaginatedList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@@ -45,6 +45,7 @@ public class HuskHomesCommand extends Command implements TabProvider {
|
||||
"help", false,
|
||||
"reload", true,
|
||||
"import", true,
|
||||
"delete", true,
|
||||
"update", true
|
||||
);
|
||||
|
||||
@@ -111,15 +112,6 @@ public class HuskHomesCommand extends Command implements TabProvider {
|
||||
+ " you need to restart your server for these changes to take effect.](gray)"
|
||||
));
|
||||
}
|
||||
case "update" -> updateChecker.check().thenAccept(checked -> {
|
||||
if (checked.isUpToDate()) {
|
||||
plugin.getLocales().getLocale("up_to_date", plugin.getVersion().toString())
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
plugin.getLocales().getLocale("update_available", checked.getLatestVersion().toString(),
|
||||
plugin.getVersion().toString()).ifPresent(executor::sendMessage);
|
||||
});
|
||||
case "import" -> {
|
||||
if (!importersLoaded) {
|
||||
importersLoaded = true;
|
||||
@@ -132,12 +124,38 @@ public class HuskHomesCommand extends Command implements TabProvider {
|
||||
}
|
||||
this.importData(executor, removeFirstArg(args));
|
||||
}
|
||||
case "delete" -> {
|
||||
if (args.length < 2) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
final String[] deletionArgs = removeFirstArg(args);
|
||||
switch (deletionArgs[0].toLowerCase(Locale.ENGLISH)) {
|
||||
case "player" -> this.deletePlayerData(executor, removeFirstArg(deletionArgs));
|
||||
case "homes" -> this.deleteHomes(executor, removeFirstArg(deletionArgs));
|
||||
case "warps" -> this.deleteWarps(executor, removeFirstArg(deletionArgs));
|
||||
default -> plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/" + getName() + " delete <player|homes|warps> [args]")
|
||||
.ifPresent(executor::sendMessage);
|
||||
}
|
||||
}
|
||||
case "update" -> updateChecker.check().thenAccept(checked -> {
|
||||
if (checked.isUpToDate()) {
|
||||
plugin.getLocales().getLocale("up_to_date", plugin.getVersion().toString())
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
plugin.getLocales().getLocale("update_available", checked.getLatestVersion().toString(),
|
||||
plugin.getVersion().toString()).ifPresent(executor::sendMessage);
|
||||
});
|
||||
default -> plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
|
||||
.ifPresent(executor::sendMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void importData(@NotNull CommandUser executor, String[] args) {
|
||||
// Import data from another plugin
|
||||
private void importData(@NotNull CommandUser executor, @NotNull String[] args) {
|
||||
switch (parseStringArg(args, 0).orElse("list")) {
|
||||
case "start" -> parseStringArg(args, 1).ifPresentOrElse(
|
||||
name -> {
|
||||
@@ -162,6 +180,109 @@ public class HuskHomesCommand extends Command implements TabProvider {
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the data of a player
|
||||
private void deletePlayerData(@NotNull CommandUser executor, @NotNull String[] args) {
|
||||
final Optional<String> nameOrUuid = parseStringArg(args, 0);
|
||||
if (nameOrUuid.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/" + getName() + " delete player <player> [confirm]")
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.runAsync(() -> {
|
||||
Optional<SavedUser> savedUser;
|
||||
try {
|
||||
savedUser = plugin.getDatabase().getUserData(UUID.fromString(nameOrUuid.get()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
savedUser = plugin.getDatabase().getUserDataByName(nameOrUuid.get());
|
||||
}
|
||||
|
||||
if (savedUser.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_player_not_found", nameOrUuid.get())
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = savedUser.get().getUser();
|
||||
if (!parseStringArg(args, 1)
|
||||
.map(a -> a.equalsIgnoreCase("confirm")).orElse(false)) {
|
||||
plugin.getLocales().getLocale("delete_player_confirm",
|
||||
savedUser.get().getUser().getUsername()).ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
final int homesDeleted = plugin.getManager().homes().deleteAllHomes(user);
|
||||
plugin.getDatabase().deleteUserData(user.getUuid());
|
||||
plugin.getLocales().getLocale("delete_player_success",
|
||||
savedUser.get().getUser().getUsername(), Integer.toString(homesDeleted))
|
||||
.ifPresent(executor::sendMessage);
|
||||
});
|
||||
}
|
||||
|
||||
// Delete homes in a certain world and/or server
|
||||
private void deleteHomes(@NotNull CommandUser executor, @NotNull String[] args) {
|
||||
final Map<String, String> filters;
|
||||
try {
|
||||
filters = getBulkDeleteFilters(args);
|
||||
} catch (IllegalArgumentException e) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/" + getName() + " delete homes <world> <server> [confirm]")
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parseStringArg(args, 2).map(a -> a.equalsIgnoreCase("confirm")).orElse(false)) {
|
||||
plugin.getLocales().getLocale("bulk_delete_homes_confirm",
|
||||
filters.get("world"), filters.get("server")).ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
plugin.runAsync(() -> {
|
||||
final int homesDeleted = plugin.getManager().homes().deleteAllHomes(
|
||||
filters.get("world"), filters.get("server")
|
||||
);
|
||||
plugin.getLocales().getLocale("bulk_delete_homes_success",
|
||||
Integer.toString(homesDeleted), filters.get("world"), filters.get("server"))
|
||||
.ifPresent(executor::sendMessage);
|
||||
});
|
||||
}
|
||||
|
||||
// Delete warps in a certain world and/or server
|
||||
private void deleteWarps(@NotNull CommandUser executor, @NotNull String[] args) {
|
||||
final Map<String, String> filters;
|
||||
try {
|
||||
filters = getBulkDeleteFilters(args);
|
||||
} catch (IllegalArgumentException e) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/" + getName() + " delete warps <world> <server> [confirm]")
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parseStringArg(args, 2).map(a -> a.equalsIgnoreCase("confirm")).orElse(false)) {
|
||||
plugin.getLocales().getLocale("bulk_delete_warps_confirm",
|
||||
filters.get("world"), filters.get("server")).ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
plugin.runAsync(() -> {
|
||||
final int homesDeleted = plugin.getManager().warps().deleteAllWarps(
|
||||
filters.get("world"), filters.get("server")
|
||||
);
|
||||
plugin.getLocales().getLocale("bulk_delete_warps_success",
|
||||
Integer.toString(homesDeleted), filters.get("world"), filters.get("server"))
|
||||
.ifPresent(executor::sendMessage);
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<String, String> getBulkDeleteFilters(@NotNull String[] args) throws IllegalArgumentException {
|
||||
final Map<String, String> filters = new LinkedHashMap<>();
|
||||
filters.put("world", parseStringArg(args, 0)
|
||||
.orElseThrow(() -> new IllegalArgumentException("World not specified")));
|
||||
filters.put("server", parseStringArg(args, 1).orElse(plugin.getServerName()));
|
||||
return filters;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PaginatedList getCommandList(@NotNull CommandUser user) {
|
||||
return PaginatedList.of(plugin.getCommands().stream()
|
||||
@@ -205,6 +326,7 @@ public class HuskHomesCommand extends Command implements TabProvider {
|
||||
case "help" -> IntStream.rangeClosed(1, getCommandList(user).getTotalPages())
|
||||
.mapToObj(Integer::toString).toList();
|
||||
case "import" -> List.of("start", "list");
|
||||
case "delete" -> List.of("player", "homes", "warps");
|
||||
default -> null;
|
||||
};
|
||||
case 3 -> {
|
||||
|
||||
@@ -142,18 +142,31 @@ public class Settings {
|
||||
@YamlKey("general.strict_tpa_here_requests")
|
||||
private boolean strictTpaHereRequests = true;
|
||||
|
||||
|
||||
// Name & description settings
|
||||
@YamlComment("Whether home or warp names should be case insensitive (i.e. allow /home HomeOne and /home homeone)")
|
||||
@YamlKey("general.case_insensitive_names")
|
||||
private boolean caseInsensitiveNames = false;
|
||||
|
||||
@YamlComment("Whether home or warp names should allow UTF-8 characters (i.e. allow /home 你好)")
|
||||
@YamlKey("general.allow_unicode_names")
|
||||
private boolean allowUnicodeNames = false;
|
||||
@YamlComment("Whether home and warp names should be restricted by a regex."
|
||||
+ "Set this to false to allow full UTF-8 names (i.e. allow /home 你好).")
|
||||
@YamlKey("towns.restrict_names")
|
||||
private boolean restrictNames = true;
|
||||
|
||||
@YamlComment("Whether home or warp descriptions should allow UTF-8 characters")
|
||||
@YamlKey("general.allow_unicode_descriptions")
|
||||
private boolean allowUnicodeDescriptions = true;
|
||||
@YamlComment("Regex which home and warp names must match. Names have a max length of 16 characters")
|
||||
@YamlKey("towns.name_regex")
|
||||
private String nameRegex = "[a-zA-Z0-9-_]*";
|
||||
|
||||
@YamlComment("Whether home/warp descriptions should be restricted. Set this to true to restrict UTF-8 usage.")
|
||||
@YamlKey("towns.restrict_descriptions")
|
||||
private boolean restrictDescriptions = false;
|
||||
|
||||
@YamlComment("Regex which home and warp descriptions must match. A hard max length of 256 characters is enforced")
|
||||
@YamlKey("towns.description_regex")
|
||||
private String descriptionRegex = "\\A\\p{ASCII}*\\z";
|
||||
|
||||
|
||||
// Back command settings
|
||||
@YamlComment("Whether /back should work to teleport the user to where they died")
|
||||
@YamlKey("general.back_command_return_by_death")
|
||||
private boolean backCommandReturnByDeath = true;
|
||||
@@ -408,12 +421,22 @@ public class Settings {
|
||||
return caseInsensitiveNames;
|
||||
}
|
||||
|
||||
public boolean doAllowUnicodeNames() {
|
||||
return allowUnicodeNames;
|
||||
public boolean doRestrictNames() {
|
||||
return restrictNames;
|
||||
}
|
||||
|
||||
public boolean doAllowUnicodeDescriptions() {
|
||||
return allowUnicodeDescriptions;
|
||||
@NotNull
|
||||
public String getNameRegex() {
|
||||
return nameRegex;
|
||||
}
|
||||
|
||||
public boolean doRestrictDescriptions() {
|
||||
return restrictDescriptions;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getDescriptionRegex() {
|
||||
return descriptionRegex;
|
||||
}
|
||||
|
||||
public boolean doBackCommandReturnByDeath() {
|
||||
|
||||
@@ -172,6 +172,13 @@ public abstract class Database {
|
||||
*/
|
||||
public abstract Optional<SavedUser> getUserData(@NotNull UUID uuid);
|
||||
|
||||
/**
|
||||
* Delete a {@link SavedUser} from the database.
|
||||
*
|
||||
* @param uuid The {@link UUID} of the {@link SavedUser} to delete
|
||||
*/
|
||||
public abstract void deleteUserData(@NotNull UUID uuid);
|
||||
|
||||
/**
|
||||
* Get the currently active cooldown of a {@link User} for a specific {@link TransactionResolver.Action}.
|
||||
*
|
||||
@@ -414,6 +421,15 @@ public abstract class Database {
|
||||
*/
|
||||
public abstract int deleteAllHomes(@NotNull User user);
|
||||
|
||||
/**
|
||||
* Deletes all {@link Home}s on a specific world and server (given by name) from the home table on the database.
|
||||
*
|
||||
* @param worldName The name of the world to delete homes from
|
||||
* @param serverName The name of the server to delete homes from
|
||||
* @return An integer; the number of deleted homes
|
||||
*/
|
||||
public abstract int deleteAllHomes(@NotNull String worldName, @NotNull String serverName);
|
||||
|
||||
/**
|
||||
* Deletes a {@link Warp} by the given unique id from the warp table on the database.
|
||||
*
|
||||
@@ -428,6 +444,15 @@ public abstract class Database {
|
||||
*/
|
||||
public abstract int deleteAllWarps();
|
||||
|
||||
/**
|
||||
* Deletes all {@link Warp}s on a specific world and server (given by name) from the warp table on the database.
|
||||
*
|
||||
* @param worldName The name of the world to delete warps from
|
||||
* @param serverName The name of the server to delete warps from
|
||||
* @return An integer; the number of deleted warps
|
||||
*/
|
||||
public abstract int deleteAllWarps(@NotNull String worldName, @NotNull String serverName);
|
||||
|
||||
/**
|
||||
* Close any remaining connection to the database source.
|
||||
*/
|
||||
|
||||
@@ -291,6 +291,21 @@ public class H2Database extends Database {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserData(@NotNull UUID uuid) {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%players_table%`
|
||||
WHERE `uuid`=?;"""))) {
|
||||
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete a player from the database", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Instant> getCooldown(@NotNull TransactionResolver.Action action, @NotNull User user) {
|
||||
try (Connection connection = getConnection()) {
|
||||
@@ -1042,6 +1057,33 @@ public class H2Database extends Database {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAllHomes(@NotNull String worldName, @NotNull String serverName) {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `%positions_table%`.`id` IN (
|
||||
SELECT `position_id`
|
||||
FROM `%saved_positions_table%`
|
||||
WHERE `%saved_positions_table%`.`id` IN (
|
||||
SELECT `saved_position_id`
|
||||
FROM `%homes_table%`
|
||||
WHERE `world_name`=?
|
||||
AND `server_name`=?
|
||||
)
|
||||
);"""))) {
|
||||
statement.setString(1, worldName);
|
||||
statement.setString(2, serverName);
|
||||
|
||||
return statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete homes in the world " + worldName + " on the server "
|
||||
+ serverName + " from the database", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarp(@NotNull UUID uuid) {
|
||||
try (Connection connection = getConnection()) {
|
||||
@@ -1086,6 +1128,33 @@ public class H2Database extends Database {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAllWarps(@NotNull String worldName, @NotNull String serverName) {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `%positions_table%`.`id` IN (
|
||||
SELECT `position_id`
|
||||
FROM `%saved_positions_table%`
|
||||
WHERE `%saved_positions_table%`.`id` IN (
|
||||
SELECT `saved_position_id`
|
||||
FROM `%warps_table%`
|
||||
WHERE `world_name`=?
|
||||
AND `server_name`=?
|
||||
)
|
||||
);"""))) {
|
||||
statement.setString(1, worldName);
|
||||
statement.setString(2, serverName);
|
||||
|
||||
return statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete warps in the world " + worldName + " on the server "
|
||||
+ serverName + " from the database", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terminate() {
|
||||
if (connectionPool != null) {
|
||||
|
||||
@@ -329,6 +329,21 @@ public class MySqlDatabase extends Database {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserData(@NotNull UUID uuid) {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%players_table%`
|
||||
WHERE `uuid`=?;"""))) {
|
||||
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete a player from the database", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Instant> getCooldown(@NotNull TransactionResolver.Action action, @NotNull User user) {
|
||||
try (Connection connection = getConnection()) {
|
||||
@@ -1080,6 +1095,33 @@ public class MySqlDatabase extends Database {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAllHomes(@NotNull String worldName, @NotNull String serverName) {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `%positions_table%`.`id` IN (
|
||||
SELECT `position_id`
|
||||
FROM `%saved_positions_table%`
|
||||
WHERE `%saved_positions_table%`.`id` IN (
|
||||
SELECT `saved_position_id`
|
||||
FROM `%homes_table%`
|
||||
WHERE `world_name`=?
|
||||
AND `server_name`=?
|
||||
)
|
||||
);"""))) {
|
||||
statement.setString(1, worldName);
|
||||
statement.setString(2, serverName);
|
||||
|
||||
return statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete homes in the world " + worldName + " on the server "
|
||||
+ serverName + " from the database", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarp(@NotNull UUID uuid) {
|
||||
try (Connection connection = getConnection()) {
|
||||
@@ -1124,6 +1166,33 @@ public class MySqlDatabase extends Database {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAllWarps(@NotNull String worldName, @NotNull String serverName) {
|
||||
try (Connection connection = getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `%positions_table%`.`id` IN (
|
||||
SELECT `position_id`
|
||||
FROM `%saved_positions_table%`
|
||||
WHERE `%saved_positions_table%`.`id` IN (
|
||||
SELECT `saved_position_id`
|
||||
FROM `%warps_table%`
|
||||
WHERE `world_name`=?
|
||||
AND `server_name`=?
|
||||
)
|
||||
);"""))) {
|
||||
statement.setString(1, worldName);
|
||||
statement.setString(2, serverName);
|
||||
|
||||
return statement.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete warps in the world " + worldName + " on the server "
|
||||
+ serverName + " from the database", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terminate() {
|
||||
if (dataSource != null) {
|
||||
|
||||
@@ -321,6 +321,18 @@ public class SqLiteDatabase extends Database {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserData(@NotNull UUID uuid) {
|
||||
try (PreparedStatement statement = getConnection().prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%players_table%`
|
||||
WHERE `uuid`=?;"""))) {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete a player from the database", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Instant> getCooldown(@NotNull TransactionResolver.Action action, @NotNull User user) {
|
||||
try (PreparedStatement statement = getConnection().prepareStatement(formatStatementTables("""
|
||||
@@ -1026,6 +1038,30 @@ public class SqLiteDatabase extends Database {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAllHomes(@NotNull String worldName, @NotNull String serverName) {
|
||||
try (PreparedStatement statement = getConnection().prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `%positions_table%`.`id` IN (
|
||||
SELECT `position_id`
|
||||
FROM `%saved_positions_table%`
|
||||
WHERE `%saved_positions_table%`.`id` IN (
|
||||
SELECT `saved_position_id`
|
||||
FROM `%homes_table%`
|
||||
WHERE `world_name`=?
|
||||
AND `server_name`=?
|
||||
)
|
||||
);"""))) {
|
||||
statement.setString(1, worldName);
|
||||
statement.setString(2, serverName);
|
||||
return statement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete homes in the world " + worldName + " on the server "
|
||||
+ serverName + " from the database", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarp(@NotNull UUID uuid) {
|
||||
try (PreparedStatement statement = getConnection().prepareStatement(formatStatementTables("""
|
||||
@@ -1065,6 +1101,30 @@ public class SqLiteDatabase extends Database {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAllWarps(@NotNull String worldName, @NotNull String serverName) {
|
||||
try (PreparedStatement statement = getConnection().prepareStatement(formatStatementTables("""
|
||||
DELETE FROM `%positions_table%`
|
||||
WHERE `%positions_table%`.`id` IN (
|
||||
SELECT `position_id`
|
||||
FROM `%saved_positions_table%`
|
||||
WHERE `%saved_positions_table%`.`id` IN (
|
||||
SELECT `saved_position_id`
|
||||
FROM `%warps_table%`
|
||||
WHERE `world_name`=?
|
||||
AND `server_name`=?
|
||||
)
|
||||
);"""))) {
|
||||
statement.setString(1, worldName);
|
||||
statement.setString(2, serverName);
|
||||
return statement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to delete warps in the world " + worldName + " on the server "
|
||||
+ serverName + " from the database", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terminate() {
|
||||
try {
|
||||
|
||||
@@ -113,6 +113,13 @@ public class BlueMapHook extends MapHook {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearHomes(@NotNull String worldName) {
|
||||
if (publicHomesMarkerSets != null) {
|
||||
publicHomesMarkerSets.get(worldName).getMarkers().clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWarp(@NotNull Warp warp) {
|
||||
if (!isValidPosition(warp)) {
|
||||
@@ -143,6 +150,13 @@ public class BlueMapHook extends MapHook {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearWarps(@NotNull String worldName) {
|
||||
if (warpsMarkerSets != null) {
|
||||
warpsMarkerSets.get(worldName).getMarkers().clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getIcon(@NotNull String iconName) {
|
||||
return BlueMapAPI.getInstance().map(api -> {
|
||||
|
||||
@@ -112,6 +112,13 @@ public class DynmapHook extends MapHook {
|
||||
.forEach(Marker::deleteMarker)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearHomes(@NotNull String worldName) {
|
||||
plugin.runSync(() -> getPublicHomesMarkerSet().ifPresent(markerSet -> markerSet.getMarkers().stream()
|
||||
.filter(marker -> marker.getWorld().equals(worldName))
|
||||
.forEach(Marker::deleteMarker)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWarp(@NotNull Warp warp) {
|
||||
if (!isValidPosition(warp)) {
|
||||
@@ -150,6 +157,13 @@ public class DynmapHook extends MapHook {
|
||||
.forEach(Marker::deleteMarker)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearWarps(@NotNull String worldName) {
|
||||
plugin.runSync(() -> getWarpsMarkerSet().ifPresent(markerSet -> markerSet.getMarkers().stream()
|
||||
.filter(marker -> marker.getWorld().equals(worldName))
|
||||
.forEach(Marker::deleteMarker)));
|
||||
}
|
||||
|
||||
private Optional<DynmapCommonAPI> getDynmap() {
|
||||
return Optional.ofNullable(dynmapApi);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,13 @@ public abstract class MapHook extends Hook {
|
||||
*/
|
||||
public abstract void clearHomes(@NotNull User user);
|
||||
|
||||
/**
|
||||
* Clears homes on a world from the map.
|
||||
*
|
||||
* @param worldName the world to clear homes from
|
||||
*/
|
||||
public abstract void clearHomes(@NotNull String worldName);
|
||||
|
||||
/**
|
||||
* Update a warp, adding it to the map if it exists, or updating it on the map if it doesn't.
|
||||
*
|
||||
@@ -99,6 +106,13 @@ public abstract class MapHook extends Hook {
|
||||
*/
|
||||
public abstract void clearWarps();
|
||||
|
||||
/**
|
||||
* Clears all warps from a world from the map.
|
||||
*
|
||||
* @param worldName the world to clear warps from
|
||||
*/
|
||||
public abstract void clearWarps(@NotNull String worldName);
|
||||
|
||||
/**
|
||||
* Returns if the position is valid to be set on this server.
|
||||
*
|
||||
|
||||
@@ -85,6 +85,11 @@ public class Pl3xMapHook extends MapHook implements EventListener {
|
||||
publicHomes.removeIf(home -> home.getOwner().equals(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearHomes(@NotNull String worldName) {
|
||||
publicHomes.removeIf(home -> home.getWorld().getName().equals(worldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWarp(@NotNull Warp warp) {
|
||||
warps.remove(warp);
|
||||
@@ -103,6 +108,11 @@ public class Pl3xMapHook extends MapHook implements EventListener {
|
||||
warps.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearWarps(@NotNull String worldName) {
|
||||
warps.removeIf(warp -> warp.getWorld().getName().equals(worldName));
|
||||
}
|
||||
|
||||
private void registerIcon(@NotNull String key, @NotNull String iconFileName) {
|
||||
try (InputStream iconStream = plugin.getResource(iconFileName)) {
|
||||
if (iconStream == null) {
|
||||
|
||||
@@ -181,16 +181,16 @@ public class HomesManager {
|
||||
userHomes.remove(user.getUuid().toString());
|
||||
}
|
||||
|
||||
|
||||
public void createHome(@NotNull User owner, @NotNull String name, @NotNull Position position,
|
||||
@NotNull
|
||||
public Home createHome(@NotNull User owner, @NotNull String name, @NotNull Position position,
|
||||
boolean overwrite, boolean buyAdditionalSlots) throws ValidationException {
|
||||
final Optional<Home> existingHome = plugin.getDatabase().getHome(owner, name);
|
||||
if (existingHome.isPresent() && !overwrite) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_TAKEN);
|
||||
}
|
||||
if (!plugin.getValidator().isValidName(name)) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_INVALID);
|
||||
}
|
||||
|
||||
// Validate the home name; throw an exception if invalid
|
||||
plugin.getValidator().validateName(name);
|
||||
|
||||
// Determine what the new home count would be & validate against user max homes
|
||||
int homes = plugin.getDatabase().getHomes(owner).size() + (existingHome.isPresent() ? 0 : 1);
|
||||
@@ -224,11 +224,12 @@ public class HomesManager {
|
||||
.orElse(Home.from(position, PositionMeta.create(name, ""), owner));
|
||||
plugin.getDatabase().saveHome(home);
|
||||
this.cacheHome(home, true);
|
||||
return home;
|
||||
}
|
||||
|
||||
public void createHome(@NotNull OnlineUser owner, @NotNull String name,
|
||||
@NotNull Position position) throws ValidationException {
|
||||
createHome(owner, name, position, plugin.getSettings().doOverwriteExistingHomesWarps(), true);
|
||||
this.createHome(owner, name, position, plugin.getSettings().doOverwriteExistingHomesWarps(), true);
|
||||
}
|
||||
|
||||
public void deleteHome(@NotNull User owner, @NotNull String name) throws ValidationException {
|
||||
@@ -257,6 +258,19 @@ public class HomesManager {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public int deleteAllHomes(@NotNull String worldName, @NotNull String serverName) {
|
||||
final int deleted = plugin.getDatabase().deleteAllHomes(worldName, serverName);
|
||||
userHomes.values().forEach(homes -> homes.removeIf(
|
||||
h -> h.getWorld().getName().equals(worldName) && h.getServer().equals(serverName)
|
||||
));
|
||||
publicHomes.removeIf(h -> h.getWorld().getName().equals(worldName) && h.getServer().equals(serverName));
|
||||
if (plugin.getSettings().doCrossServer() && serverName.equals(plugin.getServerName())) {
|
||||
plugin.getMapHook().ifPresent(hook -> hook.clearHomes(worldName));
|
||||
}
|
||||
plugin.getManager().propagateCacheUpdate();
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setHomePosition(@NotNull User owner, @NotNull String name,
|
||||
@NotNull Position position) throws ValidationException {
|
||||
final Optional<Home> optionalHome = plugin.getDatabase().getHome(owner, name);
|
||||
@@ -284,10 +298,7 @@ public class HomesManager {
|
||||
}
|
||||
|
||||
public void setHomeName(@NotNull Home home, @NotNull String newName) throws ValidationException {
|
||||
if (!plugin.getValidator().isValidName(newName)) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_INVALID);
|
||||
}
|
||||
|
||||
plugin.getValidator().validateName(newName);
|
||||
home.getMeta().setName(newName);
|
||||
plugin.getDatabase().saveHome(home);
|
||||
this.cacheHome(home, true);
|
||||
@@ -304,10 +315,7 @@ public class HomesManager {
|
||||
}
|
||||
|
||||
public void setHomeDescription(@NotNull Home home, @NotNull String description) {
|
||||
if (!plugin.getValidator().isValidDescription(description)) {
|
||||
throw new ValidationException(ValidationException.Type.DESCRIPTION_INVALID);
|
||||
}
|
||||
|
||||
plugin.getValidator().validateDescription(description);
|
||||
home.getMeta().setDescription(description);
|
||||
plugin.getDatabase().saveHome(home);
|
||||
this.cacheHome(home, true);
|
||||
|
||||
@@ -112,16 +112,16 @@ public class WarpsManager {
|
||||
.toList();
|
||||
}
|
||||
|
||||
public void createWarp(@NotNull String name, @NotNull Position position,
|
||||
@NotNull
|
||||
public Warp createWarp(@NotNull String name, @NotNull Position position,
|
||||
boolean overwrite) throws ValidationException {
|
||||
final Optional<Warp> existingWarp = plugin.getDatabase().getWarp(name);
|
||||
if (existingWarp.isPresent() && !overwrite) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_TAKEN);
|
||||
}
|
||||
|
||||
if (!plugin.getValidator().isValidName(name)) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_INVALID);
|
||||
}
|
||||
// Validate the home name; throw an exception if invalid
|
||||
plugin.getValidator().validateName(name);
|
||||
|
||||
final Warp warp = existingWarp
|
||||
.map(existing -> {
|
||||
@@ -132,10 +132,12 @@ public class WarpsManager {
|
||||
.orElse(Warp.from(position, PositionMeta.create(name, "")));
|
||||
plugin.getDatabase().saveWarp(warp);
|
||||
this.cacheWarp(warp, true);
|
||||
return warp;
|
||||
}
|
||||
|
||||
public void createWarp(@NotNull String name, @NotNull Position position) throws ValidationException {
|
||||
this.createWarp(name, position, plugin.getSettings().doOverwriteExistingHomesWarps());
|
||||
@NotNull
|
||||
public Warp createWarp(@NotNull String name, @NotNull Position position) throws ValidationException {
|
||||
return this.createWarp(name, position, plugin.getSettings().doOverwriteExistingHomesWarps());
|
||||
}
|
||||
|
||||
public void deleteWarp(@NotNull String name) throws ValidationException {
|
||||
@@ -160,6 +162,16 @@ public class WarpsManager {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public int deleteAllWarps(@NotNull String worldName, @NotNull String serverName) {
|
||||
final int deleted = plugin.getDatabase().deleteAllWarps(worldName, serverName);
|
||||
warps.removeIf(warp -> warp.getServer().equals(serverName) && warp.getWorld().getName().equals(worldName));
|
||||
if (plugin.getSettings().doCrossServer() && plugin.getServerName().equals(serverName)) {
|
||||
plugin.getMapHook().ifPresent(hook -> hook.clearWarps(worldName));
|
||||
}
|
||||
plugin.getManager().propagateCacheUpdate();
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setWarpPosition(@NotNull String name, @NotNull Position position) throws ValidationException {
|
||||
final Optional<Warp> optionalWarp = plugin.getDatabase().getWarp(name);
|
||||
if (optionalWarp.isEmpty()) {
|
||||
@@ -185,10 +197,7 @@ public class WarpsManager {
|
||||
}
|
||||
|
||||
public void setWarpName(@NotNull Warp warp, @NotNull String newName) throws ValidationException {
|
||||
if (!plugin.getValidator().isValidName(newName)) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_INVALID);
|
||||
}
|
||||
|
||||
plugin.getValidator().validateName(newName);
|
||||
warp.getMeta().setName(newName);
|
||||
plugin.getDatabase().saveWarp(warp);
|
||||
this.cacheWarp(warp, true);
|
||||
@@ -204,10 +213,7 @@ public class WarpsManager {
|
||||
}
|
||||
|
||||
public void setWarpDescription(@NotNull Warp warp, @NotNull String description) {
|
||||
if (!plugin.getValidator().isValidDescription(description)) {
|
||||
throw new ValidationException(ValidationException.Type.DESCRIPTION_INVALID);
|
||||
}
|
||||
|
||||
plugin.getValidator().validateDescription(description);
|
||||
warp.getMeta().setDescription(description);
|
||||
plugin.getDatabase().saveWarp(warp);
|
||||
this.cacheWarp(warp, true);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package net.william278.huskhomes.network;
|
||||
|
||||
import net.kyori.adventure.key.InvalidKeyException;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
@@ -27,8 +28,10 @@ import net.william278.huskhomes.teleport.TeleportationException;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public abstract class Broker {
|
||||
|
||||
@@ -149,12 +152,19 @@ public abstract class Broker {
|
||||
*/
|
||||
public abstract void close();
|
||||
|
||||
// Get the formatted channel ID for the broker
|
||||
@NotNull
|
||||
protected String getSubChannelId() {
|
||||
final String version = plugin.getVersion().getMajor() + "." + plugin.getVersion().getMinor();
|
||||
return plugin.getKey(plugin.getSettings().getClusterId(), version).asString();
|
||||
final String version = String.format("%s.%s", plugin.getVersion().getMajor(), plugin.getVersion().getMinor());
|
||||
try {
|
||||
return plugin.getKey(plugin.getSettings().getClusterId().toLowerCase(Locale.ENGLISH), version).asString();
|
||||
} catch (InvalidKeyException e) {
|
||||
plugin.log(Level.SEVERE, "Cluster ID specified in config contains invalid characters");
|
||||
}
|
||||
return plugin.getKey("main", version).asString();
|
||||
}
|
||||
|
||||
// Get the name of this server
|
||||
@NotNull
|
||||
protected String getServer() {
|
||||
return plugin.getServerName();
|
||||
|
||||
@@ -42,12 +42,18 @@ public class ValidationException extends IllegalArgumentException {
|
||||
case NAME_TAKEN -> plugin.getLocales()
|
||||
.getLocale("error_home_name_taken")
|
||||
.ifPresent(viewer::sendMessage);
|
||||
case NAME_INVALID -> plugin.getLocales()
|
||||
case NAME_INVALID_CHARACTERS -> plugin.getLocales()
|
||||
.getLocale("error_home_name_characters", args)
|
||||
.ifPresent(viewer::sendMessage);
|
||||
case DESCRIPTION_INVALID -> plugin.getLocales()
|
||||
case NAME_INVALID_LENGTH -> plugin.getLocales()
|
||||
.getLocale("error_home_name_length", args)
|
||||
.ifPresent(viewer::sendMessage);
|
||||
case DESCRIPTION_INVALID_CHARACTERS -> plugin.getLocales()
|
||||
.getLocale("error_home_description_characters", args)
|
||||
.ifPresent(viewer::sendMessage);
|
||||
case DESCRIPTION_INVALID_LENGTH -> plugin.getLocales()
|
||||
.getLocale("error_home_description_length", args)
|
||||
.ifPresent(viewer::sendMessage);
|
||||
case NOT_ENOUGH_HOME_SLOTS, REACHED_MAX_HOMES -> plugin.getLocales()
|
||||
.getLocale("error_set_home_maximum_homes",
|
||||
Integer.toString(plugin.getManager().homes()
|
||||
@@ -72,12 +78,18 @@ public class ValidationException extends IllegalArgumentException {
|
||||
case NAME_TAKEN -> plugin.getLocales()
|
||||
.getLocale("error_warp_name_taken", args)
|
||||
.ifPresent(viewer::sendMessage);
|
||||
case NAME_INVALID -> plugin.getLocales()
|
||||
case NAME_INVALID_CHARACTERS -> plugin.getLocales()
|
||||
.getLocale("error_warp_name_characters", args)
|
||||
.ifPresent(viewer::sendMessage);
|
||||
case DESCRIPTION_INVALID -> plugin.getLocales()
|
||||
case NAME_INVALID_LENGTH -> plugin.getLocales()
|
||||
.getLocale("error_warp_name_length", args)
|
||||
.ifPresent(viewer::sendMessage);
|
||||
case DESCRIPTION_INVALID_CHARACTERS -> plugin.getLocales()
|
||||
.getLocale("error_warp_description_characters", args)
|
||||
.ifPresent(viewer::sendMessage);
|
||||
case DESCRIPTION_INVALID_LENGTH -> plugin.getLocales()
|
||||
.getLocale("error_warp_description_length", args)
|
||||
.ifPresent(viewer::sendMessage);
|
||||
default -> {
|
||||
// Do nothing (silently handle validation errors)
|
||||
}
|
||||
@@ -96,12 +108,14 @@ public class ValidationException extends IllegalArgumentException {
|
||||
public enum Type {
|
||||
NOT_FOUND,
|
||||
NAME_TAKEN,
|
||||
NAME_INVALID,
|
||||
NAME_INVALID_CHARACTERS,
|
||||
NAME_INVALID_LENGTH,
|
||||
REACHED_MAX_HOMES,
|
||||
NOT_ENOUGH_HOME_SLOTS,
|
||||
REACHED_MAX_PUBLIC_HOMES,
|
||||
TRANSACTION_FAILED,
|
||||
DESCRIPTION_INVALID
|
||||
DESCRIPTION_INVALID_CHARACTERS,
|
||||
DESCRIPTION_INVALID_LENGTH,
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public class Validator {
|
||||
|
||||
public static final int MAX_NAME_LENGTH = 16;
|
||||
@@ -37,35 +36,62 @@ public class Validator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a name is valid.
|
||||
* Validate home and warp names.
|
||||
*
|
||||
* @param name The name to check
|
||||
* @return True if the name is valid as per the plugin settings, false otherwise
|
||||
* @param name The name to validate
|
||||
* @throws ValidationException If the name is invalid
|
||||
*/
|
||||
public boolean isValidName(@NotNull String name) {
|
||||
return (isAsciiOnly(name) || plugin.getSettings().doAllowUnicodeNames())
|
||||
&& !containsWhitespace(name) && !name.contains(Home.IDENTIFIER_DELIMITER)
|
||||
&& name.length() <= MAX_NAME_LENGTH && name.length() >= MIN_NAME_LENGTH;
|
||||
public void validateName(@NotNull String name) throws ValidationException {
|
||||
if (!isValidNameCharacters(name)) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_INVALID_CHARACTERS);
|
||||
}
|
||||
if (!isValidNameLength(name)) {
|
||||
throw new ValidationException(ValidationException.Type.NAME_INVALID_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate home and warp descriptions.
|
||||
*
|
||||
* @param description The meta to validate
|
||||
* @return Whether the meta is valid against the plugin settings
|
||||
* @param description The description to validate
|
||||
* @throws ValidationException If the description is invalid
|
||||
*/
|
||||
public boolean isValidDescription(@NotNull String description) {
|
||||
return (isAsciiOnly(description) || plugin.getSettings().doAllowUnicodeDescriptions())
|
||||
&& description.length() <= MAX_DESCRIPTION_LENGTH;
|
||||
public void validateDescription(@NotNull String description) throws ValidationException {
|
||||
if (!isValidDescriptionCharacters(description)) {
|
||||
throw new ValidationException(ValidationException.Type.DESCRIPTION_INVALID_CHARACTERS);
|
||||
}
|
||||
if (!isValidDescriptionLength(description)) {
|
||||
throw new ValidationException(ValidationException.Type.DESCRIPTION_INVALID_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if a string contains only ASCII characters
|
||||
private static boolean isAsciiOnly(@NotNull String string) {
|
||||
return string.matches("\\A\\p{ASCII}*\\z") && !string.contains("\u0000");
|
||||
// Check a home/warp name contains only valid characters
|
||||
private boolean isValidNameCharacters(@NotNull String name) {
|
||||
return (name.matches(plugin.getSettings().getNameRegex()) || !plugin.getSettings().doRestrictNames())
|
||||
&& !name.contains("\u0000")
|
||||
&& !containsWhitespace(name)
|
||||
&& !name.contains(Home.IDENTIFIER_DELIMITER);
|
||||
}
|
||||
|
||||
// Check a home/warp name is of a valid length
|
||||
private boolean isValidNameLength(@NotNull String name) {
|
||||
return name.length() <= MAX_NAME_LENGTH && name.length() >= MIN_NAME_LENGTH;
|
||||
}
|
||||
|
||||
// Check a home/warp description contains only valid characters
|
||||
private boolean isValidDescriptionCharacters(@NotNull String description) {
|
||||
return (description.matches(plugin.getSettings().getDescriptionRegex())
|
||||
|| !plugin.getSettings().doRestrictDescriptions())
|
||||
&& !description.contains("\u0000");
|
||||
}
|
||||
|
||||
// Check a home/warp description is of a valid length
|
||||
private boolean isValidDescriptionLength(@NotNull String description) {
|
||||
return description.length() <= MAX_DESCRIPTION_LENGTH;
|
||||
}
|
||||
|
||||
// Check if a string contains whitespace
|
||||
private static boolean containsWhitespace(@NotNull String string) {
|
||||
private boolean containsWhitespace(@NotNull String string) {
|
||||
return string.matches(".*\\s.*");
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| You are running the latest version of
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| A new version of HuskHomes is available: v%1% (running: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| Available Data Importers:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&Click to import data through this importer. suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&This importer supports importing:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[Error:](#ff3300) [No importers are currently available. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_invalid_importer: '[Error:](#ff3300) [Invalid importer. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_home_name_taken: '[Error:](#ff3300) [You already have a home set with that name.](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| Du verwendest die neueste Version von
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| Eine neue Version von HuskHomes ist verfügbar: v%1% (Deine Version: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| Verfügbare Daten-Importer:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&Klicke, um Daten über diesen Importer zu importieren suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&Dieser Importer unterstützt das Importieren von:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[Fehler:](#ff3300) [Derzeit sind keine Importer verfügbar. Bitte prüfen die](#ff7e5e) [Plugin-Dokumentationen](#ff7e5e italic show_text=&#ff7e5e&Klicke, um den Link zu öffnen open_url=https://william278.net/docs/huskhomes/importing-data) [für weitere Informationen.](#ff7e5e)'
|
||||
error_invalid_importer: '[Fehler:](#ff3300) [Ungültiger Importer. Bitte prüfen die](#ff7e5e) [Plugin-Dokumentationen](#ff7e5e italic show_text=&#ff7e5e&Klicke, um den Link zu öffnen open_url=https://william278.net/docs/huskhomes/importing-data) [für weitere Informationen.](#ff7e5e)'
|
||||
error_home_name_taken: '[Fehler:](#ff3300) [Du hast bereits ein Home mit diesem Namen gesetzt.](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| You are running the latest version of
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| A new version of HuskHomes is available: v%1% (running: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| Available Data Importers:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&Click to import data through this importer. suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&This importer supports importing:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[Error:](#ff3300) [No importers are currently available. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_invalid_importer: '[Error:](#ff3300) [Invalid importer. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_home_name_length: '[Error:](#ff3300) [Home names can only contain up to 16 characters!](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| You are running the latest version of
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| A new version of HuskHomes is available: v%1% (running: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| Available Data Importers:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&Click to import data through this importer. suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&This importer supports importing:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[Error:](#ff3300) [No importers are currently available. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_invalid_importer: '[Error:](#ff3300) [Invalid importer. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_home_name_taken: '[Error:](#ff3300) [Ya tienes una casa con ese nombre.](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| Il plugin è all''ultima versione disp
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| Disponibile una nuova versione: v%1% (running: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| Available Data Importers:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&Click to import data through this importer. suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&This importer supports importing:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[Error:](#ff3300) [No importers are currently available. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_invalid_importer: '[Error:](#ff3300) [Invalid importer. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_home_name_taken: '[Errore:](#ff3300) [Hai già una home impostata con quel nome.](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| HuskHomesの最新バージョンを
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| HuskHomesの最新バージョンが更新されています: v%1% (running: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| 利用可能なデータインポーター:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&クリックすると、このインポーターでデータを取り込むことができます。 suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&このインポーターは、インポートに対応しています。:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[エラー:](#ff3300) [現在、利用可能なインポーターはありません。詳しくは](#ff7e5e) [プラグインドキュメント](#ff7e5e italic show_text=&#ff7e5e&クリックしてリンクを開く open_url=https://william278.net/docs/huskhomes/importing-data) [を確認してください。](#ff7e5e)'
|
||||
error_invalid_importer: '[エラー:](#ff3300) [インポーターが無効です。詳しくは](#ff7e5e) [プラグインドキュメント](#ff7e5e italic show_text=&#ff7e5e&クリックしてリンクを開く open_url=https://william278.net/docs/huskhomes/importing-data) [を確認してください](#ff7e5e)'
|
||||
error_home_name_length: '[エラー:](#ff3300) [ホーム名は最大16文字までしか使用できません!](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| You are running the latest version of
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| A new version of HuskHomes is available: v%1% (running: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| Available Data Importers:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&Click to import data through this importer. suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&This importer supports importing:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[Error:](#ff3300) [No importers are currently available. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_invalid_importer: '[Error:](#ff3300) [Invalid importer. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_home_name_taken: '[Error:](#ff3300) [You already have a home set with that name.](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| Вы используете после
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| Доступна новая версия HuskHomes: v%1% (текущая: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| Доступные импортеры данных:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&Нажмите, чтобы импортировать данные через этот импортер. suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&Этот импортер поддерживает импорт данных:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[Ошибка:](#ff3300) [В данный момент нет доступных импортеров. Пожалуйста, проверьте](#ff7e5e) [документацию плагина](#ff7e5e italic show_text=&#ff7e5e&Нажмите, чтобы открыть ссылку open_url=https://william278.net/docs/huskhomes/importing-data) [для получения дополнительной информации.](#ff7e5e)'
|
||||
error_invalid_importer: '[Ошибка:](#ff3300) [Неверный импортер. Пожалуйста, проверьте](#ff7e5e) [документацию плагина](#ff7e5e italic show_text=&#ff7e5e&Нажмите, чтобы открыть ссылку open_url=https://william278.net/docs/huskhomes/importing-data) [для получения дополнительной информации.](#ff7e5e)'
|
||||
error_home_name_taken: '[Error:](#ff3300) [You already have a home set with that name.](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| HuskHomesun en son sürümünü kullan
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| HuskHomesun yeni bir sürümü mevcut: v%1% (yürütülen: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| Kullanılabilir Veri Aktarıcıları:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&Bu içe aktarıcı aracılığıyla verileri içe aktarmak için tıklayın. suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&Bu içe aktarıcı içe aktarmayı destekler:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[Hata:](#ff3300) [Şu anda kullanılabilir ithalatçı yok. Lütfen şunu kontrol edin](#ff7e5e) [eklenti dökümanları](#ff7e5e italic show_text=&#ff7e5e&Bağlantıyı açmak için tıklayın open_url=https://william278.net/docs/huskhomes/importing-data) [daha fazla detay için.](#ff7e5e)'
|
||||
error_invalid_importer: '[Hata:](#ff3300) [Geçersiz ithalatçı. Lütfen şunu kontrol edin](#ff7e5e) [eklenti dökümanları](#ff7e5e italic show_text=&#ff7e5e&Bağlantıyı açmak için tıklayın open_url=https://william278.net/docs/huskhomes/importing-data) [daha fazla detay için.](#ff7e5e)'
|
||||
error_home_name_taken: '[Hata:](#ff3300) [Bu ada sahip bir eviniz zaten var.](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| You are running the latest version of
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| A new version of HuskHomes is available: v%1% (running: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| Available Data Importers:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&Click to import data through this importer. suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&This importer supports importing:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[Error:](#ff3300) [No importers are currently available. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_invalid_importer: '[Error:](#ff3300) [Invalid importer. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_home_name_taken: '[Error:](#ff3300) [You already have a home set with that name.](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| 你正在使用最新版本的HuskHome
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| 一个新版本的HuskHomes已经可以更新: v%1% (当前: v%2%)](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| 可用的数据导入器:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&点击以通过此导入器导入数据. suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&此导入器支持导入:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[错误:](#ff3300) [目前没有可用的数据来源. 请检查](#ff7e5e) [插件文档](#ff7e5e italic show_text=&#ff7e5e&点击打开链接 open_url=https://william278.net/docs/huskhomes/importing-data)'
|
||||
error_invalid_importer: '[错误:](#ff3300) [数据源无效,请检查](#ff7e5e) [插件文档](#ff7e5e italic show_text=&#ff7e5e&点击打开链接 open_url=https://william278.net/docs/huskhomes/importing-data)'
|
||||
error_home_name_taken: '[错误:](#ff3300) [已有一个相同名称的家](#ff7e5e)'
|
||||
|
||||
@@ -107,6 +107,12 @@ up_to_date: '[HuskHomes](#00fb9a bold) [| 您運行的是最新版本的 HuskHom
|
||||
update_available: '[HuskHomes](#ff7e5e bold) [| 發現可用的新版本: v%1% (running: v%2%).](#ff7e5e)'
|
||||
importer_list_title: '[HuskHomes](#00fb9a bold) [| Available Data Importers:](#00fb9a)\n'
|
||||
importer_list_item: '[%1%](#00fb9a show_text=�fb9a&Click to import data through this importer. suggest_command=/huskhomes:huskhomes import start %1%) [⏩ %2%](white show_text=�fb9a&This importer supports importing:\n&f%2% suggest_command=/huskhomes:huskhomes import start %1%)'
|
||||
delete_player_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of %1%''s data?](#ff7e5e)\n[All associated homes will also be deleted. This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete player %1% confirm)'
|
||||
delete_player_success: '[Successfully deleted all player data for](#00fb9a) [%1%](#00fb9a bold)[, including %2% home(s).](#00fb9a)'
|
||||
bulk_delete_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all warps in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete warps %1% %2% confirm)'
|
||||
bulk_delete_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [warps.](#00fb9a)'
|
||||
bulk_delete_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all homes in world \"%1%\"?](#ff7e5e)\n[This action is irreversible.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/huskhomes:huskhomes delete homes %1% %2% confirm)'
|
||||
bulk_delete_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [homes.](#00fb9a)'
|
||||
error_no_importers_available: '[Error:](#ff3300) [No importers are currently available. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_invalid_importer: '[Error:](#ff3300) [Invalid importer. Please check the](#ff7e5e) [plugin docs](#ff7e5e italic show_text=&#ff7e5e&Click to open link open_url=https://william278.net/docs/huskhomes/importing-data) [for more details.](#ff7e5e)'
|
||||
error_home_name_taken: '[錯誤:](#ff3300) [已有一個相同名稱的家.](#ff7e5e)'
|
||||
|
||||
+9
-8
@@ -33,7 +33,7 @@ This is a table of HuskHomes' commands and their required permission nodes. Addi
|
||||
| `/spawn` | Teleport to spawn | `huskhomes.command.spawn` | ✅ |
|
||||
| `/setspawn` | Set the spawn position | `huskhomes.command.setspawn` | ❌ |
|
||||
| `/back` | Return to your previous position, or where you died | `huskhomes.command.back` | ✅ |
|
||||
| `/huskhomes [about/help/reload/import/update]` | View plugin information & reload configs | `huskhomes.command.huskhomes` | ✅ |
|
||||
| `/huskhomes [about/help/reload/import/delete/update]` | View plugin information & reload configs | `huskhomes.command.huskhomes` | ✅ |
|
||||
|
||||
* † **Base Permission** — Required permission for basic command execution; some commands require additional permissions for certain functions ([See below…](#other-permissions))
|
||||
* ‡ **Default** — ✅ = Accessible by all players by default — ❌ = Accessible only by server operators by default.
|
||||
@@ -142,11 +142,12 @@ These permissions allow you to use /tp and /rtp to teleport other players remote
|
||||
|
||||
These permissions control what arguments of the /huskhomes command a user may use.
|
||||
|
||||
| Command | Description | Permission | Default |
|
||||
|----------------------------------|--------------------------------------------|--------------------------------------|:-------:|
|
||||
| `/huskhomes help [page]` | View a list of HuskHomes commands | `huskhomes.command.huskhomes.help` | ✅ |
|
||||
| `/huskhomes [about]` | View the plugin about menu | `huskhomes.command.huskhomes.about` | ✅ |
|
||||
| `/huskhomes reload` | Reload the plugin config and message files | `huskhomes.command.huskhomes.reload` | ❌ |
|
||||
| `/huskhomes import [list/start]` | Import data from other plugins/mods | `huskhomes.command.huskhomes.import` | ❌ |
|
||||
| `/huskhomes update` | Check for updates | `huskhomes.command.huskhomes.update` | ❌ |
|
||||
| Command | Description | Permission | Default |
|
||||
|-------------------------------------------------|----------------------------------------------------------|--------------------------------------|:-------:|
|
||||
| `/huskhomes help [page]` | View a list of HuskHomes commands | `huskhomes.command.huskhomes.help` | ✅ |
|
||||
| `/huskhomes [about]` | View the plugin about menu | `huskhomes.command.huskhomes.about` | ✅ |
|
||||
| `/huskhomes reload` | Reload the plugin config and message files | `huskhomes.command.huskhomes.reload` | ❌ |
|
||||
| `/huskhomes import [list/start]` | Import data from other plugins/mods | `huskhomes.command.huskhomes.import` | ❌ |
|
||||
| `/huskhomes delete [player/homes/warps] [args]` | Perform bulk actions on homes/warps & delete player data | `huskhomes.command.huskhomes.delete` | ❌ |
|
||||
| `/huskhomes update` | Check for updates | `huskhomes.command.huskhomes.update` | ❌ |
|
||||
</details>
|
||||
@@ -72,10 +72,14 @@ general:
|
||||
strict_tpa_here_requests: true
|
||||
# Whether home or warp names should be case insensitive (i.e. allow /home HomeOne and /home homeone)
|
||||
case_insensitive_names: false
|
||||
# Whether home or warp names should allow UTF-8 characters (i.e. allow /home 你好)
|
||||
allow_unicode_names: false
|
||||
# Whether home or warp descriptions should allow UTF-8 characters
|
||||
allow_unicode_descriptions: true
|
||||
# Whether home and warp names should be restricted by a regex. Set this to false to allow full UTF-8 names (i.e. allow /home 你好).
|
||||
restrict_names: true
|
||||
# Regex which home and warp names must match. Names have a max length of 16 characters
|
||||
name_regex: '[a-zA-Z0-9-_]*'
|
||||
# Whether home/warp descriptions should be restricted. Set this to true to restrict UTF-8 usage.
|
||||
restrict_descriptions: false
|
||||
# Regex which home and warp descriptions must match. A hard max length of 256 characters is enforced
|
||||
description_regex: '\A\p{ASCII}*\z'
|
||||
# Whether /back should work to teleport the user to where they died
|
||||
back_command_return_by_death: true
|
||||
# Whether /back should work with other plugins that use the PlayerTeleportEvent (can cause conflicts)
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ javaVersion=16
|
||||
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
|
||||
org.gradle.daemon=true
|
||||
|
||||
plugin_version=4.4.6
|
||||
plugin_version=4.5
|
||||
plugin_archive=huskhomes
|
||||
plugin_description=The powerful and intuitive homes, warps, and teleports plugin/mod
|
||||
|
||||
|
||||
@@ -19,34 +19,15 @@
|
||||
|
||||
package net.william278.huskhomes;
|
||||
|
||||
import net.william278.huskhomes.command.BukkitCommand;
|
||||
import net.william278.huskhomes.command.Command;
|
||||
import net.william278.huskhomes.command.PaperCommand;
|
||||
import net.william278.huskhomes.hook.Pl3xMapHook;
|
||||
import net.william278.huskhomes.listener.EventListener;
|
||||
import net.william278.huskhomes.listener.PaperEventListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PaperHuskHomes extends BukkitHuskHomes {
|
||||
|
||||
@Override
|
||||
public void registerHooks() {
|
||||
super.registerHooks();
|
||||
|
||||
if (getMapHook().isEmpty() && isDependencyLoaded("Pl3xMap")) {
|
||||
getHooks().add(new Pl3xMapHook(this));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Command> registerCommands() {
|
||||
return Arrays.stream(BukkitCommand.Type.values())
|
||||
.map((type) -> type.createCommand(this))
|
||||
.filter((command) -> !this.getSettings().isCommandDisabled(command))
|
||||
.peek((command) -> new PaperCommand(command, this).register())
|
||||
.toList();
|
||||
protected @NotNull EventListener registerListener() {
|
||||
return new PaperEventListener(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* This file is part of HuskHomes, licensed under the Apache License 2.0.
|
||||
*
|
||||
* Copyright (c) William278 <[email protected]>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import me.lucko.commodore.CommodoreProvider;
|
||||
import net.william278.huskhomes.PaperHuskHomes;
|
||||
import net.william278.huskhomes.user.BukkitUser;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PaperCommand extends org.bukkit.command.Command {
|
||||
|
||||
private final PaperHuskHomes plugin;
|
||||
private final Command command;
|
||||
|
||||
public PaperCommand(@NotNull Command command, @NotNull PaperHuskHomes plugin) {
|
||||
super(command.getName(), command.getDescription(), command.getUsage(), command.getAliases());
|
||||
this.command = command;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
this.command.onExecuted(sender instanceof Player p ? BukkitUser.adapt(p, plugin) : plugin.getConsole(), args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias,
|
||||
@NotNull String[] args) throws IllegalArgumentException {
|
||||
if (!(this.command instanceof TabProvider provider)) {
|
||||
return List.of();
|
||||
}
|
||||
final CommandUser user = sender instanceof Player p ? BukkitUser.adapt(p, plugin) : plugin.getConsole();
|
||||
return provider.getSuggestions(user, args);
|
||||
}
|
||||
|
||||
public void register() {
|
||||
// Register with bukkit
|
||||
plugin.getServer().getCommandMap().register("huskhomes", this);
|
||||
|
||||
// Register permissions
|
||||
BukkitCommand.addPermission(
|
||||
plugin,
|
||||
command.getPermission(),
|
||||
command.getUsage(),
|
||||
BukkitCommand.getPermissionDefault(command.isOperatorCommand())
|
||||
);
|
||||
final List<Permission> childNodes = command.getAdditionalPermissions()
|
||||
.entrySet().stream()
|
||||
.map((entry) -> BukkitCommand.addPermission(
|
||||
plugin,
|
||||
entry.getKey(),
|
||||
"",
|
||||
BukkitCommand.getPermissionDefault(entry.getValue()))
|
||||
)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
if (!childNodes.isEmpty()) {
|
||||
BukkitCommand.addPermission(
|
||||
plugin,
|
||||
command.getPermission("*"),
|
||||
command.getUsage(),
|
||||
PermissionDefault.FALSE,
|
||||
childNodes.toArray(new Permission[0])
|
||||
);
|
||||
}
|
||||
|
||||
// Register commodore TAB completion
|
||||
if (CommodoreProvider.isSupported() && plugin.getSettings().doBrigadierTabCompletion()) {
|
||||
BrigadierUtil.registerCommodore(plugin, this, command);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user