private static void init() throws Throwable {
if (!initialized) {
// Denote that we're done
initialized = true;
initPackage();
DispenserRegistry.c(); // Basically registers everything
// Mock the server object
Server mockedServer = mock(Server.class);
ItemMeta mockedMeta = mock(ItemMeta.class);
ItemFactory mockedFactory = new ItemFactoryDelegate(mockedMeta);
when(mockedServer.getItemFactory()).thenReturn(mockedFactory);
when(mockedServer.isPrimaryThread()).thenReturn(true);
// when(mockedFactory.getItemMeta(any(Material.class))).thenReturn(mockedMeta);
// Inject this fake server
FieldUtils.writeStaticField(Bukkit.class, "server", mockedServer, true);
}
}
java类org.bukkit.inventory.ItemFactory的实例源码
WrapperTest.java 文件源码
项目:Wrappit
阅读 26
收藏 0
点赞 0
评论 0
RuleBookItem.java 文件源码
项目:ShankShock-Core
阅读 19
收藏 0
点赞 0
评论 0
public void giveItem(Player ply, Registration plugin) {
ItemStack i = new ItemStack(Material.WRITTEN_BOOK);
ItemFactory itemFactory = plugin.getServer().getItemFactory();
BookMeta bookMeta = (BookMeta) itemFactory.getItemMeta(Material.WRITTEN_BOOK);
bookMeta.setTitle("The Manual");
bookMeta.setAuthor("Shank");
bookMeta.setPages("Welcome to BlockShock, a ShankShock Production.\n\nThis manual contains the rules, commands, and basics for surviving on the server.\n\nMore info @ ShankShock.Com.",
"## The Rules\n\n1. No chat spamming.\n2. No hacking mods.\n3. Don't steal, break, or cause grief to any player or their creations.\n4. Don't ask for admin.\n5. Don't advertise.\n6. Respect all players.",
"## Commands\n\n1. The usual home/warp commands.\n2. /inventory\n3. /shop\n4. /name",
"## Mods\n\nExplosions & TNT are disabled. Creepers can't break your stuff. You can't drown. Falling damage and fire spread are disabled too.",
"## Conversations\n\nSome commands, such as the inventory and shop commands, will take over your chat box. Simply type a response to what they ask for to use them. You can always exit with /quit.",
"## Exiting Spawn\n\nTo exit spawn, simply warp to another location.\n\n/warp ShadowVale",
"## Help\n\nAdmins have light blue name colors in chat. The owners are dark red and cyan. You can ask them for any help you need, though they don't have to give it. Admins aren't your slaves.",
"## More Info\n\nMore information can be found at:\n\nwiki.shankshock.com\nshankshock.com");
i.setItemMeta(bookMeta);
ply.getInventory().addItem(i);
}
ChallengeLogicTest.java 文件源码
项目:uSkyBlock
阅读 19
收藏 0
点赞 0
评论 0
private static Server createServerMock() {
Server serverMock = mock(Server.class);
ItemFactory itemFactoryMock = mock(ItemFactory.class);
when(serverMock.getItemFactory()).thenReturn(itemFactoryMock);
PluginManager pluginManagerMock = mock(PluginManager.class);
when(serverMock.getPluginManager()).thenReturn(pluginManagerMock);
return serverMock;
}
CardboardMetaEnchantment.java 文件源码
项目:StarQuestCode
阅读 16
收藏 0
点赞 0
评论 0
@SuppressWarnings("deprecation")
public ItemMeta unbox() {
ItemFactory factory = Bukkit.getServer().getItemFactory();
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) factory.getItemMeta(Material.getMaterial(this.id));
for (CardboardEnchantment e : this.enchantments.keySet()) {
meta.addStoredEnchant(e.unbox(), this.enchantments.get(e), true);
}
return meta;
}
CardboardBox.java 文件源码
项目:StarQuestCode
阅读 20
收藏 0
点赞 0
评论 0
public ItemStack unbox() {
@SuppressWarnings("deprecation")
ItemStack item = new ItemStack(type, amount, damage);
// These metas below will never be null because of the if/else during
// the packing
ItemFactory factory = Bukkit.getServer().getItemFactory();
ItemMeta itemMeta = factory.getItemMeta(Material.getMaterial(item.getTypeId()));
// Should only have one specific item meta at a time
if ((this.meta != null)) {
itemMeta = this.meta.unbox();
}
if (this.name != null) {
itemMeta.setDisplayName(this.name);
}
if (this.lore != null) {
itemMeta.setLore(this.lore);
}
// Apply item meta
item.setItemMeta(itemMeta);
HashMap<Enchantment, Integer> map = new HashMap<Enchantment, Integer>();
for (CardboardEnchantment cEnchantment : enchants.keySet()) {
map.put(cEnchantment.unbox(), enchants.get(cEnchantment));
}
item.addUnsafeEnchantments(map);
return item;
}
CardboardMetaEnchantment.java 文件源码
项目:StarQuestCode
阅读 18
收藏 0
点赞 0
评论 0
@SuppressWarnings("deprecation")
public ItemMeta unbox() {
ItemFactory factory = Bukkit.getServer().getItemFactory();
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) factory.getItemMeta(Material.getMaterial(this.id));
for (CardboardEnchantment e : this.enchantments.keySet()) {
meta.addStoredEnchant(e.unbox(), this.enchantments.get(e), true);
}
return meta;
}
CardboardBox.java 文件源码
项目:StarQuestCode
阅读 22
收藏 0
点赞 0
评论 0
public ItemStack unbox() {
@SuppressWarnings("deprecation")
ItemStack item = new ItemStack(type, amount, damage);
// These metas below will never be null because of the if/else during
// the packing
ItemFactory factory = Bukkit.getServer().getItemFactory();
ItemMeta itemMeta = factory.getItemMeta(Material.getMaterial(item.getTypeId()));
// Should only have one specific item meta at a time
if ((this.meta != null)) {
itemMeta = this.meta.unbox();
}
if (this.name != null) {
itemMeta.setDisplayName(this.name);
}
if (this.lore != null) {
itemMeta.setLore(this.lore);
}
// Apply item meta
item.setItemMeta(itemMeta);
HashMap<Enchantment, Integer> map = new HashMap<Enchantment, Integer>();
for (CardboardEnchantment cEnchantment : enchants.keySet()) {
map.put(cEnchantment.unbox(), enchants.get(cEnchantment));
}
item.addUnsafeEnchantments(map);
return item;
}
CardboardMetaEnchantment.java 文件源码
项目:StarQuestCode
阅读 20
收藏 0
点赞 0
评论 0
public ItemMeta unbox() {
ItemFactory factory = Bukkit.getServer().getItemFactory();
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) factory.getItemMeta(Material.getMaterial(this.id));
for (CardboardEnchantment e : this.enchantments.keySet()) {
meta.addStoredEnchant(e.unbox(), this.enchantments.get(e), true);
}
return meta;
}
CardboardBox.java 文件源码
项目:StarQuestCode
阅读 19
收藏 0
点赞 0
评论 0
public ItemStack unbox() {
ItemStack item = new ItemStack(type, amount, damage);
// These metas below will never be null because of the if/else during
// the packing
ItemFactory factory = Bukkit.getServer().getItemFactory();
ItemMeta itemMeta = factory.getItemMeta(Material.getMaterial(item.getTypeId()));
// Should only have one specific item meta at a time
if ((this.meta != null)) {
itemMeta = this.meta.unbox();
}
if (this.name != null) {
itemMeta.setDisplayName(this.name);
}
if (this.lore != null) {
itemMeta.setLore(this.lore);
}
// Apply item meta
item.setItemMeta(itemMeta);
HashMap<Enchantment, Integer> map = new HashMap<Enchantment, Integer>();
for (CardboardEnchantment cEnchantment : enchants.keySet()) {
map.put(cEnchantment.unbox(), enchants.get(cEnchantment));
}
item.addUnsafeEnchantments(map);
return item;
}
ItemStackTest.java 文件源码
项目:Craft-city
阅读 21
收藏 0
点赞 0
评论 0
Material[] value() {
final ItemFactory factory = CraftItemFactory.instance();
final Map<Class<? extends ItemMeta>, Material> possibleMaterials = new HashMap<Class<? extends ItemMeta>, Material>();
for (final Material material : Material.values()) {
final ItemMeta meta = factory.getItemMeta(material);
if (meta == null || possibleMaterials.containsKey(meta.getClass()))
continue;
possibleMaterials.put(meta.getClass(), material);
}
return possibleMaterials.values().toArray(new Material[possibleMaterials.size()]);
}
MockFactory.java 文件源码
项目:MCLibrary
阅读 25
收藏 0
点赞 0
评论 0
public static ItemFactory createItemFactory() {
ItemFactory factory = mock(ItemFactory.class);
when(factory.getItemMeta(any())).thenReturn(new MockItemMeta());
return factory;
}
NetherServer.java 文件源码
项目:netherrack
阅读 19
收藏 0
点赞 0
评论 0
@Override
public ItemFactory getItemFactory() {
// TODO Auto-generated method stub
return null;
}
Bukkit.java 文件源码
项目:Thermos-Bukkit
阅读 40
收藏 0
点赞 0
评论 0
/**
* @see Server#getItemFactory()
*/
public static ItemFactory getItemFactory() {
return server.getItemFactory();
}
TestServer.java 文件源码
项目:ExilePearl
阅读 23
收藏 0
点赞 0
评论 0
@Override
public ItemFactory getItemFactory() {
return itemFactory;
}
CraftServer.java 文件源码
项目:Pokkit
阅读 22
收藏 0
点赞 0
评论 0
@Override
public ItemFactory getItemFactory() {
return itemFactory;
}
Bukkit.java 文件源码
项目:CauldronGit
阅读 19
收藏 0
点赞 0
评论 0
/**
* @see Server#getItemFactory()
*/
public static ItemFactory getItemFactory() {
return server.getItemFactory();
}
CanaryServer.java 文件源码
项目:CanaryBukkit
阅读 21
收藏 0
点赞 0
评论 0
public ItemFactory getItemFactory() {
throw new NotImplementedException("getItemFactory()");
}
Bukkit.java 文件源码
项目:Cauldron
阅读 24
收藏 0
点赞 0
评论 0
/**
* @see Server#getItemFactory()
*/
public static ItemFactory getItemFactory() {
return server.getItemFactory();
}
Bukkit.java 文件源码
项目:Cauldron
阅读 41
收藏 0
点赞 0
评论 0
/**
* @see Server#getItemFactory()
*/
public static ItemFactory getItemFactory() {
return server.getItemFactory();
}
Bukkit.java 文件源码
项目:Cauldron
阅读 23
收藏 0
点赞 0
评论 0
/**
* @see Server#getItemFactory()
*/
public static ItemFactory getItemFactory() {
return server.getItemFactory();
}
Bukkit.java 文件源码
项目:Almura-API
阅读 19
收藏 0
点赞 0
评论 0
/**
* @see Server#getItemFactory()
*/
public static ItemFactory getItemFactory() {
return server.getItemFactory();
}
ServerTest.java 文件源码
项目:Minotaurus
阅读 38
收藏 0
点赞 0
评论 0
@Override
public ItemFactory getItemFactory() {
return null;
}
PoreServer.java 文件源码
项目:Pore
阅读 21
收藏 0
点赞 0
评论 0
@Override
public ItemFactory getItemFactory() {
throw new NotImplementedException("TODO");
}
Bukkit.java 文件源码
项目:BedrockAPI
阅读 21
收藏 0
点赞 0
评论 0
public static ItemFactory getItemFactory() {
return null;
}
Bukkit.java 文件源码
项目:Spigot-API
阅读 23
收藏 0
点赞 0
评论 0
/**
* @see Server#getItemFactory()
*/
public static ItemFactory getItemFactory() {
return server.getItemFactory();
}
Bukkit.java 文件源码
项目:Bukkit-JavaDoc
阅读 22
收藏 0
点赞 0
评论 0
/**
* @see Server#getItemFactory()
*/
public static ItemFactory getItemFactory() {
return server.getItemFactory();
}
Server.java 文件源码
项目:GGS
阅读 23
收藏 0
点赞 0
评论 0
@Override
public ItemFactory getItemFactory() {
// TODO Auto-generated method stub
return null;
}
Server.java 文件源码
项目:Thermos-Bukkit
阅读 31
收藏 0
点赞 0
评论 0
/**
* Gets the instance of the item factory (for {@link ItemMeta}).
*
* @return the item factory
* @see ItemFactory
*/
ItemFactory getItemFactory();
Server.java 文件源码
项目:CauldronGit
阅读 21
收藏 0
点赞 0
评论 0
/**
* Gets the instance of the item factory (for {@link ItemMeta}).
*
* @return the item factory
* @see ItemFactory
*/
ItemFactory getItemFactory();
Server.java 文件源码
项目:Cauldron
阅读 21
收藏 0
点赞 0
评论 0
/**
* Gets the instance of the item factory (for {@link ItemMeta}).
*
* @return the item factory
* @see ItemFactory
*/
ItemFactory getItemFactory();