Search in sources :

Example 1 with PlayerConnection

use of net.minecraft.server.v1_12_R1.PlayerConnection in project DragonsOnline by UniverseCraft.

the class PlayerNPC116R3 method spawn.

public void spawn() {
    registry.unregister(this);
    uuid = UUID.randomUUID();
    this.isDestroyed = false;
    DedicatedServer server = ((CraftServer) Bukkit.getServer()).getServer();
    WorldServer world = ((CraftWorld) location.getWorld()).getHandle();
    // displayName);
    GameProfile gameProfile = new GameProfile(uuid, "");
    gameProfile.getProperties().clear();
    gameProfile.getProperties().put("textures", new Property("textures", texture, signature));
    this.handle = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));
    handle.persist = true;
    handle.collides = false;
    handle.setCustomNameVisible(false);
    handle.setInvulnerable(npc.isImmortal());
    handle.playerConnection = new PlayerConnection(((CraftServer) Bukkit.getServer()).getServer(), new NetworkManager(EnumProtocolDirection.SERVERBOUND), handle);
    ((CraftWorld) location.getWorld()).addEntity(handle, CreatureSpawnEvent.SpawnReason.CUSTOM);
    handle.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    registry.register(this);
    for (Entity e : getEntity().getNearbyEntities(SPAWN_RADIUS, SPAWN_RADIUS, SPAWN_RADIUS)) {
        if (e instanceof Player) {
            registry.updateSpawns((Player) e, true);
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) PacketPlayOutEntity(net.minecraft.server.v1_16_R3.PacketPlayOutEntity) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) GameProfile(com.mojang.authlib.GameProfile) PlayerInteractManager(net.minecraft.server.v1_16_R3.PlayerInteractManager) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) DedicatedServer(net.minecraft.server.v1_16_R3.DedicatedServer) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer) NetworkManager(net.minecraft.server.v1_16_R3.NetworkManager) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) Property(com.mojang.authlib.properties.Property) PlayerConnection(net.minecraft.server.v1_16_R3.PlayerConnection)

Example 2 with PlayerConnection

use of net.minecraft.server.v1_12_R1.PlayerConnection in project THP-Engine by TheHollowPlanetMC.

the class FlyPacketHandler method rewrite.

@Override
public Object rewrite(Object packet, EnginePlayer EnginePlayer, boolean cacheSetting) {
    ParallelUniverse universe = EnginePlayer.getUniverse();
    if (universe == null)
        return packet;
    World world = EnginePlayer.getBukkitPlayer().getWorld();
    String worldName = world.getName();
    ParallelWorld parallelWorld = universe.getWorld(worldName);
    EntityPlayer entityPlayer = ((CraftPlayer) EnginePlayer.getBukkitPlayer()).getHandle();
    int x = NumberConversions.floor(entityPlayer.locX());
    int y = NumberConversions.floor(entityPlayer.locY());
    int z = NumberConversions.floor(entityPlayer.locZ());
    int downY = y - 1;
    downY = Math.max(0, downY);
    if (parallelWorld.hasBlockData(x, y, z) || parallelWorld.hasBlockData(x, downY, z)) {
        try {
            PlayerConnection playerConnection = entityPlayer.playerConnection;
            C.set(playerConnection, 0);
            E.set(playerConnection, 0);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return packet;
}
Also used : ParallelWorld(thpmc.engine.api.world.parallel.ParallelWorld) ParallelUniverse(thpmc.engine.api.world.parallel.ParallelUniverse) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) World(org.bukkit.World) ParallelWorld(thpmc.engine.api.world.parallel.ParallelWorld) PlayerConnection(net.minecraft.server.v1_15_R1.PlayerConnection)

Example 3 with PlayerConnection

use of net.minecraft.server.v1_12_R1.PlayerConnection in project HitW-plugin by Blackoutburst.

the class GameUtils method sendTitle.

public static void sendTitle(Player player, String title, String subtitle, int fadeIn, int stay, int fadeOut) {
    CraftPlayer craftplayer = (CraftPlayer) player;
    PlayerConnection connection = craftplayer.getHandle().playerConnection;
    IChatBaseComponent titleJSON = ChatSerializer.a("{'text': '" + title + "'}");
    IChatBaseComponent subtitleJSON = ChatSerializer.a("{'text': '" + subtitle + "'}");
    PacketPlayOutTitle timePacket = new PacketPlayOutTitle(fadeIn, stay, fadeOut);
    PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleJSON);
    PacketPlayOutTitle subtitlePacket = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, subtitleJSON);
    connection.sendPacket(timePacket);
    connection.sendPacket(titlePacket);
    connection.sendPacket(subtitlePacket);
}
Also used : PacketPlayOutTitle(net.minecraft.server.v1_8_R3.PacketPlayOutTitle) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) IChatBaseComponent(net.minecraft.server.v1_8_R3.IChatBaseComponent) PlayerConnection(net.minecraft.server.v1_8_R3.PlayerConnection)

Example 4 with PlayerConnection

use of net.minecraft.server.v1_12_R1.PlayerConnection in project SkinChangerAPI by gabrielmercier.

the class SkinChangerAPI method change.

/**
 * Change the player skin.
 *
 * @param player       The targeted player.
 * @param skinProperty The property of the new player's skin.
 */
public static void change(Player player, Property skinProperty) {
    // Init the player's connection
    GameProfile profile = ((CraftPlayer) player).getHandle().getProfile();
    PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
    // Send the packets
    connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, ((CraftPlayer) player).getHandle()));
    profile.getProperties().removeAll("textures");
    profile.getProperties().put("textures", skinProperty);
    connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ((CraftPlayer) player).getHandle()));
}
Also used : GameProfile(com.mojang.authlib.GameProfile) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo) PlayerConnection(net.minecraft.server.v1_8_R3.PlayerConnection)

Example 5 with PlayerConnection

use of net.minecraft.server.v1_12_R1.PlayerConnection in project WLib by WizardlyBump17.

the class EntityAdapter method sendPacket.

@Override
public void sendPacket(Object... packets) {
    if (!(entity instanceof Player))
        return;
    EntityPlayer player = ((CraftPlayer) entity).getHandle();
    PlayerConnection connection = player.playerConnection;
    for (Object packet : packets) {
        if (!(packet instanceof Packet))
            continue;
        connection.sendPacket(((Packet<?>) packet));
    }
}
Also used : Packet(net.minecraft.server.v1_12_R1.Packet) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) PlayerConnection(net.minecraft.server.v1_12_R1.PlayerConnection)

Aggregations

Player (org.bukkit.entity.Player)6 EntityPlayer (net.minecraft.server.v1_16_R3.EntityPlayer)3 PlayerConnection (net.minecraft.server.v1_16_R3.PlayerConnection)3 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)3 GameProfile (com.mojang.authlib.GameProfile)2 PacketPlayOutEntityLook (net.minecraft.server.v1_12_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)2 EntityPlayer (net.minecraft.server.v1_15_R1.EntityPlayer)2 PlayerConnection (net.minecraft.server.v1_15_R1.PlayerConnection)2 PlayerConnection (net.minecraft.server.v1_8_R3.PlayerConnection)2 World (org.bukkit.World)2 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)2 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)2 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)2 ParallelUniverse (thpmc.engine.api.world.parallel.ParallelUniverse)2 ParallelWorld (thpmc.engine.api.world.parallel.ParallelWorld)2 Property (com.mojang.authlib.properties.Property)1 IOException (java.io.IOException)1 Socket (java.net.Socket)1 EmptyNetHandler (net.citizensnpcs.nms.v1_12_R1.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_12_R1.network.EmptyNetworkManager)1