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


Java Timespan.getTicks_i方法代码示例

本文整理汇总了Java中ch.njol.skript.util.Timespan.getTicks_i方法的典型用法代码示例。如果您正苦于以下问题:Java Timespan.getTicks_i方法的具体用法?Java Timespan.getTicks_i怎么用?Java Timespan.getTicks_i使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.njol.skript.util.Timespan的用法示例。


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

示例1: execute

import ch.njol.skript.util.Timespan; //导入方法依赖的package包/类
@Override
protected void execute(final Event e) {
	for (final LivingEntity le : entites.getArray(e)) {
		if (!cure) {
			Timespan dur;
			int d = (int) (duration != null && (dur = duration.getSingle(e)) != null ? 
					(dur.getTicks_i() >= Integer.MAX_VALUE ? Integer.MAX_VALUE : dur.getTicks_i()) : DEFAULT_DURATION);
			if (le.hasPotionEffect(PotionEffectType.POISON)) {
				for (final PotionEffect pe : le.getActivePotionEffects()) {
					if (pe.getType() != PotionEffectType.POISON)
						continue;
					d += pe.getDuration();
				}
			}
			le.addPotionEffect(new PotionEffect(PotionEffectType.POISON, d, 0), true);
		} else {
			le.removePotionEffect(PotionEffectType.POISON);
		}
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:21,代码来源:EffPoison.java

示例2: execute

import ch.njol.skript.util.Timespan; //导入方法依赖的package包/类
@Override
protected void execute(final Event e) {
	final int d;
	if (duration != null) {
		final Timespan t = duration.getSingle(e);
		if (t == null)
			return;
		d = (int) (t.getTicks_i() >= Integer.MAX_VALUE ? Integer.MAX_VALUE : t.getTicks_i());
	} else {
		d = ignite ? DEFAULT_DURATION : 0;
	}
	for (final Entity en : entities.getArray(e)) {
		if (e instanceof EntityDamageEvent && ((EntityDamageEvent) e).getEntity() == en && !Delay.isDelayed(e)) {
			Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
				@Override
				public void run() {
					en.setFireTicks(d);
				}
			});
		} else {
			if (e instanceof EntityCombustEvent && ((EntityCombustEvent) e).getEntity() == en && !Delay.isDelayed(e))
				((EntityCombustEvent) e).setCancelled(true);// can't change the duration, thus simply cancel the event (and create a new one)
			en.setFireTicks(d);
		}
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:27,代码来源:EffIgnite.java

示例3: startBackupTask

import ch.njol.skript.util.Timespan; //导入方法依赖的package包/类
public void startBackupTask(final Timespan t) {
	final File file = this.file;
	if (file == null || t.getTicks_i() == 0)
		return;
	backupTask = new Task(Skript.getInstance(), t.getTicks_i(), t.getTicks_i(), true) {
		@Override
		public void run() {
			synchronized (connectionLock) {
				disconnect();
				try {
					FileUtils.backup(file);
				} catch (final IOException e) {
					Skript.error("Automatic variables backup failed: " + e.getLocalizedMessage());
				} finally {
					connect();
				}
			}
		}
	};
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:21,代码来源:VariablesStorage.java

示例4: change

import ch.njol.skript.util.Timespan; //导入方法依赖的package包/类
@Override
public void change(LivingEntity livingEntity, Timespan timespan, Changer.ChangeMode changeMode) {
    int ticks;
    switch (changeMode) {
        case SET: ticks = (int) timespan.getTicks_i(); break;
        case ADD: ticks = getAirTicks(livingEntity) + (int) timespan.getTicks_i(); break;
        case REMOVE: ticks = getAirTicks(livingEntity) + (int) timespan.getTicks_i(); break;
        default: throw new IllegalArgumentException("Illegal changeMode: " + changeMode);
    }
    switch (getPropertyName()) {
        case "breath": livingEntity.setRemainingAir(ticks); break;
        case "max breath": livingEntity.setMaximumAir(ticks); break;
        default: throw new IllegalStateException("Illegal getPropertyName() value: " + getPropertyName());
    }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:16,代码来源:ExprRemainingAir.java

示例5: getTicks

import ch.njol.skript.util.Timespan; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static int getTicks(Timespan time) {
	if (Skript.methodExists(Timespan.class, "getTicks_i")) {
		Number tick = time.getTicks_i();
		return tick.intValue();
	} else {
		return time.getTicks();
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:10,代码来源:Skellett.java

示例6: set

import ch.njol.skript.util.Timespan; //导入方法依赖的package包/类
@Override
public void set(final Timespan t) {
	final Task ct = Updater.checkerTask;
	if (t.getTicks_i() != 0 && ct != null && !ct.isAlive())
		ct.setNextExecution(t.getTicks_i());
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:7,代码来源:SkriptConfig.java


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