diff --git a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java index d1f489f3..c3de72c4 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java @@ -114,7 +114,7 @@ public class ConfigRepositoryImpl implements ConfigRepository { public void loadConfig(DataStorage dataStorage) { this.dataStorage = dataStorage; this.config = dataStorage.loadFile(Config.class, "config.yaml"); - if(config == null) { + if (config == null) { this.config = new Config(); } } diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java index 196182e8..ba3e1aa7 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java @@ -15,7 +15,6 @@ import com.sekwah.advancedportals.spigot.connector.container.SpigotServerContain import com.sekwah.advancedportals.spigot.importer.LegacyImporter; import com.sekwah.advancedportals.spigot.metrics.Metrics; import com.sekwah.advancedportals.spigot.warpeffects.SpigotWarpEffects; - import java.io.File; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -97,7 +96,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin { File destiFolder = new File(this.getDataFolder(), "desti"); if (destiFile.exists() && !destiFolder.exists()) { destiFolder.mkdirs(); - getLogger().info("Importing old destinations from destinations.yaml"); + getLogger().info( + "Importing old destinations from destinations.yaml"); LegacyImporter.importDestinations(this.destinationServices); } diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java index 61e5168e..f8c4b874 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java @@ -10,12 +10,10 @@ import com.sekwah.advancedportals.shadowed.inject.Inject; import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; import com.sekwah.advancedportals.spigot.importer.ConfigAccessor; import com.sekwah.advancedportals.spigot.importer.LegacyImporter; - import java.util.List; import java.util.Set; public class ImportPortalSubCommand implements SubCommand { - @Inject DestinationServices destinationServices; @@ -28,7 +26,8 @@ public class ImportPortalSubCommand implements SubCommand { sender.sendMessage(Lang.getPositivePrefix() + Lang.translateInsertVariables( "command.portal.import.confirm")); - int destinations = LegacyImporter.importDestinations(destinationServices); + int destinations = + LegacyImporter.importDestinations(destinationServices); int portals = LegacyImporter.importPortals(portalServices); sender.sendMessage( Lang.getPositivePrefix() diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/importer/LegacyImporter.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/importer/LegacyImporter.java index 73435c17..f7ec89fc 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/importer/LegacyImporter.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/importer/LegacyImporter.java @@ -6,35 +6,33 @@ import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; -import org.bukkit.configuration.ConfigurationSection; - import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.bukkit.configuration.ConfigurationSection; public class LegacyImporter { - private LegacyImporter() { } public static int importPortals(PortalServices portalServices) { ConfigAccessor portalConfig = new ConfigAccessor( - AdvancedPortalsPlugin.getInstance(), "portals.yml"); + AdvancedPortalsPlugin.getInstance(), "portals.yml"); var config = portalConfig.getConfig(); Set portalSet = config.getKeys(false); int count = 0; for (String portalName : portalSet) { BlockLocation pos1 = - new BlockLocation(config.getString(portalName + ".world"), - config.getInt(portalName + ".pos1.X"), - config.getInt(portalName + ".pos1.Y"), - config.getInt(portalName + ".pos1.Z")); + new BlockLocation(config.getString(portalName + ".world"), + config.getInt(portalName + ".pos1.X"), + config.getInt(portalName + ".pos1.Y"), + config.getInt(portalName + ".pos1.Z")); BlockLocation pos2 = - new BlockLocation(config.getString(portalName + ".world"), - config.getInt(portalName + ".pos2.X"), - config.getInt(portalName + ".pos2.Y"), - config.getInt(portalName + ".pos2.Z")); + new BlockLocation(config.getString(portalName + ".world"), + config.getInt(portalName + ".pos2.X"), + config.getInt(portalName + ".pos2.Y"), + config.getInt(portalName + ".pos2.Z")); List args = new ArrayList<>(); args.add(new DataTag("name", portalName)); var triggerblock = config.getString(portalName + ".triggerblock"); @@ -56,9 +54,9 @@ public class LegacyImporter { } ConfigurationSection portalConfigSection = - config.getConfigurationSection(portalName); + config.getConfigurationSection(portalName); ConfigurationSection portalArgsConf = - portalConfigSection.getConfigurationSection("portalArgs"); + portalConfigSection.getConfigurationSection("portalArgs"); if (portalArgsConf != null) { Set argsSet = portalArgsConf.getKeys(true); @@ -66,8 +64,8 @@ public class LegacyImporter { // skip if it argName starts with command. if (portalArgsConf.isString(argName.toString())) { args.add(new DataTag( - argName.toString(), - portalArgsConf.getString(argName.toString()))); + argName.toString(), + portalArgsConf.getString(argName.toString()))); } } } @@ -82,12 +80,12 @@ public class LegacyImporter { } if (!commands.isEmpty()) { args.add( - new DataTag("commands", commands.toArray(new String[0]))); + new DataTag("commands", commands.toArray(new String[0]))); } args.stream() - .filter(dataTag -> dataTag.NAME.startsWith("command.")) - .toList() - .forEach(args::remove); + .filter(dataTag -> dataTag.NAME.startsWith("command.")) + .toList() + .forEach(args::remove); // Find an arg called "delayed" and add a new one called portalEvent var delayed = getArg(args, "delayed"); @@ -105,9 +103,10 @@ public class LegacyImporter { return count; } - public static int importDestinations(DestinationServices destinationServices) { + public static int importDestinations( + DestinationServices destinationServices) { ConfigAccessor destiConfig = new ConfigAccessor( - AdvancedPortalsPlugin.getInstance(), "destinations.yml"); + AdvancedPortalsPlugin.getInstance(), "destinations.yml"); var config = destiConfig.getConfig(); Set destiSet = config.getKeys(false); @@ -115,14 +114,14 @@ public class LegacyImporter { for (String destiName : destiSet) { var destiPos = destiName + ".pos"; var desti = destinationServices.createDesti( - new PlayerLocation( - config.getString(destiName + ".world"), - config.getDouble(destiPos + ".X"), - config.getDouble(destiPos + ".Y"), - config.getDouble(destiPos + ".Z"), - (float) config.getDouble(destiPos + ".yaw"), - (float) config.getDouble(destiPos + ".pitch")), - List.of(new DataTag("name", destiName))); + new PlayerLocation( + config.getString(destiName + ".world"), + config.getDouble(destiPos + ".X"), + config.getDouble(destiPos + ".Y"), + config.getDouble(destiPos + ".Z"), + (float) config.getDouble(destiPos + ".yaw"), + (float) config.getDouble(destiPos + ".pitch")), + List.of(new DataTag("name", destiName))); if (desti != null) count++; } @@ -137,5 +136,4 @@ public class LegacyImporter { } return null; } - }