當前位置: 首頁>>代碼示例>>Java>>正文


Java Order.EARLY屬性代碼示例

本文整理匯總了Java中org.spongepowered.api.event.Order.EARLY屬性的典型用法代碼示例。如果您正苦於以下問題:Java Order.EARLY屬性的具體用法?Java Order.EARLY怎麽用?Java Order.EARLY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.spongepowered.api.event.Order的用法示例。


在下文中一共展示了Order.EARLY屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onFire

@Listener(order=Order.EARLY, beforeModifications = true)
public void onFire(ChangeBlockEvent event)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	event
	.getTransactions()
	.stream()
	.filter(trans -> trans.getFinal().getState().getType() == BlockTypes.FIRE)
	.filter(trans -> {
		Optional<Location<World>> optLoc = trans.getFinal().getLocation();
		if (!optLoc.isPresent())
			return false;
		return !DataHandler.getFlag("fire", optLoc.get());
	})
	.forEach(trans -> trans.setValid(false));
}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:19,代碼來源:FireListener.java

示例2: onWorldLoad

@Listener(order = Order.EARLY, beforeModifications = true)
public void onWorldLoad(LoadWorldEvent event) {
    if (!SpongeImpl.getServer().isServerRunning() || !GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getTargetWorld().getProperties())) {
        return;
    }

    GPTimings.WORLD_LOAD_EVENT.startTimingIfSync();
    GriefPreventionPlugin.instance.dataStore.loadWorldData(event.getTargetWorld());
    net.minecraft.world.World world = (net.minecraft.world.World) event.getTargetWorld();
    world.addEventListener(new EntityRemovalListener());
    GPTimings.WORLD_LOAD_EVENT.stopTimingIfSync();
    if (!GriefPreventionPlugin.getActiveConfig(event.getTargetWorld().getProperties()).getConfig().claim.bankTaxSystem) {
        return;
    }
    if (GriefPreventionPlugin.instance.economyService.isPresent()) {
        // run tax task
        TaxApplyTask taxTask = new TaxApplyTask(event.getTargetWorld().getProperties());
        int taxHour = GriefPreventionPlugin.getActiveConfig(event.getTargetWorld().getProperties()).getConfig().claim.taxApplyHour;
        long delay = TaskUtils.computeDelay(taxHour, 0, 0);
        Sponge.getScheduler().createTaskBuilder().async().delay(delay, TimeUnit.SECONDS).interval(1, TimeUnit.DAYS).execute(taxTask).submit(GriefPreventionPlugin.instance);
    }
}
 
開發者ID:MinecraftPortCentral,項目名稱:GriefPrevention,代碼行數:22,代碼來源:WorldEventHandler.java

示例3: onGamePreInitialization

@Listener(order = Order.EARLY)
public void onGamePreInitialization(@Nonnull final GamePreInitializationEvent event) {
    if (this.configProfilesFile == null) {
        LOGGER.error("Failed to properly load configuration profiles.", new IllegalStateException());
        return;
    }

    this.configProfiles.clear();
    for (final Map.Entry<Object, ? extends ConfigurationNode> entry : this.configProfilesFile.getNode().getChildrenMap().entrySet()) {
        if (!entry.getValue().hasMapChildren()) {
            continue;
        }

        final String key = "" + entry.getKey();
        final ConfigurationNode config = entry.getValue();

        final ConfigProfile profile = ConfigProfile.parse(key, config);
        if (profile == null) {
            continue;
        }

        LOGGER.info("Found \"{}\" profile, using \"{}\".", key,
                profile.getStorage().getStorageType().toString());

        this.configProfiles.put(key, profile);
    }

    if (!this.hasConfigProfile("default")) {
        LOGGER.warn("Couldn't find a \"default\" configuration profile.");
    }
}
 
開發者ID:FerusTech,項目名稱:Amicus,代碼行數:31,代碼來源:AmicusCore.java

示例4: onInteractItemPrimary

@Listener(order = Order.EARLY)
public void onInteractItemPrimary(InteractItemEvent.Primary event, @First Player player)
{
    String name = "";
    Optional<VirtualChestInventory> inventoryOptional = Optional.empty();
    for (String inventoryName : this.dispatcher.listInventories())
    {
        VirtualChestInventory inventory = this.dispatcher.getInventory(inventoryName).get();
        if (inventory.matchItemForOpeningWithPrimaryAction(event.getItemStack()))
        {
            if (player.hasPermission("virtualchest.open.self." + inventoryName))
            {
                name = inventoryName;
                inventoryOptional = Optional.of(inventory);
                event.setCancelled(true);
                break;
            }
        }
    }
    if (inventoryOptional.isPresent())
    {
        try
        {
            this.logger.debug("Player {} tries to create the GUI ({}) by primary action", player.getName(), name);
            SpongeUnimplemented.openInventory(player, inventoryOptional.get().createInventory(player), this);
        }
        catch (InvalidDataException e)
        {
            this.logger.error("There is something wrong with the GUI configuration (" + name + ")", e);
        }
    }
}
 
開發者ID:ustc-zzzz,項目名稱:VirtualChest,代碼行數:32,代碼來源:VirtualChestPlugin.java

示例5: onInteractItemSecondary

@Listener(order = Order.EARLY)
public void onInteractItemSecondary(InteractItemEvent.Secondary event, @First Player player)
{
    String name = "";
    Optional<VirtualChestInventory> inventoryOptional = Optional.empty();
    for (String inventoryName : this.dispatcher.listInventories())
    {
        VirtualChestInventory inventory = this.dispatcher.getInventory(inventoryName).get();
        if (inventory.matchItemForOpeningWithSecondaryAction(event.getItemStack()))
        {
            if (player.hasPermission("virtualchest.open.self." + inventoryName))
            {
                name = inventoryName;
                inventoryOptional = Optional.of(inventory);
                event.setCancelled(true);
                break;
            }
        }
    }
    if (inventoryOptional.isPresent())
    {
        try
        {
            this.logger.debug("Player {} tries to create the GUI ({}) by secondary action", player.getName(), name);
            SpongeUnimplemented.openInventory(player, inventoryOptional.get().createInventory(player), this);
        }
        catch (InvalidDataException e)
        {
            this.logger.error("There is something wrong with the GUI configuration (" + name + ")", e);
        }
    }
}
 
開發者ID:ustc-zzzz,項目名稱:VirtualChest,代碼行數:32,代碼來源:VirtualChestPlugin.java

示例6: onGamePreInitialization

@Listener(order = Order.EARLY)
public void onGamePreInitialization(GamePreInitializationEvent event) {
    Scheduler scheduler = Sponge.getScheduler();
    asyncExecutor = scheduler.createAsyncExecutor(this);
    syncExecutor = scheduler.createSyncExecutor(this);
    service = new MineskinServiceImpl().load();
    Sponge.getServiceManager().setProvider(this, MineskinService.class, service);
    MineskinCommands.register();
}
 
開發者ID:Limeth,項目名稱:MineskinSponge,代碼行數:9,代碼來源:MineskinSponge.java

示例7: onClientAuth

@Listener(order = Order.EARLY)
@IsCancelled(Tristate.UNDEFINED)
public void onClientAuth(ClientConnectionEvent.Auth e) {
    /* Called when the player first attempts a connection with the server.
       Listening on AFTER_PRE priority to allow plugins to modify username / UUID data here. (auth plugins) */

    final GameProfile p = e.getProfile();
    final String username = p.getName().orElseThrow(() -> new RuntimeException("No username present for user " + p.getUniqueId()));

    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLog().info("Processing auth event for " + p.getUniqueId() + " - " + p.getName());
    }

    this.plugin.getUniqueConnections().add(p.getUniqueId());

    /* Actually process the login for the connection.
       We do this here to delay the login until the data is ready.
       If the login gets cancelled later on, then this will be cleaned up.

       This includes:
       - loading uuid data
       - loading permissions
       - creating a user instance in the UserManager for this connection.
       - setting up cached data. */
    try {
        User user = loadUser(p.getUniqueId(), username);
        this.plugin.getEventFactory().handleUserLoginProcess(p.getUniqueId(), username, user);
    } catch (Exception ex) {
        this.plugin.getLog().severe("Exception occured whilst loading data for " + p.getUniqueId() + " - " + p.getName());
        ex.printStackTrace();

        this.deniedAsyncLogin.add(p.getUniqueId());

        e.setCancelled(true);
        e.setMessageCancelled(false);
        //noinspection deprecation
        e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
    }
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:39,代碼來源:SpongeConnectionListener.java

示例8: onConstructWorldProperties

@Listener(order = Order.EARLY)
public void onConstructWorldProperties(ConstructWorldPropertiesEvent event) {
    if (!SpongeImpl.getServer().isServerRunning() || !GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getWorldProperties())) {
        return;
    }

    GriefPreventionPlugin.instance.dataStore.registerWorld(event.getWorldProperties());
}
 
開發者ID:MinecraftPortCentral,項目名稱:GriefPrevention,代碼行數:8,代碼來源:WorldEventHandler.java

示例9: onPartyJoin

@Listener(order = Order.EARLY)
public void onPartyJoin(PartyJoinEvent event) {
	if (PluginConfig.MAX_PARTY_SIZE > -1) {
		if (event.getParty().getPlayers().size() > PluginConfig.MAX_PARTY_SIZE) {
			event.setCancelled(true);
		}
	}
}
 
開發者ID:NeumimTo,項目名稱:NT-RPG,代碼行數:8,代碼來源:RpgListener.java

示例10: onGameConstruction

@Listener(order = Order.EARLY)
public void onGameConstruction(GameConstructionEvent event) {
    instance = this;
}
 
開發者ID:Limeth,項目名稱:MineskinSponge,代碼行數:4,代碼來源:MineskinSponge.java

示例11: onServerStop

@Listener(order = Order.EARLY)
public void onServerStop(GameStoppingServerEvent evt) {
    ServerStopsScriptEvent event = (ServerStopsScriptEvent) clone();
    event.internal = evt;
    event.run();
}
 
開發者ID:DenizenScript,項目名稱:Denizen2Sponge,代碼行數:6,代碼來源:ServerStopsScriptEvent.java

示例12: onPlayerChat

@Listener(order = Order.EARLY)
public void onPlayerChat(MessageChannelEvent.Chat event) {
    java.util.Optional<Player> player = event.getCause().first(Player.class);
    if (!player.isPresent()) {
        return;
    }

    for (Minigame mg : CommonCore.getMinigames().values()) {
        IWizardManager wm = ((InfernoMinigame) mg).getLobbyWizardManager();
        // check if the player is in a wizard
        if (wm.hasPlayer(player.get().getUniqueId())) {
            event.setCancelled(true);
            // send the original message since the event is cancelled
            player.get().sendMessage(Text.builder().append(Text.of("<"))
                    .append(player.get().getDisplayNameData().displayName().get()).append(Text.of("> "))
                    .append(event.getMessage()).build());

            // feed the message to the wizard manager and get the response
            String[] response = wm.accept(player.get().getUniqueId(), event.getMessage().toPlain());
            CommonCore.getChatAgent().processAndSend(player.get().getUniqueId(), response);

            return; // no need for further checks
        }

        if (!event.getChannel().isPresent()) {
            return;
        }

        MessageChannel mutable = event.getChannel().get().asMutable();
        Iterator<MessageReceiver> it = mutable.getMembers().iterator();
        while (it.hasNext()) {
            MessageReceiver recip = it.next();

            if (!(recip instanceof Player)) {
                return;
            }

            // check if the recipient is in a lobby wizard
            if (((InfernoMinigame) mg).getLobbyWizardManager().hasPlayer(((Player) recip).getUniqueId())) {
                ((InfernoMinigame) mg).getLobbyWizardManager().withholdMessage(
                        ((Player) recip).getUniqueId(),
                        player.get().getDisplayNameData().displayName().get().toPlain(),
                        event.getMessage().toPlain()
                );
                continue;
            }

            // check if a chat barrier exists between the sender and recipient
            if (ChatHelper.isBarrierPresent(player.get().getUniqueId(), ((Player) recip).getUniqueId())) {
                it.remove();
            }
        }
        event.setChannel(mutable);
    }
}
 
開發者ID:caseif,項目名稱:Inferno,代碼行數:55,代碼來源:PlayerWorldListener.java

示例13: preInit

@Listener(order = Order.EARLY)
public void preInit(GamePreInitializationEvent event) {
    this.logger.info("Initializing " + getContainer().getName());
    setup();
}
 
開發者ID:BadgeUp,項目名稱:badgeup-sponge-client,代碼行數:5,代碼來源:BadgeUpSponge.java

示例14: onQPress

@Listener(order = Order.EARLY)
public void onQPress(DropItemEvent.Pre e, @Root Player player) {
	IActiveCharacter character = characterService.getCharacter(player);
	e.setCancelled(characterService.processUserAction(character, UserActionType.Q));
}
 
開發者ID:NeumimTo,項目名稱:NT-RPG,代碼行數:5,代碼來源:ComboListener.java

示例15: onInventoryOpen

@Listener(order = Order.EARLY)
public void onInventoryOpen(InteractInventoryEvent.Open e, @Root Player player) {
	IActiveCharacter character = characterService.getCharacter(player);
	e.setCancelled(characterService.processUserAction(character, UserActionType.E));
}
 
開發者ID:NeumimTo,項目名稱:NT-RPG,代碼行數:5,代碼來源:ComboListener.java


注:本文中的org.spongepowered.api.event.Order.EARLY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。