本文整理汇总了Java中ch.njol.skript.util.Timespan类的典型用法代码示例。如果您正苦于以下问题:Java Timespan类的具体用法?Java Timespan怎么用?Java Timespan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Timespan类属于ch.njol.skript.util包,在下文中一共展示了Timespan类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:18,代码来源:SExprItemEffectTypeDuration.java
示例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).");
}
开发者ID:MundoSK,项目名称:MundoSK,代码行数:26,代码来源:WorldBorderMundo.java
示例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;
}
}
开发者ID:nfell2009,项目名称:Skript,代码行数:18,代码来源:ExprTime.java
示例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);
}
}
}
开发者ID:nfell2009,项目名称:Skript,代码行数:21,代码来源:EffPoison.java
示例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);
}
}
}
开发者ID:nfell2009,项目名称:Skript,代码行数:27,代码来源:EffIgnite.java
示例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;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:23,代码来源:IndeterminateDelay.java
示例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;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:23,代码来源:Delay.java
示例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();
}
}
}
};
}
开发者ID:nfell2009,项目名称:Skript,代码行数:21,代码来源:VariablesStorage.java
示例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
}
}
开发者ID:nfell2009,项目名称:Skript,代码行数:24,代码来源:ClassesTest.java
示例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;
}
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:18,代码来源:EffTitle.java
示例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;
}
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:11,代码来源:ExprCustomPotionEffect.java
示例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;
}
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:10,代码来源:SExprItemEffectTypeDuration.java
示例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];
}
}
开发者ID:MundoSK,项目名称:MundoSK,代码行数:8,代码来源:EffChangeBorderDiameter.java
示例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];
}
开发者ID:MundoSK,项目名称:MundoSK,代码行数:12,代码来源:ExprTimeRemainingUntilBorderStabilize.java
示例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;
}
开发者ID:MundoSK,项目名称:MundoSK,代码行数:13,代码来源:EffWriteToSocket.java
示例16: init
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
// TODO Auto-generated method stub
host = (Expression<String>) expr[0];
port = (Expression<Number>) expr[1];
timeout = (Expression<Timespan>) expr[2];
return true;
}
开发者ID:MundoSK,项目名称:MundoSK,代码行数:10,代码来源:CondServerSocketIsOpen.java
示例17: 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
示例18: init
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
date = (Expression<Date>) exprs[0];
delta = (Expression<Timespan>) exprs[1];
setNegated(matchedPattern == 1);
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:9,代码来源:CondDate.java
示例19: check
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
@Override
public boolean check(final Event e) {
final long now = System.currentTimeMillis();
return date.check(e, new Checker<Date>() {
@Override
public boolean check(final Date d) {
return delta.check(e, new Checker<Timespan>() {
@Override
public boolean check(final Timespan t) {
return now - d.getTimestamp() >= t.getMilliSeconds();
}
}, isNegated());
}
});
}
开发者ID:nfell2009,项目名称:Skript,代码行数:16,代码来源:CondDate.java
示例20: start
import ch.njol.skript.util.Timespan; //导入依赖的package包/类
static void start() {
checkerTask = new Task(Skript.getInstance(), 0, true) {
@SuppressWarnings("null")
@Override
public void run() {
if (!SkriptConfig.checkForNewVersion.value())
return;
check(Bukkit.getConsoleSender(), SkriptConfig.automaticallyDownloadNewVersion.value(), true);
final Timespan t = SkriptConfig.updateCheckInterval.value();
if (t.getTicks_i() != 0)
setNextExecution(t.getTicks_i());
}
};
}
开发者ID:nfell2009,项目名称:Skript,代码行数:15,代码来源:Updater.java
注:本文中的ch.njol.skript.util.Timespan类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论