Skip to content

Commit

Permalink
修复在mot核心上使用无法保存字符串id物品
Browse files Browse the repository at this point in the history
  • Loading branch information
lt-name committed Jan 10, 2024
1 parent 600a92b commit d9afe23
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/smallaswater/npc/utils/Utils.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.smallaswater.npc.utils;

import cn.lanink.gamecore.utils.NukkitTypeUtils;
import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.item.Item;
import cn.nukkit.item.StringItem;
import cn.nukkit.level.Location;
import cn.nukkit.plugin.Plugin;
import com.smallaswater.npc.RsNPC;
Expand All @@ -28,6 +30,11 @@ private Utils() {
* @return 保存用字符串ID
*/
public static String item2String(Item item) {
if (NukkitTypeUtils.getNukkitType() == NukkitTypeUtils.NukkitType.MOT) {
if (item instanceof StringItem) {
return item.getNamespaceId();
}
}
return item.getId() + ":" + item.getDamage();
}

Expand Down

0 comments on commit d9afe23

Please sign in to comment.