Examples of PlayerStats


Examples of me.drayshak.WorldInventories.PlayerStats

                        MIYamlFiles.saveYamlFile(groups, "groups.yml");
                        for(OfflinePlayer player1 : Bukkit.getServer().getOfflinePlayers()) {
                            plugin.getLogger().info("Importing player " + player1.getName() + "'s inventory from group " + mvgroup.getName());
                            HashMap<Integer, ItemStack[]> pinventory = mvinventories.loadPlayerInventory(player1.getName(), mvgroup, InventoryLoadType.INVENTORY);
                            HashMap<Integer, ItemStack[]> playerenderchest = mvinventories.loadPlayerInventory(player1.getName(), mvgroup, InventoryLoadType.ENDERCHEST);
                            PlayerStats playerstats = mvinventories.loadPlayerStats(player1.getName(), mvgroup);
                            if(pinventory != null) {
                                ItemStack[] inventory = pinventory.get(InventoryStoredType.INVENTORY);
                                ItemStack[] armor = pinventory.get(InventoryStoredType.ARMOUR);
                                double health = 20;
                                int hunger = 20;
                                float saturation = 5;
                                int totalexp = 0;
                                int level = 0;
                                float exp = 0;
                                if(playerstats != null) {
                                    health = playerstats.getHealth();
                                    hunger = playerstats.getFoodLevel();
                                    saturation = playerstats.getSaturation();
                                    level = playerstats.getLevel();
                                    exp = playerstats.getExp();
                                    totalexp = plugin.getTotalXP(level, exp);
                                }
                                if(MIYamlFiles.usesql) {
                                    if(playerenderchest != null) {
                                        ItemStack[] enderchestinventory = playerenderchest.get(InventoryStoredType.ARMOUR);
View Full Code Here

Examples of org.newinstance.gucoach.model.PlayerStats

     * Converts a data record of a player's statistics into a player stats entity.
     *
     * @param record the record to convert
     */
    private void convertRecordToPlayerStats(final String[] record) {
        final PlayerStats playerStats = new PlayerStats();
        playerStats.setPlayer(players.get(new Long(record[AttributePosition.ID])));
        playerStats.setNumber(new Integer(record[AttributePosition.NUMBER]));
        // is training filled?
        final String training = record[AttributePosition.TRAINING];
        playerStats.setTraining(StringUtils.isEmpty(training) ? null : training);
        // erase apostrophe in strength value
        final String strength = StringUtils.remove(record[AttributePosition.STRENGTH], '\'');
        playerStats.setAverageStrength(new Float(strength));
        playerStats.setPosition(Position.valueOf(record[AttributePosition.POSITION]));
        playerStats.setForm(new Integer(record[AttributePosition.FORM]));
        playerStats.setEnergy(new Integer(record[AttributePosition.ENERGY]));
        playerStats.setEndurance(new Integer(record[AttributePosition.ENDURANCE]));
        playerStats.setExperience(new Integer(record[AttributePosition.EXPERIENCE]));
        playerStats.setSkillGoalkeeping(new Integer(record[AttributePosition.SKILL_GOALKEEPING]));
        playerStats.setSkillTackling(new Integer(record[AttributePosition.SKILL_TACKLING]));
        playerStats.setSkillPlaymaking(new Integer(record[AttributePosition.SKILL_PLAYMAKING]));
        playerStats.setSkillPassing(new Integer(record[AttributePosition.SKILL_PASSING]));
        playerStats.setSkillScoring(new Integer(record[AttributePosition.SKILL_SCORING]));
        playerStats.setTalent(record[AttributePosition.TALENT]);
        playerStats.setTalentLevel(new Integer(record[AttributePosition.TALENT_LEVEL]));
        playerStats.setAge(new Integer(record[AttributePosition.AGE]));
        playerStats.setSalary(new Integer(record[AttributePosition.SALARY]));
        playerStats.setAssignments(new Integer(record[AttributePosition.ASSIGNMENTS]));
        playerStats.setGoalsSeason(new Integer(record[AttributePosition.GOALS_SEASON]));
        playerStats.setGoalsTotal(new Integer(record[AttributePosition.GOALS_TOTAL]));
        // is market value filled?
        final String marketValue = record[AttributePosition.MARKET_VALUE];
        playerStats.setMarketValue(StringUtils.isEmpty(marketValue) ? null : new Integer(marketValue));
        playerStats.setYellowCardsSeason(new Integer(record[AttributePosition.YELLOW_CARDS_SEASON]));
        playerStats.setYellowCardsTotal(new Integer(record[AttributePosition.YELLOW_CARDS_TOTAL]));
        playerStats.setRedCardsSeason(new Integer(record[AttributePosition.RED_CARDS_SEASON]));
        playerStats.setRedCardsTotal(new Integer(record[AttributePosition.RED_CARDS_TOTAL]));
        playerStats.setImportDate(importDate);
        stats.put(playerStats.getPlayer().getId(), playerStats);
    }
View Full Code Here

Examples of org.newinstance.gucoach.model.PlayerStats

                    em.getTransaction().begin();
                    playerHistoryService.insertPlayerHistory(importService.getHistory().get(player.getId()));
                    em.getTransaction().commit();
                } else {
                    // update player statistics only if there are changes
                    final PlayerStats playerStatsDb = playerStatsService.findPlayerStatsByPlayer(player);
                    if (!importService.getStats().get(player.getId()).equals(playerStatsDb)) {
                        em.getTransaction().begin();
                        playerStatsService.updatePlayerStats(importService.getStats().get(player.getId()));
                        em.getTransaction().commit();
                    }
View Full Code Here

Examples of org.newinstance.gucoach.model.PlayerStats

    public static ObservableList<PlayerDataRow> getPlayerData() {
        // make sure to initialise tables
        final List<PlayerDataRow> playerDataRows = new ArrayList<PlayerDataRow>();
        final List<Player> players = playerService.findAllPlayers();
        for (final Player player : players) {
            final PlayerStats playerStats = playerStatsService.findPlayerStatsByPlayer(player);
            playerDataRows.add(convertToPlayerDataRow(player, playerStats));
        }

        return FXCollections.observableList(playerDataRows);
    }
View Full Code Here

Examples of org.newinstance.gucoach.model.PlayerStats

        ImportController importController = new ImportControllerImpl(em);
        importController.executeImport(new File(SAMPLE_IMPORT_FILE));
        final List<Player> players = playerService.findAllPlayers();
        Assert.assertFalse(players.isEmpty());
        for (final Player player : players) {
            final PlayerStats playerStats = playerStatsService.findPlayerStatsByPlayer(player);
            Assert.assertNotNull(playerStats);
            Assert.assertEquals(player.getId(), playerStats.getPlayer().getId());
            final List<PlayerHistory> playerHistoryList = playerHistoryService.findPlayerHistoryByPlayer(player);
            Assert.assertNotNull(playerHistoryList);
            Assert.assertFalse(playerHistoryList.isEmpty());
        }
    }
View Full Code Here

Examples of org.newinstance.gucoach.model.PlayerStats

    }

    @Test(expected = NoResultException.class)
    public void insertAndDeletePlayerStatsTest() {
        final Player player = createPlayer();
        final PlayerStats playerStats1 = createPlayerStats(player);

        em.getTransaction().begin();
        playerService.insertPlayer(player);
        playerStatsService.insertPlayerStats(playerStats1);
        em.getTransaction().commit();

        List<Player> playerList = playerService.findAllPlayers();
        Assert.assertNotNull(playerList);
        Assert.assertFalse(playerList.isEmpty());

        PlayerStats playerStats = playerStatsService.findPlayerStatsByPlayer(player);
        Assert.assertNotNull(playerStats);
        Assert.assertEquals("Player statistics does not match to player.", player, playerStats.getPlayer());

        // delete player (and related player statistics records)
        em.getTransaction().begin();
        playerService.removePlayer(player);
        em.getTransaction().commit();
View Full Code Here

Examples of org.newinstance.gucoach.model.PlayerStats

    }

    @Test
    public void insertPlayerStatsTest() {
        final Player player = createPlayer();
        final PlayerStats playerStats = createPlayerStats(player);

        em.getTransaction().begin();
        playerService.insertPlayer(player);
        playerStatsService.insertPlayerStats(playerStats);
        em.getTransaction().commit();

        final PlayerStats result = em.find(PlayerStats.class, playerStats.getId());
        Assert.assertNotNull(result);
        Assert.assertEquals(90, result.getForm().intValue());
        Assert.assertEquals(Position.DEF, result.getPosition());
    }
View Full Code Here

Examples of org.newinstance.gucoach.model.PlayerStats

    }

    @Test(expected = NoResultException.class)
    public void insertUpdateAndDeletePlayerStatsTest() {
        final Player player = createPlayer();
        final PlayerStats playerStats1 = createPlayerStats(player);

        em.getTransaction().begin();
        playerService.insertPlayer(player);
        playerStatsService.insertPlayerStats(playerStats1);
        em.getTransaction().commit();

        List<Player> playerList = playerService.findAllPlayers();
        Assert.assertNotNull(playerList);
        Assert.assertFalse(playerList.isEmpty());

        PlayerStats playerStats = playerStatsService.findPlayerStatsByPlayer(player);
        Assert.assertNotNull(playerStats);
        Assert.assertEquals("Player statistics do not match to player.", player, playerStats.getPlayer());

        // UPDATE
        playerStats1.setPlayer(player);
        playerStats1.setEndurance(65);
        playerStats1.setEnergy(71);
        playerStats1.setForm(85);

        em.getTransaction().begin();
        playerStatsService.updatePlayerStats(playerStats1);
        em.getTransaction().commit();

        playerStats = playerStatsService.findPlayerStatsByPlayer(player);
        Assert.assertNotNull(playerStats);

        // compare updated values
        Assert.assertEquals(playerStats1.getEndurance(), playerStats.getEndurance());
        Assert.assertEquals(playerStats1.getEnergy(), playerStats.getEnergy());
        Assert.assertEquals(playerStats1.getForm(), playerStats.getForm());

        // DELETE
        em.getTransaction().begin();
        playerService.removePlayer(player);
        em.getTransaction().commit();
View Full Code Here

Examples of org.newinstance.gucoach.model.PlayerStats

    }

    @Test
    public void updatePlayerStatsTest() {
        final Player player = createPlayer();
        final PlayerStats playerStats = createPlayerStats(player);

        em.getTransaction().begin();
        playerService.insertPlayer(player);
        playerStatsService.insertPlayerStats(playerStats);
        em.getTransaction().commit();

        // update player statistics
        playerStats.setAge(30);

        em.getTransaction().begin();
        playerStatsService.updatePlayerStats(playerStats);
        em.getTransaction().commit();

        final PlayerStats result = playerStatsService.findPlayerStatsByPlayer(player);
        Assert.assertNotNull(result);
        Assert.assertEquals(30, result.getAge().intValue());
    }
View Full Code Here

Examples of org.newinstance.gucoach.model.PlayerStats

     *
     * @param player the player the statistics record belongs to
     * @return a new entity
     */
    protected PlayerStats createPlayerStats(final Player player) {
        final PlayerStats playerStats = new PlayerStats();
        playerStats.setAge(23);
        playerStats.setAssignments(33);
        playerStats.setAverageStrength(3.4f);
        playerStats.setEndurance(77);
        playerStats.setEnergy(88);
        playerStats.setExperience(100);
        playerStats.setForm(90);
        playerStats.setGoalsSeason(4);
        playerStats.setGoalsTotal(10);
        playerStats.setMarketValue(null);
        playerStats.setNumber(11);
        playerStats.setPlayer(player);
        playerStats.setPosition(Position.DEF);
        playerStats.setRedCardsSeason(0);
        playerStats.setRedCardsTotal(1);
        playerStats.setSalary(4300);
        playerStats.setSkillGoalkeeping(3);
        playerStats.setSkillPassing(19);
        playerStats.setSkillPlaymaking(17);
        playerStats.setSkillScoring(12);
        playerStats.setSkillTackling(37);
        playerStats.setTalent(null);
        playerStats.setTalentLevel(0);
        playerStats.setTraining(null);
        playerStats.setYellowCardsSeason(2);
        playerStats.setYellowCardsTotal(7);
        playerStats.setImportDate(new Date());
        return playerStats;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.