mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-28 18:21:23 +01:00
Correct code format for file DescParseTickFormat
This commit is contained in:
parent
b07ba21659
commit
f75390bd3f
@ -6,6 +6,7 @@ import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* This utility class is used for converting between the ingame
|
||||
* time in ticks to ingame time as a friendly string.
|
||||
@ -15,25 +16,23 @@ import java.util.logging.Logger;
|
||||
*
|
||||
* @author Olof Larsson
|
||||
*/
|
||||
public class DescParseTickFormat {
|
||||
|
||||
public class DescParseTickFormat
|
||||
{
|
||||
// ============================================
|
||||
// First some information vars. TODO: Should this be in a config file?
|
||||
// --------------------------------------------
|
||||
|
||||
public static final Map<String, Integer> nameToTicks = new LinkedHashMap<String, Integer>();
|
||||
public static final Set<String> resetAliases = new HashSet<String>();
|
||||
|
||||
public static final int ticksAtMidnight = 18000;
|
||||
public static final int ticksPerDay = 24000;
|
||||
public static final int ticksPerHour = 1000;
|
||||
public static final double ticksPerMinute = 1000d / 60d;
|
||||
public static final double ticksPerSecond = 1000d / 60d / 60d;
|
||||
|
||||
private static final SimpleDateFormat SDFTwentyFour = new SimpleDateFormat("HH:mm", Locale.ENGLISH);
|
||||
private static final SimpleDateFormat SDFTwelve = new SimpleDateFormat("h:mmaa", Locale.ENGLISH);
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
|
||||
nameToTicks.put("sunrise", 22000);
|
||||
nameToTicks.put("rise", 22000);
|
||||
@ -68,7 +67,6 @@ public class DescParseTickFormat {
|
||||
// ============================================
|
||||
// PARSE. From describing String to int
|
||||
// --------------------------------------------
|
||||
|
||||
public static long parse(String desc) throws NumberFormatException
|
||||
{
|
||||
Long ret;
|
||||
@ -77,16 +75,40 @@ public class DescParseTickFormat {
|
||||
desc = desc.toLowerCase().replaceAll("[^A-Za-z0-9]", "");
|
||||
|
||||
// Detect ticks format
|
||||
try { return parseTicks(desc); } catch (Exception e) {}
|
||||
try
|
||||
{
|
||||
return parseTicks(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect 24-hour format
|
||||
try { return parse24(desc); } catch (Exception e) {}
|
||||
try
|
||||
{
|
||||
return parse24(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect 12-hour format
|
||||
try { return parse12(desc); } catch (Exception e) {}
|
||||
try
|
||||
{
|
||||
return parse12(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect aliases
|
||||
try { return parseAlias(desc); } catch (Exception e) {}
|
||||
try
|
||||
{
|
||||
return parseAlias(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Well we failed to understand...
|
||||
throw new NumberFormatException();
|
||||
@ -201,7 +223,6 @@ public class DescParseTickFormat {
|
||||
// ============================================
|
||||
// FORMAT. From int to describing String
|
||||
// --------------------------------------------
|
||||
|
||||
public static String format(long ticks)
|
||||
{
|
||||
StringBuilder msg = new StringBuilder();
|
||||
|
Loading…
Reference in New Issue
Block a user