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

long getTime();

void setFullTime(long time);

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

MCFallingBlock spawnFallingBlock(MCLocation loc, MCBlockData data);
@@ -474,6 +474,11 @@ public long getTime() {
return w.getTime();
}

@Override
public void setFullTime(long time) {
w.setFullTime(time);
}

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

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

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

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

@Override
public String docs() {
return "void {[world], day} Set the current day number of a given 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 == 2) {
w = Static.getServer().getWorld(args[0].val());
}
if(w == null) {
throw new CREInvalidWorldException("No world specified", t);
}

int day = ArgumentValidation.getInt32((args.length == 1 ? args[0] : args[1]), t);
if(day < 0) {
throw new CRERangeException("Day cannot be negative.", t);
}

w.setFullTime((day * 24000) + w.getTime());
return CVoid.VOID;
}
}
@api(environments = {CommandHelperEnvironment.class})
public static class create_world extends AbstractFunction {

0 comments on commit ed12160

Please sign in to comment.