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


Java Sponge.getScheduler方法代碼示例

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


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

示例1: gameStarted

import org.spongepowered.api.Sponge; //導入方法依賴的package包/類
@Listener
public void gameStarted(GameStartedServerEvent event){

    if(forceStop) {
        return;
    }

    HuskyCommandManager huskyCommandManager = new HuskyCommandManager();

    scheduler = Sponge.getScheduler();
    //genericCause = Cause.of(EventContext.);
    Sponge.getCommandManager().register(this, huskyCommandManager.getCrateSpec(), "hc","huskycrates");
    Sponge.getCommandManager().register(this, huskyCommandManager.getHuskySpec(), "husky");
    metrics.addCustomChart(new Metrics.SimplePie("huskyui_version", () -> HuskyUI.PLUGIN_VERSION));
    logger.info("Crates has been started.");
}
 
開發者ID:codeHusky,項目名稱:HuskyCrates-Sponge,代碼行數:17,代碼來源:HuskyCrates.java

示例2: RouletteCrateView

import org.spongepowered.api.Sponge; //導入方法依賴的package包/類
public RouletteCrateView(HuskyCrates plugin, Player runner, VirtualCrate virtualCrate){
    this.plugin = plugin;
    vc = virtualCrate;
    ourplr = runner;
    items = vc.getItemSet();
    if(virtualCrate.scrambleRewards){
        scrambleRewards();
    }
    disp = Inventory.builder()
            .of(InventoryArchetypes.DISPENSER)
            .listener(InteractInventoryEvent.class, evt ->{
                if(!(evt instanceof InteractInventoryEvent.Open) && !(evt instanceof  InteractInventoryEvent.Close)){
                    evt.setCancelled(true);
                    if(!stopped && evt instanceof ClickInventoryEvent){
                        ourplr.playSound(SoundTypes.ENTITY_FIREWORK_LAUNCH,ourplr.getLocation().getPosition(),1);
                    }
                    stopped = true;
                }

            })
            .property(InventoryTitle.PROPERTY_NAME,InventoryTitle.of(TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName)))
            .build(plugin);
    updateInv(0);
    Scheduler scheduler = Sponge.getScheduler();
    Task.Builder taskBuilder = scheduler.createTaskBuilder();
    updater = taskBuilder.execute(this::updateTick).intervalTicks(1).submit(plugin);
}
 
開發者ID:codeHusky,項目名稱:HuskyCrates-Sponge,代碼行數:28,代碼來源:RouletteCrateView.java

示例3: InstantGUIView

import org.spongepowered.api.Sponge; //導入方法依賴的package包/類
public InstantGUIView(HuskyCrates plugin, Player runner, VirtualCrate virtualCrate){
    //System.out.println("AA");
    this.plugin = plugin;
    vc = virtualCrate;
    ourplr = runner;
    items = vc.getItemSet();
    if(virtualCrate.scrambleRewards){
        scrambleRewards();
    }
    disp = Inventory.builder()
            .of(InventoryArchetypes.DISPENSER)
            .listener(InteractInventoryEvent.class, evt ->{
                if(!(evt instanceof InteractInventoryEvent.Open) && !(evt instanceof  InteractInventoryEvent.Close)){
                    evt.setCancelled(true);
                }

            })
            .property(InventoryTitle.PROPERTY_NAME,InventoryTitle.of(TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName)))
            .build(plugin);
    updateInv(0);
    Scheduler scheduler = Sponge.getScheduler();
    Task.Builder taskBuilder = scheduler.createTaskBuilder();
    updater = taskBuilder.execute(this::updateTick).intervalTicks(1).submit(plugin);
    scheduler.createTaskBuilder().execute(() -> {
        updater.cancel();
        ourplr.closeInventory();
        handleReward(holder);
        ourplr.playSound(SoundTypes.ENTITY_EXPERIENCE_ORB_PICKUP,ourplr.getLocation().getPosition(),1);
    }).delay(3, TimeUnit.SECONDS).submit(HuskyCrates.instance);
}
 
開發者ID:codeHusky,項目名稱:HuskyCrates-Sponge,代碼行數:31,代碼來源:InstantGUIView.java

示例4: startParticleEffects

import org.spongepowered.api.Sponge; //導入方法依賴的package包/類
public void startParticleEffects(){
    if(runner != null){
        runner.cancel();
    }
    Scheduler scheduler = Sponge.getScheduler();
    Task.Builder taskBuilder = scheduler.createTaskBuilder();
    runner = taskBuilder.execute(this::particleRunner).intervalTicks(1).submit(plugin);
}
 
開發者ID:codeHusky,項目名稱:HuskyCrates-Sponge,代碼行數:9,代碼來源:CrateUtilities.java

示例5: SpinnerCrateView

import org.spongepowered.api.Sponge; //導入方法依賴的package包/類
public SpinnerCrateView(HuskyCrates plugin, Player runner, VirtualCrate virtualCrate){
    this.vc = virtualCrate;
    ourplr = runner;
    this.plugin = plugin;

    items = virtualCrate.getItemSet();
    if(virtualCrate.scrambleRewards){
        scrambleRewards();
    }

    if(virtualCrate.getOptions().containsKey("dampening")) {
        dampening = (double) virtualCrate.getOptions().get("dampening");
        //HuskyCrates.instance.logger.info("dampening override: " + dampening);
    }
    if(virtualCrate.getOptions().containsKey("maxClicks")) {
        maxClicks = (int) virtualCrate.getOptions().get("maxClicks");
        //HuskyCrates.instance.logger.info("maxClicks override: " + maxClicks);
    }
    if(virtualCrate.getOptions().containsKey("minClickModifier") || virtualCrate.getOptions().containsKey("maxClickModifier")){
        int min = (int)virtualCrate.getOptions().get("minClickModifier");
        int max = (int)virtualCrate.getOptions().get("maxClickModifier");
        Random rand = new Random();
        maxClicks += Math.round((max*rand.nextDouble())+(min*rand.nextDouble()));
    }
    try {
        clicks = itemIndexSelected() - (maxClicks % items.size());
    }catch (RandomItemSelectionFailureException e){
        HuskyCrates.initError();
        System.out.println("--------------------------------");
        System.out.println("--------------------------------");
        System.out.println("ERROR WHEN INITING RANDOM ITEM FOR " + vc.displayName);
        System.out.println("--------------------------------");
        System.out.println("--------------------------------");
    }
    disp = Inventory.builder()
            .of(InventoryArchetypes.CHEST)
            .listener(InteractInventoryEvent.class, evt ->{
                if(!(evt instanceof InteractInventoryEvent.Open) && !(evt instanceof  InteractInventoryEvent.Close)){
                    evt.setCancelled(true);
                }
                //System.out.println(evt.getClass());
            })
            .property(InventoryTitle.PROPERTY_NAME,InventoryTitle.of(TextSerializers.FORMATTING_CODE.deserialize(virtualCrate.displayName)))
            .build(plugin);
    updateInv(0);
    Scheduler scheduler = Sponge.getScheduler();
    Task.Builder taskBuilder = scheduler.createTaskBuilder();
    updater = taskBuilder.execute(this::updateTick).intervalTicks(1).submit(plugin);


}
 
開發者ID:codeHusky,項目名稱:HuskyCrates-Sponge,代碼行數:52,代碼來源:SpinnerCrateView.java


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