下面列出了org.bukkit.Material#isItem ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void importToolsBroken(PlayerInfo playerInfo, String worldName) {
Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName);
if (!object.isPresent()) {
return;
}
Optional<JSONObject> brokenSection = getBrokenSection(playerInfo.getUUID(), worldName);
if (!brokenSection.isPresent()) return;
for (Material material : Material.values()) {
if (material.isItem()) {
long broken = (Long) getStatistic(brokenSection.get(), material.getKey().toString()).orElse(0L);
if (broken <= 0) continue;
playerInfo.addRow(PlayerStat.TOOLS_BROKEN,
StatzUtil.makeQuery(playerInfo.getUUID(), "value", broken, "world",
worldName, "item", material));
}
}
}
protected static void register(
Int2ObjectOpenHashMap<EnumMap<ProtocolVersion, List<ItemStackComplexRemapper>>> registry,
Material material, ItemStackComplexRemapper transformer, ProtocolVersion... versions
) {
if (!material.isItem()) {
throw new IllegalArgumentException(material + " is not an item");
}
EnumMap<ProtocolVersion, List<ItemStackComplexRemapper>> map = registry.computeIfAbsent(ItemMaterialLookup.getRuntimeId(material), k -> new EnumMap<>(ProtocolVersion.class));
Arrays.stream(versions).forEach(version -> map.computeIfAbsent(version, k -> new ArrayList<>()).add(transformer));
}
/**
* Returns item network id
* @param material item material
* @return item network id
*/
@SuppressWarnings("deprecation")
public static int getItemNetworkId(Material material) {
if (material.isLegacy()) {
throw new IllegalArgumentException(MessageFormat.format("Material {0} is legacy", material));
}
if (!material.isItem()) {
throw new IllegalArgumentException(MessageFormat.format("Material {0} is not an item", material));
}
return ItemMaterialLookup.getRuntimeId(material);
}
private void importItemsCrafted(PlayerInfo playerInfo, String worldName) {
Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName);
if (!object.isPresent()) {
return;
}
Optional<JSONObject> craftedSection = getCraftedSection(playerInfo.getUUID(), worldName);
if (!craftedSection.isPresent()) return;
for (Material material : Material.values()) {
if (material.isItem()) {
long itemsCrafted = (Long) getStatistic(craftedSection.get(), material.getKey().toString()).orElse(0L);
if (itemsCrafted <= 0) continue;
playerInfo.addRow(PlayerStat.ITEMS_CRAFTED,
StatzUtil.makeQuery(playerInfo.getUUID(), "value", itemsCrafted, "world",
worldName, "item", material));
}
}
}
private Material getIconMaterialForSpecificStatistic(Query query, PlayerStat stat) {
if (stat == PlayerStat.BLOCKS_BROKEN || stat == PlayerStat.BLOCKS_PLACED) {
Material material = Material.getMaterial(query.getValue("block").toString());
if (material != null && material.isItem()) {
return material;
}
}
if (stat == PlayerStat.VILLAGER_TRADES) {
return Material.getMaterial(query.getValue("trade").toString());
}
if (stat == PlayerStat.KILLS_MOBS) {
return Material.getMaterial(query.getValue("weapon").toString());
}
if (stat == PlayerStat.ITEMS_PICKED_UP || stat == PlayerStat.ITEMS_DROPPED || stat == PlayerStat.ITEMS_CRAFTED || stat == PlayerStat.TOOLS_BROKEN) {
return Material.getMaterial(query.getValue("item").toString());
}
if (stat == PlayerStat.ITEMS_CAUGHT) {
return Material.getMaterial(query.getValue("caught").toString());
}
if (stat == PlayerStat.FOOD_EATEN) {
return Material.getMaterial(query.getValue("foodEaten").toString());
}
if (stat == PlayerStat.DISTANCE_TRAVELLED) {
String movementType = query.getValue("moveType").toString();
switch (movementType) {
case "SWIM":
return Material.TROPICAL_FISH;
case "FLY":
return Material.BLAZE_POWDER;
case "BOAT":
return Material.OAK_BOAT;
case "MINECART":
case "HORSE IN MINECART":
return Material.MINECART;
case "PIG IN MINECART":
case "PIG":
return Material.COOKED_PORKCHOP;
case "HORSE":
return Material.DIAMOND_HORSE_ARMOR;
case "FLY WITH ELYTRA":
return Material.ELYTRA;
case "WALK":
return Material.GOLDEN_BOOTS;
}
}
return plugin.getStatisticDescriptionConfig().getIconMaterial(stat);
}