@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);
}
java类org.bukkit.event.player.PlayerSwapHandItemsEvent的实例源码
TrinketManager.java 文件源码
项目:ZentrelaRPG
阅读 23
收藏 0
点赞 0
评论 0
Player19Listener.java 文件源码
项目:BedwarsRel
阅读 24
收藏 0
点赞 0
评论 0
@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;
}
}
HandSwapListener.java 文件源码
项目:RPGInventory
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
}
}
Soul.java 文件源码
项目:Damocles
阅读 22
收藏 0
点赞 0
评论 0
@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;
}
Listener19.java 文件源码
项目:PetBlocks
阅读 34
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerSwapItems(PlayerSwapHandItemsEvent event) {
if (this.carryingPet.contains(event.getPlayer())) {
event.setCancelled(true);
}
}
InventoryEditionListener.java 文件源码
项目:Hub
阅读 30
收藏 0
点赞 0
评论 0
@EventHandler
public void onSecondHandItemSwap(PlayerSwapHandItemsEvent event)
{
event.setCancelled(true);
}
HandSwapListener.java 文件源码
项目:RPGInventory
阅读 26
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void afterHandSwap(PlayerSwapHandItemsEvent event) {
ItemManager.updateStats(event.getPlayer());
}
ModuleDisableOffHand.java 文件源码
项目:BukkitOldCombatMechanics
阅读 28
收藏 0
点赞 0
评论 0
@EventHandler (priority = EventPriority.HIGHEST)
public void onSwapHandItems(PlayerSwapHandItemsEvent e) {
if(isEnabled(e.getPlayer().getWorld()) && shouldWeCancel(e.getOffHandItem())){
e.setCancelled(true);
}
}
CustomBookOverlay1_9.java 文件源码
项目:CS-CoreLib
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler
public void onDrop(PlayerSwapHandItemsEvent e) {
if (CustomBookOverlay.opening.contains(e.getPlayer().getUniqueId())) e.setCancelled(true);
}
PlayerSwapHandItemsList.java 文件源码
项目:LeagueOfLegends
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler
public void shieldProtection(PlayerSwapHandItemsEvent event){
event.setCancelled(true);
}
PlayerListener19.java 文件源码
项目:AuthMeReloaded
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if (listenerService.shouldCancelEvent(event)) {
event.setCancelled(true);
}
}
PlayerListener19Test.java 文件源码
项目:AuthMeReloaded
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void shouldCancelEvent() {
withServiceMock(listenerService)
.check(listener::onPlayerSwapHandItems, PlayerSwapHandItemsEvent.class);
}