Solved WorldGuard API 6.1

Discussion in 'Spigot Plugin Development' started by KrakenArtz, Feb 8, 2020.

  1. I did a combatlog plugin for my own server and I have 2 regions but one is polygon and other cuboid
    polygon region pvp is disabled and enabled on cuboid.

    Cuboid is check before poly how can I sort the priority to check if the pvp is disabled.


    Code (Text):
    @EventHandler
        public void onHit(EntityDamageByEntityEvent e) {
            if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
                Player p = (Player) e.getEntity();
                Player p1 = (Player) e.getDamager();
                if (p == p1) {
                    return;
                }
                RegionManager rgm = WGBukkit.getRegionManager(p.getWorld());
                if (rgm.getApplicableRegions(p.getLocation()).getRegions() != null) {
                    ApplicableRegionSet regionFrom = rgm.getApplicableRegions(p.getLocation());
                    for (ProtectedRegion r : regionFrom.getRegions()) {
                        if (r.getFlag(DefaultFlag.PVP) == StateFlag.State.ALLOW) {
                            long time = (System.currentTimeMillis() + 15 * 1000L);
                            combat.setTimer(p, time);
                            combat.setTimer(p1, time);
                            combat.setLastEnemy(p, p1);
                            combat.setLastEnemy(p1, p);
                            if (!combat.getIncombat().contains(p1)) {
                                combat.setIncombat(p1);
                            }
                            if (!combat.getIncombat().contains(p)) {
                                combat.setIncombat(p);
                            }
                        }
                    }
                }
            }
        }