Remove UUID lib dependency. Will resolve #317

This commit is contained in:
Trent Hensler
2018-01-01 10:50:42 -08:00
parent 8dd5e8cffb
commit 0b43300b21
6 changed files with 108 additions and 70 deletions
+94
View File
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.drtshock</groupId>
<artifactId>PlayerVaultsX</artifactId>
<name>PlayerVaultsX</name>
<version>4.0.1</version>
<url>http://dev.bukkit.org/pancakes/playervaults/</url>
<build>
<defaultGoal>clean install</defaultGoal>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources/</directory>
<includes>
<include>*.yml</include>
</includes>
</resource>
</resources>
<finalName>PlayerVaultsX</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<artifactSet>
<includes>
<include>com.turt2live.uuid</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.turt2live.uuid</pattern>
<shadedPattern>com.drtshock.playervaults.lib</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.turt2live</groupId>
<artifactId>UUID-Library</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}/lib/UUID-Library.jar</systemPath>
</dependency>
</dependencies>
<properties>
<build.number>SNAPSHOT</build.number>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Binary file not shown.
+2 -33
View File
@@ -34,32 +34,6 @@
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.turt2live:UUID-Library</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.turt2live.uuid</pattern>
<shadedPattern>com.drtshock.playervaults.lib.uuid</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
@@ -79,18 +53,13 @@
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.turt2live</groupId>
<artifactId>UUID-Library</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/UUID-Library.jar</systemPath>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -5,24 +5,16 @@ import com.drtshock.playervaults.converters.BackpackConverter;
import com.drtshock.playervaults.converters.Converter;
import com.drtshock.playervaults.util.Lang;
import com.drtshock.playervaults.vaultmanagement.VaultOperations;
import com.turt2live.uuid.CachingServiceProvider;
import com.turt2live.uuid.ServiceProvider;
import com.turt2live.uuid.turt2live.v2.ApiV2Service;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class ConvertCommand implements CommandExecutor {
private final List<Converter> converters = new ArrayList<>();
private ServiceProvider uuidProvider;
public ConvertCommand() {
converters.add(new BackpackConverter());
@@ -56,27 +48,15 @@ public class ConvertCommand implements CommandExecutor {
PlayerVaults.getInstance().getServer().getScheduler().runTaskLaterAsynchronously(PlayerVaults.getInstance(), new Runnable() {
@Override
public void run() {
if (uuidProvider == null) {
CachingServiceProvider cachingUuidProvider = new CachingServiceProvider(new ApiV2Service());
Map<UUID, String> seed = new HashMap<>();
for (OfflinePlayer player : PlayerVaults.getInstance().getServer().getOfflinePlayers()) {
if (player.hasPlayedBefore()) {
seed.put(player.getUniqueId(), player.getName());
}
}
cachingUuidProvider.seedLoad(seed, 6 * 60 * 60); // 6 hour cache time
uuidProvider = cachingUuidProvider;
}
int converted = 0;
VaultOperations.setLocked(true);
for (Converter converter : applicableConverters) {
if (converter.canConvert()) {
converted += converter.run(sender, uuidProvider);
converted += converter.run(sender);
}
}
VaultOperations.setLocked(false);
sender.sendMessage(Lang.TITLE + Lang.CONVERT_COMPLETE.toString().replace("%converted", converted + ""));
}
@@ -2,8 +2,8 @@ package com.drtshock.playervaults.converters;
import com.drtshock.playervaults.PlayerVaults;
import com.drtshock.playervaults.vaultmanagement.VaultManager;
import com.turt2live.uuid.PlayerRecord;
import com.turt2live.uuid.ServiceProvider;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
@@ -22,10 +22,7 @@ import java.util.UUID;
public class BackpackConverter implements Converter {
@Override
public int run(CommandSender initiator, ServiceProvider uuidProvider) {
if (uuidProvider == null) {
throw new IllegalArgumentException();
}
public int run(CommandSender initiator) {
PlayerVaults plugin = PlayerVaults.getInstance();
File destination = new File(plugin.getDataFolder().getParentFile(), "Backpack" + File.separator + "backpacks");
@@ -39,7 +36,7 @@ public class BackpackConverter implements Converter {
int vaultNum = 1;
for (File file : worldDirs != null ? worldDirs : new File[0]) {
if (file.isDirectory()) {
converted += convert(file, vaultNum, uuidProvider);
converted += convert(file, vaultNum);
vaultNum++;
}
}
@@ -47,7 +44,7 @@ public class BackpackConverter implements Converter {
return converted;
}
private int convert(File worldFolder, int intoVaultNum, ServiceProvider uuidProvider) {
private int convert(File worldFolder, int intoVaultNum) {
PlayerVaults plugin = PlayerVaults.getInstance();
VaultManager vaults = VaultManager.getInstance();
int converted = 0;
@@ -56,11 +53,11 @@ public class BackpackConverter implements Converter {
for (File file : files != null ? files : new File[0]) {
if (file.isFile() && file.getName().toLowerCase().endsWith(".yml")) {
try {
PlayerRecord player = uuidProvider.doLookup(file.getName().substring(0, file.getName().lastIndexOf('.')));
if (player == null || player.getUuid() == null) {
OfflinePlayer player = Bukkit.getOfflinePlayer(file.getName().substring(0, file.getName().lastIndexOf('.')));
if (player == null || player.getUniqueId() == null) {
plugin.getLogger().warning("Unable to convert Backpack for player: " + (player != null ? player.getName() : file.getName()));
} else {
UUID uuid = player.getUuid();
UUID uuid = player.getUniqueId();
FileConfiguration yaml = YamlConfiguration.loadConfiguration(file);
ConfigurationSection section = yaml.getConfigurationSection("backpack");
if (section.getKeys(false).size() <= 0) {
@@ -1,6 +1,5 @@
package com.drtshock.playervaults.converters;
import com.turt2live.uuid.ServiceProvider;
import org.bukkit.command.CommandSender;
/**
@@ -14,11 +13,10 @@ public interface Converter {
* Converts the other plugin's data.
*
* @param initiator the initiator of the conversion. May be null
* @param uuidProvider the UUID provider to use, cannot be null
*
* @return the number of vaults converted. Returns 0 on none converted or -1 if no vaults were converted.
*/
int run(CommandSender initiator, ServiceProvider uuidProvider);
int run(CommandSender initiator);
/**
* Determines if this converter is applicable for converting to PlayerVaults. This may check for the existance of a