fix: removed all deprecations! :)

This commit is contained in:
Janik Heß
2025-03-08 23:47:41 +01:00
parent bc71ccee8f
commit c245c199a0

View File

@@ -1,7 +1,5 @@
package de.hessj.environmentex;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -57,8 +55,6 @@ import org.bukkit.event.player.PlayerAttemptPickupItemEvent;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@@ -968,8 +964,10 @@ public class EnvironmentExListeners implements Listener {
|| e.getWhoClicked().getOpenInventory().title()
.equals(Component.translatable("Riesiger Rucksack"))) {
if (/*e.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD
|| */e.getAction() == InventoryAction.HOTBAR_SWAP) {
if (/*
* e.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD
* ||
*/e.getAction() == InventoryAction.HOTBAR_SWAP) {
if (e.getHotbarButton() != -1) {// evtl auch schauen ob titel, da es sonst auch nicht in truhe
// gepackt werden kann, evtl aber auch schon oben gekläört
@@ -1098,15 +1096,11 @@ public class EnvironmentExListeners implements Listener {
}
static String itemStackArrayToBase64(ItemStack[] itemArray) throws IllegalStateException {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeObject(itemArray);
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
byte[] iss = ItemStack.serializeItemsAsBytes(itemArray);
App.main.log(Base64Coder.encodeLines(iss));
return Base64Coder.encodeLines(iss);
} catch (Exception e) {
throw new IllegalStateException("Error whilst saving items, Please contact the developer", e);
}
@@ -1114,14 +1108,10 @@ public class EnvironmentExListeners implements Listener {
static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] itemArray = (ItemStack[]) dataInput.readObject();
dataInput.close();
return itemArray;
} catch (ClassNotFoundException e) {
App.main.log(data);
ItemStack[] is = ItemStack.deserializeItemsFromBytes(Base64Coder.decodeLines(data));
return is;
} catch (IllegalStateException e) {
throw new IOException("Error whilst loading items, Please contact the developer", e);
}