本文整理匯總了Java中org.bukkit.event.player.PlayerPickupItemEvent類的典型用法代碼示例。如果您正苦於以下問題:Java PlayerPickupItemEvent類的具體用法?Java PlayerPickupItemEvent怎麽用?Java PlayerPickupItemEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PlayerPickupItemEvent類屬於org.bukkit.event.player包,在下文中一共展示了PlayerPickupItemEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPlayerPickupItem
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
private void onPlayerPickupItem(PlayerPickupItemEvent event)
{
if (event.getItem().getItemStack() != null && event.getItem().getItemStack().getItemMeta() != null && event.getItem().getItemStack().getItemMeta().getDisplayName() != null)
{
if (this.alive && event.getItem().getItemStack().getItemMeta().getDisplayName().equals(this.uuid.toString()))
{
event.setCancelled(true);
HandlerList.unregisterAll(this);
this.remove(true);
this.parent.onPickup(event.getPlayer());
}
}
}
示例2: onPickUp
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
public void onPickUp(PlayerPickupItemEvent e) {
Player p = e.getPlayer();
if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.Disable")) {
if (!ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.World.All_World")) {
if (WorldUtils.getWItemPickUp().contains(p.getWorld().getName())) {
if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.Bypass")) {
if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.pickup")) {
e.setCancelled(true);
}
} else {
e.setCancelled(true);
}
}
} else {
if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.Bypass")) {
if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.pickup")) {
e.setCancelled(true);
}
} else {
e.setCancelled(true);
}
}
}
}
示例3: onPickupToQuickSlot
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onPickupToQuickSlot(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player) || !ItemManager.allowedForPlayer(player, event.getItem().getItemStack(), false)) {
return;
}
for (Slot quickSlot : SlotManager.instance().getQuickSlots()) {
int slotId = quickSlot.getQuickSlot();
if (quickSlot.isCup(player.getInventory().getItem(slotId)) && quickSlot.isValidItem(event.getItem().getItemStack())) {
player.getInventory().setItem(slotId, event.getItem().getItemStack());
event.getItem().remove();
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, .3f, 1.7f);
if (Config.getConfig().getBoolean("attack.auto-held")) {
player.getInventory().setHeldItemSlot(quickSlot.getQuickSlot());
}
event.setCancelled(true);
}
}
}
示例4: onBlockPickup
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
public void onBlockPickup(PlayerPickupItemEvent event) {
if (event.getItem().getItemStack().getType() == material && event.getItem().getItemStack().getData().getData() == data) {
if(this.touches.contains(event.getPlayer().getUniqueId())) return;
TeamModule teamModule = TeamManager.getTeamByPlayer(event.getPlayer());
if (teamModule == null) return;
if(super.isCompletedBy(teamModule)) return;
if (teamModule.getObjectives().contains(this)) {
this.touches.add(event.getPlayer().getUniqueId());
for (ScoreboardModule scoreboardModule : GameHandler.getGameHandler().getMatch().getModules().getModules(ScoreboardModule.class)) {
scoreboardModule.refresh(this);
}
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(teamModule.getColor() + new LocalizedChatMessage(ChatConstant.GAME_CAPTURABLE_TOUCHED, event.getPlayer().getName() + ChatColor.DARK_AQUA, ChatColor.AQUA + super.getName() + ChatColor.DARK_AQUA, teamModule.getColor() + teamModule.getName() + ChatColor.DARK_AQUA).getMessage(player.spigot().getLocale()));
}
}
}
}
示例5: onPlayerPickupItem
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
void onPlayerPickupItem(PlayerPickupItemEvent event)
{
Player player = event.getPlayer();
if(!player.isSneaking() && PhantomAdmin.instance.isInvisible(player))
{
event.setCancelled(true);
PlayerData data = PlayerData.FromPlayer(player);
if(!data.gotItemPickupInfo)
{
PhantomAdmin.sendMessage(player, TextMode.Warn, Messages.NoItemPickupWhileInvisible);
data.gotItemPickupInfo = true;
}
return;
}
}
示例6: onItemPickup
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
public void onItemPickup(PlayerPickupItemEvent event)
{
System.out.println("Item pickup");
Item item = event.getItem();
ItemStack stack = item.getItemStack();
Location location = item.getLocation();
Player player = event.getPlayer();
String playerName = player == null ? "null" : player.getName();
PickupItemObsel obsel = new PickupItemObsel(
new Date().getTime(),
stack.getType().toString(),
stack.getAmount(),
stack.getData().getData(),
location.getBlockX(),
location.getBlockY(),
location.getBlockZ(),
location.getWorld().getName(),
playerName);
JSONObselManager.getInstance().addObsel(obsel);
}
示例7: onPickupItem
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPickupItem(PlayerPickupItemEvent event)
{
Player player = event.getPlayer();
if(featureEnabled(Features.SortInventory, player))
{
PlayerData playerData = PlayerData.FromPlayer(player);
if(playerData.firstEmptySlot >= 0) return;
PlayerInventory inventory = player.getInventory();
int firstEmpty = inventory.firstEmpty();
if(firstEmpty < 9) return;
playerData.firstEmptySlot = firstEmpty;
PickupSortTask task = new PickupSortTask(player, playerData, inventory);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AutomaticInventory.instance, task, 100L);
}
}
示例8: onItemPickup
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
if (e.isCancelled()) {
return;
}
ItemStack item = e.getItem().getItemStack();
if (item.getType().equals(Material.WRITTEN_BOOK)) {
BookMeta meta = (BookMeta) item.getItemMeta();
if (meta.getTitle().equals("Quest Log")) {
e.getItem().remove();
e.setCancelled(true);
QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(
e.getPlayer().getUniqueId()).addQuestBook();
}
}
}
示例9: onInventoryChange
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryChange(PlayerPickupItemEvent e) {
if (this.participants == null) {
return;
}
if (state) {
return;
}
if (!e.isCancelled() && e.getItem().getItemStack().getType() == itemType) {
for (QuestPlayer qp : participants.getParticipants()) {
if (qp.getPlayer().getUniqueId().equals(e.getPlayer().getUniqueId())) {
final Requirement req = this;
Bukkit.getScheduler().runTaskLater(QuestManagerPlugin.questManagerPlugin, req::update, 1);
}
}
}
}
示例10: onPlayerPickUp
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerPickUp(final PlayerPickupItemEvent event) {
final PlayerStat stat = PlayerStat.ITEMS_PICKED_UP;
// Get player
final Player player = event.getPlayer();
// Do general check
if (!plugin.doGeneralCheck(player, stat))
return;
// Update value to new stat.
plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid",
player.getUniqueId().toString(), "value", event.getItem().getItemStack().getAmount(), "world", player.getWorld().getName(), "item", event.getItem().getItemStack().getType().toString()));
}
示例11: d
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@Override
public void d(final EntityHuman entityhuman) {
if (!this.world.isClientSide && this.inGround && (this.shake <= 0)) {
boolean pickup = (this.fromPlayer == 1) || ((this.fromPlayer == 2) && entityhuman.abilities.canInstantlyBuild);
ItemStack itemstack = this.getItemStack();
if ((this.fromPlayer == 1) && !entityhuman.inventory.pickup(itemstack)) {
pickup = false;
}
final EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
final PlayerPickupItemEvent event = new PlayerPickupItemEvent((Player) entityhuman.getBukkitEntity(), new CraftItem(this.world.getServer(), this, item), 0);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
if (pickup) {
this.makeSound("random.pop", 0.2F, (((this.random.nextFloat() - this.random.nextFloat()) * 0.7F) + 1.0F) * 2.0F);
entityhuman.receive(this, 1);
this.die();
}
}
}
示例12: onPickup
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
public void onPickup(PlayerPickupItemEvent ppie) {
Player player = ppie.getPlayer();
Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player);
if (game == null) {
game = BedwarsRel.getInstance().getGameManager().getGameByLocation(player.getLocation());
if (game == null) {
return;
}
}
if (game.getState() != GameState.WAITING && game.isInGame(player)) {
return;
}
ppie.setCancelled(true);
}
示例13: onPickup
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
public void onPickup(PlayerPickupItemEvent e){
Item item = e.getItem();
if(item.getCustomName()!=null) {
String name = ChatColor.stripColor(item.getCustomName());
// if(name!=null && ChatColor.stripColor(language.get("nameSyntax")).replace("{money}", "").equals(name.replaceAll(regex, ""))){
e.setCancelled(true);
String money = plugin.getMoney(name);
Player p = e.getPlayer();
if (p.hasPermission("PickupMoney.pickup")) {
item.remove();
float amount = Float.parseFloat(money);
if(plugin.pickupMulti.containsKey(p.getUniqueId())) amount*=plugin.pickupMulti.get(p.getUniqueId());
plugin.giveMoney(amount, p);
p.sendMessage(plugin.language.get("pickup").replace("{money}", String.valueOf(amount)));
if (plugin.fc.getBoolean("sound.enable")) {
p.getLocation().getWorld().playSound(p.getLocation(), Sound.valueOf(plugin.fc.getString("sound.type"))
, (float) plugin.fc.getDouble("sound.volumn")
, (float) plugin.fc.getDouble("sound.pitch"));
}
}
// }
}
}
示例14: onPlayerPickup
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerPickup(PlayerPickupItemEvent event) {
String name;
boolean rare = false;
if (event.getItem().getItemStack().getItemMeta().hasDisplayName()) {
name = event.getItem().getItemStack().getItemMeta().getDisplayName();
rare = true;
} else {
name = event.getItem().getItemStack().getType().name().replace("_", " ").toLowerCase();
}
Resident resident = CivGlobal.getResident(event.getPlayer());
if (resident.getItemMode().equals("all")) {
CivMessage.send(event.getPlayer(), CivColor.LightGreen+"You've picked up "+CivColor.LightPurple+event.getItem().getItemStack().getAmount()+" "+name);
} else if (resident.getItemMode().equals("rare") && rare) {
CivMessage.send(event.getPlayer(), CivColor.LightGreen+"You've picked up "+CivColor.LightPurple+event.getItem().getItemStack().getAmount()+" "+name);
}
}
示例15: OnPlayerPickupItem
import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void OnPlayerPickupItem(PlayerPickupItemEvent event) {
BonusGoodie goodie = CivGlobal.getBonusGoodie(event.getItem().getItemStack());
if (goodie == null) {
return;
}
try {
goodie.setHolder(event.getPlayer());
goodie.update(false);
goodie.updateLore(event.getItem().getItemStack());
} catch (CivException e) {
e.printStackTrace();
}
}