当前位置: 首页>>代码示例>>Java>>正文


Java DestructEntityEvent.getTargetEntity方法代码示例

本文整理汇总了Java中org.spongepowered.api.event.entity.DestructEntityEvent.getTargetEntity方法的典型用法代码示例。如果您正苦于以下问题:Java DestructEntityEvent.getTargetEntity方法的具体用法?Java DestructEntityEvent.getTargetEntity怎么用?Java DestructEntityEvent.getTargetEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.event.entity.DestructEntityEvent的用法示例。


在下文中一共展示了DestructEntityEvent.getTargetEntity方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPaintingBreakEvent

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.EARLY)
public void onPaintingBreakEvent(DestructEntityEvent event)
{
    if (!(event.getTargetEntity() instanceof Painting))
    {
        return;
    }

    Painting painting = (Painting)event.getTargetEntity();

    Iterator<Entry<UUID, Painting>> paintingIterator = this.paintingChange.entrySet().iterator();
    while(paintingIterator.hasNext())
    {
        Entry<UUID, Painting> entry = paintingIterator.next();
        if(entry.getValue().equals(painting))
        {
            Optional<Player> player = Sponge.getServer().getPlayer(entry.getKey());
            if (player.isPresent())
            {
                i18n.send(player.get(), NEGATIVE, "The painting broke");
            }
            paintingIterator.remove();
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:26,代码来源:PaintingListener.java

示例2: onEntityDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityDeath(DestructEntityEvent event, @First EntityDamageSource source) // Cleanup Locks in case Entity dies
{
    Entity target = event.getTargetEntity();
    Lock lock = this.manager.getLockForEntityUID(target.getUniqueId());
    if (lock == null) return;
    Player player;
    if (source.getSource() instanceof Player)
    {
        player = ((Player)source.getSource());
    }
    else if (source instanceof IndirectEntityDamageSource && ((IndirectEntityDamageSource)source).getIndirectSource() instanceof Player)
    {
        player = ((Player)((IndirectEntityDamageSource)source).getIndirectSource());
    }
    else
    {
        return;
    }
    lock.handleEntityDeletion(player); // Delete Lock and notify user that destroyed Lock
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:22,代码来源:LockerListener.java

示例3: onEntityDespawn

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onEntityDespawn(DestructEntityEvent event) {
    cacheService.removeEntity(event.getTargetEntity().getUniqueId());

    Entity ent = event.getTargetEntity();
    if (ent instanceof Player) {
        webHookService.notifyHooks(WebHookService.WebHookType.PLAYER_DEATH, event);
    }
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:10,代码来源:WebAPI.java

示例4: onEntityDestruct

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityDestruct(DestructEntityEvent event) {
    Entity entity = event.getTargetEntity();
    CustomWorld world = WorldManager.toCustomWorld(entity.getWorld());
    EntityTracker tracker = world.getEntityTracker(event.getTargetEntity());
    if (tracker == null) {
        return;
    }
    tracker.onEntityRemoved(event.getTargetEntity());
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:11,代码来源:EntityEventListeners.java

示例5: onPlayerDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerDeath(DestructEntityEvent event)
{
	if (event.getTargetEntity() instanceof Player)
	{
		Player died = (Player) event.getTargetEntity();

		Utils.savePlayerInventory(died, died.getWorld().getUniqueId());
		Utils.setLastTeleportOrDeathLocation(died.getUniqueId(), died.getLocation());
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:12,代码来源:PlayerDeathListener.java

示例6: onDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入方法依赖的package包/类
@Listener
public void onDeath(DestructEntityEvent event){
	if (event.getTargetEntity() instanceof Player){
		Player p = (Player) event.getTargetEntity();
		if (p.getName().equals(this.player.getName())){
			close();
		}
	}		
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:10,代码来源:RPGui.java

示例7: onDestructEntityEvent

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入方法依赖的package包/类
@Listener
public void onDestructEntityEvent(DestructEntityEvent event) {
    if (event.getTargetEntity() instanceof Player) {
        final Player player = (Player) event.getTargetEntity();
        if (!player.hasPermission("backpack." + player.getWorld().getName().toLowerCase() + ".death.bypass")) {
            final Optional<BackpackInventory> optBackpack = BackpackFactory.get(player.getWorld(), player);
            if (optBackpack.isPresent()) {
                for (int i = 0; i < optBackpack.get().getSizeInventory(); i++) {
                    ((EntityPlayerMP) player).dropItem(optBackpack.get().getStackInSlot(i), true, true);
                    optBackpack.get().setInventorySlotContents(i, null);
                }
            }
        }
    }
}
 
开发者ID:AlmuraDev,项目名称:Backpack,代码行数:16,代码来源:Backpack.java

示例8: onDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入方法依赖的package包/类
@Listener
public void onDeath(DestructEntityEvent event)
{
    if (!(event.getTargetEntity() instanceof Player))
    {
        return;
    }
    if (((Player)event.getTargetEntity()).hasPermission(module.perms().COMMAND_BACK_ONDEATH.getId()))
    {
        deathLocations.put(event.getTargetEntity().getUniqueId(), event.getTargetEntity().getTransform());
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:13,代码来源:TeleportListener.java

示例9: onDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入方法依赖的package包/类
@Listener
public void onDeath(DestructEntityEvent event) {
    if (!(event.getTargetEntity() instanceof Player)) {
        return;
    }
    Player p = (Player) event.getTargetEntity();

    //Get the translation, because for some reason sponge hides it in a lot of children
    Text orgmessage = event.getOriginalMessage();
    while (!(orgmessage instanceof TranslatableText) && !orgmessage.getChildren().isEmpty()) {
        for (Text child : orgmessage.getChildren()) {
            if (child instanceof TranslatableText) {
                break;
            }
        }
        orgmessage = orgmessage.getChildren().get(0); //Safe because of while loop
    }

    if (orgmessage instanceof TranslatableText) {
        //Id
        TranslatableText org = (TranslatableText) orgmessage;
        String id_mc = org.getTranslation().getId();
        if (!id_mc.startsWith("death.")) {
            return;
        }
        String id_uc = id_mc.toLowerCase().replaceFirst("death\\.", "deathmessage.message.");

        //Item
        ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND).orElse(ItemStack.of(ItemTypes.NONE, 1));
        Text item = stack.get(Keys.DISPLAY_NAME).orElse(Text.of(stack.getTranslation().get()));

        //Final message //TODO hover
        Text message = Messages.getFormatted(id_uc, "%player%", VariableUtil.getNameSource(p), "%item%", item);

        //Custom args
        int i = 1;
        for (Object ob : org.getArguments()) {
            message = TextUtil.replace(message, "%arg" + i + "%", ob instanceof Text ? ((Text) ob) : Text.of(ob.toString()));
            i++;
        }

        event.setMessage(message);
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:45,代码来源:DeathmessageListener.java


注:本文中的org.spongepowered.api.event.entity.DestructEntityEvent.getTargetEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。