Update EssentialsX kit conversion (EssentialsX 2.20.1+ required)

This commit is contained in:
ceze88 2024-04-15 16:53:51 +02:00
parent 6e568b1077
commit b3c0f41948
3 changed files with 38 additions and 7 deletions

35
pom.xml
View File

@ -111,11 +111,31 @@
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>essentials-snapshots</id>
<url>https://repo.essentialsx.net/snapshots/</url>
</repository>
<repository>
<id>essentials-releases</id>
<url>https://repo.essentialsx.net/releases/</url>
</repository>
<repository>
<id>paper-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>public</id>
<url>https://repo.craftaro.com/repository/public/</url>
@ -144,10 +164,19 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.earth2me</groupId>
<artifactId>essentials</artifactId>
<version>2.17.1</version>
<groupId>net.essentialsx</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.19.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Required by Essentials -->
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
</dependency>

View File

@ -53,7 +53,8 @@ public class Convert {
}
plugin.saveKits(true);
} catch (NoSuchMethodError | NoClassDefFoundError e) {
System.out.println("UltimateKits conversion failed.");
plugin.getLogger().severe("Failed to convert kits from " + hook.getClass().getSimpleName() + "most likely due to an outdated plugin version.");
e.printStackTrace();
}
}

View File

@ -5,6 +5,7 @@ import com.craftaro.ultimatekits.conversion.Hook;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.Kit;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.config.EssentialsConfiguration;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
@ -23,10 +24,10 @@ public class EssentialsHook implements Hook {
@Override
public Map<String, ConversionKit> getKits() {
ConfigurationSection cs = this.essentials.getSettings().getKits();
EssentialsConfiguration cs = this.essentials.getKits().getRootConfig();
Map<String, ConversionKit> kits = new LinkedHashMap<>();
try {
for (String name : cs.getKeys(false)) {
for (String name : cs.getKeys()) {
Set<ItemStack> stacks = new HashSet<>();
Kit kitObj = new Kit(name, this.essentials);
for (String nonParse : kitObj.getItems()) {
@ -42,7 +43,7 @@ public class EssentialsHook implements Hook {
}
stacks.add(metaStack.getItemStack());
}
kits.put(name, new ConversionKit(stacks, Integer.toUnsignedLong((int) this.essentials.getSettings().getKit(name).getOrDefault("delay", 0))));
kits.put(name, new ConversionKit(stacks, Integer.toUnsignedLong((int) cs.getInt("delay", 0))));
}
} catch (Exception e) {
return kits;