Add STOP_ELYTRA PlayerAnimation, add a right click option to /npc shop to avoid having to make a command for it
This commit is contained in:
parent
84e59407e4
commit
f6d7ebe809
|
@ -106,6 +106,7 @@ import net.citizensnpcs.trait.CommandTrait;
|
|||
import net.citizensnpcs.trait.Controllable;
|
||||
import net.citizensnpcs.trait.CurrentLocation;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.trait.ShopTrait;
|
||||
import net.citizensnpcs.util.ChunkCoord;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
|
@ -493,6 +494,9 @@ public class EventListen implements Listener {
|
|||
if (npc.hasTrait(CommandTrait.class)) {
|
||||
npc.getTraitNullable(CommandTrait.class).dispatch(player, CommandTrait.Hand.RIGHT);
|
||||
}
|
||||
if (npc.hasTrait(ShopTrait.class)) {
|
||||
npc.getTraitNullable(ShopTrait.class).onRightClick(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
|
|
|
@ -1523,7 +1523,7 @@ public class NPCCommands {
|
|||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
modifiers = { "name" },
|
||||
modifiers = { "name", "hidename" },
|
||||
usage = "name (-h(over))",
|
||||
desc = "Toggle nameplate visibility, or only show names on hover",
|
||||
min = 1,
|
||||
|
|
|
@ -68,9 +68,18 @@ public class ShopTrait extends Trait {
|
|||
return StoredShops.GLOBAL_SHOPS.computeIfAbsent(name, NPCShop::new);
|
||||
}
|
||||
|
||||
public void onRightClick(Player player) {
|
||||
NPCShop shop = getDefaultShop();
|
||||
if (shop.openOnRightClick) {
|
||||
shop.display(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static class NPCShop {
|
||||
@Persist(value = "")
|
||||
private String name;
|
||||
@Persist
|
||||
private boolean openOnRightClick;
|
||||
@Persist(reify = true)
|
||||
private final List<NPCShopPage> pages = Lists.newArrayList();
|
||||
@Persist
|
||||
|
@ -497,6 +506,7 @@ public class ShopTrait extends Trait {
|
|||
this.ctx = ctx;
|
||||
ctx.getSlot(2).setDescription("<f>Edit shop view permission<br>" + shop.getRequiredPermission());
|
||||
ctx.getSlot(6).setDescription("<f>Edit shop title<br>" + shop.title);
|
||||
ctx.getSlot(8).setDescription("<f>Show shop on right click<br>" + shop.openOnRightClick);
|
||||
}
|
||||
|
||||
@MenuSlot(slot = { 0, 4 }, material = Material.FEATHER, amount = 1, title = "<f>Edit shop items")
|
||||
|
@ -529,6 +539,13 @@ public class ShopTrait extends Trait {
|
|||
Choice.of(ShopType.COMMAND, Material.ENDER_EYE, "Clicks trigger commands only",
|
||||
shop.type == ShopType.COMMAND)));
|
||||
}
|
||||
|
||||
@MenuSlot(slot = { 0, 8 }, material = Material.COMMAND_BLOCK, amount = 1)
|
||||
public void onToggleRightClick(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
|
||||
event.setCancelled(true);
|
||||
shop.openOnRightClick = !shop.openOnRightClick;
|
||||
ctx.getSlot(8).setDescription("<f>Show shop on right click<br>" + shop.openOnRightClick);
|
||||
}
|
||||
}
|
||||
|
||||
@Menu(title = "Shop", type = InventoryType.CHEST, dimensions = { 5, 9 })
|
||||
|
|
|
@ -27,6 +27,7 @@ public enum PlayerAnimation {
|
|||
START_ELYTRA,
|
||||
START_USE_MAINHAND_ITEM,
|
||||
START_USE_OFFHAND_ITEM,
|
||||
STOP_ELYTRA,
|
||||
STOP_SITTING,
|
||||
STOP_SLEEPING,
|
||||
STOP_SNEAKING,
|
||||
|
|
|
@ -37,6 +37,9 @@ public class PlayerAnimationImpl {
|
|||
case START_ELYTRA:
|
||||
player.M();
|
||||
break;
|
||||
case STOP_ELYTRA:
|
||||
player.N();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.c(EnumHand.MAIN_HAND);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
|
|
|
@ -27,6 +27,9 @@ public class PlayerAnimationImpl {
|
|||
case START_ELYTRA:
|
||||
player.M();
|
||||
break;
|
||||
case STOP_ELYTRA:
|
||||
player.N();
|
||||
break;
|
||||
case SLEEP:
|
||||
PacketPlayOutBed packet = new PacketPlayOutBed(player,
|
||||
new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
|
||||
|
|
|
@ -37,6 +37,9 @@ public class PlayerAnimationImpl {
|
|||
case START_ELYTRA:
|
||||
player.N();
|
||||
break;
|
||||
case STOP_ELYTRA:
|
||||
player.O();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.c(EnumHand.MAIN_HAND);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
|
|
|
@ -37,6 +37,9 @@ public class PlayerAnimationImpl {
|
|||
case START_ELYTRA:
|
||||
player.J();
|
||||
break;
|
||||
case STOP_ELYTRA:
|
||||
player.K();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.c(EnumHand.MAIN_HAND);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
|
|
|
@ -40,6 +40,9 @@ public class PlayerAnimationImpl {
|
|||
case START_ELYTRA:
|
||||
player.J();
|
||||
break;
|
||||
case STOP_ELYTRA:
|
||||
player.K();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.c(EnumHand.MAIN_HAND);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
|
|
|
@ -40,6 +40,9 @@ public class PlayerAnimationImpl {
|
|||
case START_ELYTRA:
|
||||
player.startGliding();
|
||||
break;
|
||||
case STOP_ELYTRA:
|
||||
player.stopGliding();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.c(EnumHand.MAIN_HAND);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
|
|
|
@ -40,6 +40,9 @@ public class PlayerAnimationImpl {
|
|||
case START_ELYTRA:
|
||||
player.startGliding();
|
||||
break;
|
||||
case STOP_ELYTRA:
|
||||
player.stopGliding();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.c(EnumHand.MAIN_HAND);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
|
|
|
@ -33,6 +33,9 @@ public class PlayerAnimationImpl {
|
|||
case START_ELYTRA:
|
||||
player.startFallFlying();
|
||||
break;
|
||||
case STOP_ELYTRA:
|
||||
player.stopFallFlying();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.startUsingItem(InteractionHand.MAIN_HAND);
|
||||
sendPacketNearby(new ClientboundSetEntityDataPacket(player.getId(), player.getEntityData(), true),
|
||||
|
|
|
@ -33,6 +33,9 @@ public class PlayerAnimationImpl {
|
|||
case START_ELYTRA:
|
||||
player.startFallFlying();
|
||||
break;
|
||||
case STOP_ELYTRA:
|
||||
player.stopFallFlying();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.startUsingItem(InteractionHand.MAIN_HAND);
|
||||
sendPacketNearby(new ClientboundSetEntityDataPacket(player.getId(), player.getEntityData(), true),
|
||||
|
|
|
@ -33,6 +33,9 @@ public class PlayerAnimationImpl {
|
|||
case START_ELYTRA:
|
||||
player.startFallFlying();
|
||||
break;
|
||||
case STOP_ELYTRA:
|
||||
player.stopFallFlying();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.startUsingItem(InteractionHand.MAIN_HAND);
|
||||
sendPacketNearby(new ClientboundSetEntityDataPacket(player.getId(), player.getEntityData(), true),
|
||||
|
|
Loading…
Reference in New Issue