Search in sources :

Example 81 with User

use of org.neo4j.ogm.domain.gh368.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 82 with User

use of org.neo4j.ogm.domain.gh368.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 83 with User

use of org.neo4j.ogm.domain.gh368.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)

Example 84 with User

use of org.neo4j.ogm.domain.gh368.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 85 with User

use of org.neo4j.ogm.domain.gh368.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)

Aggregations

User (pl.plajer.villagedefense3.User)30 Player (org.bukkit.entity.Player)18 User (org.gluu.oxtrust.model.scim2.User)17 Test (org.junit.Test)17 User (org.openstack4j.model.identity.v3.User)13 EventHandler (org.bukkit.event.EventHandler)11 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)10 ScimPatchUser (org.gluu.oxtrust.model.scim2.ScimPatchUser)10 Date (java.util.Date)9 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.v202202.User)6 SimpleUser (me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser)6 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)6 Test (org.junit.jupiter.api.Test)6 ArrayList (java.util.ArrayList)5 Path (javax.ws.rs.Path)5 User (org.apache.archiva.redback.rest.api.model.v2.User)5 UserInfo (org.apache.archiva.redback.rest.api.model.v2.UserInfo)5 PersonRequiredFieldsException (org.gluu.oxtrust.exception.PersonRequiredFieldsException)5