Skip to content
Permalink
Browse files
Add get_world_day
  • Loading branch information
Murreey committed Aug 15, 2020
1 parent ed12160 commit 2cac88e3d9ed5ad70a331533552745f389813f84
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
@@ -136,6 +136,8 @@ public interface MCWorld extends MCMetadatable {

void setFullTime(long time);

long getFullTime();

CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation location, Target t);

MCFallingBlock spawnFallingBlock(MCLocation loc, MCBlockData data);
@@ -479,6 +479,11 @@ public void setFullTime(long time) {
w.setFullTime(time);
}

@Override
public long getFullTime() {
return w.getFullTime();
}

@Override
public MCBiomeType getBiome(int x, int z) {
return BukkitMCBiomeType.valueOfConcrete(w.getBiome(x, z));
@@ -940,6 +940,61 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
return CVoid.VOID;
}
}

@api(environments = CommandHelperEnvironment.class)
public static class get_world_day extends AbstractFunction {

@Override
public String getName() {
return "get_world_day";
}

@Override
public Integer[] numArgs() {
return new Integer[]{0, 1};
}

@Override
public String docs() {
return "int {[world]} Returns the current day number of the specified world";
}

@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[]{CREInvalidWorldException.class};
}

@Override
public boolean isRestricted() {
return true;
}

@Override
public MSVersion since() {
return MSVersion.V3_3_4;
}

@Override
public Boolean runAsync() {
return false;
}

@Override
public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException {
MCWorld w = null;
if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) {
w = environment.getEnv(CommandHelperEnvironment.class).GetPlayer().getWorld();
}
if(args.length == 1) {
w = Static.getServer().getWorld(args[0].val());
}
if(w == null) {
throw new CREInvalidWorldException("No world specified", t);
}
return new CInt((long) java.lang.Math.floor(w.getFullTime() / 24000), t);
}
}

@api(environments = {CommandHelperEnvironment.class})
public static class create_world extends AbstractFunction {

0 comments on commit 2cac88e

Please sign in to comment.