org.bukkit.Material#STONE源码实例Demo

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

源代码1 项目: TrMenu   文件: JsonItem.java
public static ItemStack fromJson(String item) {
    JsonElement json = new JsonParser().parse(TLocale.Translate.setColored(item));
    if (json instanceof JsonObject) {
        ItemBuilder itemBuilder = new ItemBuilder(Material.STONE);
        JsonElement type = ((JsonObject) json).get("type");
        if (type != null) {
            itemBuilder.material(Items.asMaterial(type.getAsString()));
        }
        JsonElement data = ((JsonObject) json).get("data");
        if (data != null) {
            itemBuilder.damage(data.getAsInt());
        }
        JsonElement amount = ((JsonObject) json).get("amount");
        if (amount != null) {
            itemBuilder.amount(amount.getAsInt());
        }
        ItemStack itemBuild = itemBuilder.build();
        JsonElement meta = ((JsonObject) json).get("meta");
        if (meta != null) {
            return NMS.handle().saveNBT(itemBuild, NBTCompound.fromJson(meta.toString()));
        }
        return itemBuild;
    }
    return null;
}
 
源代码2 项目: TabooLib   文件: Items.java
public static ItemStack fromJson(String item) {
    JsonElement json = new JsonParser().parse(item);
    if (json instanceof JsonObject) {
        ItemBuilder itemBuilder = new ItemBuilder(Material.STONE);
        JsonElement type = ((JsonObject) json).get("type");
        if (type != null) {
            itemBuilder.material(Items.asMaterial(type.getAsString()));
        }
        JsonElement data = ((JsonObject) json).get("data");
        if (data != null) {
            itemBuilder.damage(data.getAsInt());
        }
        JsonElement amount = ((JsonObject) json).get("amount");
        if (amount != null) {
            itemBuilder.amount(amount.getAsInt());
        }
        ItemStack itemBuild = itemBuilder.build();
        JsonElement meta = ((JsonObject) json).get("meta");
        if (meta != null) {
            return NMS.handle().saveNBT(itemBuild, NBTCompound.fromJson(meta.toString()));
        }
        return itemBuild;
    }
    return null;
}
 
源代码3 项目: Hawk   文件: TestWindow.java
public TestWindow(Hawk hawk, Player p) {
    super(hawk, p, 1, "Test");
    elements[4] = new Element(Material.STONE, "Click on me to update inventory") {
        @Override
        public void doAction(Player p, Hawk hawk) {
            Element element = elements[4];
            if(element.getItemStack().getType() == Material.STONE) {
                element.getItemStack().setType(Material.WOOD);
            }
            else {
                element.getItemStack().setType(Material.STONE);
            }
            updateWindow();
        }
    };

    prepareInventory();
}
 
源代码4 项目: Item-NBT-API   文件: ItemConvertionTest.java
@Override
public void test() throws Exception {
	ItemStack item = new ItemStack(Material.STONE, 1);
	ItemMeta meta = item.getItemMeta();
	meta.setLore(Lists.newArrayList("Firest Line", "Second Line"));
	item.setItemMeta(meta);
	String nbt = NBTItem.convertItemtoNBT(item).toString();
	if (!nbt.contains("Firest Line") || !nbt.contains("Second Line"))
		throw new NbtApiException("The Item nbt '" + nbt + "' didn't contain the lore");
	ItemStack rebuild = NBTItem.convertNBTtoItem(new NBTContainer(nbt));
	if (!item.isSimilar(rebuild))
		throw new NbtApiException("Rebuilt item did not match the original!");
	
	NBTContainer cont = new NBTContainer();
	cont.setItemStack("testItem", item);
	if(!cont.getItemStack("testItem").isSimilar(item))
		throw new NbtApiException("Rebuilt item did not match the original!");
}
 
源代码5 项目: Quests   文件: ItemGetter_1_13.java
@Override
public ItemStack getItemStack(String material, Quests plugin) {
    Material type;
    try {
        type = Material.valueOf(material);
    } catch (Exception e) {
        plugin.getQuestsLogger().debug("Unrecognised material: " + material);
        type = Material.STONE;
    }
    return new ItemStack(type, 1);
}
 
源代码6 项目: Quests   文件: ItemGetterLatest.java
@Override
public ItemStack getItemStack(String material, Quests plugin) {
    Material type;
    try {
        type = Material.valueOf(material);
    } catch (Exception e) {
        plugin.getQuestsLogger().debug("Unrecognised material: " + material);
        type = Material.STONE;
    }
    return new ItemStack(type, 1);
}
 
源代码7 项目: StaffPlus   文件: Options.java
private Material stringToMaterial(String string)
{
	Material sound = Material.STONE;
	boolean isValid = JavaUtils.isValidEnum(Material.class, string);
	
	if(!isValid)
	{
		message.sendConsoleMessage("Invalid material type '" + string + "'!", true);
	}else sound = Material.valueOf(string);
	
	return sound;
}
 
源代码8 项目: Survival-Games   文件: ChestReplaceEvent.java
private Material getWool() {
Material wool = Material.STONE;
try {
	if(SurvivalGames.PRE1_13) {
		wool = Material.class.cast(Material.class.getDeclaredField("WOOL").get(Material.class));
	}else {				
		wool = Material.class.cast(Material.class.getDeclaredField("LEGACY_WOOL").get(Material.class));
	}
} catch (Exception e1) {
		e1.printStackTrace();
}
return wool;
  }
 
源代码9 项目: Crazy-Crates   文件: ItemBuilder.java
/**
 * The initial starting point for making an item.
 */
public ItemBuilder() {
    this.nbtItem = null;
    this.material = Material.STONE;
    this.damage = 0;
    this.name = "";
    this.crateName = "";
    this.lore = new ArrayList<>();
    this.amount = 1;
    this.player = "";
    this.isHash = false;
    this.isURL = false;
    this.isHead = false;
    this.enchantments = new HashMap<>();
    this.unbreakable = false;
    this.hideItemFlags = false;
    this.glowing = false;
    this.referenceItem = null;
    this.entityType = EntityType.BAT;
    this.potionType = null;
    this.potionColor = null;
    this.isPotion = false;
    this.armorColor = null;
    this.isLeatherArmor = false;
    this.patterns = new ArrayList<>();
    this.isBanner = false;
    this.isShield = false;
    this.customModelData = 0;
    this.useCustomModelData = false;
    this.isMobEgg = false;
    this.namePlaceholders = new HashMap<>();
    this.lorePlaceholders = new HashMap<>();
    this.itemFlags = new ArrayList<>();
}
 
@NotNull
private Material getMaterial(String type, boolean needBlock) {
    Material material = Material.matchMaterial(type);
    if (material == null) {
        plugin.getLogger().warning("Invalid material for particle in the config: " + type);
        return Material.STONE;
    }

    if (needBlock && !material.isBlock()) {
        plugin.getLogger().warning("The material for particle in the config must be a block: " + type);
        return Material.STONE;
    }

    return material;
}
 
源代码11 项目: NyaaUtils   文件: RepairConfig.java
public RepairConfigItem normalize() {
    if (material == null) material = Material.STONE;
    if (fullRepairCost <= 0) fullRepairCost = 1;
    if (expCost < 0) expCost = 0;
    if (enchantCostPerLv < 0) enchantCostPerLv = 0;
    if (repairLimit <= 0) repairLimit = 0;
    return this;
}
 
源代码12 项目: Item-NBT-API   文件: GsonTest.java
@Override
public void test() throws Exception {
	if (!MinecraftVersion.hasGsonSupport()) {
		return;
	}
	try {
		ItemStack item = new ItemStack(Material.STONE, 1);
		NBTItem nbtItem = new NBTItem(item);

		nbtItem.setObject(JSON_TEST_KEY, new SimpleJsonTestObject());

		if (!nbtItem.hasKey(JSON_TEST_KEY)) {
			throw new NbtApiException(
					"Wasn't able to find JSON key! The Item-NBT-API may not work with Json serialization/deserialization!");
		} else {
			SimpleJsonTestObject simpleObject = nbtItem.getObject(JSON_TEST_KEY, SimpleJsonTestObject.class);
			if (simpleObject == null) {
				throw new NbtApiException(
						"Wasn't able to check JSON key! The Item-NBT-API may not work with Json serialization/deserialization!");
			} else if (!(STRING_TEST_VALUE).equals(simpleObject.getTestString())
					|| simpleObject.getTestInteger() != INT_TEST_VALUE
					|| simpleObject.getTestDouble() != DOUBLE_TEST_VALUE
					|| !simpleObject.isTestBoolean() == BOOLEAN_TEST_VALUE) {
				throw new NbtApiException(
						"One key does not equal the original value in JSON! The Item-NBT-API may not work with Json serialization/deserialization!");
			}
		}
	} catch (Exception ex) {
		throw new NbtApiException("Exception during Gson check!", ex);
	}
}
 
源代码13 项目: Slimefun4   文件: TestMultiBlocks.java
@Test
public void testEqualWithMovingPistons() {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PISTON_MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test"));

    // Some Pistons are moving but that should not interefere with the Multiblock
    MultiBlock multiblock = new MultiBlock(item, new Material[] { Material.PISTON, Material.MOVING_PISTON, Material.PISTON, null, Material.CRAFTING_TABLE, null, Material.PISTON, Material.STONE, Material.PISTON }, BlockFace.DOWN);
    MultiBlock multiblock2 = new MultiBlock(item, new Material[] { Material.MOVING_PISTON, Material.PISTON, Material.MOVING_PISTON, null, Material.CRAFTING_TABLE, null, Material.PISTON, Material.STONE, Material.PISTON }, BlockFace.DOWN);
    MultiBlock multiblock3 = new MultiBlock(item, new Material[] { Material.PISTON, Material.PISTON, Material.STICKY_PISTON, null, Material.CRAFTING_TABLE, null, Material.PISTON, Material.STONE, Material.PISTON }, BlockFace.DOWN);

    Assertions.assertTrue(multiblock.equals(multiblock2));
    Assertions.assertFalse(multiblock.equals(multiblock3));
}
 
源代码14 项目: CardinalPGM   文件: ClassModuleBuilder.java
@Override
public ModuleCollection<ClassModule> load(Match match) {
    ModuleCollection<ClassModule> results = new ModuleCollection<>();
    for (Element classes : match.getDocument().getRootElement().getChildren("classes")) {
        for (Element classElement : classes.getChildren("class")) {
            String name = null;
            if (classElement.getAttributeValue("name") != null) {
                name = classElement.getAttributeValue("name");
            } else if (classes.getAttributeValue("name") != null) {
                name = classes.getAttributeValue("name");
            }
            String description = null;
            if (classElement.getAttributeValue("description") != null) {
                description = classElement.getAttributeValue("description");
            } else if (classes.getAttributeValue("description") != null) {
                description = classes.getAttributeValue("description");
            }
            String longDescription = description;
            if (classElement.getAttributeValue("longdescription") != null) {
                longDescription = classElement.getAttributeValue("longdescription");
            } else if (classes.getAttributeValue("longdescription") != null) {
                longDescription = classes.getAttributeValue("longdescription");
            }
            Material icon = Material.STONE;
            if (classElement.getAttributeValue("icon") != null) {
                icon = Material.matchMaterial(classElement.getAttributeValue("icon"));
            } else if (classes.getAttributeValue("icon") != null) {
                icon = Material.matchMaterial(classes.getAttributeValue("icon"));
            }
            boolean sticky = false;
            if (classElement.getAttributeValue("sticky") != null) {
                sticky = classElement.getAttributeValue("sticky").equalsIgnoreCase("true");
            } else if (classes.getAttributeValue("sticky") != null) {
                sticky = classes.getAttributeValue("sticky").equalsIgnoreCase("true");
            }
            boolean defaultClass = false;
            if (classElement.getAttributeValue("default") != null) {
                defaultClass = classElement.getAttributeValue("default").equalsIgnoreCase("true");
            } else if (classes.getAttributeValue("default") != null) {
                defaultClass = classes.getAttributeValue("default").equalsIgnoreCase("true");
            }
            boolean restrict = false;
            if (classElement.getAttributeValue("restrict") != null) {
                restrict = !classElement.getAttributeValue("restrict").equalsIgnoreCase("false");
            } else if (classes.getAttributeValue("restrict") != null) {
                restrict = !classes.getAttributeValue("restrict").equalsIgnoreCase("false");
            }
            KitNode kit = classElement.getChildren().size() > 0 ? KitBuilder.getKit(classElement.getChildren().get(0)) : null;
            results.add(new ClassModule(name, description, longDescription, icon, sticky, defaultClass, restrict, kit));
        }
    }
    return results;
}
 
源代码15 项目: Carbon   文件: StoneVariantPopulator.java
@SuppressWarnings("deprecation")
public void createVein(World world, int size, int x, int y, int z) {
       Random random = new Random(world.getSeed());
       float f = random.nextFloat() * 3.141593F;
       double d1 = x + 8 + Math.sin(f) * size / 8.0F;
       double d2 = x + 8 - Math.sin(f) * size / 8.0F;
       double d3 = z + 8 + Math.cos(f) * size / 8.0F;
       double d4 = z + 8 - Math.cos(f) * size / 8.0F;
       double d5 = y + random.nextInt(3) - 2;
       double d6 = y + random.nextInt(3) - 2;
       for (int i = 0; i <= size; i++) {
           double d7 = d1 + (d2 - d1) * i / size;
           double d8 = d5 + (d6 - d5) * i / size;
           double d9 = d3 + (d4 - d3) * i / size;
           double d10 = random.nextDouble() * size / 16.0D;
           double d11 = (Math.sin(i * 3.141593F / size) + 1.0F) * d10 + 1.0D;
           double d12 = (Math.sin(i * 3.141593F / size) + 1.0F) * d10 + 1.0D;
           int j = (int) Math.floor(d7 - d11 / 2.0D);
           int k = (int) Math.floor(d8 - d12 / 2.0D);
           int m = (int) Math.floor(d9 - d11 / 2.0D);
           int n = (int) Math.floor(d7 + d11 / 2.0D);
           int i1 = (int) Math.floor(d8 + d12 / 2.0D);
           int i2 = (int) Math.floor(d9 + d11 / 2.0D);
           for (int i3 = j; i3 <= n; i3++) {
               double d13 = (i3 + 0.5D - d7) / (d11 / 2.0D);
               if (d13 * d13 < 1.0D) {
                   for (int i4 = k; i4 <= i1; i4++) {
                       double d14 = (i4 + 0.5D - d8) / (d12 / 2.0D);
                       if (d13 * d13 + d14 * d14 < 1.0D) {
                           for (int i5 = m; i5 <= i2; i5++) {
                               double d15 = (i5 + 0.5D - d9) / (d11 / 2.0D);
                               if ((d13 * d13 + d14 * d14 + d15 * d15 >= 1.0D) || (world.getBlockAt(i3, i4, i5).getType() != Material.STONE)) {
                                   continue;
                               }
                               world.getBlockAt(i3, i4, i5).setTypeIdAndData(blockType.getId(), data, true);
                           }
                       }
                   }
               }
           }
       }
   }
 
源代码16 项目: Civs   文件: CVItem.java
public static CVItem createCVItemFromString(String locale, String materialString)  {
    boolean isMMOItem = materialString.contains("mi:");
    if (isMMOItem) {
        materialString = materialString.replace("mi:", "");
    }

    String quantityString = "1";
    String chanceString = "100";
    String nameString = null;
    String mmoType = "";
    Material mat;

    String[] splitString;


    for (;;) {
        int asteriskIndex = materialString.indexOf("*");
        int percentIndex = materialString.indexOf("%");
        int nameIndex = materialString.indexOf(".");
        if (asteriskIndex != -1 && asteriskIndex > percentIndex && asteriskIndex > nameIndex) {
            splitString = materialString.split("\\*");
            quantityString = splitString[splitString.length - 1];
            materialString = splitString[0];
        } else if (percentIndex != -1 && percentIndex > asteriskIndex && percentIndex > nameIndex) {
            splitString = materialString.split("%");
            chanceString = splitString[splitString.length - 1];
            materialString = splitString[0];
        } else if (nameIndex != -1 && nameIndex > percentIndex && nameIndex > asteriskIndex) {
            splitString = materialString.split("\\.");
            nameString = splitString[splitString.length -1];
            materialString = splitString[0];
        } else {
            if (isMMOItem) {
                mmoType = materialString;
                mat = Material.STONE;
            } else {
                mat = getMaterialFromString(materialString);
            }
            break;
        }
    }


    if (mat == null) {
        mat = Material.STONE;
        Civs.logger.severe(Civs.getPrefix() + "Unable to parse material " + materialString);
    }
    int quantity = Integer.parseInt(quantityString);
    int chance = Integer.parseInt(chanceString);

    if (isMMOItem) {
        if (Civs.mmoItems == null) {
            Civs.logger.severe(Civs.getPrefix() + "Unable to create MMOItem because MMOItems is disabled");
            return new CVItem(mat, quantity, chance);
        }
        Type mmoItemType = Civs.mmoItems.getTypes().get(mmoType);
        if (mmoItemType == null) {
            Civs.logger.severe(Civs.getPrefix() + "MMOItem type " + mmoType + " not found");
            return new CVItem(mat, quantity, chance);
        }
        if (nameString == null) {
            Civs.logger.severe(Civs.getPrefix() + "Invalid MMOItem " + mmoType + " did not provide item name");
            return new CVItem(mat, quantity, chance);
        }
        MMOItem mmoItem = Civs.mmoItems.getItems().getMMOItem(mmoItemType, nameString);
        ItemStack item = mmoItem.newBuilder().build();
        CVItem cvItem = new CVItem(item.getType(), quantity, chance, item.getItemMeta().getDisplayName(),
                item.getItemMeta().getLore());
        cvItem.mmoItemName = nameString;
        cvItem.mmoItemType = mmoType;
        return cvItem;
    }
    if (nameString == null) {
        return new CVItem(mat, quantity, chance);
    } else {
        String displayName = LocaleManager.getInstance().getTranslation(locale, "item-" + nameString + "-name");
        List<String> lore = new ArrayList<>();
        lore.add(ChatColor.BLACK + nameString);
        lore.addAll(Util.textWrap(ConfigManager.getInstance().getCivsItemPrefix() +
                LocaleManager.getInstance().getTranslation(locale, "item-" + nameString + "-desc")));
        return new CVItem(mat, quantity, chance, displayName, lore);
    }
}
 
源代码17 项目: LanguageUtils   文件: ItemEntryTest.java
@Test
public void testEquals() throws Exception {
    //Same Material
    ItemEntry equalEntry1 = new ItemEntry(Material.STONE);
    ItemEntry equalEntry2 = new ItemEntry(Material.STONE);

    assertThat(equalEntry1, is(equalEntry2));
    assertThat(equalEntry1.hashCode(), is(equalEntry2.hashCode()));

    //Same Material + metadata
    ItemEntry equalEntry3 = new ItemEntry(Material.STONE, 2);
    ItemEntry equalEntry4 = new ItemEntry(Material.STONE, 2);

    assertThat(equalEntry3, is(equalEntry4));
    assertThat(equalEntry3.hashCode(), is(equalEntry4.hashCode()));

    //Different Material
    ItemEntry diffEntry1 = new ItemEntry(Material.STONE);
    ItemEntry diffEntry2 = new ItemEntry(Material.ANVIL);

    assertThat(diffEntry1, not(diffEntry2));
    assertThat(diffEntry1.hashCode(), not(diffEntry2.hashCode()));

    //Different metadata
    ItemEntry diffEntry3 = new ItemEntry(Material.STONE, 4);
    ItemEntry diffEntry4 = new ItemEntry(Material.STONE, 7);

    assertThat(diffEntry3, not(diffEntry4));
    assertThat(diffEntry3.hashCode(), not(diffEntry4.hashCode()));

    //Different Material + metadata
    ItemEntry diffEntry5 = new ItemEntry(Material.STONE, 4);
    ItemEntry diffEntry6 = new ItemEntry(Material.SAND, 2);

    assertThat(diffEntry5, not(diffEntry6));
    assertThat(diffEntry5.hashCode(), not(diffEntry6.hashCode()));


    //HashMap Test
    Map<ItemEntry, EnumItem> testMap = new HashMap<ItemEntry, EnumItem>();

    testMap.put(equalEntry1, EnumItem.STONE);
    assertTrue(testMap.containsKey(equalEntry1));

    testMap.put(equalEntry3, EnumItem.POLISHED_GRANITE);
    assertTrue(testMap.containsKey(equalEntry4));

    assertFalse(testMap.containsKey(diffEntry2));
    assertFalse(testMap.containsKey(diffEntry3));
    assertFalse(testMap.containsKey(diffEntry6));
}
 
源代码18 项目: TrMenu   文件: TrUtils.java
/**
 * 取得一个 ItemStack 构造器 (from TabooLib5)
 *
 * @return
 */
public ItemBuilder getItemBuildr() {
    return new ItemBuilder(Material.STONE);
}
 
源代码19 项目: iDisguise   文件: ItemDisguise.java
/**
 * Creates an instance.<br>
 * The default item stack is one stone.
 * 
 * @since 5.1.1
 */
public ItemDisguise() {
	this(new ItemStack(Material.STONE, 1));
}
 
源代码20 项目: iDisguise   文件: FallingBlockDisguise.java
/**
 * Creates an instance.<br>
 * The default material is {@linkplain Material#STONE}.
 * 
 * @since 5.1.1
 */
public FallingBlockDisguise() {
	this(Material.STONE);
}
 
 方法所在类
 同类方法