Commits
1 - | --- /home/matt/mc-dev-private//net/minecraft/server/PlayerList.java 2015-03-08 10:28:09.527576065 +0000 |
2 - | +++ src/main/java/net/minecraft/server/PlayerList.java 2015-03-08 10:28:09.531576065 +0000 |
1 + | --- /home/matt/mc-dev-private//net/minecraft/server/PlayerList.java 2015-03-08 10:56:47.731557415 +0000 |
2 + | +++ src/main/java/net/minecraft/server/PlayerList.java 2015-03-08 10:56:47.735557415 +0000 |
3 3 | |
4 4 | import org.apache.logging.log4j.LogManager; |
5 5 | import org.apache.logging.log4j.Logger; |
6 6 | |
7 7 | +// CraftBukkit start |
8 8 | +import org.bukkit.craftbukkit.CraftServer; |
9 9 | +import org.bukkit.craftbukkit.CraftWorld; |
10 10 | +import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor; |
11 11 | + |
12 12 | +import org.bukkit.Bukkit; |
360 360 | entityplayer.u().getPlayerChunkMap().removePlayer(entityplayer); |
361 361 | this.players.remove(entityplayer); |
362 362 | this.server.getWorldServer(entityplayer.dimension).removeEntity(entityplayer); |
363 363 | BlockPosition blockposition = entityplayer.getBed(); |
364 364 | boolean flag1 = entityplayer.isRespawnForced(); |
365 365 | |
366 366 | + /* CraftBukkit start |
367 367 | entityplayer.dimension = i; |
368 368 | Object object; |
369 369 | |
370 - | |
370 + | |
371 371 | } |
372 372 | |
373 373 | EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object); |
374 374 | - |
375 375 | + // */ |
376 376 | + EntityPlayer entityplayer1 = entityplayer; |
377 377 | + org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld(); |
378 378 | + entityplayer.viewingCredits = false; |
379 379 | + // CraftBukkit end |
380 380 | + |
434 434 | |
435 435 | - while (!worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()).isEmpty() && entityplayer1.locY < 256.0D) { |
436 436 | + while (avoidSuffocation && !worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()).isEmpty() && entityplayer1.locY < 256.0D) { |
437 437 | entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ); |
438 438 | } |
439 439 | - |
440 440 | - entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.dimension, entityplayer1.world.getDifficulty(), entityplayer1.world.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode())); |
441 441 | + // CraftBukkit start |
442 442 | + byte actualDimension = (byte) (worldserver.getWorld().getEnvironment().getId()); |
443 443 | + // Force the client to refresh their chunk cache |
444 - | + entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn((byte) (actualDimension >= 0 ? -1 : 0), worldserver.getDifficulty(), worldserver.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode())); |
444 + | + if (fromWorld.getEnvironment() == worldserver.getWorld().getEnvironment()) { |
445 + | + entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn((byte) (actualDimension >= 0 ? -1 : 0), worldserver.getDifficulty(), worldserver.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode())); |
446 + | + } |
445 447 | + entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(actualDimension, worldserver.getDifficulty(), worldserver.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode())); |
446 448 | + entityplayer1.spawnIn(worldserver); |
447 449 | + entityplayer1.dead = false; |
448 450 | + entityplayer1.playerConnection.teleport(new Location(worldserver.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch)); |
449 451 | + entityplayer1.setSneaking(false); |
450 452 | blockposition1 = worldserver.getSpawn(); |
451 453 | - entityplayer1.playerConnection.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); |
452 454 | + // entityplayer1.playerConnection.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); |
453 455 | entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition1)); |
454 456 | entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel)); |
667 669 | worldserver.methodProfiler.a("moving"); |
668 670 | + */ |
669 671 | + entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); |
670 672 | + if (entity.isAlive()) { |
671 673 | + worldserver.entityJoinedWorld(entity, false); |
672 674 | + } |
673 675 | + /* |
674 676 | if (entity.dimension == -1) { |
675 677 | d0 = MathHelper.a(d0 / d2, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D); |
676 678 | d1 = MathHelper.a(d1 / d2, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); |
677 - | |
679 + | |
678 680 | BlockPosition blockposition; |
679 681 | |
680 682 | if (i == 1) { |
681 683 | + // use default NORMAL world spawn instead of target |
682 684 | + worldserver1 = this.server.worlds.get(0); |
683 685 | blockposition = worldserver1.getSpawn(); |
684 686 | } else { |
685 687 | blockposition = worldserver1.getDimensionSpawn(); |
686 - | |
688 + | |
687 689 | worldserver.entityJoinedWorld(entity, false); |
688 690 | } |
689 691 | } |
690 692 | + */ |
691 693 | |
692 694 | worldserver.methodProfiler.b(); |
693 695 | if (i != 1) { |
694 696 | worldserver.methodProfiler.a("placing"); |
695 697 | + /* |
696 698 | d0 = (double) MathHelper.clamp((int) d0, -29999872, 29999872); |
705 707 | + Vector velocity = entity.getBukkitEntity().getVelocity(); |
706 708 | + worldserver1.getTravelAgent().adjustExit(entity, exit, velocity); |
707 709 | + entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); |
708 710 | + if (entity.motX != velocity.getX() || entity.motY != velocity.getY() || entity.motZ != velocity.getZ()) { |
709 711 | + entity.getBukkitEntity().setVelocity(velocity); |
710 712 | + } |
711 713 | + } |
712 714 | worldserver1.addEntity(entity); |
713 715 | worldserver1.entityJoinedWorld(entity, false); |
714 716 | } |
715 - | |
717 + | |
716 718 | } |
717 719 | |
718 720 | entity.spawnIn(worldserver1); |
719 721 | + // CraftBukkit end |
720 722 | } |
721 723 | |
722 724 | public void tick() { |
723 - | |
725 + | |
724 726 | |
725 727 | } |
726 728 | |
727 729 | + // CraftBukkit start - add a world limited version |
728 730 | + public void sendAll(Packet packet, World world) { |
729 731 | + for (int i = 0; i < world.players.size(); ++i) { |
730 732 | + ((EntityPlayer) this.players.get(i)).playerConnection.sendPacket(packet); |
731 733 | + } |
732 734 | + |
733 735 | + } |
734 736 | + // CraftBukkit end |
735 737 | + |
736 738 | public void a(Packet packet, int i) { |
737 739 | for (int j = 0; j < this.players.size(); ++j) { |
738 740 | EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); |
739 - | |
741 + | |
740 742 | |
741 743 | public void addOp(GameProfile gameprofile) { |
742 744 | this.operators.add(new OpListEntry(gameprofile, this.server.p())); |
743 745 | + |
744 746 | + // CraftBukkit start |
745 747 | + Player player = server.server.getPlayer(gameprofile.getId()); |
746 748 | + if (player != null) { |
747 749 | + player.recalculatePermissions(); |
748 750 | + } |
749 751 | + // CraftBukkit end |
754 756 | + |
755 757 | + // CraftBukkit start |
756 758 | + Player player = server.server.getPlayer(gameprofile.getId()); |
757 759 | + if (player != null) { |
758 760 | + player.recalculatePermissions(); |
759 761 | + } |
760 762 | + // CraftBukkit end |
761 763 | } |
762 764 | |
763 765 | public boolean isWhitelisted(GameProfile gameprofile) { |
764 - | |
766 + | |
765 767 | } |
766 768 | |
767 769 | public boolean isOp(GameProfile gameprofile) { |
768 770 | - return this.operators.d(gameprofile) || this.server.S() && this.server.worldServer[0].getWorldData().v() && this.server.R().equalsIgnoreCase(gameprofile.getName()) || this.t; |
769 771 | + return this.operators.d(gameprofile) || this.server.S() && this.server.worlds.get(0).getWorldData().v() && this.server.R().equalsIgnoreCase(gameprofile.getName()) || this.t; // CraftBukkit |
770 772 | } |
771 773 | |
772 774 | public EntityPlayer getPlayer(String s) { |
773 - | |
775 + | |
774 776 | for (int j = 0; j < this.players.size(); ++j) { |
775 777 | EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); |
776 778 | |
777 779 | + // CraftBukkit start - Test if player receiving packet can see the source of the packet |
778 780 | + if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { |
779 781 | + continue; |
780 782 | + } |
781 783 | + // CraftBukkit end |
782 784 | + |
783 785 | if (entityplayer != entityhuman && entityplayer.dimension == i) { |
784 786 | double d4 = d0 - entityplayer.locX; |
785 787 | double d5 = d1 - entityplayer.locY; |
786 - | |
788 + | |
787 789 | public void reloadWhitelist() {} |
788 790 | |
789 791 | public void b(EntityPlayer entityplayer, WorldServer worldserver) { |
790 792 | - WorldBorder worldborder = this.server.worldServer[0].getWorldBorder(); |
791 793 | + WorldBorder worldborder = entityplayer.world.getWorldBorder(); // CraftBukkit |
792 794 | |
793 795 | entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE)); |
794 796 | entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))); |
795 797 | if (worldserver.S()) { |
796 798 | - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F)); |
808 810 | } |
809 811 | |
810 812 | public void updateClient(EntityPlayer entityplayer) { |
811 813 | entityplayer.updateInventory(entityplayer.defaultContainer); |
812 814 | - entityplayer.triggerHealthUpdate(); |
813 815 | + // entityplayer.triggerHealthUpdate(); |
814 816 | + entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange |
815 817 | entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); |
816 818 | } |
817 819 | |
818 - | |
820 + | |
819 821 | } |
820 822 | |
821 823 | public String[] getSeenPlayers() { |
822 824 | - return this.server.worldServer[0].getDataManager().getPlayerFileData().getSeenPlayers(); |
823 825 | + return this.server.worlds.get(0).getDataManager().getPlayerFileData().getSeenPlayers(); // CraftBukkit |
824 826 | } |
825 827 | |
826 828 | public boolean getHasWhitelist() { |
827 - | |
829 + | |
828 830 | |
829 831 | public void u() { |
830 832 | for (int i = 0; i < this.players.size(); ++i) { |
831 833 | - ((EntityPlayer) this.players.get(i)).playerConnection.disconnect("Server closed"); |
832 834 | + ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message |
833 835 | } |
834 836 | |
835 837 | } |
836 838 | |
837 839 | + // CraftBukkit start |
846 848 | this.server.sendMessage(ichatbasecomponent); |
847 849 | int i = flag ? 1 : 0; |
848 850 | |
849 851 | - this.sendAll(new PacketPlayOutChat(ichatbasecomponent, (byte) i)); |
850 852 | + // CraftBukkit start - we run this through our processor first so we can get web links etc |
851 853 | + this.sendAll(new PacketPlayOutChat(CraftChatMessage.fixComponent(ichatbasecomponent), (byte) i)); |
852 854 | + // CraftBukkit end |
853 855 | } |
854 856 | |
855 857 | public void sendMessage(IChatBaseComponent ichatbasecomponent) { |
856 - | |
858 + | |
857 859 | WorldServer[] aworldserver = this.server.worldServer; |
858 860 | int j = aworldserver.length; |
859 861 | |
860 862 | - for (int k = 0; k < j; ++k) { |
861 863 | - WorldServer worldserver = aworldserver[k]; |
862 864 | + // CraftBukkit start |
863 865 | + for (int k = 0; k < server.worlds.size(); ++k) { |
864 866 | + WorldServer worldserver = server.worlds.get(0); |
865 867 | + // CraftBukkit end |
866 868 | |