Search in sources :

Example 61 with User

use of com.google.api.ads.admanager.axis.v202108.User in project Village_Defense by Plajer.

the class ArenaUtils method updateLevelStat.

public static void updateLevelStat(Player player, Arena arena) {
    User user = UserManager.getUser(player.getUniqueId());
    if (Math.pow(50 * user.getInt("level"), 1.5) < user.getInt("xp")) {
        user.addInt("level", 1);
        player.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.formatMessage(arena, ChatManager.colorMessage("In-Game.You-Leveled-Up"), user.getInt("level")));
    }
}
Also used : User(pl.plajer.villagedefense3.User)

Example 62 with User

use of com.google.api.ads.admanager.axis.v202108.User in project Village_Defense by Plajer.

the class ArenaUtils method updateScoreboard.

public static void updateScoreboard(Arena arena) {
    if (arena.getPlayers().size() == 0)
        return;
    for (Player p : arena.getPlayers()) {
        User user = UserManager.getUser(p.getUniqueId());
        if (user.getScoreboard().getObjective("vd_state_0") == null) {
            for (ArenaState state : ArenaState.values()) {
                user.getScoreboard().registerNewObjective("vd_state_" + state.ordinal(), "dummy");
            }
            // fighting stage of IN_GAME state
            user.getScoreboard().registerNewObjective("vd_state_2F", "dummy");
        }
        if (arena.getArenaState() == ArenaState.ENDING) {
            user.removeScoreboard();
            return;
        }
        Objective gameObjective;
        if (arena.getArenaState() == ArenaState.IN_GAME) {
            gameObjective = user.getScoreboard().getObjective("vd_state_" + arena.getArenaState().ordinal() + (arena.isFighting() ? "F" : ""));
        } else {
            gameObjective = user.getScoreboard().getObjective("vd_state_" + arena.getArenaState().ordinal());
        }
        if (gameObjective == null)
            return;
        gameObjective.setDisplayName(ChatManager.colorMessage("Scoreboard.Header"));
        gameObjective.setDisplaySlot(DisplaySlot.SIDEBAR);
        switch(arena.getArenaState()) {
            case WAITING_FOR_PLAYERS:
                Score playersTotal1 = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Players")));
                playersTotal1.setScore(arena.getPlayers().size());
                Score neededPlayers2 = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Minimum-Players")));
                neededPlayers2.setScore(arena.getMinimumPlayers());
                break;
            case STARTING:
                Score timer = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Starting-In")));
                timer.setScore(arena.getTimer());
                Score playersTotal = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Players")));
                playersTotal.setScore(arena.getPlayers().size());
                Score neededPlayers = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Minimum-Players")));
                neededPlayers.setScore(arena.getMinimumPlayers());
                break;
            case IN_GAME:
                Score playersLeft = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Players-Left")));
                playersLeft.setScore(arena.getPlayersLeft().size());
                Score villagersLeft = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Villagers-Left")));
                villagersLeft.setScore(arena.getVillagers().size());
                Score orbs = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Orbs")));
                orbs.setScore(user.getInt("orbs"));
                if (arena.isFighting()) {
                    Score zombiesLeft = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Zombies-Left")));
                    zombiesLeft.setScore(arena.getZombiesLeft());
                } else {
                    Score nextWaveIn = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Next-Wave-In")));
                    nextWaveIn.setScore(arena.getTimer());
                }
                Score rottenFlesh = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Rotten-Flesh")));
                rottenFlesh.setScore(arena.getRottenFlesh());
                break;
            case RESTARTING:
                break;
            default:
                arena.setArenaState(ArenaState.WAITING_FOR_PLAYERS);
                break;
        }
        Score empty = gameObjective.getScore("");
        empty.setScore(-1);
        Score footer = gameObjective.getScore(ChatManager.colorMessage("Scoreboard.Footer"));
        footer.setScore(-2);
        user.setScoreboard(user.getScoreboard());
    }
}
Also used : Objective(org.bukkit.scoreboard.Objective) Player(org.bukkit.entity.Player) Score(org.bukkit.scoreboard.Score) User(pl.plajer.villagedefense3.User)

Example 63 with User

use of com.google.api.ads.admanager.axis.v202108.User in project Village_Defense by Plajer.

the class GameCommands method sendStatsOther.

public void sendStatsOther(CommandSender sender, String p) {
    Player player = Bukkit.getPlayerExact(p);
    if (player == null || UserManager.getUser(player.getUniqueId()) == null) {
        sender.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("Commands.Admin-Commands.Player-Not-Found"));
        return;
    }
    User user = UserManager.getUser(player.getUniqueId());
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Header-Other").replaceAll("%player%", player.getName()));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Kills") + user.getInt("kills"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Deaths") + user.getInt("deaths"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Games-Played") + user.getInt("gamesplayed"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Highest-Wave") + user.getInt("highestwave"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Level") + user.getInt("level"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Exp") + user.getInt("xp"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Next-Level-Exp") + Math.ceil(Math.pow(50 * user.getInt("level"), 1.5)));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Footer"));
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User)

Example 64 with User

use of com.google.api.ads.admanager.axis.v202108.User in project Village_Defense by Plajer.

the class GameCommands method sendStats.

public void sendStats(CommandSender sender) {
    if (checkSenderIsConsole(sender))
        return;
    User user = UserManager.getUser(((Player) sender).getUniqueId());
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Header"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Kills") + user.getInt("kills"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Deaths") + user.getInt("deaths"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Games-Played") + user.getInt("gamesplayed"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Highest-Wave") + user.getInt("highestwave"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Level") + user.getInt("level"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Exp") + user.getInt("xp"));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Next-Level-Exp") + Math.ceil(Math.pow(50 * user.getInt("level"), 1.5)));
    sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Footer"));
}
Also used : User(pl.plajer.villagedefense3.User)

Example 65 with User

use of com.google.api.ads.admanager.axis.v202108.User in project Village_Defense by Plajer.

the class Arena method leaveAttempt.

/**
 * Attempts player to leave arena.
 * Calls VillageGameLeaveAttemptEvent event.
 *
 * @param p player to join
 * @see VillageGameLeaveAttemptEvent
 */
public void leaveAttempt(Player p) {
    VillageGameLeaveAttemptEvent villageGameLeaveAttemptEvent = new VillageGameLeaveAttemptEvent(p, this);
    Bukkit.getPluginManager().callEvent(villageGameLeaveAttemptEvent);
    if (Main.isDebugged()) {
        System.out.println("[Village Debugger] Player " + p.getName() + " is attemping to leave arena!");
    }
    User user = UserManager.getUser(p.getUniqueId());
    user.setInt("orbs", 0);
    p.getInventory().clear();
    ArmorHelper.clearArmor(p);
    this.removePlayer(p);
    if (!user.isSpectator()) {
        ChatManager.broadcastLeaveMessage(this, p);
    }
    user.setFakeDead(false);
    user.setSpectator(false);
    user.removeScoreboard();
    if (user.getKit() instanceof GolemFriendKit) {
        for (IronGolem ironGolem : getIronGolems()) {
            if (ironGolem.getCustomName().contains(user.toPlayer().getName()))
                ironGolem.remove();
        }
    }
    if (plugin.isBossbarEnabled()) {
        gameBar.removePlayer(p);
    }
    p.setMaxHealth(20.0);
    p.setHealth(p.getMaxHealth());
    p.setFoodLevel(20);
    p.setFlying(false);
    p.setAllowFlight(false);
    for (PotionEffect effect : p.getActivePotionEffects()) {
        p.removePotionEffect(effect.getType());
    }
    p.setFireTicks(0);
    if (getPlayers().size() == 0) {
        this.setArenaState(ArenaState.RESTARTING);
    }
    p.setGameMode(GameMode.SURVIVAL);
    for (Player players : plugin.getServer().getOnlinePlayers()) {
        if (ArenaRegistry.getArena(players) != null)
            players.showPlayer(p);
        p.showPlayer(players);
    }
    this.teleportToEndLocation(p);
    if (!plugin.isBungeeActivated() && plugin.isInventoryManagerEnabled()) {
        plugin.getInventoryManager().loadInventory(p);
    }
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User) PotionEffect(org.bukkit.potion.PotionEffect) GolemFriendKit(pl.plajer.villagedefense3.kits.GolemFriendKit) IronGolem(org.bukkit.entity.IronGolem) VillageGameLeaveAttemptEvent(pl.plajer.villagedefense3.villagedefenseapi.VillageGameLeaveAttemptEvent)

Aggregations

User (pl.plajer.villagedefense3.User)30 Player (org.bukkit.entity.Player)18 User (org.gluu.oxtrust.model.scim2.User)17 EventHandler (org.bukkit.event.EventHandler)11 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)10 ScimPatchUser (org.gluu.oxtrust.model.scim2.ScimPatchUser)10 User (org.openstack4j.model.identity.v3.User)10 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)8 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)8 Arena (pl.plajer.villagedefense3.arena.Arena)8 ArrayList (java.util.ArrayList)7 User (me.zhanghai.android.douya.network.api.info.apiv2.User)7 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)7 User (com.google.api.ads.admanager.axis.v202108.User)6 UserServiceInterface (com.google.api.ads.admanager.axis.v202108.UserServiceInterface)6 User (com.google.api.ads.admanager.axis.v202111.User)6 UserServiceInterface (com.google.api.ads.admanager.axis.v202111.UserServiceInterface)6 User (com.google.api.ads.admanager.axis.v202202.User)6 UserServiceInterface (com.google.api.ads.admanager.axis.v202202.UserServiceInterface)6 Date (java.util.Date)6