2.0.0
Fixed: - Map handling errors Changed: - Java 21 to java 25
This commit is contained in:
1 parent
1a2c27af99
commit
09da9cbe66
3 files changed
+71
-59
No files matched your search
@@ -8,11 +8,11 @@
|
||||
<groupId>com.rsscripting</groupId>
|
||||
<artifactId>RS-Warehouse</artifactId>
|
||||
<name>RS-Warehouse</name>
|
||||
<version>1.6.0</version>
|
||||
<version>2.0.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>25</maven.compiler.source>
|
||||
<maven.compiler.target>25</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.21.6-R0.1-SNAPSHOT</version>
|
||||
<version>26.3.build.32-alpha</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.MapId;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
import java.util.List;
|
||||
@@ -314,49 +315,31 @@ public class ItemsMenu {
|
||||
warehouseItem.serializedItem()
|
||||
);
|
||||
|
||||
if (
|
||||
item == null
|
||||
||
|
||||
item.getType()
|
||||
!= Material.FILLED_MAP
|
||||
) {
|
||||
|
||||
if (item == null) {
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (
|
||||
!(item.getItemMeta()
|
||||
instanceof MapMeta mapMeta)
|
||||
) {
|
||||
MapId mapId =
|
||||
item.getData(
|
||||
DataComponentTypes.MAP_ID
|
||||
);
|
||||
|
||||
if (mapId == null) {
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (
|
||||
!mapMeta.hasMapView()
|
||||
) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
MapView mapView =
|
||||
mapMeta.getMapView();
|
||||
|
||||
if (
|
||||
mapView == null
|
||||
) {
|
||||
Bukkit.getMap(
|
||||
mapId.id()
|
||||
);
|
||||
|
||||
if (mapView == null) {
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
player.sendMap(
|
||||
mapView
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
player.openInventory(
|
||||
|
||||
@@ -8,16 +8,12 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
import org.bukkit.util.io.BukkitObjectInputStream;
|
||||
import org.bukkit.util.io.BukkitObjectOutputStream;
|
||||
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.SuspiciousStewEffects;
|
||||
import io.papermc.paper.potion.SuspiciousEffectEntry;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
@@ -28,6 +24,10 @@ public class ItemStackUtils {
|
||||
ItemStack item
|
||||
) {
|
||||
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack serializedItem =
|
||||
item.clone();
|
||||
|
||||
@@ -37,38 +37,31 @@ public class ItemStackUtils {
|
||||
|
||||
try {
|
||||
|
||||
ByteArrayOutputStream outputStream =
|
||||
new ByteArrayOutputStream();
|
||||
|
||||
BukkitObjectOutputStream dataOutput =
|
||||
new BukkitObjectOutputStream(
|
||||
outputStream
|
||||
);
|
||||
|
||||
dataOutput.writeObject(
|
||||
serializedItem
|
||||
);
|
||||
|
||||
dataOutput.close();
|
||||
|
||||
return Base64.getEncoder()
|
||||
.encodeToString(
|
||||
outputStream.toByteArray()
|
||||
serializedItem.serializeAsBytes()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ItemStack deserialize(
|
||||
String data
|
||||
) {
|
||||
|
||||
if (data == null || data.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
byte[] bytes =
|
||||
@@ -77,22 +70,58 @@ public class ItemStackUtils {
|
||||
data
|
||||
);
|
||||
|
||||
ByteArrayInputStream inputStream =
|
||||
new ByteArrayInputStream(
|
||||
/*
|
||||
* New format:
|
||||
* Paper NBT ItemStack serialization.
|
||||
*/
|
||||
try {
|
||||
|
||||
return ItemStack.deserializeBytes(
|
||||
bytes
|
||||
);
|
||||
|
||||
BukkitObjectInputStream dataInput =
|
||||
new BukkitObjectInputStream(
|
||||
inputStream
|
||||
}
|
||||
|
||||
catch (Exception modernException) {
|
||||
|
||||
/*
|
||||
* Legacy format:
|
||||
* BukkitObjectOutputStream serialization.
|
||||
*
|
||||
* Existing warehouse databases may still
|
||||
* contain these entries.
|
||||
*/
|
||||
try (
|
||||
java.io.ByteArrayInputStream inputStream =
|
||||
new java.io.ByteArrayInputStream(
|
||||
bytes
|
||||
);
|
||||
|
||||
org.bukkit.util.io.BukkitObjectInputStream dataInput =
|
||||
new org.bukkit.util.io.BukkitObjectInputStream(
|
||||
inputStream
|
||||
)
|
||||
) {
|
||||
|
||||
ItemStack item =
|
||||
(ItemStack) dataInput.readObject();
|
||||
|
||||
dataInput.close();
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return item;
|
||||
/*
|
||||
* Ask Paper to convert legacy item data
|
||||
* to the current server representation.
|
||||
*/
|
||||
return Bukkit.getItemFactory()
|
||||
.ensureServerConversions(
|
||||
item
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user