org.spongepowered.api.event.Listener类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中org.spongepowered.api.event.Listener类的一些代码示例,展示了Listener类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Listener类的具体详情如下:
包路径:org.spongepowered.api.event.Listener
类名称:Listener

Listener介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

@Listener
public void postInit(GamePostInitializationEvent event) {
  logger.info("WorldEdit for Sponge (version " + getInternalVersion() + ") is loaded");
}

代码示例来源:origin: EngineHub/WorldEdit

@Listener
public void init(GameInitializationEvent event) {
  CUIChannelHandler.init();
}

代码示例来源:origin: EngineHub/WorldEdit

@Listener
public void serverStopping(GameStoppingServerEvent event) {
  WorldEdit worldEdit = WorldEdit.getInstance();
  worldEdit.getSessionManager().unload();
  worldEdit.getPlatformManager().unregister(platform);
}

代码示例来源:origin: EngineHub/WorldEdit

@Listener
public void serverStarted(GameStartedServerEvent event) {
  WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
  loadAdapter();
}

代码示例来源:origin: EngineHub/WorldEdit

@Listener
public void preInit(GamePreInitializationEvent event) {
  // Load configuration
  config.load();
  Task.builder().interval(30, TimeUnit.SECONDS).execute(ThreadSafeCache.getInstance()).submit(this);
}

代码示例来源:origin: EngineHub/WorldEdit

@Listener
public void serverAboutToStart(GameAboutToStartServerEvent event) {
  if (this.platform != null) {
    logger.warn("GameAboutToStartServerEvent occurred when GameStoppingServerEvent hasn't");
    WorldEdit.getInstance().getPlatformManager().unregister(platform);
  }
  this.platform = new SpongePlatform(this);
  this.provider = new SpongePermissionsProvider();
  for (BlockType blockType : Sponge.getRegistry().getAllOf(BlockType.class)) {
    // TODO Handle blockstate stuff
    String id = blockType.getId();
    if (!com.sk89q.worldedit.world.block.BlockType.REGISTRY.keySet().contains(id)) {
      com.sk89q.worldedit.world.block.BlockTypes.register(new com.sk89q.worldedit.world.block.BlockType(id));
    }
  }
  for (ItemType itemType : Sponge.getRegistry().getAllOf(ItemType.class)) {
    String id = itemType.getId();
    if (!com.sk89q.worldedit.world.item.ItemType.REGISTRY.keySet().contains(id)) {
      ItemTypes.register(new com.sk89q.worldedit.world.item.ItemType(id));
    }
  }
  WorldEdit.getInstance().getPlatformManager().register(platform);
}

代码示例来源:origin: EngineHub/WorldEdit

@Listener
public void onPlayerInteract(InteractBlockEvent event, @Root Player spongePlayer) {
  if (platform == null) {

代码示例来源:origin: PEXPlugins/PermissionsEx

@Listener
public void onReload(GameReloadEvent event) {
  if (this.manager != null) {
    this.manager.reload();
  }
}

代码示例来源:origin: TVPT/VoxelSniper

@Listener
public void onReload(GameReloadEvent event) {
  this.logger.info("Reloading VoxelSniper configuration");
  Path config = this.configDir.resolve("voxelsniper.conf");
  VoxelSniperConfiguration.init(config);
}

代码示例来源:origin: MylesIsCool/ViaVersion

@Listener
public void onServerStart(GameAboutToStartServerEvent event) {
  // Inject!
  logger.info("ViaVersion is injecting!");
  Via.getManager().init();
}

代码示例来源:origin: EngineHub/CraftBook

@Listener
public void onBlockUpdate(NotifyNeighborBlockEvent event, @First LocatableBlock source) {
  event.getNeighbors().entrySet().stream()
      .map((directionBlockStateEntry -> source.getLocation().getRelative(directionBlockStateEntry.getKey())))
      .forEach(this::checkForPhysics);
}

代码示例来源:origin: EngineHub/CraftBook

@Listener
public void onServerStopping(GameStoppingServerEvent event) {
  saveConfig();
  disableMechanics();
}

代码示例来源:origin: EngineHub/CraftBook

@Listener
public void onEntityConstruct(SpawnEntityEvent event) {
  event.getEntities().stream().filter(entity -> entity instanceof Boat).forEach(boat -> {
    if (!isWater(boat.getLocation())) {
      event.setCancelled(true);
    }
  });
}

代码示例来源:origin: EngineHub/CraftBook

@Listener
public void onBlockBreak(ChangeBlockEvent.Break event) {
  event.getTransactions().stream().map(transaction -> transaction.getOriginal().getLocation().get()).forEach(location -> {
    if (loadedICs.containsKey(location)) {
      IC ic = loadedICs.remove(location);
      ic.unload();
      if (ic instanceof SelfTriggeringIC) {
        ((SpongeSelfTriggerManager) CraftBookPlugin.inst().getSelfTriggerManager().get()).unregister(this, location);
      }
    }
  });
}

代码示例来源:origin: PEXPlugins/PermissionsEx

@Listener
public void disable(GameStoppedServerEvent event) {
  logger.debug(t("Disabling %s", PomData.NAME));
  PermissionsEx manager = this.manager;
  if (manager != null) {
    manager.close();
  }
}

代码示例来源:origin: EngineHub/CraftBook

@Listener
public void onVehicleEnter(RideEntityEvent.Mount event, @First Entity entity) {
  if (event.getTargetEntity() instanceof RideableMinecart) {
    if (!(entity instanceof Player)) {
      event.setCancelled(true);
    }
  }
}

代码示例来源:origin: EngineHub/CraftBook

@Listener
public void onBlockBreak(ChangeBlockEvent.Break event) {
  event.getTransactions().forEach((transaction) -> transaction.getOriginal().getLocation().ifPresent((location) -> {
    Chair<?> chair = getChair(location);
    if (chair != null)
      removeChair(chair, true);
  }));
}

代码示例来源:origin: Rsl1122/Plan-PlayerAnalytics

@Listener(order = Order.POST)
public void onWorldChange(MoveEntityEvent.Teleport event, @First Player player) {
  if (event.isCancelled()) {
    return;
  }
  try {
    actOnEvent(event, player);
  } catch (Exception e) {
    errorHandler.log(L.ERROR, this.getClass(), e);
  }
}

代码示例来源:origin: EngineHub/CraftBook

@Listener
public void onVehicleCollide(CollideEntityEvent event, @First ChestMinecart chestMinecart) {
  event.getEntities().stream().filter(entity -> entity.getType() == EntityTypes.ITEM).filter(item -> !item.isRemoved()).forEach(item -> {
    Collection<ItemStackSnapshot> rejects = chestMinecart.getInventory().offer(item.get(Keys.REPRESENTED_ITEM).get().createStack()).getRejectedItems();
    if (rejects.isEmpty()) {
      item.remove();
    }
  });
}

代码示例来源:origin: MylesIsCool/ViaVersion

@Listener
public void onInteract(InteractEvent event, @Root Player player) {
  if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) {
    if (ArmorType.isArmor(player.getItemInHand(HandTypes.MAIN_HAND).get().getItem().getId()))
      sendDelayedArmorUpdate(player);
  }
}

相关文章

Listener类方法