本文整理汇总了Java中org.bukkit.Material.getMaterial方法的典型用法代码示例。如果您正苦于以下问题:Java Material.getMaterial方法的具体用法?Java Material.getMaterial怎么用?Java Material.getMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.getMaterial方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import org.bukkit.Material; //导入方法依赖的package包/类
/**
* Deserialize items.
*/
public static ItemStack deserialize(ConfigurationSection section) {
Material type = Material.getMaterial(section.getString("type"));
byte data = (byte) section.getInt("data");
ItemBuilder item = new ItemBuilder(type, data);
item.setAmount(section.getInt("amount"));
item.setDurability((short) section.getInt("durability"));
item.setDisplayName(section.getString("displayName"));
item.setLore(section.getString("lore"));
List<String> enchants = section.getStringList("enchantments");
for (String enchant : enchants) {
String tmp[] = enchant.split(",");
Enchantment enc = Enchantment.getByName(tmp[0]);
int lev = Integer.parseInt(tmp[1]);
item.addEnchantment(enc, lev);
}
return item.build();
}
示例2: dumpMaterials
import org.bukkit.Material; //导入方法依赖的package包/类
public static void dumpMaterials() {
if (MinecraftServer.getServer().cauldronConfig.dumpMaterials.getValue())
{
FMLLog.info("Cauldron Dump Materials is ENABLED. Starting dump...");
for (int i = 0; i < 32000; i++)
{
Material material = Material.getMaterial(i);
if (material != null)
{
FMLLog.info("Found material " + material + " with ID " + i);
}
}
FMLLog.info("Cauldron Dump Materials complete.");
FMLLog.info("To disable these dumps, set cauldron.dump-materials to false in bukkit.yml.");
}
}
示例3: SParticle
import org.bukkit.Material; //导入方法依赖的package包/类
public SParticle(Map<String, Object> items) throws Exception {
super();
this.effect = SParticle.getParticleEffectFromName((String) items.get("effect"));
this.isEnabled = (boolean) items.get("enabled");
this.amount = (int) items.get("amount");
this.speed = (double) items.get("speed");
this.x = (double) items.get("size.x");
this.y = (double) items.get("size.y");
this.z = (double) items.get("size.z");
this.blue = (Integer) items.get("color.blue");
this.red = (Integer) items.get("color.red");
this.green = (Integer) items.get("color.green");
if (items.containsKey("block.material"))
this.material = Material.getMaterial((Integer) items.get("block.material"));
if (items.containsKey("block.damage"))
this.data = (Byte) items.get("block.damage");
}
示例4: getSimpleStats
import org.bukkit.Material; //导入方法依赖的package包/类
public static Map<Material, Integer> getSimpleStats(UUID uuid) {
EnumMap<Material, Integer> map = new EnumMap<>(Material.class);
try (Connection con = MySQLThreadPool.getInstance().getConnection()) {
PreparedStatement st = con.prepareStatement("SELECT material,block_data,amount FROM block_break_stat_simple WHERE player=UNHEX(?)");
st.setString(1, uuid.toString().replace("-", ""));
ResultSet set = st.executeQuery();
while (set != null && set.next()) {
Material mat = Material.getMaterial(set.getString("material"));
int amount = set.getInt("amount");
if (map.containsKey(mat)) {
map.put(mat, map.get(mat) + amount);
} else {
map.put(mat, amount);
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return map;
}
示例5: getTrackedCropMaterial
import org.bukkit.Material; //导入方法依赖的package包/类
public Material getTrackedCropMaterial(String _trackedType) {
Material trackedType = Material.getMaterial(_trackedType);
if (Material.MELON_BLOCK.equals(trackedType))
return Material.MELON_BLOCK;
else if (Material.PUMPKIN.equals(trackedType))
return Material.PUMPKIN;
else {
for (Material material : harvestableCrops.keySet()) {
if (material.equals(trackedType))
return material;
}
}
CropControl.getPlugin().debug("Unable to match tracked crop type material {0}", trackedType);
return null;
}
示例6: generate
import org.bukkit.Material; //导入方法依赖的package包/类
@Override
public ItemStack generate() {
ItemStack itemStack = new ItemStack(Material.getMaterial(this.id), 1, (short) this.damage);
if (this.id == Material.SKULL_ITEM.getId() && this.damage == 3) {
if (this.owner != null && this.owner.contains("textures.minecraft")) {
itemStack = SSKulls.activateHeadByURL(this.owner, itemStack);
} else if (this.owner != null) {
itemStack = SSKulls.activateHeadByName(this.owner, itemStack);
}
}
return itemStack;
}
示例7: getOriginal
import org.bukkit.Material; //导入方法依赖的package包/类
@Override
public Object getOriginal() {
ItemStack sta = new ItemStack(Material.getMaterial(id));
ItemMeta meta = sta.getItemMeta();
if(meta != null)
((DefaultMeta)this.meta).setToMeta(meta);
sta.setItemMeta(meta);
sta.setDurability((short) durability);
sta.setAmount(amount);
(array).setToItemStack(sta);
return sta;
}
示例8: fromString
import org.bukkit.Material; //导入方法依赖的package包/类
public static final ItemStack fromString(String s) {
int data = 0;
String mat = s.trim();
if(mat.contains(":")) {
String[] spl = mat.split(":");
mat = spl[0].trim();
data = Integer.parseInt(spl[1].trim());
}
return new ItemStack(Material.getMaterial(mat), 1, (byte) data);
}
示例9: DisplayArmorstand
import org.bukkit.Material; //导入方法依赖的package包/类
/**
* Initializes the armorstand
*
* @param player player
* @param location location
* @param id id
* @param data data
* @param watchers watchers
*/
public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) {
super();
this.watchers = watchers;
this.player = player;
this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle());
final NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("invulnerable", true);
compound.setBoolean("Invisible", true);
compound.setBoolean("PersistenceRequired", true);
compound.setBoolean("NoBasePlate", true);
this.armorStand.a(compound);
this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0);
this.storedId = id;
this.storedData = data;
ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data);
this.getCraftEntity().setHelmet(stackBuilder.build());
this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0));
this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0));
this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0));
if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) {
stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3);
if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) {
stackBuilder.setSkin(NMSRegistry.WATER_HEAD);
} else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) {
stackBuilder.setSkin(NMSRegistry.LAVA_HEAD);
} else {
stackBuilder.setSkin(NMSRegistry.NOT_FOUND);
}
((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build());
}
}
示例10: getMaterialFromStatistic
import org.bukkit.Material; //导入方法依赖的package包/类
public static Material getMaterialFromStatistic(net.minecraft.stats.StatBase statistic) {
String statisticString = statistic.statId;
int id;
try {
id = Integer.valueOf(statisticString.substring(statisticString.lastIndexOf(".") + 1));
} catch (NumberFormatException e) {
return null;
}
return Material.getMaterial(id);
}
示例11: toItemStack
import org.bukkit.Material; //导入方法依赖的package包/类
public static ItemStack toItemStack(int code, int data, String display, List<String> lores, List<String> enchants) {
ItemStack is = new ItemStack(Material.getMaterial(code));
is.setDurability((short) data);
ItemMeta im = is.getItemMeta();
im.setDisplayName(ChatColor.translateAlternateColorCodes('&',display));
im.setLore(Util.translatingcolorcodes(lores));
for(String enchant : enchants) {
im.addEnchant(itemConfigToEnchantment(enchant),itemConfigToEnchantPower(enchant),false);
}
is.setItemMeta(im);
return is;
}
示例12: listItems
import org.bukkit.Material; //导入方法依赖的package包/类
private void listItems() {
int i = 0;
for (final BoostItem boostItem : this.arenaEntity.getBoostItemHandler().getBoostItems()) {
if (Material.getMaterial(boostItem.getId()) != null)
this.player.sendMessage(Language.PREFIX + i + " - " + Material.getMaterial(boostItem.getId()).name().toUpperCase() + '-' + boostItem.getDamage());
else
this.player.sendMessage(Language.PREFIX + i + " - " + boostItem.getId() + '-' + boostItem.getDamage());
i++;
}
}
示例13: DisplayArmorstand
import org.bukkit.Material; //导入方法依赖的package包/类
/**
* Initializes the armorstand
*
* @param player player
* @param location location
* @param id id
* @param data data
* @param watchers watchers
*/
public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) {
super();
this.watchers = watchers;
this.player = player;
this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle());
final NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("invulnerable", true);
compound.setBoolean("Invisible", true);
compound.setBoolean("PersistenceRequired", true);
compound.setBoolean("NoBasePlate", true);
this.armorStand.a(compound);
this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0);
this.storedId = id;
this.storedData = data;
ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data);
this.getCraftEntity().setHelmet(stackBuilder.build());
this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0));
this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0));
this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0));
this.getCraftEntity().setGlowing(true);
if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) {
stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3);
if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) {
stackBuilder.setSkin(NMSRegistry.WATER_HEAD);
} else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) {
stackBuilder.setSkin(NMSRegistry.LAVA_HEAD);
} else {
stackBuilder.setSkin(NMSRegistry.NOT_FOUND);
}
((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build());
}
}
示例14: isBlockAtLocationOccluding
import org.bukkit.Material; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static boolean isBlockAtLocationOccluding(Location loc) {
try {
ChunkSnapshot snapshot = null;
int chunkX = (int) Math.floor(loc.getBlockX() / 16d);
int chunkZ = (int) Math.floor(loc.getBlockZ() / 16d);
ChunkCoords cc = new ChunkCoords(loc.getWorld().getName(), chunkX, chunkZ);
if (TransportPipes.instance.blockChangeListener.cachedChunkSnapshots.containsKey(cc)) {
snapshot = TransportPipes.instance.blockChangeListener.cachedChunkSnapshots.get(cc);
}
if (snapshot == null) {
return false;
}
int relativeX = loc.getBlockX() % 16;
if (relativeX < 0) {
relativeX = 16 + relativeX;
}
int relativeZ = loc.getBlockZ() % 16;
if (relativeZ < 0) {
relativeZ = 16 + relativeZ;
}
Material material = Material.getMaterial(snapshot.getBlockTypeId(relativeX, loc.getBlockY(), relativeZ));
return material.isOccluding();
} catch (Exception e) {
e.printStackTrace();
Sentry.capture(e);
return false;
}
}
示例15: getType
import org.bukkit.Material; //导入方法依赖的package包/类
public Material getType() {
return Material.getMaterial(getTypeId());
}