本文整理汇总了Java中org.bukkit.event.player.PlayerInteractEvent.getClickedBlock方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent.getClickedBlock方法的具体用法?Java PlayerInteractEvent.getClickedBlock怎么用?Java PlayerInteractEvent.getClickedBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerInteractEvent
的用法示例。
在下文中一共展示了PlayerInteractEvent.getClickedBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE && player.hasPermission(ProtectionListener.PROTECTION_BYPASS_PERMISSION)) {
return;
}
if (plugin.getEotwHandler().isEndOfTheWorld()) {
return;
}
Block block = event.getClickedBlock();
if (!this.isSubclaimable(block)) {
return;
}
if (!this.checkSubclaimIntegrity(player, block)) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You do not have access to this subclaimed " + block.getType().toString() + '.');
}
}
示例2: onClick
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(PlayerInteractEvent e) {
if (e.getClickedBlock() == null)
return;
if (e.getClickedBlock().getType() != Material.COAL_BLOCK)
return;
KingdomFactionsPlayer player = PlayerModule.getInstance().getPlayer(e.getPlayer());
if (player.hasAction()) {
if (player.getAction() instanceof SetCapitalAction) {
e.setCancelled(true);
SetCapitalAction action = (SetCapitalAction) player.getAction();
action.setLocation(e.getClickedBlock().getLocation());
action.execute();
player.sendMessage(Messages.getInstance().getPrefix() + "Je hebt de HoofdStad Nexus gezet!");
}
}
}
示例3: run
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void run(PlayerInteractEvent evt) {
Block target = evt.getClickedBlock();
if (target == null) return;
Player player = evt.getPlayer();
if (fillFaceable(target) && !isFacedLog(target)) {
target.setData(fillData(target));
AzureAPI.playSound(player, Sound.BLOCK_WOOD_FALL, true);
ItemStack item = evt.getItem();
if (Item.isTool(item)) {
item.setDurability((short) (item.getDurability() + 4));
if (item.getType().getMaxDurability() <= item.getDurability()) {
player.setItemInHand(null);
AzureAPI.playSound(player, Sound.ENTITY_ITEM_BREAK, true);
}
}
} else {
AzureAPI.log(player, isFacedLog(target) ? "这块木头已削过皮了" : "这把刀只能削树皮用");
}
}
示例4: onSignClick
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onSignClick(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR)
return;
Block b = event.getClickedBlock();
if (b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN) {
Sign sign = (Sign) b.getState();
SignClickEvent ev = new SignClickEvent(event.getPlayer(), sign, event.getClickedBlock(), event.getAction() == Action.RIGHT_CLICK_BLOCK);
Bukkit.getServer().getPluginManager().callEvent(ev);
}
}
示例5: CheckInterackBed
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void CheckInterackBed(PlayerInteractEvent e) {
if (ConfigPatch.noBedExplore == true) {
Player p = e.getPlayer();
Block block = e.getClickedBlock();
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (block.getType() == Material.BED_BLOCK) {
if (p.getWorld().getEnvironment() == World.Environment.NETHER || p.getWorld().getEnvironment() == World.Environment.THE_END) {
e.setCancelled(true);
AzureAPI.log(p, ConfigPatch.AntiBedExplodeTipMessage);
}
}
}
}
}
示例6: onChestOpen
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
/**
* Open public inventory
*
* @param event Interact Event instance
*/
@EventHandler(ignoreCancelled = true)
public void onChestOpen(PlayerInteractEvent event)
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK
&& event.getClickedBlock() != null
&& event.getClickedBlock().getType() == Material.ENDER_CHEST
&& event.getClickedBlock().getLocation().getBlockX() == 0
&& event.getClickedBlock().getLocation().getBlockZ() == 0)
{
event.setCancelled(true);
event.getPlayer().openInventory(this.inventory);
}
}
示例7: anvilStuff
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void anvilStuff(PlayerInteractEvent e){
if(e.getClickedBlock() == null)return;
if(e.getClickedBlock().getType().equals(Material.ANVIL)){
e.setCancelled(true);
Player p = e.getPlayer();
String uuid = p.getUniqueId().toString();
long tokens = getTokens(uuid);
if(p.getItemInHand().getType() == Material.AIR ||
p.getItemInHand().getType() == Material.GOLDEN_APPLE ||
p.getItemInHand().getType() == Material.ARROW ||
p.getItemInHand().getType() == Material.POTION){
p.sendMessage(tag + ChatColor.RED + "You can\'t repair that!");
}else{
if(tokens < 1){
p.sendMessage(tag + ChatColor.RED + "You need at least 1 token to repair things!!");
}else{
if(p.getItemInHand().getDurability() > 0){
p.getItemInHand().setDurability((short) 0);
setTokens(uuid, getTokens(uuid)-1);
p.sendMessage(tag + ChatColor.BLUE + "Your item has been repaired");
}else{
p.sendMessage(tag + ChatColor.RED + "This item isn\'t broken");
}
}
}
}
}
示例8: onInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteract(PlayerInteractEvent e) {
final TOAUser u = TOA.getPlayer(e.getPlayer());
if (e.getItem() != null) {
Material m = e.getItem().getType();
if (m == Material.WRITTEN_BOOK || m == Material.BOW || m == Material.SHEARS || m == Material.DIAMOND_SWORD) return;
Ability.useAbility(u, e.getItem().getType());
e.setCancelled(true);
}
if (!u.isOnRank(PACmd.Grupo.Builder)) {
if (e.getClickedBlock() != null) {
if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
|| e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
|| e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
|| e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
|| e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
|| e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
|| e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
|| e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
|| e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
|| e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
|| e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
e.setCancelled(true);
}
}
}
}
示例9: onPlayerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent evt) {
if (!shouldHandleEvent(evt.getPlayer()) || !evt.hasBlock())
return;
Block bk = evt.getClickedBlock();
onBlockClick(evt, bk, evt.getAction() == Action.RIGHT_CLICK_BLOCK);
if (getFakeBlocks().containsKey(bk)) { // Make a block's fake material not fail.
evt.setCancelled(true);
Bukkit.getScheduler().runTask(Core.getInstance(), () -> setFakeBlock(bk, getFakeBlocks().get(bk)));
}
}
示例10: onInteractBusy
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteractBusy(PlayerInteractEvent event) {
if (event.getClickedBlock() == null)
return;
if (!inUse.contains(event.getClickedBlock().getLocation()))
return;
event.setCancelled(true);
if (event.getHand() == EquipmentSlot.HAND)
event.getPlayer().sendMessage(ChatColor.RED + "That generator is busy right now!");
}
示例11: onSignElevator
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onSignElevator(PlayerInteractEvent e) {
if (e.getClickedBlock() == null) {
return;
}
Block block = e.getClickedBlock();
BlockState state = block.getState();
if (state instanceof Sign) {
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Sign sign = (Sign)state;
double zdif = Math.abs(e.getPlayer().getLocation().getZ() - block.getLocation().getZ());
double xdif = Math.abs(e.getPlayer().getLocation().getX() - block.getLocation().getX());
String lineZero = sign.getLine(0);
String lineOne = sign.getLine(1);
if(ChatColor.stripColor(lineZero).equalsIgnoreCase("[Elevator]")) {
if(zdif < 1.5D && xdif < 1.5D ) {
if (ChatColor.stripColor(lineOne).equalsIgnoreCase("Up")) {
e.getPlayer().teleport(this.teleportSpotUp(block.getLocation(), block.getLocation().getBlockY(), 254));
}
if (ChatColor.stripColor(lineOne).equalsIgnoreCase("Down")) {
e.getPlayer().teleport(this.teleportSpotDown(block.getLocation(), block.getLocation().getBlockY(), 1));
}
} else {
e.getPlayer().sendMessage(ChatColor.RED + "You must be standing next to the sign!");
}
}
e.setCancelled(true);
return;
}
}
}
示例12: protect36
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void protect36(final PlayerInteractEvent event) {
if(event.getClickedBlock() != null) {
if(event.getClickedBlock().getType() == Material.PISTON_MOVING_PIECE) {
event.setCancelled(true);
}
}
}
示例13: onPlayerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
return;
Player p = event.getPlayer();
Gamer g = Gamer.get(p);
Block b = event.getClickedBlock();
for (Course c : Course.getList()) {
Block test1 = c.getButton();
Block test2 = c.getEnd();
if (test1 != null && test1.getX() == b.getX() && test1.getY() == b.getY() && test1.getZ() == b.getZ()) {
g.setVariable("parkour", c);
p.teleport(c.getStart());
return;
}
if (test2 != null && test2.getX() == b.getX() && test2.getY() == b.getY() && test2.getZ() == b.getZ()) {
Chat.server(Gamer.get(p.getName()).getRank().getPrefix() + p.getDisplayName() + " &ejust beat &2&l" + c.getTitle() + "");
if (c.getNextCourse() != null) {
Course next = Course.get(c.getNextCourse());
if (next != null) {
g.setVariable("parkour", next);
p.teleport(next.getStart());
return;
}
}
p.teleport(c.getStart());
return;
}
}
}
示例14: onPlayerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
public void onPlayerInteract(PlayerInteractEvent e) {
if (e.isCancelled()) return;
KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
if(p.getSettingsProfile().hasAdminMode()) return;
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if (e.getClickedBlock() == null) return;
Block clickedBlock = e.getClickedBlock();
if (clickedBlock.getType().equals(Material.CHEST) || clickedBlock.getType().equals(Material.TRAPPED_CHEST) || clickedBlock.getType().equals(Material.BEACON)) {
e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 500));
return;
}
if (clickedBlock.getType().equals(Material.BURNING_FURNACE) || clickedBlock.getType().equals(Material.FURNACE) || clickedBlock.getType().equals(Material.DISPENSER) || clickedBlock.getType().equals(Material.HOPPER) || clickedBlock.getType().equals(Material.DROPPER)) {
e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 150));
return;
}
MaterialData data = clickedBlock.getState() != null ? clickedBlock.getState().getData() : null;
if (data instanceof Openable) {
if (clickedBlock.getType() == Material.IRON_TRAPDOOR || clickedBlock.getType() == Material.IRON_DOOR) return;
e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 150));
return;
}
}
}
示例15: soilChangePlayer
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void soilChangePlayer(PlayerInteractEvent e) {
if(e.getClickedBlock() == null) return;
if ((e.getAction() == Action.PHYSICAL) && (e.getClickedBlock().getType() == Material.SOIL)) {
KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
if(p.isVanished()) return;
if(e.isCancelled()) return;
if(!p.canBuild(e.getClickedBlock().getLocation())) {
e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 50));
}
}
}