use of com.griefdefender.lib.flowpowered.math.vector.Vector3i in project BanFromClaim by Baktus79.
the class GDListener method onPlayerEnterClaim.
@EventHandler(ignoreCancelled = true)
public void onPlayerEnterClaim(PlayerMoveEvent e) {
final ClaimData claimData = new ClaimData();
final Location locFrom = e.getFrom();
final Location locTo = e.getTo();
if (locFrom.getBlock().equals(locTo.getBlock())) {
return;
}
final Player player = e.getPlayer();
final Core gd = GriefDefender.getCore();
final Vector3i vectorTo = Vector3i.from(locTo.getBlockX(), locTo.getBlockY(), locTo.getBlockZ());
final Vector3i vectorFrom = Vector3i.from(locFrom.getBlockX(), locFrom.getBlockY(), locFrom.getBlockZ());
final Claim claimTo = gd.getClaimManager(locTo.getWorld().getUID()).getClaimAt(vectorTo);
final Claim claimFrom = gd.getClaimManager(locFrom.getWorld().getUID()).getClaimAt(vectorFrom);
final ParticleHandler ph = new ParticleHandler(e.getTo());
if (locFrom.getBlockX() != locTo.getBlockX() || locFrom.getBlockZ() != locTo.getBlockZ()) {
if (player.hasPermission("bfc.bypass") || player.getGameMode().equals(GameMode.SPECTATOR)) {
return;
}
if (!claimTo.isWilderness()) {
final UUID ownerUUID = claimTo.getOwnerUniqueId();
boolean hasAttacked = false;
if (CombatMode.ATTACKER.containsKey(player.getUniqueId()))
hasAttacked = CombatMode.ATTACKER.get(player.getUniqueId()).equals(ownerUUID);
if ((claimData.isAllBanned(claimTo.getUniqueId().toString()) || playerBanned(player, claimTo)) && !hasAttacked && !hasTrust(player.getUniqueId(), claimTo)) {
if (!claimFrom.isWilderness()) {
if (playerBanned(player, claimFrom)) {
final World world = Bukkit.getWorld(claimFrom.getWorldUniqueId());
final int x = claimFrom.getGreaterBoundaryCorner().getX();
final int z = claimFrom.getGreaterBoundaryCorner().getZ();
final int y = world.getHighestBlockAt(x, z).getY();
final Location tpLoc = new Location(world, x, y, z).add(0D, 1D, 0D);
if (tpLoc.getBlock().getType().equals(Material.AIR)) {
if (Config.SAFE_LOCATION != null) {
player.teleport(Config.SAFE_LOCATION);
} else {
player.teleport(tpLoc.add(0D, 1D, 0D));
}
} else {
player.teleport(tpLoc.add(0D, 1D, 0D));
}
} else {
final Location tpLoc = player.getLocation().add(e.getFrom().toVector().subtract(e.getTo().toVector()).normalize().multiply(3));
if (tpLoc.getBlock().getType().equals(Material.AIR)) {
player.teleport(tpLoc);
} else {
final Location safeLoc = tpLoc.getWorld().getHighestBlockAt(tpLoc).getLocation().add(0D, 1D, 0D);
player.teleport(safeLoc);
}
if (e.getTo().getBlockX() == e.getFrom().getBlockX()) {
ph.drawCircle(1, true);
} else {
ph.drawCircle(1, false);
}
}
} else {
final Location tpLoc = player.getLocation().add(e.getFrom().toVector().subtract(e.getTo().toVector()).normalize().multiply(3));
if (tpLoc.getBlock().getType().equals(Material.AIR)) {
player.teleport(tpLoc);
} else {
final Location safeLoc = tpLoc.getWorld().getHighestBlockAt(tpLoc).getLocation().add(0D, 1D, 0D);
player.teleport(safeLoc);
}
if (e.getTo().getBlockX() == e.getFrom().getBlockX()) {
ph.drawCircle(1, true);
} else {
ph.drawCircle(1, false);
}
}
if (!MessageHandler.spamMessageClaim.contains(player.getUniqueId().toString())) {
MessageHandler.sendTitle(player, Messages.TITLE_MESSAGE, Messages.SUBTITLE_MESSAGE);
MessageHandler.spamMessageClaim.add(player.getUniqueId().toString());
Bukkit.getScheduler().runTaskLater(BfcPlugin.getInstance(), () -> {
MessageHandler.spamMessageClaim.remove(player.getUniqueId().toString());
}, 5L * 20L);
}
}
}
}
}
use of com.griefdefender.lib.flowpowered.math.vector.Vector3i in project GDHooks by bloodmc.
the class DynmapProvider method updateClaimMarker.
private void updateClaimMarker(Claim claim) {
final World world = Bukkit.getWorld(claim.getWorldUniqueId());
if (world == null) {
return;
}
final String worldName = world.getName();
final String owner = claim.getOwnerName();
if (isVisible(claim, owner, worldName)) {
final Vector3i lesserPos = claim.getLesserBoundaryCorner();
final Vector3i greaterPos = claim.getGreaterBoundaryCorner();
final double[] x = new double[4];
final double[] z = new double[4];
x[0] = lesserPos.getX();
z[0] = lesserPos.getZ();
x[1] = lesserPos.getX();
z[1] = greaterPos.getZ() + 1.0;
x[2] = greaterPos.getX() + 1.0;
z[2] = greaterPos.getZ() + 1.0;
x[3] = greaterPos.getX() + 1.0;
z[3] = lesserPos.getZ();
final UUID id = claim.getUniqueId();
final String markerid = "GD_" + id;
AreaMarker marker = this.areaMarkers.remove(markerid);
if (marker == null) {
marker = this.set.createAreaMarker(markerid, owner, false, worldName, x, z, false);
if (marker == null) {
return;
}
} else {
marker.setCornerLocations(x, z);
marker.setLabel(owner);
}
if (this.cfg.use3dRegions) {
marker.setRangeY(greaterPos.getY() + 1.0, lesserPos.getY());
}
addClaimStyle(claim, marker, worldName, owner);
String desc = getWindowInfo(claim, marker);
marker.setDescription(desc);
this.areaMarkers.put(markerid, marker);
}
}
use of com.griefdefender.lib.flowpowered.math.vector.Vector3i in project GDHooks by bloodmc.
the class TownyProvider method canCreateTown.
private boolean canCreateTown(World world, int townBlockX, int townBlockZ) {
final int sx = townBlockX << 4;
final int sz = townBlockZ << 4;
final int bx = sx + 15;
final int bz = sz + 15;
final Vector3i lesserBoundary = new Vector3i(sx, -64, sz);
final Vector3i greaterBoundary = new Vector3i(bx, 319, bz);
final ClaimResult result = GriefDefender.getRegistry().createBuilder(Claim.Builder.class).bounds(lesserBoundary, greaterBoundary).cuboid(false).owner(TEMP_USER_UUID).type(ClaimTypes.BASIC).world(world.getUID()).build();
if (!result.successful()) {
return false;
}
return true;
}
Aggregations