Search in sources :

Example 46 with ItemBuilder

use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.

the class AchievementsMenu method openAchievementsMenu.

// GENERAL - CTF - TDM - GAMEMODE - GAMEMODE
// TIERED ACHIEVEMENTS - CHALLENGES
// ACHIEVEMENT HISTORY
public static void openAchievementsMenu(Player player) {
    Menu menu = new Menu("Achievements", 9 * 6);
    menu.setItem(1, 1, new ItemBuilder(Material.STONE_AXE).name(ChatColor.GREEN + "General").get(), (m, e) -> openAchievementTypeMenu(player, null));
    for (int i = 0; i < GameMode.values().length; i++) {
        GameMode gameMode = GameMode.values()[i];
        if (gameMode.itemStack == null)
            continue;
        menu.setItem(i + 1, 1, new ItemBuilder(gameMode.itemStack).name(ChatColor.GREEN + gameMode.name).get(), (m, e) -> openAchievementTypeMenu(player, gameMode));
    }
    menu.setItem(4, 5, MENU_CLOSE, ACTION_CLOSE_MENU);
    menu.openForPlayer(player);
}
Also used : GameMode(com.ebicep.warlords.game.GameMode) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) Menu(com.ebicep.warlords.menu.Menu)

Example 47 with ItemBuilder

use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.

the class AchievementsMenu method openTieredAchievementHistoryMenu.

public static void openTieredAchievementHistoryMenu(Player player, GameMode gameMode, TieredAchievements achievement) {
    if (DatabaseManager.playerService == null)
        return;
    DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
    List<TieredAchievements.TieredAchievementRecord> achievementRecords = databasePlayer.getAchievements().stream().filter(TieredAchievements.TieredAchievementRecord.class::isInstance).map(TieredAchievements.TieredAchievementRecord.class::cast).filter(t -> t.getAchievement() == achievement).collect(Collectors.toList());
    Menu menu = new Menu("Achievement History", 9 * 6);
    int x = 0;
    int y = 0;
    for (TieredAchievements.TieredAchievementRecord achievementRecord : achievementRecords) {
        menu.setItem(x, y, new ItemBuilder(Material.BOOK).name(ChatColor.GREEN + achievement.name).lore(ChatColor.GRAY + DATE_FORMAT.format(achievementRecord.getDate())).get(), (m, e) -> {
        });
        x++;
        if (x == 9) {
            x = 0;
            y++;
        }
    }
    menu.setItem(3, 5, MENU_BACK, (m, e) -> openTieredAchievementsMenu(player, gameMode));
    menu.setItem(4, 5, MENU_CLOSE, ACTION_CLOSE_MENU);
    menu.openForPlayer(player);
}
Also used : ItemFlag(org.bukkit.inventory.ItemFlag) TieredAchievements(com.ebicep.warlords.achievements.types.TieredAchievements) Menu(com.ebicep.warlords.menu.Menu) Arrays(java.util.Arrays) Enchantment(org.bukkit.enchantments.Enchantment) SimpleDateFormat(java.text.SimpleDateFormat) Warlords(com.ebicep.warlords.Warlords) DatabaseManager(com.ebicep.warlords.database.DatabaseManager) WordWrap(com.ebicep.warlords.util.bukkit.WordWrap) Player(org.bukkit.entity.Player) UUID(java.util.UUID) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) Collectors(java.util.stream.Collectors) ChallengeAchievements(com.ebicep.warlords.achievements.types.ChallengeAchievements) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) List(java.util.List) ChatColor(org.bukkit.ChatColor) GameMode(com.ebicep.warlords.game.GameMode) Material(org.bukkit.Material) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) TieredAchievements(com.ebicep.warlords.achievements.types.TieredAchievements) Menu(com.ebicep.warlords.menu.Menu) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)

Example 48 with ItemBuilder

use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.

the class FlagRenderer method render.

public void render() {
    if (this.lastLocation != null) {
        this.reset();
    }
    this.lastLocation = info.getFlag();
    Warlords plugin = Warlords.getInstance();
    if (this.lastLocation instanceof GroundFlagLocation || this.lastLocation instanceof SpawnFlagLocation) {
        Block block = this.lastLocation.getLocation().getBlock();
        for (int i = 0; !block.isEmpty() && block.getType() != Material.STANDING_BANNER && i < 4; i++) {
            block = block.getRelative(0, 1, 0);
        }
        if (block.isEmpty() || block.getType() == Material.STANDING_BANNER) {
            renderedBlocks.add(block);
            block.setType(Material.STANDING_BANNER);
            org.bukkit.block.Banner banner = (org.bukkit.block.Banner) block.getState();
            banner.setBaseColor(info.getTeam() == Team.BLUE ? DyeColor.BLUE : DyeColor.RED);
            banner.addPattern(new Pattern(DyeColor.BLACK, PatternType.SKULL));
            banner.addPattern(new Pattern(DyeColor.BLACK, PatternType.TRIANGLES_TOP));
            banner.update();
            MaterialData newData = block.getState().getData();
            Vector target = this.lastLocation.getLocation().getDirection();
            Vector toTest = new Vector(0, 0, 0);
            BlockFace dir = SOUTH;
            double distance = Double.MAX_VALUE;
            for (BlockFace face : new BlockFace[] { SOUTH, SOUTH_SOUTH_WEST, SOUTH_WEST, WEST_SOUTH_WEST, WEST, WEST_NORTH_WEST, NORTH_WEST, NORTH_NORTH_WEST, NORTH, NORTH_NORTH_EAST, NORTH_EAST, EAST_NORTH_EAST, EAST, EAST_SOUTH_EAST, SOUTH_SOUTH_EAST, SOUTH_EAST }) {
                toTest.setX(face.getModX());
                toTest.setZ(face.getModZ());
                toTest.normalize();
                double newDistance = toTest.distanceSquared(target);
                if (newDistance < distance) {
                    dir = face;
                    distance = newDistance;
                }
            }
            ((Banner) newData).setFacingDirection(dir);
            block.setData(newData.getData());
        }
        ArmorStand stand = this.lastLocation.getLocation().getWorld().spawn(block.getLocation().add(.5, 0, .5), ArmorStand.class);
        renderedArmorStands.add(stand);
        stand.setGravity(false);
        stand.setCanPickupItems(false);
        stand.setCustomName(info.getTeam() == Team.BLUE ? ChatColor.BLUE + "" + ChatColor.BOLD + "BLU FLAG" : ChatColor.RED + "" + ChatColor.BOLD + "RED FLAG");
        stand.setCustomNameVisible(true);
        stand.setMetadata("INFO", new FixedMetadataValue(plugin, info));
        stand.setVisible(false);
        ArmorStand stand1 = this.lastLocation.getLocation().getWorld().spawn(block.getLocation().add(.5, -0.3, .5), ArmorStand.class);
        renderedArmorStands.add(stand1);
        stand1.setGravity(false);
        stand1.setCanPickupItems(false);
        stand1.setCustomName(ChatColor.WHITE + "" + ChatColor.BOLD + "LEFT-CLICK TO STEAL IT");
        stand1.setCustomNameVisible(true);
        stand.setMetadata("INFO", new FixedMetadataValue(plugin, info));
        stand1.setVisible(false);
    } else if (this.lastLocation instanceof PlayerFlagLocation) {
        PlayerFlagLocation flag = (PlayerFlagLocation) this.lastLocation;
        runningTasksCancel.add(flag.getPlayer().getSpeed().addSpeedModifier("FLAG", -20, 0, true));
        LivingEntity entity = ((PlayerFlagLocation) this.lastLocation).getPlayer().getEntity();
        if (entity instanceof Player) {
            Player player = (Player) entity;
            this.affectedPlayers.add(player);
            ItemStack item = new ItemStack(Material.BANNER);
            BannerMeta banner = (BannerMeta) item.getItemMeta();
            banner.setBaseColor(info.getTeam() == Team.BLUE ? DyeColor.BLUE : DyeColor.RED);
            banner.addPattern(new Pattern(DyeColor.BLACK, PatternType.SKULL));
            banner.addPattern(new Pattern(DyeColor.BLACK, PatternType.TRIANGLES_TOP));
            item.setItemMeta(banner);
            player.getInventory().setHelmet(item);
            player.getInventory().setItem(6, new ItemBuilder(Material.BANNER, 1).name("§aDrop Flag").get());
        }
    }
}
Also used : Pattern(org.bukkit.block.banner.Pattern) BannerMeta(org.bukkit.inventory.meta.BannerMeta) Player(org.bukkit.entity.Player) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) Banner(org.bukkit.material.Banner) BlockFace(org.bukkit.block.BlockFace) Warlords(com.ebicep.warlords.Warlords) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) LivingEntity(org.bukkit.entity.LivingEntity) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) ArmorStand(org.bukkit.entity.ArmorStand) Block(org.bukkit.block.Block) MaterialData(org.bukkit.material.MaterialData) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector)

Example 49 with ItemBuilder

use of com.ebicep.warlords.util.bukkit.ItemBuilder in project Warlords by ebicep.

the class WarlordsEvents method joinInteraction.

public static void joinInteraction(Player player, boolean fromGame) {
    Location rejoinPoint = Warlords.getRejoinPoint(player.getUniqueId());
    boolean isSpawnWorld = Bukkit.getWorlds().get(0).getName().equals(rejoinPoint.getWorld().getName());
    boolean playerIsInWrongWorld = !player.getWorld().getName().equals(rejoinPoint.getWorld().getName());
    if (isSpawnWorld || playerIsInWrongWorld) {
        player.teleport(rejoinPoint);
    }
    if (playerIsInWrongWorld && isSpawnWorld) {
        player.sendMessage(ChatColor.RED + "The game you were previously playing is no longer running!");
    }
    if (playerIsInWrongWorld && !isSpawnWorld) {
        player.sendMessage(ChatColor.RED + "The game started without you, but we still love you enough and you were warped into the game");
    }
    if (isSpawnWorld) {
        player.removePotionEffect(PotionEffectType.BLINDNESS);
        player.removePotionEffect(PotionEffectType.SLOW);
        player.removePotionEffect(PotionEffectType.ABSORPTION);
        player.setGameMode(GameMode.ADVENTURE);
        ChatUtils.sendCenteredMessage(player, ChatColor.GRAY + "-----------------------------------------------------");
        ChatUtils.sendCenteredMessage(player, ChatColor.GOLD + "" + ChatColor.BOLD + "Welcome to Warlords 2.0 " + ChatColor.GRAY + "(" + ChatColor.RED + Warlords.VERSION + ChatColor.GRAY + ")");
        ChatUtils.sendCenteredMessage(player, ChatColor.GOLD + "Developed by " + ChatColor.RED + "sumSmash " + ChatColor.GOLD + "&" + ChatColor.RED + " Plikie");
        ChatUtils.sendCenteredMessage(player, "");
        ChatUtils.sendCenteredMessage(player, ChatColor.GOLD + "Click the Nether Star or do " + ChatColor.GREEN + "/menu" + ChatColor.GOLD + " to open the selection menu.");
        ChatUtils.sendCenteredMessage(player, ChatColor.GOLD + "You can start private games using the " + ChatColor.GREEN + "Blaze Powder" + ChatColor.GOLD + " in your inventory!");
        ChatUtils.sendCenteredMessage(player, "");
        ChatUtils.sendCenteredMessage(player, ChatColor.GOLD + "Make sure to join our discord if you wish to stay up-to-date with our most recent patches, interact with our community and make bug reports or game suggestions at: " + ChatColor.RED + "§ldiscord.gg/GWPAx9sEG7");
        ChatUtils.sendCenteredMessage(player, "");
        ChatUtils.sendCenteredMessage(player, ChatColor.GOLD + "We highly recommend you to download our resourcepack at: " + ChatColor.RED + "§lhttps://bit.ly/3J1lGGn");
        ChatUtils.sendCenteredMessage(player, ChatColor.GRAY + "-----------------------------------------------------");
        PlayerSettings playerSettings = Warlords.getPlayerSettings(player.getUniqueId());
        Classes selectedClass = playerSettings.getSelectedClass();
        AbstractPlayerClass apc = selectedClass.create.get();
        player.getInventory().clear();
        player.getInventory().setArmorContents(new ItemStack[] { null, null, null, null });
        player.getInventory().setItem(1, new ItemBuilder(apc.getWeapon().getItem(playerSettings.getWeaponSkins().getOrDefault(selectedClass, Weapons.FELFLAME_BLADE).item)).name("§aWeapon Skin Preview").lore("").get());
        player.getInventory().setItem(4, new ItemBuilder(Material.NETHER_STAR).name("§aSelection Menu").get());
        if (!fromGame) {
            Warlords.partyManager.getPartyFromAny(player.getUniqueId()).ifPresent(party -> {
                List<RegularGamesMenu.RegularGamePlayer> playerList = party.getRegularGamesMenu().getRegularGamePlayers();
                if (!playerList.isEmpty()) {
                    playerList.stream().filter(regularGamePlayer -> regularGamePlayer.getUuid().equals(player.getUniqueId())).findFirst().ifPresent(regularGamePlayer -> player.getInventory().setItem(7, // @see Team.java
                    new ItemBuilder(Material.WOOL).name("§aTeam Builder").get()));
                }
            });
        }
        if (player.hasPermission("warlords.game.debug")) {
            player.getInventory().setItem(3, new ItemBuilder(Material.EMERALD).name("§aDebug Menu").get());
        } else {
            player.getInventory().setItem(3, new ItemBuilder(Material.BLAZE_POWDER).name("§aStart Menu").get());
        }
        if (fromGame) {
            Warlords.playerScoreboards.get(player.getUniqueId()).giveMainLobbyScoreboard();
            ExperienceManager.giveExperienceBar(player);
        }
        player.getActivePotionEffects().clear();
    }
    WarlordsPlayer p = Warlords.getPlayer(player);
    if (p != null) {
        player.teleport(p.getLocation());
        p.updatePlayerReference(player);
    } else {
        player.setAllowFlight(true);
    }
    Warlords.getInstance().hideAndUnhidePeople(player);
}
Also used : ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) AbstractPlayerClass(com.ebicep.warlords.classes.AbstractPlayerClass) PlayerFlagLocation(com.ebicep.warlords.game.flags.PlayerFlagLocation) GroundFlagLocation(com.ebicep.warlords.game.flags.GroundFlagLocation) WaitingFlagLocation(com.ebicep.warlords.game.flags.WaitingFlagLocation) SpawnFlagLocation(com.ebicep.warlords.game.flags.SpawnFlagLocation)

Aggregations

ItemBuilder (com.ebicep.warlords.util.bukkit.ItemBuilder)49 Menu (com.ebicep.warlords.menu.Menu)31 ItemStack (org.bukkit.inventory.ItemStack)22 Warlords (com.ebicep.warlords.Warlords)12 Player (org.bukkit.entity.Player)12 Classes (com.ebicep.warlords.player.Classes)11 DatabasePlayer (com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)10 Collectors (java.util.stream.Collectors)10 DatabaseManager (com.ebicep.warlords.database.DatabaseManager)8 Team (com.ebicep.warlords.game.Team)8 ChatColor (org.bukkit.ChatColor)8 AbstractPlayerClass (com.ebicep.warlords.classes.AbstractPlayerClass)7 List (java.util.List)7 Material (org.bukkit.Material)7 Enchantment (org.bukkit.enchantments.Enchantment)7 ItemFlag (org.bukkit.inventory.ItemFlag)7 ArrayList (java.util.ArrayList)6 Arrays (java.util.Arrays)6 UUID (java.util.UUID)6 Game (com.ebicep.warlords.game.Game)5