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); }
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; }
@Override public int getStatistic(Statistic arg0) throws IllegalArgumentException { switch (arg0) { case PLAY_ONE_TICK: long first = nukkit.getFirstPlayed(); long diff = System.currentTimeMillis() - first; // This is the // difference in // millis int seconds = (int) (diff / 1000) % 60; // And this is the // difference in seconds return seconds * 20; // And this is in ticks default: break; } throw Pokkit.unsupported(); }
public static net.minecraft.server.Statistic getMaterialStatistic(org.bukkit.Statistic stat, Material material) { try { if (stat == Statistic.MINE_BLOCK) { return StatisticList.MINE_BLOCK_COUNT[material.getId()]; } if (stat == Statistic.CRAFT_ITEM) { return StatisticList.CRAFT_BLOCK_COUNT[material.getId()]; } if (stat == Statistic.USE_ITEM) { return StatisticList.USE_ITEM_COUNT[material.getId()]; } if (stat == Statistic.BREAK_ITEM) { return StatisticList.BREAK_ITEM_COUNT[material.getId()]; } } catch (ArrayIndexOutOfBoundsException e) { return null; } return null; }
public boolean putFarming(String str, Player player){ UUID uuid = player.getUniqueId(); //各データをセット : ダイピ・種・ジャガイモ・人参使用数 sql.setCommands("use_dPickaxe", (player).getStatistic(Statistic.USE_ITEM, Material.DIAMOND_PICKAXE)); sql.setCommands("use_seed", (player).getStatistic(Statistic.USE_ITEM, Material.SEEDS)); sql.setCommands("use_potate", (player).getStatistic(Statistic.USE_ITEM, Material.POTATO_ITEM)); sql.setCommands("use_carrot", (player).getStatistic(Statistic.USE_ITEM, Material.CARROT_ITEM)); //各出力データを送信 return sql.insertCommands(str, uuid.toString()); }
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; }
@EventHandler public void onStatisticIncrement(PlayerStatisticIncrementEvent event){ //Don't increment elytra statistic if the player is swimming. if(event.getStatistic() == Statistic.AVIATE_ONE_CM && event.getPlayer().hasMetadata("swimming")){ event.setCancelled(true); } }
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; }
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; }
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; }
public long getStatistic(PlayerStat stat) { switch (stat) { case PLAY_TIME_MS: { return Long.valueOf(String.valueOf(Bukkit.getPlayer(uuid).getStatistic(Statistic.PLAY_ONE_TICK) * 50)); } default: { if (statistics.containsKey(stat)) return statistics.get(stat); else return 0; } } }
@Override public Statistic getStatisticFromInternalName(String name) { try { return Statistic.valueOf(name.toUpperCase().replace("MINECRAFT:", "")); } catch (IllegalArgumentException e) { return null; } }
@Nullable protected Number[] get(Event e) { Statistic stat = (Statistic) Utils.getEnum(Statistic.class, statistic.getSingle(e)); if (entity != null) { EntityType type = (EntityType) Utils.getEnum(EntityType.class, entity.getSingle(e)); return new Number[]{player.getSingle(e).getStatistic(stat, type)}; } if (material != null) { Material m = (Material) Utils.getEnum(Material.class, material.getSingle(e)); return new Number[]{player.getSingle(e).getStatistic(stat, m)}; } return new Number[]{player.getSingle(e).getStatistic(stat)}; }
private void setEntity(String statistic, Player player, String entity, Integer value) { Statistic stat = (Statistic) Utils.getEnum(Statistic.class, statistic); if (entity != null) { EntityType type = (EntityType) Utils.getEnum(EntityType.class, entity); player.setStatistic(stat, type, value); } }
private void setMaterial(String statistic, Player player, String material, Integer value) { Statistic stat = (Statistic) Utils.getEnum(Statistic.class, statistic); if (material != null) { Material m = (Material) Utils.getEnum(Material.class, material); player.setStatistic(stat, m, value); } player.setStatistic(stat, value); }
@Override public void setStatistic(Statistic statistic, Material material, int newValue) { Validate.notNull(statistic, "Statistic cannot be null"); Validate.notNull(material, "Material cannot be null"); Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0"); Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter"); net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material); Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic"); getHandle().getStatisticManager().setStatistic(getHandle(), nmsStatistic, newValue); }
@Override public void setStatistic(Statistic statistic, EntityType entityType, int newValue) { Validate.notNull(statistic, "Statistic cannot be null"); Validate.notNull(entityType, "EntityType cannot be null"); Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0"); Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter"); net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType); Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic"); getHandle().getStatisticManager().setStatistic(getHandle(), nmsStatistic, newValue); }
@Override public int getStatistic(Statistic statistic, EntityType entityType) { Validate.notNull(statistic, "Statistic cannot be null"); Validate.notNull(entityType, "EntityType cannot be null"); Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter"); net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType); Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic"); return getHandle().getStatisticManager().getStatisticValue(nmsStatistic); }
@Override public List<String> tabCompleteInternalStatisticOrAchievementName(String token, List<String> completions) { List<String> matches = new ArrayList<String>(); Iterator iterator = StatisticList.stats.iterator(); while (iterator.hasNext()) { String statistic = ((net.minecraft.server.Statistic) iterator.next()).name; if (statistic.startsWith(token)) { matches.add(statistic); } } return matches; }
public static Material getMaterialFromStatistic(net.minecraft.server.Statistic statistic) { String statisticString = statistic.name; int id; try { id = Integer.valueOf(statisticString.substring(statisticString.lastIndexOf(".") + 1)); } catch (NumberFormatException e) { return null; } return Material.getMaterial(id); }