本文整理汇总了Java中org.bukkit.block.Beacon类的典型用法代码示例。如果您正苦于以下问题:Java Beacon类的具体用法?Java Beacon怎么用?Java Beacon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Beacon类属于org.bukkit.block包,在下文中一共展示了Beacon类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import org.bukkit.block.Beacon; //导入依赖的package包/类
@Nullable
@Override
protected PotionEffect[] get(Event e) {
Block b = beacon.getSingle(e);
if (b == null) {
return null;
}
if (b.getType() == Material.BEACON) {
return new PotionEffect[]{isPrimary
? ((Beacon) b.getState()).getPrimaryEffect()
: ((Beacon) b.getState()).getSecondaryEffect()};
}
return null;
}
示例2: change
import org.bukkit.block.Beacon; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode changeMode) {
Block b = beacon.getSingle(e);
if (b == null) {
return;
}
if (b.getType() == Material.BEACON) {
Beacon state = ((Beacon) b.getState());
switch (changeMode) {
case SET:
if (isPrimary) {
state.setPrimaryEffect((PotionEffectType) delta[0]);
} else {
state.setSecondaryEffect((PotionEffectType) delta[0]);
}
break;
case DELETE:
case RESET:
if (isPrimary) {
state.setPrimaryEffect(null);
} else {
state.setSecondaryEffect(null);
}
break;
}
state.update(true, false);
}
}
示例3: get
import org.bukkit.block.Beacon; //导入依赖的package包/类
@Nullable
@Override
protected LivingEntity[] get(Event e) {
Block b = beacon.getSingle(e);
if (b == null) {
return null;
}
if (b.getType() == Material.BEACON) {
Beacon state = (Beacon) b.getState();
return state.getEntitiesInRange().toArray(new LivingEntity[state.getEntitiesInRange().size()]);
}
return null;
}
示例4: convert
import org.bukkit.block.Beacon; //导入依赖的package包/类
@Override
public Number convert(Block b) {
if (b.getState() instanceof Beacon) {
return ((Beacon) b.getState()).getTier();
}
return null;
}
示例5: onInteraction
import org.bukkit.block.Beacon; //导入依赖的package包/类
@EventHandler
public void onInteraction(PlayerInteractEvent event) {
if (testObserver(event.getPlayer())) {
event.setCancelled(true);
if ((event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) && (event.getPlayer().getInventory().getItemInMainHand() != null && event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.WRITTEN_BOOK))){
event.setUseInteractedBlock(Event.Result.DENY);
event.setUseItemInHand(Event.Result.ALLOW);
}
if (event.getClickedBlock() != null && !event.getPlayer().isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (event.getClickedBlock().getType().equals(Material.CHEST) || event.getClickedBlock().getType().equals(Material.TRAPPED_CHEST)) {
Inventory chest = Bukkit.createInventory(null, ((Chest) event.getClickedBlock().getState()).getInventory().getSize());
for (int i = 0; i < ((Chest) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
chest.setItem(i, ((Chest) event.getClickedBlock().getState()).getInventory().getItem(i));
}
event.getPlayer().openInventory(chest);
}
if (event.getClickedBlock().getType().equals(Material.FURNACE) || event.getClickedBlock().getType().equals(Material.BURNING_FURNACE)) {
Inventory furnace = Bukkit.createInventory(null, InventoryType.FURNACE);
for (int i = 0; i < ((Furnace) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
furnace.setItem(i, ((Furnace) event.getClickedBlock().getState()).getInventory().getItem(i));
}
event.getPlayer().openInventory(furnace);
}
if (event.getClickedBlock().getType().equals(Material.DISPENSER)) {
Inventory dispenser = Bukkit.createInventory(null, InventoryType.DISPENSER);
for (int i = 0; i < ((Dispenser) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
dispenser.setItem(i, ((Dispenser) event.getClickedBlock().getState()).getInventory().getItem(i));
}
event.getPlayer().openInventory(dispenser);
}
if (event.getClickedBlock().getType().equals(Material.DROPPER)) {
Inventory dropper = Bukkit.createInventory(null, InventoryType.DROPPER);
for (int i = 0; i < ((Dropper) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
dropper.setItem(i, ((Dropper) event.getClickedBlock().getState()).getInventory().getItem(i));
}
event.getPlayer().openInventory(dropper);
}
if (event.getClickedBlock().getType().equals(Material.HOPPER)) {
Inventory hopper = Bukkit.createInventory(null, InventoryType.HOPPER);
for (int i = 0; i < ((Hopper) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
hopper.setItem(i, ((Hopper) event.getClickedBlock().getState()).getInventory().getItem(i));
}
event.getPlayer().openInventory(hopper);
}
if (event.getClickedBlock().getType().equals(Material.BREWING_STAND)) {
Inventory brewingStand = Bukkit.createInventory(null, InventoryType.BREWING);
for (int i = 0; i < ((BrewingStand) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
brewingStand.setItem(i, ((BrewingStand) event.getClickedBlock().getState()).getInventory().getItem(i));
}
event.getPlayer().openInventory(brewingStand);
}
if (event.getClickedBlock().getType().equals(Material.BEACON)) {
Inventory beacon = Bukkit.createInventory(null, InventoryType.BEACON);
for (int i = 0; i < ((Beacon) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
beacon.setItem(i, ((Beacon) event.getClickedBlock().getState()).getInventory().getItem(i));
}
event.getPlayer().openInventory(beacon);
}
}
}
}