当前位置: 首页>>代码示例>>Java>>正文


Java PlayerSwapHandItemsEvent类代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerSwapHandItemsEvent的典型用法代码示例。如果您正苦于以下问题:Java PlayerSwapHandItemsEvent类的具体用法?Java PlayerSwapHandItemsEvent怎么用?Java PlayerSwapHandItemsEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PlayerSwapHandItemsEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerSwapHandItemsEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPlayerSwapHandItems

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
    event.setCancelled(true);
    try {
        PlayerDataRPG pd = plugin.getPD(event.getPlayer());
        if (pd != null && pd.isValid()) {
            if (pd.trinket != null) {
                if (System.currentTimeMillis() > pd.nextTrinketCast) {
                    pd.sendMessage(ChatColor.GRAY + ">> " + ChatColor.GREEN + "You cast your Trinket Spell, " + ChatColor.YELLOW + pd.trinket.spell.getName() + ChatColor.GREEN + ".");
                    RParticles.showWithOffsetPositiveY(ParticleEffect.VILLAGER_HAPPY, event.getPlayer().getLocation().add(0, 1, 0), 1.0, 10);
                    pd.trinket.spell.cast(event.getPlayer(), pd);
                    pd.nextTrinketCast = System.currentTimeMillis() + pd.trinket.spell.getCooldown() * 1000;
                } else {
                    double diff = ((double) pd.nextTrinketCast - System.currentTimeMillis()) / 1000.0;
                    pd.sendMessage(ChatColor.RED + "You cannot use your Trinket Spell for another " + String.format("%.1f", diff) + " seconds!");
                }
            } else {
                pd.sendMessage(ChatColor.RED + "You do not have a Trinket equipped! Use " + ChatColor.YELLOW + "/trinket" + ChatColor.RED + " to equip one!");
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    event.setCancelled(true);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:26,代码来源:TrinketManager.java

示例2: onPlayerSwapHandItems

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
  Player player = event.getPlayer();
  Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player);

  if (game == null) {
    return;
  }

  if (game.getState() == GameState.WAITING
      || (game.getCycle() instanceof BungeeGameCycle && game.getCycle().isEndGameRunning()
      && BedwarsRel.getInstance().getBooleanConfig("bungeecord.endgame-in-lobby", true))) {
    event.setCancelled(true);
    return;
  }
}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:17,代码来源:Player19Listener.java

示例3: onHandSwap

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler
public void onHandSwap(PlayerSwapHandItemsEvent event) {
    Player player = event.getPlayer();

    Slot offHandSlot = SlotManager.instance().getShieldSlot();
    Slot mainHandSlot = SlotManager.instance().getSlot(player.getInventory().getHeldItemSlot(), InventoryType.SlotType.QUICKBAR);
    ItemStack newOffHandItem = event.getOffHandItem();
    ItemStack newMainHandItem = event.getMainHandItem();

    if (offHandSlot == null && mainHandSlot == null) {
        return;
    }

    if (offHandSlot != null) {
        if (!ItemUtils.isEmpty(newOffHandItem)
                && !InventoryManager.validateUpdate(player, ActionType.SET, offHandSlot, newOffHandItem)) {
            event.setCancelled(true);
            return;
        }
    }

    if (mainHandSlot != null) {
        if (!ItemUtils.isEmpty(newOffHandItem) && mainHandSlot.isCup(newOffHandItem)) {
            event.setCancelled(true);
            return;
        }

        if (!InventoryManager.validateUpdate(player, ActionType.SET, mainHandSlot, newMainHandItem)) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:33,代码来源:HandSwapListener.java

示例4: onItemSwap

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler
public void onItemSwap(PlayerSwapHandItemsEvent event){
	ItemStack main = event.getMainHandItem();
	ItemStack off = event.getOffHandItem();
	Account account = new Account(event.getPlayer());
	ca.damocles.accountsystem.Character character = account.getLoadedCharacter();
	if(main.equals(soulApple(character))){
		event.setCancelled(true);
	}
	if(off.equals(soulApple(character))){
		event.setCancelled(true);
	}
	
	return;
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:16,代码来源:Soul.java

示例5: onPlayerSwapItems

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerSwapItems(PlayerSwapHandItemsEvent event) {
    if (this.carryingPet.contains(event.getPlayer())) {
        event.setCancelled(true);
    }
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:7,代码来源:Listener19.java

示例6: onSecondHandItemSwap

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler
public void onSecondHandItemSwap(PlayerSwapHandItemsEvent event)
{
    event.setCancelled(true);
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:6,代码来源:InventoryEditionListener.java

示例7: afterHandSwap

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void afterHandSwap(PlayerSwapHandItemsEvent event) {
    ItemManager.updateStats(event.getPlayer());
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:5,代码来源:HandSwapListener.java

示例8: onSwapHandItems

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler (priority = EventPriority.HIGHEST)
public void onSwapHandItems(PlayerSwapHandItemsEvent e) {
	if(isEnabled(e.getPlayer().getWorld()) && shouldWeCancel(e.getOffHandItem())){
		e.setCancelled(true);
	}
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:7,代码来源:ModuleDisableOffHand.java

示例9: onDrop

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler
public void onDrop(PlayerSwapHandItemsEvent e) {
	if (CustomBookOverlay.opening.contains(e.getPlayer().getUniqueId())) e.setCancelled(true);
}
 
开发者ID:TheBusyBiscuit,项目名称:CS-CoreLib,代码行数:5,代码来源:CustomBookOverlay1_9.java

示例10: shieldProtection

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler
public void shieldProtection(PlayerSwapHandItemsEvent event){
	event.setCancelled(true);
}
 
开发者ID:xdev-pl,项目名称:LeagueOfLegends,代码行数:5,代码来源:PlayerSwapHandItemsList.java

示例11: onPlayerSwapHandItems

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
    if (listenerService.shouldCancelEvent(event)) {
        event.setCancelled(true);
    }
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:7,代码来源:PlayerListener19.java

示例12: shouldCancelEvent

import org.bukkit.event.player.PlayerSwapHandItemsEvent; //导入依赖的package包/类
@Test
public void shouldCancelEvent() {
    withServiceMock(listenerService)
        .check(listener::onPlayerSwapHandItems, PlayerSwapHandItemsEvent.class);
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:6,代码来源:PlayerListener19Test.java


注:本文中的org.bukkit.event.player.PlayerSwapHandItemsEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。