Search in sources :

Example 21 with User

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

the class QuitEvent method onQuitSaveStats.

@EventHandler
public void onQuitSaveStats(PlayerQuitEvent event) {
    if (ArenaRegistry.getArena(event.getPlayer()) != null) {
        ArenaRegistry.getArena(event.getPlayer()).leaveAttempt(event.getPlayer());
    }
    final User user = UserManager.getUser(event.getPlayer().getUniqueId());
    final Player player = event.getPlayer();
    if (plugin.isDatabaseActivated()) {
        Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
            for (final String s : FileStats.STATISTICS) {
                int i;
                try {
                    i = plugin.getMySQLDatabase().getStat(player.getUniqueId().toString(), s);
                } catch (NullPointerException npe) {
                    i = 0;
                    System.out.print("COULDN'T GET STATS FROM PLAYER: " + player.getName());
                    npe.printStackTrace();
                    BigTextUtils.errorOccured();
                    Bukkit.getConsoleSender().sendMessage("Cannot get stats from MySQL database!");
                    Bukkit.getConsoleSender().sendMessage("Check configuration of mysql.yml file or disable mysql option in config.yml");
                }
                if (i > user.getInt(s)) {
                    plugin.getMySQLDatabase().setStat(player.getUniqueId().toString(), s, user.getInt(s) + i);
                } else {
                    plugin.getMySQLDatabase().setStat(player.getUniqueId().toString(), s, user.getInt(s));
                }
            }
        });
    } else {
        for (String s : FileStats.STATISTICS) {
            plugin.getFileStats().saveStat(player, s);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User) EventHandler(org.bukkit.event.EventHandler)

Example 22 with User

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

the class BlockerKit method onBarrierPlace.

@EventHandler(priority = EventPriority.HIGHEST)
public void onBarrierPlace(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
        return;
    Player player = event.getPlayer();
    if (player.getItemInHand() == null)
        return;
    if (ArenaRegistry.getArena(player) == null)
        return;
    if (!player.getItemInHand().hasItemMeta())
        return;
    if (!player.getItemInHand().getItemMeta().hasDisplayName())
        return;
    if (!player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatManager.colorMessage("Kits.Blocker.Game-Item-Name")))
        return;
    Block block = null;
    for (Block blocks : player.getLastTwoTargetBlocks(null, 5)) {
        if (blocks.getType() == Material.AIR)
            block = blocks;
    }
    if (block == null) {
        event.getPlayer().sendMessage(ChatManager.colorMessage("Kits.Blocker.Game-Item-Place-Fail"));
        return;
    }
    if (player.getItemInHand().getAmount() <= 1) {
        player.setItemInHand(new ItemStack(Material.AIR));
    } else {
        player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
    }
    User user = UserManager.getUser(event.getPlayer().getUniqueId());
    user.toPlayer().sendMessage(ChatManager.colorMessage("Kits.Blocker.Game-Item-Place-Message"));
    ZombieBarrier zombieBarrier = new ZombieBarrier();
    zombieBarrier.setLocation(block.getLocation());
    zombieBarrier.getLocation().getWorld().playEffect(zombieBarrier.getLocation(), Effect.FIREWORKS_SPARK, 20);
    new BukkitRunnable() {

        @Override
        public void run() {
            zombieBarrier.decrementSeconds();
            if (zombieBarrier.getSeconds() <= 0) {
                zombieBarrier.getLocation().getBlock().setType(Material.AIR);
                if (plugin.is1_8_R3()) {
                    zombieBarrier.getLocation().getWorld().playEffect(zombieBarrier.getLocation(), Effect.FIREWORKS_SPARK, 20);
                } else {
                    zombieBarrier.getLocation().getWorld().spawnParticle(Particle.FIREWORKS_SPARK, zombieBarrier.getLocation(), 20);
                }
                this.cancel();
            }
        }
    }.runTaskTimer(plugin, 20, 20);
    block.setType(Material.FENCE);
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User) Block(org.bukkit.block.Block) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 23 with User

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

the class Events method onItemPickup.

@EventHandler
public void onItemPickup(PlayerExpChangeEvent event) {
    Arena arena = ArenaRegistry.getArena(event.getPlayer());
    if (arena == null)
        return;
    int amount = (int) Math.ceil(event.getAmount() * 1.6);
    User user = UserManager.getUser(event.getPlayer().getUniqueId());
    event.setAmount(amount);
    if (user.isFakeDead()) {
        event.setAmount(0);
        return;
    }
    // bonus orbs with custom permissions
    for (String perm : plugin.getCustomPermissions().keySet()) {
        if (event.getPlayer().hasPermission(perm)) {
            amount = +(int) Math.ceil(event.getAmount() * (plugin.getCustomPermissions().get(perm) / 100));
            user.addInt("orbs", (int) Math.ceil(event.getAmount() * (plugin.getCustomPermissions().get(perm) / 100)));
        }
    }
    if (event.getPlayer().hasPermission(PermissionsManager.getElite())) {
        amount = +(int) Math.ceil(event.getAmount() * 1.5);
        user.addInt("orbs", (int) Math.ceil(event.getAmount() * 1.5));
    } else if (event.getPlayer().hasPermission(PermissionsManager.getMvp())) {
        amount = +(int) Math.ceil(event.getAmount() * 1.0);
        user.addInt("orbs", (int) Math.ceil(event.getAmount() * 1.0));
    } else if (event.getPlayer().hasPermission(PermissionsManager.getVip())) {
        amount = +(int) Math.ceil(event.getAmount() * 0.5);
        user.addInt("orbs", (int) Math.ceil(event.getAmount() * 0.5));
    } else {
        amount = +event.getAmount();
        user.addInt("orbs", event.getAmount());
    }
    event.getPlayer().sendMessage(ChatManager.colorMessage("In-Game.Orbs-Pickup").replaceAll("%number%", String.valueOf(amount)));
}
Also used : User(pl.plajer.villagedefense3.User) Arena(pl.plajer.villagedefense3.arena.Arena) EventHandler(org.bukkit.event.EventHandler)

Example 24 with User

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

the class Events method onSecond.

@EventHandler(priority = EventPriority.HIGHEST)
public void onSecond(EntityDamageByEntityEvent event) {
    User user = UserManager.getUser((event.getDamager().getUniqueId()));
    if (user.isFakeDead() || user.isSpectator()) {
        event.setCancelled(true);
        return;
    }
    if (!(event.getDamager() instanceof Arrow))
        return;
    Arrow arrow = (Arrow) event.getDamager();
    if (arrow.getShooter() == null)
        return;
    if (!(arrow.getShooter() instanceof Player))
        return;
    Arena arena = ArenaRegistry.getArena((Player) arrow.getShooter());
    if (arena == null)
        return;
    if (user.isFakeDead() || user.isSpectator()) {
        event.setCancelled(true);
        return;
    }
    if (!VILLAGE_ENTITIES.contains(event.getEntityType()))
        return;
    event.setCancelled(true);
}
Also used : Arrow(org.bukkit.entity.Arrow) Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User) Arena(pl.plajer.villagedefense3.arena.Arena) EventHandler(org.bukkit.event.EventHandler)

Example 25 with User

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

the class AdminCommands method respawnOther.

public void respawnOther(CommandSender sender, String player) {
    if (checkSenderIsConsole(sender))
        return;
    if (!checkIsInGameInstance((Player) sender))
        return;
    if (!hasPermission(sender, "villagedefense.admin.respawn.others"))
        return;
    Arena arena = ArenaRegistry.getArena((Player) sender);
    for (Player loopPlayer : arena.getPlayers()) {
        if (player.equalsIgnoreCase(loopPlayer.getName())) {
            loopPlayer.setGameMode(GameMode.SURVIVAL);
            User user = UserManager.getUser(loopPlayer.getUniqueId());
            user.setFakeDead(false);
            user.setSpectator(false);
            sender.sendMessage(ChatColor.GREEN + "Player respawned!");
            arena.teleportToStartLocation(loopPlayer);
            loopPlayer.setFlying(false);
            loopPlayer.setAllowFlight(false);
            ArenaUtils.showPlayer(loopPlayer, arena);
            loopPlayer.getInventory().clear();
            user.getKit().giveKitItems(loopPlayer);
            loopPlayer.sendMessage(ChatManager.colorMessage("In-Game.Back-In-Game"));
            return;
        }
    }
    sender.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("Commands.Admin-Commands.Player-Not-Found"));
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User) Arena(pl.plajer.villagedefense3.arena.Arena)

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.v202111.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.v202202.User)6 UserServiceInterface (com.google.api.ads.admanager.axis.v202202.UserServiceInterface)6 Date (java.util.Date)6 SimpleUser (me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser)6 UserTeamAssociation (com.google.api.ads.admanager.axis.v202111.UserTeamAssociation)5