use of gg.projecteden.nexus.models.setting.Setting in project Nexus by ProjectEdenGG.
the class Pride20Command method joinParade.
@Path("parade join [player]")
void joinParade(@Arg(value = "self", permission = Group.STAFF) OfflinePlayer player) {
if (!isStaff())
player = player();
Setting setting = service.get(player, "pride20Parade");
if (setting.getBoolean())
error("You have already joined the parade");
WorldGuardUtils worldguard = new WorldGuardUtils(Bukkit.getWorld("safepvp"));
ProtectedRegion region = worldguard.getProtectedRegion("pride20_parade");
Location npcLoc;
if (!worldguard.getPlayersInRegion("pride20_parade").contains(player)) {
Location random;
int attempts = 0;
do {
random = Bukkit.getWorld("safepvp").getHighestBlockAt(worldguard.getRandomBlock(region).getLocation()).getLocation();
attempts++;
if (attempts >= 300) {
error("There was an error while trying to join the parade, please try again");
break;
}
} while (!region.contains(worldguard.toBlockVector3(random)) || citizenAtBlock(random) || !random.getBlock().getType().isSolid() || !isHighestBlock(random));
npcLoc = random;
} else {
npcLoc = player.getPlayer().getLocation();
}
npcLoc.setYaw(180);
npcLoc.setPitch(0);
NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, player.getName());
npc.spawn(npcLoc.add(0, 2, 0));
npcLoc = LocationUtils.getCenteredLocation(npcLoc);
npc.teleport(npcLoc, PlayerTeleportEvent.TeleportCause.COMMAND);
setting.setBoolean(true);
service.save(setting);
send(PREFIX + "You have joined the pride parade");
}
Aggregations