I've recently been writing to make use of the AltFinder API. I was following the Wiki which recommended I use the ExternalAPI.java class.
I recieve the following stacktrace while executing the code.
[18:52:30 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'twsalt' in plugin TWSAltFinder v0.0.1
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[purpur.jar:git-Purpur-265]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:172) ~[purpur.jar:git-Purpur-265]
at org.bukkit.craftbukkit.v1_14_R1.CraftServer.dispatchCommand(CraftServer.java:739) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.PlayerConnection.handleCommand(PlayerConnection.java:1864) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.PlayerConnection.a(PlayerConnection.java:1672) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.PacketPlayInChat.a(PacketPlayInChat.java:47) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:23) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.TickTask.run(SourceFile:18) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.MinecraftServer.aX(MinecraftServer.java:1020) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.MinecraftServer.executeNext(MinecraftServer.java:1013) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.MinecraftServer.sleepForTick(MinecraftServer.java:997) ~[purpur.jar:git-Purpur-265]
at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:930) ~[purpur.jar:git-Purpur-265]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
Caused by: java.lang.ClassCastException: me.egg82.altfinder.core.PlayerData cannot be cast to me.egg82.altfinder.core.PlayerData
at kyle.tws.altfinder.commands.AltCommand.onCommand(AltCommand.java:65) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur.jar:git-Purpur-265]
... 17 more
And on the Server itself I am using the altfinder-bukkit-3.4.24.jar plugin and version.
My code is below. It is failing on the line which begins the for loop. It seems to be failing to cast the items in Sorted to PlayerData.java, sorted is a list of elements I am getting from the Api. Potenially, there is a version discrepancy between the two causing it throw the cast exception.
ExternalAPI api = ExternalAPI.getInstance();
try {
List<PlayerData> sorted = new ArrayList<>(api.getPlayerData(user.getId()));
sorted.sort(Comparator.comparingLong(PlayerData::getCreated));
if (sorted.isEmpty()) {
outputLines.add("No player data for: " + user.getName());
}
else {
for (PlayerData playerData : sorted) {
long lastSeen = playerData.getUpdated();
long currentTime = api.getCurrentSQLTime();
long daysBetween = ChronoUnit.DAYS.between(Instant.ofEpochMilli(currentTime), Instant.ofEpochMilli(lastSeen));
outputLines.add(user.getName() + " Last seen: " + daysBetween + " days ago");
}
}
} catch (APIException e) {
e.printStackTrace();
}
Looks like I attempted to cast classes across the child CL by accident. The easiest solution would be to take the data received apart and put it back together on the other side.
Hi,
I've recently been writing to make use of the AltFinder API. I was following the Wiki which recommended I use the
ExternalAPI.java
class.I recieve the following stacktrace while executing the code.
In my
pom.xml
file I have the following:And on the Server itself I am using the
altfinder-bukkit-3.4.24.jar
plugin and version.My code is below. It is failing on the line which begins the
for loop
. It seems to be failing to cast the items in Sorted toPlayerData.java
, sorted is a list of elements I am getting from the Api. Potenially, there is a version discrepancy between the two causing it throw the cast exception.Are you able to assist me with this?