Ir para conteúdo
  • 0

[Dúvida] Máximo de players em tal área do WorldGuard!


Lelfe

Pergunta

então... é o seguinte..


to fazendo um pl de arenas, um kibe do skysurvival... blz.


já fiz "tudo", só ta falando isso aqui: ** prnt.sc/f1urfb ** de colocar o máximo de players em tal arena (area do worldguard).


 


eu fá fiz pra criar a region (arena), mas eu queria colocar um máximo de players nessa arena (area do worldguard).


 

acho que deu para entender ;/

 

 

Código que to usando para criar a arena (area do worldguard)

 



if(args[0].equalsIgnoreCase("saara") && args.length == 1){

Selection sel = getWE().getSelection(p);

if(sel == null){
p.sendMessage("§c");
p.sendMessage("§6Marque toda a região da arena antes de seta-la!");
p.sendMessage("§f* Use o WorldEdit para isso.");
p.sendMessage("§c");
return true;
}





ProtectedCuboidRegion region = new ProtectedCuboidRegion("arena-saara",
new com.sk89q.worldedit.BlockVector(sel.getNativeMinimumPoint()),
new com.sk89q.worldedit.BlockVector(sel.getNativeMaximumPoint()));


getWG().getRegionManager(p.getWorld()).addRegion(region);



fc.set("Arenas." + saara + ".Mundo", p.getWorld().getName());
fc.set("Arenas." + saara + ".Y", Double.valueOf(loc.getY()));
fc.set("Arenas." + saara + ".X", Double.valueOf(loc.getX()));
fc.set("Arenas." + saara + ".Z", Double.valueOf(loc.getZ()));
fc.set("Arenas." + saara + ".Yaw", Float.valueOf(loc.getYaw()));
fc.set("Arenas." + saara + ".Pitch", Float.valueOf(loc.getPitch()));

p.sendMessage("§eArena §fSaara §esetada com sucesso.");

try{
fc.save(f);
}catch (IOException e){
e.printStackTrace();
}
return false;
}


 


tá funcionando de boa até ;-;

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

Eu não usaria worldguard, não gosto de criar plugins com dependência de outros..

 

eu não sei como, mas se você descobrir como pegar a Location do minimumPoint e do maximumPoint, poderá usar isso

 

 

    private List<Player> getPlayers(Location l1, Location l2){
        List<Player> toReturn = new ArrayList<>();

        int x_lower = l1.getBlockX() <= l2.getBlockX() ? l1.getBlockX() : l2.getBlockX();
        int x_higher = l1.getBlockX() <= l2.getBlockX() ? l1.getBlockX() : l2.getBlockX();

        int y_lower = l1.getBlockY() <= l2.getBlockY() ? l1.getBlockY() : l2.getBlockY();
        int y_higher = l1.getBlockY() <= l2.getBlockY() ? l1.getBlockY() : l2.getBlockY();

        int z_lower = l1.getBlockZ() <= l2.getBlockZ() ? l1.getBlockZ() : l2.getBlockZ();
        int z_higher = l1.getBlockZ() <= l2.getBlockZ() ? l1.getBlockZ() : l2.getBlockZ();

        for(int x = x_lower; x < x_higher; x += 16){
            for(int z = z_lower; z < z_higher; z += 16){

                Chunk chunk = new Location(l1.getWorld(), x, 50, z).getChunk();
                for(Entity entity : chunk.getEntities()){
                    if(entity.getType() != EntityType.PLAYER) continue;
                    if(entity.getLocation().getBlockX() < x_lower || entity.getLocation().getBlockX() > x_higher) continue;
                    if(entity.getLocation().getBlockY() < y_lower || entity.getLocation().getBlockY() > y_higher) continue;
                    if(entity.getLocation().getBlockZ() < z_lower || entity.getLocation().getBlockZ() > z_higher) continue;

                    toReturn.add((Player)entity);
                }

            }
        }

        return toReturn;
    } 

Ou então não use worldguard..

 

 

 

Ae usa getPlayers().size() para pegar quantos jogadores estão na arena

 

@Edit

achei como usar worldguard (mesmo assim eu não usaria :p)

 

 

    private int getPlayerCount(World world, String id){
        RegionManager regionManager = WorldGuardPlugin.inst().getRegionContainer().get(world);
        if(regionManager == null) return 0;

        ProtectedRegion region = regionManager.getRegion(id);
        if(region == null) return 0;

        Location l1 = new Location(world, region.getMinimumPoint().getBlockX(), region.getMinimumPoint().getBlockY(), region.getMinimumPoint().getBlockZ());
        Location l2 = new Location(world, region.getMaximumPoint().getBlockX(), region.getMaximumPoint().getBlockY(), region.getMaximumPoint().getBlockZ());

        return getPlayers(l1, l2).size();
    } 

 

 

 

Depois disso, só usar

int playersInSaara = getPlayerCount(world, "saara");
Editado por zAth
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...