Search in sources :

Example 1 with WorldGroup

use of gg.projecteden.nexus.utils.WorldGroup in project Nexus by ProjectEdenGG.

the class HomeListener method onPlayerRespawn.

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) {
    WorldGroup group = WorldGroup.of(event.getPlayer());
    if (!Arrays.asList(WorldGroup.SURVIVAL, WorldGroup.SKYBLOCK).contains(group))
        return;
    HomeOwner homeOwner = new HomeService().get(event.getPlayer().getUniqueId());
    Optional<Home> respawn = homeOwner.getHomes().stream().filter(Home::isRespawn).findFirst();
    Optional<Home> main = homeOwner.getHome("home");
    Optional<Home> first = homeOwner.getHomes().stream().findFirst();
    if (respawn.isPresent())
        event.setRespawnLocation(respawn.get().getLocation());
    else if (main.isPresent())
        event.setRespawnLocation(main.get().getLocation());
    else if (first.isPresent())
        event.setRespawnLocation(first.get().getLocation());
    else
        event.setRespawnLocation(Warps.getSpawn());
}
Also used : WorldGroup(gg.projecteden.nexus.utils.WorldGroup) HomeService(gg.projecteden.nexus.models.home.HomeService) HomeOwner(gg.projecteden.nexus.models.home.HomeOwner) Home(gg.projecteden.nexus.models.home.Home) EventHandler(org.bukkit.event.EventHandler)

Example 2 with WorldGroup

use of gg.projecteden.nexus.utils.WorldGroup in project Nexus by ProjectEdenGG.

the class WorldBanCommand method onWorldChange.

@EventHandler
public void onWorldChange(PlayerChangedWorldEvent event) {
    Player player = event.getPlayer();
    WorldBan worldBan = new WorldBanService().get(player);
    WorldGroup worldGroup = WorldGroup.of(player);
    if (worldBan.getBans().contains(worldGroup))
        removeFromBannedWorld(player, worldGroup);
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) WorldGroup(gg.projecteden.nexus.utils.WorldGroup) WorldBanService(gg.projecteden.nexus.models.worldban.WorldBanService) WorldBan(gg.projecteden.nexus.models.worldban.WorldBan) EventHandler(org.bukkit.event.EventHandler)

Example 3 with WorldGroup

use of gg.projecteden.nexus.utils.WorldGroup in project Nexus by ProjectEdenGG.

the class KitCommand method kit.

@Path("<kit>")
void kit(Kit kit) {
    WorldGroup worldGroup = worldGroup();
    if (worldGroup != WorldGroup.SURVIVAL && worldGroup != WorldGroup.CREATIVE)
        error("Kits may only be claimed in survival and creative");
    if (!player().hasPermission("kit." + kit.getName()))
        error("You do not have permission to use this kit");
    CooldownService service = new CooldownService();
    if (!service.check(player(), "kit-" + kit.getName(), kit.getDelay()))
        error("You must wait " + service.getDiff(player(), "kit-" + kit.getName()) + " before you can receive that kit again");
    PlayerUtils.giveItems(player(), Arrays.asList(kit.getItems()));
    send(PREFIX + "You have been given the &e" + StringUtils.camelCase(kit.getName()) + " &3kit");
}
Also used : WorldGroup(gg.projecteden.nexus.utils.WorldGroup) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 4 with WorldGroup

use of gg.projecteden.nexus.utils.WorldGroup in project Nexus by ProjectEdenGG.

the class MailCommand method onWorldChange.

@EventHandler
public void onWorldChange(PlayerChangedWorldEvent event) {
    Player player = event.getPlayer();
    WorldGroup worldGroup = WorldGroup.of(player);
    Mailer mailer = service.get(player);
    List<Mail> mails = new ArrayList<>(mailer.getMail(worldGroup));
    if (isNullOrEmpty(mails))
        return;
    if (!new CooldownService().check(player, "youhavemail", TickTime.MINUTE.x(5)))
        return;
    mailer.sendNotification();
}
Also used : Player(org.bukkit.entity.Player) Mail(gg.projecteden.nexus.models.mail.Mailer.Mail) WorldGroup(gg.projecteden.nexus.utils.WorldGroup) ArrayList(java.util.ArrayList) Mailer(gg.projecteden.nexus.models.mail.Mailer) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) EventHandler(org.bukkit.event.EventHandler)

Example 5 with WorldGroup

use of gg.projecteden.nexus.utils.WorldGroup in project Nexus by ProjectEdenGG.

the class WorldBanCommand method worldBan.

@Path("<player> [worldGroup]")
void worldBan(OfflinePlayer player, WorldGroup worldGroup) {
    WorldBan worldBan = service.get(player);
    if (worldGroup == null) {
        if (worldBan.getBans().size() == 0)
            error(player.getName() + " is not world banned");
        else
            send(PREFIX + "&e" + player.getName() + "&7 - &3" + String.join("&e, &3", worldBan.getBanNames()));
    } else {
        if (worldGroup.equals(WorldGroup.SURVIVAL) || worldGroup.equals(WorldGroup.UNKNOWN))
            error("Cannot world ban from " + worldGroup);
        List<WorldGroup> worldList = worldBan.getBans();
        if (worldList.contains(worldGroup))
            error(player.getName() + " is already banned from " + worldGroup);
        worldList.add(worldGroup);
        service.save(worldBan);
        String message = "&a" + name() + " &fhas world banned &a" + player.getName() + " &ffrom &a" + worldGroup;
        Broadcast.log().prefix("Justice").message(message).send();
        if (player.isOnline() && player.getPlayer() != null)
            if (WorldGroup.of(player.getPlayer()).equals(worldGroup)) {
                if (player.getPlayer().getVehicle() != null)
                    player.getPlayer().getVehicle().removePassenger(player.getPlayer());
                removeFromBannedWorld(player.getPlayer(), worldGroup);
            }
    }
}
Also used : WorldGroup(gg.projecteden.nexus.utils.WorldGroup) WorldBan(gg.projecteden.nexus.models.worldban.WorldBan) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Aggregations

WorldGroup (gg.projecteden.nexus.utils.WorldGroup)10 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)6 WorldBan (gg.projecteden.nexus.models.worldban.WorldBan)4 Player (org.bukkit.entity.Player)4 EventHandler (org.bukkit.event.EventHandler)4 CooldownService (gg.projecteden.nexus.models.cooldown.CooldownService)3 OfflinePlayer (org.bukkit.OfflinePlayer)3 WorldBanService (gg.projecteden.nexus.models.worldban.WorldBanService)2 PlayerNotOnlineException (gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException)1 Home (gg.projecteden.nexus.models.home.Home)1 HomeOwner (gg.projecteden.nexus.models.home.HomeOwner)1 HomeService (gg.projecteden.nexus.models.home.HomeService)1 Mailer (gg.projecteden.nexus.models.mail.Mailer)1 Mail (gg.projecteden.nexus.models.mail.Mailer.Mail)1 Poof (gg.projecteden.nexus.models.poof.Poof)1 Trust (gg.projecteden.nexus.models.trust.Trust)1 TrustService (gg.projecteden.nexus.models.trust.TrustService)1 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1