No Fly Zones

Discussion in 'Plugin Development' started by DreadKyller, May 3, 2011.

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

    DreadKyller

    I am sick and tired of people teleporting to you while working on something secret, I'm sure many others are too.

    I am trying to make a command in which you define two corners at any height and it would prevent any form of teleportation into that area unless that person has been given permission to enter.

    But even after setting the zone It still does not do anything.

    Here is my code:
    PHP:
        public void setNoFly(int x1int z1int x2int z2){
            
    int zam=0;
            
    int xam=0;
            
    int zmove=0;
            
    int xmove=0;
            
    double x=x1;
            
    double z=z1;
            if(
    x1>x2){
                
    xam =(x1-x2);
                
    xmove=-1;
            }
            if(
    x1>x2){
                
    xam=(int) (x2-x1);
                
    xmove=1;
            }
            if(
    z1>z2){
                
    zam=(int) (z1-z2);
                
    zmove=-1;
            }
            if(
    z1>z2){
                
    zam=(int) (z2-z1);
                
    zmove=1;
            }
            for(
    int ix=0ix<xam;ix=ix+xmove){
                
    double nx=x+ix;
                
    this.nofliesx.put(String.valueOf(nx), nx);
            }
            for(
    int iz=0;iz<zam;iz=iz+zmove){
                
    double nz=z+iz;
                
    this.nofliesz.put(String.valueOf(nz), nz);
            }
        }
    What this basically does is adds the x and z positions between both corners into hashmaps on the main.java(my base class), then on player teleport, I get the getTo().getX and getZ() and see if both are in the hashmap (meaning person is in the zone) and if so teleport them back to the getFrom() position and send a message.

    The setting of corners and building of the zone is done by commands.

    However, nothing happens at all.
     
Thread Status:
Not open for further replies.

Share This Page