本文整理汇总了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);
}
示例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());
}
示例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());
}
}
}
示例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");
}
示例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);
}
示例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();
}
示例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!");
}
}
示例8: disable
import org.spongepowered.api.event.Subscribe; //导入依赖的package包/类
@Subscribe
public void disable(ServerStoppingEvent event) {
for (Manager manager : managers) {
manager.onDisable();
}
managers.clear();
}
示例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 );
}
}
}
}
}
示例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);
}
}
示例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();
}
});
}
}
示例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!");
}
}
}
示例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());
}
示例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();
}
示例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();
}