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


Java Subscribe类代码示例

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


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

示例1: onEnabled

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void onEnabled(final ServerStartedEvent event) throws TimeoutException {
    this.service = event.getGame().getServiceManager().provide(CrossEventService.class).get();

    event.getGame().getAsyncScheduler().runRepeatingTask(this, new Runnable() {
        @Override
        public void run() {
            long startTime = System.currentTimeMillis();
            System.out.println(new Gson().toJson(new spamEvent(1711515,"Hello")));
            try {
                service.callEvent((new spamEvent(1711515, "Hello")));
            } catch (TimeoutException e) {
                e.printStackTrace();
            }
            System.out.println("Event ended");
            long endTime = System.currentTimeMillis();
            long duration = (endTime - startTime);
            System.out.println(duration);
        }
    }, TimeUnit.SECONDS, 1);
}
 
开发者ID:thomas15v,项目名称:CrossEvents,代码行数:22,代码来源:SpamPlugin.java

示例2: onEnabled

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void onEnabled(ServerStartedEvent event){
    instance = this;
    if (!configDir.exists())
        configDir.mkdirs();
    try {
        this.config = new PluginConfig(defaultConfig);
        this.languageManager = new LanguageManager(configDir, config.getLanguage());
        this.claimManager = new ClaimManager(event.getGame(), configDir);
        this.tenantManager = new TenantManager(event.getGame(), configDir);
    } catch (IOException e) {
        e.printStackTrace();
    }
    this.game = event.getGame();
    registerEvents(event.getGame());
    registerCommands(event.getGame());
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:18,代码来源:ChunkLordPlugin.java

示例3: onCommand

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe(order = Order.LATE)
public void onCommand(CommandEvent event)
{
    boolean confirm = event.getCommand().equalsIgnoreCase(confirmAlias);
    boolean deny = event.getCommand().equalsIgnoreCase(denyAlias);

    if (confirm || deny)
    {
        Request request = requestCache.getIfPresent(event.getSource());
        if (request != null)
        {
            event.setCancelled(true);
            event.setResult(CommandResult.empty());
            
            if (confirm) request.confirm(event.getSource());
            else request.deny(event.getSource());
            
            // Remove the request from cache
            requestCache.invalidate(event.getSource());
        }
    }
}
 
开发者ID:boformer,项目名称:DoubleCheck,代码行数:23,代码来源:DoubleCheckService.java

示例4: onServerAboutToStart

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void onServerAboutToStart(ServerAboutToStartEvent event) throws IOException {
    storage = new Storage(configuration, loader).load();

    final List<String> bingAliases = storage.getChildNode("engines.bing.options.aliases").getList(Types::asString);
    new BingEngine("bing", bingAliases.toArray(new String[bingAliases.size()])).register();

    final List<String> duckduckgoAliases = storage.getChildNode("engines.duckduckgo.options.aliases").getList(Types::asString);
    new DuckDuckGoEngine("duckduckgo", duckduckgoAliases.toArray(new String[duckduckgoAliases.size()])).register();

    final List<String> googleAliases = storage.getChildNode("engines.google.options.aliases").getList(Types::asString);
    new GoogleEngine("google", googleAliases.toArray(new String[googleAliases.size()])).register();

    // Fire SearchEngineRegistrationEvent to register search engines
    this.game.getEventManager().post(new SearchEngineRegistrationEvent(engines));

    // Register commands for registered engines
    final Map<List<String>, CommandSpec> children = Maps.newHashMap();
    for (SearchEngine engine : engines) {
        this.game.getCommandDispatcher().register(this, engine.getCommandSpec(), engine.getAliases());
        children.put(engine.getAliases(), engine.getCommandSpec());
        this.logger.info("Registered [" + Texts.toPlain(engine.getName()) + "] with aliases " + engine.getAliases());
    }
    this.game.getCommandDispatcher().register(this, CommandSpec.builder().children(children).build(), "enquiry", "eq");
}
 
开发者ID:InspireNXE,项目名称:Enquiry-Legacy,代码行数:26,代码来源:Enquiry.java

示例5: onPreInitialization

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void onPreInitialization (PreInitializationEvent event) {
    if (!this.configDir.exists()) {
        if (!this.configDir.mkdir()) {
            this.logger.error("Unable to create configuration folder");
        }
    }

    this.mainConfig = new SpongeConfig(new File(this.configDir, "config.yml"), this.logger);
}
 
开发者ID:TheArchives,项目名称:ArchBlock,代码行数:11,代码来源:SpongePlugin.java

示例6: onPreInit

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
   public void onPreInit(PreInitializationEvent event) {
	// Create a new DirectiveHandler with the plugin object (this) and the game
	DirectiveHandler handler = new DirectiveHandler(this, event.getGame());
	
	// Add all of your directive commands through the addDirectives method
	handler.addDirectives(DemoPlugin.class);
	
	// After you have added all of the directives, register them
	handler.registerDirectives();
}
 
开发者ID:mcardy,项目名称:Directive,代码行数:12,代码来源:DemoPlugin.java

示例7: PlayerChatEvent

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void PlayerChatEvent(PlayerChatEvent event)
{
    try {
        this.service.callEvent(new CrossChatEvent(event.getNewMessage()));
    } catch (TimeoutException e) {
        logger.info("Failed to pass event to server!");
    }
}
 
开发者ID:thomas15v,项目名称:CrossEvents,代码行数:10,代码来源:CrossChat.java

示例8: disable

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void disable(ServerStoppingEvent event) {
	for (Manager manager : managers) {
		manager.onDisable();
	}
	managers.clear();
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:8,代码来源:ZephyrPlugin.java

示例9: security

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void security( PlayerInteractBlockEvent event )
{
    ProtectionLocation location = new OglofusProtectionLocation(
            this,
            ( ( World ) event.getBlock().getExtent() ).getUniqueId(),
            event.getBlock().getBlockX(),
            event.getBlock().getBlockY(),
            event.getBlock().getBlockZ()
    );
    ProtectionRegion region;
    if ( ( region = getRegionManager().getRegion( location ).orNull() ) != null )
    {
        if ( !region.getProtectionStaff().hasMemberAccess( event.getEntity().getUniqueId() ) )
        {
            event.setCancelled( true );
        } else
        {
            if ( region.getProtectionVector().getBlockLocation().equals( location ) )
            {
                if ( !region.getProtectionStaff().hasOwnerAccess( event.getEntity().getUniqueId() ) )
                {
                    event.setCancelled( true );
                }
            }
        }
    }
}
 
开发者ID:nikosgram13,项目名称:OglofusProtection,代码行数:29,代码来源:OglofusSponge.java

示例10: onBlockChange

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe(ignoreCancelled = true)
public void onBlockChange(BlockChangeEvent event){
    Optional<Claim> claim = getClaim(event.getBlock());
    if (event.getCause().isPresent() && claim.isPresent()){
        if (event.getCause().get().getCause() instanceof Player){
            Player player = (Player) event.getCause().get().getCause();
            if (canAcces(player, claim.get()))
                return;
        }
        System.out.println("BlockChangeEvent BLOCKED!");
        event.setCancelled(true);
    }
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:14,代码来源:WorldListener.java

示例11: onBlocksChange

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void onBlocksChange(BulkBlockEvent event){
    System.out.println("HEY SPONGE IS READY :D!!!!!!!!!!!!!!");
    for (Location location : event.getBlocks()){
        event.filter(new Predicate<Location>() {
            @Override
            public boolean apply(Location input) {
                Optional<Claim> claimOptional = getClaim(input);
                return claimOptional.isPresent();
            }
        });
    }
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:14,代码来源:WorldListener.java

示例12: onInteract

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe(ignoreCancelled = true)
public void onInteract(PlayerInteractEvent event){
    if (event.getClickedPosition().isPresent() && event.getInteractionType() != EntityInteractionTypes.PICK_BLOCK &&
            event.getUser().getItemInHand().isPresent()) {
        Optional<Claim> claim = getClaim(event.getUser().getWorld(), event.getClickedPosition().get().toInt());
        if (claim.isPresent() && !canAcces(event.getUser(), claim.get())) {
            event.setCancelled(true);
            System.out.println("PlayerInteractEvent BLOCKED!");
        }

    }
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:13,代码来源:WorldListener.java

示例13: onCommandOccupation

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void onCommandOccupation(CommandOccupationEvent event)
{
    if (event.getService() == this) return;
    
	if (event.getCommand().equalsIgnoreCase(confirmAlias) || event.getCommand().equalsIgnoreCase(denyAlias)) requestCache.invalidate(event
            .getSource());
}
 
开发者ID:boformer,项目名称:DoubleCheck,代码行数:9,代码来源:DoubleCheckService.java

示例14: onEnable

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void onEnable(ServerStartedEvent event) {
    game.getEventManager().register(this, new SpongePlotListener(this));
    game.getEventManager().register(this, new SpongePlotDenyListener(this));
    serverObjectBuilder = new SpongeServerBridge(this, new BridgeLogger(logger));
    plotme = new PlotMe_Core();
    setupCommands();
}
 
开发者ID:WorldCretornica,项目名称:PlotMe-Core,代码行数:9,代码来源:PlotMe_Sponge.java

示例15: onEnable

import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void onEnable(ServerStartedEvent event)
{
    this.game = event.getGame();
    this.service = this.game.getServiceManager().provide(CrossEventService.class).get();
}
 
开发者ID:thomas15v,项目名称:CrossEvents,代码行数:7,代码来源:CrossChat.java


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