mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-25 12:06:17 +01:00
chore: pre-commit changes [skip ci]
This commit is contained in:
parent
9f23a617ff
commit
ce1715436e
@ -114,7 +114,7 @@ public class ConfigRepositoryImpl implements ConfigRepository {
|
|||||||
public void loadConfig(DataStorage dataStorage) {
|
public void loadConfig(DataStorage dataStorage) {
|
||||||
this.dataStorage = dataStorage;
|
this.dataStorage = dataStorage;
|
||||||
this.config = dataStorage.loadFile(Config.class, "config.yaml");
|
this.config = dataStorage.loadFile(Config.class, "config.yaml");
|
||||||
if(config == null) {
|
if (config == null) {
|
||||||
this.config = new Config();
|
this.config = new Config();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import com.sekwah.advancedportals.spigot.connector.container.SpigotServerContain
|
|||||||
import com.sekwah.advancedportals.spigot.importer.LegacyImporter;
|
import com.sekwah.advancedportals.spigot.importer.LegacyImporter;
|
||||||
import com.sekwah.advancedportals.spigot.metrics.Metrics;
|
import com.sekwah.advancedportals.spigot.metrics.Metrics;
|
||||||
import com.sekwah.advancedportals.spigot.warpeffects.SpigotWarpEffects;
|
import com.sekwah.advancedportals.spigot.warpeffects.SpigotWarpEffects;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -97,7 +96,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
|||||||
File destiFolder = new File(this.getDataFolder(), "desti");
|
File destiFolder = new File(this.getDataFolder(), "desti");
|
||||||
if (destiFile.exists() && !destiFolder.exists()) {
|
if (destiFile.exists() && !destiFolder.exists()) {
|
||||||
destiFolder.mkdirs();
|
destiFolder.mkdirs();
|
||||||
getLogger().info("Importing old destinations from destinations.yaml");
|
getLogger().info(
|
||||||
|
"Importing old destinations from destinations.yaml");
|
||||||
LegacyImporter.importDestinations(this.destinationServices);
|
LegacyImporter.importDestinations(this.destinationServices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,12 +10,10 @@ import com.sekwah.advancedportals.shadowed.inject.Inject;
|
|||||||
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.spigot.importer.ConfigAccessor;
|
import com.sekwah.advancedportals.spigot.importer.ConfigAccessor;
|
||||||
import com.sekwah.advancedportals.spigot.importer.LegacyImporter;
|
import com.sekwah.advancedportals.spigot.importer.LegacyImporter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ImportPortalSubCommand implements SubCommand {
|
public class ImportPortalSubCommand implements SubCommand {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DestinationServices destinationServices;
|
DestinationServices destinationServices;
|
||||||
|
|
||||||
@ -28,7 +26,8 @@ public class ImportPortalSubCommand implements SubCommand {
|
|||||||
sender.sendMessage(Lang.getPositivePrefix()
|
sender.sendMessage(Lang.getPositivePrefix()
|
||||||
+ Lang.translateInsertVariables(
|
+ Lang.translateInsertVariables(
|
||||||
"command.portal.import.confirm"));
|
"command.portal.import.confirm"));
|
||||||
int destinations = LegacyImporter.importDestinations(destinationServices);
|
int destinations =
|
||||||
|
LegacyImporter.importDestinations(destinationServices);
|
||||||
int portals = LegacyImporter.importPortals(portalServices);
|
int portals = LegacyImporter.importPortals(portalServices);
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
Lang.getPositivePrefix()
|
Lang.getPositivePrefix()
|
||||||
|
@ -6,35 +6,33 @@ import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
|
|||||||
import com.sekwah.advancedportals.core.services.DestinationServices;
|
import com.sekwah.advancedportals.core.services.DestinationServices;
|
||||||
import com.sekwah.advancedportals.core.services.PortalServices;
|
import com.sekwah.advancedportals.core.services.PortalServices;
|
||||||
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
public class LegacyImporter {
|
public class LegacyImporter {
|
||||||
|
|
||||||
private LegacyImporter() {
|
private LegacyImporter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int importPortals(PortalServices portalServices) {
|
public static int importPortals(PortalServices portalServices) {
|
||||||
ConfigAccessor portalConfig = new ConfigAccessor(
|
ConfigAccessor portalConfig = new ConfigAccessor(
|
||||||
AdvancedPortalsPlugin.getInstance(), "portals.yml");
|
AdvancedPortalsPlugin.getInstance(), "portals.yml");
|
||||||
var config = portalConfig.getConfig();
|
var config = portalConfig.getConfig();
|
||||||
Set<String> portalSet = config.getKeys(false);
|
Set<String> portalSet = config.getKeys(false);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (String portalName : portalSet) {
|
for (String portalName : portalSet) {
|
||||||
BlockLocation pos1 =
|
BlockLocation pos1 =
|
||||||
new BlockLocation(config.getString(portalName + ".world"),
|
new BlockLocation(config.getString(portalName + ".world"),
|
||||||
config.getInt(portalName + ".pos1.X"),
|
config.getInt(portalName + ".pos1.X"),
|
||||||
config.getInt(portalName + ".pos1.Y"),
|
config.getInt(portalName + ".pos1.Y"),
|
||||||
config.getInt(portalName + ".pos1.Z"));
|
config.getInt(portalName + ".pos1.Z"));
|
||||||
BlockLocation pos2 =
|
BlockLocation pos2 =
|
||||||
new BlockLocation(config.getString(portalName + ".world"),
|
new BlockLocation(config.getString(portalName + ".world"),
|
||||||
config.getInt(portalName + ".pos2.X"),
|
config.getInt(portalName + ".pos2.X"),
|
||||||
config.getInt(portalName + ".pos2.Y"),
|
config.getInt(portalName + ".pos2.Y"),
|
||||||
config.getInt(portalName + ".pos2.Z"));
|
config.getInt(portalName + ".pos2.Z"));
|
||||||
List<DataTag> args = new ArrayList<>();
|
List<DataTag> args = new ArrayList<>();
|
||||||
args.add(new DataTag("name", portalName));
|
args.add(new DataTag("name", portalName));
|
||||||
var triggerblock = config.getString(portalName + ".triggerblock");
|
var triggerblock = config.getString(portalName + ".triggerblock");
|
||||||
@ -56,9 +54,9 @@ public class LegacyImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationSection portalConfigSection =
|
ConfigurationSection portalConfigSection =
|
||||||
config.getConfigurationSection(portalName);
|
config.getConfigurationSection(portalName);
|
||||||
ConfigurationSection portalArgsConf =
|
ConfigurationSection portalArgsConf =
|
||||||
portalConfigSection.getConfigurationSection("portalArgs");
|
portalConfigSection.getConfigurationSection("portalArgs");
|
||||||
|
|
||||||
if (portalArgsConf != null) {
|
if (portalArgsConf != null) {
|
||||||
Set<String> argsSet = portalArgsConf.getKeys(true);
|
Set<String> argsSet = portalArgsConf.getKeys(true);
|
||||||
@ -66,8 +64,8 @@ public class LegacyImporter {
|
|||||||
// skip if it argName starts with command.
|
// skip if it argName starts with command.
|
||||||
if (portalArgsConf.isString(argName.toString())) {
|
if (portalArgsConf.isString(argName.toString())) {
|
||||||
args.add(new DataTag(
|
args.add(new DataTag(
|
||||||
argName.toString(),
|
argName.toString(),
|
||||||
portalArgsConf.getString(argName.toString())));
|
portalArgsConf.getString(argName.toString())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,12 +80,12 @@ public class LegacyImporter {
|
|||||||
}
|
}
|
||||||
if (!commands.isEmpty()) {
|
if (!commands.isEmpty()) {
|
||||||
args.add(
|
args.add(
|
||||||
new DataTag("commands", commands.toArray(new String[0])));
|
new DataTag("commands", commands.toArray(new String[0])));
|
||||||
}
|
}
|
||||||
args.stream()
|
args.stream()
|
||||||
.filter(dataTag -> dataTag.NAME.startsWith("command."))
|
.filter(dataTag -> dataTag.NAME.startsWith("command."))
|
||||||
.toList()
|
.toList()
|
||||||
.forEach(args::remove);
|
.forEach(args::remove);
|
||||||
|
|
||||||
// Find an arg called "delayed" and add a new one called portalEvent
|
// Find an arg called "delayed" and add a new one called portalEvent
|
||||||
var delayed = getArg(args, "delayed");
|
var delayed = getArg(args, "delayed");
|
||||||
@ -105,9 +103,10 @@ public class LegacyImporter {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int importDestinations(DestinationServices destinationServices) {
|
public static int importDestinations(
|
||||||
|
DestinationServices destinationServices) {
|
||||||
ConfigAccessor destiConfig = new ConfigAccessor(
|
ConfigAccessor destiConfig = new ConfigAccessor(
|
||||||
AdvancedPortalsPlugin.getInstance(), "destinations.yml");
|
AdvancedPortalsPlugin.getInstance(), "destinations.yml");
|
||||||
var config = destiConfig.getConfig();
|
var config = destiConfig.getConfig();
|
||||||
Set<String> destiSet = config.getKeys(false);
|
Set<String> destiSet = config.getKeys(false);
|
||||||
|
|
||||||
@ -115,14 +114,14 @@ public class LegacyImporter {
|
|||||||
for (String destiName : destiSet) {
|
for (String destiName : destiSet) {
|
||||||
var destiPos = destiName + ".pos";
|
var destiPos = destiName + ".pos";
|
||||||
var desti = destinationServices.createDesti(
|
var desti = destinationServices.createDesti(
|
||||||
new PlayerLocation(
|
new PlayerLocation(
|
||||||
config.getString(destiName + ".world"),
|
config.getString(destiName + ".world"),
|
||||||
config.getDouble(destiPos + ".X"),
|
config.getDouble(destiPos + ".X"),
|
||||||
config.getDouble(destiPos + ".Y"),
|
config.getDouble(destiPos + ".Y"),
|
||||||
config.getDouble(destiPos + ".Z"),
|
config.getDouble(destiPos + ".Z"),
|
||||||
(float) config.getDouble(destiPos + ".yaw"),
|
(float) config.getDouble(destiPos + ".yaw"),
|
||||||
(float) config.getDouble(destiPos + ".pitch")),
|
(float) config.getDouble(destiPos + ".pitch")),
|
||||||
List.of(new DataTag("name", destiName)));
|
List.of(new DataTag("name", destiName)));
|
||||||
if (desti != null)
|
if (desti != null)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@ -137,5 +136,4 @@ public class LegacyImporter {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user