本文整理匯總了Java中org.bukkit.event.player.PlayerDropItemEvent.getPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerDropItemEvent.getPlayer方法的具體用法?Java PlayerDropItemEvent.getPlayer怎麽用?Java PlayerDropItemEvent.getPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.player.PlayerDropItemEvent
的用法示例。
在下文中一共展示了PlayerDropItemEvent.getPlayer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
}
示例2: 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);
}
}
}
}
示例3: 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;
}
}
示例4: 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);
}
示例5: 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();
}
}
}
}
示例6: 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()));
}
示例7: 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!");
}
}
}
示例8: 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);
}
示例9: onDrop
import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onDrop(PlayerDropItemEvent event) {
Player p = event.getPlayer();
Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p);
if (g == null) {
return;
}
if (g.getState() == GameState.RUNNING
&& event.getItemDrop().getItemStack().getItemMeta().getDisplayName() != null
&& event.getItemDrop().getItemStack().getItemMeta().getDisplayName()
.equals(BedwarsRel._l("ingame.specials.warp-powder.cancel"))) {
event.setCancelled(true);
}
}
示例10: onDropEvent
import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onDropEvent(PlayerDropItemEvent event) {
if (event.isCancelled() || event.getPlayer() == null) {
return;
}
Player player = event.getPlayer();
if (!plugin.isSkyWorld(player.getWorld())) {
return;
}
if (!visitorsCanDrop && !plugin.playerIsOnIsland(player) && !plugin.playerIsInSpawn(player)) {
event.setCancelled(true);
plugin.notifyPlayer(player, tr("\u00a7eVisitors can't drop items!"));
return;
}
addDropInfo(player, event.getItemDrop().getItemStack());
}
示例11: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
/**
* On player drop item.
*
* @param event
* the event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) {
Player player = event.getPlayer();
IPlayerConfEntry entry = playerConf.get(player);
if (entry != null && !entry.isAdminMod()) {
IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(
player.getLocation());
if (!checkPermission(land, event.getPlayer(),
PermissionList.DROP.getPermissionType())) {
messagePermission(player);
event.setCancelled(true);
}
}
}
示例12: DropItem
import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
/**
* Checks if player has proper permission to drop items.
*
* @param event that triggers listener.
*/
@EventHandler(priority = EventPriority.LOW)
private void DropItem(PlayerDropItemEvent event) {
Player player = event.getPlayer();
// Drop item check.
if (player != null && !player.hasPermission("antibuild.bypass")) {
if (!player.hasPermission("antibuild.dropitems")) {
event.setCancelled(true);
PlayerMessenger.messageHandler(plugin.getConfigHandler().getNoDropItemsMessage(), player);
}
}
// // World Check
// if (!event.isCancelled() && plugin.isUsingLock()) {
// if (plugin.isLockedWorld(player.getWorld().getName())
// && !player.hasPermission("antibuild.lock.bypass") && !player.hasPermission("antibuild.lock
// .bypass" +
// "." + player.getWorld().getName())) {
// event.setCancelled(true);
// messageHandler(plugin.getLockedWorldMessage(), player);
// }
// }
}
示例13: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event)
{
Player pl = event.getPlayer();
if (pl != null)
{
if (plugin.isInArena(pl))
{
if (plugin.getArena(pl).type.equals("Hunger"))
{
event.setCancelled(false);
}
else
{
event.setCancelled(true);
}
}
}
}
示例14: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerDropItem(final PlayerDropItemEvent event)
{
final Player user = event.getPlayer();
final ItemStack item = event.getItemDrop().getItemStack();
if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user))
{
return;
}
{
if (!Permissions.DROP.isAuthorized(user, item.getType(), item.getData()))
{
event.setCancelled(true);
user.getPlayer().updateInventory();
if (antib.getSettings().getData().isWarnOnBuildDisallow())
{
user.sendMessage(_("§4You are not permitted to drop§c {0}§4.", item.getType().toString()));
}
}
}
}
示例15: onDrop
import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onDrop(PlayerDropItemEvent evt) {
if(ConfigPatch.fixDupeDropItem){
Player player = evt.getPlayer();
if (AzurePlayerList.contains(player) && player.isDead()) evt.setCancelled(true);
}
}