本文整理汇总了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.");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}