Solved Constructors

Discussion in 'Plugin Development' started by TerroDoor, Nov 18, 2019.

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

    TerroDoor

    @timtower
    Code:
     ArrayList<UUID> inspawn = new ArrayList<UUID>();
    
     public boolean inSpawn(Location ploc) {
     if (ploc == null) {
     return false;
     } else {
     return ploc.getBlockX() >= pos1.getBlockX() && ploc.getBlockX() <= pos2.getBlockX()
     && ploc.getBlockY() >= pos1.getBlockY() && ploc.getBlockY() <= pos2.getBlockY()
     && ploc.getBlockZ() >= pos1.getBlockZ() && ploc.getBlockZ() <= pos2.getBlockZ();
     }
     }
     public spawnregion() {
     double minx = Math.min(pos1.getBlockX(), pos2.getBlockX());
     double maxx = Math.max(pos1.getBlockX(), pos2.getBlockX());
     double minz = Math.min(pos1.getBlockZ(), pos2.getBlockZ());
     double maxz = Math.max(pos1.getBlockZ(), pos2.getBlockZ());
     double miny = Math.min(pos1.getBlockY(), pos2.getBlockY());
     double maxy = Math.max(pos1.getBlockY(), pos2.getBlockY());
     this.pos1 = new Vector(minx, miny, minz);
     this.pos2 = new Vector(maxx, maxy, maxz);
     for (double x = minx; x <= maxx; x++) {
     for (double y = miny; y <= maxy; y++) {
     for (double z = minz; z <= maxz; z++) {
     Location loc = new Location(w, x, y, z);
     if (x == minx && x == maxx && z == minz && z == maxz) {
     loc.getBlock().setType(Material.BLACK_WOOL);
     } else {
     loc.getBlock().setType(Material.AIR);
     }
     }
     }
     }
     return;
     }
     @EventHandler
     public void onMove(PlayerMoveEvent e) {
     Player p = (Player)e.getPlayer();
     Vector pvec = p.getLocation().toVector();
     
     if (pvec.isInAABB(pos1, pos2)) {
     
     p.sendMessage("in");
     inspawn.add(p.getUniqueId());
     return;
     } else {
     
     p.sendMessage("out");
     inspawn.remove(p.getUniqueId());
     return;
     }
     }
    
    
     
  2. Online

    timtower Moderator Moderator

    @TerroDoor You don't check the inspawn list for the message
     
  3. Offline

    TerroDoor

    If inSpawn.contains?


    Sent from my iPhone using Tapatalk
     
  4. Online

    timtower Moderator Moderator

  5. Offline

    TerroDoor

    @timtower
    Thankyou so much, I’ve finally got it working! Marking thread as solved


    Sent from my iPhone using Tapatalk
     
    timtower likes this.
Thread Status:
Not open for further replies.

Share This Page