Search in sources :

Example 61 with User

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

the class LooterKit method onDeath.

@EventHandler
public void onDeath(EntityDeathEvent event) {
    if (event.getEntity().getType() != EntityType.ZOMBIE)
        return;
    if (event.getEntity().getKiller() == null)
        return;
    Player player = event.getEntity().getKiller();
    if (ArenaRegistry.getArena(player) == null)
        return;
    User user = UserManager.getUser(player.getUniqueId());
    if (user.getKit() instanceof LooterKit) {
        player.getInventory().addItem(new ItemStack(Material.ROTTEN_FLESH, 1));
    }
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 62 with User

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

the class WorkerKit method onDoorPlace.

@EventHandler(priority = EventPriority.HIGHEST)
public void onDoorPlace(BlockPlaceEvent event) {
    Arena arena = ArenaRegistry.getArena(event.getPlayer());
    if (arena == null)
        return;
    User user = UserManager.getUser(event.getPlayer().getUniqueId());
    if (user.isSpectator()) {
        event.setCancelled(true);
        return;
    }
    if (event.getPlayer().getItemInHand() == null) {
        event.setCancelled(true);
        return;
    }
    if (!(event.getPlayer().getItemInHand().getType() == Material.WOOD_DOOR || event.getPlayer().getItemInHand().getType() == Material.WOODEN_DOOR)) {
        event.setCancelled(true);
        return;
    }
    if (!arena.getDoorLocations().containsKey(event.getBlock().getLocation())) {
        event.setCancelled(true);
        return;
    }
    event.setCancelled(false);
    event.getPlayer().sendMessage(ChatManager.colorMessage("Kits.Worker.Game-Item-Place-Message"));
}
Also used : User(pl.plajer.villagedefense3.User) Arena(pl.plajer.villagedefense3.arena.Arena) EventHandler(org.bukkit.event.EventHandler)

Example 63 with User

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

the class AdminCommands method addOrbsOther.

public void addOrbsOther(CommandSender sender, String p, String number) {
    // check only target player, maybe sender would do this from console.
    if (Bukkit.getPlayerExact(p) == null) {
        sender.sendMessage(ChatColor.RED + "Target player doesn't exist!");
    }
    Player player = Bukkit.getPlayer(p);
    if (!checkIsInGameInstance(player))
        return;
    if (!hasPermission(sender, "villagedefense.admin.addorbs.others"))
        return;
    if (NumberUtils.isNumber(number)) {
        User user = UserManager.getUser(player.getUniqueId());
        user.setInt("orbs", user.getInt("orbs") + Integer.parseInt(number));
        sender.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("Commands.Admin-Commands.Added-Orbs"));
    } else {
        sender.sendMessage(ChatColor.RED + "Wrong usage. Do /villagedefense addorbs <player> <amount>");
    }
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User)

Example 64 with User

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

the class AdminCommands method respawn.

public void respawn(CommandSender sender) {
    if (checkSenderIsConsole(sender))
        return;
    Player player = (Player) sender;
    if (!hasPermission(player, "villagedefense.admin.respawn"))
        return;
    if (!checkIsInGameInstance(player))
        return;
    Arena arena = ArenaRegistry.getArena(player);
    player.setGameMode(GameMode.SURVIVAL);
    User user = UserManager.getUser(player.getUniqueId());
    user.setFakeDead(false);
    user.setSpectator(false);
    arena.teleportToStartLocation(player);
    player.setFlying(false);
    player.setAllowFlight(false);
    ArenaUtils.showPlayer(player, arena);
    player.getInventory().clear();
    user.getKit().giveKitItems(player);
    player.sendMessage(ChatManager.colorMessage("In-Game.Back-In-Game"));
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User) Arena(pl.plajer.villagedefense3.arena.Arena)

Example 65 with User

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

the class AdminCommands method addOrbs.

public void addOrbs(CommandSender sender, String number) {
    if (!checkIsInGameInstance((Player) sender))
        return;
    if (!hasPermission(sender, "villagedefense.admin.addorbs"))
        return;
    if (NumberUtils.isNumber(number)) {
        User user = UserManager.getUser(((Player) sender).getUniqueId());
        user.setInt("orbs", user.getInt("orbs") + Integer.parseInt(number));
        sender.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("Commands.Admin-Commands.Added-Orbs"));
    } else {
        sender.sendMessage(ChatColor.RED + "Wrong usage. Do /villagedefense addorbs <amount>");
    }
}
Also used : Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User)

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