Java Code Examples for org.bukkit.World#setTime()

The following examples show how to use org.bukkit.World#setTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PermadayCommand.java    From UHC with MIT License 5 votes vote down vote up
@Override
protected boolean runCommand(CommandSender sender, OptionSet options) {
    List<World> worlds = worldsSpec.values(options);

    if (worlds.size() == 0) {
        if (!(sender instanceof Player)) {
            sender.sendMessage(messages.getRaw("provide world"));
            return true;
        }

        worlds = Lists.newArrayList(((Player) sender).getWorld());
    }

    final boolean on = !options.has(turnOff);

    for (final World world : worlds) {
        if (on) {
            world.setGameRuleValue(DO_DAYLIGHT_CYCLE_GAMERULE, "false");
            world.setTime(SUN_OVERHEAD_TIME);
        } else {
            world.setGameRuleValue(DO_DAYLIGHT_CYCLE_GAMERULE, "true");
        }

        final String message = messages.evalTemplate(
                on ? "on notification" : "off notification",
                ImmutableMap.of("world", world.getName())
        );

        for (final Player player : world.getPlayers()) {
            player.sendMessage(message);
        }
    }

    sender.sendMessage(messages.evalTemplate(
            on ? "on completed" : "off completed",
            ImmutableMap.of("count", worlds.size())
    ));

    return true;
}
 
Example 2
Source File: TimeEvent.java    From BetonQuest with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Void execute(String playerID) {
    World world = PlayerConverter.getPlayer(playerID).getWorld();
    long time = amount;
    if (add) {
        time += world.getTime();
    }
    world.setTime(time % 24000);
    return null;
}
 
Example 3
Source File: PermaKillListener.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
    World world = getGameManager().getLobby().getLoc().getWorld();
    world.setTime(world.getTime() + 12000);
}
 
Example 4
Source File: EnablePermanentDayThread.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void run() {
    World overWorld = Bukkit.getWorld(GameManager.getGameManager().getConfiguration().getOverworldUuid());
    VersionUtils.getVersionUtils().setGameRuleValue(overWorld, "doDaylightCycle", "false");
    overWorld.setTime(6000);
}
 
Example 5
Source File: TimeFeature.java    From VoxelGamesLibv2 with MIT License 4 votes vote down vote up
@Override
public void enable() {
    World world = getPhase().getFeature(MapFeature.class).getWorld();
    world.setGameRuleValue("doDaylightCycle", shouldChange + "");
    world.setTime(time);
}
 
Example 6
Source File: NoTimeChangeFeature.java    From VoxelGamesLibv2 with MIT License 4 votes vote down vote up
@Override
public void enable() {
    World w = getPhase().getFeature(MapFeature.class).getWorld();
    w.setTime(time);
    w.setGameRuleValue("doDaylightCycle", "false");
}