Помогите ивент зоны

strifeslider

Активный участник
Баллы
61
Имя в Minecraft
greenelte
мне надо что бы при заходе н-ого количества людей(пусть будет 10) пускался алерт о том что скоро в этой зоне будет пвп(10 секунд до пвп) и как ни странно включалось пвп
 
Посмотри туторы по WorldEdit там есть видео про то, как человек делает зоны, и когда он туда заходит, пишется привет, а когда выходит, пока!
 
Посмотри туторы по WorldEdit там есть видео про то, как человек делает зоны, и когда он туда заходит, пишется привет, а когда выходит, пока!
ты имеешь в виду изменить ивент sendmessage на те которые мне нужны?
P.S. можешь скинуть ссылку?
 
Код:
public class CuboidTask extends BukkitRunnable {
    public Cuboid cuboid;

    public CuboidTask(Cuboid cuboid) {
        this.cuboid = cuboid;
    }

    @Override
    public void run() {
        if(this.cuboid.getPlayerCount()>9) {
            //TODO
        }
    }
}
Код:
package Blank.rg;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;

public class Cuboid {
    private long xMin;
    private long xMax;
    private long yMin;
    private long yMax;
    private long zMin;
    private long zMax;

    public Cuboid(Location loc1, Location loc2) {
        normalize(loc1.getBlockX(), loc1.getBlockY(), loc1.getBlockZ(), loc2.getBlockX(), loc2.getBlockY(),
                loc2.getBlockZ());
    }

    public Cuboid(long x1, long y1, long z1, long x2, long y2, long z2) {
        normalize(x1, y1, z1, x2, y2, z2);
    }

    private void normalize(long x1, long y1, long z1, long x2, long y2, long z2) {
        this.xMin = Math.min(x1, x2);
        this.xMax = Math.max(x1, x2);
        this.yMin = Math.min(y1, y2);
        this.yMax = Math.max(y1, y2);
        this.zMin = Math.min(z1, z2);
        this.zMax = Math.max(z1, z2);
    }

    public boolean intersects(Cuboid cuboid) {
        return cuboid.xMin <= xMax && cuboid.xMax >= xMin && cuboid.yMin <= yMax && cuboid.yMax >= yMin
                && cuboid.zMin <= zMax && cuboid.zMax >= zMin;
    }

    public boolean contains(Location loc) {
        return contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    }

    public boolean contains(long x, long y, long z) {
        return x >= xMin && x <= xMax && y >= yMin && y <= yMax && z >= zMin && z <= zMax;
    }

    public long getVolume() {
        return getWidth() * getHeight() * getDepth();
    }

    public long getWidth() {
        return xMax - xMin + 1;
    }

    public long getHeight() {
        return yMax - yMin + 1;
    }

    public long getDepth() {
        return zMax - zMin + 1;
    }

    @Override
    public String toString() {
        return "Cuboid: " + xMin + "," + yMin + "," + zMin + "=>" + xMax + "," + yMax + "," + zMax;
    }
   
    public int getPlayerCount() {
        int count = 0;
        for(Player player : Bukkit.getOnlinePlayers()) {
            if(this.contains(player.getLocation())) {
                count++;
            }
        }
        return count;
    }
}
 
Назад
Верх