Freezing & Alignment of player

Discussion in 'Plugin Development' started by Pymous, May 22, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Pymous

    Hello fellows !

    First of all, i'm French, so i'm sorry for my poor english !

    Second, it's also my first 'work' on Java, so my post will certainly be a bit... hard to follow !

    But i will try my best, and again, sorry :)


    So ! I'm working on this plugin, wich allow admins to 'manage' people during event, by freezing a list of players, teleporting them, ... mass give, ...

    But i'm a bit stucked with 2 things !

    1*/ I'd like to teleport every player from a list in front of the admin who enter a specific command and align them ! But i don't really understand the vector & location stuff in MC !

    Just like that:
    [​IMG]

    So I tried to write a small code, and thanks to someone on the IRC (I think it was 'TomyLobo' :) ), i can tp every player of my list in front of the player, but at the same spot !

    Here is the snippet:

    Code:
    // adminLoc is a Direction wich contain the admin location
    // target is a Player entity in my for wich contain the actual player in the loop
    Vector inFront = adminLoc.toVector().add(adminLoc.getDirection().multiply(5));
    target.teleport(inFront.toLocation(player.getWorld()));
    
    I tried different things, but I can't align every player correctly ! :(

    2*/ I need to be able to 'froze' players in the list but still alowing them to move the view, and i found out how, by doing this:
    Code:
        public void onPlayerMove(PlayerMoveEvent event) {
            Player player = event.getPlayer();
            Location fromLoc = event.getFrom();
            Location toLoc = event.getTo();
            if (plugin.checkPlayer(player) && plugin.freezed) {
                player.setFallDistance(0);
                if (toLoc.getX() != fromLoc.getX() || toLoc.getY() != fromLoc.getY() || toLoc.getZ() != fromLoc.getZ()) {
                    toLoc.setX(fromLoc.getX());
                    toLoc.setY(fromLoc.getY());
                    toLoc.setZ(fromLoc.getZ());
                    player.sendMessage("[CrowdControl] Don't move !");
                    event.setCancelled(true);
                    player.teleport(toLoc);
                }
            }
        }
    But theyre is a small flaw in this... if I freeze a player while he's jumping, or falling, he's view keep alternate between the fromLoc to the toLoc (it's normal, he's falling...) and the message is spammed.

    So I'm looking for a way to "land" the player, but since I'm quit bad with the Location thing, i need help for that part too !

    Thanks in advance for your awesome help, I already had been superbly supported on IRC, and I thanks every single people who helped me until now :)

    And again, sorry for my poor english ! :)
     
Thread Status:
Not open for further replies.

Share This Page