org.bukkit.Material#values ( )源码实例Demo

下面列出了org.bukkit.Material#values ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Transport-Pipes   文件: DuctListener.java
@Inject
public DuctListener(ItemService itemService, JavaPlugin plugin, DuctRegister ductRegister, GlobalDuctManager globalDuctManager, TPContainerListener tpContainerListener, GeneralConf generalConf, SentryService sentry, TransportPipes transportPipes, ThreadService threadService, PlayerSettingsService playerSettingsService) {
    this.itemService = itemService;
    this.ductRegister = ductRegister;
    this.globalDuctManager = globalDuctManager;
    this.tpContainerListener = tpContainerListener;
    this.generalConf = generalConf;
    this.sentry = sentry;
    this.transportPipes = transportPipes;
    this.threadService = threadService;
    this.playerSettingsService = playerSettingsService;

    for (Material m : Material.values()) {
        if (m.isInteractable()) {
            interactables.add(m);
        }
    }

    Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::updateInteractSet, 0L, 1L);
}
 
源代码2 项目: Skript   文件: BurgerHelper.java
public static Map<Integer,Material> mapIds() {
if (typeIdMethod == null) {
	throw new IllegalStateException("requires Minecraft 1.12.2 or older");
}
  	
  	Map<Integer,Material> ids = new HashMap<>();
  	for (Material mat : Material.values()) {
  		try {
		ids.put((int) typeIdMethod.invokeExact(mat), mat);
	} catch (Throwable e) {
		throw new RuntimeException(e);
	}
  	}
  	
  	return ids;
  }
 
源代码3 项目: Statz   文件: ImportManager.java
private void importBlocksPlaced(PlayerInfo playerInfo, String worldName) {
    Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName);

    if (!object.isPresent()) {
        return;
    }

    Optional<JSONObject> placedSection = getUsedSection(playerInfo.getUUID(), worldName);

    if (!placedSection.isPresent()) return;

    for (Material material : Material.values()) {
        if (material.isBlock()) {

            long placed = (Long) getStatistic(placedSection.get(), material.getKey().toString()).orElse(0L);

            if (placed <= 0) continue;

            playerInfo.addRow(PlayerStat.BLOCKS_PLACED,
                    StatzUtil.makeQuery(playerInfo.getUUID(), "value", placed, "world",
                            worldName, "block", material));
        }
    }
}
 
源代码4 项目: Statz   文件: ImportManager.java
private void importBlocksBroken(PlayerInfo playerInfo, String worldName) {
    Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName);

    if (!object.isPresent()) {
        return;
    }

    Optional<JSONObject> minedSection = getMinedSection(playerInfo.getUUID(), worldName);

    if (!minedSection.isPresent()) return;

    for (Material material : Material.values()) {
        if (material.isBlock()) {

            long broken = (Long) getStatistic(minedSection.get(), material.getKey().toString()).orElse(0L);

            if (broken <= 0) continue;

            playerInfo.addRow(PlayerStat.BLOCKS_BROKEN,
                    StatzUtil.makeQuery(playerInfo.getUUID(), "value", broken, "world",
                            worldName, "block", material));
        }
    }
}
 
源代码5 项目: Statz   文件: ImportManager.java
private void importFoodEaten(PlayerInfo playerInfo, String worldName) {
    Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName);

    if (!object.isPresent()) {
        return;
    }

    Optional<JSONObject> foodSection = getUsedSection(playerInfo.getUUID(), worldName);

    if (!foodSection.isPresent()) return;

    for (Material material : Material.values()) {
        if (material.isEdible()) {

            long eaten = (Long) getStatistic(foodSection.get(), material.getKey().toString()).orElse(0L);

            if (eaten <= 0) continue;

            playerInfo.addRow(PlayerStat.FOOD_EATEN,
                    StatzUtil.makeQuery(playerInfo.getUUID(), "value", eaten, "world",
                            worldName, "foodEaten", material));
        }
    }
}
 
源代码6 项目: Statz   文件: ImportManager.java
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));
        }
    }
}
 
源代码7 项目: Statz   文件: ImportManager.java
private void importItemsDropped(PlayerInfo playerInfo, String worldName) {
    Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName);

    if (!object.isPresent()) {
        return;
    }

    Optional<JSONObject> droppedSection = getDroppedSection(playerInfo.getUUID(), worldName);

    if (!droppedSection.isPresent()) return;

    for (Material material : Material.values()) {
        long dropped = (Long) getStatistic(droppedSection.get(), material.getKey().toString()).orElse(0L);

        if (dropped <= 0) continue;

        playerInfo.addRow(PlayerStat.ITEMS_DROPPED,
                StatzUtil.makeQuery(playerInfo.getUUID(), "value", dropped, "world",
                        worldName, "item", material));
    }
}
 
源代码8 项目: QuickShop-Reremake   文件: MsgUtil.java
/**
 * Load Itemi18n fron file
 */
public static void loadItemi18n() {
    plugin.getLogger().info("Starting loading items translation...");
    File itemi18nFile = new File(plugin.getDataFolder(), "itemi18n.yml");
    if (!itemi18nFile.exists()) {
        plugin.getLogger().info("Creating itemi18n.yml");
        plugin.saveResource("itemi18n.yml", false);
    }
    // Store it
    itemi18n = YamlConfiguration.loadConfiguration(itemi18nFile);
    itemi18n.options().copyDefaults(false);
    YamlConfiguration itemi18nYAML =
            YamlConfiguration.loadConfiguration(
                    new InputStreamReader(Objects.requireNonNull(plugin.getResource("itemi18n.yml"))));
    itemi18n.setDefaults(itemi18nYAML);
    Util.parseColours(itemi18n);
    Material[] itemsi18n = Material.values();
    for (Material material : itemsi18n) {
        String itemi18nString = itemi18n.getString("itemi18n." + material.name());
        if (itemi18nString != null && !itemi18nString.isEmpty()) {
            continue;
        }
        String itemName = gameLanguage.getItem(material);
        itemi18n.set("itemi18n." + material.name(), itemName);
        plugin
                .getLogger()
                .info("Found new items/blocks [" + itemName + "] , adding it to the config...");
    }
    try {
        itemi18n.save(itemi18nFile);
    } catch (IOException e) {
        e.printStackTrace();
        plugin
                .getLogger()
                .log(
                        Level.WARNING,
                        "Could not load/save transaction itemname from itemi18n.yml. Skipping.");
    }
    plugin.getLogger().info("Complete to load items translation.");
}
 
源代码9 项目: GlobalWarming   文件: FuelModelTest.java
@Test
public void fuelModelContainsAllMaterials() {
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    FuelModel model = new FuelModel(gson, "world");
    Map<Material, Double> existingFuelMap = model.getFuelMap();
    for (Material material : Material.values()) {
        if (material.isFuel()) {
            Assert.assertTrue(existingFuelMap.containsKey(material), material.name());
        }
    }
}
 
源代码10 项目: Skript   文件: BurgerHelper.java
public Map<String,Material> mapMaterials() {
	Map<String,Material> materials = new HashMap<>();
	
	// Check all existing materials
       for (Material material : Material.values()) {
       	// Get id
		int id;
		try {
			id = (int) typeIdMethod.invokeExact(material);
		} catch (Throwable e) {
			throw new RuntimeException(e);
		}
		
		// Search in blocks
           String vanillaId = null;
           for (ItemOrBlock item : burger.items.item.values()) {
               if (item.numeric_id == id) {
                   vanillaId = item.text_id;
                   break;
               }
           }
           
           // Search in items
           for (ItemOrBlock block : burger.blocks.block.values()) {
               if (block.numeric_id == id) {
                   vanillaId = block.text_id;
                   break;
               }
           }
           
           materials.put(vanillaId, material);
       }
       
       return materials;
}
 
源代码11 项目: Skript   文件: AliasesMap.java
/**
 * Clears all data from this aliases map.
 */
public void clear() {
	materialEntries = new MaterialEntry[Material.values().length];
	for (int i = 0; i < materialEntries.length; i++) {
		materialEntries[i] = new MaterialEntry();
	}
}
 
源代码12 项目: SaneEconomy   文件: ItemDatabase.java
private static Optional<Material> parseMaterialFromName(String materialName) {
    for (Material mat : Material.values()) {
        if (normalizeItemName(mat.name()).equals(normalizeItemName(materialName))) {
            return Optional.of(mat);
        }
    }

    return Optional.empty();
}
 
源代码13 项目: NovaGuilds   文件: CompatibilityUtils.java
/**
 * Gets material by id
 *
 * @param id id
 * @return material enum
 */
public static Material getMaterial(int id) {
	for(Material material : Material.values()) {
		if(material.getId() == id) {
			return material;
		}
	}

	return null;
}
 
源代码14 项目: HeavySpleef   文件: MaterialDataMatcher.java
private Material matchMaterialByName(String name) {
	name = name.replace("_", "");
	
	for (Material material : Material.values()) {
		String materialName = material.name().replace("_", "");
		
		if (name.equalsIgnoreCase(materialName)) {
			return material;
		}
	}
	
	return null;
}
 
源代码15 项目: BetonQuest   文件: BlockSelector.java
/**
 * Return material
 * <p>
 * If we match multiple materials we will return the first match
 */
public Material getMaterial() {
    for (Material m : Material.values()) {
        if (match(m)) {
            return m;
        }
    }
    return null;
}
 
源代码16 项目: Skript   文件: ExprItems.java
@Override
@Nullable
public Iterator<ItemStack> iterator(final Event e) {
	Iterator<ItemStack> iter;
	if (types == null) {
		iter = new Iterator<ItemStack>() {
			
			private final Iterator<Material> iter = new ArrayIterator<>(Material.values());
			
			@Override
			public boolean hasNext() {
				return iter.hasNext();
			}
			
			@Override
			public ItemStack next() {
				return new ItemStack(iter.next());
			}
			
			@Override
			public void remove() {}
			
		};
	} else {
		@SuppressWarnings("null")
		final Iterator<ItemType> it = new ArrayIterator<>(types.getArray(e));
		if (!it.hasNext())
			return null;
		iter = new Iterator<ItemStack>() {
			
			@SuppressWarnings("null")
			Iterator<ItemStack> current = it.next().getAll().iterator();
			
			@SuppressWarnings("null")
			@Override
			public boolean hasNext() {
				while (!current.hasNext() && it.hasNext()) {
					current = it.next().getAll().iterator();
				}
				return current.hasNext();
			}
			
			@SuppressWarnings("null")
			@Override
			public ItemStack next() {
				if (!hasNext())
					throw new NoSuchElementException();
				return current.next();
			}
			
			@Override
			public void remove() {}
			
		};
	}
	
	if (!blocks)
		return iter;
	
	return new CheckedIterator<>(iter, new NullableChecker<ItemStack>() {
		@Override
		public boolean check(final @Nullable ItemStack is) {
			return is != null && is.getType().isBlock();
		}
	});
}
 
源代码17 项目: Skript   文件: MaterialRegistry.java
/**
 * Creates a new material registry.
 */
public MaterialRegistry() {
	this(Material.values());
}
 
源代码18 项目: Statz   文件: ImportManager.java
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));
            }
        }
    }
 
源代码19 项目: Statz   文件: ImportManager.java
private void importItemsPickedUp(PlayerInfo playerInfo, String worldName) {
    Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName);

    if (!object.isPresent()) {
        return;
    }

    Optional<JSONObject> pickedUpSection = getPickedUpSection(playerInfo.getUUID(), worldName);

    if (!pickedUpSection.isPresent()) return;

    for (Material material : Material.values()) {

        long pickedUp = (Long) getStatistic(pickedUpSection.get(), material.getKey().toString()).orElse(0L);

        if (pickedUp <= 0) continue;

        playerInfo.addRow(PlayerStat.ITEMS_PICKED_UP,
                StatzUtil.makeQuery(playerInfo.getUUID(), "value", pickedUp, "world",
                        worldName, "item", material));
    }
}
 
源代码20 项目: askyblock   文件: ASkyBlock.java
/**
 * Registers events
 */
public void registerEvents() {
    final PluginManager manager = getServer().getPluginManager();
    // Nether portal events
    manager.registerEvents(new NetherPortals(this), this);
    // Nether spawning events
    manager.registerEvents(new NetherSpawning(this), this);
    // Island Protection events
    manager.registerEvents(new IslandGuard(this), this);
    // Island Entity Limits
    entityLimits = new EntityLimits(this);
    manager.registerEvents(entityLimits, this);
    // Player events
    playerEvents = new PlayerEvents(this);
    manager.registerEvents(playerEvents, this);
    try {
        Class<?> clazz = Class.forName("org.bukkit.event.entity.EntityPickupItemEvent", false, getClassLoader());
        if (clazz != null) {
            manager.registerEvents(new PlayerEvents3(this), this);
        }
    } catch (ClassNotFoundException e) {
        manager.registerEvents(new PlayerEvents2(this), this);
    }
    // New V1.8 events
    if (onePointEight) {
        manager.registerEvents(new IslandGuard1_8(this), this);
    }
    // Check for 1.9 material
    for (Material m : Material.values()) {
        if (m.name().equalsIgnoreCase("END_CRYSTAL")) {
            manager.registerEvents(new IslandGuard1_9(this), this);
            break;
        }
    }
    // Events for when a player joins or leaves the server
    manager.registerEvents(new JoinLeaveEvents(this), this);
    // Ensures Lava flows correctly in ASkyBlock world
    lavaListener = new LavaCheck(this);
    manager.registerEvents(lavaListener, this);
    // Ensures that water is acid
    manager.registerEvents(new AcidEffect(this), this);
    // Ensures that boats are safe in ASkyBlock
    if (Settings.acidDamage > 0D) {
        manager.registerEvents(new SafeBoat(this), this);
    }
    // Enables warp signs in ASkyBlock
    warpSignsListener = new WarpSigns(this);
    manager.registerEvents(warpSignsListener, this);
    // Control panel - for future use
    // manager.registerEvents(new ControlPanel(), this);
    // Change names of inventory items
    //manager.registerEvents(new AcidInventory(this), this);
    // Schematics panel
    schematicsPanel = new SchematicsPanel(this);
    manager.registerEvents(schematicsPanel, this);
    // Track incoming world teleports
    manager.registerEvents(new WorldEnter(this), this);
    // Team chat
    chatListener = new ChatListener(this);
    manager.registerEvents(chatListener, this);
    // Wither
    if (Settings.restrictWither) {
        manager.registerEvents(new FlyingMobEvents(this), this);
    }
    if (Settings.recoverSuperFlat) {
        manager.registerEvents(new CleanSuperFlat(), this);
    }
}
 
 方法所在类
 同类方法