#Runnable problem

1 messages · Page 1 of 1 (latest)

rancid zealot
#

anyone can help ?

opaque shuttle
#

The record is null?

rancid zealot
#

i want a simple record system

#

record get started with /record start and stop with /record stop

#

when plugin is recording, record my locations, and on stop get stopped and do not save any more locations

#

then on /record play, create a npc with my name, and play where i moved ( each tick has a location )

#
    public static void addNPCPacket(EntityPlayer npc, Player player) {
        PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
        connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
        connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
        connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (npc.yaw * 256 / 360)));
    }

    public static void removeNPCPacket(Entity npc, Player player) {
        PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
        connection.sendPacket(new PacketPlayOutEntityDestroy(npc.getId()));
    }

    public static void lookNPCPacket(Entity npc, Player player, float yaw, float pitch) {
        PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
        connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (yaw * 256 / 360)));
        connection.sendPacket(new PacketPlayOutEntity.PacketPlayOutEntityLook(npc.getId(), (byte) (yaw * 256 / 360), (byte) (pitch * 256 / 360), true));
    }

    public static void sendMoveEntityPacket(Entity entity, Player player, double x, double y, double z) {
        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntity.PacketPlayOutRelEntityMove(entity.getId(), (short) (x * 4096), (short) (y * 4096), (short) (z * 4096), true));
    }
#
        if (args[0].equalsIgnoreCase("start")) {

            BukkitTask record = new BukkitRunnable() {

                int count = 0;

                @Override
                public void run() {

                    locations[count] = player.getLocation();

                    Utils.sendActionbar(player, "&dRecorded " + String.valueOf(count) + " &dticks");

                    count++;

                    if (count == 100) {
                        cancel();
                    }

                }

            }.runTaskTimer(Main.getInstance(), 1, 1);

        }

        if (args[0].equalsIgnoreCase(("play"))) {

            Utils.addNPCPacket(npc, player);

            BukkitTask record = new BukkitRunnable() {

                int count = 0;

                @Override
                public void run() {

                    Utils.sendActionbar(player, "&dPlayed " + String.valueOf(count) + " &dticks");
                    Utils.sendMoveEntityPacket(npc, player, locations[count].getX(), locations[count].getY(), locations[count].getZ());

                    count++;

                    if (count == 100) {
                        cancel();
                    }

                }

            }.runTaskTimer(Main.getInstance(), 1, 1);

        }

        return false;

    }
opaque shuttle
#

It'd help a lot if you could paste each class into pastebin

rancid zealot
#

this is better now i think

opaque shuttle
#

I'd rather not download anything.

rancid zealot
#

wait