Search in sources :

Example 81 with User

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

the class Events method onFriendHurt.

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

Example 82 with User

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

the class Events method onEntityInteractEntity.

@EventHandler
public void onEntityInteractEntity(PlayerInteractEntityEvent event) {
    Arena arena = ArenaRegistry.getArena(event.getPlayer());
    if (arena == null)
        return;
    User user = UserManager.getUser(event.getPlayer().getUniqueId());
    if (user.isFakeDead()) {
        event.setCancelled(true);
        return;
    }
    if (event.getPlayer().getItemInHand().getType() == Material.SADDLE) {
        if (event.getRightClicked().getType() == EntityType.IRON_GOLEM || event.getRightClicked().getType() == EntityType.VILLAGER) {
            event.getRightClicked().setPassenger(event.getPlayer());
            event.setCancelled(true);
            return;
        }
    }
    if (event.getRightClicked().getType() == EntityType.VILLAGER) {
        event.setCancelled(true);
        ShopManager.openShop(event.getPlayer());
    } else if (event.getRightClicked().getType() == EntityType.IRON_GOLEM) {
        IronGolem ironGolem = (IronGolem) event.getRightClicked();
        if (ironGolem.getCustomName() != null && ironGolem.getCustomName().contains(event.getPlayer().getName())) {
            event.getRightClicked().setPassenger(event.getPlayer());
        } else {
            event.getPlayer().sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Cant-Ride-Others-Golem"));
        }
    }
}
Also used : User(pl.plajer.villagedefense3.User) IronGolem(org.bukkit.entity.IronGolem) Arena(pl.plajer.villagedefense3.arena.Arena) EventHandler(org.bukkit.event.EventHandler)

Example 83 with User

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

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

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

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