本文整理汇总了Java中org.bukkit.event.player.PlayerItemHeldEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerItemHeldEvent.isCancelled方法的具体用法?Java PlayerItemHeldEvent.isCancelled怎么用?Java PlayerItemHeldEvent.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerItemHeldEvent
的用法示例。
在下文中一共展示了PlayerItemHeldEvent.isCancelled方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
}
}
示例2: 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);
}
}
示例3: 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
}
}
示例4: 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
}
}
示例5: 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
}
}
示例6: 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
}
}
示例7: onHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler
public void onHeld(PlayerItemHeldEvent e) {
if (e.isCancelled()) {
return;
}
if (!Utils.isInArena(e.getPlayer())) {
return;
}
if (e.getNewSlot() == 0) {
return;
}
if (e.getNewSlot() >= 2 && e.getNewSlot() <= 4) {
int slot = e.getNewSlot();
Player p = e.getPlayer();
PlayerInventory inv = p.getInventory();
ItemStack item = inv.getItem(slot).clone();
item.setAmount(1);
if (SkillManager.getInstance().isSkillSelector(item)) {
Skill skill = SkillManager.getInstance().getSkillBySelector(item);
if(skill.getSkillType().equals(SkillType.ITEM)){
inv.setItem(0, skill.getShow());
}
else{
Class<?> skillClazz=skill.getClass();
try {
Method method =skillClazz.getMethod("doUpgrade",Player.class);
if(method!=null){
method.invoke(SkillManager.getInstance().getSkillByName(skill.getName()),p);
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
inv.setItem(2, ItemManager.getForbidden(3));
inv.setItem(3, ItemManager.getForbidden(4));
inv.setItem(4, ItemManager.getForbidden(5));
}
}
e.setCancelled(true);
}
示例8: processHeldItemChange
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
public void processHeldItemChange(C09PacketHeldItemChange p_147355_1_)
{
// CraftBukkit start
if (this.playerEntity.isDead)
{
return;
}
if (p_147355_1_.func_149614_c() >= 0 && p_147355_1_.func_149614_c() < InventoryPlayer.getHotbarSize())
{
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayerB(), this.playerEntity.inventory.currentItem, p_147355_1_.func_149614_c());
this.server.getPluginManager().callEvent(event);
if (event.isCancelled())
{
this.sendPacket(new S09PacketHeldItemChange(this.playerEntity.inventory.currentItem));
this.playerEntity.func_143004_u();
return;
}
// CraftBukkit end
this.playerEntity.inventory.currentItem = p_147355_1_.func_149614_c();
this.playerEntity.func_143004_u();
}
else
{
logger.warn(this.playerEntity.getCommandSenderName() + " tried to set an invalid carried item");
this.kickPlayerFromServer("Nope!"); // CraftBukkit
}
}