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


Java DestructEntityEvent类代码示例

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


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

示例1: onPlayerDeath

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

        PowerService.decreasePower(player.getUniqueId());

        player.sendMessage(Text.of(PluginInfo.PluginPrefix, "Your power has been decreased by ", TextColors.GOLD, String.valueOf(MainLogic.getPowerDecrement()) + "\n",
                TextColors.GRAY, "Current power: ", String.valueOf(PowerService.getPlayerPower(player.getUniqueId())) + "/" + String.valueOf(PowerService.getPlayerMaxPower(player.getUniqueId()))));

        PlayerService.setPlayerChunkPosition(player.getUniqueId(), null);

        return;
    }
    else return;
}
 
开发者ID:Aquerr,项目名称:EagleFactions,代码行数:19,代码来源:PlayerDeathListener.java

示例2: onPlayerDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
@Listener
public void onPlayerDeath(DestructEntityEvent.Death event) {
    DiscordBridge mod = DiscordBridge.getInstance();
    GlobalConfig config = mod.getConfig();
    DiscordAPI client = mod.getBotClient();

    if (!(event.getTargetEntity() instanceof Player) || event.isMessageCancelled() || StringUtils.isBlank(event.getMessage().toPlain())) return;
    Player player = (Player) event.getTargetEntity();

    if (client != null) {
        for (ChannelConfig channelConfig : config.channels) {
            if (StringUtils.isNotBlank(channelConfig.discordId) && channelConfig.discord != null) {
                String template = ConfigUtil.get(channelConfig.discord.deathTemplate, null);
                if (StringUtils.isNotBlank(template)) {
                    Channel channel = client.getChannelById(channelConfig.discordId);
                    ChannelUtil.sendMessage(channel, template.replace("%s", event.getMessage().toPlain()));
                }
            }
        }
    }
}
 
开发者ID:nguyenquyhy,项目名称:DiscordBridge,代码行数:22,代码来源:DeathListener.java

示例3: onEntityDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
@Listener(order = Order.LAST)
public void onEntityDeath(DestructEntityEvent.Death event) {
    if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getTargetEntity().getWorld().getProperties())) {
        return;
    }

    GPTimings.ENTITY_DEATH_EVENT.startTimingIfSync();
    final Living entity = event.getTargetEntity();
    if (!(entity instanceof Player) || !event.getCause().first(EntityDamageSource.class).isPresent()) {
        GPTimings.ENTITY_DEATH_EVENT.stopTimingIfSync();
        return;
    }
    // don't do the rest in worlds where claims are not enabled
    if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(entity.getWorld().getProperties())) {
        GPTimings.ENTITY_DEATH_EVENT.stopTimingIfSync();
        return;
    }

    GPTimings.ENTITY_DEATH_EVENT.stopTimingIfSync();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:21,代码来源:EntityEventHandler.java

示例4: handleDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
private void handleDeath() {
    // Can happen when a dead player joins, just
    // mark the player as dead since the events
    // have already been thrown.
    if (getWorld() == null) {
        setDead(true);
    }
    if (isDead()) {
        return;
    }
    setDead(true);
    final CauseStack causeStack = CauseStack.current();

    // Post the entity destruction event
    final DestructEntityEvent event = SpongeEventFactory.createDestructEntityEventDeath(causeStack.getCurrentCause(),
            MessageChannel.TO_NONE, Optional.empty(), new MessageEvent.MessageFormatter(), this, false);
    postDestructEvent(event);

    try (CauseStack.Frame frame = causeStack.pushCauseFrame()) {
        // Add the destruct event to the cause, this can be used
        // to track the cause of the entity death.
        frame.pushCause(event);
        // Post the harvest event
        handleDeath(causeStack);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:27,代码来源:LanternLiving.java

示例5: remove

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
public void remove(RemoveState removeState) {
    checkNotNull(removeState, "removeState");
    if (this.removeState == removeState) {
        return;
    }
    this.removeState = removeState;
    if (removeState == RemoveState.DESTROYED) {
        setVehicle(null);
        clearPassengers();

        // Call the normal destroy entity event,
        // don't do it if the entity is dead.
        if (!isDead()) {
            setDead(true);

            final CauseStack causeStack = CauseStack.current();
            // TODO: Message channel?
            final DestructEntityEvent event = SpongeEventFactory.createDestructEntityEvent(causeStack.getCurrentCause(),
                    MessageChannel.TO_NONE, Optional.empty(), new MessageEvent.MessageFormatter(), this, false);
            postDestructEvent(event);
        }
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:24,代码来源:LanternEntity.java

示例6: onEntityDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
@Listener
public void onEntityDeath(DestructEntityEvent.Death event, @Getter("getTargetEntity") Zombie zombie) {
  Optional<PatientXInstance> optInst = manager.getApplicableZone(zombie);
  if (!optInst.isPresent()) {
    return;
  }

  if (((EntityZombie) zombie).isChild()) {
    if (Probability.getChance(10)) {
      Task.builder().execute(() -> {
        new ItemDropper(zombie.getLocation()).dropStacks(
            Lists.newArrayList(newItemStack(ItemTypes.GOLD_INGOT, Probability.getRandom(16))),
            SpawnTypes.DROPPED_ITEM
        );
      }).delayTicks(1).submit(SkreePlugin.inst());
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:19,代码来源:PatientXListener.java

示例7: onPlayerDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
@Listener
public void onPlayerDeath(DestructEntityEvent.Death event, @Getter("getTargetEntity") Player player) {
  if (!isApplicable(player)) {
    return;
  }

  PlayerStateService service = Sponge.getServiceManager().provideUnchecked(PlayerStateService.class);
  try {
    service.storeInventory(player);
    service.releaseInventory(player);

    player.getInventory().clear();
  } catch (InventoryStorageStateException e) {
    e.printStackTrace();
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:ZoneInventoryProtector.java

示例8: onEntityDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
@Listener
public void onEntityDeath(DestructEntityEvent.Death destructEntityEvent, @First EntityDamageSource damageSource) {
    Living targetEntity = destructEntityEvent.getTargetEntity();
    if (targetEntity instanceof Player) {
        Player targetPlayer = (Player) targetEntity;
        increaseDeaths(targetPlayer);
    }

    Entity killerEntity = damageSource.getSource();
    if (killerEntity instanceof Player) {
        Player killerPlayer = (Player) killerEntity;
        if (targetEntity instanceof Player) {
            increasePlayerKills(killerPlayer);
        } else {
            increaseMobKills(killerPlayer);
        }
    }
}
 
开发者ID:games647,项目名称:TrackMe,代码行数:19,代码来源:PlayerListener.java

示例9: 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

示例10: 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

示例11: onDesctruct

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
@Listener
public void onDesctruct(DestructEntityEvent event)
{
/* TODO    if (event.getCause().get("CombinedItem", Object.class).isPresent())
    {
        // Ignore CombinedItem
        return;
    }

 TODO     if (event.getCause().get("PickedUp", Object.class).isPresent())
    {
        // Ignore Pickup
        return;
    }
    */

    if (!isActive(event.getTargetEntity().getWorld()))
    {
        return;
    }

    report(observe(event));
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:24,代码来源:DestructReport.java

示例12: onDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
@Listener(order = Order.LAST)
public void onDeath(DestructEntityEvent.Death e) {
    if (!(e.getTargetEntity() instanceof Player))
        return;

    Player p = (Player) e.getTargetEntity();
    if (isOnPipe(p.getUniqueId()) && Via.getConfig().isShowNewDeathMessages() && checkGamerule(p.getWorld())) {
        sendPacket(p, e.getMessage().toPlain());
    }
}
 
开发者ID:MylesIsCool,项目名称:ViaVersion,代码行数:11,代码来源:DeathListener.java

示例13: onEntityDies

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
@Listener
public void onEntityDies(DestructEntityEvent.Death evt) {
    EntityDiesScriptEvent event = (EntityDiesScriptEvent) clone();
    event.internal = evt;
    event.entity = new EntityTag(evt.getTargetEntity());
    event.message = new FormattedTextTag(evt.getMessage());
    event.run();
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:9,代码来源:EntityDiesScriptEvent.java

示例14: onPlayerDeath

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
@Listener
public void onPlayerDeath(DestructEntityEvent.Death event) {
	if (event.getTargetEntity() instanceof Player) {
		EPlayer player = this.plugin.getEServer().getEPlayer((Player) event.getTargetEntity());
		
		player.setBack();
	}
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:9,代码来源:EEPlayerListeners.java

示例15: commandSuicide

import org.spongepowered.api.event.entity.DestructEntityEvent; //导入依赖的package包/类
private CompletableFuture<Boolean> commandSuicide(final EPlayer player) {
	// Event cancel
	if(!player.setHealth(0)) {
		EEMessages.SUICIDE_CANCEL.sender()
			.replace("{player}", player.getName())
			.sendTo(player);
		return CompletableFuture.completedFuture(false);
	}
	
	final MessageEvent.MessageFormatter formatter = new MessageEvent.MessageFormatter();
       MessageChannel originalChannel;
       MessageChannel channel;
       boolean messageCancelled = false;

       originalChannel = player.getMessageChannel();
       channel = player.getMessageChannel();

       messageCancelled = !EEMessages.SUICIDE_DEATH_MESSAGE.getMessage().getChat().isPresent();
       
       formatter.getBody().add(new MessageEvent.DefaultBodyApplier(EEMessages.SUICIDE_DEATH_MESSAGE.getFormat().toText(player.getReplaces())));
       
       List<NamedCause> causes = new ArrayList<NamedCause>();
       causes.add(NamedCause.of("Command", "kill"));
       causes.add(NamedCause.owner(player));
       Cause cause = Cause.of(causes);
       
       DestructEntityEvent.Death event = SpongeEventFactory.createDestructEntityEventDeath(cause, originalChannel, Optional.of(channel), formatter, player, messageCancelled);
       this.plugin.getGame().getEventManager().post(event);

   	if (!event.isMessageCancelled() && !event.getMessage().isEmpty()) {
   		event.getChannel().ifPresent(eventChannel -> eventChannel.send(player, event.getMessage()));
   	} else {
   		EEMessages.SUICIDE_PLAYER.sender()
   			.replace("{player}", player.getName())
   			.sendTo(player);
   	}
   	return CompletableFuture.completedFuture(true);
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:39,代码来源:EESuicide.java


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