Add date/time variables for commands/schematics

Fixes #21
This commit is contained in:
Thijs Wiefferink 2015-07-26 20:15:45 +02:00
parent 2f9b6d3987
commit 3bf493109c
3 changed files with 37 additions and 0 deletions

View File

@ -105,6 +105,16 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
public static final String tagMaxInactiveTime = "%inactivetime%";
public static final String tagLandlord = "%landlord%";
public static final String tagLandlordUUID = "%landlorduuid%";
public static final String tagDateTime = "%datetime%";
public static final String tagDateTimeShort = "%datetimeshort%";
public static final String tagYear = "%year%";
public static final String tagMonth = "%month%";
public static final String tagDay = "%day%";
public static final String tagHour = "%hour%";
public static final String tagMinute = "%minute%";
public static final String tagSecond = "%second%";
public static final String tagMillisecond = "%millisecond%";
public static final String tagEpoch = "%epoch%";
public static AreaShop getInstance() {
return AreaShop.instance;

View File

@ -2,8 +2,10 @@ package nl.evolutioncoding.areashop.regions;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -466,6 +468,23 @@ public abstract class GeneralRegion implements GeneralRegionInterface {
result.put(AreaShop.tagFriendsUUID, Utils.createCommaSeparatedList(getFriends()));
result.put(AreaShop.tagLandlord, getLandlordName());
result.put(AreaShop.tagLandlordUUID, getLandlord());
// Date/time stuff
Calendar calendar = Calendar.getInstance();
result.put(AreaShop.tagEpoch, calendar.getTimeInMillis());
result.put(AreaShop.tagMillisecond, calendar.get(Calendar.MILLISECOND));
result.put(AreaShop.tagSecond, calendar.get(Calendar.SECOND));
result.put(AreaShop.tagMinute, calendar.get(Calendar.MINUTE));
result.put(AreaShop.tagHour, calendar.get(Calendar.HOUR_OF_DAY));
result.put(AreaShop.tagDay, calendar.get(Calendar.DAY_OF_MONTH));
result.put(AreaShop.tagMonth, calendar.get(Calendar.MONTH));
result.put(AreaShop.tagYear, calendar.get(Calendar.YEAR));
// In specified format
SimpleDateFormat date = new SimpleDateFormat(plugin.getConfig().getString("timeFormatChat"));
String dateString = date.format(Calendar.getInstance().getTime());
result.put(AreaShop.tagDateTime, dateString);
date = new SimpleDateFormat(plugin.getConfig().getString("timeFormatSign"));
dateString = date.format(Calendar.getInstance().getTime());
result.put(AreaShop.tagDateTimeShort, dateString);
// TODO: add more? coordinates?

View File

@ -129,6 +129,14 @@ limitGroups:
## %extendsleft% The number of extends that are left (maxextends - timesextended)
## %maxrenttime% The maximum time you can rent a region in advance (human readable)
## %inactivetime% The maximum time a player may be inactive before unrent/sell (human readable)
## %year% The current year
## %month% The current month in the year
## %day% The current day in the month
## %hour% The current hour in the day (0-23)
## %minute% The current minute of the hour
## %second% The current second of the minute
## %millisecond% The current millisecond of the second
## %epoch% The number of milliseconds since January 1, 1970 (Unix Epoch)
## Below are profiles for the signs, you can assign profiles to regions
## by setting 'general.signProfile' in default.yml, groups or individual regions