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