org.bukkit.Statistic Java Examples
The following examples show how to use
org.bukkit.Statistic.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NMSHandler.java From Shopkeepers with GNU General Public License v3.0 | 7 votes |
@Override public boolean openTradeWindow(String title, List<ItemStack[]> recipes, Player player) { // create empty merchant: Merchant merchant = Bukkit.createMerchant(title); // create list of merchant recipes: List<MerchantRecipe> merchantRecipes = new ArrayList<MerchantRecipe>(); for (ItemStack[] recipe : recipes) { // skip invalid recipes: if (recipe == null || recipe.length != 3 || Utils.isEmpty(recipe[0]) || Utils.isEmpty(recipe[2])) { continue; } // create and add merchant recipe: merchantRecipes.add(this.createMerchantRecipe(recipe[0], recipe[1], recipe[2])); } // set merchant's recipes: merchant.setRecipes(merchantRecipes); // increase 'talked-to-villager' statistic: player.incrementStatistic(Statistic.TALKED_TO_VILLAGER); // open merchant: return player.openMerchant(merchant, true) != null; }
Example #2
Source File: NMSHandler.java From Shopkeepers with GNU General Public License v3.0 | 6 votes |
@Override public boolean openTradeWindow(String title, List<ItemStack[]> recipes, Player player) { // create empty merchant: Merchant merchant = Bukkit.createMerchant(title); // create list of merchant recipes: List<MerchantRecipe> merchantRecipes = new ArrayList<MerchantRecipe>(); for (ItemStack[] recipe : recipes) { // skip invalid recipes: if (recipe == null || recipe.length != 3 || Utils.isEmpty(recipe[0]) || Utils.isEmpty(recipe[2])) { continue; } // create and add merchant recipe: merchantRecipes.add(this.createMerchantRecipe(recipe[0], recipe[1], recipe[2])); } // set merchant's recipes: merchant.setRecipes(merchantRecipes); // increase 'talked-to-villager' statistic: player.incrementStatistic(Statistic.TALKED_TO_VILLAGER); // open merchant: return player.openMerchant(merchant, true) != null; }
Example #3
Source File: SentinelEventHandler.java From Sentinel with MIT License | 6 votes |
/** * Called when a player statistic increments, to prevent the "PLAYER_KILLS" stat updating for killing an NPC. */ @EventHandler public void onStatisticIncrement(PlayerStatisticIncrementEvent event) { if (event.getStatistic() == Statistic.PLAYER_KILLS) { UUID uuid = event.getPlayer().getUniqueId(); TrackedKillToBlock blocker = killStatsToBlock.get(uuid); if (blocker != null) { blocker.killCount--; if (blocker.systemTick != SentinelPlugin.instance.tickTimeTotal) { killStatsToBlock.remove(uuid); return; } if (blocker.killCount <= 0) { killStatsToBlock.remove(uuid); } event.setCancelled(true); } } }
Example #4
Source File: PlayerStats.java From CS-CoreLib with GNU General Public License v3.0 | 6 votes |
public long getStatistic(PlayerStat stat) { switch (stat) { case PLAY_TIME_MS: { if (ReflectionUtils.isVersion("v1_12_", "v1_11_", "v1_10_", "v1_9_")) { return Long.valueOf(String.valueOf(Bukkit.getPlayer(uuid).getStatistic(Statistic.valueOf("PLAY_ONE_TICK")) * 50)); } else { return Long.valueOf(String.valueOf(Bukkit.getPlayer(uuid).getStatistic(Statistic.valueOf("PLAY_ONE_MINUTE")) * 1000L)); } } default: { if (statistics.containsKey(stat)) return statistics.get(stat); else return 0; } } }
Example #5
Source File: ImportManager.java From Statz with GNU General Public License v3.0 | 6 votes |
private void importFishCaught(PlayerInfo playerInfo, String worldName) { Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName); if (!object.isPresent()) { return; } long caught = (Long) getStatistic(object.get(), Statistic.FISH_CAUGHT.getKey().toString()) .orElse(0L); if (caught <= 0) return; playerInfo.addRow(PlayerStat.ITEMS_CAUGHT, StatzUtil.makeQuery(playerInfo.getUUID(), "value", caught, "world", worldName, "caught", Material.TROPICAL_FISH)); }
Example #6
Source File: ImportManager.java From Statz with GNU General Public License v3.0 | 6 votes |
private void importPlayersKilled(PlayerInfo playerInfo, String worldName) { Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName); if (!object.isPresent()) { return; } long playersKilled = (Long) getStatistic(object.get(), Statistic.PLAYER_KILLS.getKey().toString()) .orElse(0L); if (playersKilled <= 0) return; playerInfo.addRow(PlayerStat.KILLS_PLAYERS, StatzUtil.makeQuery(playerInfo.getUUID(), "value", playersKilled, "world", worldName, "playerKilled", "Notch")); }
Example #7
Source File: ImportManager.java From Statz with GNU General Public License v3.0 | 6 votes |
private void importPlaytime(PlayerInfo playerInfo, String worldName) { Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName); if (!object.isPresent()) { return; } long ticksPlayed = (Long) getStatistic(object.get(), Statistic.PLAY_ONE_MINUTE.getKey().toString()) .orElse(0L); if (ticksPlayed <= 0) return; playerInfo.addRow(PlayerStat.TIME_PLAYED, StatzUtil.makeQuery(playerInfo.getUUID(), "value", ticksPlayed / (20 * 60), "world", worldName)); }
Example #8
Source File: ImportManager.java From Statz with GNU General Public License v3.0 | 6 votes |
private void importDamageTaken(PlayerInfo playerInfo, String worldName) { Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName); if (!object.isPresent()) { return; } long damageTaken = (Long) getStatistic(object.get(), Statistic.DAMAGE_TAKEN.getKey().toString()) .orElse(0L); if (damageTaken <= 0) return; playerInfo.addRow(PlayerStat.DAMAGE_TAKEN, StatzUtil.makeQuery(playerInfo.getUUID(), "value", damageTaken, "world", worldName, "cause", EntityDamageEvent.DamageCause.ENTITY_ATTACK)); }
Example #9
Source File: DeathEvent.java From StackMob-3 with GNU General Public License v3.0 | 6 votes |
private void multiplication(LivingEntity dead, List<ItemStack> drops, int subtractAmount, int originalExperience){ if(sm.getCustomConfig().getBoolean("multiply-drops.enabled")){ sm.getDropTools().doDrops(subtractAmount, dead, drops); } if(sm.getCustomConfig().getBoolean("multiply-exp.enabled")){ // double newExperience = subtractAmount * (originalExperience * sm.config.getCustomConfig().getDouble("multiply-exp-scaling", 1.0)); ExperienceOrb exp = (ExperienceOrb) dead.getWorld().spawnEntity(dead.getLocation(), EntityType.EXPERIENCE_ORB); exp.setExperience(sm.getExpTools().multiplyExperience(originalExperience, subtractAmount)); } if(sm.getCustomConfig().getBoolean("increase-player-stats")){ if(dead.getKiller() != null){ int oldStat = dead.getKiller().getStatistic(Statistic.MOB_KILLS); dead.getKiller().setStatistic(Statistic.MOB_KILLS, oldStat + subtractAmount); } } }
Example #10
Source File: AccelerateNightTask.java From Harbor with MIT License | 6 votes |
@Override public void run() { final long time = world.getTime(); final int dayTime = Math.max(150, Config.getInteger("night-skip.daytime-ticks")); final int sleeping = Checker.getSleeping(world).size(); double timeRate = Config.getInteger("night-skip.time-rate"); if (Config.getBoolean("night-skip.proportional-acceleration")) { if (sleeping != 0) timeRate = Math.min(timeRate, Math.round(timeRate / world.getPlayers().size() * sleeping)); } if (time >= (dayTime - timeRate * 1.5) && time <= dayTime) { if (Config.getBoolean("night-skip.reset-phantom-statistic")) { world.getPlayers().forEach(player -> player.setStatistic(Statistic.TIME_SINCE_REST, 0)); } Checker.SKIPPING_WORLDS.remove(world); BedListener.COOLDOWNS.clear(); Messages.sendRandomChatMessage(world, "messages.chat.night-skipped"); this.cancel(); } else { world.setTime(time + (int) timeRate); } }
Example #11
Source File: ImportManager.java From Statz with GNU General Public License v3.0 | 6 votes |
private void importBedsEntered(PlayerInfo playerInfo, String worldName) { Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName); if (!object.isPresent()) { return; } long bedsEntered = (Long) getStatistic(object.get(), Statistic.SLEEP_IN_BED.getKey().toString()).orElse(0L); if (bedsEntered <= 0) return; playerInfo.addRow(PlayerStat.ENTERED_BEDS, StatzUtil.makeQuery(playerInfo.getUUID(), "value", bedsEntered, "world", worldName)); }
Example #12
Source File: CraftStatistic.java From Kettle with GNU General Public License v3.0 | 6 votes |
public static StatBase getMaterialStatistic(Statistic stat, Material material) { try { if (stat == Statistic.MINE_BLOCK) { return StatList.getBlockStats(CraftMagicNumbers.getBlock(material)); // PAIL: getMineBlockStatistic } if (stat == Statistic.CRAFT_ITEM) { return StatList.getCraftStats(CraftMagicNumbers.getItem(material)); // PAIL: getCraftItemStatistic } if (stat == Statistic.USE_ITEM) { return StatList.getObjectUseStats(CraftMagicNumbers.getItem(material)); // PAIL: getUseItemStatistic } if (stat == Statistic.BREAK_ITEM) { return StatList.getObjectBreakStats(CraftMagicNumbers.getItem(material)); // PAIL: getBreakItemStatistic } if (stat == Statistic.PICKUP) { return StatList.getObjectsPickedUpStats(CraftMagicNumbers.getItem(material)); // PAIL: getPickupStatistic } if (stat == Statistic.DROP) { return StatList.getDroppedObjectStats(CraftMagicNumbers.getItem(material)); // PAIL: getDropItemStatistic } } catch (ArrayIndexOutOfBoundsException e) { return null; } return null; }
Example #13
Source File: ImportManager.java From Statz with GNU General Public License v3.0 | 6 votes |
private void importVillageTrades(PlayerInfo playerInfo, String worldName) { Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName); if (!object.isPresent()) { return; } long traded = (Long) getStatistic(object.get(), Statistic.TRADED_WITH_VILLAGER.getKey().toString()).orElse(0L); if (traded <= 0) return; playerInfo.addRow(PlayerStat.VILLAGER_TRADES, StatzUtil.makeQuery(playerInfo.getUUID(), "value", traded, "world", worldName, "trade", Material.STICK)); }
Example #14
Source File: CraftStatistic.java From Thermos with GNU General Public License v3.0 | 6 votes |
public static org.bukkit.Statistic getBukkitStatisticByName(String name) { if (name.startsWith("stat.killEntity")) { name = "stat.killEntity"; } if (name.startsWith("stat.entityKilledBy")) { name = "stat.entityKilledBy"; } if (name.startsWith("stat.breakItem")) { name = "stat.breakItem"; } if (name.startsWith("stat.useItem")) { name = "stat.useItem"; } if (name.startsWith("stat.mineBlock")) { name = "stat.mineBlock"; } if (name.startsWith("stat.craftItem")) { name = "stat.craftItem"; } return statistics.get(name); }
Example #15
Source File: CraftStatistic.java From Thermos with GNU General Public License v3.0 | 6 votes |
public static net.minecraft.stats.StatBase getMaterialStatistic(org.bukkit.Statistic stat, Material material) { try { if (stat == Statistic.MINE_BLOCK) { return StatList.mineBlockStatArray[material.getId()]; } if (stat == Statistic.CRAFT_ITEM) { return StatList.objectCraftStats[material.getId()]; } if (stat == Statistic.USE_ITEM) { return StatList.objectUseStats[material.getId()]; } if (stat == Statistic.BREAK_ITEM) { return StatList.objectBreakStats[material.getId()]; } } catch (ArrayIndexOutOfBoundsException e) { return null; } return null; }
Example #16
Source File: CraftStatistic.java From Kettle with GNU General Public License v3.0 | 5 votes |
public static StatBase getEntityStatistic(Statistic stat, EntityType entity) { EntityList.EntityEggInfo monsteregginfo = EntityList.ENTITY_EGGS.get(new ResourceLocation(entity.getName())); if (monsteregginfo != null) { if (stat == Statistic.KILL_ENTITY) { return monsteregginfo.killEntityStat; } if (stat == Statistic.ENTITY_KILLED_BY) { return monsteregginfo.entityKilledByStat; } } return null; }
Example #17
Source File: PlayerStatisticIncrementEvent.java From Kettle with GNU General Public License v3.0 | 5 votes |
public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue, Material material) { super(player); this.statistic = statistic; this.initialValue = initialValue; this.newValue = newValue; this.entityType = null; this.material = material; }
Example #18
Source File: CraftStatistic.java From Kettle with GNU General Public License v3.0 | 5 votes |
public static Statistic getBukkitStatisticByName(String name) { if (name.startsWith("stat.killEntity.")) { name = "stat.killEntity"; } if (name.startsWith("stat.entityKilledBy.")) { name = "stat.entityKilledBy"; } if (name.startsWith("stat.breakItem.")) { name = "stat.breakItem"; } if (name.startsWith("stat.useItem.")) { name = "stat.useItem"; } if (name.startsWith("stat.mineBlock.")) { name = "stat.mineBlock"; } if (name.startsWith("stat.craftItem.")) { name = "stat.craftItem"; } if (name.startsWith("stat.drop.")) { name = "stat.drop"; } if (name.startsWith("stat.pickup.")) { name = "stat.pickup"; } return statistics.get(name); }
Example #19
Source File: PlayerStatisticIncrementEvent.java From Kettle with GNU General Public License v3.0 | 5 votes |
public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue) { super(player); this.statistic = statistic; this.initialValue = initialValue; this.newValue = newValue; this.entityType = null; this.material = null; }
Example #20
Source File: PlayerStatisticIncrementEvent.java From Kettle with GNU General Public License v3.0 | 5 votes |
public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue, EntityType entityType) { super(player); this.statistic = statistic; this.initialValue = initialValue; this.newValue = newValue; this.entityType = entityType; this.material = null; }
Example #21
Source File: ImportManager.java From Statz with GNU General Public License v3.0 | 5 votes |
private void importJoins(PlayerInfo playerInfo, String worldName) { Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName); if (!object.isPresent()) { return; } long joins = (Long) getStatistic(object.get(), Statistic.LEAVE_GAME.getKey().toString()) .orElse(0L); if (joins <= 0) return; playerInfo.addRow(PlayerStat.JOINS, StatzUtil.makeQuery(playerInfo.getUUID(), "value", joins)); }
Example #22
Source File: ImportManager.java From Statz with GNU General Public License v3.0 | 5 votes |
private void importDeaths(PlayerInfo playerInfo, String worldName) { Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName); if (!object.isPresent()) { return; } long deaths = (Long) getStatistic(object.get(), Statistic.DEATHS.getKey().toString()) .orElse(0L); if (deaths <= 0) return; playerInfo.addRow(PlayerStat.DEATHS, StatzUtil.makeQuery(playerInfo.getUUID(), "value", deaths, "world", worldName)); }
Example #23
Source File: CraftStatistic.java From Thermos with GNU General Public License v3.0 | 5 votes |
public static net.minecraft.stats.StatBase getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) { EntityEggInfo entityEggInfo = (EntityEggInfo) EntityList.entityEggs.get(Integer.valueOf(entity.getTypeId())); if (entityEggInfo != null) { return entityEggInfo.field_151512_d; } return null; }
Example #24
Source File: UnresolvedOfflinePlayer.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public void decrementStatistic(Statistic statistic) throws IllegalArgumentException { bukkitOfflinePlayer.decrementStatistic(statistic); }
Example #25
Source File: CraftStatistic.java From Thermos with GNU General Public License v3.0 | 4 votes |
public static net.minecraft.stats.StatBase getNMSStatistic(org.bukkit.Statistic statistic) { return StatList.func_151177_a(statistics.inverse().get(statistic)); }
Example #26
Source File: UnresolvedOfflinePlayer.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public void incrementStatistic(Statistic statistic) throws IllegalArgumentException { bukkitOfflinePlayer.incrementStatistic(statistic); }
Example #27
Source File: ImportManager.java From Statz with GNU General Public License v3.0 | 4 votes |
private void importDistanceTravelled(PlayerInfo playerInfo, String worldName) { Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName); if (!object.isPresent()) { return; } long moved = (Long) getStatistic(object.get(), Statistic.WALK_ONE_CM.getKey().toString()) .orElse(0L) / 100L; if (moved > 0) { playerInfo.addRow(PlayerStat.DISTANCE_TRAVELLED, StatzUtil.makeQuery(playerInfo.getUUID(), "value", moved, "world", worldName, "moveType", "WALK")); } moved = (Long) getStatistic(object.get(), Statistic.SWIM_ONE_CM.getKey().toString()) .orElse(0L) / 100L; if (moved > 0) { playerInfo.addRow(PlayerStat.DISTANCE_TRAVELLED, StatzUtil.makeQuery(playerInfo.getUUID(), "value", moved, "world", worldName, "moveType", "SWIM")); } moved = (Long) getStatistic(object.get(), Statistic.FLY_ONE_CM.getKey().toString()) .orElse(0L) / 100L; if (moved > 0) { playerInfo.addRow(PlayerStat.DISTANCE_TRAVELLED, StatzUtil.makeQuery(playerInfo.getUUID(), "value", moved, "world", worldName, "moveType", "FLY WITH ELYTRA")); } moved = (Long) getStatistic(object.get(), Statistic.BOAT_ONE_CM.getKey().toString()) .orElse(0L) / 100L; if (moved > 0) { playerInfo.addRow(PlayerStat.DISTANCE_TRAVELLED, StatzUtil.makeQuery(playerInfo.getUUID(), "value", moved, "world", worldName, "moveType", "BOAT")); } moved = (Long) getStatistic(object.get(), Statistic.MINECART_ONE_CM.getKey().toString()) .orElse(0L) / 100L; if (moved > 0) { playerInfo.addRow(PlayerStat.DISTANCE_TRAVELLED, StatzUtil.makeQuery(playerInfo.getUUID(), "value", moved, "world", worldName, "moveType", "MINECART")); } moved = (Long) getStatistic(object.get(), Statistic.HORSE_ONE_CM.getKey().toString()) .orElse(0L) / 100L; if (moved > 0) { playerInfo.addRow(PlayerStat.DISTANCE_TRAVELLED, StatzUtil.makeQuery(playerInfo.getUUID(), "value", moved, "world", worldName, "moveType", "HORSE")); } moved = (Long) getStatistic(object.get(), Statistic.PIG_ONE_CM.getKey().toString()) .orElse(0L) / 100L; if (moved > 0) { playerInfo.addRow(PlayerStat.DISTANCE_TRAVELLED, StatzUtil.makeQuery(playerInfo.getUUID(), "value", moved, "world", worldName, "moveType", "PIG")); } }
Example #28
Source File: CraftStatistic.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static StatBase getNMSStatistic(Statistic statistic) { return StatList.getOneShotStat(statistics.inverse().get(statistic)); }
Example #29
Source File: CraftStatistic.java From Thermos with GNU General Public License v3.0 | 4 votes |
public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.StatBase statistic) { return getBukkitStatisticByName(statistic.statId); }
Example #30
Source File: NullPlayer.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
@Override public int getStatistic(@NotNull Statistic statistic) throws IllegalArgumentException { return 0; }