diff --git a/bukkit/build.gradle b/bukkit/build.gradle index a107da87..8193d852 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -1,5 +1,5 @@ dependencies { - implementation project(path: ':common', configuration: 'shadow') + implementation project(path: ':common') implementation 'commons-io:commons-io:2.11.0' implementation 'de.themoep:minedown:1.7.1-SNAPSHOT' diff --git a/bukkit/src/main/java/net/william278/huskhomes/HuskHomesBukkit.java b/bukkit/src/main/java/net/william278/huskhomes/HuskHomesBukkit.java new file mode 100644 index 00000000..17bd95a5 --- /dev/null +++ b/bukkit/src/main/java/net/william278/huskhomes/HuskHomesBukkit.java @@ -0,0 +1,53 @@ +package net.william278.huskhomes; + +import net.william278.huskhomes.config.Messages; +import net.william278.huskhomes.config.Settings; +import net.william278.huskhomes.player.Player; +import net.william278.huskhomes.position.Server; +import net.william278.huskhomes.util.Logger; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.Set; + +public class HuskHomesBukkit extends JavaPlugin implements HuskHomes { + + @Override + public void onLoad() { + super.onLoad(); + } + + @Override + public void onEnable() { + super.onEnable(); + } + + @Override + public void onDisable() { + super.onDisable(); + } + + @Override + public Logger getLoggingAdapter() { + return null; + } + + @Override + public Set getOnlinePlayers() { + return null; + } + + @Override + public Settings getSettings() { + return null; + } + + @Override + public Messages getMessages() { + return null; + } + + @Override + public Server getServerData() { + return null; + } +} diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml new file mode 100644 index 00000000..b794d0f1 --- /dev/null +++ b/bukkit/src/main/resources/plugin.yml @@ -0,0 +1,3 @@ +name: HuskHomes +main: net.william278.huskhomes.HuskHomesBukkit +version: ${version} \ No newline at end of file diff --git a/common/src/main/java/net/william278/huskhomes/HuskHomes.java b/common/src/main/java/net/william278/huskhomes/HuskHomes.java index 676ff890..4b3159ce 100644 --- a/common/src/main/java/net/william278/huskhomes/HuskHomes.java +++ b/common/src/main/java/net/william278/huskhomes/HuskHomes.java @@ -1,6 +1,9 @@ package net.william278.huskhomes; +import net.william278.huskhomes.config.Messages; +import net.william278.huskhomes.config.Settings; import net.william278.huskhomes.player.Player; +import net.william278.huskhomes.position.Server; import net.william278.huskhomes.util.Logger; import java.util.Set; @@ -15,7 +18,7 @@ public interface HuskHomes { * * @return the {@link Logger} implementation to use */ - Logger getLogger(); + Logger getLoggingAdapter(); /** * Returns a {@link Set} of online {@link Player}s on this server @@ -24,4 +27,25 @@ public interface HuskHomes { */ Set getOnlinePlayers(); + /** + * Return the plugin {@link Settings} loaded from file + * + * @return the plugin {@link Settings} + */ + Settings getSettings(); + + /** + * Return the plugin messages loaded from file + * + * @return The plugin {@link Messages} + */ + Messages getMessages(); + + /** + * Return the {@link Server} the plugin is running on + * + * @return the {@link Server} object representing the implementing server + */ + Server getServerData(); + } diff --git a/common/src/main/java/net/william278/huskhomes/command/CommandBase.java b/common/src/main/java/net/william278/huskhomes/command/CommandBase.java index 5164680d..34953350 100644 --- a/common/src/main/java/net/william278/huskhomes/command/CommandBase.java +++ b/common/src/main/java/net/william278/huskhomes/command/CommandBase.java @@ -55,4 +55,4 @@ public abstract class CommandBase { */ public abstract List onTabComplete(Player player, String[] args); -} \ No newline at end of file +} diff --git a/common/src/main/java/net/william278/huskhomes/config/Messages.java b/common/src/main/java/net/william278/huskhomes/config/Messages.java new file mode 100644 index 00000000..13120578 --- /dev/null +++ b/common/src/main/java/net/william278/huskhomes/config/Messages.java @@ -0,0 +1,95 @@ +package net.william278.huskhomes.config; + +import de.themoep.minedown.MineDown; +import dev.dejvokep.boostedyaml.YamlDocument; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; +import java.util.Optional; + +/** + * Loaded locales used by the plugin to display various messages + */ +public class Messages { + + @NotNull + private final HashMap rawMessages; + + private Messages(YamlDocument messagesConfig) { + this.rawMessages = new HashMap<>(); + for (String messageId : messagesConfig.getRoutesAsStrings(false)) { + rawMessages.put(messageId, messagesConfig.getString(messageId)); + } + } + + /** + * Returns an unformatted message loaded from the messages file + * + * @param messageId String identifier of the message, corresponding to a key in the file + * @return An {@link Optional} containing the message corresponding to the id, if it exists + */ + public Optional getRawMessage(String messageId) { + if (rawMessages.containsKey(messageId)) { + return Optional.of(rawMessages.get(messageId)); + } + return Optional.empty(); + } + + /** + * Returns an unformatted message loaded from the messages file, with replacements applied + * + * @param messageId String identifier of the message, corresponding to a key in the file + * @return An {@link Optional} containing the replacement-applied message corresponding to the id, if it exists + */ + public Optional getRawMessage(String messageId, String... replacements) { + return getRawMessage(messageId).map(message -> applyReplacements(message, replacements)); + } + + /** + * Returns a MineDown-formatted message from the messages file + * + * @param messageId String identifier of the message, corresponding to a key in the file + * @return An {@link Optional} containing the formatted message corresponding to the id, if it exists + */ + public Optional getMessage(String messageId) { + return getRawMessage(messageId).map(MineDown::new); + } + + /** + * Returns a MineDown-formatted message from the messages file, with replacements applied + * + * @param messageId String identifier of the message, corresponding to a key in the file + * @return An {@link Optional} containing the replacement-applied, formatted message corresponding to the id, if it exists + */ + public Optional getMessage(String messageId, String... replacements) { + return getRawMessage(messageId, replacements).map(MineDown::new); + } + + /** + * Apply placeholder replacements to a raw message + * + * @param rawMessage The raw, unparsed message + * @param replacements Ordered list of placeholder replacement Strings + * @return the raw message, with inserted placeholders + */ + private String applyReplacements(String rawMessage, String... replacements) { + int replacementIndexer = 1; + for (String replacement : replacements) { + String replacementString = "%" + replacementIndexer + "%"; + rawMessage = rawMessage.replace(replacementString, replacement); + replacementIndexer = replacementIndexer + 1; + } + return rawMessage; + } + + /** + * Load the messages from a BoostedYaml {@link YamlDocument} messages file + * + * @param messagesConfig The loaded {@link YamlDocument} messages.yml file + * @return the loaded {@link Messages} + */ + public Messages load(YamlDocument messagesConfig) { + return new Messages(messagesConfig); + } + +} diff --git a/common/src/main/java/net/william278/huskhomes/config/Settings.java b/common/src/main/java/net/william278/huskhomes/config/Settings.java new file mode 100644 index 00000000..e85e88d8 --- /dev/null +++ b/common/src/main/java/net/william278/huskhomes/config/Settings.java @@ -0,0 +1,279 @@ +package net.william278.huskhomes.config; + +import dev.dejvokep.boostedyaml.YamlDocument; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.*; + +/** + * Settings used for the plugin, as read from the config file + */ +public class Settings { + + /** + * Map of {@link ConfigOption}s read from the config file + */ + private final HashMap configOptions; + + // Load the settings from the document + private Settings(YamlDocument config) { + this.configOptions = new HashMap<>(); + Arrays.stream(ConfigOption.values()).forEach(configOption -> configOptions + .put(configOption, switch (configOption.optionType) { + case BOOLEAN -> configOption.getBooleanValue(config); + case STRING -> configOption.getStringValue(config); + case DOUBLE -> configOption.getDoubleValue(config); + case FLOAT -> configOption.getFloatValue(config); + case INTEGER -> configOption.getIntValue(config); + case STRING_LIST -> configOption.getStringListValue(config); + })); + } + + /** + * Get the value of the specified {@link ConfigOption} + * + * @param option the {@link ConfigOption} to check + * @return the value of the {@link ConfigOption} as a boolean + * @throws ClassCastException if the option is not a boolean + */ + public boolean getBooleanValue(ConfigOption option) throws ClassCastException { + return (Boolean) configOptions.get(option); + } + + /** + * Get the value of the specified {@link ConfigOption} + * + * @param option the {@link ConfigOption} to check + * @return the value of the {@link ConfigOption} as a string + * @throws ClassCastException if the option is not a string + */ + public String getStringValue(ConfigOption option) throws ClassCastException { + return (String) configOptions.get(option); + } + + /** + * Get the value of the specified {@link ConfigOption} + * + * @param option the {@link ConfigOption} to check + * @return the value of the {@link ConfigOption} as a double + * @throws ClassCastException if the option is not a double + */ + public double getDoubleValue(ConfigOption option) throws ClassCastException { + return (Double) configOptions.get(option); + } + + /** + * Get the value of the specified {@link ConfigOption} + * + * @param option the {@link ConfigOption} to check + * @return the value of the {@link ConfigOption} as a float + * @throws ClassCastException if the option is not a float + */ + public double getFloatValue(ConfigOption option) throws ClassCastException { + return (Float) configOptions.get(option); + } + + /** + * Get the value of the specified {@link ConfigOption} + * + * @param option the {@link ConfigOption} to check + * @return the value of the {@link ConfigOption} as an integer + * @throws ClassCastException if the option is not an integer + */ + public int getIntegerValue(ConfigOption option) throws ClassCastException { + return (Integer) configOptions.get(option); + } + + /** + * Get the value of the specified {@link ConfigOption} + * + * @param option the {@link ConfigOption} to check + * @return the value of the {@link ConfigOption} as a string {@link List} + * @throws ClassCastException if the option is not a string list + */ + @SuppressWarnings("unchecked") + public List getStringListValue(ConfigOption option) throws ClassCastException { + return (List) configOptions.get(option); + } + + + /** + * Load the settings from a BoostedYaml {@link YamlDocument} config file + * + * @param config The loaded {@link YamlDocument} config.yml file + * @return the loaded {@link Settings} + */ + public Settings load(YamlDocument config) { + return new Settings(config); + } + + /** + * Represents an option stored by a path in config.yml + */ + public enum ConfigOption { + LANGUAGE("language", OptionType.STRING, "en-gb"), + CHECK_FOR_UPDATES("check_for_updates", OptionType.BOOLEAN, true), + + DATA_STORAGE_TYPE("data_storage_options.storage_type", OptionType.STRING, "SQLite"), + DATABASE_HOST("data_storage_options.mysql_credentials.host", OptionType.STRING, "localhost"), + DATABASE_PORT("data_storage_options.mysql_credentials.port", OptionType.INTEGER, 3306), + DATABASE_NAME("data_storage_options.mysql_credentials.database", OptionType.STRING, "HuskHomes"), + DATABASE_USERNAME("data_storage_options.mysql_credentials.username", OptionType.STRING, "root"), + DATABASE_PASSWORD("data_storage_options.mysql_credentials.password", OptionType.STRING, "pa55w0rd"), + DATABASE_CONNECTION_PARAMS("data_storage_options.mysql_credentials.params", OptionType.STRING, "?autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull"), + + DATABASE_CONNECTION_POOL_MAX_SIZE("data_storage_options.connection_pool_options.maximum_pool_size", OptionType.INTEGER, 10), + DATABASE_CONNECTION_POOL_MIN_IDLE("data_storage_options.connection_pool_options.minimum_idle", OptionType.INTEGER, 10), + DATABASE_CONNECTION_POOL_MAX_LIFETIME("data_storage_options.connection_pool_options.maximum_lifetime", OptionType.INTEGER, 1800000), + DATABASE_CONNECTION_POOL_KEEPALIVE("data_storage_options.connection_pool_options.keepalive_time", OptionType.INTEGER, 0), + DATABASE_CONNECTION_POOL_TIMEOUT("data_storage_options.connection_pool_options.connection_timeout", OptionType.INTEGER, 5000), + + DATABASE_PLAYER_TABLE_NAME("data_storage_options.table_names.player_data", OptionType.STRING, "huskhomes_player_data"), + DATABASE_LOCATION_TABLE_NAME("data_storage_options.table_names.locations_data", OptionType.STRING, "huskhomes_location_data"), + DATABASE_HOMES_TABLE_NAME("data_storage_options.table_names.homes_data", OptionType.STRING, "huskhomes_home_data"), + DATABASE_WARPS_TABLE_NAME("data_storage_options.table_names.warps_data", OptionType.STRING, "huskhomes_warp_data"), + + MAX_SETHOMES("general.max_sethomes", OptionType.INTEGER, 10), + AUTO_COMPLETE_PLAYER_NAMES("general.auto_complete_player_names", OptionType.BOOLEAN, true), + HOME_LIMIT_PERMISSION_STACKING("general.home_limit_permission_stacking", OptionType.BOOLEAN, false), + TELEPORT_WARMUP_TIME("general.teleport_warmup_time", OptionType.INTEGER, 5), + TELEPORT_WARMUP_DISPLAY_SLOT("general.teleport_warmup_display", OptionType.STRING, "ACTION_BAR"), + TELEPORT_REQUEST_EXPIRY_TIME("general.teleport_request_expiry_time", OptionType.INTEGER, 60), + ALLOW_UNICODE_DESCRIPTIONS("general.allow_unicode_descriptions", OptionType.BOOLEAN, true), + USE_PAPERLIB_IF_AVAILABLE("general.use_paperlib_if_available", OptionType.BOOLEAN, true), + + TELEPORT_COMPLETE_SOUND("general.sounds.teleportation_complete", OptionType.STRING, "ENTITY_ENDERMAN_TELEPORT"), + TELEPORT_WARMUP_SOUND("general.sounds.teleportation_warmup", OptionType.STRING, "BLOCK_NOTE_BLOCK_BANJO"), + TELEPORT_CANCELLED_SOUND("general.sounds.teleportation_cancelled", OptionType.STRING, "ENTITY_ITEM_BREAK"), + + PRIVATE_HOME_LIST_ITEMS_PER_PAGE("general.lists.private_homes_per_page", OptionType.INTEGER, 10), + PUBLIC_HOME_LIST_ITEMS_PER_PAGE("general.lists.public_homes_per_page", OptionType.INTEGER, 10), + WARP_LIST_ITEMS_PER_PAGE("general.lists.warps_per_page", OptionType.INTEGER, 10), + + HELP_MENU_HIDE_COMMANDS_WITHOUT_PERMISSION("general.help_menu.hide_commands_without_permission", OptionType.BOOLEAN, true), + HELP_MENU_HIDE_HUSKHOMES_COMMAND("general.help_menu.hide_huskhomes_command", OptionType.BOOLEAN, false), + + ENABLE_PROXY_MODE("proxy_options.enable_proxy_mode", OptionType.BOOLEAN, false), + CLUSTER_ID("proxy_options.cluster_id", OptionType.STRING, ""), + MESSENGER_TYPE("proxy_options.messenger_type", OptionType.STRING, "PLUGIN_MESSAGE"), + + REDIS_HOST("proxy_options.redis_credentials.host", OptionType.STRING, "localhost"), + REDIS_PORT("proxy_options.redis_credentials.port", OptionType.INTEGER, 6379), + REDIS_PASSWORD("proxy_options.redis_credentials.password", OptionType.STRING, ""), + REDIS_USE_SSL("proxy_options.redis_credentials.use_ssl", OptionType.BOOLEAN, false); + + /** + * The path in the config.yml file to the value + */ + @NotNull + public final String configPath; + + /** + * The {@link OptionType} of this option + */ + @NotNull + public final OptionType optionType; + + /** + * The default value of this option if not set in config + */ + @Nullable + private final Object defaultValue; + + ConfigOption(@NotNull String configPath, @NotNull OptionType optionType, @Nullable Object defaultValue) { + this.configPath = configPath; + this.optionType = optionType; + this.defaultValue = defaultValue; + } + + ConfigOption(@NotNull String configPath, @NotNull OptionType optionType) { + this.configPath = configPath; + this.optionType = optionType; + this.defaultValue = null; + } + + /** + * Get the value at the path specified (or return default if set), as a string + * + * @param config The {@link YamlDocument} config file + * @return the value defined in the config, as a string + */ + public String getStringValue(@NotNull YamlDocument config) { + return defaultValue != null + ? config.getString(configPath, (String) defaultValue) + : config.getString(configPath); + } + + /** + * Get the value at the path specified (or return default if set), as a boolean + * + * @param config The {@link YamlDocument} config file + * @return the value defined in the config, as a boolean + */ + public boolean getBooleanValue(@NotNull YamlDocument config) { + return defaultValue != null + ? config.getBoolean(configPath, (Boolean) defaultValue) + : config.getBoolean(configPath); + } + + /** + * Get the value at the path specified (or return default if set), as a double + * + * @param config The {@link YamlDocument} config file + * @return the value defined in the config, as a double + */ + public double getDoubleValue(@NotNull YamlDocument config) { + return defaultValue != null + ? config.getDouble(configPath, (Double) defaultValue) + : config.getDouble(configPath); + } + + /** + * Get the value at the path specified (or return default if set), as a float + * + * @param config The {@link YamlDocument} config file + * @return the value defined in the config, as a float + */ + public float getFloatValue(@NotNull YamlDocument config) { + return defaultValue != null + ? config.getFloat(configPath, (Float) defaultValue) + : config.getFloat(configPath); + } + + /** + * Get the value at the path specified (or return default if set), as an int + * + * @param config The {@link YamlDocument} config file + * @return the value defined in the config, as an int + */ + public int getIntValue(@NotNull YamlDocument config) { + return defaultValue != null + ? config.getInt(configPath, (Integer) defaultValue) + : config.getInt(configPath); + } + + /** + * Get the value at the path specified (or return default if set), as a string {@link List} + * + * @param config The {@link YamlDocument} config file + * @return the value defined in the config, as a string {@link List} + */ + public List getStringListValue(@NotNull YamlDocument config) { + return config.getStringList(configPath, new ArrayList<>()); + } + + /** + * Represents the type of the object + */ + public enum OptionType { + BOOLEAN, + STRING, + DOUBLE, + FLOAT, + INTEGER, + STRING_LIST + } + } + +} diff --git a/common/src/main/java/net/william278/huskhomes/player/Player.java b/common/src/main/java/net/william278/huskhomes/player/Player.java index 13b3c540..a2919b55 100644 --- a/common/src/main/java/net/william278/huskhomes/player/Player.java +++ b/common/src/main/java/net/william278/huskhomes/player/Player.java @@ -1,7 +1,8 @@ package net.william278.huskhomes.player; +import de.themoep.minedown.MineDown; import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.teleport.TeleportResult; +import org.jetbrains.annotations.NotNull; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -38,9 +39,14 @@ public interface Player { * @param node The permission node string * @return {@code true} if the player has the node; {@code false} otherwise */ - boolean hasPermission(String node); + boolean hasPermission(@NotNull String node); - void sendMessage(); + /** + * Dispatch a MineDown-formatted message to this player + * + * @param mineDown the parsed {@link MineDown} to send + */ + void sendMessage(@NotNull MineDown mineDown); /** * Returns the maximum number of homes this player can set @@ -56,12 +62,4 @@ public interface Player { */ CompletableFuture getFreeHomes(); - /** - * Teleport the player to a specified {@link Position} - * - * @param position the target {@link Position} to teleport to - * @return A {@link CompletableFuture} callback returning the {@link TeleportResult} of completing the teleport - */ - CompletableFuture teleport(Position position); - } \ No newline at end of file diff --git a/common/src/main/java/net/william278/huskhomes/position/SavedPosition.java b/common/src/main/java/net/william278/huskhomes/position/SavedPosition.java index 71f0f7e8..1da5432e 100644 --- a/common/src/main/java/net/william278/huskhomes/position/SavedPosition.java +++ b/common/src/main/java/net/william278/huskhomes/position/SavedPosition.java @@ -2,7 +2,14 @@ package net.william278.huskhomes.position; import org.jetbrains.annotations.NotNull; +/** + * Represents a persistently-saved {@link Position} + */ public class SavedPosition extends Position { + + /** + * Metadata about this position (name, description) + */ @NotNull public final PositionMeta positionMeta; diff --git a/common/src/main/java/net/william278/huskhomes/position/Server.java b/common/src/main/java/net/william278/huskhomes/position/Server.java index 7609ce14..6255e5b2 100644 --- a/common/src/main/java/net/william278/huskhomes/position/Server.java +++ b/common/src/main/java/net/william278/huskhomes/position/Server.java @@ -1,7 +1,5 @@ package net.william278.huskhomes.position; -import java.util.UUID; - /** * Represents a server on a proxied network */ @@ -12,9 +10,16 @@ public class Server { */ public String id; - /** - * Plugin-assigned identifier of this server - */ - public UUID uuid; + public Server(String id) { + this.id = id; + } + @Override + public boolean equals(Object other) { + if (other instanceof Server server) { + // If the id of this server matches another, the servers are the same. + return server.id.equalsIgnoreCase(this.id); + } + return super.equals(other); + } } diff --git a/common/src/main/java/net/william278/huskhomes/teleport/Teleport.java b/common/src/main/java/net/william278/huskhomes/teleport/Teleport.java new file mode 100644 index 00000000..87a68308 --- /dev/null +++ b/common/src/main/java/net/william278/huskhomes/teleport/Teleport.java @@ -0,0 +1,28 @@ +package net.william278.huskhomes.teleport; + +import net.william278.huskhomes.player.Player; +import net.william278.huskhomes.position.Position; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a teleport in the process of being executed + */ +public class Teleport { + + /** + * The player involved in the teleport + */ + @NotNull + public Player player; + + /** + * The target position for the player + */ + @NotNull + public Position target; + + public Teleport(@NotNull Player player, @NotNull Position target) { + this.player = player; + this.target = target; + } +} diff --git a/common/src/main/java/net/william278/huskhomes/teleport/TeleportManager.java b/common/src/main/java/net/william278/huskhomes/teleport/TeleportManager.java new file mode 100644 index 00000000..f8f67911 --- /dev/null +++ b/common/src/main/java/net/william278/huskhomes/teleport/TeleportManager.java @@ -0,0 +1,54 @@ +package net.william278.huskhomes.teleport; + +import net.william278.huskhomes.HuskHomes; +import net.william278.huskhomes.player.Player; +import net.william278.huskhomes.position.Position; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.CompletableFuture; + +/** + * Cross-platform teleportation manager + */ +public abstract class TeleportManager { + + /** + * Instance of the implementing plugin + */ + @NotNull + private final HuskHomes plugin; + + /** + * {@link Set} of currently processing teleports + */ + @NotNull + private final Set> processingTeleports; + + public TeleportManager(@NotNull HuskHomes plugin) { + this.plugin = plugin; + this.processingTeleports = new HashSet<>(); + } + + /** + * Teleport the player to a specified {@link Position} + * + * @param position the target {@link Position} to teleport to + * @return A {@link CompletableFuture} callback returning the {@link TeleportResult} of completing the teleport + */ + public CompletableFuture teleport(Player player, Position position) { + if (position.server.equals(plugin.getServerData())) { + return teleportLocally(new Teleport(player, position)); + } else { + return teleportCrossServer(new Teleport(player, position)); + } + } + + public abstract CompletableFuture teleportLocally(Teleport teleport); + + private CompletableFuture teleportCrossServer(Teleport teleport) { + return null; //todo dispatch cross-server message here! + } + +} diff --git a/common/src/main/java/net/william278/huskhomes/teleport/TeleportResult.java b/common/src/main/java/net/william278/huskhomes/teleport/TeleportResult.java index a5507e18..018e0459 100644 --- a/common/src/main/java/net/william278/huskhomes/teleport/TeleportResult.java +++ b/common/src/main/java/net/william278/huskhomes/teleport/TeleportResult.java @@ -4,31 +4,31 @@ import net.william278.huskhomes.position.Position; import net.william278.huskhomes.position.World; /** - * Represents the result of a completed teleport + * Represents the result of a completed {@link Teleport} */ public enum TeleportResult { /** - * Returns if the teleport completed successfully + * Returns if the {@link Teleport} completed successfully */ SUCCESS(true), /** - * Returns if the teleport failed because the {@link World} of the + * Returns if the {@link Teleport} failed because the {@link World} of the * target {@link Position} could not be found *

*/ FAILED_INVALID_WORLD(false), /** - * Returns if the teleport failed because the server of the target + * Returns if the {@link Teleport} failed because the server of the target * {@link Position} was invalid or not online *

*/ FAILED_INVALID_SERVER(false), /** - * Returns if the teleport failed because the coordinates of the + * Returns if the {@link Teleport} failed because the coordinates of the * target {@link Position} were outside the world border limits *

*/ diff --git a/common/src/main/java/net/william278/huskhomes/util/Logger.java b/common/src/main/java/net/william278/huskhomes/util/Logger.java index cb5542dd..17272067 100644 --- a/common/src/main/java/net/william278/huskhomes/util/Logger.java +++ b/common/src/main/java/net/william278/huskhomes/util/Logger.java @@ -2,6 +2,9 @@ package net.william278.huskhomes.util; import java.util.logging.Level; +/** + * An abstract, cross-platform representation of a logger + */ public interface Logger { void log(Level level, String message, Exception e); diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml new file mode 100644 index 00000000..e4bae474 --- /dev/null +++ b/common/src/main/resources/config.yml @@ -0,0 +1,94 @@ +# ------------------------------ +# | HuskHomes Config | +# | Developed by William278 | +# ------------------------------ +# Configuration guide: https://github.com/WiIIiam278/HuskHomes2/wiki/Config-File + +language: 'en-gb' +check_for_updates: true +data_storage_options: + storage_type: 'SQLite' + mysql_credentials: + host: localhost + port: 3306 + database: HuskHomes + username: root + password: pa55w0rd + params: '?autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull' + connection_pool_options: + maximum_pool_size: 10 + minimum_idle: 10 + maximum_lifetime: 1800000 + keepalive_time: 0 + connection_timeout: 5000 + table_names: + player_data: 'huskhomes_player_data' + locations_data: 'huskhomes_location_data' + homes_data: 'huskhomes_home_data' + warps_data: 'huskhomes_warp_data' +general: + max_sethomes: 10 + auto_complete_player_names: true + home_limit_permission_stacking: false + teleport_warmup_time: 5 + teleport_warmup_display: 'ACTION_BAR' + teleport_request_expiry_time: 60 + allow_unicode_descriptions: true + enable_back_command: true + use_paperlib_if_available: true + sounds: + teleportation_complete: 'ENTITY_ENDERMAN_TELEPORT' + teleportation_warmup: 'BLOCK_NOTE_BLOCK_BANJO' + teleportation_cancelled: 'ENTITY_ITEM_BREAK' + lists: + private_homes_per_page: 10 + public_homes_per_page: 10 + warps_per_page: 10 + help_menu: + hide_commands_without_permission: true + hide_huskhomes_command: false +proxy_options: + enable_proxy_mode: false # todo Server ID is now fetched automatically by the implementor + cluster_id: '' + messenger_type: 'PLUGIN_MESSAGE' + redis_credentials: + host: localhost + port: 6379 + password: '' + use_ssl: false # todo tab complete cross-server options removed +warp_command: + enabled: true + permission_restrictions: + require_permission: false + format: 'huskhomes.warp.' + hide_restricted_warps: true +spawn_command: + enabled: true + force_teleport_on_login: false + bungee_network_spawn: + enabled: false + warp_name: 'Spawn' +random_teleport_command: + enabled: true + cooldown: 30 + range: 5000 +map_integration: + enabled: false + plugin: 'dynmap' + markers: + public_homes: + show: true + set_name: 'Public Homes' + warps: + show: true + set_name: 'Warps' +economy_integration: + enabled: false + free_home_slots: 5 + costs: + additional_home_slot: 100 + make_home_public: 50 + random_teleport: 20 + back: 0 +handle_vanished_players: true +config_version: 10 \ No newline at end of file diff --git a/common/src/main/resources/languages/en-gb.yml b/common/src/main/resources/languages/en-gb.yml new file mode 100644 index 00000000..b5962741 --- /dev/null +++ b/common/src/main/resources/languages/en-gb.yml @@ -0,0 +1,153 @@ +error_no_permission: '[Error:](#ff3300) [You do not have permission to execute that command.](#ff7e5e)' +error_no_last_position: '[Error:](#ff3300) [You have no last position to return to!](#ff7e5e)' +teleporting_last_position: '[Returning to your last position in](#00fb9a) [%1%](#00fb9a bold) [seconds](#00fb9a)' +teleporting_offline_player: '[Teleporting you to where %1% last logged out...](#00fb9a)' +teleporting_countdown_start: '[You will be teleported in](#00fb9a) [%1%](#00fb9a bold) [seconds](#00fb9a)' +teleporting_cancelled_movement: '[Teleportation cancelled; you moved!](#ff7e5e)' +teleporting_cancelled_damage: '[Teleportation cancelled; you took damage!](#ff7e5e)' +teleporting_complete: '[Teleportation complete!](#00fb9a)' +teleporting_action_bar_countdown: '[Teleporting in](#00fb9a) [%1%](#00fb9a bold)[...](#00fb9a)' +teleporting_action_bar_cancelled: '[Teleportation cancelled!](#ff7e5e)' +teleporting_please_stand_still: '[Teleportation will be cancelled if you move or take damage.](gray)' +home_deleted: '[Successfully deleted the home called](#00fb9a) [%1%](#00fb9a bold)' +home_deleted_other: '[Successfully deleted %1%''s home,](#00fb9a) [%2%](#00fb9a bold)' +warp_deleted: '[Successfully deleted the warp called](#00fb9a) [%1%](#00fb9a bold)' +error_home_invalid: '[Error:](#ff3300) [You do not have a home named "%1%"](#ff7e5e)' +error_warp_invalid: '[Error:](#ff3300) [There is no warp set named "%1%"](#ff7e5e)' +error_invalid_syntax: '[Error:](#ff3300) [Incorrect syntax. Usage: %1%](#ff7e5e)' +edit_home_title: '\n[Edit home details for](#00fb9a) [%1%](#00fb9a bold)[:](#00fb9a)' +edit_home_title_other: '\n[Edit home details for %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[:](#00fb9a)' +edit_home_options: '\n[[Teleport]](green show_text=&7Teleport to this home run_command=/huskhomes:home %1%.%2%) [[Delete]](red show_text=&7Delete this home run_command=/huskhomes:delhome %1%.%2%) [[Relocate]](blue show_text=&7Update this home''s location run_command=/huskhomes:edithome %1%.%2% location)\n[[Rename]](yellow show_text=&7Change the name of this home suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Edit Description]](gold show_text=&7Update the description of this home suggest_command=/huskhomes:edithome %1%.%2% description )\n' +edit_home_options_make_public: '\n[[Teleport]](green show_text=&7Teleport to this home run_command=/huskhomes:home %1%.%2%) [[Delete]](red show_text=&7Delete this home run_command=/huskhomes:delhome %1%.%2%) [[Relocate]](blue show_text=&7Update this home''s location run_command=/huskhomes:edithome %1%.%2% location)\n[[Rename]](yellow show_text=&7Change the name of this home suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Edit Description]](gold show_text=&7Update the description of this home suggest_command=/huskhomes:edithome %1%.%2% description ) [[Make Public]](dark_green show_text=&7Open this home to the public run_command=/huskhomes:edithome %1%.%2% public)\n' +edit_home_options_make_private: '\n[[Teleport]](green show_text=&7Teleport to this home run_command=/huskhomes:home %1%.%2%) [[Delete]](red show_text=&7Delete this home run_command=/huskhomes:delhome %1%.%2%) [[Relocate]](blue show_text=&7Update this home''s location run_command=/huskhomes:edithome %1%.%2% location)\n[[Rename]](yellow show_text=&7Change the name of this home suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Edit Description]](gold show_text=&7Update the description of this home suggest_command=/huskhomes:edithome %1%.%2% description ) [[Make Private]](dark_red show_text=&7Make this home private run_command=/huskhomes:edithome %1%.%2% private)\n' +edit_home_privacy_private: '• Access: &#ff7e5e&Private &7(Only you can use it)' +edit_home_privacy_private_other: '• Access: &#ff7e5e&Private &7(Only %1% can use it)' +edit_home_privacy_public: '• Access: &aPublic &7(Anyone can use it)' +edit_home_privacy_public_success: '[Successfully made the home,](#00fb9a) [%1%](#00fb9a bold)[, open to the public.](#00fb9a)' +edit_home_privacy_public_success_economy: '[Successfully made the home,](#00fb9a) [%1%](#00fb9a bold)[, open to the public for %2%.](#00fb9a)' +edit_home_privacy_private_success: '[Successfully made the home,](#00fb9a) [%1%](#00fb9a bold)[, private.](#00fb9a)' +error_edit_home_privacy_already_public: '[Error:](#ff3300) [This home is already set as public.](#ff7e5e)' +error_edit_home_privacy_already_private: '[Error:](#ff3300) [This home is already set as private.](#ff7e5e)' +error_edit_home_privacy_no_permission: '[Error:](#ff3300) [You do not have permission to make homes public.](#ff7e5e)' +error_edit_home_description_length: '[Error:](#ff3300) [Home descriptions must be less than 255 characters in length.](#ff7e5e)' +error_edit_home_description_characters: '[Error:](#ff3300) [Home descriptions may only contain alphanumeric (A-Z, 0-9) characters, hyphens (-) and underscores (_)](#ff7e5e)' +edit_home_update_location: '[Re-located](#00fb9a) [%1%](#00fb9a bold) [to your current position.](#00fb9a)' +edit_home_update_description: '[Changed the description for](#00fb9a) [%1%](#00fb9a bold) [to "%2%"](#00fb9a)' +edit_home_update_name: '[Successfully changed your home''s name: %1% →](#00fb9a) [%2%](#00fb9a bold)' +edit_warp_title: '\n[Edit details for the warp](#00fb9a) [%1%](#00fb9a bold)[:](#00fb9a)' +edit_warp_options: '\n[[Teleport]](green show_text=&7Teleport to this warp run_command=/huskhomes:warp %1%) [[Delete]](red show_text=&7Delete this warp run_command=/huskhomes:delwarp %1%) [[Relocate]](blue show_text=&7Update this warp''s location run_command=/huskhomes:editwarp %1% location)\n[[Rename]](yellow show_text=&7Change the name of this warp suggest_command=/huskhomes:editwarp %1% rename ) [[Edit Description]](gold show_text=&7Update this warp''s description suggest_command=/huskhomes:editwarp %1% description )\n' +error_edit_warp_description_length: '[Error:](#ff3300) [Warp descriptions must be less than 255 characters in length.](#ff7e5e)' +error_edit_warp_description_characters: '[Error:](#ff3300) [Warp descriptions may only contain alphanumeric (A-Z, 0-9) characters, hyphens (-) and underscores (_)](#ff7e5e)' +edit_warp_update_location: '[Re-located the warp](#00fb9a) [%1%](#00fb9a bold) [to your current position.](#00fb9a)' +edit_warp_update_description: '[Changed the description for the warp](#00fb9a) [%1%](#00fb9a bold) [to "%2%".](#00fb9a)' +edit_warp_update_name: '[Successfully changed a warp''s name: %1% →](#00fb9a) [%2%](#00fb9a bold)' +edit_description: '• Description: &7%1%' +edit_location: '• Location: &7%1%, %2%, %3%' +edit_world: '• World: &7%1%' +edit_server: '• Server: &7%1%' +edit_timestamp: '• Created: &7%1%' +error_no_homes_set: '[Error:](#ff3300) [You haven''t set any homes!](#ff7e5e)' +error_no_public_homes_set: '[Error:](#ff3300) [There aren''t any public homes set!](#ff7e5e)' +error_no_warps_set: '[Error:](#ff3300) [There aren''t any warps set!](#ff7e5e)' +private_home_list_page_top: '\n[%1%''s Homes:](#00fb9a) [(](#00fb9a)[%2%-%3%](#00fb9a bold) [of](#00fb9a) [%4%](#00fb9a bold)[)](#00fb9a)\n' +public_home_list_page_top: '\n[Public Homes:](#00fb9a) [(](#00fb9a)[%1%-%2%](#00fb9a bold) [of](#00fb9a) [%3%](#00fb9a bold)[)](#00fb9a)\n' +warp_list_page_top: '\n[Warps:](#00fb9a) [(](#00fb9a)[%1%-%2%](#00fb9a bold) [of](#00fb9a) [%3%](#00fb9a bold)[)](#00fb9a)\n' +error_public_home_invalid: '[Error:](#ff3300) [Could not find a public home owned by %1% called %2%.](#ff7e5e)' +error_set_home_invalid_characters: '[Error:](#ff3300) [Home names must be alphanumeric (A-Z, 0-9, -_)](#ff7e5e)' +error_set_home_invalid_length: '[Error:](#ff3300) [Home names can only contain up to 16 characters!](#ff7e5e)' +error_set_warp_invalid_characters: '[Error:](#ff3300) [Warp names must be alphanumeric (A-Z,0-9, -_)](#ff7e5e)' +error_set_warp_invalid_length: '[Error:](#ff3300) [Warp names can only contain up to 16 characters!](#ff7e5e)' +error_set_home_maximum_homes: '[Error:](#ff3300) [You can only set a maximum of %1% homes!](#ff7e5e)' +error_insufficient_funds: '[Error:](#ff3300) [You do not have enough money! (Cost: %1%)](#ff7e5e)' +set_home_spent_money: '[Successfully spent %1% to set an additional home!](gray)' +set_home_used_free_slots: '[You''ve used all of your free set home slots (%1%); setting additional homes will cost %2% each.](gray)' +set_home_success: '[Successfully set a new home called](#00fb9a) [%1%](#00fb9a bold)' +set_warp_success: '[Successfully set a new warp called](#00fb9a) [%1%](#00fb9a bold)' +error_set_home_name_taken: '[Error:](#ff3300) [You already have a home set with that name.](#ff7e5e)' +error_set_warp_name_taken: '[Error:](#ff3300) [There is already a warp set with that name.](#ff7e5e)' +set_spawn_success: '[Updated spawn position for this server to your current location.](#00fb9a)' +error_spawn_undefined: '[Error:](#ff3300) [There is no spawn position defined on this server.](#ff7e5e)' +error_tpa_no_pending_request: '[Error:](#ff3300) [You do not have a pending teleport request.](#ff7e5e)' +error_tpa_request_expired: '[Error:](#ff3300) [Your pending teleport request has expired.](#ff7e5e)' +error_player_not_found: '[Error:](#ff3300) [Could not find the player %1%.](#ff7e5e)' +return_by_death: '[Return to where you died?](gray) [/back](#00fb9a show_text=�fb9a&Click to return to where you died run_command=/back)' +teleport_request_options: '[Click an option:](gray) [[Accept]](#00fb9a show_text=�fb9a&Accept the teleport request; /tpaccept %1% run_command=/tpaccept %1%) [•](gray) [[Decline]](#ff7e5e show_text=&#ff7e5e&Decline the teleport request; /tpdeny %1% run_command=/tpdeny %1%)' +tpa_you_accepted: '[You accepted %1%''s teleport request](#00fb9a)' +tpa_you_declined: '[You declined %1%''s teleport request](#ff7e5e)' +tpa_has_accepted: '[%1% accepted your teleport request](#00fb9a)' +tpa_has_declined: '[%1% declined your teleport request](#ff7e5e)' +tpa_request_sent: '[You sent a teleport request to teleport to](#00fb9a) [%1%](#00fb9a bold)' +tpa_request_ask: '[%1%](#00fb9a bold) [has requested to teleport to you](#00fb9a)' +tpahere_request_sent: '[You sent a teleport request asking](#00fb9a) [%1%](#00fb9a bold) [to teleport to you](#00fb9a)' +tpahere_request_ask: '[%1%](#00fb9a bold) [has requested that you teleport to them](#00fb9a)' +error_tp_self: '[Error:](#ff3300) [You can''t teleport to yourself!](#ff7e5e)' +error_rtp_invalid_dimension: '[Error:](#ff3300) [You can only randomly teleport in the overworld!](#ff7e5e)' +error_rtp_cooldown: '[Error:](#ff3300) [You must wait %1% minutes before randomly teleporting again.](#ff7e5e)' +rtp_spent_money: '[Spent %1% to randomly teleport.](gray)' +back_spent_money: '[Spent %1% to return to your last position.](gray)' +error_command_disabled: '[Error:](#ff3300) [That command is disabled!](#ff7e5e)' +error_console_only: '[Error:](#ff3300) [That command can only be run from the server console.](#ff7e5e)' +error_tp_invalid_world: '[Error:](#ff3300) [Please specify a valid server world.](#ff7e5e)' +error_rtp_randomization_timeout: '[Error:](#ff3300) [Failed to find a safe random location to teleport you.](#ff7e5e)' +list_item_divider: ' [•](gray) ' +home_list_item: '[[%1%]](show_text=&7%3% run_command=/huskhomes:edithome %2%.%1%)' +public_home_list_item: '[[%1%]](show_text=�fb9a&%2%: &7%3% run_command=/huskhomes:phome %2%.%1%)' +warp_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:warp %1%)' +home_default_description: '%1%''s home' +warp_default_description: 'A publicly accessible warp' +delete_all_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete all of your homes?](#ff7e5e)\n[Once you confirm, it will not be possible to recover them.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/delhome all confirm)' +delete_all_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete every warp?](#ff7e5e)\n[Once you confirm, it will not be possible to recover them.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/delwarp all confirm)' +delete_all_homes_success: '[Successfully deleted your](#00fb9a) [%1%](#00fb9a bold) [home(s).](#00fb9a)' +delete_all_warps_success: '[Successfully deleted all](#00fb9a) [%1%](#00fb9a bold) [server warp(s).](#00fb9a)' +error_permission_restricted_warp: '[Error:](#ff3300) [You do not have permission to warp to %1%!](#ff7e5e)' +teleporting_complete_console: '[Console teleported you to %1%.](gray)' +spawn_warp_default_description: 'The /spawn position of the server' +error_invalid_page_number: '[Error:](#ff3300) [Please specify a valid page number.](#ff7e5e)' +page_options: '[←](gray show_text=&7View previous page run_command=%1%) [Viewing Page %2%/%3%](#00fb9a) [→](gray show_text=&7View next page run_command=%4%)' +page_options_min: '[Viewing Page %1%/%2%](#00fb9a) [→](gray show_text=&7View next page run_command=%3%)' +page_options_min_max: '[Viewing Page %1%/%2%](#00fb9a)' +page_options_max: '[←](gray show_text=&7View previous page run_command=%1%) [Viewing Page %2%/%3%](#00fb9a)' +page_no_items: '[(No items to display on this page)](gray show_text=&7Try a different page number)' +command_list_header: '\n[HuskHomes](#00fb9a bold) [| Command List](#00fb9a)' +command_list_item: '[/%1%](#00fb9a show_text=�fb9a&%2% suggest_command=/%1%) [•](white) [%3%](gray)' +error_invalid_on_arrival: '[Error:](#ff3300) [Failed to finish your teleportation as the target world could not be found.](#ff7e5e)' +tpignore_toggle_on: '[You are now](#00fb9a) [ignoring](#00fb9a bold) [incoming teleport requests.](#00fb9a) [(Click to toggle)](gray show_text=&7Click to listen for incoming teleport requests run_command=/huskhomes:tpignore)' +tpignore_toggle_off: '[You are now](#00fb9a) [listening](#00fb9a bold) [to any incoming teleport requests.](#00fb9a) [(Click to toggle)](gray show_text=&7Click to ignore incoming teleport requests run_command=/huskhomes:tpignore)' +tpignore_on_reminder: '[You are currently ignoring incoming teleport requests!](gray) [(Click to toggle)](gray show_text=&7Click to listen for incoming teleport requests run_command=/huskhomes:tpignore)' +error_ignoring_teleport_requests: '[Error:](#ff3300) [You are currently ignoring teleport requests!](#ff7e5e) [(Click to toggle)](#ff7e5e show_text=&#ff7e5e&Click to listen for incoming teleport requests run_command=/huskhomes:tpignore)' +error_no_offline_position: '[Error:](#ff3300) [Could not find where %1% last logged out.](#ff7e5e)' +error_invalid_player: '[Error:](#ff3300) [Please specify the name of a valid player!](#ff7e5e)' +error_no_homes_set_other: '[Error:](#ff3300) [%1% hasn''t set any homes!](#ff7e5e)' +error_home_invalid_other: '[Error:](#ff3300) [%1% doesn''t have a home set named "%2%"](#ff7e5e)' +error_edit_home_maximum_public_homes: '[Error:](#ff3300) [You can only make a maximum of %1% homes public.](#ff7e5e)' +tpaall_request_sent: '[You sent a teleport request asking everyone to teleport to you!](#00fb9a)' +error_no_other_online_players: '[Error:](#ff3300) [There are no other online players who could teleport to you.](#ff7e5e)' +teleporting_all_players: '[Teleporting all players to your position...](#00fb9a)' +error_illegal_target_coordinates: '[Error:](#ff3300) [Aborted teleport as it exceeds the possible game world limits.](#ff7e5e)' +home_command_description: 'Teleport to one of your homes' +sethome_command_description: 'Set a new home with given name' +delhome_command_description: 'Delete a home you previously set' +edithome_command_description: 'Edit one of your homes' +warp_command_description: 'Teleport to a warp' +setwarp_command_description: 'Set a new warp with given name' +delwarp_command_description: 'Delete a warp' +editwarp_command_description: 'Edit a warp' +back_command_description: 'Return to your previous position, or where you died' +homelist_command_description: 'Get a list of your homes' +warplist_command_description: 'View the list of warps' +publichomelist_command_description: 'View the list of public homes' +publichome_command_description: 'Teleport to a public home' +tp_command_description: 'Teleport to another player or location' +tphere_command_description: 'Teleport another player to you' +tpa_command_description: 'Request to teleport to another player' +tpahere_command_description: 'Request another player to teleport to you' +tpaccept_command_description: 'Accept a teleport request' +tpdeny_command_description: 'Deny a teleport request' +tpignore_command_description: 'Ignore incoming teleport requests' +tpoffline_command_description: 'Teleport to where a player was last online' +rtp_command_description: 'Teleport randomly into the wild' +spawn_command_description: 'Teleport to spawn' +setspawn_command_description: 'Set the spawn position' +tpaall_command_description: 'Request that everyone teleports to you' +tpall_command_description: 'Teleport everyone to your position' +huskhomes_command_description: 'View plugin information & reload configs' \ No newline at end of file