fix curios bugs.

This commit is contained in:
mlus-Asuka 2023-03-31 13:18:36 +08:00
parent dbe90ecd25
commit 8940c8be8d
2 changed files with 15 additions and 12 deletions

View File

@ -25,18 +25,21 @@ public class ModsSupport {
LazyOptional<IItemHandlerModifiable> itemHandler = CuriosApi.getCuriosHelper().getEquippedCurios(player); LazyOptional<IItemHandlerModifiable> itemHandler = CuriosApi.getCuriosHelper().getEquippedCurios(player);
ResultSet resultSet = JDBCsetUp.executeQuery("SELECT curios_item FROM curios WHERE uuid = '"+player.getUUID()+"'"); ResultSet resultSet = JDBCsetUp.executeQuery("SELECT curios_item FROM curios WHERE uuid = '"+player.getUUID()+"'");
if(resultSet.next()) { if(resultSet.next()) {
Map<Integer, String> curios = LocalJsonUtil.StringToEntryMap(resultSet.getString("curios_item")); String curios_data=resultSet.getString("curios_item");
itemHandler.ifPresent(handler -> { if(curios_data.length()>2) {
for (int i = 0; i < handler.getSlots(); i++) { Map<Integer, String> curios = LocalJsonUtil.StringToEntryMap(curios_data);
try { itemHandler.ifPresent(handler -> {
if(curios.get(i)==null) continue; for (int i = 0; i < handler.getSlots(); i++) {
handler.setStackInSlot(i, ItemStack.of(NbtUtils.snbtToStructure(curios.get(i).replace("|", ",")))); try {
} catch (CommandSyntaxException e) { if (curios.get(i) == null) continue;
throw new RuntimeException(e); handler.setStackInSlot(i, ItemStack.of(NbtUtils.snbtToStructure(curios.get(i).replace("|", ","))));
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
} }
} });
}); }
resultSet.close(); resultSet.close();
}else{ }else{
StoreCurios(player,true); StoreCurios(player,true);
} }

View File

@ -19,7 +19,7 @@ modId="playersync" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata # ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
# see the associated build.gradle script for how to populate this completely automatically during a build # see the associated build.gradle script for how to populate this completely automatically during a build
version="1.1.2" #mandatory version="1.1.3" #mandatory
# A display name for the mod # A display name for the mod
displayName="PlayerSync" #mandatory displayName="PlayerSync" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/