use of gg.projecteden.nexus.utils.WorldGuardUtils in project Nexus by ProjectEdenGG.
the class Flag method getSuitableLocation.
public static Location getSuitableLocation(Location originalLocation) {
Location location = originalLocation.clone();
double originalHeight = location.getY();
int maxHeight = location.getWorld().getMaxHeight();
int minHeight = location.getWorld().getMinHeight();
while (// goal is to be in an air block
!MaterialTag.ALL_AIR.isTagged(location.getBlock().getType()) && // don't go above the world
location.getY() < maxHeight && // the check against the current height is to avoid warping down on stairs
(location.getY() - originalHeight < 2 || !location.getBlock().getType().isSolid())) location.add(0, 1, 0);
Block below = location.clone().subtract(0, 1, 0).getBlock();
while ((MaterialTag.ALL_AIR.isTagged(below.getType()) || below.getType() == Material.BARRIER || !MaterialTag.ALL_AIR.isTagged(location.getBlock().getType())) && ArenaManager.getFromLocation(originalLocation).getRegion().contains(new WorldGuardUtils(Minigames.getWorld()).toBlockVector3(location))) {
location.subtract(0, 1, 0);
below = location.clone().subtract(0, 1, 0).getBlock();
if (location.getY() <= minHeight) {
// maybe this should throw an exception to avoid possible harm in deleting blocks?
// although it's probably just bedrock...
Nexus.warn("Could not find a safe location for flag, dumping it at " + location.toString() + " (overwriting " + location.getBlock().getType().name() + ")");
break;
}
}
return location;
}
use of gg.projecteden.nexus.utils.WorldGuardUtils in project Nexus by ProjectEdenGG.
the class RegenRegions method onBreakBlock.
@EventHandler
public void onBreakBlock(BlockBreakEvent event) {
if (!(event.getPlayer().getGameMode().equals(GameMode.SURVIVAL)))
return;
Block eventBlock = event.getBlock();
Location loc = eventBlock.getLocation();
WorldGuardUtils worldguard = new WorldGuardUtils(loc);
String key = "_regen_";
for (ProtectedRegion region : worldguard.getRegionsAt(loc)) {
String regionName = region.getId();
if (regionName.contains(key)) {
int ndx = regionName.indexOf('_');
String variables = regionName.substring(ndx + key.length() - 1);
String[] varSplit = variables.split("_");
String cooldownStr = varSplit[varSplit.length - 1];
int cooldown = getInteger(cooldownStr);
String materialStr = variables;
if (cooldown != -1)
materialStr = variables.substring(0, variables.indexOf(cooldownStr));
Material material = getMaterial(materialStr);
if (material == null) {
// throw error?
Nexus.log("Unknown material to regen");
return;
}
}
}
}
use of gg.projecteden.nexus.utils.WorldGuardUtils in project Nexus by ProjectEdenGG.
the class Pride21Command method leaveParade.
@Path("parade leave [player]")
void leaveParade(@Arg(value = "self", permission = Group.STAFF) OfflinePlayer player) {
String playerText = isSelf(player) ? "You have" : Nickname.of(player) + " has";
final Pride21User user = service.get(player);
if (user.isJoinedParade())
error(playerText + " not joined the parade");
World world = Bukkit.getWorld("events");
if (world == null)
error("Could not load the event world, please report to a dev <3");
WorldGuardUtils worldguard = new WorldGuardUtils(world);
for (NPC npc : NPCFinder.builder().owner(player).world(world).region(worldguard.getProtectedRegion("pride21_parade")).build().get()) npc.destroy();
user.setJoinedParade(false);
service.save(user);
send(PREFIX + playerText + " left the pride parade");
}
use of gg.projecteden.nexus.utils.WorldGuardUtils in project Nexus by ProjectEdenGG.
the class Pride21Command method joinParade.
@Path("parade join [player]")
void joinParade(@Arg(value = "self", permission = Group.STAFF) Player player) {
String playerText = isSelf(player) ? "You have" : Nickname.of(player) + " has";
final Pride21User user = service.get(player);
if (user.isJoinedParade())
error(playerText + " already joined the parade");
World world = Bukkit.getWorld("events");
if (world == null)
error("Could not load the event world, please report to a dev <3");
WorldGuardUtils worldguard = new WorldGuardUtils(world);
if (!worldguard.isInRegion(player, "pride21_parade"))
error("You must be standing in the Pride parade to use this command");
Location npcLoc = LocationUtils.getCenteredLocation(player.getLocation());
CitizensUtils.spawnNPC(player, npcLoc);
user.setJoinedParade(true);
service.save(user);
send(PREFIX + playerText + " joined the pride parade");
}
use of gg.projecteden.nexus.utils.WorldGuardUtils in project Nexus by ProjectEdenGG.
the class Quests method viewFloat.
public static void viewFloat(Player player, boolean view) {
Tasks.async(() -> {
World world = Bukkit.getWorld("events");
BlockData gray = Material.GRAY_TERRACOTTA.createBlockData();
if (world == null)
return;
for (BlockVector3 blockVector3 : new WorldGuardUtils(world).getRegion("pride21_val")) {
Location location = new Location(world, blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
Material material = location.getBlock().getType();
if (MaterialTag.ALL_TERRACOTTAS.isTagged(material))
player.sendBlockChange(location, view ? location.getBlock().getBlockData() : gray);
}
});
}
Aggregations