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