use of gg.projecteden.nexus.utils.WorldGuardUtils in project Nexus by ProjectEdenGG.
the class Pride20Command method leaveParade.
@Path("parade leave [player]")
void leaveParade(@Arg(value = "self", permission = Group.STAFF) OfflinePlayer player) {
boolean isSelf = isSelf(player);
String playerText = isSelf ? "You have" : Nickname.of(player) + " has";
Setting setting = service.get(player, "pride20Parade");
if (!setting.getBoolean())
error(playerText + " not joined the parade");
WorldGuardUtils worldguard = new WorldGuardUtils(Bukkit.getWorld("safepvp"));
for (Entity entity : worldguard.getEntitiesInRegion("pride20_parade")) {
if (!entity.hasMetadata("NPC"))
continue;
if (entity.getName().equalsIgnoreCase(player.getName()))
CitizensAPI.getNPCRegistry().getNPC(entity).destroy();
}
setting.setBoolean(false);
service.save(setting);
send(PREFIX + playerText + " left the pride parade");
}
use of gg.projecteden.nexus.utils.WorldGuardUtils in project Nexus by ProjectEdenGG.
the class InteractListener method onPutt.
@EventHandler
public void onPutt(PlayerInteractEvent event) {
if (event.getHand() == null)
return;
if (!event.getHand().equals(EquipmentSlot.HAND))
return;
MiniGolfUser user = MiniGolfUtils.getUser(event.getPlayer().getUniqueId());
if (user == null)
return;
ItemStack item = event.getItem();
if (isNullOrAir(item)) {
user.debug("item is null or air, returning");
return;
}
Action action = event.getAction();
Block block = event.getClickedBlock();
if (item.getType().equals(Material.SNOWBALL)) {
user.debug("placing golf ball...");
if (user.getGolfBall() != null && user.getGolfBall().getSnowball() != null) {
user.debug("you already have a ball placed");
event.setCancelled(true);
return;
}
if (isNullOrAir(block)) {
user.debug("placed on block is air or null");
event.setCancelled(true);
return;
}
GolfBall golfBall = new GolfBall(user.getUuid());
// Verify region
WorldGuardUtils worldguard = new WorldGuardUtils(block);
Set<ProtectedRegion> regions = worldguard.getRegionsLikeAt(MiniGolf.holeRegionRegex, block.getLocation());
ProtectedRegion region = regions.stream().findFirst().orElse(null);
if (region == null) {
user.debug("hole region not found");
event.setCancelled(true);
return;
}
golfBall.setHoleRegion(region.getId());
// Place Event
MiniGolfUserPlaceBallEvent placeBallEvent = new MiniGolfUserPlaceBallEvent(user, golfBall, Set.of(Material.GREEN_WOOL));
if (!placeBallEvent.callEvent()) {
user.debug("place ball event cancelled");
event.setCancelled(true);
return;
}
if (!placeBallEvent.canPlaceBall(block.getType())) {
user.debug("incorrect starting position");
event.setCancelled(true);
return;
}
// Spawn Event
MiniGolfBallSpawnEvent ballSpawnEvent = new MiniGolfBallSpawnEvent(golfBall, block.getLocation());
if (!ballSpawnEvent.callEvent()) {
user.debug("place spawn event cancelled");
event.setCancelled(true);
return;
}
item.setAmount(item.getAmount() - 1);
ballSpawnEvent.spawnBall();
MiniGolf.getGolfBalls().add(golfBall);
}
// TODO
}
use of gg.projecteden.nexus.utils.WorldGuardUtils in project Nexus by ProjectEdenGG.
the class BannerCommand method onBuyBanner.
@EventHandler
public void onBuyBanner(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (event.getClickedBlock() == null || !MaterialTag.SIGNS.isTagged(event.getClickedBlock().getType()))
return;
if (!"safepvp".equals(event.getPlayer().getWorld().getName()))
return;
if (!new WorldGuardUtils(event.getPlayer()).isInRegion(event.getPlayer().getLocation(), "banners"))
return;
Sign sign = (Sign) event.getClickedBlock().getState();
String id = sign.getLine(0);
if (isNullOrEmpty(id))
return;
Block banner = event.getClickedBlock().getLocation().add(0, -1, 0).getBlock();
if (!MaterialTag.STANDING_BANNERS.isTagged(banner.getType()))
return;
ConfirmationMenu.builder().onConfirm(e -> {
try {
new VoterService().edit(event.getPlayer(), voter -> voter.takePoints(5));
} catch (InvalidInputException ex) {
send(event.getPlayer(), ex.getMessage());
return;
}
PlayerUtils.giveItems(event.getPlayer(), banner.getDrops());
send(event.getPlayer(), StringUtils.getPrefix("VPS") + colorize("You purchased banner &e" + id + " &3for &e5 vote points"));
}).open(event.getPlayer());
}
use of gg.projecteden.nexus.utils.WorldGuardUtils in project Nexus by ProjectEdenGG.
the class NPCListener method onNpcSpawn.
@EventHandler
public void onNpcSpawn(NPCSpawnEvent event) {
UUID uuid = event.getNPC().getTrait(Owner.class).getOwnerId();
if (uuid == null)
return;
if (ALLOWED_NPCS.contains(event.getNPC().getId()))
return;
if (event.getLocation().getWorld().getName().equals("events") && new WorldGuardUtils(event.getLocation()).isInRegion(event.getLocation(), "pride21_parade"))
return;
OfflinePlayer owner = PlayerUtils.getPlayer(uuid);
if (Rank.of(owner).gte(Rank.NOBLE) || Dev.of(owner.getUniqueId()) != null)
return;
if (isPerkAllowedAt(owner, event.getLocation()))
return;
event.setCancelled(true);
PlayerUtils.send(owner, "&cYou cannot teleport NPCs here");
Nexus.warn("Preventing NPC spawn: " + event.getNPC().getId() + " from " + getShortLocationString(event.getNPC().getStoredLocation()) + " to " + getShortLocationString(event.getLocation()));
}
use of gg.projecteden.nexus.utils.WorldGuardUtils in project Nexus by ProjectEdenGG.
the class NPCListener method onNpcTeleport.
@EventHandler
public void onNpcTeleport(NPCTeleportEvent event) {
UUID uuid = event.getNPC().getTrait(Owner.class).getOwnerId();
if (uuid == null)
return;
if (event.getTo() == null)
return;
if (event.getTo().getWorld().getName().equals("events") && new WorldGuardUtils(event.getTo()).isInRegion(event.getTo(), "pride21_parade"))
return;
OfflinePlayer owner = PlayerUtils.getPlayer(uuid);
if (!event.getFrom().getWorld().equals(event.getTo().getWorld())) {
event.setCancelled(true);
PlayerUtils.send(owner, "&cNPCs cannot be teleported across worlds");
Nexus.warn("Preventing NPC cross-world teleport: " + event.getNPC().getId() + " from " + getShortLocationString(event.getFrom()) + " to " + getShortLocationString(event.getTo()));
return;
}
if (ALLOWED_NPCS.contains(event.getNPC().getId()))
return;
if (Rank.of(owner).gte(Rank.NOBLE) || Dev.of(owner.getUniqueId()) != null)
return;
if (isPerkAllowedAt(owner, event.getTo()))
return;
event.setCancelled(true);
PlayerUtils.send(owner, "&cYou cannot teleport NPCs here");
Nexus.warn("Preventing NPC teleport: " + event.getNPC().getId() + " from " + getShortLocationString(event.getFrom()) + " to " + getShortLocationString(event.getTo()));
}
Aggregations