Adds nullability annotations among other things
Adds nullability annotations for all methods Fixes some nullability problems and inconsistencies Gets rid of RelativeBlockVector's inner class Changes RelativeBlockVector to a record Simplifies FromTheEndTeleportation's storage, and makes it into a minimal record Removes the putStringInList method Gets rid of some primitive list usage Fixes some incorrect method accessibility Removes some redundancy in PortalOption
This commit is contained in:
		@@ -35,6 +35,8 @@ import org.bukkit.plugin.PluginManager;
 | 
			
		||||
import org.bukkit.plugin.java.JavaPlugin;
 | 
			
		||||
import org.bukkit.plugin.java.JavaPluginLoader;
 | 
			
		||||
import org.bukkit.scheduler.BukkitScheduler;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
@@ -112,7 +114,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @param version <p>The version of the new update available</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void setUpdateAvailable(String version) {
 | 
			
		||||
    public static void setUpdateAvailable(@NotNull String version) {
 | 
			
		||||
        updateAvailable = version;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -121,6 +123,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The version number if an update is available. Null otherwise</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static String getUpdateAvailable() {
 | 
			
		||||
        return updateAvailable;
 | 
			
		||||
    }
 | 
			
		||||
@@ -130,6 +133,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>An instance of this plugin, or null if not instantiated</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Stargate getInstance() {
 | 
			
		||||
        return stargate;
 | 
			
		||||
    }
 | 
			
		||||
@@ -139,7 +143,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @param request <p>The request to add</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void addBlockChangeRequest(BlockChangeRequest request) {
 | 
			
		||||
    public static void addBlockChangeRequest(@Nullable BlockChangeRequest request) {
 | 
			
		||||
        if (request != null) {
 | 
			
		||||
            blockChangeRequestQueue.add(request);
 | 
			
		||||
        }
 | 
			
		||||
@@ -150,6 +154,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A block change request queue</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Queue<BlockChangeRequest> getBlockChangeRequestQueue() {
 | 
			
		||||
        return blockChangeRequestQueue;
 | 
			
		||||
    }
 | 
			
		||||
@@ -159,6 +164,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The sender for sending messages to players</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static MessageSender getMessageSender() {
 | 
			
		||||
        return stargateConfig.getMessageSender();
 | 
			
		||||
    }
 | 
			
		||||
@@ -168,6 +174,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The object containing gate configuration values</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static StargateGateConfig getGateConfig() {
 | 
			
		||||
        return stargateConfig.getStargateGateConfig();
 | 
			
		||||
    }
 | 
			
		||||
@@ -177,6 +184,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This plugin's version</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static String getPluginVersion() {
 | 
			
		||||
        return pluginVersion;
 | 
			
		||||
    }
 | 
			
		||||
@@ -186,6 +194,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The logger</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Logger getConsoleLogger() {
 | 
			
		||||
        return logger;
 | 
			
		||||
    }
 | 
			
		||||
@@ -206,7 +215,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     * @param route   <p>The class name/route where something happened</p>
 | 
			
		||||
     * @param message <p>A message describing what happened</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void debug(String route, String message) {
 | 
			
		||||
    public static void debug(@NotNull String route, @NotNull String message) {
 | 
			
		||||
        if (stargateConfig == null || stargateConfig.isNotLoaded() || stargateConfig.isDebuggingEnabled()) {
 | 
			
		||||
            logger.info("[Stargate::" + route + "] " + message);
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -219,7 +228,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @param message <p>The message to log</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void logInfo(String message) {
 | 
			
		||||
    public static void logInfo(@NotNull String message) {
 | 
			
		||||
        log(Level.INFO, message);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -228,7 +237,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @param message <p>The message to log</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void logSevere(String message) {
 | 
			
		||||
    public static void logSevere(@NotNull String message) {
 | 
			
		||||
        log(Level.SEVERE, message);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -237,7 +246,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @param message <p>The message to log</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void logWarning(String message) {
 | 
			
		||||
    public static void logWarning(@NotNull String message) {
 | 
			
		||||
        log(Level.WARNING, message);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -247,7 +256,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     * @param severity <p>The severity of the event triggering the message</p>
 | 
			
		||||
     * @param message  <p>The message to log</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void log(Level severity, String message) {
 | 
			
		||||
    private static void log(@NotNull Level severity, @NotNull String message) {
 | 
			
		||||
        if (logger == null) {
 | 
			
		||||
            logger = Bukkit.getLogger();
 | 
			
		||||
        }
 | 
			
		||||
@@ -261,6 +270,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The folder for storing the portal database</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static String getPortalFolder() {
 | 
			
		||||
        return stargateConfig.getPortalFolder();
 | 
			
		||||
    }
 | 
			
		||||
@@ -272,6 +282,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The folder storing gate files</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static String getGateFolder() {
 | 
			
		||||
        return stargateConfig.getGateFolder();
 | 
			
		||||
    }
 | 
			
		||||
@@ -281,6 +292,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The default network</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static String getDefaultNetwork() {
 | 
			
		||||
        return stargateConfig.getStargateGateConfig().getDefaultPortalNetwork();
 | 
			
		||||
    }
 | 
			
		||||
@@ -293,7 +305,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     * @param name <p>The name/key of the string to get</p>
 | 
			
		||||
     * @return <p>The full translated string</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static String getString(String name) {
 | 
			
		||||
    public static @NotNull String getString(@NotNull String name) {
 | 
			
		||||
        return stargateConfig.getLanguageLoader().getString(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -305,7 +317,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     * @param name <p>The name/key of the string to get</p>
 | 
			
		||||
     * @return <p>The full string in the backup language (English)</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static String getBackupString(String name) {
 | 
			
		||||
    public static @NotNull String getBackupString(@NotNull String name) {
 | 
			
		||||
        return stargateConfig.getLanguageLoader().getBackupString(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -317,7 +329,8 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     * @param value  <p>The replacement value</p>
 | 
			
		||||
     * @return <p>The input string with the search replaced with value</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static String replaceVars(String input, String search, String value) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static String replacePlaceholders(@NotNull String input, @NotNull String search, @NotNull String value) {
 | 
			
		||||
        return input.replace(search, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -326,6 +339,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A plugin manager</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static PluginManager getPluginManager() {
 | 
			
		||||
        return pluginManager;
 | 
			
		||||
    }
 | 
			
		||||
@@ -335,6 +349,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The object containing economy config values</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static EconomyConfig getEconomyConfig() {
 | 
			
		||||
        return stargateConfig.getEconomyConfig();
 | 
			
		||||
    }
 | 
			
		||||
@@ -344,6 +359,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The raw configuration</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public FileConfiguration getConfiguration() {
 | 
			
		||||
        return this.configuration;
 | 
			
		||||
    }
 | 
			
		||||
@@ -354,8 +370,8 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
        this.configuration = new StargateYamlConfiguration();
 | 
			
		||||
        try {
 | 
			
		||||
            this.configuration.load(new File(getDataFolder(), CONFIG_FILE_NAME));
 | 
			
		||||
        } catch (IOException | InvalidConfigurationException e) {
 | 
			
		||||
            logSevere("Unable to load the configuration! Message: " + e.getMessage());
 | 
			
		||||
        } catch (IOException | InvalidConfigurationException exception) {
 | 
			
		||||
            logSevere("Unable to load the configuration! Message: " + exception.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -364,8 +380,8 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
        super.saveConfig();
 | 
			
		||||
        try {
 | 
			
		||||
            this.configuration.save(new File(getDataFolder(), CONFIG_FILE_NAME));
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            logSevere("Unable to save the configuration! Message: " + e.getMessage());
 | 
			
		||||
        } catch (IOException exception) {
 | 
			
		||||
            logSevere("Unable to save the configuration! Message: " + exception.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -390,8 +406,8 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
        this.configuration = new StargateYamlConfiguration();
 | 
			
		||||
        try {
 | 
			
		||||
            this.configuration.load(new File(getDataFolder(), CONFIG_FILE_NAME));
 | 
			
		||||
        } catch (IOException | InvalidConfigurationException e) {
 | 
			
		||||
            getLogger().log(Level.SEVERE, e.getMessage());
 | 
			
		||||
        } catch (IOException | InvalidConfigurationException exception) {
 | 
			
		||||
            getLogger().log(Level.SEVERE, exception.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
        this.configuration.options().copyDefaults(true);
 | 
			
		||||
 | 
			
		||||
@@ -470,6 +486,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The chunk unload queue</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Queue<ChunkUnloadRequest> getChunkUnloadQueue() {
 | 
			
		||||
        return chunkUnloadQueue;
 | 
			
		||||
    }
 | 
			
		||||
@@ -479,7 +496,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @param request <p>The new chunk unload request to add</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void addChunkUnloadRequest(ChunkUnloadRequest request) {
 | 
			
		||||
    public static void addChunkUnloadRequest(@NotNull ChunkUnloadRequest request) {
 | 
			
		||||
        chunkUnloadQueue.removeIf((item) -> item.getChunkToUnload().equals(request.getChunkToUnload()));
 | 
			
		||||
        chunkUnloadQueue.add(request);
 | 
			
		||||
    }
 | 
			
		||||
@@ -489,6 +506,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The stargate configuration</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static StargateConfig getStargateConfig() {
 | 
			
		||||
        return stargateConfig;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -26,9 +26,11 @@ public class CommandAbout implements CommandExecutor {
 | 
			
		||||
        ChatColor highlightColor = ChatColor.GREEN;
 | 
			
		||||
 | 
			
		||||
        try (InputStream inputStream = Stargate.class.getResourceAsStream("/messages/about.md")) {
 | 
			
		||||
            String aboutMessageString = FileHelper.readStreamToString(inputStream);
 | 
			
		||||
            BaseComponent[] component = MineDown.parse(aboutMessageString);
 | 
			
		||||
            commandSender.spigot().sendMessage(component);
 | 
			
		||||
            if (inputStream != null) {
 | 
			
		||||
                String aboutMessageString = FileHelper.readStreamToString(inputStream);
 | 
			
		||||
                BaseComponent[] component = MineDown.parse(aboutMessageString);
 | 
			
		||||
                commandSender.spigot().sendMessage(component);
 | 
			
		||||
            }
 | 
			
		||||
        } catch (IOException ioException) {
 | 
			
		||||
            commandSender.sendMessage("Internal error");
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.configuration.file.FileConfiguration;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@@ -65,7 +66,8 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param commandSender  <p>The command sender that changed the value</p>
 | 
			
		||||
     * @param value          <p>The new value of the config option</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void updateConfigValue(ConfigOption selectedOption, CommandSender commandSender, String value) {
 | 
			
		||||
    private void updateConfigValue(@NotNull ConfigOption selectedOption, @NotNull CommandSender commandSender,
 | 
			
		||||
                                   @NotNull String value) {
 | 
			
		||||
        FileConfiguration configuration = Stargate.getInstance().getConfiguration();
 | 
			
		||||
 | 
			
		||||
        //Validate any sign colors
 | 
			
		||||
@@ -119,7 +121,8 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param value          <p>The new value of the config option</p>
 | 
			
		||||
     * @param configuration  <p>The configuration file to save to</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void updateBooleanConfigValue(ConfigOption selectedOption, String value, FileConfiguration configuration) {
 | 
			
		||||
    private void updateBooleanConfigValue(@NotNull ConfigOption selectedOption, @NotNull String value,
 | 
			
		||||
                                          @NotNull FileConfiguration configuration) {
 | 
			
		||||
        boolean newValue = Boolean.parseBoolean(value);
 | 
			
		||||
        if (selectedOption == ConfigOption.ENABLE_BUNGEE && newValue != Stargate.getGateConfig().enableBungee()) {
 | 
			
		||||
            Stargate.getStargateConfig().startStopBungeeListener(newValue);
 | 
			
		||||
@@ -135,7 +138,8 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param commandSender  <p>The command sender that changed the value</p>
 | 
			
		||||
     * @param value          <p>The new value of the config option</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void updateStringConfigValue(ConfigOption selectedOption, CommandSender commandSender, String value) {
 | 
			
		||||
    private void updateStringConfigValue(@NotNull ConfigOption selectedOption, @NotNull CommandSender commandSender,
 | 
			
		||||
                                         @NotNull String value) {
 | 
			
		||||
        if (selectedOption == ConfigOption.GATE_FOLDER || selectedOption == ConfigOption.PORTAL_FOLDER ||
 | 
			
		||||
                selectedOption == ConfigOption.DEFAULT_GATE_NETWORK) {
 | 
			
		||||
            if (value.contains("../") || value.contains("..\\")) {
 | 
			
		||||
@@ -161,7 +165,8 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param commandSender  <p>The command sender that changed the value</p>
 | 
			
		||||
     * @param arguments      <p>The arguments for the new config option</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void updateListConfigValue(ConfigOption selectedOption, CommandSender commandSender, String[] arguments) {
 | 
			
		||||
    private void updateListConfigValue(@NotNull ConfigOption selectedOption, @NotNull CommandSender commandSender,
 | 
			
		||||
                                       @NotNull String[] arguments) {
 | 
			
		||||
        FileConfiguration configuration = Stargate.getInstance().getConfiguration();
 | 
			
		||||
 | 
			
		||||
        if (selectedOption == ConfigOption.PER_SIGN_COLORS) {
 | 
			
		||||
@@ -190,7 +195,8 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param arguments     <p>The arguments given by the user</p>
 | 
			
		||||
     * @return <p>The per-sign color string to update with, or null if the input was invalid</p>
 | 
			
		||||
     */
 | 
			
		||||
    private String parsePerSignColorInput(CommandSender commandSender, String[] arguments) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private String parsePerSignColorInput(@NotNull CommandSender commandSender, @NotNull String[] arguments) {
 | 
			
		||||
        //Make sure the sign type is an actual sign
 | 
			
		||||
        if (Material.matchMaterial(arguments[1] + "_SIGN") == null) {
 | 
			
		||||
            Stargate.getMessageSender().sendErrorMessage(commandSender, "The given sign type is invalid");
 | 
			
		||||
@@ -199,7 +205,8 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
        String colorString = arguments[1] + ":";
 | 
			
		||||
 | 
			
		||||
        //Validate the colors given by the user
 | 
			
		||||
        String[] errorMessage = new String[]{"The given main sign color is invalid!", "The given highlight sign color is invalid!"};
 | 
			
		||||
        String[] errorMessage = new String[]{"The given main sign color is invalid!", "The given highlight sign color " +
 | 
			
		||||
                "is invalid!"};
 | 
			
		||||
        String[] newColors = new String[2];
 | 
			
		||||
        for (int i = 0; i < 2; i++) {
 | 
			
		||||
            if (validatePerSignColor(arguments[i + 2])) {
 | 
			
		||||
@@ -220,9 +227,11 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param colorString   <p>The new color string to replace any previous value with</p>
 | 
			
		||||
     * @param configuration <p>The file configuration to update with the new per-sign colors</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void updatePerSignColors(String signType, String colorString, FileConfiguration configuration) {
 | 
			
		||||
    private void updatePerSignColors(@NotNull String signType, @NotNull String colorString,
 | 
			
		||||
                                     @NotNull FileConfiguration configuration) {
 | 
			
		||||
        List<String> newColorStrings = new ArrayList<>();
 | 
			
		||||
        List<?> oldColors = (List<?>) Stargate.getStargateConfig().getConfigOptionsReference().get(ConfigOption.PER_SIGN_COLORS);
 | 
			
		||||
        List<?> oldColors = (List<?>) Stargate.getStargateConfig().getConfigOptionsReference().get(
 | 
			
		||||
                ConfigOption.PER_SIGN_COLORS);
 | 
			
		||||
        for (Object object : oldColors) {
 | 
			
		||||
            newColorStrings.add(String.valueOf(object));
 | 
			
		||||
        }
 | 
			
		||||
@@ -239,7 +248,7 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param color <p>The color chosen by the user</p>
 | 
			
		||||
     * @return <p>True if the given color is valid</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean validatePerSignColor(String color) {
 | 
			
		||||
    private boolean validatePerSignColor(@NotNull String color) {
 | 
			
		||||
        ChatColor newHighlightColor = parseColor(color);
 | 
			
		||||
        return newHighlightColor != null || color.equalsIgnoreCase("default") ||
 | 
			
		||||
                color.equalsIgnoreCase("inverted");
 | 
			
		||||
@@ -251,7 +260,7 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param selectedOption <p>The config option that was changed</p>
 | 
			
		||||
     * @param commandSender  <p>The command sender that executed the config command</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void saveAndReload(ConfigOption selectedOption, CommandSender commandSender) {
 | 
			
		||||
    private void saveAndReload(@NotNull ConfigOption selectedOption, @NotNull CommandSender commandSender) {
 | 
			
		||||
        //Save the config file and reload if necessary
 | 
			
		||||
        Stargate.getInstance().saveConfig();
 | 
			
		||||
 | 
			
		||||
@@ -268,7 +277,8 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param commandSender  <p>The command sender to alert if the color is invalid</p>
 | 
			
		||||
     * @param value          <p>The new option value</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean registerColor(ConfigOption selectedOption, String value, CommandSender commandSender) {
 | 
			
		||||
    private boolean registerColor(@NotNull ConfigOption selectedOption, @NotNull String value,
 | 
			
		||||
                                  @NotNull CommandSender commandSender) {
 | 
			
		||||
        ChatColor parsedColor = parseColor(value);
 | 
			
		||||
        if (parsedColor == null) {
 | 
			
		||||
            commandSender.sendMessage(ChatColor.RED + "Invalid color given");
 | 
			
		||||
@@ -291,7 +301,8 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param value <p>The value to parse</p>
 | 
			
		||||
     * @return <p>The parsed color or null</p>
 | 
			
		||||
     */
 | 
			
		||||
    private ChatColor parseColor(String value) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private ChatColor parseColor(@NotNull String value) {
 | 
			
		||||
        try {
 | 
			
		||||
            return ChatColor.of(value.toUpperCase());
 | 
			
		||||
        } catch (IllegalArgumentException | NullPointerException ignored) {
 | 
			
		||||
@@ -307,7 +318,9 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param value          <p>The value given</p>
 | 
			
		||||
     * @return <p>An integer, or null if it was invalid</p>
 | 
			
		||||
     */
 | 
			
		||||
    private Integer getInteger(CommandSender commandSender, ConfigOption selectedOption, String value) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private Integer getInteger(@NotNull CommandSender commandSender, @NotNull ConfigOption selectedOption,
 | 
			
		||||
                               @NotNull String value) {
 | 
			
		||||
        try {
 | 
			
		||||
            int intValue = Integer.parseInt(value);
 | 
			
		||||
 | 
			
		||||
@@ -331,7 +344,9 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param value          <p>The value given</p>
 | 
			
		||||
     * @return <p>A double, or null if it was invalid</p>
 | 
			
		||||
     */
 | 
			
		||||
    private Double getDouble(CommandSender commandSender, ConfigOption selectedOption, String value) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private Double getDouble(@NotNull CommandSender commandSender, @NotNull ConfigOption selectedOption,
 | 
			
		||||
                             @NotNull String value) {
 | 
			
		||||
        try {
 | 
			
		||||
            double doubleValue = Double.parseDouble(value);
 | 
			
		||||
 | 
			
		||||
@@ -353,7 +368,7 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param commandSender <p>The command sender initiating the reload</p>
 | 
			
		||||
     * @param configOption  <p>The changed config option</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void reloadIfNecessary(CommandSender commandSender, ConfigOption configOption) {
 | 
			
		||||
    private void reloadIfNecessary(@NotNull CommandSender commandSender, @NotNull ConfigOption configOption) {
 | 
			
		||||
        if (ConfigTag.requiresFullReload(configOption)) {
 | 
			
		||||
            //Reload everything
 | 
			
		||||
            Stargate.getStargateConfig().reload(commandSender);
 | 
			
		||||
@@ -391,7 +406,7 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param sender <p>The command sender that sent the command</p>
 | 
			
		||||
     * @param option <p>The config option to print information about</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void printConfigOptionValue(CommandSender sender, ConfigOption option) {
 | 
			
		||||
    private void printConfigOptionValue(@NotNull CommandSender sender, @NotNull ConfigOption option) {
 | 
			
		||||
        Object value = Stargate.getStargateConfig().getConfigOptions().get(option);
 | 
			
		||||
        sender.sendMessage(getOptionDescription(option));
 | 
			
		||||
        sender.sendMessage(ChatColor.GREEN + "Current value: " + ChatColor.GOLD + value);
 | 
			
		||||
@@ -402,7 +417,7 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     *
 | 
			
		||||
     * @param sender <p>The command sender to display the config list to</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void displayConfigValues(CommandSender sender) {
 | 
			
		||||
    private void displayConfigValues(@NotNull CommandSender sender) {
 | 
			
		||||
        sender.sendMessage(ChatColor.GREEN + Stargate.getBackupString("prefix") + ChatColor.GOLD +
 | 
			
		||||
                "Config values:");
 | 
			
		||||
        for (ConfigOption option : ConfigOption.values()) {
 | 
			
		||||
@@ -416,7 +431,8 @@ public class CommandConfig implements CommandExecutor {
 | 
			
		||||
     * @param option <p>The option to describe</p>
 | 
			
		||||
     * @return <p>A string describing the config option</p>
 | 
			
		||||
     */
 | 
			
		||||
    private String getOptionDescription(ConfigOption option) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private String getOptionDescription(@NotNull ConfigOption option) {
 | 
			
		||||
        Object defaultValue = option.getDefaultValue();
 | 
			
		||||
        String stringValue = String.valueOf(defaultValue);
 | 
			
		||||
        if (option.getDataType() == OptionDataType.STRING_LIST) {
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,9 @@ public class ConfigTabCompleter implements TabCompleter {
 | 
			
		||||
     * @param typedText      <p>The beginning of the typed text, for filtering matching results</p>
 | 
			
		||||
     * @return <p>Some or all of the valid values for the option</p>
 | 
			
		||||
     */
 | 
			
		||||
    private List<String> getPossibleOptionValues(ConfigOption selectedOption, String typedText) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private List<String> getPossibleOptionValues(@NotNull ConfigOption selectedOption,
 | 
			
		||||
                                                 @NotNull String typedText) {
 | 
			
		||||
        switch (selectedOption) {
 | 
			
		||||
            case LANGUAGE:
 | 
			
		||||
                //Return available languages
 | 
			
		||||
@@ -71,7 +73,7 @@ public class ConfigTabCompleter implements TabCompleter {
 | 
			
		||||
            case DEFAULT_GATE_NETWORK:
 | 
			
		||||
                //Just return the default value as most values should be possible
 | 
			
		||||
                if (typedText.trim().isEmpty()) {
 | 
			
		||||
                    return putStringInList((String) selectedOption.getDefaultValue());
 | 
			
		||||
                    return List.of((String) selectedOption.getDefaultValue());
 | 
			
		||||
                } else {
 | 
			
		||||
                    return new ArrayList<>();
 | 
			
		||||
                }
 | 
			
		||||
@@ -114,7 +116,9 @@ public class ConfigTabCompleter implements TabCompleter {
 | 
			
		||||
     * @param args           <p>The arguments given by the user</p>
 | 
			
		||||
     * @return <p>Some or all of the valid values for the option</p>
 | 
			
		||||
     */
 | 
			
		||||
    private List<String> getPossibleStringListOptionValues(ConfigOption selectedOption, String[] args) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private List<String> getPossibleStringListOptionValues(@NotNull ConfigOption selectedOption,
 | 
			
		||||
                                                           @NotNull String[] args) {
 | 
			
		||||
        if (selectedOption == ConfigOption.PER_SIGN_COLORS) {
 | 
			
		||||
            return getPerSignColorCompletion(args);
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -128,7 +132,8 @@ public class ConfigTabCompleter implements TabCompleter {
 | 
			
		||||
     * @param args <p>The arguments given by the user</p>
 | 
			
		||||
     * @return <p>The options to give the user</p>
 | 
			
		||||
     */
 | 
			
		||||
    private List<String> getPerSignColorCompletion(String[] args) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private List<String> getPerSignColorCompletion(@NotNull String[] args) {
 | 
			
		||||
        if (args.length < 3) {
 | 
			
		||||
            return filterMatchingStartsWith(signTypes, args[1]);
 | 
			
		||||
        } else if (args.length < 4) {
 | 
			
		||||
@@ -139,18 +144,6 @@ public class ConfigTabCompleter implements TabCompleter {
 | 
			
		||||
        return new ArrayList<>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Puts a single string value into a string list
 | 
			
		||||
     *
 | 
			
		||||
     * @param value <p>The string to make into a list</p>
 | 
			
		||||
     * @return <p>A list containing the string value</p>
 | 
			
		||||
     */
 | 
			
		||||
    private List<String> putStringInList(String value) {
 | 
			
		||||
        List<String> list = new ArrayList<>();
 | 
			
		||||
        list.add(value);
 | 
			
		||||
        return list;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Initializes all lists of auto-completable values
 | 
			
		||||
     */
 | 
			
		||||
@@ -200,6 +193,7 @@ public class ConfigTabCompleter implements TabCompleter {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The available chat colors</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private List<ChatColor> getChatColors() {
 | 
			
		||||
        List<ChatColor> chatColors = new ArrayList<>();
 | 
			
		||||
        char[] colors = new char[]{'a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
 | 
			
		||||
 
 | 
			
		||||
@@ -17,8 +17,9 @@ import java.util.List;
 | 
			
		||||
public class StarGateTabCompleter implements TabCompleter {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public @Nullable List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command,
 | 
			
		||||
                                                @NotNull String s, @NotNull String[] args) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
 | 
			
		||||
                                      @NotNull String[] args) {
 | 
			
		||||
        if (args.length == 1) {
 | 
			
		||||
            List<String> commands = getAvailableCommands(commandSender);
 | 
			
		||||
            List<String> matchingCommands = new ArrayList<>();
 | 
			
		||||
@@ -42,7 +43,8 @@ public class StarGateTabCompleter implements TabCompleter {
 | 
			
		||||
     * @param commandSender <p>The command sender to get available commands for</p>
 | 
			
		||||
     * @return <p>The commands available to the command sender</p>
 | 
			
		||||
     */
 | 
			
		||||
    private List<String> getAvailableCommands(CommandSender commandSender) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private List<String> getAvailableCommands(@NotNull CommandSender commandSender) {
 | 
			
		||||
        List<String> commands = new ArrayList<>();
 | 
			
		||||
        commands.add("about");
 | 
			
		||||
        if (!(commandSender instanceof Player player) || player.hasPermission("stargate.admin.reload")) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,8 @@
 | 
			
		||||
package net.knarcraft.stargate.config;
 | 
			
		||||
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A ConfigOption represents one of the available config options
 | 
			
		||||
 */
 | 
			
		||||
@@ -209,7 +212,7 @@ public enum ConfigOption {
 | 
			
		||||
     * @param description  <p>The description of what this config option does</p>
 | 
			
		||||
     * @param defaultValue <p>The default value of this config option</p>
 | 
			
		||||
     */
 | 
			
		||||
    ConfigOption(String configNode, String description, Object defaultValue) {
 | 
			
		||||
    ConfigOption(@NotNull String configNode, @NotNull String description, @NotNull Object defaultValue) {
 | 
			
		||||
        this.configNode = configNode;
 | 
			
		||||
        this.description = description;
 | 
			
		||||
        this.defaultValue = defaultValue;
 | 
			
		||||
@@ -235,7 +238,7 @@ public enum ConfigOption {
 | 
			
		||||
     * @param name <p>The name of the config option to get</p>
 | 
			
		||||
     * @return <p>The corresponding config option, or null if the name is invalid</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static ConfigOption getByName(String name) {
 | 
			
		||||
    public static @Nullable ConfigOption getByName(@NotNull String name) {
 | 
			
		||||
        for (ConfigOption option : ConfigOption.values()) {
 | 
			
		||||
            if (option.getName().equalsIgnoreCase(name)) {
 | 
			
		||||
                return option;
 | 
			
		||||
@@ -249,7 +252,7 @@ public enum ConfigOption {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The name of this config option</p>
 | 
			
		||||
     */
 | 
			
		||||
    public String getName() {
 | 
			
		||||
    public @NotNull String getName() {
 | 
			
		||||
        if (!this.configNode.contains(".")) {
 | 
			
		||||
            return this.configNode;
 | 
			
		||||
        }
 | 
			
		||||
@@ -262,7 +265,7 @@ public enum ConfigOption {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The data type used</p>
 | 
			
		||||
     */
 | 
			
		||||
    public OptionDataType getDataType() {
 | 
			
		||||
    public @NotNull OptionDataType getDataType() {
 | 
			
		||||
        return this.dataType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -271,7 +274,7 @@ public enum ConfigOption {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This config option's config node</p>
 | 
			
		||||
     */
 | 
			
		||||
    public String getConfigNode() {
 | 
			
		||||
    public @NotNull String getConfigNode() {
 | 
			
		||||
        return this.configNode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -280,7 +283,7 @@ public enum ConfigOption {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The description of this config option</p>
 | 
			
		||||
     */
 | 
			
		||||
    public String getDescription() {
 | 
			
		||||
    public @NotNull String getDescription() {
 | 
			
		||||
        return this.description;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -289,7 +292,7 @@ public enum ConfigOption {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This config option's default value</p>
 | 
			
		||||
     */
 | 
			
		||||
    public Object getDefaultValue() {
 | 
			
		||||
    public @NotNull Object getDefaultValue() {
 | 
			
		||||
        return this.defaultValue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,25 +1,38 @@
 | 
			
		||||
package net.knarcraft.stargate.config;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A config tag groups config values by a property
 | 
			
		||||
 */
 | 
			
		||||
public enum ConfigTag {
 | 
			
		||||
 | 
			
		||||
    COLOR(new ConfigOption[]{ConfigOption.FREE_GATES_COLOR, ConfigOption.MAIN_SIGN_COLOR,
 | 
			
		||||
            ConfigOption.HIGHLIGHT_SIGN_COLOR, ConfigOption.PER_SIGN_COLORS}),
 | 
			
		||||
    FOLDER(new ConfigOption[]{ConfigOption.GATE_FOLDER, ConfigOption.PORTAL_FOLDER}),
 | 
			
		||||
    DYNMAP(new ConfigOption[]{ConfigOption.ENABLE_DYNMAP, ConfigOption.DYNMAP_ICONS_DEFAULT_HIDDEN});
 | 
			
		||||
    /**
 | 
			
		||||
     * Color-related configuration options
 | 
			
		||||
     */
 | 
			
		||||
    COLOR(Set.of(ConfigOption.FREE_GATES_COLOR, ConfigOption.MAIN_SIGN_COLOR, ConfigOption.HIGHLIGHT_SIGN_COLOR,
 | 
			
		||||
            ConfigOption.PER_SIGN_COLORS)),
 | 
			
		||||
 | 
			
		||||
    private final ConfigOption[] taggedOptions;
 | 
			
		||||
    /**
 | 
			
		||||
     * Folder-altering configuration options
 | 
			
		||||
     */
 | 
			
		||||
    FOLDER(Set.of(ConfigOption.GATE_FOLDER, ConfigOption.PORTAL_FOLDER)),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Dynmap-related configuration options
 | 
			
		||||
     */
 | 
			
		||||
    DYNMAP(Set.of(ConfigOption.ENABLE_DYNMAP, ConfigOption.DYNMAP_ICONS_DEFAULT_HIDDEN));
 | 
			
		||||
 | 
			
		||||
    private final Set<ConfigOption> taggedOptions;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Instantiates a new config tag
 | 
			
		||||
     *
 | 
			
		||||
     * @param taggedOptions <p>The config options included in this tag</p>
 | 
			
		||||
     */
 | 
			
		||||
    ConfigTag(ConfigOption[] taggedOptions) {
 | 
			
		||||
    ConfigTag(@NotNull Set<ConfigOption> taggedOptions) {
 | 
			
		||||
        this.taggedOptions = taggedOptions;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -29,8 +42,8 @@ public enum ConfigTag {
 | 
			
		||||
     * @param option <p>The config option to check</p>
 | 
			
		||||
     * @return <p>True of the config option is tagged</p>
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isTagged(ConfigOption option) {
 | 
			
		||||
        return Arrays.stream(taggedOptions).anyMatch((item) -> item == option);
 | 
			
		||||
    public boolean isTagged(@NotNull ConfigOption option) {
 | 
			
		||||
        return taggedOptions.contains(option);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -39,7 +52,7 @@ public enum ConfigTag {
 | 
			
		||||
     * @param configOption <p>The config option to check</p>
 | 
			
		||||
     * @return <p>True if changing the config option requires a "reload of colors" to take effect</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean requiresColorReload(ConfigOption configOption) {
 | 
			
		||||
    public static boolean requiresColorReload(@NotNull ConfigOption configOption) {
 | 
			
		||||
        return (COLOR.isTagged(configOption) && configOption != ConfigOption.FREE_GATES_COLOR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -49,7 +62,7 @@ public enum ConfigTag {
 | 
			
		||||
     * @param option <p>The config option to check</p>
 | 
			
		||||
     * @return <p>True if changing the config option requires a full reload to take effect</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean requiresFullReload(ConfigOption option) {
 | 
			
		||||
    public static boolean requiresFullReload(@NotNull ConfigOption option) {
 | 
			
		||||
        return FOLDER.isTagged(option);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -59,7 +72,7 @@ public enum ConfigTag {
 | 
			
		||||
     * @param configOption <p>The config option to check</p>
 | 
			
		||||
     * @return <p>True if changing the config option requires a reload of all dynmap markers</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean requiresDynmapReload(ConfigOption configOption) {
 | 
			
		||||
    public static boolean requiresDynmapReload(@NotNull ConfigOption configOption) {
 | 
			
		||||
        return DYNMAP.isTagged(configOption);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -69,7 +82,7 @@ public enum ConfigTag {
 | 
			
		||||
     * @param option <p>The config option to check</p>
 | 
			
		||||
     * @return <p>True if changing the config option requires a portal reload to take effect</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean requiresPortalReload(ConfigOption option) {
 | 
			
		||||
    public static boolean requiresPortalReload(@NotNull ConfigOption option) {
 | 
			
		||||
        return COLOR.isTagged(option) || FOLDER.isTagged(option) || option == ConfigOption.VERIFY_PORTALS;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -79,7 +92,7 @@ public enum ConfigTag {
 | 
			
		||||
     * @param option <p>The config option to check</p>
 | 
			
		||||
     * @return <p>True if the language loader requires a reload</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean requiresLanguageReload(ConfigOption option) {
 | 
			
		||||
    public static boolean requiresLanguageReload(@NotNull ConfigOption option) {
 | 
			
		||||
        return option == ConfigOption.LANGUAGE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -89,7 +102,7 @@ public enum ConfigTag {
 | 
			
		||||
     * @param option <p>The config option to check</p>
 | 
			
		||||
     * @return <p>True if economy requires a reload</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean requiresEconomyReload(ConfigOption option) {
 | 
			
		||||
    public static boolean requiresEconomyReload(@NotNull ConfigOption option) {
 | 
			
		||||
        return option == ConfigOption.USE_ECONOMY;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package net.knarcraft.stargate.config;
 | 
			
		||||
 | 
			
		||||
import net.knarcraft.stargate.Stargate;
 | 
			
		||||
import net.knarcraft.stargate.container.RelativeBlockVector;
 | 
			
		||||
import net.knarcraft.stargate.portal.Portal;
 | 
			
		||||
import net.knarcraft.stargate.portal.PortalRegistry;
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
@@ -10,6 +11,8 @@ import org.dynmap.markers.GenericMarker;
 | 
			
		||||
import org.dynmap.markers.Marker;
 | 
			
		||||
import org.dynmap.markers.MarkerIcon;
 | 
			
		||||
import org.dynmap.markers.MarkerSet;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A manager for dealing with everything Dynmap
 | 
			
		||||
@@ -29,7 +32,7 @@ public final class DynmapManager {
 | 
			
		||||
     * @param dynmapAPI <p>A reference</p>
 | 
			
		||||
     * @throws NullPointerException <p>If dynmap has an invalid state</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void initialize(DynmapAPI dynmapAPI) throws NullPointerException {
 | 
			
		||||
    public static void initialize(@Nullable DynmapAPI dynmapAPI) throws NullPointerException {
 | 
			
		||||
        if (dynmapAPI == null || !dynmapAPI.markerAPIInitialized() || dynmapAPI.getMarkerAPI() == null) {
 | 
			
		||||
            markerSet = null;
 | 
			
		||||
            portalIcon = null;
 | 
			
		||||
@@ -67,7 +70,7 @@ public final class DynmapManager {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The portal to add a marker for</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void addPortalMarker(Portal portal) {
 | 
			
		||||
    public static void addPortalMarker(@NotNull Portal portal) {
 | 
			
		||||
        if (markerSet == null || Stargate.getStargateConfig().isDynmapDisabled()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -76,7 +79,13 @@ public final class DynmapManager {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Location location = portal.getBlockAt(portal.getGate().getLayout().getExit());
 | 
			
		||||
        Location location;
 | 
			
		||||
        @Nullable RelativeBlockVector exit = portal.getGate().getLayout().getExit();
 | 
			
		||||
        if (exit == null) {
 | 
			
		||||
            location = portal.getTopLeft();
 | 
			
		||||
        } else {
 | 
			
		||||
            location = portal.getBlockAt(exit);
 | 
			
		||||
        }
 | 
			
		||||
        Marker marker = markerSet.createMarker(getPortalMarkerId(portal), portal.getName(), world.getName(),
 | 
			
		||||
                location.getX(), location.getY(), location.getZ(), portalIcon, false);
 | 
			
		||||
        if (marker == null) {
 | 
			
		||||
@@ -112,7 +121,7 @@ public final class DynmapManager {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The portal to remove the marker for</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void removePortalMarker(Portal portal) {
 | 
			
		||||
    public static void removePortalMarker(@NotNull Portal portal) {
 | 
			
		||||
        if (markerSet == null || Stargate.getStargateConfig().isDynmapDisabled()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -128,7 +137,7 @@ public final class DynmapManager {
 | 
			
		||||
     * @param portal <p>The portal to get a marker id for</p>
 | 
			
		||||
     * @return <p></p>
 | 
			
		||||
     */
 | 
			
		||||
    private static String getPortalMarkerId(Portal portal) {
 | 
			
		||||
    private static String getPortalMarkerId(@NotNull Portal portal) {
 | 
			
		||||
        return portal.getNetwork() + "-:-" + portal.getName();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,8 @@ import org.bukkit.plugin.Plugin;
 | 
			
		||||
import org.bukkit.plugin.PluginManager;
 | 
			
		||||
import org.bukkit.plugin.RegisteredServiceProvider;
 | 
			
		||||
import org.bukkit.plugin.ServicesManager;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
@@ -29,7 +31,7 @@ public final class EconomyConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @param configOptions <p>The loaded config options to read</p>
 | 
			
		||||
     */
 | 
			
		||||
    public EconomyConfig(Map<ConfigOption, Object> configOptions) {
 | 
			
		||||
    public EconomyConfig(@NotNull Map<ConfigOption, Object> configOptions) {
 | 
			
		||||
        this.configOptions = configOptions;
 | 
			
		||||
        try {
 | 
			
		||||
            String freeColor = (String) configOptions.get(ConfigOption.FREE_GATES_COLOR);
 | 
			
		||||
@@ -62,6 +64,7 @@ public final class EconomyConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>An economy object, or null if economy is disabled or not initialized</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Economy getEconomy() {
 | 
			
		||||
        return economy;
 | 
			
		||||
    }
 | 
			
		||||
@@ -71,6 +74,7 @@ public final class EconomyConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>An instance of the Vault plugin, or null if Vault is not loaded</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Plugin getVault() {
 | 
			
		||||
        return vault;
 | 
			
		||||
    }
 | 
			
		||||
@@ -137,6 +141,7 @@ public final class EconomyConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The account all taxes are paid to</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public String getTaxAccount() {
 | 
			
		||||
        return (String) configOptions.get(ConfigOption.TAX_ACCOUNT);
 | 
			
		||||
    }
 | 
			
		||||
@@ -158,6 +163,7 @@ public final class EconomyConfig {
 | 
			
		||||
     * @param amount <p>The amount to display</p>
 | 
			
		||||
     * @return <p>A formatted text string describing the amount</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String format(int amount) {
 | 
			
		||||
        if (isEconomyEnabled()) {
 | 
			
		||||
            return economy.format(amount);
 | 
			
		||||
@@ -172,7 +178,7 @@ public final class EconomyConfig {
 | 
			
		||||
     * @param pluginManager <p>The plugin manager to get plugins from</p>
 | 
			
		||||
     * @return <p>True if economy was enabled</p>
 | 
			
		||||
     */
 | 
			
		||||
    public boolean setupEconomy(PluginManager pluginManager) {
 | 
			
		||||
    public boolean setupEconomy(@NotNull PluginManager pluginManager) {
 | 
			
		||||
        if (!isEconomyEnabled()) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
@@ -211,7 +217,7 @@ public final class EconomyConfig {
 | 
			
		||||
     * @param gate   <p>The gate type used</p>
 | 
			
		||||
     * @return <p>The cost of creating the gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    public int getCreateCost(Player player, Gate gate) {
 | 
			
		||||
    public int getCreateCost(@NotNull Player player, @NotNull Gate gate) {
 | 
			
		||||
        if (isFree(player, "create")) {
 | 
			
		||||
            return 0;
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -226,7 +232,7 @@ public final class EconomyConfig {
 | 
			
		||||
     * @param gate   <p>The gate type used</p>
 | 
			
		||||
     * @return <p>The cost of destroying the gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    public int getDestroyCost(Player player, Gate gate) {
 | 
			
		||||
    public int getDestroyCost(@NotNull Player player, @NotNull Gate gate) {
 | 
			
		||||
        if (isFree(player, "destroy")) {
 | 
			
		||||
            return 0;
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -241,7 +247,7 @@ public final class EconomyConfig {
 | 
			
		||||
     * @param permissionNode <p>The free.permissionNode necessary to allow free gate {action}</p>
 | 
			
		||||
     * @return <p></p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean isFree(Player player, String permissionNode) {
 | 
			
		||||
    private boolean isFree(@NotNull Player player, @NotNull String permissionNode) {
 | 
			
		||||
        return !useEconomy() || PermissionHelper.hasPermission(player, "stargate.free." + permissionNode);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,8 @@ package net.knarcraft.stargate.config;
 | 
			
		||||
import net.knarcraft.knarlib.property.ColorConversion;
 | 
			
		||||
import net.knarcraft.knarlib.util.FileHelper;
 | 
			
		||||
import net.knarcraft.stargate.Stargate;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.BufferedWriter;
 | 
			
		||||
@@ -30,7 +32,7 @@ public final class LanguageLoader {
 | 
			
		||||
     *
 | 
			
		||||
     * @param languageFolder <p>The folder containing the language files</p>
 | 
			
		||||
     */
 | 
			
		||||
    public LanguageLoader(String languageFolder) {
 | 
			
		||||
    public LanguageLoader(@NotNull String languageFolder) {
 | 
			
		||||
        this.languageFolder = languageFolder;
 | 
			
		||||
        File testFile = new File(languageFolder, "en.txt");
 | 
			
		||||
        if (!testFile.exists()) {
 | 
			
		||||
@@ -65,7 +67,8 @@ public final class LanguageLoader {
 | 
			
		||||
     * @param name <p>The name/key of the string to display</p>
 | 
			
		||||
     * @return <p>The string in the user's preferred language</p>
 | 
			
		||||
     */
 | 
			
		||||
    public String getString(String name) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getString(@NotNull String name) {
 | 
			
		||||
        String value = null;
 | 
			
		||||
        if (loadedStringTranslations != null) {
 | 
			
		||||
            value = loadedStringTranslations.get(name);
 | 
			
		||||
@@ -82,7 +85,8 @@ public final class LanguageLoader {
 | 
			
		||||
     * @param name <p>The name/key of the string to display</p>
 | 
			
		||||
     * @return <p>The string in the backup language (English)</p>
 | 
			
		||||
     */
 | 
			
		||||
    public String getBackupString(String name) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getBackupString(@NotNull String name) {
 | 
			
		||||
        String value = null;
 | 
			
		||||
        if (loadedBackupStrings != null) {
 | 
			
		||||
            value = loadedBackupStrings.get(name);
 | 
			
		||||
@@ -98,7 +102,7 @@ public final class LanguageLoader {
 | 
			
		||||
     *
 | 
			
		||||
     * @param chosenLanguage <p>The new plugin language</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setChosenLanguage(String chosenLanguage) {
 | 
			
		||||
    public void setChosenLanguage(@NotNull String chosenLanguage) {
 | 
			
		||||
        this.chosenLanguage = chosenLanguage;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -107,7 +111,7 @@ public final class LanguageLoader {
 | 
			
		||||
     *
 | 
			
		||||
     * @param language <p>The language to update</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void updateLanguage(String language) {
 | 
			
		||||
    private void updateLanguage(@NotNull String language) {
 | 
			
		||||
        Map<String, String> currentLanguageValues = load(language);
 | 
			
		||||
 | 
			
		||||
        InputStream inputStream = getClass().getResourceAsStream("/lang/" + language + ".txt");
 | 
			
		||||
@@ -133,8 +137,8 @@ public final class LanguageLoader {
 | 
			
		||||
     * @param currentLanguageValues <p>The current values of the loaded/processed language</p>
 | 
			
		||||
     * @throws IOException <p>if unable to read a language file</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void readChangedLanguageStrings(InputStream inputStream, String language, Map<String,
 | 
			
		||||
            String> currentLanguageValues) throws IOException {
 | 
			
		||||
    private void readChangedLanguageStrings(@NotNull InputStream inputStream, @NotNull String language,
 | 
			
		||||
                                            @Nullable Map<String, String> currentLanguageValues) throws IOException {
 | 
			
		||||
        //Get language values
 | 
			
		||||
        BufferedReader bufferedReader = FileHelper.getBufferedReaderFromInputStream(inputStream);
 | 
			
		||||
        Map<String, String> internalLanguageValues = FileHelper.readKeyValuePairs(bufferedReader, "=",
 | 
			
		||||
@@ -177,8 +181,8 @@ public final class LanguageLoader {
 | 
			
		||||
     * @param customLanguageStrings <p>Any custom language strings not recognized</p>
 | 
			
		||||
     * @throws IOException <p>If unable to write to the language file</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void updateLanguageFile(String language, Map<String, String> languageStrings,
 | 
			
		||||
                                    Map<String, String> customLanguageStrings) throws IOException {
 | 
			
		||||
    private void updateLanguageFile(@NotNull String language, @NotNull Map<String, String> languageStrings,
 | 
			
		||||
                                    @Nullable Map<String, String> customLanguageStrings) throws IOException {
 | 
			
		||||
        BufferedWriter bufferedWriter = FileHelper.getBufferedWriterFromString(languageFolder + language + ".txt");
 | 
			
		||||
 | 
			
		||||
        //Output normal Language data
 | 
			
		||||
@@ -203,7 +207,8 @@ public final class LanguageLoader {
 | 
			
		||||
     * @param lang <p>The language to load</p>
 | 
			
		||||
     * @return <p>A mapping between loaded string indexes and the strings to display</p>
 | 
			
		||||
     */
 | 
			
		||||
    private Map<String, String> load(String lang) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private Map<String, String> load(@NotNull String lang) {
 | 
			
		||||
        return load(lang, null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -214,7 +219,8 @@ public final class LanguageLoader {
 | 
			
		||||
     * @param inputStream <p>An optional input stream to use. Defaults to using a file input stream</p>
 | 
			
		||||
     * @return <p>A mapping between loaded string indexes and the strings to display</p>
 | 
			
		||||
     */
 | 
			
		||||
    private Map<String, String> load(String lang, InputStream inputStream) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private Map<String, String> load(@NotNull String lang, @Nullable InputStream inputStream) {
 | 
			
		||||
        Map<String, String> strings;
 | 
			
		||||
        BufferedReader bufferedReader;
 | 
			
		||||
        try {
 | 
			
		||||
@@ -224,7 +230,7 @@ public final class LanguageLoader {
 | 
			
		||||
                bufferedReader = FileHelper.getBufferedReaderFromInputStream(inputStream);
 | 
			
		||||
            }
 | 
			
		||||
            strings = FileHelper.readKeyValuePairs(bufferedReader, "=", ColorConversion.NORMAL);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
        } catch (Exception exception) {
 | 
			
		||||
            if (Stargate.getStargateConfig().isDebuggingEnabled()) {
 | 
			
		||||
                Stargate.logInfo("Unable to load language " + lang);
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package net.knarcraft.stargate.config;
 | 
			
		||||
 | 
			
		||||
import net.md_5.bungee.api.ChatColor;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The message sender is responsible sending messages to players with correct coloring and formatting
 | 
			
		||||
@@ -15,7 +16,7 @@ public final class MessageSender {
 | 
			
		||||
     *
 | 
			
		||||
     * @param languageLoader <p>The language loader to get translated strings from</p>
 | 
			
		||||
     */
 | 
			
		||||
    public MessageSender(LanguageLoader languageLoader) {
 | 
			
		||||
    public MessageSender(@NotNull LanguageLoader languageLoader) {
 | 
			
		||||
        this.languageLoader = languageLoader;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -25,7 +26,7 @@ public final class MessageSender {
 | 
			
		||||
     * @param player  <p>The player to send the message to</p>
 | 
			
		||||
     * @param message <p>The message to send</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void sendErrorMessage(CommandSender player, String message) {
 | 
			
		||||
    public void sendErrorMessage(@NotNull CommandSender player, @NotNull String message) {
 | 
			
		||||
        sendMessage(player, message, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -35,7 +36,7 @@ public final class MessageSender {
 | 
			
		||||
     * @param player  <p>The player to send the message to</p>
 | 
			
		||||
     * @param message <p>The message to send</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void sendSuccessMessage(CommandSender player, String message) {
 | 
			
		||||
    public void sendSuccessMessage(@NotNull CommandSender player, @NotNull String message) {
 | 
			
		||||
        sendMessage(player, message, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -46,7 +47,7 @@ public final class MessageSender {
 | 
			
		||||
     * @param message <p>The message to send</p>
 | 
			
		||||
     * @param error   <p>Whether the message sent is an error</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void sendMessage(CommandSender sender, String message, boolean error) {
 | 
			
		||||
    private void sendMessage(@NotNull CommandSender sender, @NotNull String message, boolean error) {
 | 
			
		||||
        if (message.isEmpty()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@ import org.bukkit.configuration.file.FileConfiguration;
 | 
			
		||||
import org.bukkit.configuration.file.YamlConfiguration;
 | 
			
		||||
import org.bukkit.plugin.messaging.Messenger;
 | 
			
		||||
import org.dynmap.DynmapAPI;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
@@ -58,7 +59,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @param logger <p>The logger to use for logging errors</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargateConfig(Logger logger) {
 | 
			
		||||
    public StargateConfig(@NotNull Logger logger) {
 | 
			
		||||
        this.logger = logger;
 | 
			
		||||
        configOptions = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
@@ -76,6 +77,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A reference to the config options map</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Map<ConfigOption, Object> getConfigOptionsReference() {
 | 
			
		||||
        return configOptions;
 | 
			
		||||
    }
 | 
			
		||||
@@ -136,6 +138,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The loaded config options</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Map<ConfigOption, Object> getConfigOptions() {
 | 
			
		||||
        return new HashMap<>(configOptions);
 | 
			
		||||
    }
 | 
			
		||||
@@ -147,6 +150,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The open portals queue</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Queue<Portal> getOpenPortalsQueue() {
 | 
			
		||||
        return openPortalsQueue;
 | 
			
		||||
    }
 | 
			
		||||
@@ -158,6 +162,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The active portals queue</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Queue<Portal> getActivePortalsQueue() {
 | 
			
		||||
        return activePortalsQueue;
 | 
			
		||||
    }
 | 
			
		||||
@@ -203,6 +208,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The object containing economy config values</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public EconomyConfig getEconomyConfig() {
 | 
			
		||||
        return this.economyConfig;
 | 
			
		||||
    }
 | 
			
		||||
@@ -212,7 +218,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @param sender <p>The sender of the reload request</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void reload(CommandSender sender) {
 | 
			
		||||
    public void reload(@NotNull CommandSender sender) {
 | 
			
		||||
        //Unload all saved data
 | 
			
		||||
        unload();
 | 
			
		||||
 | 
			
		||||
@@ -285,6 +291,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The managed worlds</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Set<String> getManagedWorlds() {
 | 
			
		||||
        return new HashSet<>(managedWorlds);
 | 
			
		||||
    }
 | 
			
		||||
@@ -294,7 +301,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @param worldName <p>The name of the world to manage</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void addManagedWorld(String worldName) {
 | 
			
		||||
    public void addManagedWorld(@NotNull String worldName) {
 | 
			
		||||
        managedWorlds.add(worldName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -303,7 +310,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @param worldName <p>The name of the world to stop managing</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void removeManagedWorld(String worldName) {
 | 
			
		||||
    public void removeManagedWorld(@NotNull String worldName) {
 | 
			
		||||
        managedWorlds.remove(worldName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -448,6 +455,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>Gets the gate config</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public StargateGateConfig getStargateGateConfig() {
 | 
			
		||||
        return stargateGateConfig;
 | 
			
		||||
    }
 | 
			
		||||
@@ -465,13 +473,13 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @param currentConfiguration <p>The current config to back up</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void migrateConfig(FileConfiguration currentConfiguration) {
 | 
			
		||||
    private void migrateConfig(@NotNull FileConfiguration currentConfiguration) {
 | 
			
		||||
        String debugPath = "StargateConfig::migrateConfig";
 | 
			
		||||
 | 
			
		||||
        //Save the old config just in case something goes wrong
 | 
			
		||||
        try {
 | 
			
		||||
            currentConfiguration.save(new File(dataFolderPath, "config.yml.old"));
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
        } catch (IOException exception) {
 | 
			
		||||
            Stargate.debug(debugPath, "Unable to save old backup and do migration");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -489,7 +497,7 @@ public final class StargateConfig {
 | 
			
		||||
            migrationFields = FileHelper.readKeyValuePairs(FileHelper.getBufferedReaderFromInputStream(
 | 
			
		||||
                            FileHelper.getInputStreamForInternalFile("/config-migrations.txt")), "=",
 | 
			
		||||
                    ColorConversion.NORMAL);
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
        } catch (IOException exception) {
 | 
			
		||||
            Stargate.debug(debugPath, "Unable to load config migration file");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -530,9 +538,10 @@ public final class StargateConfig {
 | 
			
		||||
     */
 | 
			
		||||
    private void setupVaultEconomy() {
 | 
			
		||||
        EconomyConfig economyConfig = getEconomyConfig();
 | 
			
		||||
        if (economyConfig.setupEconomy(Stargate.getPluginManager()) && economyConfig.getEconomy() != null) {
 | 
			
		||||
        if (economyConfig.setupEconomy(Stargate.getPluginManager()) && economyConfig.getEconomy() != null &&
 | 
			
		||||
                economyConfig.getVault() != null) {
 | 
			
		||||
            String vaultVersion = economyConfig.getVault().getDescription().getVersion();
 | 
			
		||||
            Stargate.logInfo(Stargate.replaceVars(Stargate.getString("vaultLoaded"), "%version%", vaultVersion));
 | 
			
		||||
            Stargate.logInfo(Stargate.replacePlaceholders(Stargate.getString("vaultLoaded"), "%version%", vaultVersion));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -578,6 +587,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The portal folder</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getPortalFolder() {
 | 
			
		||||
        return portalFolder;
 | 
			
		||||
    }
 | 
			
		||||
@@ -589,6 +599,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The folder storing gate files</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getGateFolder() {
 | 
			
		||||
        return gateFolder;
 | 
			
		||||
    }
 | 
			
		||||
@@ -598,6 +609,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The sender for sending messages to players</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public MessageSender getMessageSender() {
 | 
			
		||||
        return messageSender;
 | 
			
		||||
    }
 | 
			
		||||
@@ -607,6 +619,7 @@ public final class StargateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The language loader</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public LanguageLoader getLanguageLoader() {
 | 
			
		||||
        return languageLoader;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@ import net.knarcraft.stargate.portal.PortalSignDrawer;
 | 
			
		||||
import net.md_5.bungee.api.ChatColor;
 | 
			
		||||
import org.bukkit.Color;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
@@ -26,7 +27,7 @@ public final class StargateGateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @param configOptions <p>The loaded config options to use</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargateGateConfig(Map<ConfigOption, Object> configOptions) {
 | 
			
		||||
    public StargateGateConfig(@NotNull Map<ConfigOption, Object> configOptions) {
 | 
			
		||||
        this.configOptions = configOptions;
 | 
			
		||||
        loadGateConfig();
 | 
			
		||||
    }
 | 
			
		||||
@@ -248,8 +249,8 @@ public final class StargateGateConfig {
 | 
			
		||||
     * @param defaultColors          <p>The specified default colors</p>
 | 
			
		||||
     * @param colorMaps              <p>The list of color maps to save the resulting colors to</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void parsePerSignColors(Object signColorSpecification, ChatColor[] defaultColors,
 | 
			
		||||
                                    List<Map<Material, ChatColor>> colorMaps) {
 | 
			
		||||
    private void parsePerSignColors(@NotNull Object signColorSpecification, @NotNull ChatColor[] defaultColors,
 | 
			
		||||
                                    @NotNull List<Map<Material, ChatColor>> colorMaps) {
 | 
			
		||||
        String[] specificationData = String.valueOf(signColorSpecification).split(":");
 | 
			
		||||
        Material[] signMaterials = new Material[]{Material.matchMaterial(specificationData[0] + "_SIGN"),
 | 
			
		||||
                Material.matchMaterial(specificationData[0] + "_WALL_SIGN")};
 | 
			
		||||
@@ -280,8 +281,8 @@ public final class StargateGateConfig {
 | 
			
		||||
     * @param signMaterials <p>The materials to load this color for</p>
 | 
			
		||||
     * @param colorMaps     <p>The list of color maps to save the resulting color to</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void loadPerSignColor(String[] colors, int colorIndex, ChatColor[] defaultColors, Material[] signMaterials,
 | 
			
		||||
                                  List<Map<Material, ChatColor>> colorMaps) {
 | 
			
		||||
    private void loadPerSignColor(@NotNull String[] colors, int colorIndex, @NotNull ChatColor[] defaultColors,
 | 
			
		||||
                                  @NotNull Material[] signMaterials, @NotNull List<Map<Material, ChatColor>> colorMaps) {
 | 
			
		||||
        ChatColor parsedColor;
 | 
			
		||||
        if (colors[colorIndex].equalsIgnoreCase("inverted")) {
 | 
			
		||||
            //Convert from ChatColor to awt.Color to Bukkit.Color then invert and convert to ChatColor
 | 
			
		||||
@@ -309,7 +310,7 @@ public final class StargateGateConfig {
 | 
			
		||||
     *
 | 
			
		||||
     * @param mainSignColor <p>A string representing the main sign color</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void loadPerSignColor(String mainSignColor, String highlightSignColor) {
 | 
			
		||||
    private void loadPerSignColor(@NotNull String mainSignColor, @NotNull String highlightSignColor) {
 | 
			
		||||
        try {
 | 
			
		||||
            PortalSignDrawer.setMainColor(ChatColor.of(mainSignColor.toUpperCase()));
 | 
			
		||||
        } catch (IllegalArgumentException | NullPointerException exception) {
 | 
			
		||||
 
 | 
			
		||||
@@ -21,18 +21,20 @@ import java.util.List;
 | 
			
		||||
 */
 | 
			
		||||
public class StargateYamlConfiguration extends YamlConfiguration {
 | 
			
		||||
 | 
			
		||||
    public static final String START_OF_COMMENT_LINE = "[HASHTAG]";
 | 
			
		||||
    static public final String END_OF_COMMENT = "_endOfComment_";
 | 
			
		||||
    static public final String START_OF_COMMENT = "comment_";
 | 
			
		||||
    private static final String START_OF_COMMENT_LINE = "[HASHTAG]";
 | 
			
		||||
    private static final String END_OF_COMMENT = "_endOfComment_";
 | 
			
		||||
    private static final String START_OF_COMMENT = "comment_";
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
    @SuppressWarnings("deprecation")
 | 
			
		||||
    protected @NotNull String buildHeader() {
 | 
			
		||||
    protected String buildHeader() {
 | 
			
		||||
        return "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public @NotNull String saveToString() {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String saveToString() {
 | 
			
		||||
        // Convert YAML comments to normal comments
 | 
			
		||||
        return this.convertYAMLMappingsToComments(super.saveToString());
 | 
			
		||||
    }
 | 
			
		||||
@@ -51,7 +53,8 @@ public class StargateYamlConfiguration extends YamlConfiguration {
 | 
			
		||||
     * the {@link FileConfiguration#save(File)} method. The config
 | 
			
		||||
     * needs to be saved if a config value has changed.</p>
 | 
			
		||||
     */
 | 
			
		||||
    private String convertCommentsToYAMLMappings(String configString) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private String convertCommentsToYAMLMappings(@NotNull String configString) {
 | 
			
		||||
        StringBuilder yamlBuilder = new StringBuilder();
 | 
			
		||||
        List<String> currentComment = new ArrayList<>();
 | 
			
		||||
        int commentId = 0;
 | 
			
		||||
@@ -84,8 +87,8 @@ public class StargateYamlConfiguration extends YamlConfiguration {
 | 
			
		||||
     * @param previousIndentation <p>The indentation of the current block comment</p>
 | 
			
		||||
     * @param commentId           <p>The id of the comment</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void addYamlString(StringBuilder yamlBuilder, List<String> currentComment, String line,
 | 
			
		||||
                               int previousIndentation, int commentId) {
 | 
			
		||||
    private void addYamlString(@NotNull StringBuilder yamlBuilder, @NotNull List<String> currentComment,
 | 
			
		||||
                               @NotNull String line, int previousIndentation, int commentId) {
 | 
			
		||||
        String trimmed = line.trim();
 | 
			
		||||
        //Write the full formatted comment to the StringBuilder
 | 
			
		||||
        if (!currentComment.isEmpty()) {
 | 
			
		||||
@@ -105,7 +108,7 @@ public class StargateYamlConfiguration extends YamlConfiguration {
 | 
			
		||||
     * @param commentParts <p>The list to add to</p>
 | 
			
		||||
     * @param comment      <p>The comment to add</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void addComment(List<String> commentParts, String comment) {
 | 
			
		||||
    private void addComment(@NotNull List<String> commentParts, @NotNull String comment) {
 | 
			
		||||
        if (comment.startsWith("# ")) {
 | 
			
		||||
            commentParts.add(comment.replaceFirst("# ", START_OF_COMMENT_LINE));
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -121,7 +124,8 @@ public class StargateYamlConfiguration extends YamlConfiguration {
 | 
			
		||||
     * @param commentId    <p>The unique id of the comment</p>
 | 
			
		||||
     * @param indentation  <p>The indentation to add to every line</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void generateCommentYAML(StringBuilder yamlBuilder, List<String> commentLines, int commentId, int indentation) {
 | 
			
		||||
    private void generateCommentYAML(@NotNull StringBuilder yamlBuilder, @NotNull List<String> commentLines,
 | 
			
		||||
                                     int commentId, int indentation) {
 | 
			
		||||
        String subIndentation = this.addIndentation(indentation + 2);
 | 
			
		||||
        //Add the comment start marker
 | 
			
		||||
        yamlBuilder.append(this.addIndentation(indentation)).append(START_OF_COMMENT).append(commentId).append(": |\n");
 | 
			
		||||
@@ -143,7 +147,8 @@ public class StargateYamlConfiguration extends YamlConfiguration {
 | 
			
		||||
     * @param yamlString <p>A string using the YAML format</p>
 | 
			
		||||
     * @return <p>The corresponding comment string</p>
 | 
			
		||||
     */
 | 
			
		||||
    private String convertYAMLMappingsToComments(String yamlString) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private String convertYAMLMappingsToComments(@NotNull String yamlString) {
 | 
			
		||||
        StringBuilder finalText = new StringBuilder();
 | 
			
		||||
 | 
			
		||||
        String[] lines = yamlString.split("\n");
 | 
			
		||||
@@ -173,7 +178,8 @@ public class StargateYamlConfiguration extends YamlConfiguration {
 | 
			
		||||
     * @param commentIndentation <p>The indentation of the read comment</p>
 | 
			
		||||
     * @return <p>The index containing the next non-comment line</p>
 | 
			
		||||
     */
 | 
			
		||||
    private int readComment(StringBuilder builder, String[] lines, int startIndex, int commentIndentation) {
 | 
			
		||||
    private int readComment(@NotNull StringBuilder builder, @NotNull String[] lines, int startIndex,
 | 
			
		||||
                            int commentIndentation) {
 | 
			
		||||
        for (int currentIndex = startIndex; currentIndex < lines.length; currentIndex++) {
 | 
			
		||||
            String line = lines[currentIndex];
 | 
			
		||||
            String possibleComment = line.trim();
 | 
			
		||||
@@ -194,6 +200,7 @@ public class StargateYamlConfiguration extends YamlConfiguration {
 | 
			
		||||
     * @param indentationSpaces <p>The number spaces to use for indentation</p>
 | 
			
		||||
     * @return <p>A string containing the number of spaces specified</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private String addIndentation(int indentationSpaces) {
 | 
			
		||||
        return " ".repeat(Math.max(0, indentationSpaces));
 | 
			
		||||
    }
 | 
			
		||||
@@ -205,7 +212,7 @@ public class StargateYamlConfiguration extends YamlConfiguration {
 | 
			
		||||
     * @param line <p>The line to get indentation of</p>
 | 
			
		||||
     * @return <p>The number of spaces in the line's indentation</p>
 | 
			
		||||
     */
 | 
			
		||||
    private int getIndentation(String line) {
 | 
			
		||||
    private int getIndentation(@NotNull String line) {
 | 
			
		||||
        int spacesFound = 0;
 | 
			
		||||
        for (char aCharacter : line.toCharArray()) {
 | 
			
		||||
            if (aCharacter == ' ') {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@ package net.knarcraft.stargate.container;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Axis;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Represents a request for changing a block into another material
 | 
			
		||||
@@ -19,7 +21,7 @@ public class BlockChangeRequest {
 | 
			
		||||
     * @param material      <p>The new material to change the block to</p>
 | 
			
		||||
     * @param axis          <p>The new axis to orient the block along</p>
 | 
			
		||||
     */
 | 
			
		||||
    public BlockChangeRequest(BlockLocation blockLocation, Material material, Axis axis) {
 | 
			
		||||
    public BlockChangeRequest(@NotNull BlockLocation blockLocation, @NotNull Material material, @Nullable Axis axis) {
 | 
			
		||||
        this.blockLocation = blockLocation;
 | 
			
		||||
        newMaterial = material;
 | 
			
		||||
        newAxis = axis;
 | 
			
		||||
@@ -30,6 +32,7 @@ public class BlockChangeRequest {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The location of the block</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockLocation getBlockLocation() {
 | 
			
		||||
        return blockLocation;
 | 
			
		||||
    }
 | 
			
		||||
@@ -39,6 +42,7 @@ public class BlockChangeRequest {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The material to change the block into</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Material getMaterial() {
 | 
			
		||||
        return newMaterial;
 | 
			
		||||
    }
 | 
			
		||||
@@ -48,6 +52,7 @@ public class BlockChangeRequest {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The axis to orient the block along</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Axis getAxis() {
 | 
			
		||||
        return newAxis;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,8 @@ import org.bukkit.block.data.BlockData;
 | 
			
		||||
import org.bukkit.block.data.Directional;
 | 
			
		||||
import org.bukkit.block.data.type.Sign;
 | 
			
		||||
import org.bukkit.util.Vector;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class represents a block location
 | 
			
		||||
@@ -30,7 +32,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
     * @param y     <p>The y coordinate of the block</p>
 | 
			
		||||
     * @param z     <p>The z coordinate of the block</p>
 | 
			
		||||
     */
 | 
			
		||||
    public BlockLocation(World world, int x, int y, int z) {
 | 
			
		||||
    public BlockLocation(@NotNull World world, int x, int y, int z) {
 | 
			
		||||
        super(world, x, y, z);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -39,7 +41,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
     *
 | 
			
		||||
     * @param block <p>The block to get the location of</p>
 | 
			
		||||
     */
 | 
			
		||||
    public BlockLocation(Block block) {
 | 
			
		||||
    public BlockLocation(@NotNull Block block) {
 | 
			
		||||
        super(block.getWorld(), block.getX(), block.getY(), block.getZ());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -49,7 +51,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
     * @param world  <p>The world the block exists in</p>
 | 
			
		||||
     * @param string <p>A comma separated list of x, y and z coordinates as integers</p>
 | 
			
		||||
     */
 | 
			
		||||
    public BlockLocation(World world, String string) {
 | 
			
		||||
    public BlockLocation(@NotNull World world, @NotNull String string) {
 | 
			
		||||
        super(world, Integer.parseInt(string.split(",")[0]), Integer.parseInt(string.split(",")[1]),
 | 
			
		||||
                Integer.parseInt(string.split(",")[2]));
 | 
			
		||||
    }
 | 
			
		||||
@@ -62,6 +64,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
     * @param z <p>The number of blocks to move in the z-direction</p>
 | 
			
		||||
     * @return <p>A new block location</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockLocation makeRelativeBlockLocation(int x, int y, int z) {
 | 
			
		||||
        return (BlockLocation) this.clone().add(x, y, z);
 | 
			
		||||
    }
 | 
			
		||||
@@ -75,6 +78,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
     * @param yaw <p>The number of blocks to move in the z-direction</p>
 | 
			
		||||
     * @return <p>A new location</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Location makeRelativeLocation(double x, double y, double z, float yaw) {
 | 
			
		||||
        Location newLocation = this.clone();
 | 
			
		||||
        newLocation.setYaw(yaw);
 | 
			
		||||
@@ -89,9 +93,10 @@ public class BlockLocation extends Location {
 | 
			
		||||
     * @param yaw            <p>The yaw pointing outwards from a portal (in the relative vector's out direction)</p>
 | 
			
		||||
     * @return <p>A location relative to this location</p>
 | 
			
		||||
     */
 | 
			
		||||
    public BlockLocation getRelativeLocation(RelativeBlockVector relativeVector, double yaw) {
 | 
			
		||||
        Vector realVector = DirectionHelper.getCoordinateVectorFromRelativeVector(relativeVector.getRight(),
 | 
			
		||||
                relativeVector.getDown(), relativeVector.getOut(), yaw);
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockLocation getRelativeLocation(@NotNull RelativeBlockVector relativeVector, double yaw) {
 | 
			
		||||
        Vector realVector = DirectionHelper.getCoordinateVectorFromRelativeVector(relativeVector.right(),
 | 
			
		||||
                relativeVector.down(), relativeVector.out(), yaw);
 | 
			
		||||
        return makeRelativeBlockLocation(realVector.getBlockX(), realVector.getBlockY(), realVector.getBlockZ());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -107,6 +112,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
     * @param portalYaw <p>The yaw when looking out from the portal</p>
 | 
			
		||||
     * @return A new location relative to this block location
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Location getRelativeLocation(double right, double down, double out, float portalYaw) {
 | 
			
		||||
        Vector realVector = DirectionHelper.getCoordinateVectorFromRelativeVector(right, down, out, portalYaw);
 | 
			
		||||
        return makeRelativeLocation(0.5 + realVector.getBlockX(), realVector.getBlockY(),
 | 
			
		||||
@@ -118,6 +124,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The block's material type</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Material getType() {
 | 
			
		||||
        return this.getBlock().getType();
 | 
			
		||||
    }
 | 
			
		||||
@@ -127,7 +134,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
     *
 | 
			
		||||
     * @param type <p>The block's new material type</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setType(Material type) {
 | 
			
		||||
    public void setType(@NotNull Material type) {
 | 
			
		||||
        this.getBlock().setType(type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -136,6 +143,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The location representing this block location</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Location getLocation() {
 | 
			
		||||
        return this.clone();
 | 
			
		||||
    }
 | 
			
		||||
@@ -148,6 +156,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This block location's parent block</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Block getParent() {
 | 
			
		||||
        if (parent == null) {
 | 
			
		||||
            findParent();
 | 
			
		||||
@@ -184,6 +193,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return String.valueOf(this.getBlockX()) + ',' + this.getBlockY() + ',' + this.getBlockZ();
 | 
			
		||||
    }
 | 
			
		||||
@@ -203,7 +213,7 @@ public class BlockLocation extends Location {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean equals(Object object) {
 | 
			
		||||
    public boolean equals(@Nullable Object object) {
 | 
			
		||||
        if (this == object) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ public class ChunkUnloadRequest implements Comparable<ChunkUnloadRequest> {
 | 
			
		||||
     * @param chunkToUnload   <p>The chunk to request the unloading of</p>
 | 
			
		||||
     * @param timeUntilUnload <p>The time in milliseconds to wait before unloading the chunk</p>
 | 
			
		||||
     */
 | 
			
		||||
    public ChunkUnloadRequest(Chunk chunkToUnload, Long timeUntilUnload) {
 | 
			
		||||
    public ChunkUnloadRequest(@NotNull Chunk chunkToUnload, @NotNull Long timeUntilUnload) {
 | 
			
		||||
        this.chunkToUnload = chunkToUnload;
 | 
			
		||||
        long systemNanoTime = System.nanoTime();
 | 
			
		||||
        this.unloadNanoTime = systemNanoTime + (timeUntilUnload * 1000000);
 | 
			
		||||
@@ -28,6 +28,7 @@ public class ChunkUnloadRequest implements Comparable<ChunkUnloadRequest> {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The chunk to unload</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Chunk getChunkToUnload() {
 | 
			
		||||
        return this.chunkToUnload;
 | 
			
		||||
    }
 | 
			
		||||
@@ -37,11 +38,13 @@ public class ChunkUnloadRequest implements Comparable<ChunkUnloadRequest> {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The system nano time denoting when the chunk is to be unloaded</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Long getUnloadNanoTime() {
 | 
			
		||||
        return this.unloadNanoTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "{" + chunkToUnload + ", " + unloadNanoTime + "}";
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,60 +1,16 @@
 | 
			
		||||
package net.knarcraft.stargate.container;
 | 
			
		||||
 | 
			
		||||
import net.knarcraft.stargate.portal.Portal;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class represents a player teleporting from the end to the over-world using an artificial end portal
 | 
			
		||||
 * This class represents a teleportation from the end to the over-world using an artificial end portal
 | 
			
		||||
 *
 | 
			
		||||
 * <p>This is necessary because a player entering an end portal in the end is a special case. Instead of being
 | 
			
		||||
 * teleported, the player is respawned. Because of this, the teleportation needs to be saved and later used to hijack
 | 
			
		||||
 * the position of where the player is to respawn.</p>
 | 
			
		||||
 *
 | 
			
		||||
 * @param exitPortal <p>The portal the player should exit from when arriving in the over-world</p>
 | 
			
		||||
 */
 | 
			
		||||
public class FromTheEndTeleportation {
 | 
			
		||||
 | 
			
		||||
    private final Player teleportingPlayer;
 | 
			
		||||
    private final Portal exitPortal;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Instantiates a new teleportation from the end
 | 
			
		||||
     *
 | 
			
		||||
     * @param teleportingPlayer <p>The teleporting player</p>
 | 
			
		||||
     * @param exitPortal        <p>The portal to exit from</p>
 | 
			
		||||
     */
 | 
			
		||||
    public FromTheEndTeleportation(Player teleportingPlayer, Portal exitPortal) {
 | 
			
		||||
        this.teleportingPlayer = teleportingPlayer;
 | 
			
		||||
        this.exitPortal = exitPortal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the teleporting player
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The teleporting player</p>
 | 
			
		||||
     */
 | 
			
		||||
    public Player getPlayer() {
 | 
			
		||||
        return this.teleportingPlayer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the portal to exit from
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The portal to exit from</p>
 | 
			
		||||
     */
 | 
			
		||||
    public Portal getExit() {
 | 
			
		||||
        return this.exitPortal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int hashCode() {
 | 
			
		||||
        return teleportingPlayer.hashCode();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean equals(Object other) {
 | 
			
		||||
        if (!(other instanceof FromTheEndTeleportation otherTeleportation)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return teleportingPlayer.equals(otherTeleportation.teleportingPlayer);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public record FromTheEndTeleportation(@NotNull Portal exitPortal) {
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,8 @@
 | 
			
		||||
package net.knarcraft.stargate.container;
 | 
			
		||||
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This stores a block location as a vector relative to a position
 | 
			
		||||
 *
 | 
			
		||||
@@ -7,62 +10,48 @@ package net.knarcraft.stargate.container;
 | 
			
		||||
 * top-left block of a gate (top-left when looking at the side with the sign). The right is therefore the distance
 | 
			
		||||
 * from the top-left corner towards the top-right corner. Down is the distance from the top-left corner towards the
 | 
			
		||||
 * bottom-left corner. Out is the distance outward from the gate.</p>
 | 
			
		||||
 *
 | 
			
		||||
 * <p>Relative block vectors start from a top-left corner. A yaw is used to orient a relative block vector in the
 | 
			
		||||
 * "real world". In terms of a gate layout, the origin is 0,0. Right is towards the end of the line. Down is to the
 | 
			
		||||
 * next line. Out is towards the observer.</p>
 | 
			
		||||
 *
 | 
			
		||||
 * @param right <p>The distance rightward relative to the origin</p>
 | 
			
		||||
 * @param down  <p>The distance downward relative to the origin</p>
 | 
			
		||||
 * @param out   <p>The distance outward relative to the origin</p>
 | 
			
		||||
 */
 | 
			
		||||
public class RelativeBlockVector {
 | 
			
		||||
 | 
			
		||||
    private final int right;
 | 
			
		||||
    private final int down;
 | 
			
		||||
    private final int out;
 | 
			
		||||
public record RelativeBlockVector(int right, int down, int out) {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * A specifier for one of the relative block vector's three properties
 | 
			
		||||
     * Adds the given value to this relative block vector's "right" property
 | 
			
		||||
     *
 | 
			
		||||
     * @param valueToAdd <p>The value to add</p>
 | 
			
		||||
     * @return <p>The new resulting vector</p>
 | 
			
		||||
     */
 | 
			
		||||
    public enum Property {
 | 
			
		||||
        /**
 | 
			
		||||
         * Specifies the relative block vector's right property
 | 
			
		||||
         */
 | 
			
		||||
        RIGHT,
 | 
			
		||||
        /**
 | 
			
		||||
         * Specifies the relative block vector's down property
 | 
			
		||||
         */
 | 
			
		||||
        DOWN,
 | 
			
		||||
        /**
 | 
			
		||||
         * Specifies the relative block vector's out property
 | 
			
		||||
         */
 | 
			
		||||
        OUT
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public RelativeBlockVector addRight(int valueToAdd) {
 | 
			
		||||
        return new RelativeBlockVector(this.right + valueToAdd, this.down, this.out);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Instantiates a new relative block vector
 | 
			
		||||
     * Adds the given value to this relative block vector's "down" property
 | 
			
		||||
     *
 | 
			
		||||
     * <p>Relative block vectors start from a top-left corner. A yaw is used to orient a relative block vector in the
 | 
			
		||||
     * "real world".
 | 
			
		||||
     * In terms of a gate layout, the origin is 0,0. Right is towards the end of the line. Down is to the
 | 
			
		||||
     * next line. Out is towards the observer.</p>
 | 
			
		||||
     *
 | 
			
		||||
     * @param right <p>The distance rightward relative to the origin</p>
 | 
			
		||||
     * @param down  <p>The distance downward relative to the origin</p>
 | 
			
		||||
     * @param out   <p>The distance outward relative to the origin</p>
 | 
			
		||||
     * @param valueToAdd <p>The value to add</p>
 | 
			
		||||
     * @return <p>The new resulting vector</p>
 | 
			
		||||
     */
 | 
			
		||||
    public RelativeBlockVector(int right, int down, int out) {
 | 
			
		||||
        this.right = right;
 | 
			
		||||
        this.down = down;
 | 
			
		||||
        this.out = out;
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public RelativeBlockVector addDown(int valueToAdd) {
 | 
			
		||||
        return new RelativeBlockVector(this.right, this.down + valueToAdd, this.out);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds a value to one of the properties of this relative block vector
 | 
			
		||||
     * Adds the given value to this relative block vector's "out" property
 | 
			
		||||
     *
 | 
			
		||||
     * @param propertyToAddTo <p>The property to add to</p>
 | 
			
		||||
     * @param valueToAdd      <p>The value to add to the property (negative to move in the opposite direction)</p>
 | 
			
		||||
     * @return <p>A new relative block vector with the property altered</p>
 | 
			
		||||
     * @param valueToAdd <p>The value to add</p>
 | 
			
		||||
     * @return <p>The new resulting vector</p>
 | 
			
		||||
     */
 | 
			
		||||
    public RelativeBlockVector addToVector(Property propertyToAddTo, int valueToAdd) {
 | 
			
		||||
        return switch (propertyToAddTo) {
 | 
			
		||||
            case RIGHT -> new RelativeBlockVector(this.right + valueToAdd, this.down, this.out);
 | 
			
		||||
            case DOWN -> new RelativeBlockVector(this.right, this.down + valueToAdd, this.out);
 | 
			
		||||
            case OUT -> new RelativeBlockVector(this.right, this.down, this.out + valueToAdd);
 | 
			
		||||
        };
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public RelativeBlockVector addOut(int valueToAdd) {
 | 
			
		||||
        return new RelativeBlockVector(this.right, this.down, this.out + valueToAdd);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -70,6 +59,7 @@ public class RelativeBlockVector {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This vector, but inverted</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public RelativeBlockVector invert() {
 | 
			
		||||
        return new RelativeBlockVector(-this.right, -this.down, -this.out);
 | 
			
		||||
    }
 | 
			
		||||
@@ -79,7 +69,8 @@ public class RelativeBlockVector {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The distance to the right relative to the origin</p>
 | 
			
		||||
     */
 | 
			
		||||
    public int getRight() {
 | 
			
		||||
    @Override
 | 
			
		||||
    public int right() {
 | 
			
		||||
        return right;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -88,7 +79,8 @@ public class RelativeBlockVector {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The distance downward relative to the origin</p>
 | 
			
		||||
     */
 | 
			
		||||
    public int getDown() {
 | 
			
		||||
    @Override
 | 
			
		||||
    public int down() {
 | 
			
		||||
        return down;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -97,17 +89,19 @@ public class RelativeBlockVector {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The distance outward relative to the origin</p>
 | 
			
		||||
     */
 | 
			
		||||
    public int getOut() {
 | 
			
		||||
    @Override
 | 
			
		||||
    public int out() {
 | 
			
		||||
        return out;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return String.format("(right = %d, down = %d, out = %d)", right, down, out);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean equals(Object other) {
 | 
			
		||||
    public boolean equals(@Nullable Object other) {
 | 
			
		||||
        if (other == this) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import net.knarcraft.stargate.utility.SignHelper;
 | 
			
		||||
import net.md_5.bungee.api.ChatColor;
 | 
			
		||||
import org.bukkit.DyeColor;
 | 
			
		||||
import org.bukkit.block.Sign;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A class that keeps track of the sign colors for a given sign
 | 
			
		||||
@@ -23,7 +24,7 @@ public class SignData {
 | 
			
		||||
     * @param mainSignColor      <p>The main color to use for the sign</p>
 | 
			
		||||
     * @param highlightSignColor <p>The highlighting color to use for the sign</p>
 | 
			
		||||
     */
 | 
			
		||||
    public SignData(Sign sign, ChatColor mainSignColor, ChatColor highlightSignColor) {
 | 
			
		||||
    public SignData(@NotNull Sign sign, @NotNull ChatColor mainSignColor, @NotNull ChatColor highlightSignColor) {
 | 
			
		||||
        this.sign = sign;
 | 
			
		||||
        this.mainSignColor = mainSignColor;
 | 
			
		||||
        this.highlightSignColor = highlightSignColor;
 | 
			
		||||
@@ -35,6 +36,7 @@ public class SignData {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The sign of this sign colors object</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Sign getSign() {
 | 
			
		||||
        return sign;
 | 
			
		||||
    }
 | 
			
		||||
@@ -44,6 +46,7 @@ public class SignData {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The main color of the sign</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public ChatColor getMainSignColor() {
 | 
			
		||||
        if (dyedColor != DyeColor.BLACK) {
 | 
			
		||||
            return ColorHelper.fromColor(dyedColor.getColor());
 | 
			
		||||
@@ -57,6 +60,7 @@ public class SignData {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The highlighting color of the sign</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public ChatColor getHighlightSignColor() {
 | 
			
		||||
        if (dyedColor != DyeColor.BLACK) {
 | 
			
		||||
            return ColorHelper.fromColor(ColorHelper.invert(dyedColor.getColor()));
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ public class StargateAccessEvent extends StargatePlayerEvent {
 | 
			
		||||
     * @param portal <p>The portal involved in the event</p>
 | 
			
		||||
     * @param deny   <p>Whether the stargate access should be denied</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargateAccessEvent(Player player, Portal portal, boolean deny) {
 | 
			
		||||
    public StargateAccessEvent(@NotNull Player player, @NotNull Portal portal, boolean deny) {
 | 
			
		||||
        super(portal, player);
 | 
			
		||||
 | 
			
		||||
        this.deny = deny;
 | 
			
		||||
@@ -53,6 +53,7 @@ public class StargateAccessEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A handler-list with all event handlers</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static HandlerList getHandlerList() {
 | 
			
		||||
        return handlers;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,8 @@ public class StargateActivateEvent extends StargatePlayerEvent {
 | 
			
		||||
     * @param destinations <p>The destinations available to the player using the portal</p>
 | 
			
		||||
     * @param destination  <p>The currently selected destination</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargateActivateEvent(Portal portal, Player player, List<String> destinations, String destination) {
 | 
			
		||||
    public StargateActivateEvent(@NotNull Portal portal, @NotNull Player player, @NotNull List<String> destinations,
 | 
			
		||||
                                 @NotNull String destination) {
 | 
			
		||||
        super(portal, player);
 | 
			
		||||
 | 
			
		||||
        this.destinations = destinations;
 | 
			
		||||
@@ -40,6 +41,7 @@ public class StargateActivateEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The destinations available for the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public List<String> getDestinations() {
 | 
			
		||||
        return destinations;
 | 
			
		||||
    }
 | 
			
		||||
@@ -49,7 +51,7 @@ public class StargateActivateEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @param destinations <p>The new list of available destinations</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setDestinations(List<String> destinations) {
 | 
			
		||||
    public void setDestinations(@NotNull List<String> destinations) {
 | 
			
		||||
        this.destinations = destinations;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -58,6 +60,7 @@ public class StargateActivateEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The selected destination</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getDestination() {
 | 
			
		||||
        return destination;
 | 
			
		||||
    }
 | 
			
		||||
@@ -67,7 +70,7 @@ public class StargateActivateEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @param destination <p>The new selected destination</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setDestination(String destination) {
 | 
			
		||||
    public void setDestination(@NotNull String destination) {
 | 
			
		||||
        this.destination = destination;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -76,6 +79,7 @@ public class StargateActivateEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A handler-list with all event handlers</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static HandlerList getHandlerList() {
 | 
			
		||||
        return handlers;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ public class StargateCloseEvent extends StargateEvent {
 | 
			
		||||
     * @param portal <p>The portal to close</p>
 | 
			
		||||
     * @param force  <p>Whether to force the gate to close, even if set as always-on</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargateCloseEvent(Portal portal, boolean force) {
 | 
			
		||||
    public StargateCloseEvent(@NotNull Portal portal, boolean force) {
 | 
			
		||||
        super(portal);
 | 
			
		||||
 | 
			
		||||
        this.force = force;
 | 
			
		||||
@@ -51,6 +51,7 @@ public class StargateCloseEvent extends StargateEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A handler-list with all event handlers</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static HandlerList getHandlerList() {
 | 
			
		||||
        return handlers;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,8 @@ public class StargateCreateEvent extends StargatePlayerEvent {
 | 
			
		||||
     * @param denyReason <p>The reason stargate creation was denied</p>
 | 
			
		||||
     * @param cost       <p>The cost of creating the new star gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargateCreateEvent(Player player, Portal portal, String[] lines, boolean deny, String denyReason, int cost) {
 | 
			
		||||
    public StargateCreateEvent(@NotNull Player player, @NotNull Portal portal, @NotNull String[] lines, boolean deny,
 | 
			
		||||
                               @NotNull String denyReason, int cost) {
 | 
			
		||||
        super(portal, player);
 | 
			
		||||
        this.lines = lines;
 | 
			
		||||
        this.deny = deny;
 | 
			
		||||
@@ -44,6 +45,7 @@ public class StargateCreateEvent extends StargatePlayerEvent {
 | 
			
		||||
     * @return <p>The text on the given line</p>
 | 
			
		||||
     * @throws IndexOutOfBoundsException <p>If given a line index less than zero or above three</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getLine(int index) throws IndexOutOfBoundsException {
 | 
			
		||||
        return lines[index];
 | 
			
		||||
    }
 | 
			
		||||
@@ -71,6 +73,7 @@ public class StargateCreateEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The reason the stargate creation was denied</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getDenyReason() {
 | 
			
		||||
        return denyReason;
 | 
			
		||||
    }
 | 
			
		||||
@@ -80,7 +83,7 @@ public class StargateCreateEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @param denyReason <p>The new reason why the stargate creation was denied</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setDenyReason(String denyReason) {
 | 
			
		||||
    public void setDenyReason(@NotNull String denyReason) {
 | 
			
		||||
        this.denyReason = denyReason;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -107,6 +110,7 @@ public class StargateCreateEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A handler-list with all event handlers</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static HandlerList getHandlerList() {
 | 
			
		||||
        return handlers;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ public class StargateDeactivateEvent extends StargateEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The portal which was deactivated</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargateDeactivateEvent(Portal portal) {
 | 
			
		||||
    public StargateDeactivateEvent(@NotNull Portal portal) {
 | 
			
		||||
        super(portal);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -29,6 +29,7 @@ public class StargateDeactivateEvent extends StargateEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A handler-list with all event handlers</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static HandlerList getHandlerList() {
 | 
			
		||||
        return handlers;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,8 @@ public class StargateDestroyEvent extends StargatePlayerEvent {
 | 
			
		||||
     * @param denyMsg <p>The message to display if the event is denied</p>
 | 
			
		||||
     * @param cost    <p>The cost of destroying the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargateDestroyEvent(Portal portal, Player player, boolean deny, String denyMsg, int cost) {
 | 
			
		||||
    public StargateDestroyEvent(@NotNull Portal portal, @NotNull Player player, boolean deny, @NotNull String denyMsg,
 | 
			
		||||
                                int cost) {
 | 
			
		||||
        super(portal, player);
 | 
			
		||||
        this.deny = deny;
 | 
			
		||||
        this.denyReason = denyMsg;
 | 
			
		||||
@@ -57,6 +58,7 @@ public class StargateDestroyEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The reason the event was denied</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getDenyReason() {
 | 
			
		||||
        return denyReason;
 | 
			
		||||
    }
 | 
			
		||||
@@ -66,7 +68,7 @@ public class StargateDestroyEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @param denyReason <p>The reason the event was denied</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setDenyReason(String denyReason) {
 | 
			
		||||
    public void setDenyReason(@NotNull String denyReason) {
 | 
			
		||||
        this.denyReason = denyReason;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -93,6 +95,7 @@ public class StargateDestroyEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A handler-list with all event handlers</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static HandlerList getHandlerList() {
 | 
			
		||||
        return handlers;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,8 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
 | 
			
		||||
     * @param destination      <p>The destination the entity should exit from</p>
 | 
			
		||||
     * @param exit             <p>The exit location of the destination portal the entity will be teleported to</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargateEntityPortalEvent(Entity travellingEntity, Portal portal, Portal destination, Location exit) {
 | 
			
		||||
    public StargateEntityPortalEvent(@NotNull Entity travellingEntity, @NotNull Portal portal,
 | 
			
		||||
                                     @NotNull Portal destination, @NotNull Location exit) {
 | 
			
		||||
        super(portal);
 | 
			
		||||
 | 
			
		||||
        this.travellingEntity = travellingEntity;
 | 
			
		||||
@@ -40,6 +41,7 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The non-player teleporting</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Entity getEntity() {
 | 
			
		||||
        return travellingEntity;
 | 
			
		||||
    }
 | 
			
		||||
@@ -49,6 +51,7 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The destination portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Portal getDestination() {
 | 
			
		||||
        return destination;
 | 
			
		||||
    }
 | 
			
		||||
@@ -59,6 +62,7 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
 | 
			
		||||
     * @return <p>Location of the exit point</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Location getExit() {
 | 
			
		||||
        return exit;
 | 
			
		||||
    }
 | 
			
		||||
@@ -68,7 +72,7 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
 | 
			
		||||
     *
 | 
			
		||||
     * @param location <p>The new location of the entity's exit point</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setExit(Location location) {
 | 
			
		||||
    public void setExit(@NotNull Location location) {
 | 
			
		||||
        this.exit = location;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -77,6 +81,7 @@ public class StargateEntityPortalEvent extends StargateEvent implements Stargate
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A handler-list with all event handlers</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static HandlerList getHandlerList() {
 | 
			
		||||
        return handlers;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package net.knarcraft.stargate.event;
 | 
			
		||||
import net.knarcraft.stargate.portal.Portal;
 | 
			
		||||
import org.bukkit.event.Cancellable;
 | 
			
		||||
import org.bukkit.event.Event;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * An abstract event describing any stargate event
 | 
			
		||||
@@ -18,7 +19,7 @@ public abstract class StargateEvent extends Event implements Cancellable {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The portal involved in this stargate event</p>
 | 
			
		||||
     */
 | 
			
		||||
    StargateEvent(Portal portal) {
 | 
			
		||||
    StargateEvent(@NotNull Portal portal) {
 | 
			
		||||
        this.portal = portal;
 | 
			
		||||
        this.cancelled = false;
 | 
			
		||||
    }
 | 
			
		||||
@@ -28,6 +29,7 @@ public abstract class StargateEvent extends Event implements Cancellable {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The portal involved in this stargate event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Portal getPortal() {
 | 
			
		||||
        return portal;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ import net.knarcraft.stargate.portal.Portal;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.event.HandlerList;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This event should be called whenever a player opens a stargate
 | 
			
		||||
@@ -23,7 +24,7 @@ public class StargateOpenEvent extends StargatePlayerEvent {
 | 
			
		||||
     * @param portal <p>The opened portal</p>
 | 
			
		||||
     * @param force  <p>Whether to force the portal open</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargateOpenEvent(Player player, Portal portal, boolean force) {
 | 
			
		||||
    public StargateOpenEvent(@Nullable Player player, @NotNull Portal portal, boolean force) {
 | 
			
		||||
        super(portal, player);
 | 
			
		||||
 | 
			
		||||
        this.force = force;
 | 
			
		||||
@@ -52,6 +53,7 @@ public class StargateOpenEvent extends StargatePlayerEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A handler-list with all event handlers</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static HandlerList getHandlerList() {
 | 
			
		||||
        return handlers;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@ package net.knarcraft.stargate.event;
 | 
			
		||||
 | 
			
		||||
import net.knarcraft.stargate.portal.Portal;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * An abstract event describing any stargate event where a player is involved
 | 
			
		||||
@@ -16,7 +18,7 @@ public abstract class StargatePlayerEvent extends StargateEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The portal involved in this stargate event</p>
 | 
			
		||||
     */
 | 
			
		||||
    StargatePlayerEvent(Portal portal, Player player) {
 | 
			
		||||
    StargatePlayerEvent(@NotNull Portal portal, @Nullable Player player) {
 | 
			
		||||
        super(portal);
 | 
			
		||||
        this.player = player;
 | 
			
		||||
    }
 | 
			
		||||
@@ -26,6 +28,7 @@ public abstract class StargatePlayerEvent extends StargateEvent {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The player creating the star gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Player getPlayer() {
 | 
			
		||||
        return player;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,8 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent implements St
 | 
			
		||||
     * @param destination <p>The destination the player should exit from</p>
 | 
			
		||||
     * @param exit        <p>The exit location of the destination portal the user will be teleported to</p>
 | 
			
		||||
     */
 | 
			
		||||
    public StargatePlayerPortalEvent(Player player, Portal portal, Portal destination, Location exit) {
 | 
			
		||||
    public StargatePlayerPortalEvent(@NotNull Player player, @NotNull Portal portal, @NotNull Portal destination,
 | 
			
		||||
                                     @NotNull Location exit) {
 | 
			
		||||
        super(portal, player);
 | 
			
		||||
 | 
			
		||||
        this.destination = destination;
 | 
			
		||||
@@ -38,6 +39,7 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent implements St
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The destination portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Portal getDestination() {
 | 
			
		||||
        return destination;
 | 
			
		||||
    }
 | 
			
		||||
@@ -48,6 +50,7 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent implements St
 | 
			
		||||
     * @return <p>Location of the exit point</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Location getExit() {
 | 
			
		||||
        return exit;
 | 
			
		||||
    }
 | 
			
		||||
@@ -57,7 +60,7 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent implements St
 | 
			
		||||
     *
 | 
			
		||||
     * @param location <p>The new location of the player's exit point</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setExit(Location location) {
 | 
			
		||||
    public void setExit(@NotNull Location location) {
 | 
			
		||||
        this.exit = location;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -66,6 +69,7 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent implements St
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A handler-list with all event handlers</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static HandlerList getHandlerList() {
 | 
			
		||||
        return handlers;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package net.knarcraft.stargate.event;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.event.Cancellable;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A generic teleportation event
 | 
			
		||||
@@ -13,6 +14,7 @@ public interface StargateTeleportEvent extends Cancellable {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>Location of the exit point</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    Location getExit();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@ import org.bukkit.event.block.BlockPistonRetractEvent;
 | 
			
		||||
import org.bukkit.event.block.BlockPlaceEvent;
 | 
			
		||||
import org.bukkit.event.block.EntityBlockFormEvent;
 | 
			
		||||
import org.bukkit.event.block.SignChangeEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@@ -46,7 +47,7 @@ public class BlockEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The triggered event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onBlockFormedByEntity(EntityBlockFormEvent event) {
 | 
			
		||||
    public void onBlockFormedByEntity(@NotNull EntityBlockFormEvent event) {
 | 
			
		||||
        if (event.isCancelled() || (!Stargate.getGateConfig().protectEntrance() &&
 | 
			
		||||
                !Stargate.getGateConfig().verifyPortals())) {
 | 
			
		||||
            return;
 | 
			
		||||
@@ -67,7 +68,7 @@ public class BlockEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The triggered event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onSignChange(SignChangeEvent event) {
 | 
			
		||||
    public void onSignChange(@NotNull SignChangeEvent event) {
 | 
			
		||||
        if (event.isCancelled()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -98,7 +99,7 @@ public class BlockEventListener implements Listener {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @EventHandler(priority = EventPriority.HIGHEST)
 | 
			
		||||
    public void onBlockPlace(BlockPlaceEvent event) {
 | 
			
		||||
    public void onBlockPlace(@NotNull BlockPlaceEvent event) {
 | 
			
		||||
        if (event.isCancelled() || !Stargate.getGateConfig().protectEntrance()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -119,7 +120,7 @@ public class BlockEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The triggered event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler(priority = EventPriority.HIGHEST)
 | 
			
		||||
    public void onBlockBreak(BlockBreakEvent event) {
 | 
			
		||||
    public void onBlockBreak(@NotNull BlockBreakEvent event) {
 | 
			
		||||
        if (event.isCancelled()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -182,8 +183,8 @@ public class BlockEventListener implements Listener {
 | 
			
		||||
     * @param event        <p>The break event</p>
 | 
			
		||||
     * @return <p>True if the payment was successful. False if the event was cancelled</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean handleEconomyPayment(StargateDestroyEvent destroyEvent, Player player, Portal portal,
 | 
			
		||||
                                         BlockBreakEvent event) {
 | 
			
		||||
    private boolean handleEconomyPayment(@NotNull StargateDestroyEvent destroyEvent, @NotNull Player player,
 | 
			
		||||
                                         @NotNull Portal portal, @NotNull BlockBreakEvent event) {
 | 
			
		||||
        int cost = destroyEvent.getCost();
 | 
			
		||||
        if (cost != 0) {
 | 
			
		||||
            String portalName = portal.getName();
 | 
			
		||||
@@ -210,7 +211,7 @@ public class BlockEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The event to check and possibly cancel</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onBlockPhysics(BlockPhysicsEvent event) {
 | 
			
		||||
    public void onBlockPhysics(@NotNull BlockPhysicsEvent event) {
 | 
			
		||||
        Block block = event.getBlock();
 | 
			
		||||
        Portal portal = null;
 | 
			
		||||
 | 
			
		||||
@@ -230,7 +231,7 @@ public class BlockEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The event to check and possibly cancel</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onBlockFromTo(BlockFromToEvent event) {
 | 
			
		||||
    public void onBlockFromTo(@NotNull BlockFromToEvent event) {
 | 
			
		||||
        Portal portal = PortalHandler.getByEntrance(event.getBlock());
 | 
			
		||||
 | 
			
		||||
        if (portal != null) {
 | 
			
		||||
@@ -244,7 +245,7 @@ public class BlockEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The event to check and possibly cancel</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPistonExtend(BlockPistonExtendEvent event) {
 | 
			
		||||
    public void onPistonExtend(@NotNull BlockPistonExtendEvent event) {
 | 
			
		||||
        cancelPistonEvent(event, event.getBlocks());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -254,7 +255,7 @@ public class BlockEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The event to check and possibly cancel</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPistonRetract(BlockPistonRetractEvent event) {
 | 
			
		||||
    public void onPistonRetract(@NotNull BlockPistonRetractEvent event) {
 | 
			
		||||
        if (!event.isSticky()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -267,7 +268,7 @@ public class BlockEventListener implements Listener {
 | 
			
		||||
     * @param event  <p>The event to cancel</p>
 | 
			
		||||
     * @param blocks <p>The blocks included in the event</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void cancelPistonEvent(BlockPistonEvent event, List<Block> blocks) {
 | 
			
		||||
    private void cancelPistonEvent(@NotNull BlockPistonEvent event, @NotNull List<Block> blocks) {
 | 
			
		||||
        for (Block block : blocks) {
 | 
			
		||||
            Portal portal = PortalHandler.getByBlock(block);
 | 
			
		||||
            if (portal != null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ import org.bukkit.event.EventPriority;
 | 
			
		||||
import org.bukkit.event.Listener;
 | 
			
		||||
import org.bukkit.event.entity.EntityExplodeEvent;
 | 
			
		||||
import org.bukkit.event.entity.EntityPortalEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This listener listens for any relevant events on portal entities
 | 
			
		||||
@@ -25,7 +26,7 @@ public class EntityEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The event to check and possibly cancel</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler(priority = EventPriority.LOWEST)
 | 
			
		||||
    public void onPortalEvent(EntityPortalEvent event) {
 | 
			
		||||
    public void onPortalEvent(@NotNull EntityPortalEvent event) {
 | 
			
		||||
        if (event.isCancelled()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -46,7 +47,7 @@ public class EntityEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The triggered explosion event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onEntityExplode(EntityExplodeEvent event) {
 | 
			
		||||
    public void onEntityExplode(@NotNull EntityExplodeEvent event) {
 | 
			
		||||
        if (event.isCancelled()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import net.knarcraft.stargate.portal.PortalHandler;
 | 
			
		||||
import org.bukkit.event.EventHandler;
 | 
			
		||||
import org.bukkit.event.Listener;
 | 
			
		||||
import org.bukkit.event.entity.CreatureSpawnEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A listener that listens for any relevant events causing entities to spawn
 | 
			
		||||
@@ -12,13 +13,12 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
 | 
			
		||||
public class EntitySpawnListener implements Listener {
 | 
			
		||||
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onCreatureSpawn(CreatureSpawnEvent event) {
 | 
			
		||||
    public void onCreatureSpawn(@NotNull CreatureSpawnEvent event) {
 | 
			
		||||
        //Prevent Zombified Piglins and other creatures form spawning at stargates
 | 
			
		||||
        if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.NETHER_PORTAL) {
 | 
			
		||||
            if (PortalHandler.getByEntrance(event.getLocation()) != null) {
 | 
			
		||||
                event.setCancelled(true);
 | 
			
		||||
                Stargate.debug("EntitySpawnListener", "Prevented creature from spawning at Stargate");
 | 
			
		||||
            }
 | 
			
		||||
        if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.NETHER_PORTAL &&
 | 
			
		||||
                PortalHandler.getByEntrance(event.getLocation()) != null) {
 | 
			
		||||
            event.setCancelled(true);
 | 
			
		||||
            Stargate.debug("EntitySpawnListener", "Prevented creature from spawning at Stargate");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
 | 
			
		||||
import org.bukkit.inventory.EquipmentSlot;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
import org.bukkit.util.Vector;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
@@ -53,7 +55,7 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The event to check for a teleporting player</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPlayerJoin(PlayerJoinEvent event) {
 | 
			
		||||
    public void onPlayerJoin(@NotNull PlayerJoinEvent event) {
 | 
			
		||||
        Player player = event.getPlayer();
 | 
			
		||||
        //Migrate player name to UUID if necessary
 | 
			
		||||
        UUIDMigrationHelper.migrateUUID(player);
 | 
			
		||||
@@ -91,7 +93,7 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The player move event which was triggered</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPlayerMove(PlayerMoveEvent event) {
 | 
			
		||||
    public void onPlayerMove(@NotNull PlayerMoveEvent event) {
 | 
			
		||||
        if (event.isCancelled() || event.getTo() == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -108,9 +110,16 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
        //Check an additional block away in case the portal is a bungee portal using END_PORTAL
 | 
			
		||||
        if (entrancePortal == null) {
 | 
			
		||||
            entrancePortal = PortalHandler.getByAdjacentEntrance(toLocation);
 | 
			
		||||
            // This should never realistically be null
 | 
			
		||||
            if (entrancePortal == null) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Portal destination = entrancePortal.getPortalActivator().getDestination(player);
 | 
			
		||||
        if (destination == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Entity playerVehicle = player.getVehicle();
 | 
			
		||||
        //If the player is in a vehicle, but vehicle handling is disabled, just ignore the player
 | 
			
		||||
@@ -129,8 +138,8 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
     * @param destination    <p>The destination of the entrance portal</p>
 | 
			
		||||
     * @param event          <p>The move event causing the teleportation to trigger</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void teleportPlayer(Entity playerVehicle, Player player, Portal entrancePortal, Portal destination,
 | 
			
		||||
                                PlayerMoveEvent event) {
 | 
			
		||||
    private void teleportPlayer(@Nullable Entity playerVehicle, @NotNull Player player, @NotNull Portal entrancePortal,
 | 
			
		||||
                                @NotNull Portal destination, @NotNull PlayerMoveEvent event) {
 | 
			
		||||
        if (playerVehicle instanceof LivingEntity) {
 | 
			
		||||
            //Make sure any horses are properly tamed
 | 
			
		||||
            if (playerVehicle instanceof AbstractHorse horse && !horse.isTamed()) {
 | 
			
		||||
@@ -159,8 +168,8 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
     * @param toLocation   <p>The location the player is moving to</p>
 | 
			
		||||
     * @return <p>True if the event is relevant</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean isRelevantMoveEvent(PlayerMoveEvent event, Player player, BlockLocation fromLocation,
 | 
			
		||||
                                        BlockLocation toLocation) {
 | 
			
		||||
    private boolean isRelevantMoveEvent(@NotNull PlayerMoveEvent event, Player player,
 | 
			
		||||
                                        @NotNull BlockLocation fromLocation, @NotNull BlockLocation toLocation) {
 | 
			
		||||
        //Check to see if the player moved to another block
 | 
			
		||||
        if (fromLocation.equals(toLocation)) {
 | 
			
		||||
            return false;
 | 
			
		||||
@@ -207,7 +216,7 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The player interact event which was triggered</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPlayerInteract(PlayerInteractEvent event) {
 | 
			
		||||
    public void onPlayerInteract(@NotNull PlayerInteractEvent event) {
 | 
			
		||||
        Player player = event.getPlayer();
 | 
			
		||||
        Block block = event.getClickedBlock();
 | 
			
		||||
 | 
			
		||||
@@ -216,6 +225,10 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
 | 
			
		||||
            if (event.getHand() == null) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // Handle right-click of a sign, button or other
 | 
			
		||||
            handleRightClickBlock(event, player, block, event.getHand());
 | 
			
		||||
        } else if (event.getAction() == Action.LEFT_CLICK_BLOCK && block.getBlockData() instanceof WallSign) {
 | 
			
		||||
            //Handle left click of a wall sign
 | 
			
		||||
@@ -231,7 +244,8 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
     * @param block     <p>The block that was clicked</p>
 | 
			
		||||
     * @param leftClick <p>Whether the player performed a left click as opposed to a right click</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void handleSignClick(PlayerInteractEvent event, Player player, Block block, boolean leftClick) {
 | 
			
		||||
    private void handleSignClick(@NotNull PlayerInteractEvent event, @NotNull Player player, @NotNull Block block,
 | 
			
		||||
                                 boolean leftClick) {
 | 
			
		||||
        Portal portal = PortalHandler.getByBlock(block);
 | 
			
		||||
        if (portal == null) {
 | 
			
		||||
            return;
 | 
			
		||||
@@ -286,7 +300,7 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
     * @param portal <p>The portal the player is trying to use</p>
 | 
			
		||||
     * @return <p>True if the player should be denied</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean cannotAccessPortal(Player player, Portal portal) {
 | 
			
		||||
    private boolean cannotAccessPortal(@NotNull Player player, @NotNull Portal portal) {
 | 
			
		||||
        boolean deny = PermissionHelper.cannotAccessNetwork(player, portal.getCleanNetwork());
 | 
			
		||||
 | 
			
		||||
        if (PermissionHelper.portalAccessDenied(player, portal, deny)) {
 | 
			
		||||
@@ -306,7 +320,8 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
     * @param block  <p>The block the player clicked</p>
 | 
			
		||||
     * @param hand   <p>The hand the player used to interact with the stargate</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void handleRightClickBlock(PlayerInteractEvent event, Player player, Block block, EquipmentSlot hand) {
 | 
			
		||||
    private void handleRightClickBlock(@NotNull PlayerInteractEvent event, @NotNull Player player, @NotNull Block block,
 | 
			
		||||
                                       @NotNull EquipmentSlot hand) {
 | 
			
		||||
        if (block.getBlockData() instanceof WallSign) {
 | 
			
		||||
            handleSignClick(event, player, block, false);
 | 
			
		||||
            return;
 | 
			
		||||
@@ -353,7 +368,7 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
     * @param block  <p>The clicked block</p>
 | 
			
		||||
     * @param player <p>The player that clicked the block</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void displayPortalInfo(Block block, Player player) {
 | 
			
		||||
    private void displayPortalInfo(@NotNull Block block, @NotNull Player player) {
 | 
			
		||||
        Portal portal = PortalHandler.getByBlock(block);
 | 
			
		||||
        if (portal == null) {
 | 
			
		||||
            return;
 | 
			
		||||
@@ -363,15 +378,15 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
        if (portal.getOptions().hasNoSign() && (!portal.getOptions().isSilent() || player.isSneaking())) {
 | 
			
		||||
            MessageSender sender = Stargate.getMessageSender();
 | 
			
		||||
            sender.sendSuccessMessage(player, ChatColor.GOLD + Stargate.getString("portalInfoTitle"));
 | 
			
		||||
            sender.sendSuccessMessage(player, Stargate.replaceVars(Stargate.getString("portalInfoName"),
 | 
			
		||||
            sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString("portalInfoName"),
 | 
			
		||||
                    "%name%", portal.getName()));
 | 
			
		||||
            sender.sendSuccessMessage(player, Stargate.replaceVars(Stargate.getString("portalInfoDestination"),
 | 
			
		||||
            sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString("portalInfoDestination"),
 | 
			
		||||
                    "%destination%", portal.getDestinationName()));
 | 
			
		||||
            if (portal.getOptions().isBungee()) {
 | 
			
		||||
                sender.sendSuccessMessage(player, Stargate.replaceVars(Stargate.getString("portalInfoServer"),
 | 
			
		||||
                sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString("portalInfoServer"),
 | 
			
		||||
                        "%server%", portal.getNetwork()));
 | 
			
		||||
            } else {
 | 
			
		||||
                sender.sendSuccessMessage(player, Stargate.replaceVars(Stargate.getString("portalInfoNetwork"),
 | 
			
		||||
                sender.sendSuccessMessage(player, Stargate.replacePlaceholders(Stargate.getString("portalInfoNetwork"),
 | 
			
		||||
                        "%network%", portal.getNetwork()));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -388,7 +403,7 @@ public class PlayerEventListener implements Listener {
 | 
			
		||||
     * @param block  <p>The block to check</p>
 | 
			
		||||
     * @return <p>True if the click is a bug and should be cancelled</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean clickIsBug(Player player, Block block) {
 | 
			
		||||
    private boolean clickIsBug(@NotNull Player player, @NotNull Block block) {
 | 
			
		||||
        Long previousEventTime = previousEventTimes.get(player);
 | 
			
		||||
        if (previousEventTime != null && previousEventTime + 50 > System.currentTimeMillis()) {
 | 
			
		||||
            previousEventTimes.put(player, null);
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@ import org.bukkit.event.EventHandler;
 | 
			
		||||
import org.bukkit.event.Listener;
 | 
			
		||||
import org.bukkit.event.server.PluginDisableEvent;
 | 
			
		||||
import org.bukkit.event.server.PluginEnableEvent;
 | 
			
		||||
import org.bukkit.plugin.Plugin;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This listener listens for any plugins being enabled or disabled to catch the loading of vault
 | 
			
		||||
@@ -19,7 +21,7 @@ public class PluginEventListener implements Listener {
 | 
			
		||||
     *
 | 
			
		||||
     * @param stargate <p>A reference to the stargate plugin to </p>
 | 
			
		||||
     */
 | 
			
		||||
    public PluginEventListener(Stargate stargate) {
 | 
			
		||||
    public PluginEventListener(@NotNull Stargate stargate) {
 | 
			
		||||
        this.stargate = stargate;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -31,10 +33,14 @@ public class PluginEventListener implements Listener {
 | 
			
		||||
     * @param ignored <p>The actual event called. This is currently not used</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPluginEnable(PluginEnableEvent ignored) {
 | 
			
		||||
    public void onPluginEnable(@NotNull PluginEnableEvent ignored) {
 | 
			
		||||
        if (Stargate.getEconomyConfig().setupEconomy(stargate.getServer().getPluginManager())) {
 | 
			
		||||
            String vaultVersion = Stargate.getEconomyConfig().getVault().getDescription().getVersion();
 | 
			
		||||
            Stargate.logInfo(Stargate.replaceVars(Stargate.getString("vaultLoaded"), "%version%", vaultVersion));
 | 
			
		||||
            Plugin vault = Stargate.getEconomyConfig().getVault();
 | 
			
		||||
            if (vault != null) {
 | 
			
		||||
                String vaultVersion = vault.getDescription().getVersion();
 | 
			
		||||
                Stargate.logInfo(Stargate.replacePlaceholders(Stargate.getString("vaultLoaded"), "%version%",
 | 
			
		||||
                        vaultVersion));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -44,7 +50,7 @@ public class PluginEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The event caused by disabling a plugin</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPluginDisable(PluginDisableEvent event) {
 | 
			
		||||
    public void onPluginDisable(@NotNull PluginDisableEvent event) {
 | 
			
		||||
        if (event.getPlugin().equals(Stargate.getEconomyConfig().getVault())) {
 | 
			
		||||
            Stargate.logInfo("Vault plugin lost.");
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -17,16 +17,17 @@ import org.bukkit.event.Listener;
 | 
			
		||||
import org.bukkit.event.entity.EntityPortalEnterEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerRespawnEvent;
 | 
			
		||||
import org.bukkit.event.world.PortalCreateEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Listens for and cancels relevant portal events
 | 
			
		||||
 */
 | 
			
		||||
public class PortalEventListener implements Listener {
 | 
			
		||||
 | 
			
		||||
    private static final List<FromTheEndTeleportation> playersFromTheEnd = new ArrayList<>();
 | 
			
		||||
    private static final Map<Player, FromTheEndTeleportation> playersFromTheEnd = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Listens for and aborts vanilla portal creation caused by stargate creation
 | 
			
		||||
@@ -34,7 +35,7 @@ public class PortalEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The triggered event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPortalCreation(PortalCreateEvent event) {
 | 
			
		||||
    public void onPortalCreation(@NotNull PortalCreateEvent event) {
 | 
			
		||||
        if (event.isCancelled()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -56,32 +57,37 @@ public class PortalEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The triggered event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onEntityPortalEnter(EntityPortalEnterEvent event) {
 | 
			
		||||
    public void onEntityPortalEnter(@NotNull EntityPortalEnterEvent event) {
 | 
			
		||||
        Location location = event.getLocation();
 | 
			
		||||
        World world = location.getWorld();
 | 
			
		||||
        Entity entity = event.getEntity();
 | 
			
		||||
        //Hijack normal portal teleportation if teleporting from a stargate
 | 
			
		||||
        if (entity instanceof Player player && location.getBlock().getType() == Material.END_PORTAL && world != null &&
 | 
			
		||||
                world.getEnvironment() == World.Environment.THE_END) {
 | 
			
		||||
            Portal portal = PortalHandler.getByAdjacentEntrance(location);
 | 
			
		||||
            if (portal == null) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        //Hijack normal portal teleportation if teleporting from a stargate, and teleporting from an end portal in the
 | 
			
		||||
        // end
 | 
			
		||||
        if (!(entity instanceof Player player) || location.getBlock().getType() != Material.END_PORTAL ||
 | 
			
		||||
                world == null || world.getEnvironment() != World.Environment.THE_END) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Portal portal = PortalHandler.getByAdjacentEntrance(location);
 | 
			
		||||
        if (portal == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Stargate.debug("PortalEventListener::onEntityPortalEnter",
 | 
			
		||||
                "Found player " + player + " entering END_PORTAL " + portal);
 | 
			
		||||
 | 
			
		||||
        //Decide if the anything stops the player from teleporting
 | 
			
		||||
        if (PermissionHelper.playerCannotTeleport(portal, portal.getPortalActivator().getDestination(),
 | 
			
		||||
                player, null) || portal.getOptions().isBungee()) {
 | 
			
		||||
            //Teleport the player back to the portal they came in, just in case
 | 
			
		||||
            playersFromTheEnd.put(player, new FromTheEndTeleportation(portal));
 | 
			
		||||
            Stargate.debug("PortalEventListener::onEntityPortalEnter",
 | 
			
		||||
                    "Found player " + player + " entering END_PORTAL " + portal);
 | 
			
		||||
 | 
			
		||||
            //Remove any old player teleportations in case weird things happen
 | 
			
		||||
            playersFromTheEnd.removeIf((teleportation -> teleportation.getPlayer() == player));
 | 
			
		||||
            //Decide if the anything stops the player from teleporting
 | 
			
		||||
            if (PermissionHelper.playerCannotTeleport(portal, portal.getPortalActivator().getDestination(), player, null) ||
 | 
			
		||||
                    portal.getOptions().isBungee()) {
 | 
			
		||||
                //Teleport the player back to the portal they came in, just in case
 | 
			
		||||
                playersFromTheEnd.add(new FromTheEndTeleportation(player, portal));
 | 
			
		||||
                Stargate.debug("PortalEventListener::onEntityPortalEnter",
 | 
			
		||||
                        "Sending player back to the entrance");
 | 
			
		||||
            } else {
 | 
			
		||||
                playersFromTheEnd.add(new FromTheEndTeleportation(player, portal.getPortalActivator().getDestination()));
 | 
			
		||||
                    "Sending player back to the entrance");
 | 
			
		||||
        } else {
 | 
			
		||||
            Portal destination = portal.getPortalActivator().getDestination();
 | 
			
		||||
            if (destination != null) {
 | 
			
		||||
                playersFromTheEnd.put(player, new FromTheEndTeleportation(destination));
 | 
			
		||||
                Stargate.debug("PortalEventListener::onEntityPortalEnter",
 | 
			
		||||
                        "Sending player to destination");
 | 
			
		||||
            }
 | 
			
		||||
@@ -94,16 +100,11 @@ public class PortalEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The triggered event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onRespawn(PlayerRespawnEvent event) {
 | 
			
		||||
    public void onRespawn(@NotNull PlayerRespawnEvent event) {
 | 
			
		||||
        Player respawningPlayer = event.getPlayer();
 | 
			
		||||
        int playerIndex = playersFromTheEnd.indexOf(new FromTheEndTeleportation(respawningPlayer, null));
 | 
			
		||||
        if (playerIndex == -1) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        FromTheEndTeleportation teleportation = playersFromTheEnd.get(playerIndex);
 | 
			
		||||
        playersFromTheEnd.remove(playerIndex);
 | 
			
		||||
        FromTheEndTeleportation teleportation = playersFromTheEnd.remove(respawningPlayer);
 | 
			
		||||
        Portal exitPortal = teleportation.exitPortal();
 | 
			
		||||
 | 
			
		||||
        Portal exitPortal = teleportation.getExit();
 | 
			
		||||
        //Overwrite respawn location to respawn in front of the portal
 | 
			
		||||
        PlayerTeleporter teleporter = new PlayerTeleporter(exitPortal, respawningPlayer);
 | 
			
		||||
        Location respawnLocation = teleporter.getExit();
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ import net.knarcraft.stargate.portal.PortalHandler;
 | 
			
		||||
import org.bukkit.event.EventHandler;
 | 
			
		||||
import org.bukkit.event.Listener;
 | 
			
		||||
import org.bukkit.event.player.PlayerTeleportEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This listener listens to teleportation-related events
 | 
			
		||||
@@ -21,7 +22,7 @@ public class TeleportEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The event to check and possibly cancel</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPlayerTeleport(PlayerTeleportEvent event) {
 | 
			
		||||
    public void onPlayerTeleport(@NotNull PlayerTeleportEvent event) {
 | 
			
		||||
        PlayerTeleportEvent.TeleportCause cause = event.getCause();
 | 
			
		||||
 | 
			
		||||
        //Block normal portal teleportation if teleporting from a stargate
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ import org.bukkit.entity.Vehicle;
 | 
			
		||||
import org.bukkit.event.EventHandler;
 | 
			
		||||
import org.bukkit.event.Listener;
 | 
			
		||||
import org.bukkit.event.vehicle.VehicleMoveEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@@ -28,7 +29,7 @@ public class VehicleEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The triggered move event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onVehicleMove(VehicleMoveEvent event) {
 | 
			
		||||
    public void onVehicleMove(@NotNull VehicleMoveEvent event) {
 | 
			
		||||
        if (!Stargate.getGateConfig().handleVehicles()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -58,7 +59,8 @@ public class VehicleEventListener implements Listener {
 | 
			
		||||
     * @param entrancePortal <p>The portal the vehicle is entering</p>
 | 
			
		||||
     * @param vehicle        <p>The vehicle passing through</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void teleportVehicle(List<Entity> passengers, Portal entrancePortal, Vehicle vehicle) {
 | 
			
		||||
    private static void teleportVehicle(@NotNull List<Entity> passengers, @NotNull Portal entrancePortal,
 | 
			
		||||
                                        @NotNull Vehicle vehicle) {
 | 
			
		||||
        String route = "VehicleEventListener::teleportVehicle";
 | 
			
		||||
 | 
			
		||||
        if (!passengers.isEmpty() && TeleportHelper.containsPlayer(passengers)) {
 | 
			
		||||
@@ -83,7 +85,7 @@ public class VehicleEventListener implements Listener {
 | 
			
		||||
     * @param entrancePortal <p>The portal the minecart entered</p>
 | 
			
		||||
     * @param vehicle        <p>The vehicle to teleport</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void teleportPlayerAndVehicle(Portal entrancePortal, Vehicle vehicle) {
 | 
			
		||||
    private static void teleportPlayerAndVehicle(@NotNull Portal entrancePortal, @NotNull Vehicle vehicle) {
 | 
			
		||||
        Entity rootEntity = vehicle;
 | 
			
		||||
        while (rootEntity.getVehicle() != null) {
 | 
			
		||||
            rootEntity = rootEntity.getVehicle();
 | 
			
		||||
@@ -101,6 +103,7 @@ public class VehicleEventListener implements Listener {
 | 
			
		||||
            Portal possibleDestinationPortal = entrancePortal.getPortalActivator().getDestination(player);
 | 
			
		||||
            if (possibleDestinationPortal != null) {
 | 
			
		||||
                destinationPortal = possibleDestinationPortal;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -116,7 +119,7 @@ public class VehicleEventListener implements Listener {
 | 
			
		||||
                cancelTeleport = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (cancelTeleport) {
 | 
			
		||||
        if (cancelTeleport || destinationPortal == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler;
 | 
			
		||||
import org.bukkit.event.Listener;
 | 
			
		||||
import org.bukkit.event.world.WorldLoadEvent;
 | 
			
		||||
import org.bukkit.event.world.WorldUnloadEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This listener listens for the loading and unloading of worlds to load and unload stargates
 | 
			
		||||
@@ -22,7 +23,7 @@ public class WorldEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The triggered world load event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onWorldLoad(WorldLoadEvent event) {
 | 
			
		||||
    public void onWorldLoad(@NotNull WorldLoadEvent event) {
 | 
			
		||||
        StargateConfig config = Stargate.getStargateConfig();
 | 
			
		||||
        if (!config.getManagedWorlds().contains(event.getWorld().getName()) &&
 | 
			
		||||
                PortalFileHelper.loadAllPortals(event.getWorld())) {
 | 
			
		||||
@@ -36,7 +37,7 @@ public class WorldEventListener implements Listener {
 | 
			
		||||
     * @param event <p>The triggered world unload event</p>
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onWorldUnload(WorldUnloadEvent event) {
 | 
			
		||||
    public void onWorldUnload(@NotNull WorldUnloadEvent event) {
 | 
			
		||||
        Stargate.debug("onWorldUnload", "Reloading all Stargates");
 | 
			
		||||
        World world = event.getWorld();
 | 
			
		||||
        String worldName = world.getName();
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,8 @@ import net.knarcraft.stargate.portal.property.gate.Gate;
 | 
			
		||||
import net.md_5.bungee.api.ChatColor;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
@@ -46,8 +48,9 @@ public class Portal {
 | 
			
		||||
     * @param portalOwner    <p>The portal's owner</p>
 | 
			
		||||
     * @param options        <p>A map containing all possible portal options, with true for the ones enabled</p>
 | 
			
		||||
     */
 | 
			
		||||
    public Portal(PortalLocation portalLocation, BlockLocation button, String destination, String name, String network,
 | 
			
		||||
                  Gate gate, PortalOwner portalOwner, Map<PortalOption, Boolean> options) {
 | 
			
		||||
    public Portal(@NotNull PortalLocation portalLocation, @Nullable BlockLocation button, @NotNull String destination,
 | 
			
		||||
                  @NotNull String name, @NotNull String network, @NotNull Gate gate, @NotNull PortalOwner portalOwner,
 | 
			
		||||
                  @NotNull Map<PortalOption, Boolean> options) {
 | 
			
		||||
        this.location = portalLocation;
 | 
			
		||||
        this.network = network;
 | 
			
		||||
        this.name = name;
 | 
			
		||||
@@ -84,6 +87,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This portal's location data</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalLocation getLocation() {
 | 
			
		||||
        return this.location;
 | 
			
		||||
    }
 | 
			
		||||
@@ -96,6 +100,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This portal's structure</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalStructure getStructure() {
 | 
			
		||||
        return this.structure;
 | 
			
		||||
    }
 | 
			
		||||
@@ -108,6 +113,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This portal's activator</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalActivator getPortalActivator() {
 | 
			
		||||
        return this.portalActivator;
 | 
			
		||||
    }
 | 
			
		||||
@@ -124,6 +130,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This portal's portal options</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalOptions getOptions() {
 | 
			
		||||
        return this.options;
 | 
			
		||||
    }
 | 
			
		||||
@@ -142,6 +149,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The player currently using this portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Player getActivePlayer() {
 | 
			
		||||
        return portalActivator.getActivePlayer();
 | 
			
		||||
    }
 | 
			
		||||
@@ -151,6 +159,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The network this portal belongs to</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getNetwork() {
 | 
			
		||||
        return network;
 | 
			
		||||
    }
 | 
			
		||||
@@ -160,6 +169,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The clean network name</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getCleanNetwork() {
 | 
			
		||||
        return cleanNetwork;
 | 
			
		||||
    }
 | 
			
		||||
@@ -181,6 +191,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The name of this portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
@@ -190,6 +201,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The clean name of this portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getCleanName() {
 | 
			
		||||
        return cleanName;
 | 
			
		||||
    }
 | 
			
		||||
@@ -201,6 +213,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This portal's portal opener</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalOpener getPortalOpener() {
 | 
			
		||||
        return portalOpener;
 | 
			
		||||
    }
 | 
			
		||||
@@ -210,6 +223,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The name of this portal's destination portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getDestinationName() {
 | 
			
		||||
        return portalOpener.getPortalActivator().getDestinationName();
 | 
			
		||||
    }
 | 
			
		||||
@@ -219,6 +233,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The gate type used by this portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Gate getGate() {
 | 
			
		||||
        return structure.getGate();
 | 
			
		||||
    }
 | 
			
		||||
@@ -230,6 +245,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This portal's owner</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalOwner getOwner() {
 | 
			
		||||
        return portalOwner;
 | 
			
		||||
    }
 | 
			
		||||
@@ -240,7 +256,7 @@ public class Portal {
 | 
			
		||||
     * @param player <p>The player to check</p>
 | 
			
		||||
     * @return <p>True if the player is the owner of this portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isOwner(Player player) {
 | 
			
		||||
    public boolean isOwner(@NotNull Player player) {
 | 
			
		||||
        if (this.portalOwner.getUUID() != null) {
 | 
			
		||||
            return player.getUniqueId().compareTo(this.portalOwner.getUUID()) == 0;
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -253,6 +269,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The world this portal belongs to</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public World getWorld() {
 | 
			
		||||
        return location.getWorld();
 | 
			
		||||
    }
 | 
			
		||||
@@ -262,6 +279,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The location of this portal's sign</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockLocation getSignLocation() {
 | 
			
		||||
        return this.location.getSignLocation();
 | 
			
		||||
    }
 | 
			
		||||
@@ -283,6 +301,7 @@ public class Portal {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The location of the top-left portal block</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockLocation getTopLeft() {
 | 
			
		||||
        return this.location.getTopLeft();
 | 
			
		||||
    }
 | 
			
		||||
@@ -293,7 +312,8 @@ public class Portal {
 | 
			
		||||
     * @param vector <p>The relative block vector explaining the position of the block</p>
 | 
			
		||||
     * @return <p>The block at the given relative position</p>
 | 
			
		||||
     */
 | 
			
		||||
    public BlockLocation getBlockAt(RelativeBlockVector vector) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockLocation getBlockAt(@NotNull RelativeBlockVector vector) {
 | 
			
		||||
        return getTopLeft().getRelativeLocation(vector, getYaw());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -303,11 +323,13 @@ public class Portal {
 | 
			
		||||
     * @param string <p>The string to clean</p>
 | 
			
		||||
     * @return <p>The clean string</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static String cleanString(String string) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static String cleanString(@NotNull String string) {
 | 
			
		||||
        return ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', string)).toLowerCase();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return String.format("Portal [id=%s, network=%s name=%s, type=%s]", getSignLocation(), network, name,
 | 
			
		||||
                structure.getGate().getFilename());
 | 
			
		||||
@@ -323,7 +345,7 @@ public class Portal {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean equals(Object object) {
 | 
			
		||||
    public boolean equals(@Nullable Object object) {
 | 
			
		||||
        if (this == object) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,8 @@ import net.knarcraft.stargate.Stargate;
 | 
			
		||||
import net.knarcraft.stargate.event.StargateActivateEvent;
 | 
			
		||||
import net.knarcraft.stargate.event.StargateDeactivateEvent;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
@@ -33,7 +35,7 @@ public class PortalActivator {
 | 
			
		||||
     * @param portalOpener <p>The portal opener to trigger when the activation causes the portal to open</p>
 | 
			
		||||
     * @param destination  <p>The fixed destination specified on the portal's sign</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalActivator(Portal portal, PortalOpener portalOpener, String destination) {
 | 
			
		||||
    public PortalActivator(@NotNull Portal portal, @NotNull PortalOpener portalOpener, @NotNull String destination) {
 | 
			
		||||
        this.portal = portal;
 | 
			
		||||
        this.opener = portalOpener;
 | 
			
		||||
        this.destination = destination;
 | 
			
		||||
@@ -44,6 +46,7 @@ public class PortalActivator {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The player this activator's portal is currently activated for</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Player getActivePlayer() {
 | 
			
		||||
        return activePlayer;
 | 
			
		||||
    }
 | 
			
		||||
@@ -53,6 +56,7 @@ public class PortalActivator {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The available portal destinations</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public List<String> getDestinations() {
 | 
			
		||||
        return new ArrayList<>(this.destinations);
 | 
			
		||||
    }
 | 
			
		||||
@@ -63,7 +67,8 @@ public class PortalActivator {
 | 
			
		||||
     * @param player <p>Used for random gates to determine which destinations are available</p>
 | 
			
		||||
     * @return <p>The destination portal the player should teleport to</p>
 | 
			
		||||
     */
 | 
			
		||||
    public Portal getDestination(Player player) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Portal getDestination(@Nullable Player player) {
 | 
			
		||||
        String portalNetwork = portal.getCleanNetwork();
 | 
			
		||||
        if (portal.getOptions().isRandom()) {
 | 
			
		||||
            //Find possible destinations
 | 
			
		||||
@@ -88,6 +93,7 @@ public class PortalActivator {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The portal destination</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Portal getDestination() {
 | 
			
		||||
        return getDestination(null);
 | 
			
		||||
    }
 | 
			
		||||
@@ -97,7 +103,7 @@ public class PortalActivator {
 | 
			
		||||
     *
 | 
			
		||||
     * @param destination <p>The new destination of this portal activator's portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setDestination(Portal destination) {
 | 
			
		||||
    public void setDestination(@NotNull Portal destination) {
 | 
			
		||||
        setDestination(destination.getName());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -106,7 +112,7 @@ public class PortalActivator {
 | 
			
		||||
     *
 | 
			
		||||
     * @param destination <p>The new destination of this portal activator's portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setDestination(String destination) {
 | 
			
		||||
    public void setDestination(@NotNull String destination) {
 | 
			
		||||
        this.destination = destination;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -115,6 +121,7 @@ public class PortalActivator {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The name of the selected destination</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getDestinationName() {
 | 
			
		||||
        return destination;
 | 
			
		||||
    }
 | 
			
		||||
@@ -125,7 +132,7 @@ public class PortalActivator {
 | 
			
		||||
     * @param player <p>The player to activate the portal for</p>
 | 
			
		||||
     * @return <p>True if the portal was activated</p>
 | 
			
		||||
     */
 | 
			
		||||
    boolean activate(Player player) {
 | 
			
		||||
    public boolean activate(@NotNull Player player) {
 | 
			
		||||
        //Clear previous destination data
 | 
			
		||||
        this.destination = "";
 | 
			
		||||
        this.destinations.clear();
 | 
			
		||||
@@ -162,7 +169,7 @@ public class PortalActivator {
 | 
			
		||||
     * @param player <p>The player trying to activate this activator's portal</p>
 | 
			
		||||
     * @return <p>True if the portal was activated. False otherwise</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean triggerStargateActivationEvent(Player player) {
 | 
			
		||||
    private boolean triggerStargateActivationEvent(@NotNull Player player) {
 | 
			
		||||
        StargateActivateEvent event = new StargateActivateEvent(portal, player, destinations, destination);
 | 
			
		||||
        Stargate.getInstance().getServer().getPluginManager().callEvent(event);
 | 
			
		||||
        if (event.isCancelled()) {
 | 
			
		||||
@@ -217,7 +224,7 @@ public class PortalActivator {
 | 
			
		||||
     *
 | 
			
		||||
     * @param player <p>The player to cycle the gate for</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void cycleDestination(Player player) {
 | 
			
		||||
    public void cycleDestination(@NotNull Player player) {
 | 
			
		||||
        cycleDestination(player, 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -227,7 +234,7 @@ public class PortalActivator {
 | 
			
		||||
     * @param player    <p>The player cycling destinations</p>
 | 
			
		||||
     * @param direction <p>The direction of the cycle (+1 for next, -1 for previous)</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void cycleDestination(Player player, int direction) {
 | 
			
		||||
    public void cycleDestination(@NotNull Player player, int direction) {
 | 
			
		||||
        //Only allow going exactly one step in either direction
 | 
			
		||||
        if (direction != 1 && direction != -1) {
 | 
			
		||||
            throw new IllegalArgumentException("The destination direction must be 1 or -1.");
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,8 @@ import org.bukkit.block.Block;
 | 
			
		||||
import org.bukkit.block.BlockFace;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.event.block.SignChangeEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
@@ -39,7 +41,7 @@ public class PortalCreator {
 | 
			
		||||
     * @param event  <p>The sign change event which initialized the creation</p>
 | 
			
		||||
     * @param player <p>The player creating the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalCreator(SignChangeEvent event, Player player) {
 | 
			
		||||
    public PortalCreator(@NotNull SignChangeEvent event, @NotNull Player player) {
 | 
			
		||||
        this.event = event;
 | 
			
		||||
        this.player = player;
 | 
			
		||||
    }
 | 
			
		||||
@@ -49,12 +51,13 @@ public class PortalCreator {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The created portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Portal createPortal() {
 | 
			
		||||
        BlockLocation signLocation = new BlockLocation(event.getBlock());
 | 
			
		||||
        Block signControlBlock = signLocation.getParent();
 | 
			
		||||
 | 
			
		||||
        //Return early if the sign is not placed on a block, or the block is not a control block
 | 
			
		||||
        if (signControlBlock == null || GateHandler.getGatesByControlBlock(signControlBlock).length == 0) {
 | 
			
		||||
        if (signControlBlock == null || GateHandler.getGatesByControlBlock(signControlBlock).isEmpty()) {
 | 
			
		||||
            Stargate.debug("createPortal", "Control block not registered");
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
@@ -144,7 +147,7 @@ public class PortalCreator {
 | 
			
		||||
        //Check if the user can create portals to this world.
 | 
			
		||||
        if (!portalOptions.get(PortalOption.BUNGEE) && !deny && destinationName.length() > 0) {
 | 
			
		||||
            Portal portal = PortalHandler.getByName(destinationName, network);
 | 
			
		||||
            if (portal != null) {
 | 
			
		||||
            if (portal != null && portal.getWorld() != null) {
 | 
			
		||||
                String world = portal.getWorld().getName();
 | 
			
		||||
                if (PermissionHelper.cannotAccessWorld(player, world)) {
 | 
			
		||||
                    Stargate.debug("canCreateNetworkGate", "Player does not have access to destination world");
 | 
			
		||||
@@ -173,7 +176,8 @@ public class PortalCreator {
 | 
			
		||||
     * @param deny        <p>Whether the portal creation has already been denied</p>
 | 
			
		||||
     * @return <p>The portal or null if its creation was denied</p>
 | 
			
		||||
     */
 | 
			
		||||
    public Portal validatePortal(String denyMessage, String[] lines, boolean deny) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Portal validatePortal(@NotNull String denyMessage, String[] lines, boolean deny) {
 | 
			
		||||
        PortalLocation portalLocation = portal.getLocation();
 | 
			
		||||
        Gate gate = portal.getStructure().getGate();
 | 
			
		||||
        PortalOptions portalOptions = portal.getOptions();
 | 
			
		||||
@@ -219,7 +223,9 @@ public class PortalCreator {
 | 
			
		||||
            PortalHandler.updatePortalsPointingAtNewPortal(portal);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        PortalFileHelper.saveAllPortals(portal.getWorld());
 | 
			
		||||
        if (portal.getWorld() != null) {
 | 
			
		||||
            PortalFileHelper.saveAllPortals(portal.getWorld());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return portal;
 | 
			
		||||
    }
 | 
			
		||||
@@ -231,7 +237,7 @@ public class PortalCreator {
 | 
			
		||||
     * @param portalName <p>The name of the newly created portal</p>
 | 
			
		||||
     * @return <p>True if the portal is completely valid</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean checkIfNewPortalIsValid(int cost, String portalName) {
 | 
			
		||||
    private boolean checkIfNewPortalIsValid(int cost, @NotNull String portalName) {
 | 
			
		||||
        //Check if the portal name can fit on the sign with padding (>name<)
 | 
			
		||||
        if (portal.getCleanName().length() < 1 || portal.getCleanName().length() > getMaxNameNetworkLength()) {
 | 
			
		||||
            Stargate.debug("createPortal", String.format("Name length error. %s is too long.",
 | 
			
		||||
@@ -282,7 +288,7 @@ public class PortalCreator {
 | 
			
		||||
     *
 | 
			
		||||
     * @param destinationName <p>The name of the destination portal. Only used if set as always on</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void updateNewPortalOpenState(String destinationName) {
 | 
			
		||||
    private void updateNewPortalOpenState(@NotNull String destinationName) {
 | 
			
		||||
        portal.drawSign();
 | 
			
		||||
        if (portal.getOptions().isRandom() || portal.getOptions().isBungee()) {
 | 
			
		||||
            //Open the implicitly always on portal
 | 
			
		||||
@@ -312,7 +318,8 @@ public class PortalCreator {
 | 
			
		||||
     * @param player  <p>The player creating the new portal</p>
 | 
			
		||||
     * @return <p>True if a conflict was found. False otherwise</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static boolean conflictsWithExistingPortal(Gate gate, BlockLocation topLeft, double yaw, Player player) {
 | 
			
		||||
    private static boolean conflictsWithExistingPortal(@NotNull Gate gate, @NotNull BlockLocation topLeft, double yaw,
 | 
			
		||||
                                                       @NotNull Player player) {
 | 
			
		||||
        for (RelativeBlockVector borderVector : gate.getLayout().getBorder()) {
 | 
			
		||||
            BlockLocation borderBlockLocation = topLeft.getRelativeLocation(borderVector, yaw);
 | 
			
		||||
            if (PortalHandler.getByBlock(borderBlockLocation.getBlock()) != null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,8 @@ import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
import org.bukkit.block.Block;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
@@ -33,6 +35,7 @@ public class PortalHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A copy of all portal networks</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<String, List<String>> getAllPortalNetworks() {
 | 
			
		||||
        return PortalRegistry.getAllPortalNetworks();
 | 
			
		||||
    }
 | 
			
		||||
@@ -42,6 +45,7 @@ public class PortalHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A copy of all bungee portals</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<String, Portal> getBungeePortals() {
 | 
			
		||||
        return PortalRegistry.getBungeePortals();
 | 
			
		||||
    }
 | 
			
		||||
@@ -52,6 +56,7 @@ public class PortalHandler {
 | 
			
		||||
     * @param network <p>The network to get portals from</p>
 | 
			
		||||
     * @return <p>A list of portal names</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static List<String> getNetwork(String network) {
 | 
			
		||||
        return PortalRegistry.getNetwork(network);
 | 
			
		||||
    }
 | 
			
		||||
@@ -64,7 +69,9 @@ public class PortalHandler {
 | 
			
		||||
     * @param network        <p>The network to get destinations from</p>
 | 
			
		||||
     * @return <p>All destinations the player can go to</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static List<String> getDestinations(Portal entrancePortal, Player player, String network) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static List<String> getDestinations(@NotNull Portal entrancePortal, @Nullable Player player,
 | 
			
		||||
                                               @NotNull String network) {
 | 
			
		||||
        List<String> destinations = new ArrayList<>();
 | 
			
		||||
        for (String destination : PortalRegistry.getAllPortalNetworks().get(network)) {
 | 
			
		||||
            Portal portal = getByName(destination, network);
 | 
			
		||||
@@ -94,7 +101,7 @@ public class PortalHandler {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            //Check if this player can access the destination world
 | 
			
		||||
            if (PermissionHelper.cannotAccessWorld(player, portal.getWorld().getName())) {
 | 
			
		||||
            if (portal.getWorld() != null && PermissionHelper.cannotAccessWorld(player, portal.getWorld().getName())) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            //The portal is visible to the player
 | 
			
		||||
@@ -110,7 +117,7 @@ public class PortalHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The portal to register</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void registerPortal(Portal portal) {
 | 
			
		||||
    public static void registerPortal(@NotNull Portal portal) {
 | 
			
		||||
        PortalRegistry.registerPortal(portal);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -123,8 +130,8 @@ public class PortalHandler {
 | 
			
		||||
     * @param network         <p>The name of the portal's network</p>
 | 
			
		||||
     * @return <p>False if the portal is an invalid bungee portal. True otherwise</p>
 | 
			
		||||
     */
 | 
			
		||||
    static boolean isValidBungeePortal(Map<PortalOption, Boolean> portalOptions, Player player,
 | 
			
		||||
                                       String destinationName, String network) {
 | 
			
		||||
    public static boolean isValidBungeePortal(@NotNull Map<PortalOption, Boolean> portalOptions, @NotNull Player player,
 | 
			
		||||
                                              @NotNull String destinationName, String network) {
 | 
			
		||||
        if (portalOptions.get(PortalOption.BUNGEE)) {
 | 
			
		||||
            if (!PermissionHelper.hasPermission(player, "stargate.admin.bungee")) {
 | 
			
		||||
                Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("bungeeDeny"));
 | 
			
		||||
@@ -147,13 +154,17 @@ public class PortalHandler {
 | 
			
		||||
     * @param world          <p>The world the player is located in</p>
 | 
			
		||||
     * @return <p>The matching gate type, or null if no such gate could be found</p>
 | 
			
		||||
     */
 | 
			
		||||
    static Gate findMatchingGate(PortalLocation portalLocation, World world) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Gate findMatchingGate(@NotNull PortalLocation portalLocation, @NotNull World world) {
 | 
			
		||||
        Block signParent = portalLocation.getSignLocation().getParent();
 | 
			
		||||
        if (signParent == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        BlockLocation parent = new BlockLocation(world, signParent.getX(), signParent.getY(),
 | 
			
		||||
                signParent.getZ());
 | 
			
		||||
 | 
			
		||||
        //Get all gates with the used type of control blocks
 | 
			
		||||
        Gate[] possibleGates = GateHandler.getGatesByControlBlock(signParent);
 | 
			
		||||
        List<Gate> possibleGates = GateHandler.getGatesByControlBlock(signParent);
 | 
			
		||||
        double yaw = portalLocation.getYaw();
 | 
			
		||||
        Gate gate = null;
 | 
			
		||||
 | 
			
		||||
@@ -187,7 +198,7 @@ public class PortalHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The newly created portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    static void updatePortalsPointingAtNewPortal(Portal portal) {
 | 
			
		||||
    public static void updatePortalsPointingAtNewPortal(@NotNull Portal portal) {
 | 
			
		||||
        for (String originName : PortalRegistry.getAllPortalNetworks().get(portal.getCleanNetwork())) {
 | 
			
		||||
            Portal origin = getByName(originName, portal.getCleanNetwork());
 | 
			
		||||
            if (origin == null ||
 | 
			
		||||
@@ -214,7 +225,9 @@ public class PortalHandler {
 | 
			
		||||
     * @param options         <p>The string on the option line of the sign</p>
 | 
			
		||||
     * @return <p>A map containing all portal options and their values</p>
 | 
			
		||||
     */
 | 
			
		||||
    static Map<PortalOption, Boolean> getPortalOptions(Player player, String destinationName, String options) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<PortalOption, Boolean> getPortalOptions(@NotNull Player player, @NotNull String destinationName,
 | 
			
		||||
                                                              @NotNull String options) {
 | 
			
		||||
        Map<PortalOption, Boolean> portalOptions = new HashMap<>();
 | 
			
		||||
        for (PortalOption option : PortalOption.values()) {
 | 
			
		||||
            portalOptions.put(option, options.indexOf(option.getCharacterRepresentation()) != -1 &&
 | 
			
		||||
@@ -252,7 +265,8 @@ public class PortalHandler {
 | 
			
		||||
     * @param network <p>The network the portal is connected to</p>
 | 
			
		||||
     * @return <p>The portal with the given name or null</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Portal getByName(String name, String network) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Portal getByName(@NotNull String name, @NotNull String network) {
 | 
			
		||||
        Map<String, Map<String, Portal>> lookupMap = PortalRegistry.getPortalLookupByNetwork();
 | 
			
		||||
        if (!lookupMap.containsKey(network.toLowerCase())) {
 | 
			
		||||
            return null;
 | 
			
		||||
@@ -267,7 +281,11 @@ public class PortalHandler {
 | 
			
		||||
     * @param location <p>The location of the portal's entrance</p>
 | 
			
		||||
     * @return <p>The portal at the given location</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Portal getByEntrance(Location location) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Portal getByEntrance(@NotNull Location location) {
 | 
			
		||||
        if (location.getWorld() == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        return PortalRegistry.getLookupEntrances().get(new BlockLocation(location.getWorld(), location.getBlockX(),
 | 
			
		||||
                location.getBlockY(), location.getBlockZ()));
 | 
			
		||||
    }
 | 
			
		||||
@@ -278,7 +296,8 @@ public class PortalHandler {
 | 
			
		||||
     * @param block <p>The block at the portal's entrance</p>
 | 
			
		||||
     * @return <p>The portal at the given block's location</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Portal getByEntrance(Block block) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Portal getByEntrance(@NotNull Block block) {
 | 
			
		||||
        return PortalRegistry.getLookupEntrances().get(new BlockLocation(block));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -288,7 +307,8 @@ public class PortalHandler {
 | 
			
		||||
     * @param location <p>A location adjacent to the portal's entrance</p>
 | 
			
		||||
     * @return <p>The portal adjacent to the given location</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Portal getByAdjacentEntrance(Location location) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Portal getByAdjacentEntrance(@NotNull Location location) {
 | 
			
		||||
        return getByAdjacentEntrance(location, 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -299,7 +319,8 @@ public class PortalHandler {
 | 
			
		||||
     * @param range    <p>The range to scan for portals</p>
 | 
			
		||||
     * @return <p>The portal adjacent to the given location</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Portal getByAdjacentEntrance(Location location, int range) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Portal getByAdjacentEntrance(@NotNull Location location, int range) {
 | 
			
		||||
        List<BlockLocation> adjacentPositions = new ArrayList<>();
 | 
			
		||||
        BlockLocation centerLocation = new BlockLocation(location.getBlock());
 | 
			
		||||
        adjacentPositions.add(centerLocation);
 | 
			
		||||
@@ -332,7 +353,8 @@ public class PortalHandler {
 | 
			
		||||
     * @param block <p>The portal's control block</p>
 | 
			
		||||
     * @return <p>The portal with the given control block</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Portal getByControl(Block block) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Portal getByControl(@NotNull Block block) {
 | 
			
		||||
        return PortalRegistry.getLookupControls().get(new BlockLocation(block));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -342,7 +364,8 @@ public class PortalHandler {
 | 
			
		||||
     * @param block <p>One of the loaded lookup blocks</p>
 | 
			
		||||
     * @return <p>The portal corresponding to the block</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Portal getByBlock(Block block) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Portal getByBlock(@NotNull Block block) {
 | 
			
		||||
        return PortalRegistry.getLookupBlocks().get(new BlockLocation(block));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -352,7 +375,8 @@ public class PortalHandler {
 | 
			
		||||
     * @param name <p>The name of the bungee portal to get</p>
 | 
			
		||||
     * @return <p>A bungee portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Portal getBungeePortal(String name) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Portal getBungeePortal(@NotNull String name) {
 | 
			
		||||
        return PortalRegistry.getBungeePortals().get(name.toLowerCase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -362,7 +386,8 @@ public class PortalHandler {
 | 
			
		||||
     * @param portalData <p>The string list containing all information about a portal</p>
 | 
			
		||||
     * @return <p>A map between portal options and booleans</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Map<PortalOption, Boolean> getPortalOptions(String[] portalData) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<PortalOption, Boolean> getPortalOptions(@NotNull String[] portalData) {
 | 
			
		||||
        Map<PortalOption, Boolean> portalOptions = new HashMap<>();
 | 
			
		||||
        for (PortalOption option : PortalOption.values()) {
 | 
			
		||||
            int saveIndex = option.getSaveIndex();
 | 
			
		||||
@@ -415,7 +440,7 @@ public class PortalHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The portal of the star portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void unregisterInvalidPortal(Portal portal) {
 | 
			
		||||
    private static void unregisterInvalidPortal(@NotNull Portal portal) {
 | 
			
		||||
        //Show debug information
 | 
			
		||||
        for (RelativeBlockVector control : portal.getGate().getLayout().getControls()) {
 | 
			
		||||
            Block block = portal.getBlockAt(control).getBlock();
 | 
			
		||||
@@ -447,7 +472,8 @@ public class PortalHandler {
 | 
			
		||||
     * @param input <p>The name to filter</p>
 | 
			
		||||
     * @return <p>The filtered name</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static String filterName(String input) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static String filterName(@Nullable String input) {
 | 
			
		||||
        if (input == null) {
 | 
			
		||||
            return "";
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,8 @@ import org.bukkit.Axis;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.block.data.Orientable;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The portal opener is responsible for opening and closing a portal
 | 
			
		||||
@@ -28,7 +30,7 @@ public class PortalOpener {
 | 
			
		||||
     * @param portal      <p>The portal this portal opener should open</p>
 | 
			
		||||
     * @param destination <p>The fixed destination defined on the portal's sign</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalOpener(Portal portal, String destination) {
 | 
			
		||||
    public PortalOpener(@NotNull Portal portal, @NotNull String destination) {
 | 
			
		||||
        this.portal = portal;
 | 
			
		||||
        this.portalActivator = new PortalActivator(portal, this, destination);
 | 
			
		||||
    }
 | 
			
		||||
@@ -56,6 +58,7 @@ public class PortalOpener {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The portal activator belonging to this portal opener</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalActivator getPortalActivator() {
 | 
			
		||||
        return this.portalActivator;
 | 
			
		||||
    }
 | 
			
		||||
@@ -75,7 +78,7 @@ public class PortalOpener {
 | 
			
		||||
     * @param openFor <p>The player to open the portal for</p>
 | 
			
		||||
     * @param force   <p>Whether to force the portal open, even if it's already open for some player</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void openPortal(Player openFor, boolean force) {
 | 
			
		||||
    public void openPortal(@Nullable Player openFor, boolean force) {
 | 
			
		||||
        //Call the StargateOpenEvent to allow the opening to be cancelled
 | 
			
		||||
        StargateOpenEvent event = new StargateOpenEvent(openFor, portal, force);
 | 
			
		||||
        Stargate.getInstance().getServer().getPluginManager().callEvent(event);
 | 
			
		||||
@@ -102,7 +105,7 @@ public class PortalOpener {
 | 
			
		||||
     *
 | 
			
		||||
     * @param openFor <p>The player to open this portal opener's portal for</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void updatePortalOpenState(Player openFor) {
 | 
			
		||||
    private void updatePortalOpenState(@Nullable Player openFor) {
 | 
			
		||||
        //Update the open state of this portal
 | 
			
		||||
        isOpen = true;
 | 
			
		||||
        triggeredTime = System.currentTimeMillis() / 1000;
 | 
			
		||||
@@ -207,7 +210,7 @@ public class PortalOpener {
 | 
			
		||||
     * @param player <p>The player to check portal state for</p>
 | 
			
		||||
     * @return <p>True if this portal opener's portal is open to the given player</p>
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isOpenFor(Player player) {
 | 
			
		||||
    public boolean isOpenFor(@Nullable Player player) {
 | 
			
		||||
        //If closed, it's closed for everyone
 | 
			
		||||
        if (!isOpen) {
 | 
			
		||||
            return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import net.knarcraft.stargate.config.DynmapManager;
 | 
			
		||||
import net.knarcraft.stargate.container.BlockLocation;
 | 
			
		||||
import net.knarcraft.stargate.utility.PortalFileHelper;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
@@ -44,11 +45,11 @@ public class PortalRegistry {
 | 
			
		||||
     *
 | 
			
		||||
     * @param world <p>The world containing the portals to clear</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void clearPortals(World world) {
 | 
			
		||||
    public static void clearPortals(@NotNull World world) {
 | 
			
		||||
        //Storing the portals to clear is necessary to avoid a concurrent modification exception
 | 
			
		||||
        List<Portal> portalsToRemove = new ArrayList<>();
 | 
			
		||||
        allPortals.forEach((portal) -> {
 | 
			
		||||
            if (portal.getWorld().equals(world)) {
 | 
			
		||||
            if (portal.getWorld() != null && portal.getWorld().equals(world)) {
 | 
			
		||||
                portalsToRemove.add(portal);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
@@ -61,7 +62,7 @@ public class PortalRegistry {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portalsToRemove <p>A list of portals to remove</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void clearPortals(List<Portal> portalsToRemove) {
 | 
			
		||||
    private static void clearPortals(@NotNull List<Portal> portalsToRemove) {
 | 
			
		||||
        //Store the names of the portals to remove as some maps require the name, not the object
 | 
			
		||||
        List<String> portalNames = new ArrayList<>();
 | 
			
		||||
        portalsToRemove.forEach((portal) -> portalNames.add(portal.getCleanName()));
 | 
			
		||||
@@ -87,6 +88,7 @@ public class PortalRegistry {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A copy of the list of all portals</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static List<Portal> getAllPortals() {
 | 
			
		||||
        return new ArrayList<>(allPortals);
 | 
			
		||||
    }
 | 
			
		||||
@@ -96,6 +98,7 @@ public class PortalRegistry {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A copy of the frame block lookup map</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<BlockLocation, Portal> getLookupBlocks() {
 | 
			
		||||
        return new HashMap<>(lookupBlocks);
 | 
			
		||||
    }
 | 
			
		||||
@@ -105,6 +108,7 @@ public class PortalRegistry {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A copy of the control block lookup map</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<BlockLocation, Portal> getLookupControls() {
 | 
			
		||||
        return new HashMap<>(lookupControls);
 | 
			
		||||
    }
 | 
			
		||||
@@ -114,6 +118,7 @@ public class PortalRegistry {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A copy of the network portal lookup map</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<String, Map<String, Portal>> getPortalLookupByNetwork() {
 | 
			
		||||
        return new HashMap<>(portalLookupByNetwork);
 | 
			
		||||
    }
 | 
			
		||||
@@ -123,6 +128,7 @@ public class PortalRegistry {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A copy of all entrances to portal mappings</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<BlockLocation, Portal> getLookupEntrances() {
 | 
			
		||||
        return new HashMap<>(lookupEntrances);
 | 
			
		||||
    }
 | 
			
		||||
@@ -132,6 +138,7 @@ public class PortalRegistry {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A copy of all portal networks</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<String, List<String>> getAllPortalNetworks() {
 | 
			
		||||
        return new HashMap<>(allPortalNetworks);
 | 
			
		||||
    }
 | 
			
		||||
@@ -141,6 +148,7 @@ public class PortalRegistry {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A copy of all bungee portals</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<String, Portal> getBungeePortals() {
 | 
			
		||||
        return new HashMap<>(bungeePortals);
 | 
			
		||||
    }
 | 
			
		||||
@@ -151,7 +159,8 @@ public class PortalRegistry {
 | 
			
		||||
     * @param network <p>The network to get portals from</p>
 | 
			
		||||
     * @return <p>A list of portal names</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static List<String> getNetwork(String network) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static List<String> getNetwork(@NotNull String network) {
 | 
			
		||||
        return allPortalNetworks.get(network.toLowerCase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -161,7 +170,7 @@ public class PortalRegistry {
 | 
			
		||||
     * @param portal    <p>The portal to un-register</p>
 | 
			
		||||
     * @param removeAll <p>Whether to remove the portal from the list of all portals</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void unregisterPortal(Portal portal, boolean removeAll) {
 | 
			
		||||
    public static void unregisterPortal(@NotNull Portal portal, boolean removeAll) {
 | 
			
		||||
        Stargate.debug("Unregister", "Unregistering gate " + portal.getName());
 | 
			
		||||
        portal.getPortalActivator().deactivate();
 | 
			
		||||
        portal.getPortalOpener().closePortal(true);
 | 
			
		||||
@@ -223,7 +232,9 @@ public class PortalRegistry {
 | 
			
		||||
        //Mark the portal's sign as unregistered
 | 
			
		||||
        new PortalSignDrawer(portal).drawUnregisteredSign();
 | 
			
		||||
 | 
			
		||||
        PortalFileHelper.saveAllPortals(portal.getWorld());
 | 
			
		||||
        if (portal.getWorld() != null) {
 | 
			
		||||
            PortalFileHelper.saveAllPortals(portal.getWorld());
 | 
			
		||||
        }
 | 
			
		||||
        portal.setRegistered(false);
 | 
			
		||||
        DynmapManager.removePortalMarker(portal);
 | 
			
		||||
    }
 | 
			
		||||
@@ -233,7 +244,7 @@ public class PortalRegistry {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The portal to register</p>
 | 
			
		||||
     */
 | 
			
		||||
    static void registerPortal(Portal portal) {
 | 
			
		||||
    public static void registerPortal(@NotNull Portal portal) {
 | 
			
		||||
        portal.getOptions().setFixed(portal.getDestinationName().length() > 0 || portal.getOptions().isRandom() ||
 | 
			
		||||
                portal.getOptions().isBungee());
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,8 +12,11 @@ import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.block.Block;
 | 
			
		||||
import org.bukkit.block.BlockState;
 | 
			
		||||
import org.bukkit.block.Sign;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The portal sign drawer draws the sing of a given portal
 | 
			
		||||
@@ -33,7 +36,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The portal whose sign this portal sign drawer is responsible for drawing</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalSignDrawer(Portal portal) {
 | 
			
		||||
    public PortalSignDrawer(@NotNull Portal portal) {
 | 
			
		||||
        this.portal = portal;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -44,7 +47,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param newHighlightColor <p>The new highlight color</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void setHighlightColor(ChatColor newHighlightColor) {
 | 
			
		||||
    public static void setHighlightColor(@NotNull ChatColor newHighlightColor) {
 | 
			
		||||
        highlightColor = newHighlightColor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -55,7 +58,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param newMainColor <p>The new main sign color</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void setMainColor(ChatColor newMainColor) {
 | 
			
		||||
    public static void setMainColor(@NotNull ChatColor newMainColor) {
 | 
			
		||||
        mainColor = newMainColor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -64,7 +67,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param freeColor <p>The new color to use for marking free stargates</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void setFreeColor(ChatColor freeColor) {
 | 
			
		||||
    public static void setFreeColor(@NotNull ChatColor freeColor) {
 | 
			
		||||
        PortalSignDrawer.freeColor = freeColor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -73,7 +76,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param signMainColors <p>The per-sign main colors</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void setPerSignMainColors(Map<Material, ChatColor> signMainColors) {
 | 
			
		||||
    public static void setPerSignMainColors(@NotNull Map<Material, ChatColor> signMainColors) {
 | 
			
		||||
        PortalSignDrawer.perSignMainColors = signMainColors;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -82,7 +85,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param signHighlightColors <p>The per-sign highlight colors</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void setPerSignHighlightColors(Map<Material, ChatColor> signHighlightColors) {
 | 
			
		||||
    public static void setPerSignHighlightColors(@NotNull Map<Material, ChatColor> signHighlightColors) {
 | 
			
		||||
        PortalSignDrawer.perSignHighlightColors = signHighlightColors;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -91,6 +94,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The currently used main sign color</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static ChatColor getMainColor() {
 | 
			
		||||
        return mainColor;
 | 
			
		||||
    }
 | 
			
		||||
@@ -100,6 +104,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The currently used highlighting sign color</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static ChatColor getHighlightColor() {
 | 
			
		||||
        return highlightColor;
 | 
			
		||||
    }
 | 
			
		||||
@@ -122,6 +127,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The sign of this sign drawer's portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private Sign getSign() {
 | 
			
		||||
        Block signBlock = portal.getSignLocation().getBlock();
 | 
			
		||||
        BlockState state = signBlock.getState();
 | 
			
		||||
@@ -141,7 +147,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param signData <p>All necessary sign information</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void drawSign(SignData signData) {
 | 
			
		||||
    private void drawSign(@NotNull SignData signData) {
 | 
			
		||||
        Sign sign = signData.getSign();
 | 
			
		||||
        ChatColor highlightColor = signData.getHighlightSignColor();
 | 
			
		||||
        ChatColor mainColor = signData.getMainSignColor();
 | 
			
		||||
@@ -174,7 +180,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param sign <p>The sign to clear</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void clearSign(Sign sign) {
 | 
			
		||||
    private void clearSign(@NotNull Sign sign) {
 | 
			
		||||
        for (int index = 0; index <= 3; index++) {
 | 
			
		||||
            SignHelper.setSignLine(sign, index, "");
 | 
			
		||||
        }
 | 
			
		||||
@@ -198,7 +204,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param signData <p>All necessary sign information</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void drawNetworkSign(SignData signData) {
 | 
			
		||||
    private void drawNetworkSign(@NotNull SignData signData) {
 | 
			
		||||
        PortalActivator destinations = portal.getPortalActivator();
 | 
			
		||||
        int maxIndex = destinations.getDestinations().size() - 1;
 | 
			
		||||
        int signLineIndex = 0;
 | 
			
		||||
@@ -233,12 +239,12 @@ public class PortalSignDrawer {
 | 
			
		||||
     * @param freeGatesColored <p>Whether to display free gates in a different color</p>
 | 
			
		||||
     * @param signLineIndex    <p>The line to draw on</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void drawNetworkSignChosenLine(SignData signData, boolean freeGatesColored, int signLineIndex) {
 | 
			
		||||
    private void drawNetworkSignChosenLine(@NotNull SignData signData, boolean freeGatesColored, int signLineIndex) {
 | 
			
		||||
        ChatColor highlightColor = signData.getHighlightSignColor();
 | 
			
		||||
        ChatColor mainColor = signData.getMainSignColor();
 | 
			
		||||
        if (freeGatesColored) {
 | 
			
		||||
            Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
 | 
			
		||||
            boolean free = PermissionHelper.isFree(portal.getActivePlayer(), portal, destination);
 | 
			
		||||
            boolean free = PermissionHelper.isFree(Objects.requireNonNull(portal.getActivePlayer()), portal, destination);
 | 
			
		||||
            ChatColor nameColor = (free ? freeColor : highlightColor);
 | 
			
		||||
            setLine(signData, signLineIndex, nameColor + ">" + (free ? freeColor : mainColor) +
 | 
			
		||||
                    translateAllColorCodes(portal.getDestinationName()) + nameColor + "<");
 | 
			
		||||
@@ -255,7 +261,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     * @param index    <p>The index of the sign line to change</p>
 | 
			
		||||
     * @param text     <p>The new text on the sign</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setLine(SignData signData, int index, String text) {
 | 
			
		||||
    public void setLine(@NotNull SignData signData, int index, @NotNull String text) {
 | 
			
		||||
        ChatColor mainColor = signData.getMainSignColor();
 | 
			
		||||
        SignHelper.setSignLine(signData.getSign(), index, mainColor + text);
 | 
			
		||||
    }
 | 
			
		||||
@@ -268,13 +274,14 @@ public class PortalSignDrawer {
 | 
			
		||||
     * @param signLineIndex    <p>The line to draw on</p>
 | 
			
		||||
     * @param destinationIndex <p>The index of the destination to draw</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void drawNetworkSignLine(SignData signData, boolean freeGatesColored, int signLineIndex, int destinationIndex) {
 | 
			
		||||
    private void drawNetworkSignLine(@NotNull SignData signData, boolean freeGatesColored, int signLineIndex,
 | 
			
		||||
                                     int destinationIndex) {
 | 
			
		||||
        ChatColor mainColor = signData.getMainSignColor();
 | 
			
		||||
        PortalActivator destinations = portal.getPortalActivator();
 | 
			
		||||
        String destinationName = destinations.getDestinations().get(destinationIndex);
 | 
			
		||||
        if (freeGatesColored) {
 | 
			
		||||
            Portal destination = PortalHandler.getByName(destinationName, portal.getNetwork());
 | 
			
		||||
            boolean free = PermissionHelper.isFree(portal.getActivePlayer(), portal, destination);
 | 
			
		||||
            boolean free = PermissionHelper.isFree(Objects.requireNonNull(portal.getActivePlayer()), portal, destination);
 | 
			
		||||
            setLine(signData, signLineIndex, (free ? freeColor : mainColor) + translateAllColorCodes(destinationName));
 | 
			
		||||
        } else {
 | 
			
		||||
            setLine(signData, signLineIndex, mainColor + translateAllColorCodes(destinationName));
 | 
			
		||||
@@ -286,12 +293,12 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param signData <p>All necessary sign information</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void drawBungeeSign(SignData signData) {
 | 
			
		||||
    private void drawBungeeSign(@NotNull SignData signData) {
 | 
			
		||||
        ChatColor highlightColor = signData.getHighlightSignColor();
 | 
			
		||||
        ChatColor mainColor = signData.getMainSignColor();
 | 
			
		||||
        setLine(signData, 1, Stargate.getString("bungeeSign"));
 | 
			
		||||
        setLine(signData, 2, highlightColor + ">" + mainColor + translateAllColorCodes(portal.getDestinationName()) +
 | 
			
		||||
                highlightColor + "<");
 | 
			
		||||
        setLine(signData, 2, highlightColor + ">" + mainColor +
 | 
			
		||||
                translateAllColorCodes(portal.getDestinationName()) + highlightColor + "<");
 | 
			
		||||
        setLine(signData, 3, highlightColor + "[" + mainColor + translateAllColorCodes(portal.getNetwork()) +
 | 
			
		||||
                highlightColor + "]");
 | 
			
		||||
    }
 | 
			
		||||
@@ -303,7 +310,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param signData <p>All necessary sign information</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void drawInactiveSign(SignData signData) {
 | 
			
		||||
    private void drawInactiveSign(@NotNull SignData signData) {
 | 
			
		||||
        ChatColor highlightColor = signData.getHighlightSignColor();
 | 
			
		||||
        ChatColor mainColor = signData.getMainSignColor();
 | 
			
		||||
        setLine(signData, 1, Stargate.getString("signRightClick"));
 | 
			
		||||
@@ -321,7 +328,7 @@ public class PortalSignDrawer {
 | 
			
		||||
     *
 | 
			
		||||
     * @param signData <p>All necessary sign information</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void drawFixedSign(SignData signData) {
 | 
			
		||||
    private void drawFixedSign(@NotNull SignData signData) {
 | 
			
		||||
        ChatColor highlightColor = signData.getHighlightSignColor();
 | 
			
		||||
        ChatColor mainColor = signData.getMainSignColor();
 | 
			
		||||
        Portal destinationPortal = PortalHandler.getByName(Portal.cleanString(portal.getDestinationName()),
 | 
			
		||||
@@ -353,7 +360,8 @@ public class PortalSignDrawer {
 | 
			
		||||
     * @param gateName       <p>The name of the invalid gate type</p>
 | 
			
		||||
     * @param lineIndex      <p>The index of the line the invalid portal was found at</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void markPortalWithInvalidGate(PortalLocation portalLocation, String gateName, int lineIndex) {
 | 
			
		||||
    public static void markPortalWithInvalidGate(@NotNull PortalLocation portalLocation, @NotNull String gateName,
 | 
			
		||||
                                                 int lineIndex) {
 | 
			
		||||
        BlockState blockState = portalLocation.getSignLocation().getBlock().getState();
 | 
			
		||||
        if (!(blockState instanceof Sign sign)) {
 | 
			
		||||
            return;
 | 
			
		||||
@@ -370,7 +378,8 @@ public class PortalSignDrawer {
 | 
			
		||||
     * @param signType <p>The sign type to get the main color for</p>
 | 
			
		||||
     * @return <p>The main color for the given sign type</p>
 | 
			
		||||
     */
 | 
			
		||||
    private ChatColor getMainColor(Material signType) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private ChatColor getMainColor(@NotNull Material signType) {
 | 
			
		||||
        ChatColor signColor = perSignMainColors.get(signType);
 | 
			
		||||
        if (signColor == null) {
 | 
			
		||||
            return mainColor;
 | 
			
		||||
@@ -385,7 +394,8 @@ public class PortalSignDrawer {
 | 
			
		||||
     * @param signType <p>The sign type to get the highlight color for</p>
 | 
			
		||||
     * @return <p>The highlight color for the given sign type</p>
 | 
			
		||||
     */
 | 
			
		||||
    private ChatColor getHighlightColor(Material signType) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private ChatColor getHighlightColor(@NotNull Material signType) {
 | 
			
		||||
        ChatColor signColor = perSignHighlightColors.get(signType);
 | 
			
		||||
        if (signColor == null) {
 | 
			
		||||
            return highlightColor;
 | 
			
		||||
@@ -400,7 +410,8 @@ public class PortalSignDrawer {
 | 
			
		||||
     * @param input <p>The input to translate color codes for</p>
 | 
			
		||||
     * @return <p>The input with color codes converted translated from & to §</p>
 | 
			
		||||
     */
 | 
			
		||||
    private String translateAllColorCodes(String input) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private String translateAllColorCodes(@NotNull String input) {
 | 
			
		||||
        return ColorHelper.translateColorCodes(input, ColorConversion.RGB);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@ import net.knarcraft.stargate.container.RelativeBlockVector;
 | 
			
		||||
import org.bukkit.Axis;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
import org.bukkit.block.BlockFace;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Keeps track of location related data for a portal
 | 
			
		||||
@@ -23,6 +25,7 @@ public class PortalLocation {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The top-left block of the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockLocation getTopLeft() {
 | 
			
		||||
        return topLeft;
 | 
			
		||||
    }
 | 
			
		||||
@@ -41,6 +44,7 @@ public class PortalLocation {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The location of the portal's sign</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockLocation getSignLocation() {
 | 
			
		||||
        return signLocation;
 | 
			
		||||
    }
 | 
			
		||||
@@ -50,6 +54,7 @@ public class PortalLocation {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The relative location of the portal's button</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public RelativeBlockVector getButtonVector() {
 | 
			
		||||
        return buttonVector;
 | 
			
		||||
    }
 | 
			
		||||
@@ -59,16 +64,19 @@ public class PortalLocation {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The button's block face</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockFace getButtonFacing() {
 | 
			
		||||
        return buttonFacing;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the rotation axis, which is the axis along which the gate is placed
 | 
			
		||||
     *
 | 
			
		||||
     * <p>The portal's rotation axis is the cross axis of the button's axis</p>
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The portal's rotation axis</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Axis getRotationAxis() {
 | 
			
		||||
        return getYaw() == 0.0F || getYaw() == 180.0F ? Axis.X : Axis.Z;
 | 
			
		||||
    }
 | 
			
		||||
@@ -78,6 +86,7 @@ public class PortalLocation {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The world this portal resides in</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public World getWorld() {
 | 
			
		||||
        return topLeft.getWorld();
 | 
			
		||||
    }
 | 
			
		||||
@@ -91,7 +100,8 @@ public class PortalLocation {
 | 
			
		||||
     * @param topLeft <p>The new top-left block of the portal's square structure</p>
 | 
			
		||||
     * @return <p>The portal location Object</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalLocation setTopLeft(BlockLocation topLeft) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalLocation setTopLeft(@NotNull BlockLocation topLeft) {
 | 
			
		||||
        this.topLeft = topLeft;
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
@@ -104,6 +114,7 @@ public class PortalLocation {
 | 
			
		||||
     * @param yaw <p>The portal's new yaw</p>
 | 
			
		||||
     * @return <p>The portal location Object</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalLocation setYaw(float yaw) {
 | 
			
		||||
        this.yaw = yaw;
 | 
			
		||||
        return this;
 | 
			
		||||
@@ -115,7 +126,8 @@ public class PortalLocation {
 | 
			
		||||
     * @param signLocation <p>The new sign location</p>
 | 
			
		||||
     * @return <p>The portal location Object</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalLocation setSignLocation(BlockLocation signLocation) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalLocation setSignLocation(@NotNull BlockLocation signLocation) {
 | 
			
		||||
        this.signLocation = signLocation;
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
@@ -126,7 +138,8 @@ public class PortalLocation {
 | 
			
		||||
     * @param buttonVector <p>The new relative button location</p>
 | 
			
		||||
     * @return <p>The portal location Object</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalLocation setButtonVector(RelativeBlockVector buttonVector) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalLocation setButtonVector(@Nullable RelativeBlockVector buttonVector) {
 | 
			
		||||
        this.buttonVector = buttonVector;
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
@@ -137,7 +150,8 @@ public class PortalLocation {
 | 
			
		||||
     * @param buttonFacing <p>The new block face of the portal's button</p>
 | 
			
		||||
     * @return <p>The portal location Object</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalLocation setButtonFacing(BlockFace buttonFacing) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public PortalLocation setButtonFacing(@NotNull BlockFace buttonFacing) {
 | 
			
		||||
        this.buttonFacing = buttonFacing;
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
package net.knarcraft.stargate.portal.property;
 | 
			
		||||
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Each enum value represents one option a portal can have/use
 | 
			
		||||
 */
 | 
			
		||||
@@ -8,57 +10,57 @@ public enum PortalOption {
 | 
			
		||||
    /**
 | 
			
		||||
     * This option allows a portal to be hidden from others
 | 
			
		||||
     */
 | 
			
		||||
    HIDDEN('h', "stargate.option.hidden", 11),
 | 
			
		||||
    HIDDEN('h', "hidden", 11),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This option allows a portal that's always on and does not need to be activated or opened each time
 | 
			
		||||
     */
 | 
			
		||||
    ALWAYS_ON('a', "stargate.option.alwayson", 12),
 | 
			
		||||
    ALWAYS_ON('a', "alwayson", 12),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This option allows a portal that's private to the stargate's owner
 | 
			
		||||
     */
 | 
			
		||||
    PRIVATE('p', "stargate.option.private", 13),
 | 
			
		||||
    PRIVATE('p', "private", 13),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This option allows a portal that's free even if stargates usually are not
 | 
			
		||||
     */
 | 
			
		||||
    FREE('f', "stargate.option.free", 15),
 | 
			
		||||
    FREE('f', "free", 15),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This option allows a portal where players exit through the back of the portal
 | 
			
		||||
     */
 | 
			
		||||
    BACKWARDS('b', "stargate.option.backwards", 16),
 | 
			
		||||
    BACKWARDS('b', "backwards", 16),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This option shows the gate in the network list even if it's always on
 | 
			
		||||
     */
 | 
			
		||||
    SHOW('s', "stargate.option.show", 17),
 | 
			
		||||
    SHOW('s', "show", 17),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This option hides the network name on the sign
 | 
			
		||||
     */
 | 
			
		||||
    NO_NETWORK('n', "stargate.option.nonetwork", 18),
 | 
			
		||||
    NO_NETWORK('n', "nonetwork", 18),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This option allows a portal where players teleport to a random exit portal in the network
 | 
			
		||||
     */
 | 
			
		||||
    RANDOM('r', "stargate.option.random", 19),
 | 
			
		||||
    RANDOM('r', "random", 19),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This option allows a portal to teleport to another server connected through BungeeCord
 | 
			
		||||
     */
 | 
			
		||||
    BUNGEE('u', "stargate.admin.bungee", 20),
 | 
			
		||||
    BUNGEE('u', "bungee", 20),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This option allows a portal which does not display a teleportation message, for better immersion
 | 
			
		||||
     */
 | 
			
		||||
    SILENT('q', "stargate.option.silent", 21),
 | 
			
		||||
    SILENT('q', "silent", 21),
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This option causes a fixed portal's sign to be removed after creation
 | 
			
		||||
     */
 | 
			
		||||
    NO_SIGN('v', "stargate.option.nosign", 22);
 | 
			
		||||
    NO_SIGN('v', "nosign", 22);
 | 
			
		||||
 | 
			
		||||
    private final char characterRepresentation;
 | 
			
		||||
    private final String permissionString;
 | 
			
		||||
@@ -70,9 +72,9 @@ public enum PortalOption {
 | 
			
		||||
     * @param characterRepresentation <p>The character representation used on the sign to allow this option</p>
 | 
			
		||||
     * @param permissionString        <p>The permission necessary to use this option</p>
 | 
			
		||||
     */
 | 
			
		||||
    PortalOption(final char characterRepresentation, String permissionString, int saveIndex) {
 | 
			
		||||
    PortalOption(final char characterRepresentation, @NotNull String permissionString, int saveIndex) {
 | 
			
		||||
        this.characterRepresentation = characterRepresentation;
 | 
			
		||||
        this.permissionString = permissionString;
 | 
			
		||||
        this.permissionString = "stargate.option." + permissionString;
 | 
			
		||||
        this.saveIndex = saveIndex;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -90,6 +92,7 @@ public enum PortalOption {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The permission necessary for this option</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getPermissionString() {
 | 
			
		||||
        return this.permissionString;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package net.knarcraft.stargate.portal.property;
 | 
			
		||||
 | 
			
		||||
import net.knarcraft.stargate.Stargate;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
@@ -18,7 +19,7 @@ public class PortalOptions {
 | 
			
		||||
     * @param options        <p>All options to keep track of</p>
 | 
			
		||||
     * @param hasDestination <p>Whether the portal has a fixed destination</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalOptions(Map<PortalOption, Boolean> options, boolean hasDestination) {
 | 
			
		||||
    public PortalOptions(@NotNull Map<PortalOption, Boolean> options, boolean hasDestination) {
 | 
			
		||||
        this.options = options;
 | 
			
		||||
 | 
			
		||||
        isFixed = hasDestination || this.isRandom() || this.isBungee();
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,8 @@ import net.knarcraft.stargate.Stargate;
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
import org.bukkit.OfflinePlayer;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
@@ -20,7 +22,7 @@ public class PortalOwner {
 | 
			
		||||
     *
 | 
			
		||||
     * @param ownerIdentifier <p>A UUID, or a username for legacy support</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalOwner(String ownerIdentifier) {
 | 
			
		||||
    public PortalOwner(@NotNull String ownerIdentifier) {
 | 
			
		||||
        parseIdentifier(ownerIdentifier);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -29,7 +31,7 @@ public class PortalOwner {
 | 
			
		||||
     *
 | 
			
		||||
     * @param player <p>The player which is the owner of the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalOwner(Player player) {
 | 
			
		||||
    public PortalOwner(@NotNull Player player) {
 | 
			
		||||
        this.ownerUUID = player.getUniqueId();
 | 
			
		||||
        this.ownerName = player.getName();
 | 
			
		||||
    }
 | 
			
		||||
@@ -39,6 +41,7 @@ public class PortalOwner {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The UUID of this owner, or null if a UUID is not available</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public UUID getUUID() {
 | 
			
		||||
        return ownerUUID;
 | 
			
		||||
    }
 | 
			
		||||
@@ -51,7 +54,7 @@ public class PortalOwner {
 | 
			
		||||
     *
 | 
			
		||||
     * @param uniqueId <p>The new unique id for the portal owner</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setUUID(UUID uniqueId) {
 | 
			
		||||
    public void setUUID(@NotNull UUID uniqueId) {
 | 
			
		||||
        if (ownerUUID == null) {
 | 
			
		||||
            ownerUUID = uniqueId;
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -64,6 +67,7 @@ public class PortalOwner {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The name of this owner</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return ownerName;
 | 
			
		||||
    }
 | 
			
		||||
@@ -76,6 +80,7 @@ public class PortalOwner {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The owner's identifier</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getIdentifier() {
 | 
			
		||||
        if (ownerUUID != null) {
 | 
			
		||||
            return ownerUUID.toString();
 | 
			
		||||
@@ -93,7 +98,7 @@ public class PortalOwner {
 | 
			
		||||
     *
 | 
			
		||||
     * @param ownerIdentifier <p>The identifier for a portal's owner</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void parseIdentifier(String ownerIdentifier) {
 | 
			
		||||
    private void parseIdentifier(@NotNull String ownerIdentifier) {
 | 
			
		||||
        UUID ownerUUID = null;
 | 
			
		||||
        String ownerName;
 | 
			
		||||
        if (ownerIdentifier.length() > 16) {
 | 
			
		||||
@@ -102,7 +107,7 @@ public class PortalOwner {
 | 
			
		||||
                ownerUUID = UUID.fromString(ownerIdentifier);
 | 
			
		||||
                OfflinePlayer offlineOwner = Bukkit.getServer().getOfflinePlayer(ownerUUID);
 | 
			
		||||
                ownerName = offlineOwner.getName();
 | 
			
		||||
            } catch (IllegalArgumentException ex) {
 | 
			
		||||
            } catch (IllegalArgumentException exception) {
 | 
			
		||||
                //Invalid as UUID and username, so just keep it as owner name and hope the server owner fixes it
 | 
			
		||||
                ownerName = ownerIdentifier;
 | 
			
		||||
                Stargate.debug("loadAllPortals", "Invalid stargate owner string: " + ownerIdentifier);
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@ import net.knarcraft.stargate.container.BlockLocation;
 | 
			
		||||
import net.knarcraft.stargate.container.RelativeBlockVector;
 | 
			
		||||
import net.knarcraft.stargate.portal.Portal;
 | 
			
		||||
import net.knarcraft.stargate.portal.property.gate.Gate;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The portal structure is responsible for the physical properties of a portal
 | 
			
		||||
@@ -28,7 +30,7 @@ public class PortalStructure {
 | 
			
		||||
     * @param gate   <p>The gate type used by this portal structure</p>
 | 
			
		||||
     * @param button <p>The real location of the portal's button</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PortalStructure(Portal portal, Gate gate, BlockLocation button) {
 | 
			
		||||
    public PortalStructure(@NotNull Portal portal, @NotNull Gate gate, @Nullable BlockLocation button) {
 | 
			
		||||
        this.portal = portal;
 | 
			
		||||
        this.gate = gate;
 | 
			
		||||
        this.verified = false;
 | 
			
		||||
@@ -40,6 +42,7 @@ public class PortalStructure {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The gate used by this portal structure</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Gate getGate() {
 | 
			
		||||
        return gate;
 | 
			
		||||
    }
 | 
			
		||||
@@ -49,6 +52,7 @@ public class PortalStructure {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The location of this portal's button</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public BlockLocation getButton() {
 | 
			
		||||
        return button;
 | 
			
		||||
    }
 | 
			
		||||
@@ -58,7 +62,7 @@ public class PortalStructure {
 | 
			
		||||
     *
 | 
			
		||||
     * @param button <p>The location of this portal's button</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void setButton(BlockLocation button) {
 | 
			
		||||
    public void setButton(@NotNull BlockLocation button) {
 | 
			
		||||
        this.button = button;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -113,7 +117,8 @@ public class PortalStructure {
 | 
			
		||||
     * @param vectors <p>The relative block vectors to convert</p>
 | 
			
		||||
     * @return <p>A list of block locations</p>
 | 
			
		||||
     */
 | 
			
		||||
    private BlockLocation[] relativeBlockVectorsToBlockLocations(RelativeBlockVector[] vectors) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private BlockLocation[] relativeBlockVectorsToBlockLocations(@NotNull RelativeBlockVector[] vectors) {
 | 
			
		||||
        BlockLocation[] locations = new BlockLocation[vectors.length];
 | 
			
		||||
        for (int i = 0; i < vectors.length; i++) {
 | 
			
		||||
            locations[i] = portal.getBlockAt(vectors[i]);
 | 
			
		||||
@@ -126,6 +131,7 @@ public class PortalStructure {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The locations of this portal's entrances</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockLocation[] getEntrances() {
 | 
			
		||||
        if (entrances == null) {
 | 
			
		||||
            //Get the locations of the entrances once, and only if necessary as it's an expensive operation
 | 
			
		||||
@@ -139,6 +145,7 @@ public class PortalStructure {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The locations of this portal's frame</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public BlockLocation[] getFrame() {
 | 
			
		||||
        if (frame == null) {
 | 
			
		||||
            //Get the locations of the frame blocks once, and only if necessary as it's an expensive operation
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@ import net.knarcraft.stargate.container.BlockLocation;
 | 
			
		||||
import net.knarcraft.stargate.container.RelativeBlockVector;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.Tag;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedWriter;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
@@ -24,10 +26,12 @@ public class Gate {
 | 
			
		||||
    private final GateLayout layout;
 | 
			
		||||
    private final Map<Character, Material> characterMaterialMap;
 | 
			
		||||
    private final Map<Character, Tag<Material>> characterTagMap;
 | 
			
		||||
 | 
			
		||||
    //Gate materials
 | 
			
		||||
    private final Material portalOpenBlock;
 | 
			
		||||
    private final Material portalClosedBlock;
 | 
			
		||||
    private final Material portalButton;
 | 
			
		||||
 | 
			
		||||
    //Economy information
 | 
			
		||||
    private final int useCost;
 | 
			
		||||
    private final int createCost;
 | 
			
		||||
@@ -49,10 +53,11 @@ public class Gate {
 | 
			
		||||
     * @param destroyCost          <p>The cost of destroying a portal with this gate layout (-1 to disable)</p>
 | 
			
		||||
     * @param toOwner              <p>Whether any payment should go to the owner of the gate, as opposed to just disappearing</p>
 | 
			
		||||
     */
 | 
			
		||||
    public Gate(String filename, GateLayout layout, Map<Character, Material> characterMaterialMap,
 | 
			
		||||
                Map<Character, Tag<Material>> characterTagMap, Material portalOpenBlock,
 | 
			
		||||
                Material portalClosedBlock, Material portalButton, int useCost, int createCost, int destroyCost,
 | 
			
		||||
                boolean toOwner) {
 | 
			
		||||
    public Gate(@NotNull String filename, @NotNull GateLayout layout,
 | 
			
		||||
                @NotNull Map<Character, Material> characterMaterialMap,
 | 
			
		||||
                @NotNull Map<Character, Tag<Material>> characterTagMap, @NotNull Material portalOpenBlock,
 | 
			
		||||
                @NotNull Material portalClosedBlock, @NotNull Material portalButton, int useCost, int createCost,
 | 
			
		||||
                int destroyCost, boolean toOwner) {
 | 
			
		||||
        this.filename = filename;
 | 
			
		||||
        this.layout = layout;
 | 
			
		||||
        this.characterMaterialMap = characterMaterialMap;
 | 
			
		||||
@@ -71,6 +76,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>This gate's layout</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public GateLayout getLayout() {
 | 
			
		||||
        return layout;
 | 
			
		||||
    }
 | 
			
		||||
@@ -80,6 +86,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The character to material map</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Map<Character, Material> getCharacterMaterialMap() {
 | 
			
		||||
        return new HashMap<>(characterMaterialMap);
 | 
			
		||||
    }
 | 
			
		||||
@@ -90,8 +97,9 @@ public class Gate {
 | 
			
		||||
     * @param material <p>The material to check</p>
 | 
			
		||||
     * @return <p>True if the material is valid for control blocks</p>
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isValidControlBlock(Material material) {
 | 
			
		||||
        return (getControlBlock() != null) ? getControlBlock().equals(material) : getControlBlockTag().isTagged(material);
 | 
			
		||||
    public boolean isValidControlBlock(@NotNull Material material) {
 | 
			
		||||
        return (getControlBlock() != null) ? getControlBlock().equals(material) :
 | 
			
		||||
                getControlBlockTag().isTagged(material);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -99,6 +107,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The material tag type used for control blocks</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Tag<Material> getControlBlockTag() {
 | 
			
		||||
        return characterTagMap.get(GateHandler.getControlBlockCharacter());
 | 
			
		||||
    }
 | 
			
		||||
@@ -108,6 +117,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The material type used for control blocks</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public Material getControlBlock() {
 | 
			
		||||
        return characterMaterialMap.get(GateHandler.getControlBlockCharacter());
 | 
			
		||||
    }
 | 
			
		||||
@@ -117,6 +127,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The filename of this gate's file</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public String getFilename() {
 | 
			
		||||
        return filename;
 | 
			
		||||
    }
 | 
			
		||||
@@ -126,6 +137,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The block type to use for the opening when open</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Material getPortalOpenBlock() {
 | 
			
		||||
        return portalOpenBlock;
 | 
			
		||||
    }
 | 
			
		||||
@@ -135,6 +147,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The block type to use for the opening when closed</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Material getPortalClosedBlock() {
 | 
			
		||||
        return portalClosedBlock;
 | 
			
		||||
    }
 | 
			
		||||
@@ -144,6 +157,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The material to use for a portal's button if using this gate type</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Material getPortalButton() {
 | 
			
		||||
        return portalButton;
 | 
			
		||||
    }
 | 
			
		||||
@@ -162,6 +176,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The cost of creating a portal with this gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Integer getCreateCost() {
 | 
			
		||||
        return createCost < 0 ? Stargate.getEconomyConfig().getDefaultCreateCost() : createCost;
 | 
			
		||||
    }
 | 
			
		||||
@@ -171,6 +186,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The cost of destroying a portal with this gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Integer getDestroyCost() {
 | 
			
		||||
        return destroyCost < 0 ? Stargate.getEconomyConfig().getDefaultDestroyCost() : destroyCost;
 | 
			
		||||
    }
 | 
			
		||||
@@ -180,6 +196,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>Whether portal payments go to the owner</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Boolean getToOwner() {
 | 
			
		||||
        return toOwner;
 | 
			
		||||
    }
 | 
			
		||||
@@ -191,7 +208,7 @@ public class Gate {
 | 
			
		||||
     * @param yaw     <p>The yaw when looking directly outwards</p>
 | 
			
		||||
     * @return <p>True if this gate matches the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public boolean matches(BlockLocation topLeft, double yaw) {
 | 
			
		||||
    public boolean matches(@NotNull BlockLocation topLeft, double yaw) {
 | 
			
		||||
        return matches(topLeft, yaw, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -207,7 +224,7 @@ public class Gate {
 | 
			
		||||
     * @param onCreate <p>Whether this is used in the context of creating a new gate</p>
 | 
			
		||||
     * @return <p>True if this gate matches the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public boolean matches(BlockLocation topLeft, double yaw, boolean onCreate) {
 | 
			
		||||
    public boolean matches(@NotNull BlockLocation topLeft, double yaw, boolean onCreate) {
 | 
			
		||||
        return verifyGateEntrancesMatch(topLeft, yaw, onCreate) && verifyGateBorderMatches(topLeft, yaw);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -218,12 +235,12 @@ public class Gate {
 | 
			
		||||
     * @param yaw     <p>The yaw when looking directly outwards from the portal</p>
 | 
			
		||||
     * @return <p>True if all border blocks of the gate match the layout</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean verifyGateBorderMatches(BlockLocation topLeft, double yaw) {
 | 
			
		||||
    private boolean verifyGateBorderMatches(@NotNull BlockLocation topLeft, double yaw) {
 | 
			
		||||
        Map<Character, Material> characterMaterialMap = new HashMap<>(this.characterMaterialMap);
 | 
			
		||||
        Map<Character, Tag<Material>> characterTagMap = new HashMap<>(this.characterTagMap);
 | 
			
		||||
        for (RelativeBlockVector borderVector : layout.getBorder()) {
 | 
			
		||||
            int rowIndex = borderVector.getRight();
 | 
			
		||||
            int lineIndex = borderVector.getDown();
 | 
			
		||||
            int rowIndex = borderVector.right();
 | 
			
		||||
            int lineIndex = borderVector.down();
 | 
			
		||||
            Character key = layout.getLayout()[lineIndex][rowIndex];
 | 
			
		||||
 | 
			
		||||
            Material materialInLayout = characterMaterialMap.get(key);
 | 
			
		||||
@@ -263,7 +280,7 @@ public class Gate {
 | 
			
		||||
     * @param onCreate <p>Whether this is used in the context of creating a new gate</p>
 | 
			
		||||
     * @return <p>Whether this is used in the context of creating a new gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean verifyGateEntrancesMatch(BlockLocation topLeft, double yaw, boolean onCreate) {
 | 
			
		||||
    private boolean verifyGateEntrancesMatch(@NotNull BlockLocation topLeft, double yaw, boolean onCreate) {
 | 
			
		||||
        Stargate.debug("verifyGateEntrancesMatch", String.valueOf(topLeft));
 | 
			
		||||
        for (RelativeBlockVector entranceVector : layout.getEntrances()) {
 | 
			
		||||
            Stargate.debug("verifyGateEntrancesMatch", String.valueOf(entranceVector));
 | 
			
		||||
@@ -289,7 +306,7 @@ public class Gate {
 | 
			
		||||
     *
 | 
			
		||||
     * @param gateFolder <p>The folder to save the gate file in</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void save(String gateFolder) {
 | 
			
		||||
    public void save(@NotNull String gateFolder) {
 | 
			
		||||
        try {
 | 
			
		||||
            BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(new File(gateFolder, filename)));
 | 
			
		||||
 | 
			
		||||
@@ -321,7 +338,7 @@ public class Gate {
 | 
			
		||||
     * @param bufferedWriter <p>The buffered writer to write to</p>
 | 
			
		||||
     * @throws IOException <p>If unable to write to the buffered writer</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void saveEconomyValues(BufferedWriter bufferedWriter) throws IOException {
 | 
			
		||||
    private void saveEconomyValues(@NotNull BufferedWriter bufferedWriter) throws IOException {
 | 
			
		||||
        //Write use cost if not disabled
 | 
			
		||||
        if (useCost != -1) {
 | 
			
		||||
            writeConfig(bufferedWriter, "usecost", useCost);
 | 
			
		||||
@@ -343,7 +360,7 @@ public class Gate {
 | 
			
		||||
     * @param bufferedWriter <p>The buffered writer to write to</p>
 | 
			
		||||
     * @throws IOException <p>If unable to write to the buffered writer</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void saveFrameBlockType(BufferedWriter bufferedWriter) throws IOException {
 | 
			
		||||
    private void saveFrameBlockType(@NotNull BufferedWriter bufferedWriter) throws IOException {
 | 
			
		||||
        for (Map.Entry<Character, Material> entry : this.characterMaterialMap.entrySet()) {
 | 
			
		||||
            Character key = entry.getKey();
 | 
			
		||||
            //Skip characters not part of the frame
 | 
			
		||||
@@ -368,7 +385,8 @@ public class Gate {
 | 
			
		||||
     * @param bufferedWriter <p>The buffered writer to write to</p>
 | 
			
		||||
     * @throws IOException <p>If unable to write to the buffered writer</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void saveFrameBlockType(Character key, String value, BufferedWriter bufferedWriter) throws IOException {
 | 
			
		||||
    private void saveFrameBlockType(@NotNull Character key, @Nullable String value,
 | 
			
		||||
                                    @NotNull BufferedWriter bufferedWriter) throws IOException {
 | 
			
		||||
        bufferedWriter.append(key.toString());
 | 
			
		||||
        bufferedWriter.append('=');
 | 
			
		||||
        if (value != null) {
 | 
			
		||||
@@ -385,7 +403,8 @@ public class Gate {
 | 
			
		||||
     * @param value          <p>The config value to save</p>
 | 
			
		||||
     * @throws IOException <p>If unable to write to the buffered writer</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void writeConfig(BufferedWriter bufferedWriter, String key, Object value) throws IOException {
 | 
			
		||||
    private void writeConfig(@NotNull BufferedWriter bufferedWriter, @NotNull String key,
 | 
			
		||||
                             @NotNull Object value) throws IOException {
 | 
			
		||||
        //Figure out the correct formatting to use
 | 
			
		||||
        String format = "%s=";
 | 
			
		||||
        if (value instanceof Boolean) {
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,8 @@ import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.NamespacedKey;
 | 
			
		||||
import org.bukkit.Tag;
 | 
			
		||||
import org.bukkit.block.Block;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
@@ -48,6 +50,7 @@ public class GateHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The character used for blocks that are not part of the gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Character getAnythingCharacter() {
 | 
			
		||||
        return ANYTHING;
 | 
			
		||||
    }
 | 
			
		||||
@@ -57,6 +60,7 @@ public class GateHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The character used for defining the entrance</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Character getEntranceCharacter() {
 | 
			
		||||
        return ENTRANCE;
 | 
			
		||||
    }
 | 
			
		||||
@@ -66,6 +70,7 @@ public class GateHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The character used for defining the exit</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Character getExitCharacter() {
 | 
			
		||||
        return EXIT;
 | 
			
		||||
    }
 | 
			
		||||
@@ -76,6 +81,7 @@ public class GateHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The character used for defining control blocks</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Character getControlBlockCharacter() {
 | 
			
		||||
        return CONTROL_BLOCK;
 | 
			
		||||
    }
 | 
			
		||||
@@ -85,7 +91,7 @@ public class GateHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @param gate <p>The gate to register</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void registerGate(Gate gate) {
 | 
			
		||||
    private static void registerGate(@NotNull Gate gate) {
 | 
			
		||||
        gates.put(gate.getFilename(), gate);
 | 
			
		||||
 | 
			
		||||
        Material blockId = gate.getControlBlock();
 | 
			
		||||
@@ -110,7 +116,8 @@ public class GateHandler {
 | 
			
		||||
     * @param file <p>The file containing the gate data</p>
 | 
			
		||||
     * @return <p>The loaded gate, or null if unable to load the gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static Gate loadGate(File file) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private static Gate loadGate(@NotNull File file) {
 | 
			
		||||
        try (Scanner scanner = new Scanner(file)) {
 | 
			
		||||
            return loadGate(file.getName(), file.getParent(), scanner);
 | 
			
		||||
        } catch (Exception exception) {
 | 
			
		||||
@@ -127,7 +134,9 @@ public class GateHandler {
 | 
			
		||||
     * @param scanner      <p>The scanner to use for reading the gate data</p>
 | 
			
		||||
     * @return <p>The loaded gate or null if unable to load the gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static Gate loadGate(String fileName, String parentFolder, Scanner scanner) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private static Gate loadGate(@NotNull String fileName, @NotNull String parentFolder,
 | 
			
		||||
                                 @NotNull Scanner scanner) {
 | 
			
		||||
        List<List<Character>> design = new ArrayList<>();
 | 
			
		||||
        Map<Character, Material> characterMaterialMap = new HashMap<>();
 | 
			
		||||
        Map<Character, Tag<Material>> characterTagMap = new HashMap<>();
 | 
			
		||||
@@ -166,9 +175,11 @@ public class GateHandler {
 | 
			
		||||
     * @param materialTagMap       <p>A map between layout characters and the material tags to use</p>
 | 
			
		||||
     * @return <p>A new gate, or null if the config is invalid</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static Gate createGate(Map<String, String> config, String fileName, Character[][] layout,
 | 
			
		||||
                                   Map<Character, Material> characterMaterialMap,
 | 
			
		||||
                                   Map<Character, Tag<Material>> materialTagMap) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private static Gate createGate(@NotNull Map<String, String> config, @NotNull String fileName,
 | 
			
		||||
                                   @NotNull Character[][] layout,
 | 
			
		||||
                                   @NotNull Map<Character, Material> characterMaterialMap,
 | 
			
		||||
                                   @NotNull Map<Character, Tag<Material>> materialTagMap) {
 | 
			
		||||
        //Read relevant material types
 | 
			
		||||
        Material portalOpenBlock = readGateConfig(config, fileName, "portal-open", defaultPortalBlockOpen);
 | 
			
		||||
        Material portalClosedBlock = readGateConfig(config, fileName, "portal-closed", defaultPortalBlockClosed);
 | 
			
		||||
@@ -198,7 +209,7 @@ public class GateHandler {
 | 
			
		||||
     * @param fileName <p>The filename of the loaded gate file</p>
 | 
			
		||||
     * @return <p>True if the gate is valid. False otherwise</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static boolean validateGate(Gate gate, String fileName) {
 | 
			
		||||
    private static boolean validateGate(@NotNull Gate gate, @NotNull String fileName) {
 | 
			
		||||
        String failString = String.format("Could not load Gate %s", fileName) + " - %s";
 | 
			
		||||
 | 
			
		||||
        if (gate.getLayout().getControls().length != 2) {
 | 
			
		||||
@@ -236,7 +247,7 @@ public class GateHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @param gateFolder <p>The folder containing the gates</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void loadGates(String gateFolder) {
 | 
			
		||||
    public static void loadGates(@NotNull String gateFolder) {
 | 
			
		||||
        File directory = new File(gateFolder);
 | 
			
		||||
        File[] files;
 | 
			
		||||
 | 
			
		||||
@@ -269,7 +280,7 @@ public class GateHandler {
 | 
			
		||||
     *
 | 
			
		||||
     * @param gateFolder <p>The folder containing gate config files</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void writeDefaultGatesToFolder(String gateFolder) {
 | 
			
		||||
    public static void writeDefaultGatesToFolder(@NotNull String gateFolder) {
 | 
			
		||||
        loadGateFromJar("nethergate.gate", gateFolder);
 | 
			
		||||
        loadGateFromJar("watergate.gate", gateFolder);
 | 
			
		||||
        loadGateFromJar("endgate.gate", gateFolder);
 | 
			
		||||
@@ -283,7 +294,7 @@ public class GateHandler {
 | 
			
		||||
     * @param gateFile   <p>The name of the gate file</p>
 | 
			
		||||
     * @param gateFolder <p>The folder containing gates</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void loadGateFromJar(String gateFile, String gateFolder) {
 | 
			
		||||
    private static void loadGateFromJar(@NotNull String gateFile, @NotNull String gateFolder) {
 | 
			
		||||
        //Get an input stream for the internal file
 | 
			
		||||
        InputStream gateFileStream = Gate.class.getResourceAsStream("/gates/" + gateFile);
 | 
			
		||||
        if (gateFileStream != null) {
 | 
			
		||||
@@ -305,7 +316,8 @@ public class GateHandler {
 | 
			
		||||
     * @param block <p>The control block to check</p>
 | 
			
		||||
     * @return <p>A list of gates using the given control block</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Gate[] getGatesByControlBlock(Block block) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static List<Gate> getGatesByControlBlock(@NotNull Block block) {
 | 
			
		||||
        return getGatesByControlBlock(block.getType());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -318,7 +330,8 @@ public class GateHandler {
 | 
			
		||||
     * @param type <p>The type of the control block to check</p>
 | 
			
		||||
     * @return <p>A list of gates using the given material for control block</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Gate[] getGatesByControlBlock(Material type) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static List<Gate> getGatesByControlBlock(@NotNull Material type) {
 | 
			
		||||
        List<Gate> result = new ArrayList<>();
 | 
			
		||||
        List<Gate> fromId = controlBlocks.get(type);
 | 
			
		||||
        List<Gate> fromTag = null;
 | 
			
		||||
@@ -337,7 +350,7 @@ public class GateHandler {
 | 
			
		||||
            result.addAll(fromTag);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return result.toArray(new Gate[0]);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -346,7 +359,8 @@ public class GateHandler {
 | 
			
		||||
     * @param fileName <p>The filename of the gate to get</p>
 | 
			
		||||
     * @return <p>The gate with the given filename</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Gate getGateByName(String fileName) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Gate getGateByName(@NotNull String fileName) {
 | 
			
		||||
        return gates.get(fileName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
package net.knarcraft.stargate.portal.property.gate;
 | 
			
		||||
 | 
			
		||||
import net.knarcraft.stargate.container.RelativeBlockVector;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedWriter;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
@@ -28,7 +30,7 @@ public class GateLayout {
 | 
			
		||||
     *
 | 
			
		||||
     * @param layout <p>A character matrix describing the layout</p>
 | 
			
		||||
     */
 | 
			
		||||
    public GateLayout(Character[][] layout) {
 | 
			
		||||
    public GateLayout(@NotNull Character[][] layout) {
 | 
			
		||||
        this.layout = layout;
 | 
			
		||||
        readLayout();
 | 
			
		||||
    }
 | 
			
		||||
@@ -38,6 +40,7 @@ public class GateLayout {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The character array describing this layout</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Character[][] getLayout() {
 | 
			
		||||
        return this.layout;
 | 
			
		||||
    }
 | 
			
		||||
@@ -49,6 +52,7 @@ public class GateLayout {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The locations of entrances for this gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public RelativeBlockVector[] getEntrances() {
 | 
			
		||||
        return entrances;
 | 
			
		||||
    }
 | 
			
		||||
@@ -61,6 +65,7 @@ public class GateLayout {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The locations of border blocks for this gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public RelativeBlockVector[] getBorder() {
 | 
			
		||||
        return border;
 | 
			
		||||
    }
 | 
			
		||||
@@ -70,6 +75,7 @@ public class GateLayout {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The exit block defined in the layout</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public RelativeBlockVector getExit() {
 | 
			
		||||
        return exitBlock;
 | 
			
		||||
    }
 | 
			
		||||
@@ -82,6 +88,7 @@ public class GateLayout {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>All possible exits</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public List<RelativeBlockVector> getExits() {
 | 
			
		||||
        return exits;
 | 
			
		||||
    }
 | 
			
		||||
@@ -94,6 +101,7 @@ public class GateLayout {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The locations of the control blocks for this gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public RelativeBlockVector[] getControls() {
 | 
			
		||||
        return controls;
 | 
			
		||||
    }
 | 
			
		||||
@@ -104,7 +112,7 @@ public class GateLayout {
 | 
			
		||||
     * @param bufferedWriter <p>The buffered writer to write to</p>
 | 
			
		||||
     * @throws IOException <p>If unable to write to the buffered writer</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void saveLayout(BufferedWriter bufferedWriter) throws IOException {
 | 
			
		||||
    public void saveLayout(@NotNull BufferedWriter bufferedWriter) throws IOException {
 | 
			
		||||
        for (Character[] line : this.layout) {
 | 
			
		||||
            for (Character character : line) {
 | 
			
		||||
                bufferedWriter.append(character);
 | 
			
		||||
@@ -137,8 +145,9 @@ public class GateLayout {
 | 
			
		||||
     * @param entranceList <p>The list of entrances to save to</p>
 | 
			
		||||
     * @param borderList   <p>The list of border blocks to save to</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void readLayout(List<RelativeBlockVector> controlList, List<RelativeBlockVector> entranceList,
 | 
			
		||||
                            List<RelativeBlockVector> borderList) {
 | 
			
		||||
    private void readLayout(@NotNull List<RelativeBlockVector> controlList,
 | 
			
		||||
                            @NotNull List<RelativeBlockVector> entranceList,
 | 
			
		||||
                            @NotNull List<RelativeBlockVector> borderList) {
 | 
			
		||||
        //Store the lowest opening for each column
 | 
			
		||||
        int[] exitDepths = new int[layout[0].length];
 | 
			
		||||
 | 
			
		||||
@@ -173,9 +182,10 @@ public class GateLayout {
 | 
			
		||||
     * @param entranceList <p>The list of entrances to save to</p>
 | 
			
		||||
     * @param borderList   <p>The list of border blocks to save to</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void parseLayoutCharacter(Character key, int columnIndex, int rowIndex, int[] exitDepths,
 | 
			
		||||
                                      List<RelativeBlockVector> controlList, List<RelativeBlockVector> entranceList,
 | 
			
		||||
                                      List<RelativeBlockVector> borderList) {
 | 
			
		||||
    private void parseLayoutCharacter(@NotNull Character key, int columnIndex, int rowIndex, int[] exitDepths,
 | 
			
		||||
                                      @NotNull List<RelativeBlockVector> controlList,
 | 
			
		||||
                                      @NotNull List<RelativeBlockVector> entranceList,
 | 
			
		||||
                                      @NotNull List<RelativeBlockVector> borderList) {
 | 
			
		||||
        //Add control blocks to the control block list
 | 
			
		||||
        if (key.equals(GateHandler.getControlBlockCharacter())) {
 | 
			
		||||
            controlList.add(new RelativeBlockVector(columnIndex, rowIndex, 0));
 | 
			
		||||
@@ -202,7 +212,7 @@ public class GateLayout {
 | 
			
		||||
     * @param character <p>The character to check</p>
 | 
			
		||||
     * @return <p>True if the character represents an opening</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean isOpening(Character character) {
 | 
			
		||||
    private boolean isOpening(@NotNull Character character) {
 | 
			
		||||
        return character.equals(GateHandler.getEntranceCharacter()) || character.equals(GateHandler.getExitCharacter());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package net.knarcraft.stargate.portal.teleporter;
 | 
			
		||||
import net.knarcraft.stargate.event.StargateEntityPortalEvent;
 | 
			
		||||
import net.knarcraft.stargate.portal.Portal;
 | 
			
		||||
import org.bukkit.entity.Entity;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The portal teleporter takes care of the actual portal teleportation for any entities
 | 
			
		||||
@@ -16,7 +17,7 @@ public class EntityTeleporter extends Teleporter {
 | 
			
		||||
     *
 | 
			
		||||
     * @param targetPortal <p>The portal which is the target of the teleportation</p>
 | 
			
		||||
     */
 | 
			
		||||
    public EntityTeleporter(Portal targetPortal, Entity teleportingEntity) {
 | 
			
		||||
    public EntityTeleporter(@NotNull Portal targetPortal, @NotNull Entity teleportingEntity) {
 | 
			
		||||
        super(targetPortal, teleportingEntity);
 | 
			
		||||
        this.teleportingEntity = teleportingEntity;
 | 
			
		||||
    }
 | 
			
		||||
@@ -27,7 +28,7 @@ public class EntityTeleporter extends Teleporter {
 | 
			
		||||
     * @param origin <p>The portal the entity is teleporting from</p>
 | 
			
		||||
     * @return <p>True if the entity was teleported. False otherwise</p>
 | 
			
		||||
     */
 | 
			
		||||
    public boolean teleportEntity(Portal origin) {
 | 
			
		||||
    public boolean teleportEntity(@NotNull Portal origin) {
 | 
			
		||||
        return teleport(origin, new StargateEntityPortalEvent(teleportingEntity, origin, portal, exit));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,8 @@ import org.bukkit.entity.Entity;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.event.player.PlayerMoveEvent;
 | 
			
		||||
import org.bukkit.util.Vector;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@@ -26,7 +28,7 @@ public class PlayerTeleporter extends Teleporter {
 | 
			
		||||
     * @param targetPortal <p>The portal which is the target of the teleportation</p>
 | 
			
		||||
     * @param player       <p>The teleporting player</p>
 | 
			
		||||
     */
 | 
			
		||||
    public PlayerTeleporter(Portal targetPortal, Player player) {
 | 
			
		||||
    public PlayerTeleporter(@NotNull Portal targetPortal, @NotNull Player player) {
 | 
			
		||||
        super(targetPortal, player);
 | 
			
		||||
        this.player = player;
 | 
			
		||||
    }
 | 
			
		||||
@@ -37,7 +39,7 @@ public class PlayerTeleporter extends Teleporter {
 | 
			
		||||
     * @param origin <p>The portal the player teleports from</p>
 | 
			
		||||
     * @param event  <p>The player move event triggering the event</p>
 | 
			
		||||
     */
 | 
			
		||||
    public void teleportPlayer(Portal origin, PlayerMoveEvent event) {
 | 
			
		||||
    public void teleportPlayer(@NotNull Portal origin, @Nullable PlayerMoveEvent event) {
 | 
			
		||||
        double velocity = player.getVelocity().length();
 | 
			
		||||
        List<Entity> passengers = player.getPassengers();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,8 @@ import org.bukkit.entity.Entity;
 | 
			
		||||
import org.bukkit.event.Event;
 | 
			
		||||
import org.bukkit.scheduler.BukkitScheduler;
 | 
			
		||||
import org.bukkit.util.Vector;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@@ -55,7 +57,7 @@ public abstract class Teleporter {
 | 
			
		||||
     * @param portal           <p>The portal which is the target of the teleportation</p>
 | 
			
		||||
     * @param teleportedEntity <p>The entity teleported by this teleporter</p>
 | 
			
		||||
     */
 | 
			
		||||
    public Teleporter(Portal portal, Entity teleportedEntity) {
 | 
			
		||||
    public Teleporter(@NotNull Portal portal, @NotNull Entity teleportedEntity) {
 | 
			
		||||
        this.portal = portal;
 | 
			
		||||
        this.scheduler = Stargate.getInstance().getServer().getScheduler();
 | 
			
		||||
        this.teleportedEntity = teleportedEntity;
 | 
			
		||||
@@ -69,11 +71,11 @@ public abstract class Teleporter {
 | 
			
		||||
     * @param stargateTeleportEvent <p>The event to call to make sure the teleportation is valid</p>
 | 
			
		||||
     * @return <p>True if the teleportation was successfully performed</p>
 | 
			
		||||
     */
 | 
			
		||||
    public boolean teleport(Portal origin, StargateTeleportEvent stargateTeleportEvent) {
 | 
			
		||||
    public boolean teleport(@NotNull Portal origin, @Nullable StargateTeleportEvent stargateTeleportEvent) {
 | 
			
		||||
        List<Entity> passengers = teleportedEntity.getPassengers();
 | 
			
		||||
 | 
			
		||||
        //Call the StargateEntityPortalEvent to allow plugins to change destination
 | 
			
		||||
        if (!origin.equals(portal)) {
 | 
			
		||||
        if (!origin.equals(portal) && stargateTeleportEvent != null) {
 | 
			
		||||
            exit = triggerPortalEvent(origin, stargateTeleportEvent);
 | 
			
		||||
            if (exit == null) {
 | 
			
		||||
                return false;
 | 
			
		||||
@@ -96,6 +98,7 @@ public abstract class Teleporter {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The exit location of this teleporter</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public Location getExit() {
 | 
			
		||||
        return exit.clone();
 | 
			
		||||
    }
 | 
			
		||||
@@ -107,7 +110,9 @@ public abstract class Teleporter {
 | 
			
		||||
     * @param stargateTeleportEvent <p>The exit location to teleport the entity to</p>
 | 
			
		||||
     * @return <p>The location the entity should be teleported to, or null if the event was cancelled</p>
 | 
			
		||||
     */
 | 
			
		||||
    protected Location triggerPortalEvent(Portal origin, StargateTeleportEvent stargateTeleportEvent) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    protected Location triggerPortalEvent(@NotNull Portal origin,
 | 
			
		||||
                                          @NotNull StargateTeleportEvent stargateTeleportEvent) {
 | 
			
		||||
        Stargate.getInstance().getServer().getPluginManager().callEvent((Event) stargateTeleportEvent);
 | 
			
		||||
        //Teleport is cancelled. Teleport the entity back to where it came from just for sanity's sake
 | 
			
		||||
        if (stargateTeleportEvent.isCancelled()) {
 | 
			
		||||
@@ -122,7 +127,7 @@ public abstract class Teleporter {
 | 
			
		||||
     *
 | 
			
		||||
     * @param exit <p>The location the entity will exit from</p>
 | 
			
		||||
     */
 | 
			
		||||
    protected void adjustExitLocationRotation(Location exit) {
 | 
			
		||||
    protected void adjustExitLocationRotation(@NotNull Location exit) {
 | 
			
		||||
        int adjust = 0;
 | 
			
		||||
        if (portal.getOptions().isBackwards()) {
 | 
			
		||||
            adjust = 180;
 | 
			
		||||
@@ -151,7 +156,9 @@ public abstract class Teleporter {
 | 
			
		||||
     * @param entity       <p>The travelling entity</p>
 | 
			
		||||
     * @return <p>A location which won't suffocate the entity inside the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    private Location preventExitSuffocation(RelativeBlockVector relativeExit, Location exitLocation, Entity entity) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private Location preventExitSuffocation(@NotNull RelativeBlockVector relativeExit,
 | 
			
		||||
                                            @NotNull Location exitLocation, @NotNull Entity entity) {
 | 
			
		||||
        //Go left to find start of opening
 | 
			
		||||
        RelativeBlockVector openingLeft = getPortalExitEdge(relativeExit, -1);
 | 
			
		||||
 | 
			
		||||
@@ -159,8 +166,8 @@ public abstract class Teleporter {
 | 
			
		||||
        RelativeBlockVector openingRight = getPortalExitEdge(relativeExit, 1);
 | 
			
		||||
 | 
			
		||||
        //Get the width to check if the entity fits
 | 
			
		||||
        int openingWidth = openingRight.getRight() - openingLeft.getRight() + 1;
 | 
			
		||||
        int existingOffset = relativeExit.getRight() - openingLeft.getRight();
 | 
			
		||||
        int openingWidth = openingRight.right() - openingLeft.right() + 1;
 | 
			
		||||
        int existingOffset = relativeExit.right() - openingLeft.right();
 | 
			
		||||
        double newOffset = (openingWidth - existingOffset) / 2D;
 | 
			
		||||
 | 
			
		||||
        //Remove the half offset for better centering
 | 
			
		||||
@@ -180,7 +187,8 @@ public abstract class Teleporter {
 | 
			
		||||
     * @param entity       <p>The entity to adjust the exit location for</p>
 | 
			
		||||
     * @return <p>The adjusted exit location</p>
 | 
			
		||||
     */
 | 
			
		||||
    private Location moveExitLocationOutwards(Location exitLocation, Entity entity) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private Location moveExitLocationOutwards(@NotNull Location exitLocation, @NotNull Entity entity) {
 | 
			
		||||
        double entitySize = EntityHelper.getEntityMaxSize(entity);
 | 
			
		||||
        int entityBoxSize = EntityHelper.getEntityMaxSizeInt(entity);
 | 
			
		||||
        if (entitySize > 1) {
 | 
			
		||||
@@ -207,12 +215,13 @@ public abstract class Teleporter {
 | 
			
		||||
     * @param direction    <p>The direction to move (+1 for right, -1 for left)</p>
 | 
			
		||||
     * @return <p>The right or left edge of the opening</p>
 | 
			
		||||
     */
 | 
			
		||||
    private RelativeBlockVector getPortalExitEdge(RelativeBlockVector relativeExit, int direction) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private RelativeBlockVector getPortalExitEdge(@NotNull RelativeBlockVector relativeExit, int direction) {
 | 
			
		||||
        RelativeBlockVector openingEdge = relativeExit;
 | 
			
		||||
 | 
			
		||||
        do {
 | 
			
		||||
            RelativeBlockVector possibleOpening = new RelativeBlockVector(openingEdge.getRight() + direction,
 | 
			
		||||
                    openingEdge.getDown(), openingEdge.getOut());
 | 
			
		||||
            RelativeBlockVector possibleOpening = new RelativeBlockVector(openingEdge.right() + direction,
 | 
			
		||||
                    openingEdge.down(), openingEdge.out());
 | 
			
		||||
            if (portal.getGate().getLayout().getExits().contains(possibleOpening)) {
 | 
			
		||||
                openingEdge = possibleOpening;
 | 
			
		||||
            } else {
 | 
			
		||||
@@ -234,7 +243,8 @@ public abstract class Teleporter {
 | 
			
		||||
     * @param exitLocation <p>The exit location generated</p>
 | 
			
		||||
     * @return <p>The location the travelling entity should be teleported to</p>
 | 
			
		||||
     */
 | 
			
		||||
    private Location adjustExitLocationHeight(Entity entity, Location exitLocation) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private Location adjustExitLocationHeight(@NotNull Entity entity, @Nullable Location exitLocation) {
 | 
			
		||||
        if (exitLocation != null) {
 | 
			
		||||
            BlockData blockData = exitLocation.getBlock().getBlockData();
 | 
			
		||||
            if ((blockData instanceof Bisected bisected && bisected.getHalf() == Bisected.Half.BOTTOM) ||
 | 
			
		||||
@@ -257,7 +267,8 @@ public abstract class Teleporter {
 | 
			
		||||
     * @param entity <p>The entity to teleport (used to determine distance from portal to avoid suffocation)</p>
 | 
			
		||||
     * @return <p>The location the entity should be teleported to.</p>
 | 
			
		||||
     */
 | 
			
		||||
    private Location getExit(Entity entity) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private Location getExit(@NotNull Entity entity) {
 | 
			
		||||
        Location exitLocation = null;
 | 
			
		||||
        RelativeBlockVector relativeExit = portal.getGate().getLayout().getExit();
 | 
			
		||||
        if (relativeExit != null) {
 | 
			
		||||
@@ -270,12 +281,10 @@ public abstract class Teleporter {
 | 
			
		||||
            }
 | 
			
		||||
            exitLocation = exit.getRelativeLocation(0D, 0D, 1, portalYaw);
 | 
			
		||||
 | 
			
		||||
            if (entity != null) {
 | 
			
		||||
                double entitySize = EntityHelper.getEntityMaxSize(entity);
 | 
			
		||||
                //Prevent exit suffocation for players riding horses or similar
 | 
			
		||||
                if (entitySize > 1) {
 | 
			
		||||
                    exitLocation = preventExitSuffocation(relativeExit, exitLocation, entity);
 | 
			
		||||
                }
 | 
			
		||||
            double entitySize = EntityHelper.getEntityMaxSize(entity);
 | 
			
		||||
            //Prevent exit suffocation for players riding horses or similar
 | 
			
		||||
            if (entitySize > 1) {
 | 
			
		||||
                exitLocation = preventExitSuffocation(relativeExit, exitLocation, entity);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            Stargate.logWarning(String.format("Missing destination point in .gate file %s",
 | 
			
		||||
@@ -293,6 +302,7 @@ public abstract class Teleporter {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A list of chunks to load</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private List<Chunk> getChunksToLoad() {
 | 
			
		||||
        List<Chunk> chunksToLoad = new ArrayList<>();
 | 
			
		||||
        for (RelativeBlockVector vector : portal.getGate().getLayout().getEntrances()) {
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@ import org.bukkit.entity.LivingEntity;
 | 
			
		||||
import org.bukkit.entity.Vehicle;
 | 
			
		||||
import org.bukkit.event.player.PlayerTeleportEvent;
 | 
			
		||||
import org.bukkit.util.Vector;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@@ -30,7 +31,7 @@ public class VehicleTeleporter extends EntityTeleporter {
 | 
			
		||||
     * @param targetPortal       <p>The targetPortal which is the target of the teleportation</p>
 | 
			
		||||
     * @param teleportingVehicle <p>The teleporting vehicle</p>
 | 
			
		||||
     */
 | 
			
		||||
    public VehicleTeleporter(Portal targetPortal, Vehicle teleportingVehicle) {
 | 
			
		||||
    public VehicleTeleporter(@NotNull Portal targetPortal, @NotNull Vehicle teleportingVehicle) {
 | 
			
		||||
        super(targetPortal, teleportingVehicle);
 | 
			
		||||
        this.teleportingVehicle = teleportingVehicle;
 | 
			
		||||
    }
 | 
			
		||||
@@ -45,7 +46,7 @@ public class VehicleTeleporter extends EntityTeleporter {
 | 
			
		||||
     * @return <p>True if the vehicle was teleported. False otherwise</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean teleportEntity(Portal origin) {
 | 
			
		||||
    public boolean teleportEntity(@NotNull Portal origin) {
 | 
			
		||||
        Stargate.debug("VehicleTeleporter::teleport", "Preparing to teleport: " + teleportingVehicle);
 | 
			
		||||
 | 
			
		||||
        double velocity = teleportingVehicle.getVelocity().length();
 | 
			
		||||
@@ -75,7 +76,7 @@ public class VehicleTeleporter extends EntityTeleporter {
 | 
			
		||||
     * @param origin      <p>The portal the vehicle teleported from</p>
 | 
			
		||||
     * @return <p>True if the vehicle was teleported. False otherwise</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean teleportVehicle(Location exit, Vector newVelocity, Portal origin) {
 | 
			
		||||
    private boolean teleportVehicle(@NotNull Location exit, @NotNull Vector newVelocity, @NotNull Portal origin) {
 | 
			
		||||
        //Load chunks to make sure not to teleport to the void
 | 
			
		||||
        loadChunks();
 | 
			
		||||
 | 
			
		||||
@@ -113,7 +114,7 @@ public class VehicleTeleporter extends EntityTeleporter {
 | 
			
		||||
     * @param passengers <p>The passengers to teleport</p>
 | 
			
		||||
     * @return <p>True if the passengers are allowed to teleport</p>
 | 
			
		||||
     */
 | 
			
		||||
    private boolean vehiclePassengersAllowed(List<Entity> passengers) {
 | 
			
		||||
    private boolean vehiclePassengersAllowed(@NotNull List<Entity> passengers) {
 | 
			
		||||
        StargateGateConfig config = Stargate.getGateConfig();
 | 
			
		||||
        //Don't teleport if the vehicle contains a creature and creature transportation is disabled
 | 
			
		||||
        if (TeleportHelper.containsNonPlayer(passengers) && !config.handleCreatureTransportation()) {
 | 
			
		||||
@@ -131,7 +132,8 @@ public class VehicleTeleporter extends EntityTeleporter {
 | 
			
		||||
     * @param newVelocity <p>The new velocity of the teleported vehicle</p>
 | 
			
		||||
     * @param origin      <p>The portal the vehicle teleported from</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void teleportVehicle(List<Entity> passengers, Location exit, Vector newVelocity, Portal origin) {
 | 
			
		||||
    private void teleportVehicle(@NotNull List<Entity> passengers, @NotNull Location exit, @NotNull Vector newVelocity,
 | 
			
		||||
                                 @NotNull Portal origin) {
 | 
			
		||||
        if (teleportingVehicle.eject()) {
 | 
			
		||||
            TeleportHelper.handleEntityPassengers(passengers, teleportingVehicle, origin, portal, exit.getDirection(),
 | 
			
		||||
                    newVelocity);
 | 
			
		||||
@@ -159,8 +161,8 @@ public class VehicleTeleporter extends EntityTeleporter {
 | 
			
		||||
     * @param newVelocity <p>The new velocity of the new vehicle</p>
 | 
			
		||||
     * @param origin      <p>The portal the vehicle teleported from</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void putPassengersInNewVehicle(List<Entity> passengers, Location exit,
 | 
			
		||||
                                           Vector newVelocity, Portal origin) {
 | 
			
		||||
    private void putPassengersInNewVehicle(@NotNull List<Entity> passengers, @NotNull Location exit,
 | 
			
		||||
                                           @NotNull Vector newVelocity, Portal origin) {
 | 
			
		||||
        World vehicleWorld = exit.getWorld();
 | 
			
		||||
        if (vehicleWorld == null) {
 | 
			
		||||
            Stargate.logWarning("Unable to get the world to teleport the vehicle to");
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ import org.bukkit.World;
 | 
			
		||||
import org.bukkit.block.Block;
 | 
			
		||||
import org.bukkit.block.EndGateway;
 | 
			
		||||
import org.bukkit.block.data.Orientable;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This thread changes gate blocks to display a gate as open or closed
 | 
			
		||||
@@ -58,7 +59,7 @@ public class BlockChangeThread implements Runnable {
 | 
			
		||||
     *
 | 
			
		||||
     * @param block <p>The block to fix</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void fixEndGatewayGate(Block block) {
 | 
			
		||||
    private static void fixEndGatewayGate(@NotNull Block block) {
 | 
			
		||||
        EndGateway gateway = (EndGateway) block.getState();
 | 
			
		||||
        gateway.setAge(Long.MIN_VALUE);
 | 
			
		||||
        if (block.getWorld().getEnvironment() == World.Environment.THE_END) {
 | 
			
		||||
@@ -74,7 +75,7 @@ public class BlockChangeThread implements Runnable {
 | 
			
		||||
     * @param block <p>The block to orient</p>
 | 
			
		||||
     * @param axis  <p>The axis to use for orienting the block</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void orientBlock(Block block, Axis axis) {
 | 
			
		||||
    private static void orientBlock(@NotNull Block block, @NotNull Axis axis) {
 | 
			
		||||
        Orientable orientable = (Orientable) block.getBlockData();
 | 
			
		||||
        orientable.setAxis(axis);
 | 
			
		||||
        block.setBlockData(orientable);
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ import org.bstats.bukkit.Metrics;
 | 
			
		||||
import org.bstats.charts.SimplePie;
 | 
			
		||||
import org.bstats.charts.SingleLineChart;
 | 
			
		||||
import org.bukkit.plugin.java.JavaPlugin;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
@@ -28,7 +29,7 @@ public final class BStatsHelper {
 | 
			
		||||
     *
 | 
			
		||||
     * @param plugin <p>The plugin to initialize BStats for</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void initialize(JavaPlugin plugin) {
 | 
			
		||||
    public static void initialize(@NotNull JavaPlugin plugin) {
 | 
			
		||||
        if (hasBeenInitialized) {
 | 
			
		||||
            throw new IllegalArgumentException("BStats initialized twice");
 | 
			
		||||
        } else {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,8 @@ import net.knarcraft.stargate.portal.teleporter.PlayerTeleporter;
 | 
			
		||||
import net.md_5.bungee.api.ChatColor;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.event.player.PlayerMoveEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.io.ByteArrayInputStream;
 | 
			
		||||
import java.io.ByteArrayOutputStream;
 | 
			
		||||
@@ -36,6 +38,7 @@ public final class BungeeHelper {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The bungee plugin channel</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static String getBungeeChannel() {
 | 
			
		||||
        return bungeeChannel;
 | 
			
		||||
    }
 | 
			
		||||
@@ -48,9 +51,10 @@ public final class BungeeHelper {
 | 
			
		||||
     * queue and teleported to the destination.</p>
 | 
			
		||||
     *
 | 
			
		||||
     * @param playerUUID <p>The UUID of the player to remove</p>
 | 
			
		||||
     * @return <p>The name of the destination portal the player should be teleported to</p>
 | 
			
		||||
     * @return <p>The name of the destination portal the player should be teleported to, or null if not queued</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static String removeFromQueue(UUID playerUUID) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static String removeFromQueue(@NotNull UUID playerUUID) {
 | 
			
		||||
        return bungeeQueue.remove(playerUUID);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -61,7 +65,7 @@ public final class BungeeHelper {
 | 
			
		||||
     * @param entrancePortal <p>The portal the player is teleporting from</p>
 | 
			
		||||
     * @return <p>True if the message was successfully sent</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean sendTeleportationMessage(Player player, Portal entrancePortal) {
 | 
			
		||||
    public static boolean sendTeleportationMessage(@NotNull Player player, @NotNull Portal entrancePortal) {
 | 
			
		||||
        try {
 | 
			
		||||
            //Build the teleportation message, format is <player identifier>delimiter<destination>
 | 
			
		||||
            String message = player.getUniqueId() + teleportMessageDelimiter + entrancePortal.getDestinationName();
 | 
			
		||||
@@ -81,8 +85,8 @@ public final class BungeeHelper {
 | 
			
		||||
            dataOutputStream.writeBytes(message);
 | 
			
		||||
            //Send the plugin message
 | 
			
		||||
            player.sendPluginMessage(Stargate.getInstance(), bungeeChannel, byteArrayOutputStream.toByteArray());
 | 
			
		||||
        } catch (IOException ex) {
 | 
			
		||||
            Stargate.logSevere("Error sending BungeeCord teleport packet! Message: " + ex.getMessage());
 | 
			
		||||
        } catch (IOException exception) {
 | 
			
		||||
            Stargate.logSevere("Error sending BungeeCord teleport packet! Message: " + exception.getMessage());
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
@@ -95,7 +99,7 @@ public final class BungeeHelper {
 | 
			
		||||
     * @param entrancePortal <p>The bungee portal the player is teleporting from</p>
 | 
			
		||||
     * @return <p>True if the plugin message was sent successfully</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean changeServer(Player player, Portal entrancePortal) {
 | 
			
		||||
    public static boolean changeServer(@NotNull Player player, @NotNull Portal entrancePortal) {
 | 
			
		||||
        try {
 | 
			
		||||
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 | 
			
		||||
            DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
 | 
			
		||||
@@ -119,6 +123,7 @@ public final class BungeeHelper {
 | 
			
		||||
     * @param message <p>The byte array to read</p>
 | 
			
		||||
     * @return <p>The message contained in the byte array, or null on failure</p>
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static String readPluginMessage(byte[] message) {
 | 
			
		||||
        byte[] data;
 | 
			
		||||
        try {
 | 
			
		||||
@@ -147,7 +152,7 @@ public final class BungeeHelper {
 | 
			
		||||
     *
 | 
			
		||||
     * @param receivedMessage <p>The received teleport message</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void handleTeleportMessage(String receivedMessage) {
 | 
			
		||||
    public static void handleTeleportMessage(@NotNull String receivedMessage) {
 | 
			
		||||
        //Get the player id and destination from the message
 | 
			
		||||
        String[] messageParts = receivedMessage.split(teleportMessageDelimiter);
 | 
			
		||||
        UUID playerUUID = UUID.fromString(messageParts[0]);
 | 
			
		||||
@@ -176,7 +181,8 @@ public final class BungeeHelper {
 | 
			
		||||
     * @param event          <p>The event causing the teleportation</p>
 | 
			
		||||
     * @return <p>True if the teleportation was successful</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean bungeeTeleport(Player player, Portal entrancePortal, PlayerMoveEvent event) {
 | 
			
		||||
    public static boolean bungeeTeleport(@NotNull Player player, @NotNull Portal entrancePortal,
 | 
			
		||||
                                         @NotNull PlayerMoveEvent event) {
 | 
			
		||||
        //Check if bungee is actually enabled
 | 
			
		||||
        if (!Stargate.getGateConfig().enableBungee()) {
 | 
			
		||||
            if (!entrancePortal.getOptions().isSilent()) {
 | 
			
		||||
@@ -211,7 +217,8 @@ public final class BungeeHelper {
 | 
			
		||||
     * @param string <p>The string to strip color from</p>
 | 
			
		||||
     * @return <p>The string without color codes</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static String stripColor(String string) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private static String stripColor(@NotNull String string) {
 | 
			
		||||
        return ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', string));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package net.knarcraft.stargate.utility;
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.block.BlockFace;
 | 
			
		||||
import org.bukkit.util.Vector;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class helps with direction-related calculations
 | 
			
		||||
@@ -24,7 +25,7 @@ public final class DirectionHelper {
 | 
			
		||||
     * @param location2 <p>The second location, which the yaw will point towards</p>
 | 
			
		||||
     * @return <p>The yaw pointing from the first location to the second location</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static float getYawFromLocationDifference(Location location1, Location location2) {
 | 
			
		||||
    public static float getYawFromLocationDifference(@NotNull Location location1, @NotNull Location location2) {
 | 
			
		||||
        Location difference = location1.clone().subtract(location2.clone());
 | 
			
		||||
        if (difference.getX() > 0) {
 | 
			
		||||
            return 90;
 | 
			
		||||
@@ -45,8 +46,10 @@ public final class DirectionHelper {
 | 
			
		||||
     *
 | 
			
		||||
     * @param yaw <p>The yaw value to convert</p>
 | 
			
		||||
     * @return <p>The block face the yaw corresponds to</p>
 | 
			
		||||
     * @throws IllegalArgumentException <p>If a yaw not divisible by 90 us given</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static BlockFace getBlockFaceFromYaw(double yaw) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static BlockFace getBlockFaceFromYaw(double yaw) throws IllegalArgumentException {
 | 
			
		||||
        //Make sure the yaw is between 0 and 360
 | 
			
		||||
        yaw = normalizeYaw(yaw);
 | 
			
		||||
 | 
			
		||||
@@ -68,8 +71,10 @@ public final class DirectionHelper {
 | 
			
		||||
     *
 | 
			
		||||
     * @param yaw <p>The yaw to convert to a direction vector</p>
 | 
			
		||||
     * @return <p>The direction vector pointing in the same direction as the yaw</p>
 | 
			
		||||
     * @throws IllegalArgumentException <p>If a yaw not divisible by 90 is given</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Vector getDirectionVectorFromYaw(double yaw) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Vector getDirectionVectorFromYaw(double yaw) throws IllegalArgumentException {
 | 
			
		||||
        //Make sure the yaw is between 0 and 360
 | 
			
		||||
        yaw = normalizeYaw(yaw);
 | 
			
		||||
 | 
			
		||||
@@ -99,7 +104,8 @@ public final class DirectionHelper {
 | 
			
		||||
     * @param yaw      <p>The yaw when looking directly outwards from a portal</p>
 | 
			
		||||
     * @return <p>A location relative to the given location</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Location moveLocation(Location location, double right, double down, double out, double yaw) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Location moveLocation(@NotNull Location location, double right, double down, double out, double yaw) {
 | 
			
		||||
        return location.add(getCoordinateVectorFromRelativeVector(right, down, out, yaw));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -111,8 +117,11 @@ public final class DirectionHelper {
 | 
			
		||||
     * @param out   <p>The distance outward from the top-left origin</p>
 | 
			
		||||
     * @param yaw   <p>The yaw when looking directly outwards from a portal</p>
 | 
			
		||||
     * @return <p>A normal vector</p>
 | 
			
		||||
     * @throws IllegalArgumentException <p>If a yaw not divisible by 90 is given</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Vector getCoordinateVectorFromRelativeVector(double right, double down, double out, double yaw) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Vector getCoordinateVectorFromRelativeVector(double right, double down, double out,
 | 
			
		||||
                                                               double yaw) throws IllegalArgumentException {
 | 
			
		||||
        //Make sure the yaw is between 0 and 360
 | 
			
		||||
        yaw = normalizeYaw(yaw);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,8 @@ import net.milkbowl.vault.economy.Economy;
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
import org.bukkit.OfflinePlayer;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
@@ -29,7 +31,7 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param cost           <p>The cost of teleportation</p>
 | 
			
		||||
     * @return <p>False if payment was successful. True if the payment was unsuccessful</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean cannotPayTeleportFee(Portal entrancePortal, Player player, int cost) {
 | 
			
		||||
    public static boolean cannotPayTeleportFee(@NotNull Portal entrancePortal, @NotNull Player player, int cost) {
 | 
			
		||||
        boolean success;
 | 
			
		||||
 | 
			
		||||
        //Try to charge the player. Paying the portal owner is only possible if a UUID is available
 | 
			
		||||
@@ -78,7 +80,7 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param portalOwner <p>The owner of the portal</p>
 | 
			
		||||
     * @param earnings    <p>The amount the owner earned</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void sendObtainMessage(String portalName, Player portalOwner, int earnings) {
 | 
			
		||||
    public static void sendObtainMessage(@NotNull String portalName, @NotNull Player portalOwner, int earnings) {
 | 
			
		||||
        String obtainedMsg = Stargate.getString("ecoObtain");
 | 
			
		||||
        obtainedMsg = replacePlaceholders(obtainedMsg, portalName, earnings);
 | 
			
		||||
        Stargate.getMessageSender().sendSuccessMessage(portalOwner, obtainedMsg);
 | 
			
		||||
@@ -91,7 +93,7 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param player     <p>The interacting player</p>
 | 
			
		||||
     * @param cost       <p>The cost of the interaction</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void sendDeductMessage(String portalName, Player player, int cost) {
 | 
			
		||||
    public static void sendDeductMessage(@NotNull String portalName, @NotNull Player player, int cost) {
 | 
			
		||||
        String deductMsg = Stargate.getString("ecoDeduct");
 | 
			
		||||
        deductMsg = replacePlaceholders(deductMsg, portalName, cost);
 | 
			
		||||
        Stargate.getMessageSender().sendSuccessMessage(player, deductMsg);
 | 
			
		||||
@@ -104,7 +106,7 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param player     <p>The interacting player</p>
 | 
			
		||||
     * @param cost       <p>The cost of the interaction</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void sendInsufficientFundsMessage(String portalName, Player player, int cost) {
 | 
			
		||||
    public static void sendInsufficientFundsMessage(@NotNull String portalName, @NotNull Player player, int cost) {
 | 
			
		||||
        String inFundMsg = Stargate.getString("ecoInFunds");
 | 
			
		||||
        inFundMsg = replacePlaceholders(inFundMsg, portalName, cost);
 | 
			
		||||
        Stargate.getMessageSender().sendErrorMessage(player, inFundMsg);
 | 
			
		||||
@@ -117,7 +119,7 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param player     <p>The player breaking the portal</p>
 | 
			
		||||
     * @param cost       <p>The amount the user has to pay for destroying the portal. (expects a negative value)</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void sendRefundMessage(String portalName, Player player, int cost) {
 | 
			
		||||
    public static void sendRefundMessage(@NotNull String portalName, @NotNull Player player, int cost) {
 | 
			
		||||
        String refundMsg = Stargate.getString("ecoRefund");
 | 
			
		||||
        refundMsg = replacePlaceholders(refundMsg, portalName, -cost);
 | 
			
		||||
        Stargate.getMessageSender().sendSuccessMessage(player, refundMsg);
 | 
			
		||||
@@ -131,7 +133,7 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param destination <p>The destination portal</p>
 | 
			
		||||
     * @return <p>The cost of using the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static int getUseCost(Player player, Portal source, Portal destination) {
 | 
			
		||||
    public static int getUseCost(@NotNull Player player, @NotNull Portal source, @Nullable Portal destination) {
 | 
			
		||||
        EconomyConfig config = Stargate.getEconomyConfig();
 | 
			
		||||
        //No payment required
 | 
			
		||||
        if (!config.useEconomy() || source.getOptions().isFree()) {
 | 
			
		||||
@@ -161,7 +163,7 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param cost   <p>The cost of the transaction</p>
 | 
			
		||||
     * @return <p>True if the player was charged successfully</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean chargePlayerIfNecessary(Player player, UUID target, int cost) {
 | 
			
		||||
    public static boolean chargePlayerIfNecessary(@NotNull Player player, @NotNull UUID target, int cost) {
 | 
			
		||||
        if (skipPayment(cost)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
@@ -176,7 +178,7 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param amount <p>The amount to charge</p>
 | 
			
		||||
     * @return <p>True if the payment succeeded, or if no payment was necessary</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static boolean chargePlayer(Player player, double amount) {
 | 
			
		||||
    private static boolean chargePlayer(@NotNull Player player, double amount) {
 | 
			
		||||
        Economy economy = Stargate.getEconomyConfig().getEconomy();
 | 
			
		||||
        if (Stargate.getEconomyConfig().isEconomyEnabled() && economy != null) {
 | 
			
		||||
            if (!economy.has(player, amount)) {
 | 
			
		||||
@@ -198,7 +200,7 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param cost    <p>The cost to transfer</p>
 | 
			
		||||
     */
 | 
			
		||||
    @SuppressWarnings("deprecation")
 | 
			
		||||
    private static void transferFees(Economy economy, int cost) {
 | 
			
		||||
    private static void transferFees(@NotNull Economy economy, int cost) {
 | 
			
		||||
        String accountName = Stargate.getEconomyConfig().getTaxAccount();
 | 
			
		||||
        if (accountName == null || accountName.isEmpty()) {
 | 
			
		||||
            return;
 | 
			
		||||
@@ -220,7 +222,7 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param cost   <p>The cost of the transaction</p>
 | 
			
		||||
     * @return <p>True if the player was charged successfully</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean chargePlayerIfNecessary(Player player, int cost) {
 | 
			
		||||
    public static boolean chargePlayerIfNecessary(@NotNull Player player, int cost) {
 | 
			
		||||
        if (skipPayment(cost)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
@@ -228,8 +230,9 @@ public final class EconomyHelper {
 | 
			
		||||
        boolean charged = chargePlayer(player, cost);
 | 
			
		||||
 | 
			
		||||
        // Transfer the charged amount to the tax account
 | 
			
		||||
        if (charged) {
 | 
			
		||||
            transferFees(Stargate.getEconomyConfig().getEconomy(), cost);
 | 
			
		||||
        Economy economy = Stargate.getEconomyConfig().getEconomy();
 | 
			
		||||
        if (charged && economy != null) {
 | 
			
		||||
            transferFees(economy, cost);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return charged;
 | 
			
		||||
@@ -253,9 +256,10 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param amount <p>The amount to charge</p>
 | 
			
		||||
     * @return <p>True if the payment succeeded, or if no payment was necessary</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static boolean chargePlayer(Player player, UUID target, double amount) {
 | 
			
		||||
    private static boolean chargePlayer(@NotNull Player player, @NotNull UUID target, double amount) {
 | 
			
		||||
        Economy economy = Stargate.getEconomyConfig().getEconomy();
 | 
			
		||||
        if (Stargate.getEconomyConfig().isEconomyEnabled() && player.getUniqueId().compareTo(target) != 0 && economy != null) {
 | 
			
		||||
        if (Stargate.getEconomyConfig().isEconomyEnabled() && player.getUniqueId().compareTo(target) != 0 &&
 | 
			
		||||
                economy != null) {
 | 
			
		||||
            if (!economy.has(player, amount)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
@@ -274,7 +278,8 @@ public final class EconomyHelper {
 | 
			
		||||
     * @param cost       <p>The cost for a given interaction</p>
 | 
			
		||||
     * @return <p>The same string with cost and portal variables replaced</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static String replacePlaceholders(String message, String portalName, int cost) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private static String replacePlaceholders(@NotNull String message, @NotNull String portalName, int cost) {
 | 
			
		||||
        return StringFormatter.replacePlaceholders(message, new String[]{"%cost%", "%portal%"},
 | 
			
		||||
                new String[]{Stargate.getEconomyConfig().format(cost), portalName});
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package net.knarcraft.stargate.utility;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.entity.Entity;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This helper class helps with entity properties not immediately available
 | 
			
		||||
@@ -21,7 +22,7 @@ public final class EntityHelper {
 | 
			
		||||
     * @param entity <p>The entity to get max size for</p>
 | 
			
		||||
     * @return <p>The max size of the entity</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static int getEntityMaxSizeInt(Entity entity) {
 | 
			
		||||
    public static int getEntityMaxSizeInt(@NotNull Entity entity) {
 | 
			
		||||
        return (int) Math.ceil((float) getEntityMaxSize(entity));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -31,7 +32,7 @@ public final class EntityHelper {
 | 
			
		||||
     * @param entity <p>The entity to get max size for</p>
 | 
			
		||||
     * @return <p>The max size of the entity</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static double getEntityMaxSize(Entity entity) {
 | 
			
		||||
    public static double getEntityMaxSize(@NotNull Entity entity) {
 | 
			
		||||
        return Math.max(entity.getBoundingBox().getWidthX(), entity.getBoundingBox().getWidthZ());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,18 @@
 | 
			
		||||
package net.knarcraft.stargate.utility;
 | 
			
		||||
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.nio.charset.StandardCharsets;
 | 
			
		||||
 | 
			
		||||
public class FileHelper {
 | 
			
		||||
public final class FileHelper {
 | 
			
		||||
 | 
			
		||||
    private FileHelper() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Converts the stream directly into a string, includes the newline character
 | 
			
		||||
@@ -15,7 +21,8 @@ public class FileHelper {
 | 
			
		||||
     * @return <p> A String of the file read </p>
 | 
			
		||||
     * @throws IOException <p>If unable to read the stream</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static String readStreamToString(InputStream stream) throws IOException {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static String readStreamToString(@NotNull InputStream stream) throws IOException {
 | 
			
		||||
        InputStreamReader inputStreamReader = new InputStreamReader(stream, StandardCharsets.UTF_8);
 | 
			
		||||
        BufferedReader reader = new BufferedReader(inputStreamReader);
 | 
			
		||||
        String line = reader.readLine();
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import org.bukkit.Bukkit;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.NamespacedKey;
 | 
			
		||||
import org.bukkit.Tag;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@@ -31,12 +32,12 @@ public final class GateReader {
 | 
			
		||||
     * @param config               <p>The map of config values to store to</p>
 | 
			
		||||
     * @return <p>The column count/width of the loaded gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static int readGateFile(Scanner scanner, Map<Character, Material> characterMaterialMap,
 | 
			
		||||
                                   Map<Character, Tag<Material>> materialTagMap, String fileName,
 | 
			
		||||
                                   List<List<Character>> design, Map<String, String> config) {
 | 
			
		||||
    public static int readGateFile(@NotNull Scanner scanner, @NotNull Map<Character, Material> characterMaterialMap,
 | 
			
		||||
                                   @NotNull Map<Character, Tag<Material>> materialTagMap, @NotNull String fileName,
 | 
			
		||||
                                   @NotNull List<List<Character>> design, Map<String, String> config) {
 | 
			
		||||
        boolean designing = false;
 | 
			
		||||
        int columns = 0;
 | 
			
		||||
        try {
 | 
			
		||||
        try (scanner) {
 | 
			
		||||
            while (scanner.hasNextLine()) {
 | 
			
		||||
                String line = scanner.nextLine();
 | 
			
		||||
 | 
			
		||||
@@ -59,10 +60,6 @@ public final class GateReader {
 | 
			
		||||
        } catch (Exception exception) {
 | 
			
		||||
            Stargate.logSevere(String.format("Could not load Gate %s - %s", fileName, exception.getMessage()));
 | 
			
		||||
            return -1;
 | 
			
		||||
        } finally {
 | 
			
		||||
            if (scanner != null) {
 | 
			
		||||
                scanner.close();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return columns;
 | 
			
		||||
    }
 | 
			
		||||
@@ -81,9 +78,10 @@ public final class GateReader {
 | 
			
		||||
     * @param design               <p>The two-dimensional list to store the loaded design to</p>
 | 
			
		||||
     * @return <p>The new max columns value of the design</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static int readGateDesignLine(String line, int maxColumns, Map<Character, Material> characterMaterialMap,
 | 
			
		||||
                                          Map<Character, Tag<Material>> materialTagMap,
 | 
			
		||||
                                          String fileName, List<List<Character>> design) {
 | 
			
		||||
    private static int readGateDesignLine(@NotNull String line, int maxColumns,
 | 
			
		||||
                                          @NotNull Map<Character, Material> characterMaterialMap,
 | 
			
		||||
                                          @NotNull Map<Character, Tag<Material>> materialTagMap,
 | 
			
		||||
                                          @NotNull String fileName, @NotNull List<List<Character>> design) {
 | 
			
		||||
        List<Character> row = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
        //Update the max columns number if this line has more columns
 | 
			
		||||
@@ -116,9 +114,9 @@ public final class GateReader {
 | 
			
		||||
     * @param config               <p>The config value map to store to</p>
 | 
			
		||||
     * @throws Exception <p>If an invalid material is encountered</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void readGateConfigValue(String line, Map<Character, Material> characterMaterialMap,
 | 
			
		||||
                                            Map<Character, Tag<Material>> materialTagMap,
 | 
			
		||||
                                            Map<String, String> config) throws Exception {
 | 
			
		||||
    private static void readGateConfigValue(@NotNull String line, @NotNull Map<Character, Material> characterMaterialMap,
 | 
			
		||||
                                            @NotNull Map<Character, Tag<Material>> materialTagMap,
 | 
			
		||||
                                            @NotNull Map<String, String> config) throws Exception {
 | 
			
		||||
        String[] split = line.split("=");
 | 
			
		||||
        String key = split[0].trim();
 | 
			
		||||
        String value = split[1].trim();
 | 
			
		||||
@@ -158,12 +156,13 @@ public final class GateReader {
 | 
			
		||||
     * @param key      <p>The config key to read</p>
 | 
			
		||||
     * @return <p>The read value, or -1 if it could not be read</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static int readGateConfig(Map<String, String> config, String fileName, String key) {
 | 
			
		||||
    public static int readGateConfig(@NotNull Map<String, String> config, @NotNull String fileName,
 | 
			
		||||
                                     @NotNull String key) {
 | 
			
		||||
        if (config.containsKey(key)) {
 | 
			
		||||
            try {
 | 
			
		||||
                return Integer.parseInt(config.get(key));
 | 
			
		||||
            } catch (NumberFormatException ex) {
 | 
			
		||||
                Stargate.logWarning(String.format("%s reading %s: %s is not numeric", ex.getClass().getName(),
 | 
			
		||||
            } catch (NumberFormatException exception) {
 | 
			
		||||
                Stargate.logWarning(String.format("%s reading %s: %s is not numeric", exception.getClass().getName(),
 | 
			
		||||
                        fileName, key));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -180,8 +179,9 @@ public final class GateReader {
 | 
			
		||||
     * @param defaultMaterial <p>The default material to use, in case the config is invalid</p>
 | 
			
		||||
     * @return <p>The material specified in the config, or the default material if it could not be read</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Material readGateConfig(Map<String, String> config, String fileName, String key,
 | 
			
		||||
                                          Material defaultMaterial) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Material readGateConfig(@NotNull Map<String, String> config, @NotNull String fileName,
 | 
			
		||||
                                          @NotNull String key, @NotNull Material defaultMaterial) {
 | 
			
		||||
        if (config.containsKey(key)) {
 | 
			
		||||
            Material material = Material.matchMaterial(config.get(key));
 | 
			
		||||
            if (material != null) {
 | 
			
		||||
@@ -203,7 +203,8 @@ public final class GateReader {
 | 
			
		||||
     * @param columns <p>The largest amount of columns in the design</p>
 | 
			
		||||
     * @return <p>A matrix containing the gate's layout</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Character[][] generateLayoutMatrix(List<List<Character>> design, int columns) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Character[][] generateLayoutMatrix(@NotNull List<List<Character>> design, int columns) {
 | 
			
		||||
        Character[][] layout = new Character[design.size()][columns];
 | 
			
		||||
        for (int lineIndex = 0; lineIndex < design.size(); lineIndex++) {
 | 
			
		||||
            List<Character> row = design.get(lineIndex);
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package net.knarcraft.stargate.utility;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.Tag;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class helps decide properties of materials not already present in the Spigot API
 | 
			
		||||
@@ -18,7 +19,7 @@ public final class MaterialHelper {
 | 
			
		||||
     * @param material <p>The material to check</p>
 | 
			
		||||
     * @return <p>True if the material is a wall coral</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean isWallCoral(Material material) {
 | 
			
		||||
    public static boolean isWallCoral(@NotNull Material material) {
 | 
			
		||||
        //Unfortunately, there is no tag for dead wall corals, so they need to be checked manually
 | 
			
		||||
        return Tag.WALL_CORALS.isTagged(material) ||
 | 
			
		||||
                material.equals(Material.DEAD_BRAIN_CORAL_WALL_FAN) ||
 | 
			
		||||
@@ -34,7 +35,7 @@ public final class MaterialHelper {
 | 
			
		||||
     * @param material <p>The material to check</p>
 | 
			
		||||
     * @return <p>True if the material is a container</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean isContainer(Material material) {
 | 
			
		||||
    public static boolean isContainer(@NotNull Material material) {
 | 
			
		||||
        return Tag.SHULKER_BOXES.isTagged(material) || material == Material.CHEST ||
 | 
			
		||||
                material == Material.TRAPPED_CHEST || material == Material.ENDER_CHEST;
 | 
			
		||||
    }
 | 
			
		||||
@@ -45,7 +46,7 @@ public final class MaterialHelper {
 | 
			
		||||
     * @param material <p>The material to check</p>
 | 
			
		||||
     * @return <p>True if the material can be used as a button</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean isButtonCompatible(Material material) {
 | 
			
		||||
    public static boolean isButtonCompatible(@NotNull Material material) {
 | 
			
		||||
        return Tag.BUTTONS.isTagged(material) || isWallCoral(material) || isContainer(material);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,8 @@ import net.knarcraft.stargate.portal.property.PortalOption;
 | 
			
		||||
import net.knarcraft.stargate.portal.teleporter.PlayerTeleporter;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.event.player.PlayerMoveEvent;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import static net.knarcraft.stargate.Stargate.getMaxNameNetworkLength;
 | 
			
		||||
 | 
			
		||||
@@ -25,7 +27,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param player <p>The player opening the portal</p>
 | 
			
		||||
     * @param portal <p>The portal to open</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void openPortal(Player player, Portal portal) {
 | 
			
		||||
    public static void openPortal(@NotNull Player player, @NotNull Portal portal) {
 | 
			
		||||
        Portal destination = portal.getPortalActivator().getDestination();
 | 
			
		||||
 | 
			
		||||
        //For an always open portal, no action is necessary
 | 
			
		||||
@@ -89,7 +91,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param deny   <p>Whether the player's access has already been denied by a previous check</p>
 | 
			
		||||
     * @return <p>False if the player should be allowed through the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean portalAccessDenied(Player player, Portal portal, boolean deny) {
 | 
			
		||||
    public static boolean portalAccessDenied(@NotNull Player player, @NotNull Portal portal, boolean deny) {
 | 
			
		||||
        StargateAccessEvent event = new StargateAccessEvent(player, portal, deny);
 | 
			
		||||
        Stargate.getInstance().getServer().getPluginManager().callEvent(event);
 | 
			
		||||
        return event.getDeny();
 | 
			
		||||
@@ -103,7 +105,8 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param destination    <p>The portal the user wants to exit from</p>
 | 
			
		||||
     * @return <p>False if the user is allowed to access the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean cannotAccessPortal(Player player, Portal entrancePortal, Portal destination) {
 | 
			
		||||
    public static boolean cannotAccessPortal(@NotNull Player player, @NotNull Portal entrancePortal,
 | 
			
		||||
                                             @Nullable Portal destination) {
 | 
			
		||||
        boolean deny = false;
 | 
			
		||||
 | 
			
		||||
        if (entrancePortal.getOptions().isBungee()) {
 | 
			
		||||
@@ -116,10 +119,17 @@ public final class PermissionHelper {
 | 
			
		||||
            //If the player does not have access to the network, deny
 | 
			
		||||
            Stargate.debug("cannotAccessPortal", "Cannot access network");
 | 
			
		||||
            deny = true;
 | 
			
		||||
        } else if (PermissionHelper.cannotAccessWorld(player, destination.getWorld().getName())) {
 | 
			
		||||
            //If the player does not have access to the portal's world, deny
 | 
			
		||||
            Stargate.debug("cannotAccessPortal", "Cannot access world");
 | 
			
		||||
            deny = true;
 | 
			
		||||
        } else {
 | 
			
		||||
            if (destination == null) {
 | 
			
		||||
                //If there is no destination, deny
 | 
			
		||||
                Stargate.debug("cannotAccessPortal", "Portal has no destination");
 | 
			
		||||
                deny = true;
 | 
			
		||||
            } else if (destination.getWorld() != null &&
 | 
			
		||||
                    PermissionHelper.cannotAccessWorld(player, destination.getWorld().getName())) {
 | 
			
		||||
                //If the player does not have access to the portal's world, deny
 | 
			
		||||
                Stargate.debug("cannotAccessPortal", "Cannot access world");
 | 
			
		||||
                deny = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //Allow other plugins to override whether the player can access the portal
 | 
			
		||||
        return portalAccessDenied(player, entrancePortal, deny);
 | 
			
		||||
@@ -134,7 +144,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param permission <p>The permission to check</p>
 | 
			
		||||
     * @return <p>True if the player has the permission</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean hasPermission(Player player, String permission) {
 | 
			
		||||
    public static boolean hasPermission(@NotNull Player player, @NotNull String permission) {
 | 
			
		||||
        if (Stargate.getStargateConfig().isPermissionDebuggingEnabled()) {
 | 
			
		||||
            Stargate.debug("hasPerm::Permission(" + player.getName() + ")", permission + " => " +
 | 
			
		||||
                    player.hasPermission(permission));
 | 
			
		||||
@@ -152,7 +162,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param permission <p>The permission to check</p>
 | 
			
		||||
     * @return <p>True if the player has the permission implicitly or explicitly</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean hasPermissionImplicit(Player player, String permission) {
 | 
			
		||||
    public static boolean hasPermissionImplicit(@NotNull Player player, @NotNull String permission) {
 | 
			
		||||
        if (!player.isPermissionSet(permission)) {
 | 
			
		||||
            if (Stargate.getStargateConfig().isPermissionDebuggingEnabled()) {
 | 
			
		||||
                Stargate.debug("hasPermissionImplicit::Permission", permission + " => implicitly true");
 | 
			
		||||
@@ -173,7 +183,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param world  <p>The world the player is trying to access</p>
 | 
			
		||||
     * @return <p>False if the player should be allowed to access the world</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean cannotAccessWorld(Player player, String world) {
 | 
			
		||||
    public static boolean cannotAccessWorld(@NotNull Player player, @NotNull String world) {
 | 
			
		||||
        //The player can access all worlds
 | 
			
		||||
        if (hasPermission(player, "stargate.world")) {
 | 
			
		||||
            //Check if the world permission has been explicitly denied
 | 
			
		||||
@@ -190,7 +200,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param network <p>The network to check</p>
 | 
			
		||||
     * @return <p>True if the player is denied from accessing the network</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean cannotAccessNetwork(Player player, String network) {
 | 
			
		||||
    public static boolean cannotAccessNetwork(@NotNull Player player, @NotNull String network) {
 | 
			
		||||
        //The player can access all networks
 | 
			
		||||
        if (hasPermission(player, "stargate.network")) {
 | 
			
		||||
            //Check if the world permission has been explicitly denied
 | 
			
		||||
@@ -215,7 +225,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param server <p>The server the player is trying to connect to</p>
 | 
			
		||||
     * @return <p>True if the player is allowed to access the given server</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean canAccessServer(Player player, String server) {
 | 
			
		||||
    public static boolean canAccessServer(@NotNull Player player, @NotNull String server) {
 | 
			
		||||
        //The player can access all servers
 | 
			
		||||
        if (hasPermission(player, "stargate.server")) {
 | 
			
		||||
            //Check if the server permission has been explicitly denied
 | 
			
		||||
@@ -233,7 +243,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param dest   <p>The portal the player wants to teleport to</p>
 | 
			
		||||
     * @return <p>True if the player can travel for free</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean isFree(Player player, Portal src, Portal dest) {
 | 
			
		||||
    public static boolean isFree(@NotNull Player player, @NotNull Portal src, @Nullable Portal dest) {
 | 
			
		||||
        //This portal is free
 | 
			
		||||
        if (src.getOptions().isFree()) {
 | 
			
		||||
            return true;
 | 
			
		||||
@@ -255,7 +265,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param portal <p>The portal to check</p>
 | 
			
		||||
     * @return <p>True if the given player can see the given portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean canSeePortal(Player player, Portal portal) {
 | 
			
		||||
    public static boolean canSeePortal(@NotNull Player player, @NotNull Portal portal) {
 | 
			
		||||
        //The portal is not hidden
 | 
			
		||||
        if (!portal.getOptions().isHidden()) {
 | 
			
		||||
            return true;
 | 
			
		||||
@@ -275,7 +285,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param portal <p>The private portal used</p>
 | 
			
		||||
     * @return <p>True if the player is allowed to use the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean canUsePrivatePortal(Player player, Portal portal) {
 | 
			
		||||
    public static boolean canUsePrivatePortal(@NotNull Player player, @NotNull Portal portal) {
 | 
			
		||||
        //Check if the player is the owner of the gate
 | 
			
		||||
        if (portal.isOwner(player)) {
 | 
			
		||||
            return true;
 | 
			
		||||
@@ -291,7 +301,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param option <p>The option the player is trying to use</p>
 | 
			
		||||
     * @return <p>True if the player is allowed to create a portal with the given option</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean canUseOption(Player player, PortalOption option) {
 | 
			
		||||
    public static boolean canUseOption(@NotNull Player player, @NotNull PortalOption option) {
 | 
			
		||||
        return hasPermission(player, option.getPermissionString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -302,7 +312,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param network <p>The network the player is trying to create a gate on</p>
 | 
			
		||||
     * @return <p>True if the player is allowed to create the new gate</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean canCreateNetworkGate(Player player, String network) {
 | 
			
		||||
    public static boolean canCreateNetworkGate(@NotNull Player player, @NotNull String network) {
 | 
			
		||||
        //Check if the player is allowed to create a portal on any network
 | 
			
		||||
        if (hasPermission(player, "stargate.create.network")) {
 | 
			
		||||
            //Check if the network has been explicitly denied
 | 
			
		||||
@@ -318,7 +328,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param player <p>The player trying to create the new gate</p>
 | 
			
		||||
     * @return <p>True if the player is allowed</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean canCreatePersonalPortal(Player player) {
 | 
			
		||||
    public static boolean canCreatePersonalPortal(@NotNull Player player) {
 | 
			
		||||
        return hasPermission(player, "stargate.create.personal");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -329,7 +339,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param gate   <p>The gate type of the new portal</p>
 | 
			
		||||
     * @return <p>True if the player is allowed to create a portal with the given gate layout</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean canCreatePortal(Player player, String gate) {
 | 
			
		||||
    public static boolean canCreatePortal(@NotNull Player player, @NotNull String gate) {
 | 
			
		||||
        //Check if the player is allowed to create all gates
 | 
			
		||||
        if (hasPermission(player, "stargate.create.gate")) {
 | 
			
		||||
            //Check if the gate type has been explicitly denied
 | 
			
		||||
@@ -346,7 +356,7 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param portal <p>The portal to destroy</p>
 | 
			
		||||
     * @return <p>True if the player is allowed to destroy the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean canDestroyPortal(Player player, Portal portal) {
 | 
			
		||||
    public static boolean canDestroyPortal(@NotNull Player player, @NotNull Portal portal) {
 | 
			
		||||
        String network = portal.getCleanNetwork();
 | 
			
		||||
 | 
			
		||||
        //Use a special check for bungee portals
 | 
			
		||||
@@ -376,7 +386,8 @@ public final class PermissionHelper {
 | 
			
		||||
     * @param event          <p>The move event causing the teleportation</p>
 | 
			
		||||
     * @return <p>True if the player cannot teleport. False otherwise</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean playerCannotTeleport(Portal entrancePortal, Portal destination, Player player, PlayerMoveEvent event) {
 | 
			
		||||
    public static boolean playerCannotTeleport(@Nullable Portal entrancePortal, @Nullable Portal destination,
 | 
			
		||||
                                               @NotNull Player player, @Nullable PlayerMoveEvent event) {
 | 
			
		||||
        //No portal or not open
 | 
			
		||||
        if (entrancePortal == null || !entrancePortal.isOpen()) {
 | 
			
		||||
            return true;
 | 
			
		||||
@@ -392,12 +403,13 @@ public final class PermissionHelper {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //No destination
 | 
			
		||||
        if (!entrancePortal.getOptions().isBungee() && destination == null) {
 | 
			
		||||
        boolean isBungee = entrancePortal.getOptions().isBungee();
 | 
			
		||||
        if (!isBungee && destination == null) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //Player cannot access portal
 | 
			
		||||
        if (PermissionHelper.cannotAccessPortal(player, entrancePortal, destination)) {
 | 
			
		||||
        if (!PermissionHelper.cannotAccessPortal(player, entrancePortal, destination)) {
 | 
			
		||||
            if (!entrancePortal.getOptions().isSilent()) {
 | 
			
		||||
                Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,8 @@ import org.bukkit.block.BlockFace;
 | 
			
		||||
import org.bukkit.block.data.BlockData;
 | 
			
		||||
import org.bukkit.block.data.Directional;
 | 
			
		||||
import org.bukkit.block.data.Waterlogged;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedWriter;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
@@ -43,7 +45,7 @@ public final class PortalFileHelper {
 | 
			
		||||
     *
 | 
			
		||||
     * @param world <p>The world to save portals for</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void saveAllPortals(World world) {
 | 
			
		||||
    public static void saveAllPortals(@NotNull World world) {
 | 
			
		||||
        Stargate.getStargateConfig().addManagedWorld(world.getName());
 | 
			
		||||
        String saveFileLocation = Stargate.getPortalFolder() + "/" + world.getName() + ".db";
 | 
			
		||||
 | 
			
		||||
@@ -52,6 +54,11 @@ public final class PortalFileHelper {
 | 
			
		||||
 | 
			
		||||
            for (Portal portal : PortalRegistry.getAllPortals()) {
 | 
			
		||||
                //Skip portals in other worlds
 | 
			
		||||
                if (portal.getWorld() == null) {
 | 
			
		||||
                    Stargate.logSevere(String.format("Could not save portal %s because its world is null",
 | 
			
		||||
                            portal.getName()));
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                String worldName = portal.getWorld().getName();
 | 
			
		||||
                if (!worldName.equalsIgnoreCase(world.getName())) {
 | 
			
		||||
                    continue;
 | 
			
		||||
@@ -61,8 +68,8 @@ public final class PortalFileHelper {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            bufferedWriter.close();
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            Stargate.logSevere(String.format("Exception while writing stargates to %s: %s", saveFileLocation, e));
 | 
			
		||||
        } catch (Exception exception) {
 | 
			
		||||
            Stargate.logSevere(String.format("Exception while writing stargates to %s: %s", saveFileLocation, exception));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -73,13 +80,13 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param portal         <p>The portal to save</p>
 | 
			
		||||
     * @throws IOException <p>If unable to write to the buffered writer</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void savePortal(BufferedWriter bufferedWriter, Portal portal) throws IOException {
 | 
			
		||||
    private static void savePortal(@NotNull BufferedWriter bufferedWriter, @NotNull Portal portal) throws IOException {
 | 
			
		||||
        StringBuilder builder = new StringBuilder();
 | 
			
		||||
        BlockLocation button = portal.getStructure().getButton();
 | 
			
		||||
 | 
			
		||||
        //WARNING: Because of the primitive save format, any change in order will break everything!
 | 
			
		||||
        builder.append(portal.getName()).append(':');
 | 
			
		||||
        builder.append(portal.getSignLocation().toString()).append(':');
 | 
			
		||||
        builder.append(portal.getSignLocation()).append(':');
 | 
			
		||||
        builder.append((button != null) ? button.toString() : "").append(':');
 | 
			
		||||
 | 
			
		||||
        //Add removes config values to keep indices consistent
 | 
			
		||||
@@ -87,7 +94,7 @@ public final class PortalFileHelper {
 | 
			
		||||
        builder.append(0).append(':');
 | 
			
		||||
 | 
			
		||||
        builder.append(portal.getYaw()).append(':');
 | 
			
		||||
        builder.append(portal.getTopLeft().toString()).append(':');
 | 
			
		||||
        builder.append(portal.getTopLeft()).append(':');
 | 
			
		||||
        builder.append(portal.getGate().getFilename()).append(':');
 | 
			
		||||
 | 
			
		||||
        //Only save the destination name if the gate is fixed as it doesn't matter otherwise
 | 
			
		||||
@@ -111,13 +118,17 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param portal  <p>The portal to save</p>
 | 
			
		||||
     * @param builder <p>The string builder to append to</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void savePortalOptions(Portal portal, StringBuilder builder) {
 | 
			
		||||
    private static void savePortalOptions(@NotNull Portal portal, @NotNull StringBuilder builder) {
 | 
			
		||||
        PortalOptions options = portal.getOptions();
 | 
			
		||||
        builder.append(':');
 | 
			
		||||
        builder.append(options.isHidden()).append(':');
 | 
			
		||||
        builder.append(options.isAlwaysOn()).append(':');
 | 
			
		||||
        builder.append(options.isPrivate()).append(':');
 | 
			
		||||
        builder.append(portal.getWorld().getName()).append(':');
 | 
			
		||||
        if (portal.getWorld() != null) {
 | 
			
		||||
            builder.append(portal.getWorld().getName()).append(':');
 | 
			
		||||
        } else {
 | 
			
		||||
            builder.append(':');
 | 
			
		||||
        }
 | 
			
		||||
        builder.append(options.isFree()).append(':');
 | 
			
		||||
        builder.append(options.isBackwards()).append(':');
 | 
			
		||||
        builder.append(options.isShown()).append(':');
 | 
			
		||||
@@ -134,7 +145,7 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param world <p>The world to load portals for</p>
 | 
			
		||||
     * @return <p>True if portals could be loaded</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean loadAllPortals(World world) {
 | 
			
		||||
    public static boolean loadAllPortals(@NotNull World world) {
 | 
			
		||||
        String location = Stargate.getPortalFolder();
 | 
			
		||||
 | 
			
		||||
        File database = new File(location, world.getName() + ".db");
 | 
			
		||||
@@ -154,7 +165,7 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param database <p>The database file containing the portals</p>
 | 
			
		||||
     * @return <p>True if the portals were loaded successfully</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static boolean loadPortals(World world, File database) {
 | 
			
		||||
    private static boolean loadPortals(@NotNull World world, @NotNull File database) {
 | 
			
		||||
        int lineIndex = 0;
 | 
			
		||||
        try {
 | 
			
		||||
            Scanner scanner = new Scanner(database);
 | 
			
		||||
@@ -185,7 +196,7 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param world     <p>The world for which portals are currently being read</p>
 | 
			
		||||
     * @return <p>True if the read portal has changed and the world's database needs to be saved</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static boolean readPortalLine(Scanner scanner, int lineIndex, World world) {
 | 
			
		||||
    private static boolean readPortalLine(@NotNull Scanner scanner, int lineIndex, @NotNull World world) {
 | 
			
		||||
        String line = scanner.nextLine().trim();
 | 
			
		||||
 | 
			
		||||
        //Ignore empty and comment lines
 | 
			
		||||
@@ -213,7 +224,7 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param world               <p>The world portals have been loaded for</p>
 | 
			
		||||
     * @param needsToSaveDatabase <p>Whether the portal database's file needs to be updated</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void doPostLoadTasks(World world, boolean needsToSaveDatabase) {
 | 
			
		||||
    private static void doPostLoadTasks(@NotNull World world, boolean needsToSaveDatabase) {
 | 
			
		||||
        //Open any always-on portals. Do this here as it should be more efficient than in the loop.
 | 
			
		||||
        PortalHandler.verifyAllPortals();
 | 
			
		||||
        int portalCount = PortalRegistry.getAllPortals().size();
 | 
			
		||||
@@ -245,7 +256,7 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param lineIndex  <p>The line index to report in case the user needs to fix an error</p>
 | 
			
		||||
     * @return <p>True if the portal's data has changed and its database needs to be updated</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static boolean loadPortal(String[] portalData, World world, int lineIndex) {
 | 
			
		||||
    private static boolean loadPortal(@NotNull String[] portalData, @NotNull World world, int lineIndex) {
 | 
			
		||||
        //Load min. required portal data
 | 
			
		||||
        String name = portalData[0];
 | 
			
		||||
        BlockLocation button = (portalData[2].length() > 0) ? new BlockLocation(world, portalData[2]) : null;
 | 
			
		||||
@@ -289,17 +300,21 @@ public final class PortalFileHelper {
 | 
			
		||||
     *
 | 
			
		||||
     * @param portal <p>The portal update the button of</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void updatePortalButton(Portal portal) {
 | 
			
		||||
    private static void updatePortalButton(@NotNull Portal portal) {
 | 
			
		||||
        BlockLocation buttonLocation = getButtonLocation(portal);
 | 
			
		||||
        if (buttonLocation == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (portal.getOptions().isAlwaysOn()) {
 | 
			
		||||
            //Clear button if not already air or water
 | 
			
		||||
            //Clear button if it exists
 | 
			
		||||
            if (MaterialHelper.isButtonCompatible(buttonLocation.getType())) {
 | 
			
		||||
                Material newMaterial = decideRemovalMaterial(buttonLocation, portal);
 | 
			
		||||
                Stargate.addBlockChangeRequest(new BlockChangeRequest(buttonLocation, newMaterial, null));
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            //Replace button if the material does not match
 | 
			
		||||
            if (buttonLocation.getType() != portal.getGate().getPortalButton()) {
 | 
			
		||||
            //Replace button if the material is not a button
 | 
			
		||||
            if (!MaterialHelper.isButtonCompatible(buttonLocation.getType())) {
 | 
			
		||||
                generatePortalButton(portal, DirectionHelper.getBlockFaceFromYaw(portal.getYaw()));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -312,7 +327,8 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param portal   <p>The portal the button/sign belongs to</p>
 | 
			
		||||
     * @return <p>The material to use for removing the button/sign</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static Material decideRemovalMaterial(BlockLocation location, Portal portal) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Material decideRemovalMaterial(@NotNull BlockLocation location, @NotNull Portal portal) {
 | 
			
		||||
        //Get the blocks to each side of the location
 | 
			
		||||
        Location leftLocation = location.getRelativeLocation(-1, 0, 0, portal.getYaw());
 | 
			
		||||
        Location rightLocation = location.getRelativeLocation(1, 0, 0, portal.getYaw());
 | 
			
		||||
@@ -333,7 +349,7 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param location <p>The location to check</p>
 | 
			
		||||
     * @return <p>True if the location is underwater</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static boolean isUnderwater(Location location) {
 | 
			
		||||
    private static boolean isUnderwater(@NotNull Location location) {
 | 
			
		||||
        BlockData blockData = location.getBlock().getBlockData();
 | 
			
		||||
        return blockData.getMaterial() == Material.WATER ||
 | 
			
		||||
                (blockData instanceof Waterlogged waterlogged && waterlogged.isWaterlogged());
 | 
			
		||||
@@ -348,7 +364,7 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param portal <p>The portal to update the button vector for</p>
 | 
			
		||||
     * @return <p>True if the calculated button location is not the same as the one in the portal file</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static boolean updateButtonVector(Portal portal) {
 | 
			
		||||
    private static boolean updateButtonVector(@NotNull Portal portal) {
 | 
			
		||||
        for (RelativeBlockVector control : portal.getGate().getLayout().getControls()) {
 | 
			
		||||
            BlockLocation controlLocation = portal.getLocation().getTopLeft().getRelativeLocation(control,
 | 
			
		||||
                    portal.getYaw());
 | 
			
		||||
@@ -374,10 +390,15 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param portal       <p>The portal to generate button for</p>
 | 
			
		||||
     * @param buttonFacing <p>The direction the button should be facing</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void generatePortalButton(Portal portal, BlockFace buttonFacing) {
 | 
			
		||||
    public static void generatePortalButton(@NotNull Portal portal, @NotNull BlockFace buttonFacing) {
 | 
			
		||||
        //Go one block outwards to find the button's location rather than the control block's location
 | 
			
		||||
        BlockLocation button = getButtonLocation(portal);
 | 
			
		||||
 | 
			
		||||
        // If the button location is null here, it is assumed that the button generation wasn't necessary
 | 
			
		||||
        if (button == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Directional buttonData = (Directional) Bukkit.createBlockData(portal.getGate().getPortalButton());
 | 
			
		||||
        buttonData.setFacing(buttonFacing);
 | 
			
		||||
        button.getBlock().setBlockData(buttonData);
 | 
			
		||||
@@ -390,11 +411,16 @@ public final class PortalFileHelper {
 | 
			
		||||
     * @param portal <p>The portal to find the button for</p>
 | 
			
		||||
     * @return <p>The location of the portal's button</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static BlockLocation getButtonLocation(Portal portal) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    private static BlockLocation getButtonLocation(@NotNull Portal portal) {
 | 
			
		||||
        BlockLocation topLeft = portal.getTopLeft();
 | 
			
		||||
        RelativeBlockVector buttonVector = portal.getLocation().getButtonVector();
 | 
			
		||||
        return topLeft.getRelativeLocation(buttonVector.addToVector(RelativeBlockVector.Property.OUT, 1),
 | 
			
		||||
                portal.getYaw());
 | 
			
		||||
 | 
			
		||||
        if (buttonVector == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return topLeft.getRelativeLocation(buttonVector.addOut(1), portal.getYaw());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,8 @@ package net.knarcraft.stargate.utility;
 | 
			
		||||
import org.bukkit.DyeColor;
 | 
			
		||||
import org.bukkit.block.Sign;
 | 
			
		||||
import org.bukkit.block.sign.Side;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A helper class for dealing with signs
 | 
			
		||||
@@ -21,7 +23,8 @@ public final class SignHelper {
 | 
			
		||||
     * @param sign <p>The sign to check</p>
 | 
			
		||||
     * @return <p>The dye currently applied to the sign</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static DyeColor getDye(Sign sign) {
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static DyeColor getDye(@NotNull Sign sign) {
 | 
			
		||||
        if (HAS_SIGN_SIDES) {
 | 
			
		||||
            return sign.getSide(Side.FRONT).getColor();
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -38,7 +41,7 @@ public final class SignHelper {
 | 
			
		||||
     * @param line <p>The line to set</p>
 | 
			
		||||
     * @param text <p>The text to set</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void setSignLine(Sign sign, int line, String text) {
 | 
			
		||||
    public static void setSignLine(@NotNull Sign sign, int line, @NotNull String text) {
 | 
			
		||||
        if (HAS_SIGN_SIDES) {
 | 
			
		||||
            sign.getSide(Side.FRONT).setLine(line, text);
 | 
			
		||||
        } else {
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.scheduler.BukkitScheduler;
 | 
			
		||||
import org.bukkit.util.Vector;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@@ -31,7 +32,7 @@ public final class TeleportHelper {
 | 
			
		||||
     * @param player <p>The player trying to teleport</p>
 | 
			
		||||
     * @return <p>False if the player has leashed any creatures that cannot go through the portal</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean noLeashedCreaturesPreventTeleportation(Player player) {
 | 
			
		||||
    public static boolean noLeashedCreaturesPreventTeleportation(@NotNull Player player) {
 | 
			
		||||
        //Find any nearby leashed entities to teleport with the player
 | 
			
		||||
        List<Creature> nearbyCreatures = getLeashedCreatures(player);
 | 
			
		||||
 | 
			
		||||
@@ -56,7 +57,8 @@ public final class TeleportHelper {
 | 
			
		||||
     * @param player <p>The player to check</p>
 | 
			
		||||
     * @return <p>A list of all creatures the player is holding in a leash (lead)</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static List<Creature> getLeashedCreatures(Player player) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static List<Creature> getLeashedCreatures(@NotNull Player player) {
 | 
			
		||||
        List<Creature> leashedCreatures = new ArrayList<>();
 | 
			
		||||
        //Find any nearby leashed entities to teleport with the player
 | 
			
		||||
        List<Entity> nearbyEntities = player.getNearbyEntities(15, 15, 15);
 | 
			
		||||
@@ -80,8 +82,8 @@ public final class TeleportHelper {
 | 
			
		||||
     * @param exitDirection <p>The direction of any passengers exiting the stargate</p>
 | 
			
		||||
     * @param newVelocity   <p>The new velocity of the teleported passenger</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void teleportAndAddPassenger(Entity targetVehicle, Entity passenger, Vector exitDirection,
 | 
			
		||||
                                               Vector newVelocity) {
 | 
			
		||||
    public static void teleportAndAddPassenger(@NotNull Entity targetVehicle, @NotNull Entity passenger,
 | 
			
		||||
                                               @NotNull Vector exitDirection, @NotNull Vector newVelocity) {
 | 
			
		||||
        Location passengerExit = targetVehicle.getLocation().clone().setDirection(exitDirection);
 | 
			
		||||
        if (!passenger.teleport(passengerExit)) {
 | 
			
		||||
            Stargate.debug("TeleportHelper::handleVehiclePassengers", "Failed to teleport passenger" +
 | 
			
		||||
@@ -112,8 +114,9 @@ public final class TeleportHelper {
 | 
			
		||||
     * @param exitRotation <p>The rotation of any passengers exiting the stargate</p>
 | 
			
		||||
     * @param newVelocity  <p>The new velocity of the teleported passengers</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void handleEntityPassengers(List<Entity> passengers, Entity entity, Portal origin, Portal target,
 | 
			
		||||
                                              Vector exitRotation, Vector newVelocity) {
 | 
			
		||||
    public static void handleEntityPassengers(@NotNull List<Entity> passengers, @NotNull Entity entity,
 | 
			
		||||
                                              @NotNull Portal origin, @NotNull Portal target,
 | 
			
		||||
                                              @NotNull Vector exitRotation, @NotNull Vector newVelocity) {
 | 
			
		||||
        for (Entity passenger : passengers) {
 | 
			
		||||
            List<Entity> passengerPassengers = passenger.getPassengers();
 | 
			
		||||
            if (!passengerPassengers.isEmpty()) {
 | 
			
		||||
@@ -144,7 +147,7 @@ public final class TeleportHelper {
 | 
			
		||||
     * @param origin <p>The portal the player is teleporting from</p>
 | 
			
		||||
     * @param target <p>The portal the player is teleporting to</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void teleportLeashedCreatures(Player player, Portal origin, Portal target) {
 | 
			
		||||
    public static void teleportLeashedCreatures(@NotNull Player player, @NotNull Portal origin, @NotNull Portal target) {
 | 
			
		||||
        //If this feature is disabled, just return
 | 
			
		||||
        if (!Stargate.getGateConfig().handleLeashedCreatures()) {
 | 
			
		||||
            return;
 | 
			
		||||
@@ -171,7 +174,7 @@ public final class TeleportHelper {
 | 
			
		||||
     * @param entities <p>The list of entities to check</p>
 | 
			
		||||
     * @return <p>True if at least one entity is not a player</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean containsNonPlayer(List<Entity> entities) {
 | 
			
		||||
    public static boolean containsNonPlayer(@NotNull List<Entity> entities) {
 | 
			
		||||
        for (Entity entity : entities) {
 | 
			
		||||
            if (!(entity instanceof Player) || containsNonPlayer(entity.getPassengers())) {
 | 
			
		||||
                return true;
 | 
			
		||||
@@ -186,7 +189,7 @@ public final class TeleportHelper {
 | 
			
		||||
     * @param entities <p>The list of entities to check</p>
 | 
			
		||||
     * @return <p>True if at least one player is present among the passengers</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean containsPlayer(List<Entity> entities) {
 | 
			
		||||
    public static boolean containsPlayer(@NotNull List<Entity> entities) {
 | 
			
		||||
        for (Entity entity : entities) {
 | 
			
		||||
            if (entity instanceof Player || containsPlayer(entity.getPassengers())) {
 | 
			
		||||
                return true;
 | 
			
		||||
@@ -201,7 +204,8 @@ public final class TeleportHelper {
 | 
			
		||||
     * @param entities <p>The entities to check for players</p>
 | 
			
		||||
     * @return <p>The found players</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static List<Player> getPlayers(List<Entity> entities) {
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static List<Player> getPlayers(@NotNull List<Entity> entities) {
 | 
			
		||||
        List<Player> players = new ArrayList<>(5);
 | 
			
		||||
        for (Entity entity : entities) {
 | 
			
		||||
            if (entity instanceof Player) {
 | 
			
		||||
@@ -220,7 +224,8 @@ public final class TeleportHelper {
 | 
			
		||||
     * @param destinationPortal <p>The portal the player is to exit from</p>
 | 
			
		||||
     * @return <p>True if the player is allowed to teleport and is able to pay necessary fees</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean playerCanTeleport(Player player, Portal entrancePortal, Portal destinationPortal) {
 | 
			
		||||
    public static boolean playerCanTeleport(@NotNull Player player, @NotNull Portal entrancePortal,
 | 
			
		||||
                                            @NotNull Portal destinationPortal) {
 | 
			
		||||
        //Make sure the user can access the portal
 | 
			
		||||
        if (PermissionHelper.cannotAccessPortal(player, entrancePortal, destinationPortal)) {
 | 
			
		||||
            if (!entrancePortal.getOptions().isSilent()) {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ import net.knarcraft.stargate.portal.PortalRegistry;
 | 
			
		||||
import net.knarcraft.stargate.portal.property.PortalOwner;
 | 
			
		||||
import org.bukkit.OfflinePlayer;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
@@ -35,7 +36,7 @@ public final class UUIDMigrationHelper {
 | 
			
		||||
     *
 | 
			
		||||
     * @param player <p>The player to migrate</p>
 | 
			
		||||
     */
 | 
			
		||||
    public static void migrateUUID(OfflinePlayer player) {
 | 
			
		||||
    public static void migrateUUID(@NotNull OfflinePlayer player) {
 | 
			
		||||
        Map<String, List<Portal>> playersToMigrate = getPlayersToMigrate();
 | 
			
		||||
        String playerName = player.getName();
 | 
			
		||||
 | 
			
		||||
@@ -53,7 +54,7 @@ public final class UUIDMigrationHelper {
 | 
			
		||||
 | 
			
		||||
        migratePortalsToUUID(portalsOwned, player.getUniqueId());
 | 
			
		||||
 | 
			
		||||
        //Remove the player to prevent the migration to happen every time the player joins
 | 
			
		||||
        //Remove the player to prevent the migration from happening every time the player joins
 | 
			
		||||
        playersToMigrate.remove(playerName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -63,7 +64,7 @@ public final class UUIDMigrationHelper {
 | 
			
		||||
     * @param portals  <p>The portals to migrate</p>
 | 
			
		||||
     * @param uniqueId <p>The unique ID of the portals' owner</p>
 | 
			
		||||
     */
 | 
			
		||||
    private static void migratePortalsToUUID(List<Portal> portals, UUID uniqueId) {
 | 
			
		||||
    private static void migratePortalsToUUID(@NotNull List<Portal> portals, @NotNull UUID uniqueId) {
 | 
			
		||||
        Set<World> worldsToSave = new HashSet<>();
 | 
			
		||||
 | 
			
		||||
        //Get the real portal from the copy and set UUID
 | 
			
		||||
@@ -86,6 +87,7 @@ public final class UUIDMigrationHelper {
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>The player names to migrate</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private static Map<String, List<Portal>> getPlayersToMigrate() {
 | 
			
		||||
        //Make sure to only go through portals once
 | 
			
		||||
        if (playerNamesToMigrate != null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -11,9 +11,9 @@ public class RelativeBlockVectorTest {
 | 
			
		||||
    @Test
 | 
			
		||||
    public void getTest() {
 | 
			
		||||
        RelativeBlockVector relativeBlockVector = new RelativeBlockVector(56, 44, 23);
 | 
			
		||||
        assertEquals(56, relativeBlockVector.getRight());
 | 
			
		||||
        assertEquals(44, relativeBlockVector.getDown());
 | 
			
		||||
        assertEquals(23, relativeBlockVector.getOut());
 | 
			
		||||
        assertEquals(56, relativeBlockVector.right());
 | 
			
		||||
        assertEquals(44, relativeBlockVector.down());
 | 
			
		||||
        assertEquals(23, relativeBlockVector.out());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
 
 | 
			
		||||
@@ -15,13 +15,13 @@ public class RelativeBlockVectorTest {
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < 1000; i++) {
 | 
			
		||||
            int randomValue = getRandomNumber();
 | 
			
		||||
            RelativeBlockVector newVector = relativeBlockVector.addToVector(RelativeBlockVector.Property.RIGHT, randomValue);
 | 
			
		||||
            RelativeBlockVector newVector = relativeBlockVector.addRight(randomValue);
 | 
			
		||||
            Assertions.assertEquals(new RelativeBlockVector(right + randomValue, down, out), newVector);
 | 
			
		||||
 | 
			
		||||
            newVector = relativeBlockVector.addToVector(RelativeBlockVector.Property.OUT, randomValue);
 | 
			
		||||
            newVector = relativeBlockVector.addOut(randomValue);
 | 
			
		||||
            Assertions.assertEquals(new RelativeBlockVector(right, down, out + randomValue), newVector);
 | 
			
		||||
 | 
			
		||||
            newVector = relativeBlockVector.addToVector(RelativeBlockVector.Property.DOWN, randomValue);
 | 
			
		||||
            newVector = relativeBlockVector.addDown(randomValue);
 | 
			
		||||
            Assertions.assertEquals(new RelativeBlockVector(right, down + randomValue, out), newVector);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import be.seeseemelk.mockbukkit.ServerMock;
 | 
			
		||||
import be.seeseemelk.mockbukkit.WorldMock;
 | 
			
		||||
import net.knarcraft.stargate.Stargate;
 | 
			
		||||
import net.knarcraft.stargate.container.RelativeBlockVector;
 | 
			
		||||
import net.knarcraft.stargate.portal.property.gate.Gate;
 | 
			
		||||
import net.knarcraft.stargate.portal.property.gate.GateHandler;
 | 
			
		||||
import net.knarcraft.stargate.portal.property.gate.GateLayout;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
@@ -28,7 +29,12 @@ public class GateLayoutTest {
 | 
			
		||||
        server.addWorld(new WorldMock(Material.DIRT, 5));
 | 
			
		||||
        System.setProperty("bstats.relocatecheck", "false");
 | 
			
		||||
        MockBukkit.load(Stargate.class);
 | 
			
		||||
        layout = GateHandler.getGateByName("nethergate.gate").getLayout();
 | 
			
		||||
        Gate gate = GateHandler.getGateByName("nethergate.gate");
 | 
			
		||||
        if (gate != null) {
 | 
			
		||||
            layout = gate.getLayout();
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new IllegalStateException("Could not set up tests, because nethergate.gate is unavailable");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @AfterAll
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user