Skip to content

Commit 2b68e81

Browse files
committed
版本更新至 3.71
修复:物品列表点击报错 新增:自用 Skript 语法 “taboocode itemcache %string%”
1 parent 149aa4c commit 2b68e81

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

src/main/src/me/skymc/taboolib/commands/sub/itemlist/listener/ItemLibraryPatch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void inventoryClick(InventoryClickEvent e) {
3131
if (e.getInventory().getHolder() instanceof ItemLibraryHolder) {
3232
e.setCancelled(true);
3333

34-
if (e.getCurrentItem() == null || e.getCurrentItem().getType().equals(Material.AIR)) {
34+
if (e.getCurrentItem() == null || e.getCurrentItem().getType().equals(Material.AIR) || e.getRawSlot() >= e.getInventory().getSize()) {
3535
return;
3636
}
3737

src/main/src/me/skymc/taboolib/skript/SkriptHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package me.skymc.taboolib.skript;
22

3+
import org.bukkit.Sound;
34
import org.bukkit.inventory.ItemStack;
45

56
import ch.njol.skript.Skript;
67
import ch.njol.skript.lang.ExpressionType;
78
import me.skymc.taboolib.skript.expression.ExpressionItemCache;
9+
import me.skymc.taboolib.skript.expression.ExpressionTabooCodeItem;
810

911
/**
1012
* @author sky
@@ -16,6 +18,7 @@ public class SkriptHandler {
1618

1719
private SkriptHandler() {
1820
Skript.registerExpression(ExpressionItemCache.class, ItemStack.class, ExpressionType.SIMPLE, "taboolib itemcache %string%");
21+
Skript.registerExpression(ExpressionTabooCodeItem.class, ItemStack.class, ExpressionType.SIMPLE, "taboocode itemcache %string%");
1922
}
2023

2124
public static SkriptHandler getInst() {

src/main/src/me/skymc/taboolib/skript/expression/ExpressionItemCache.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public String toString(Event e, boolean arg1) {
4141

4242
@Override
4343
protected ItemStack[] get(Event e) {
44-
return new ItemStack[] { ItemUtils.getCacheItem(name.getSingle(e)) };
44+
ItemStack item = ItemUtils.getCacheItem(name.getSingle(e));
45+
return new ItemStack[] { item == null ? null : item.clone() };
4546
}
4647
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package me.skymc.taboolib.skript.expression;
2+
3+
import org.bukkit.event.Event;
4+
import org.bukkit.inventory.ItemStack;
5+
6+
import ch.njol.skript.lang.Expression;
7+
import ch.njol.skript.lang.SkriptParser.ParseResult;
8+
import ch.njol.skript.lang.util.SimpleExpression;
9+
import ch.njol.util.Kleenean;
10+
import me.skymc.taboocode.TabooCodeItem;
11+
import me.skymc.taboolib.inventory.ItemUtils;
12+
13+
/**
14+
* @author sky
15+
* @since 2018-02-28 15:45:49
16+
*/
17+
public class ExpressionTabooCodeItem extends SimpleExpression<ItemStack> {
18+
19+
private Expression<String> name;
20+
21+
@Override
22+
public Class<? extends ItemStack> getReturnType() {
23+
return ItemStack.class;
24+
}
25+
26+
@Override
27+
public boolean isSingle() {
28+
return true;
29+
}
30+
31+
@SuppressWarnings("unchecked")
32+
@Override
33+
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, ParseResult arg3) {
34+
name = (Expression<String>) args[0];
35+
return true;
36+
}
37+
38+
@Override
39+
public String toString(Event e, boolean arg1) {
40+
return this.getClass().getName();
41+
}
42+
43+
@Override
44+
protected ItemStack[] get(Event e) {
45+
ItemStack item = TabooCodeItem.getItem(name.getSingle(e), false);
46+
return new ItemStack[] { item == null ? null : item.clone() };
47+
}
48+
}

0 commit comments

Comments
 (0)