-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📦 同步主仓库 (7943dcc3109ec777b33b4269901042d0864f18ae)
- Loading branch information
1 parent
56bb46e
commit dcb8d33
Showing
35 changed files
with
210 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../java/net/Indyuce/mmoitems/api/crafting/ingredient/inventory/MMOItemPlayerIngredient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/util/DurabilityItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/build/ItemStackBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 48 additions & 46 deletions
94
MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/identify/IdentifiedItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,58 @@ | ||
package net.Indyuce.mmoitems.api.item.util.identify; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
|
||
import io.lumine.mythic.lib.api.item.NBTItem; | ||
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.util.io.BukkitObjectInputStream; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; | ||
|
||
import io.lumine.mythic.lib.api.item.NBTItem; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
|
||
public class IdentifiedItem { | ||
private final NBTItem item; | ||
|
||
public IdentifiedItem(NBTItem item) { | ||
this.item = item; | ||
} | ||
|
||
/* | ||
* the identified item is stored in an item NBTTag, identifying the item | ||
* basically replaces the item for the one saved in the NBT | ||
*/ | ||
public ItemStack identify() { | ||
return deserialize(item.getString("MMOITEMS_UNIDENTIFIED_ITEM")); | ||
} | ||
|
||
private ItemStack deserialize(String data) { | ||
try { | ||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); | ||
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); | ||
ItemStack stack = (ItemStack) dataInput.readObject(); | ||
dataInput.close(); | ||
|
||
/* | ||
* For some reason, unidentified items keep having slightly different NBT tags | ||
* than items generated from mob drops or the GUI, I suppose it has to do with | ||
* the serialization-deserialization, It seems to get fixed when rebuilding | ||
* the item stack though. | ||
* | ||
* Its annoying because it prevents stacking. | ||
*/ | ||
NBTItem toRebuild = NBTItem.get(stack); | ||
if (toRebuild.hasType()) { | ||
|
||
// Rebuild | ||
LiveMMOItem rebuilt = new LiveMMOItem(stack); | ||
return rebuilt.newBuilder().build(); } | ||
|
||
return stack; | ||
} catch (ClassNotFoundException | IOException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
private final NBTItem item; | ||
|
||
public IdentifiedItem(NBTItem item) { | ||
this.item = item; | ||
} | ||
|
||
/** | ||
* The identified item is stored in an item NBTTag, identifying the | ||
* item basically replaces the item for the one saved in the NBT | ||
*/ | ||
@NotNull | ||
public ItemStack identify() { | ||
return deserialize(item.getString("MMOITEMS_UNIDENTIFIED_ITEM")); | ||
} | ||
|
||
@NotNull | ||
private ItemStack deserialize(String stringInput) { | ||
try { | ||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(stringInput)); | ||
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); | ||
ItemStack stack = (ItemStack) dataInput.readObject(); | ||
dataInput.close(); | ||
|
||
/* | ||
* For some reason, unidentified items keep having slightly different NBT tags | ||
* than items generated from mob drops or the GUI, I suppose it has to do with | ||
* the serialization-deserialization, It seems to get fixed when rebuilding | ||
* the item stack though. | ||
* | ||
* Its annoying because it prevents stacking. | ||
*/ | ||
NBTItem toRebuild = NBTItem.get(stack); | ||
if (toRebuild.hasType()) { | ||
|
||
// Rebuild | ||
LiveMMOItem rebuilt = new LiveMMOItem(stack); | ||
return rebuilt.newBuilder().build(); | ||
} | ||
|
||
return stack; | ||
} catch (ClassNotFoundException | IOException exception) { | ||
throw new RuntimeException(exception); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowParticles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.