Commits
md_5 authored f7fa6d99351
660 660 | return either; |
661 661 | } |
662 662 | } |
663 663 | - } else { |
664 664 | - return Either.left(EntityHuman.EnumBedResult.OTHER_PROBLEM); |
665 665 | } |
666 666 | + // CraftBukkit end |
667 667 | } |
668 668 | |
669 669 | @Override |
670 - | |
670 + | |
671 671 | |
672 672 | @Override |
673 673 | public void stopSleepInBed(boolean flag, boolean flag1) { |
674 674 | + if (!this.isSleeping()) return; // CraftBukkit - Can't leave bed if not in one! |
675 675 | + // CraftBukkit start - fire PlayerBedLeaveEvent |
676 676 | + CraftPlayer player = this.getBukkitEntity(); |
677 677 | + BlockPosition bedPosition = this.getSleepingPos().orElse(null); |
678 678 | + |
679 679 | + org.bukkit.block.Block bed; |
680 680 | + if (bedPosition != null) { |
685 685 | + |
686 686 | + PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true); |
687 687 | + this.level().getCraftServer().getPluginManager().callEvent(event); |
688 688 | + if (event.isCancelled()) { |
689 689 | + return; |
690 690 | + } |
691 691 | + // CraftBukkit end |
692 692 | if (this.isSleeping()) { |
693 693 | this.serverLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2)); |
694 694 | } |
695 + | |
696 + | super.stopSleepInBed(flag, flag1); |
697 + | if (this.connection != null) { |
698 + | - this.connection.teleport(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); |
699 + | + this.connection.teleport(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot(), TeleportCause.EXIT_BED); // CraftBukkit |
700 + | } |
701 + | |
702 + | } |
695 703 | |
696 704 | this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag)); |
697 705 | } |
698 706 | |
699 707 | - public void nextContainerCounter() { |
700 708 | + public int nextContainerCounter() { // CraftBukkit - void -> int |
701 709 | this.containerCounter = this.containerCounter % 100 + 1; |
702 710 | + return containerCounter; // CraftBukkit |
703 711 | } |
704 712 | |