Added /worldedit tz to set your timezone. It currently does not persist yet. Example: /we tz america/los_angeles

This commit is contained in:
sk89q 2011-03-13 20:36:28 -07:00
parent 12ba1a9fc4
commit 66edfbbae6

View File

@ -19,6 +19,10 @@
package com.sk89q.worldedit.commands;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
@ -29,6 +33,8 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
public class WorldEditCommands {
private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
@Command(
aliases = {"version", "ver"},
usage = "",
@ -73,4 +79,21 @@ public class WorldEditCommands {
session.setCUISupport(true);
session.dispatchCUISetup(player);
}
@Command(
aliases = {"tz"},
usage = "[timezone]",
desc = "Set your timezone",
min = 1,
max = 1
)
public static void tz(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
TimeZone tz = TimeZone.getTimeZone(args.getString(0));
session.setTimezone(tz);
player.print("Timezone set for this session to: " + tz.getDisplayName());
player.print("The current time in that timezone is: "
+ dateFormat.format(Calendar.getInstance(tz).getTime()));
}
}