Search in sources :

Example 76 with User

use of com.google.api.ads.admanager.axis.v202205.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)

Example 77 with User

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

the class Arena method startWave.

private void startWave() {
    VillageWaveStartEvent villageWaveStartEvent = new VillageWaveStartEvent(this, wave);
    Bukkit.getPluginManager().callEvent(villageWaveStartEvent);
    setZombieAmount();
    if (plugin.getConfig().getBoolean("Respawn-After-Wave"))
        ArenaUtils.bringDeathPlayersBack(this);
    for (User user : UserManager.getUsers(this)) {
        user.getKit().reStock(user.toPlayer());
    }
    String message = ChatManager.formatMessage(this, ChatManager.colorMessage("In-Game.Messages.Wave-Started"), wave);
    for (Player player1 : getPlayers()) {
        player1.sendMessage(ChatManager.PLUGIN_PREFIX + message);
    }
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User) VillageWaveStartEvent(pl.plajer.villagedefense3.villagedefenseapi.VillageWaveStartEvent)

Example 78 with User

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

the class Arena method addExperience.

void addExperience(Player player, int i) {
    User user = UserManager.getUser(player.getUniqueId());
    user.addInt("xp", i);
    if (player.hasPermission(PermissionsManager.getVip())) {
        user.addInt("xp", (int) Math.ceil(i / 2));
    }
    if (player.hasPermission(PermissionsManager.getMvp())) {
        user.addInt("xp", (int) Math.ceil(i / 2));
    }
    if (player.hasPermission(PermissionsManager.getElite())) {
        user.addInt("xp", (int) Math.ceil(i / 2));
    }
    ArenaUtils.updateLevelStat(player, this);
}
Also used : User(pl.plajer.villagedefense3.User)

Example 79 with User

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

the class FileStats method saveStat.

public void saveStat(Player player, String stat) {
    User user = UserManager.getUser(player.getUniqueId());
    config.set(player.getUniqueId().toString() + "." + stat, user.getInt(stat));
    try {
        config.save(ConfigurationManager.getFile("stats"));
    } catch (IOException e) {
        e.printStackTrace();
        BigTextUtils.errorOccured();
        Bukkit.getConsoleSender().sendMessage("Cannot save stats.yml file!");
        Bukkit.getConsoleSender().sendMessage("Restart the server, file COULD BE OVERRIDDEN!");
    }
}
Also used : User(pl.plajer.villagedefense3.User) IOException(java.io.IOException)

Example 80 with User

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

the class Events method onShop.

@EventHandler
public void onShop(InventoryClickEvent event) {
    if (!(event.getWhoClicked() instanceof Player))
        return;
    Player player = (Player) event.getWhoClicked();
    Inventory inv = event.getInventory();
    Arena arena = ArenaRegistry.getArena((Player) event.getWhoClicked());
    if (arena == null)
        return;
    User user = UserManager.getUser(player.getUniqueId());
    if (user.isFakeDead()) {
        event.setCancelled(true);
        return;
    }
    if (inv.getName() == null || !inv.getName().equalsIgnoreCase(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Shop-GUI-Name")))
        return;
    event.setCancelled(true);
    if (event.getCurrentItem() == null || !event.getCurrentItem().hasItemMeta() || !event.getCurrentItem().getItemMeta().hasLore())
        return;
    String string = event.getCurrentItem().getItemMeta().getLore().get(0);
    string = ChatColor.stripColor(string);
    if (!(string.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop")) || string.contains("orbs"))) {
        boolean b = false;
        for (String s : event.getCurrentItem().getItemMeta().getLore()) {
            if (string.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop")) || string.contains("orbs")) {
                string = s;
                b = true;
            }
        }
        if (!b)
            return;
    }
    int price = Integer.parseInt(string.split(" ")[0]);
    if (price > UserManager.getUser(player.getUniqueId()).getInt("orbs")) {
        player.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Not-Enough-Orbs"));
        return;
    }
    if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasDisplayName()) {
        if (event.getCurrentItem().getItemMeta().getDisplayName().contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Golem-Item-Name"))) {
            arena.spawnGolem(arena.getStartLocation(), player);
            player.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Golem-Spawned"));
            UserManager.getUser(player.getUniqueId()).setInt("orbs", UserManager.getUser(player.getUniqueId()).getInt("orbs") - price);
            return;
        }
        if (event.getCurrentItem().getItemMeta().getDisplayName().contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Wolf-Item-Name"))) {
            arena.spawnWolf(arena.getStartLocation(), player);
            player.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Wolf-Spawned"));
            UserManager.getUser(player.getUniqueId()).setInt("orbs", UserManager.getUser(player.getUniqueId()).getInt("orbs") - price);
            return;
        }
    }
    ItemStack itemStack = event.getCurrentItem().clone();
    ItemMeta itemMeta = itemStack.getItemMeta();
    List<String> lore = new ArrayList<>();
    for (String loopLore : lore) {
        if (loopLore.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop"))) {
            lore.remove(loopLore);
        }
    }
    itemMeta.setLore(lore);
    itemStack.setItemMeta(itemMeta);
    player.getInventory().addItem(itemStack);
    UserManager.getUser(player.getUniqueId()).setInt("orbs", UserManager.getUser(player.getUniqueId()).getInt("orbs") - price);
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User) ArrayList(java.util.ArrayList) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) Arena(pl.plajer.villagedefense3.arena.Arena) ItemMeta(org.bukkit.inventory.meta.ItemMeta) EventHandler(org.bukkit.event.EventHandler)

Aggregations

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