本文整理汇总了Java中org.bukkit.event.player.PlayerDropItemEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerDropItemEvent类的具体用法?Java PlayerDropItemEvent怎么用?Java PlayerDropItemEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerDropItemEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerDropItemEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onVisitorDrop
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVisitorDrop(final PlayerDropItemEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!Util.inWorld(e.getPlayer())) {
return;
}
Island island = plugin.getIslands().getIslandAt(e.getItemDrop().getLocation());
if ((island != null && island.getFlag(SettingsFlag.ITEM_DROP))
|| e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
|| plugin.getIslands().locationIsOnIsland(e.getPlayer(), e.getItemDrop().getLocation())) {
return;
}
Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
e.setCancelled(true);
}
示例2: onCraft
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler
public void onCraft(PlayerDropItemEvent e) {
//e.getPlayer().sendMessage(e.getItemDrop().getItemStack().toString());
/*for (CustomCraftingRecipe r : recipes) {
//if (r.ncon.equals("ground")) {
ArrayList<Item> items = new ArrayList<Item>();
items.add(e.getItemDrop());
for (Entity it : e.getItemDrop().getNearbyEntities(5, 5, 5)) {
if (it instanceof Item) {
items.add((Item) it);
}
}
e.getPlayer().sendMessage(String.valueOf(items.size()));
//}
}*/
}
示例3: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
if(this.ignoreNextDropEvent) {
this.ignoreNextDropEvent = false;
} else {
// If the ignore flag is clear, this drop was caused by something other than
// an inventory click (e.g. drop key, death, etc), so an event has not yet been fired
int initialQuantity = event.getItemDrop().getItemStack().getAmount();
ItemStack stack = event.getItemDrop().getItemStack();
PlayerItemTransferEvent transferEvent = new PlayerItemTransferEvent(event, ItemTransferEvent.Type.DROP, event.getPlayer(),
Optional.of(new InventorySlot(event.getPlayer().getInventory())),
Optional.empty(),
stack, event.getItemDrop(), initialQuantity,
event.getPlayer().getOpenInventory().getCursor());
this.callEvent(transferEvent);
if(!transferEvent.isCancelled() && transferEvent.getQuantity() < initialQuantity) {
int diff = initialQuantity - transferEvent.getQuantity();
stack.setAmount(stack.getAmount() - diff);
stack = stack.clone();
stack.setAmount(diff);
event.getPlayer().getInventory().addItem(stack);
}
}
}
示例4: on
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler
public void on(PlayerDropItemEvent event) {
ItemStack item = event.getItemDrop().getItemStack();
if (item == null) {
return;
}
if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
return;
}
String name = item.getItemMeta().getDisplayName();
if (name.equals("§4§lBlocked Slot")) {
event.setCancelled(true);
}
}
示例5: onDrop
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler
public void onDrop(PlayerDropItemEvent e) {
Player p = e.getPlayer();
if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Drop.Disable")) {
if (!ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Drop.World.All_World")) {
if (WorldUtils.getWItemDrop().contains(p.getWorld().getName())) {
if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Drop.Bypass")) {
if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.drop")) {
e.setCancelled(true);
}
} else {
e.setCancelled(true);
}
}
} else {
if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Drop.Bypass")) {
if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.drop")) {
e.setCancelled(true);
}
} else {
e.setCancelled(true);
}
}
}
}
示例6: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
void onPlayerDropItem(PlayerDropItemEvent event)
{
Player player = event.getPlayer();
if(!player.isSneaking() && PhantomAdmin.instance.isInvisible(player))
{
event.setCancelled(true);
PlayerData data = PlayerData.FromPlayer(player);
if(!data.gotItemDropInfo)
{
PhantomAdmin.sendMessage(player, TextMode.Warn, Messages.NoItemDropWhileInvisible);
data.gotItemDropInfo = true;
}
return;
}
}
示例7: onItemDrop
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler
public void onItemDrop(PlayerDropItemEvent event)
{
System.out.println("Item drop");
Item item = event.getItemDrop();
ItemStack stack = item.getItemStack();
Location location = item.getLocation();
Player player = event.getPlayer();
String playerName = player == null ? "null" : player.getName();
DropItemObsel obsel = new DropItemObsel(
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);
}
示例8: StopDrops
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
public void StopDrops(PlayerDropItemEvent event)
{
Player player = event.getPlayer();
Item item = event.getItemDrop();
if(item != null)
{
ItemStack stack = item.getItemStack();
if(stack != null)
{
if(KitUtils.isSoulbound(stack))
{
player.playSound(player.getLocation(), Sound.BLAZE_HIT, 1.0F, 0.3F);
event.getItemDrop().remove();
}
}
}
}
示例9: load
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
public static void load(CSCoreLib plugin) {
if (ReflectionUtils.getVersion().startsWith("v1_9_")) {
plugin.getServer().getPluginManager().registerEvents(new CustomBookOverlay1_9(), plugin);
}
else if (ReflectionUtils.getVersion().startsWith("v1_10_")) {
plugin.getServer().getPluginManager().registerEvents(new CustomBookOverlay1_9(), plugin);
}
else if (ReflectionUtils.getVersion().startsWith("v1_11_")) {
plugin.getServer().getPluginManager().registerEvents(new CustomBookOverlay1_9(), plugin);
}
else if (ReflectionUtils.getVersion().startsWith("v1_12_")) {
plugin.getServer().getPluginManager().registerEvents(new CustomBookOverlay1_9(), plugin);
}
plugin.getServer().getPluginManager().registerEvents(new Listener() {
@EventHandler
public void onDrop(PlayerDropItemEvent e) {
if (opening.contains(e.getPlayer().getUniqueId())) e.setCancelled(true);
}
}, plugin);
}
示例10: onInventoryChange
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryChange(PlayerDropItemEvent e) {
if (this.participants == null) {
return;
}
if (state) {
return;
}
if (!e.isCancelled() && e.getItemDrop().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);
}
}
}
}
示例11: onPlayerDrop
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDrop(final PlayerDropItemEvent event) {
final PlayerStat stat = PlayerStat.ITEMS_DROPPED;
// 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.getItemDrop().getItemStack().getAmount(), "world", player.getWorld().getName(), "item", event.getItemDrop().getItemStack().getType().toString()));
}
示例12: coinCheck
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
public void coinCheck(PlayerDropItemEvent event){
int LocationX = event.getItemDrop().getLocation().getBlockX();
if (coinDropper.equalsIgnoreCase(event.getPlayer().getDisplayName()) && (LocationX == coinLocationX)){
Location pitDropModifier = new Location(worldPit,pit.getBlockX(),pit.getBlockY()+3,pit.getBlockZ());
Location Fireworks = new Location(worldPit,pit.getBlockX(),pit.getBlockY()+6,pit.getBlockZ());
ItemStack Diamonds = new ItemStack(Material.DIAMOND);
Diamonds.setAmount(40);
int RandomProbability = (int)(Math.random()*100);
if (RandomProbability<50){
event.getPlayer().sendMessage("§6"+LuckyBlocksMainController.instance.language.getString("LUCKY_THIS_TIME"));
worldPit.dropItemNaturally(pitDropModifier,Diamonds);
for (int i=0;i<5;i++) homeFireworks(Fireworks,worldPit);}
else{
TNTPrimed TNT = (TNTPrimed) event.getPlayer().getWorld().spawnEntity(pitDropModifier,EntityType.PRIMED_TNT);
TNT.setYield(50);
TNT.setFuseTicks(10);
}
event.getItemDrop().remove();
}
else{
event.getPlayer().sendMessage(LuckyBlocksMainController.instance.language.getString("DROP_IT_CLOSER"));
}
}
示例13: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDropItem(PlayerDropItemEvent event) {
if (!event.isCancelled() && TeamUtils.getTeamByPlayer(event.getPlayer()) != null && event.getItemDrop().getItemStack().getType().equals(Material.WOOL)) {
for (TeamModule team : TeamUtils.getTeams()) {
if (!team.isObserver() && TeamUtils.getTeamByPlayer(event.getPlayer()) != team) {
for (GameObjective obj : TeamUtils.getShownObjectives(team)) {
if (obj instanceof WoolObjective && event.getItemDrop().getItemStack().getData().getData() == ((WoolObjective) obj).getColor().getData()) {
if (!items.containsKey(event.getPlayer())) {
items.put(event.getPlayer(), new ArrayList<Item>());
}
List<Item> list = items.get(event.getPlayer());
list.add(event.getItemDrop());
items.put(event.getPlayer(), list);
}
}
}
}
}
}
示例14: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent e) {
Player p = e.getPlayer();
if (e.getItemDrop().getItemStack().getItemMeta().hasLore()) {
if (e.getItemDrop().getItemStack().getItemMeta().getLore().get(0)
.equals("Fury")
|| e.getItemDrop().getItemStack().getItemMeta().getLore()
.get(0).equals("Sheild")
|| e.getItemDrop().getItemStack().getItemMeta().getLore()
.get(0).equals("Sprint")
|| e.getItemDrop().getItemStack().getItemMeta().getLore()
.get(0).equals("Regen")) {
e.setCancelled(true);
p.sendMessage(ChatColor.DARK_RED + "You can't drop this item!");
}
}
}
示例15: onDrop
import org.bukkit.event.player.PlayerDropItemEvent; //导入依赖的package包/类
@EventHandler
public void onDrop(PlayerDropItemEvent die) {
Player p = die.getPlayer();
Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p);
if (g == null) {
return;
}
if (g.getState() != GameState.WAITING) {
if (g.isSpectator(p)) {
die.setCancelled(true);
}
return;
}
die.setCancelled(true);
}