Search in sources :

Example 6 with Setting

use of gg.projecteden.nexus.models.setting.Setting in project Nexus by ProjectEdenGG.

the class DiscordCommand method lockdown.

@Async
@Path("lockdown")
@Permission(Group.STAFF)
void lockdown() {
    SettingService service = new SettingService();
    Setting setting = service.get("discord", "lockdown");
    setting.setBoolean(!setting.getBoolean());
    service.save(setting);
    send(PREFIX + "Lockdown " + (setting.getBoolean() ? "enabled, new members will be automatically kicked" : "disabled"));
}
Also used : SettingService(gg.projecteden.nexus.models.setting.SettingService) Setting(gg.projecteden.nexus.models.setting.Setting) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 7 with Setting

use of gg.projecteden.nexus.models.setting.Setting in project Nexus by ProjectEdenGG.

the class DiscordListener method onGuildMemberJoin.

@Override
public void onGuildMemberJoin(@Nonnull GuildMemberJoinEvent event) {
    Tasks.async(() -> {
        SettingService service = new SettingService();
        Setting setting = service.get("discord", "lockdown");
        if (setting.getBoolean())
            event.getMember().kick("This discord is currently on lockdown mode").queue();
        else {
            Tasks.waitAsync(5, () -> {
                Discord.addRole(event.getUser().getId(), Role.NERD);
                DiscordUser user = new DiscordUserService().getFromUserId(event.getUser().getId());
                if (user != null) {
                    Discord.addRole(event.getUser().getId(), Role.VERIFIED);
                    if (user.getRank() == Rank.VETERAN)
                        Discord.addRole(event.getUser().getId(), Role.VETERAN);
                    if (new BadgeUserService().get(user).owns(Badge.SUPPORTER))
                        Discord.addRole(event.getUser().getId(), Role.SUPPORTER);
                    user.updatePronouns(new NerdService().get(user).getPronouns());
                }
            });
        }
    });
}
Also used : DiscordUser(gg.projecteden.nexus.models.discord.DiscordUser) SettingService(gg.projecteden.nexus.models.setting.SettingService) Setting(gg.projecteden.nexus.models.setting.Setting) BadgeUserService(gg.projecteden.nexus.models.badge.BadgeUserService) DiscordUserService(gg.projecteden.nexus.models.discord.DiscordUserService) NerdService(gg.projecteden.nexus.models.nerd.NerdService)

Example 8 with Setting

use of gg.projecteden.nexus.models.setting.Setting in project Nexus by ProjectEdenGG.

the class DiscordAppCommand method lockdown.

@RequiredRole("Staff")
@Command("Toggle lockdown")
void lockdown(@Desc("Lockdown state") @Optional Boolean state) {
    SettingService settingService = new SettingService();
    Setting setting = settingService.get("discord", "lockdown");
    setting.setBoolean(state == null ? !setting.getBoolean() : state);
    settingService.save(setting);
    reply("Discord lockdown " + (setting.getBoolean() ? "enabled by " + nickname() + ", new members will be automatically kicked" : "disabled by " + nickname()));
}
Also used : SettingService(gg.projecteden.nexus.models.setting.SettingService) Setting(gg.projecteden.nexus.models.setting.Setting) RequiredRole(gg.projecteden.discord.appcommands.annotations.RequiredRole) Command(gg.projecteden.discord.appcommands.annotations.Command) NexusAppCommand(gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)

Example 9 with Setting

use of gg.projecteden.nexus.models.setting.Setting 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";
    Setting setting = service.get(player, "pride21Parade");
    if (!setting.getBoolean())
        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();
    setting.setBoolean(false);
    service.save(setting);
    send(PREFIX + playerText + " left the pride parade");
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) Setting(gg.projecteden.nexus.models.setting.Setting) World(org.bukkit.World) WorldGuardUtils(gg.projecteden.nexus.utils.WorldGuardUtils) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 10 with Setting

use of gg.projecteden.nexus.models.setting.Setting 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";
    Setting setting = service.get(player, "pride21Parade");
    if (setting.getBoolean())
        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);
    setting.setBoolean(true);
    service.save(setting);
    send(PREFIX + playerText + " joined the pride parade");
}
Also used : Setting(gg.projecteden.nexus.models.setting.Setting) World(org.bukkit.World) WorldGuardUtils(gg.projecteden.nexus.utils.WorldGuardUtils) Location(org.bukkit.Location) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Aggregations

Setting (gg.projecteden.nexus.models.setting.Setting)11 SettingService (gg.projecteden.nexus.models.setting.SettingService)7 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)6 WorldGuardUtils (gg.projecteden.nexus.utils.WorldGuardUtils)4 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)2 ItemBuilder (gg.projecteden.nexus.utils.ItemBuilder)2 NPC (net.citizensnpcs.api.npc.NPC)2 Location (org.bukkit.Location)2 World (org.bukkit.World)2 Player (org.bukkit.entity.Player)2 EventHandler (org.bukkit.event.EventHandler)2 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)1 Async (gg.projecteden.annotations.Async)1 Command (gg.projecteden.discord.appcommands.annotations.Command)1 RequiredRole (gg.projecteden.discord.appcommands.annotations.RequiredRole)1 NexusAppCommand (gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)1 BadgeUserService (gg.projecteden.nexus.models.badge.BadgeUserService)1 BankerService (gg.projecteden.nexus.models.banker.BankerService)1 CooldownService (gg.projecteden.nexus.models.cooldown.CooldownService)1 DiscordUser (gg.projecteden.nexus.models.discord.DiscordUser)1