本文整理汇总了Java中me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem.getHandlers方法的典型用法代码示例。如果您正苦于以下问题:Java SlimefunItem.getHandlers方法的具体用法?Java SlimefunItem.getHandlers怎么用?Java SlimefunItem.getHandlers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem
的用法示例。
在下文中一共展示了SlimefunItem.getHandlers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockRegister
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockRegister(BlockPlaceEvent e) {
if (BlockStorage.hasBlockInfo(e.getBlock())) {
e.setCancelled(true);
return;
}
ItemStack item = e.getItemInHand();
if (item != null && item.getType() == Material.INK_SACK) return;
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem != null && !(sfItem instanceof NotPlaceable)){
BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true);
if (SlimefunItem.blockhandler.containsKey(sfItem.getID())) {
SlimefunItem.blockhandler.get(sfItem.getID()).onPlace(e.getPlayer(), e.getBlock(), sfItem);
}
}
else {
for (ItemHandler handler: SlimefunItem.getHandlers("BlockPlaceHandler")) {
if (((BlockPlaceHandler) handler).onBlockPlace(e, item)) break;
}
}
}
示例2: onArrowSuccessfulHit
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler
public void onArrowSuccessfulHit(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Arrow) {
if (Variables.arrows.containsKey(e.getDamager().getUniqueId()) && e.getEntity() instanceof LivingEntity) {
for (ItemHandler handler: SlimefunItem.getHandlers("BowShootHandler")) {
if (((BowShootHandler) handler).onHit(e, (LivingEntity) e.getEntity())) break;
}
Variables.arrows.remove(e.getDamager().getUniqueId());
}
handleGrapplingHook((Arrow) e.getDamager());
}
}
示例3: onRightClick
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler
public void onRightClick(PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (!e.getHand().equals(EquipmentSlot.HAND)) return;
Player p = e.getPlayer();
Block b = e.getClickedBlock();
List<MultiBlock> multiblocks = new ArrayList<MultiBlock>();
for (MultiBlock mb: MultiBlock.list()) {
if (mb.getTriggerBlock() == b.getType()) {
Material[] blocks = mb.getBuild();
if (mb.getTriggerBlock() == blocks[1]) {
if (
BlockAdjacents.hasMaterialOnSide(b, blocks[0]) &&
BlockAdjacents.hasMaterialOnSide(b, blocks[2]) &&
BlockAdjacents.isMaterial(b.getRelative(BlockFace.DOWN), blocks[4]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.DOWN), blocks[3]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.DOWN), blocks[5]) &&
BlockAdjacents.isMaterial(b.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN), blocks[7]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN), blocks[6]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN), blocks[8])
) {
if (blocks[0] != null && blocks[0] == blocks[2] && !BlockAdjacents.hasMaterialOnBothSides(b.getRelative(0, 0, 0), blocks[0]));
else if (blocks[3] != null && blocks[3] == blocks[5] && !BlockAdjacents.hasMaterialOnBothSides(b.getRelative(0, -1, 0), blocks[5]));
else if (blocks[6] != null && blocks[6] == blocks[8] && !BlockAdjacents.hasMaterialOnBothSides(b.getRelative(0, -2, 0), blocks[8]));
else multiblocks.add(mb);
}
}
else if (mb.getTriggerBlock() == blocks[4]) {
if (
BlockAdjacents.hasMaterialOnSide(b, blocks[3]) &&
BlockAdjacents.hasMaterialOnSide(b, blocks[5]) &&
BlockAdjacents.isMaterial(b.getRelative(BlockFace.DOWN), blocks[7]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.DOWN), blocks[6]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.DOWN), blocks[8]) &&
BlockAdjacents.isMaterial(b.getRelative(BlockFace.UP), blocks[1]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.UP), blocks[0]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.UP), blocks[2])
) {
if (blocks[0] != null && blocks[0] == blocks[2] && !BlockAdjacents.hasMaterialOnBothSides(b.getRelative(0, 1, 0), blocks[0]));
else if (blocks[3] != null && blocks[3] == blocks[5] && !BlockAdjacents.hasMaterialOnBothSides(b.getRelative(0, 0, 0), blocks[5]));
else if (blocks[6] != null && blocks[6] == blocks[8] && !BlockAdjacents.hasMaterialOnBothSides(b.getRelative(0, -1, 0), blocks[8]));
else multiblocks.add(mb);;
}
}
else if (mb.getTriggerBlock() == blocks[7]) {
if (
BlockAdjacents.hasMaterialOnSide(b, blocks[6]) &&
BlockAdjacents.hasMaterialOnSide(b, blocks[8]) &&
BlockAdjacents.isMaterial(b.getRelative(BlockFace.UP).getRelative(BlockFace.UP), blocks[1]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.UP).getRelative(BlockFace.UP), blocks[0]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.UP).getRelative(BlockFace.UP), blocks[2]) &&
BlockAdjacents.isMaterial(b.getRelative(BlockFace.UP), blocks[4]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.UP), blocks[3]) &&
BlockAdjacents.hasMaterialOnSide(b.getRelative(BlockFace.UP), blocks[5])
) {
if (blocks[0] != null && blocks[0] == blocks[2] && !BlockAdjacents.hasMaterialOnBothSides(b.getRelative(0, 2, 0), blocks[0]));
else if (blocks[3] != null && blocks[3] == blocks[5] && !BlockAdjacents.hasMaterialOnBothSides(b.getRelative(0, 1, 0), blocks[5]));
else if (blocks[6] != null && blocks[6] == blocks[8] && !BlockAdjacents.hasMaterialOnBothSides(b.getRelative(0, 0, 0), blocks[8]));
else multiblocks.add(mb);;
}
}
}
}
if (!multiblocks.isEmpty()) {
e.setCancelled(true);
for (ItemHandler handler: SlimefunItem.getHandlers("MultiBlockInteractionHandler")) {
if (((MultiBlockInteractionHandler) handler).onInteract(p, multiblocks.get(multiblocks.size() - 1), b)) break;
}
MultiBlockInteractEvent event = new MultiBlockInteractEvent(p, multiblocks.get(multiblocks.size() - 1), b);
Bukkit.getPluginManager().callEvent(event);
}
}
}