本文整理汇总了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();
}
}
}
示例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
}
示例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);
}
}
示例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());
}
示例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());
}
}
示例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();
}
}
}
示例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);
}
}
}
}
}
示例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());
}
}
示例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);
}
}