Fix some 1.8.8 shop compat

This commit is contained in:
fullwall 2023-01-06 00:41:47 +08:00
parent ffac34f734
commit aee977ebb3
11 changed files with 34 additions and 15 deletions

View File

@ -603,7 +603,7 @@ public class ShopTrait extends Trait {
@MenuSlot(slot = { 0, 6 }, material = Material.NAME_TAG, amount = 1) @MenuSlot(slot = { 0, 6 }, material = Material.NAME_TAG, amount = 1)
public void onSetTitle(InventoryMenuSlot slot, CitizensInventoryClickEvent event) { public void onSetTitle(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
ctx.getMenu().transition(InputMenus.stringSetter(() -> shop.title, newTitle -> { ctx.getMenu().transition(InputMenus.stringSetter(() -> shop.title, newTitle -> {
shop.title = newTitle.isEmpty() ? null : newTitle; shop.title = newTitle;
})); }));
} }
@ -613,8 +613,8 @@ public class ShopTrait extends Trait {
shop.type = chosen.getValue(); shop.type = chosen.getValue();
}, Choice.<ShopType> of(ShopType.BUY, Material.DIAMOND, "Players buy items", shop.type == ShopType.BUY), }, Choice.<ShopType> of(ShopType.BUY, Material.DIAMOND, "Players buy items", shop.type == ShopType.BUY),
Choice.of(ShopType.SELL, Material.EMERALD, "Players sell items", shop.type == ShopType.SELL), Choice.of(ShopType.SELL, Material.EMERALD, "Players sell items", shop.type == ShopType.SELL),
Choice.of(ShopType.COMMAND, Material.ENDER_EYE, "Clicks trigger commands only", Choice.of(ShopType.COMMAND, Util.getFallbackMaterial("ENDER_EYE", "ENDER_PEARL"),
shop.type == ShopType.COMMAND))); "Clicks trigger commands only", shop.type == ShopType.COMMAND)));
} }
@MenuSlot(slot = { 0, 8 }, compatMaterial = { "COMMAND_BLOCK", "COMMAND" }, amount = 1) @MenuSlot(slot = { 0, 8 }, compatMaterial = { "COMMAND_BLOCK", "COMMAND" }, amount = 1)

View File

@ -136,7 +136,7 @@ public class CommandAction extends NPCShopAction {
CommandAction old = (CommandAction) previous; CommandAction old = (CommandAction) previous;
description = old.describe(); description = old.describe();
} }
return Util.createItem(Material.COMMAND_BLOCK, "Command", description); return Util.createItem(Util.getFallbackMaterial("COMMAND_BLOCK", "COMMAND"), "Command", description);
} }
@Override @Override

View File

@ -210,8 +210,9 @@ public class ItemAction extends NPCShopAction {
base.requireUndamaged = res; base.requireUndamaged = res;
return res ? ChatColor.GREEN + "On" : ChatColor.RED + "Off"; return res ? ChatColor.GREEN + "On" : ChatColor.RED + "Off";
}, base.requireUndamaged)); }, base.requireUndamaged));
ctx.getSlot(3 * 9 + 2).setItemStack(new ItemStack(Material.COMPARATOR), "Compare item similarity", ctx.getSlot(3 * 9 + 2).setItemStack(
base.compareSimilarity ? ChatColor.GREEN + "On" : ChatColor.RED + "Off"); new ItemStack(Util.getFallbackMaterial("COMPARATOR", "REDSTONE_COMPARATOR")),
"Compare item similarity", base.compareSimilarity ? ChatColor.GREEN + "On" : ChatColor.RED + "Off");
ctx.getSlot(3 * 9 + 2).addClickHandler(new BooleanSlotHandler((res) -> { ctx.getSlot(3 * 9 + 2).addClickHandler(new BooleanSlotHandler((res) -> {
base.compareSimilarity = res; base.compareSimilarity = res;
return res ? ChatColor.GREEN + "On" : ChatColor.RED + "Off"; return res ? ChatColor.GREEN + "On" : ChatColor.RED + "Off";
@ -221,7 +222,7 @@ public class ItemAction extends NPCShopAction {
ctx.getSlot(3 * 9 + 3) ctx.getSlot(3 * 9 + 3)
.addClickHandler((event) -> ctx.getMenu() .addClickHandler((event) -> ctx.getMenu()
.transition(InputMenus.stringSetter(() -> Joiner.on(',').join(base.metaFilter), .transition(InputMenus.stringSetter(() -> Joiner.on(',').join(base.metaFilter),
res -> base.metaFilter = Arrays.asList(res.split(","))))); res -> base.metaFilter = res == null ? null : Arrays.asList(res.split(",")))));
} }
@Override @Override

View File

@ -891,6 +891,12 @@ public class NMSImpl implements NMSBridge {
public void b(EntityHuman entityhuman) { public void b(EntityHuman entityhuman) {
} }
@Override
public void e() {
super.e();
this.a = 0;
}
@Override @Override
public CraftInventoryView getBukkitView() { public CraftInventoryView getBukkitView() {
if (this.bukkitEntity != null) { if (this.bukkitEntity != null) {
@ -914,10 +920,10 @@ public class NMSImpl implements NMSBridge {
container.getBukkitView().setItem(0, anvil.getItem(0)); container.getBukkitView().setItem(0, anvil.getItem(0));
container.getBukkitView().setItem(1, anvil.getItem(1)); container.getBukkitView().setItem(1, anvil.getItem(1));
container.checkReachable = false; container.checkReachable = false;
container.addSlotListener(handle);
handle.playerConnection handle.playerConnection
.sendPacket(new PacketPlayOutOpenWindow(container.windowId, "minecraft:anvil", new ChatMessage(title))); .sendPacket(new PacketPlayOutOpenWindow(container.windowId, "minecraft:anvil", new ChatMessage(title)));
handle.activeContainer = container; handle.activeContainer = container;
handle.syncInventory();
return container.getBukkitView(); return container.getBukkitView();
} }

View File

@ -949,6 +949,12 @@ public class NMSImpl implements NMSBridge {
public void b(EntityHuman entityhuman) { public void b(EntityHuman entityhuman) {
} }
@Override
public void e() {
super.e();
this.a = 0;
}
@Override @Override
public CraftInventoryView getBukkitView() { public CraftInventoryView getBukkitView() {
if (this.bukkitEntity != null) { if (this.bukkitEntity != null) {
@ -972,10 +978,10 @@ public class NMSImpl implements NMSBridge {
container.getBukkitView().setItem(0, anvil.getItem(0)); container.getBukkitView().setItem(0, anvil.getItem(0));
container.getBukkitView().setItem(1, anvil.getItem(1)); container.getBukkitView().setItem(1, anvil.getItem(1));
container.checkReachable = false; container.checkReachable = false;
container.addSlotListener(handle);
handle.playerConnection handle.playerConnection
.sendPacket(new PacketPlayOutOpenWindow(container.windowId, "minecraft:anvil", new ChatMessage(title))); .sendPacket(new PacketPlayOutOpenWindow(container.windowId, "minecraft:anvil", new ChatMessage(title)));
handle.activeContainer = container; handle.activeContainer = container;
handle.syncInventory();
return container.getBukkitView(); return container.getBukkitView();
} }

View File

@ -979,10 +979,10 @@ public class NMSImpl implements NMSBridge {
container.getBukkitView().setItem(0, anvil.getItem(0)); container.getBukkitView().setItem(0, anvil.getItem(0));
container.getBukkitView().setItem(1, anvil.getItem(1)); container.getBukkitView().setItem(1, anvil.getItem(1));
container.checkReachable = false; container.checkReachable = false;
container.addSlotListener(handle);
handle.playerConnection handle.playerConnection
.sendPacket(new PacketPlayOutOpenWindow(container.windowId, "minecraft:anvil", new ChatMessage(title))); .sendPacket(new PacketPlayOutOpenWindow(container.windowId, "minecraft:anvil", new ChatMessage(title)));
handle.activeContainer = container; handle.activeContainer = container;
handle.syncInventory();
return container.getBukkitView(); return container.getBukkitView();
} }

View File

@ -1021,10 +1021,10 @@ public class NMSImpl implements NMSBridge {
container.getBukkitView().setItem(0, anvil.getItem(0)); container.getBukkitView().setItem(0, anvil.getItem(0));
container.getBukkitView().setItem(1, anvil.getItem(1)); container.getBukkitView().setItem(1, anvil.getItem(1));
container.checkReachable = false; container.checkReachable = false;
container.addSlotListener(handle);
handle.playerConnection handle.playerConnection
.sendPacket(new PacketPlayOutOpenWindow(container.windowId, "minecraft:anvil", new ChatMessage(title))); .sendPacket(new PacketPlayOutOpenWindow(container.windowId, "minecraft:anvil", new ChatMessage(title)));
handle.activeContainer = container; handle.activeContainer = container;
handle.syncInventory();
return container.getBukkitView(); return container.getBukkitView();
} }

View File

@ -1084,10 +1084,10 @@ public class NMSImpl implements NMSBridge {
container.getBukkitView().setItem(0, anvil.getItem(0)); container.getBukkitView().setItem(0, anvil.getItem(0));
container.getBukkitView().setItem(1, anvil.getItem(1)); container.getBukkitView().setItem(1, anvil.getItem(1));
container.checkReachable = false; container.checkReachable = false;
container.addSlotListener(handle);
handle.playerConnection.sendPacket( handle.playerConnection.sendPacket(
new PacketPlayOutOpenWindow(container.windowId, container.getType(), new ChatMessage(title))); new PacketPlayOutOpenWindow(container.windowId, container.getType(), new ChatMessage(title)));
handle.activeContainer = container; handle.activeContainer = container;
handle.syncInventory();
return container.getBukkitView(); return container.getBukkitView();
} }

View File

@ -1102,10 +1102,10 @@ public class NMSImpl implements NMSBridge {
container.getBukkitView().setItem(0, anvil.getItem(0)); container.getBukkitView().setItem(0, anvil.getItem(0));
container.getBukkitView().setItem(1, anvil.getItem(1)); container.getBukkitView().setItem(1, anvil.getItem(1));
container.checkReachable = false; container.checkReachable = false;
container.addSlotListener(handle);
handle.playerConnection.sendPacket( handle.playerConnection.sendPacket(
new PacketPlayOutOpenWindow(container.windowId, container.getType(), new ChatMessage(title))); new PacketPlayOutOpenWindow(container.windowId, container.getType(), new ChatMessage(title)));
handle.activeContainer = container; handle.activeContainer = container;
handle.syncInventory();
return container.getBukkitView(); return container.getBukkitView();
} }

View File

@ -1120,10 +1120,10 @@ public class NMSImpl implements NMSBridge {
container.getBukkitView().setItem(0, anvil.getItem(0)); container.getBukkitView().setItem(0, anvil.getItem(0));
container.getBukkitView().setItem(1, anvil.getItem(1)); container.getBukkitView().setItem(1, anvil.getItem(1));
container.checkReachable = false; container.checkReachable = false;
container.addSlotListener(handle);
handle.playerConnection.sendPacket( handle.playerConnection.sendPacket(
new PacketPlayOutOpenWindow(container.windowId, container.getType(), new ChatMessage(title))); new PacketPlayOutOpenWindow(container.windowId, container.getType(), new ChatMessage(title)));
handle.activeContainer = container; handle.activeContainer = container;
handle.syncInventory();
return container.getBukkitView(); return container.getBukkitView();
} }

View File

@ -829,6 +829,12 @@ public class NMSImpl implements NMSBridge {
return true; return true;
} }
@Override
public void b() {
this.a = 0;
super.b();
}
@Override @Override
public void b(EntityHuman entityhuman) { public void b(EntityHuman entityhuman) {
} }
@ -856,10 +862,10 @@ public class NMSImpl implements NMSBridge {
container.getBukkitView().setItem(0, anvil.getItem(0)); container.getBukkitView().setItem(0, anvil.getItem(0));
container.getBukkitView().setItem(1, anvil.getItem(1)); container.getBukkitView().setItem(1, anvil.getItem(1));
container.checkReachable = false; container.checkReachable = false;
container.addSlotListener(handle);
handle.playerConnection handle.playerConnection
.sendPacket(new PacketPlayOutOpenWindow(container.windowId, "minecraft:anvil", new ChatMessage(title))); .sendPacket(new PacketPlayOutOpenWindow(container.windowId, "minecraft:anvil", new ChatMessage(title)));
handle.activeContainer = container; handle.activeContainer = container;
handle.syncInventory();
return container.getBukkitView(); return container.getBukkitView();
} }