本文整理汇总了Java中ch.njol.skript.util.Timespan类的典型用法代码示例。如果您正苦于以下问题:Java Timespan类的具体用法?Java Timespan怎么用?Java Timespan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Timespan类属于ch.njol.skript.util包,在下文中一共展示了Timespan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@Nullable
@Override
protected Timespan[] get(Event e) {
ItemStack i = item.getSingle(e);
if (i == null) {
return null;
}
if (PotionUtils.isPotionItem(i)) {
PotionMeta meta = (PotionMeta) i.getItemMeta();
PotionEffect eff = PotionUtils.getEffectByEffectType(meta, effectType.getSingle(e));
if (eff == null) {
return null;
}
return new Timespan[]{Timespan.fromTicks_i(eff.getDuration())};
}
return null;
}
示例2: loadBorderEvent
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
private static void loadBorderEvent() {
Bukkit.getWorlds().forEach(WorldBorderMundo::replaceBorderForWorld);
Bukkit.getServer().getPluginManager().registerEvents(new Listener() {
@EventHandler
public void onWorldLoad(WorldLoadEvent event) {
replaceBorderForWorld(event.getWorld());
}
}, Mundo.INSTANCE);
Registration.registerEvent("Border Stabilize", EvtBorderStabilize.class, BorderStabilizeEvent.class, "border stabilize [in %-worlds%]")
.document("Border Stabilize", "1.4.6", "Called when a border (optionally only of the specified world(s)) stops moving.");
Registration.registerExpression(ExprBorderMovingValue.class, Number.class, ExpressionType.PROPERTY,
"(0¦original " + DIAMETER_SYNTAX + "|1¦(eventual|final) " + DIAMETER_SYNTAX + "|2¦remaining distance until [the] border stabilize[s]) of %world%",
"%world%'s (0¦original " + DIAMETER_SYNTAX + "|1¦(eventual|final) " + DIAMETER_SYNTAX + "|2¦remaining distance until [the] border stabilize[s])")
.document("Moving Border Diameter", "1.8", "An expression for a certain property of the moving border of the specified world:"
+ "original diameter: The diameter of the border when it was last stable"
+ "final diameter: The diameter that the border will be when it stabilizes"
+ "remaining distance: The distance the border still has to go before it stabilizes");
Registration.registerExpression(ExprTimeRemainingUntilBorderStabilize.class, Timespan.class, ExpressionType.PROPERTY,
"(time remaining|remaining time) until [the] border stabilize[s] (of|in) %world%",
"%world%'s (time remaining|remaining time) until [the] border stabilize[s]")
.document("Time Remaining Until Border Stabilize", "1.4.6", "An expression for the timespan remaining until the border of the specified world stops moving.");
Registration.registerExpressionCondition(CondBorderMoving.class, ExpressionType.PROPERTY, "border of %world% is (0¦moving|1¦stable)", "%world%'s border is (0¦moving|1¦stable)")
.document("Border is Moving", "1.8", "Checks whether the border of the specified world is moving or stable (not moving).");
}
示例3: acceptChange
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
switch (mode) {
case ADD:
case REMOVE:
return CollectionUtils.array(Timespan.class);
case SET:
return CollectionUtils.array(Time.class);
case DELETE:
case REMOVE_ALL:
case RESET:
default:
return null;
}
}
示例4: 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);
}
}
}
示例5: 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);
}
}
}
示例6: walk
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@Override
@Nullable
protected TriggerItem walk(final Event e) {
debug(e, true);
final long start = Skript.debug() ? System.nanoTime() : 0;
final TriggerItem next = getNext();
if (next != null) {
delayed.add(e);
final Timespan d = duration.getSingle(e);
if (d == null)
return null;
Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
@Override
public void run() {
if (Skript.debug())
Skript.info(getIndentation() + "... continuing after " + (System.nanoTime() - start) / 1000000000. + "s");
TriggerItem.walk(next, e);
}
}, d.getTicks());
}
return null;
}
示例7: walk
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@Override
@Nullable
protected TriggerItem walk(final Event e) {
debug(e, true);
final long start = Skript.debug() ? System.nanoTime() : 0;
final TriggerItem next = getNext();
if (next != null) {
delayed.add(e);
final Timespan d = duration.getSingle(e);
if (d == null)
return null;
Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
@Override
public void run() {
if (Skript.debug())
Skript.info(getIndentation() + "... continuing after " + (System.nanoTime() - start) / 1000000000. + "s");
TriggerItem.walk(next, e);
}
}, d.getTicks_i());
}
return null;
}
示例8: 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();
}
}
}
};
}
示例9: test
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@Test
public void test() {
final Object[] random = {
// Java
(byte) 127, (short) 2000, -1600000, 1L << 40, -1.5f, 13.37,
"String",
// Skript
Color.BLACK, StructureType.RED_MUSHROOM, WeatherType.THUNDER,
new Date(System.currentTimeMillis()), new Timespan(1337), new Time(12000), new Timeperiod(1000, 23000),
new Experience(15), new Direction(0, Math.PI, 10), new Direction(new double[] {0, 1, 0}),
new EntityType(new SimpleEntityData(HumanEntity.class), 300), new CreeperData(), new SimpleEntityData(Snowball.class), new HorseData(Variant.SKELETON_HORSE), new WolfData(), new XpOrbData(50),
// Bukkit - simple classes only
GameMode.ADVENTURE, Biome.EXTREME_HILLS, DamageCause.FALL,
// there is also at least one variable for each class on my test server which are tested whenever the server shuts down.
};
for (final Object o : random) {
Classes.serialize(o); // includes a deserialisation test
}
}
示例10: init
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
if (matchedPattern == 0) {
title = (Expression<String>) e[0];
subtitle = (Expression<String>) e[1];
players = (Expression<Player>) e[2];
} else {
players = (Expression<Player>) e[0];
title = (Expression<String>) e[1];
subtitle = (Expression<String>) e[2];
}
time = (Expression<Timespan>) e[3];
fadeIn = (Expression<Timespan>) e[4];
fadeOut = (Expression<Timespan>) e[5];
return true;
}
示例11: init
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@Override
public boolean init(Expression<?>[] expr, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
type = (Expression<PotionEffectType>) expr[0];
duration = (Expression<Timespan>) expr[1];
level = (Expression<Number>) expr[2];
particles = (Expression<Boolean>) expr[3];
ambient = (Expression<Boolean>) expr[4];
color = (Expression<Color>) expr[5];
return true;
}
示例12: acceptChange
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@Nullable
@Override
public Class<?>[] acceptChange(Changer.ChangeMode mode) {
if (mode != Changer.ChangeMode.REMOVE_ALL && mode != Changer.ChangeMode.RESET
&& mode != Changer.ChangeMode.DELETE) {
return CollectionUtils.array(Timespan.class);
}
return null;
}
示例13: getTimeExpr
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
public static Expression<Timespan> getTimeExpr(int i, Expression<?>[] expressions) {
if (i == 2 || i == 3) {
return (Expression<Timespan>) expressions[1];
} else {
return (Expression<Timespan>) expressions[2];
}
}
示例14: get
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@Override
protected Timespan[] get(Event event) {
World world = worldExpression.getSingle(event);
if (world.getWorldBorder() instanceof WorldBorderImpl) {
WorldBorderImpl border = (WorldBorderImpl) world.getWorldBorder();
Double timeInSeconds = border.remainingTimeInSeconds();
Timespan result = new Timespan((long) (timeInSeconds * 1000));
return new Timespan[]{result};
}
return new Timespan[0];
}
示例15: init
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] expr, int matchedPattern,
Kleenean paramKleenean, ParseResult paramParseResult) {
msgs = (Expression<String>) expr[0];
ip = (Expression<String>) expr[1];
port = (Expression<Number>) expr[2];
timeout = (Expression<Timespan>) expr[3];
redirect = (Expression<String>) expr[4];
report = (Expression<String>) expr[5];
return true;
}