Search in sources :

Example 26 with User

use of sqlite.kripton209.model1.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 27 with User

use of sqlite.kripton209.model1.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 28 with User

use of sqlite.kripton209.model1.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 29 with User

use of sqlite.kripton209.model1.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)

Example 30 with User

use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.

the class MySQLConnectionUtils method loadPlayerStats.

public static void loadPlayerStats(Player player, Main plugin) {
    boolean b = false;
    MySQLDatabase database = plugin.getMySQLDatabase();
    ResultSet resultSet = database.executeQuery("SELECT UUID from playerstats WHERE UUID='" + player.getUniqueId().toString() + "'");
    try {
        if (!resultSet.next()) {
            database.insertPlayer(player.getUniqueId().toString());
            b = true;
        }
        int gamesplayed;
        int zombiekills;
        int highestwave;
        int deaths;
        int xp;
        int level;
        int orbs;
        gamesplayed = database.getStat(player.getUniqueId().toString(), "gamesplayed");
        zombiekills = database.getStat(player.getUniqueId().toString(), "kills");
        highestwave = database.getStat(player.getUniqueId().toString(), "highestwave");
        deaths = database.getStat(player.getUniqueId().toString(), "deaths");
        xp = database.getStat(player.getUniqueId().toString(), "xp");
        level = database.getStat(player.getUniqueId().toString(), "level");
        orbs = database.getStat(player.getUniqueId().toString(), "orbs");
        User user = UserManager.getUser(player.getUniqueId());
        user.setInt("gamesplayed", gamesplayed);
        user.setInt("kills", zombiekills);
        user.setInt("highestwave", highestwave);
        user.setInt("deaths", deaths);
        user.setInt("xp", xp);
        user.setInt("level", level);
        user.setInt("orbs", orbs);
        b = true;
    } catch (SQLException e1) {
        System.out.print("CONNECTION FAILED FOR PLAYER " + player.getName());
        e1.printStackTrace();
        BigTextUtils.errorOccured();
        Bukkit.getConsoleSender().sendMessage("Cannot save contents to MySQL database!");
        Bukkit.getConsoleSender().sendMessage("Check configuration of mysql.yml file or disable mysql option in config.yml");
    }
    if (!b) {
        try {
            if (!resultSet.next()) {
                database.insertPlayer(player.getUniqueId().toString());
            }
            int gamesplayed;
            int zombiekills;
            int highestwave;
            int deaths;
            int xp;
            int level;
            int orbs;
            gamesplayed = database.getStat(player.getUniqueId().toString(), "gamesplayed");
            zombiekills = database.getStat(player.getUniqueId().toString(), "kills");
            highestwave = database.getStat(player.getUniqueId().toString(), "highestwave");
            deaths = database.getStat(player.getUniqueId().toString(), "deaths");
            xp = database.getStat(player.getUniqueId().toString(), "xp");
            level = database.getStat(player.getUniqueId().toString(), "level");
            orbs = database.getStat(player.getUniqueId().toString(), "orbs");
            User user = UserManager.getUser(player.getUniqueId());
            user.setInt("gamesplayed", gamesplayed);
            user.setInt("kills", zombiekills);
            user.setInt("highestwave", highestwave);
            user.setInt("deaths", deaths);
            user.setInt("xp", xp);
            user.setInt("level", level);
            user.setInt("orbs", orbs);
        } catch (SQLException e1) {
            System.out.print("CONNECTION FAILED TWICE FOR PLAYER " + player.getName());
            e1.printStackTrace();
            BigTextUtils.errorOccured();
            Bukkit.getConsoleSender().sendMessage("Cannot save contents to MySQL database!");
            Bukkit.getConsoleSender().sendMessage("Check configuration of mysql.yml file or disable mysql option in config.yml");
        }
    }
}
Also used : User(pl.plajer.villagedefense3.User) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) MySQLDatabase(pl.plajer.villagedefense3.database.MySQLDatabase)

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 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)8 Arena (pl.plajer.villagedefense3.arena.Arena)8 ArrayList (java.util.ArrayList)7 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)7 Date (java.util.Date)6 SimpleUser (me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser)6 User (me.zhanghai.android.douya.network.api.info.apiv2.User)6 ItemStack (org.bukkit.inventory.ItemStack)5 PersonRequiredFieldsException (org.gluu.oxtrust.exception.PersonRequiredFieldsException)5 Test (org.junit.Test)5 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)4 BigDecimal (java.math.BigDecimal)4 URI (java.net.URI)4