本文整理汇总了Java中org.bukkit.event.player.PlayerItemHeldEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerItemHeldEvent类的具体用法?Java PlayerItemHeldEvent怎么用?Java PlayerItemHeldEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerItemHeldEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerItemHeldEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onQuickSlotHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onQuickSlotHeld(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
int slotId = event.getNewSlot();
Slot slot = InventoryManager.getQuickSlot(slotId);
if (slot != null && slot.isCup(player.getInventory().getItem(slotId))) {
event.setCancelled(true);
InventoryUtils.heldFreeSlot(player, slotId,
(event.getPreviousSlot() + 1) % 9 == slotId ? InventoryUtils.SearchType.NEXT : InventoryUtils.SearchType.PREV);
}
}
示例2: onTakeRune
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onTakeRune(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
if(plugin.getRuneManager().getEffect(player) != null && plugin.getRuneManager().getActiveRune(player) == null) {
plugin.getRuneManager().removeEffect(event.getPlayer());
}
ItemStack item = event.getPlayer().getInventory().getItem(event.getNewSlot());
if(item == null || item.getItemMeta() == null || !item.getType().equals(Material.ENCHANTED_BOOK)) {
return;
}
Rune rune = plugin.getRuneManager().getRune(item.getItemMeta().getDisplayName().substring(2));
if(rune == null) {
return;
}
plugin.getRuneManager().startHoldingEffect(player, rune);
}
示例3: onWeaponSwitch
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onWeaponSwitch(PlayerItemHeldEvent e) {
if (!player.getPlayer().isOnline()) {
return;
}
if (!e.getPlayer().getUniqueId().equals(player.getPlayer().getUniqueId())) {
return;
}
if (!(QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds()
.contains(e.getPlayer().getWorld().getName()))) {
return;
}
//not allowed to switch weapons, cheater!
this.cancel();
e.getPlayer().sendMessage(FADE_MESSAGE);
}
示例4: onToolSwap
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onToolSwap(PlayerItemHeldEvent e) {
if (!e.getPlayer().getUniqueId().equals(player.getPlayer().getUniqueId())) {
return;
}
if (!isWrongTool && !skill.isTool(e.getPlayer().getInventory().getItem(e.getNewSlot()))) {
this.isWrongTool = true;
e.getPlayer().sendMessage(WRONG_TOOL_MESSAGE);
this.wrongItemTimeLeft = WRONG_TOOL_TIMEOUT;
return;
}
if (skill.isTool(e.getPlayer().getInventory().getItem(e.getNewSlot()))) {
this.isWrongTool = false;
return;
}
}
示例5: onItemSwitch
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onItemSwitch(PlayerItemHeldEvent e) {
if (canChangeItems) {
return;
}
if (!player.getPlayer().isOnline()) {
return;
}
if (!e.getPlayer().getUniqueId().equals(player.getPlayer().getUniqueId())) {
return;
}
if (!(QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds()
.contains(e.getPlayer().getWorld().getName()))) {
return;
}
//not allowed to switch weapons, cheater!
doneCasting();
e.getPlayer().sendMessage(DISTURBED_MESSAGE);
}
示例6: a
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
// CraftBukkit start
if (this.player.dead) return;
if (packetplayinhelditemslot.c() >= 0 && packetplayinhelditemslot.c() < PlayerInventory.getHotbarSize()) {
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.c());
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
this.player.v();
return;
}
// CraftBukkit end
this.player.inventory.itemInHandIndex = packetplayinhelditemslot.c();
this.player.v();
} else {
c.warn(this.player.getName() + " tried to set an invalid carried item");
this.disconnect("Nope!"); // CraftBukkit
}
}
示例7: onMapHold
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
/**
* Make sure all player held maps have triangle overlays. (todo: make sure all maps on item frames do as well)
* There seem to be some bugs around this. It doesn't always take on the first try.
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled=true)
public void onMapHold(final PlayerItemHeldEvent event) {
Player player = event.getPlayer();
ItemStack itemInHand = player.getInventory().getItem(event.getNewSlot());
if (itemInHand == null) return;
if (!Material.MAP.equals(itemInHand.getType())) {
return;
}
if (!player.getWorld().equals(getBeaconzWorld())) {
return;
}
@SuppressWarnings("deprecation")
MapView map = Bukkit.getMap(itemInHand.getDurability());
for (MapRenderer renderer : map.getRenderers()) {
if (renderer instanceof TerritoryMapRenderer) {
return;
}
}
map.addRenderer(new TerritoryMapRenderer(getBeaconzPlugin()));
}
示例8: onItemHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemHeld(PlayerItemHeldEvent event) {
if (event.isCancelled()) {
return;
}
ItemStack stack = event.getPlayer().getItemInHand();
if (stack == null) {
return;
}
LoreMaterial material = LoreMaterial.getMaterial(stack);
if (material != null) {
material.onHold(event);
}
}
示例9: a
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
// CraftBukkit start
if (this.player.dead) return;
if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex < PlayerInventory.getHotbarSize()) {
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex);
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
this.sendPacket(new Packet16BlockItemSwitch(this.player.inventory.itemInHandIndex));
this.player.u();
return;
}
// CraftBukkit end
this.player.inventory.itemInHandIndex = packet16blockitemswitch.itemInHandIndex;
this.player.u();
} else {
this.minecraftServer.getLogger().warning(this.player.getName() + " tried to set an invalid carried item");
this.disconnect("Nope!"); // CraftBukkit
}
}
示例10: a
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
// CraftBukkit start
if (this.player.dead) return;
if (packetplayinhelditemslot.c() >= 0 && packetplayinhelditemslot.c() < PlayerInventory.getHotbarSize()) {
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.c());
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
this.player.v();
return;
}
// CraftBukkit end
this.player.inventory.itemInHandIndex = packetplayinhelditemslot.c();
this.player.v();
} else {
c.warn(this.player.getName() + " tried to set an invalid carried item");
this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit //Spigot "Nope" -> Descriptive reason
}
}
示例11: onItemHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@Override
public void onItemHeld(PlayerItemHeldEvent event) {
int delta = event.getNewSlot() - event.getPreviousSlot();
if (delta == 0) {
return;
} else if (delta >= 6) {
delta -= 9;
} else if (delta <= -6) {
delta += 9;
}
delta = (delta > 0) ? 1 : -1;
int o = getMode().ordinal() + delta;
if (o < 0) {
o = Mode.values().length - 1;
} else if (o >= Mode.values().length) {
o = 0;
}
setMode(Mode.values()[o]);
event.getPlayer().setItemInHand(toItemStack());
}
示例12: a
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x());
if (this.player.dead) return; // CraftBukkit
if (packetplayinhelditemslot.a() >= 0 && packetplayinhelditemslot.a() < PlayerInventory.getHotbarSize()) {
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.a());
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
this.player.resetIdleTimer();
return;
}
// CraftBukkit end
this.player.inventory.itemInHandIndex = packetplayinhelditemslot.a();
this.player.resetIdleTimer();
} else {
PlayerConnection.LOGGER.warn(this.player.getName() + " tried to set an invalid carried item");
this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit //Spigot "Nope" -> Descriptive reason
}
}
示例13: a
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
// CraftBukkit start
if (this.player.dead) return;
if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex < PlayerInventory.getHotbarSize()) {
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex);
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
this.sendPacket(new Packet16BlockItemSwitch(this.player.inventory.itemInHandIndex));
return;
}
// CraftBukkit end
this.player.inventory.itemInHandIndex = packet16blockitemswitch.itemInHandIndex;
} else {
this.minecraftServer.getLogger().warning(this.player.name + " tried to set an invalid carried item");
this.disconnect("Nope!"); // CraftBukkit
}
}
示例14: onItemHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
void onItemHeld(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE) return;
ItemStack newItemInHand = player.getInventory().getItem(event.getNewSlot());
if (!Settings.isShopCreationItem(newItemInHand)) {
return;
}
if (!ShopkeepersPlugin.getInstance().hasCreatePermission(player)) {
// player cannot create any shopkeeper at all
return;
}
// print info message about usage:
Utils.sendMessage(player, Settings.msgCreationItemSelected);
}
示例15: onEditBook
import org.bukkit.event.player.PlayerItemHeldEvent; //导入依赖的package包/类
@EventHandler
public void onEditBook(PlayerItemHeldEvent event){
//Get player and the action
Player player = event.getPlayer();
EpicPlayer epicPlayer = EpicSystem.getEpicPlayer(player.getUniqueId());
ItemStack inHand = player.getInventory().getItem(event.getNewSlot());
if(inHand != null && inHand.getType() == Material.WRITTEN_BOOK){
BookMeta book = (BookMeta)inHand.getItemMeta();
if(book.hasTitle() && book.getTitle().equalsIgnoreCase("Quest Book")){
//Open zeh quest book!
inHand.setItemMeta(SetQuestBookPages(epicPlayer, book));
}
}
}