Search in sources :

Example 26 with User

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

Example 27 with User

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

the class MedicKit method onZombieHit.

@EventHandler
public void onZombieHit(EntityDamageByEntityEvent event) {
    if (event.getDamager().getType() != EntityType.PLAYER)
        return;
    if (event.getEntity().getType() != EntityType.ZOMBIE)
        return;
    User user = UserManager.getUser(event.getDamager().getUniqueId());
    if (!(user.getKit() instanceof MedicKit))
        return;
    if (Math.random() <= 0.1) {
        for (Entity entity : user.toPlayer().getNearbyEntities(5, 5, 5)) {
            if (entity.getType() == EntityType.PLAYER) {
                Player player = (Player) entity;
                if (player.getMaxHealth() > (player.getHealth() + 1)) {
                    player.setHealth(player.getHealth() + 1);
                } else {
                    player.setHealth(player.getMaxHealth());
                }
                player.getEyeLocation().getWorld().playEffect(player.getEyeLocation(), Effect.HEART, 20);
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) User(pl.plajer.villagedefense3.User) EventHandler(org.bukkit.event.EventHandler)

Example 28 with User

use of com.google.api.ads.admanager.axis.v202108.User in project kripton by xcesco.

the class Test209Model2Runtime method testRunSqlite1.

@Test
public void testRunSqlite1() {
    BindApp2DataSource ds = BindApp2DataSource.instance();
    ds.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindApp2DaoFactory daoFactory) {
            Device device = new Device();
            device.name = "device-test";
            daoFactory.getDeviceDao().insert(device);
            User user = new User();
            user.userName = "user-test";
            daoFactory.getUserDao().insert(user);
            UserDevice userDevice = new UserDevice();
            userDevice.deviceId = device.id;
            userDevice.userId = user.id;
            daoFactory.getUserDeviceDao().insert(userDevice);
            List<Device> devices = daoFactory.getDeviceDao().getUserDevices(user.id);
            Assert.assertTrue(devices.size() == 1);
            return TransactionResult.ROLLBACK;
        }
    });
}
Also used : BindApp2DaoFactory(sqlite.kripton209.model2.BindApp2DaoFactory) TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) User(sqlite.kripton209.model2.User) Transaction(sqlite.kripton209.model2.BindApp2DataSource.Transaction) UserDevice(sqlite.kripton209.model2.UserDevice) Device(sqlite.kripton209.model2.Device) BindApp2DataSource(sqlite.kripton209.model2.BindApp2DataSource) List(java.util.List) UserDevice(sqlite.kripton209.model2.UserDevice) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 29 with User

use of com.google.api.ads.admanager.axis.v202108.User in project actframework by actframework.

the class GHIssue353 method testPut.

@Test
public void testPut() throws Exception {
    url("/gh/353").accept(H.Format.JSON).postJSON(user);
    String s = resp().body().string();
    User user2 = JSON.parseObject(s, User.class);
    assertNotNull(user2._id());
    checkRespCode();
    reset();
    Map<String, String> updates = C.map("name", "Donald Mickey");
    url("/gh/353/" + user2.getIdAsStr()).accept(H.Format.JSON).postJSON(updates).put();
    s = resp().body().string();
    User user3 = JSON.parseObject(s, User.class);
    eq(user2.getId(), user3.getId());
    eq("Donald Mickey", user3.name);
}
Also used : User(testapp.endpoint.ghissues.gh353.User) Test(org.junit.Test)

Example 30 with User

use of com.google.api.ads.admanager.axis.v202108.User in project Douya by DreaminginCodeZH.

the class UserResource method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    if (has()) {
        User user = get();
        setArguments(user.getIdOrUid(), user, user);
    }
}
Also used : User(me.zhanghai.android.douya.network.api.info.apiv2.User) SimpleUser(me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser)

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.v202108.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.v202111.User)6 UserServiceInterface (com.google.api.ads.admanager.axis.v202111.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