Working on changeLog creation
This commit is contained in:
parent
871bc0cf65
commit
05cd6b85f6
4 changed files with 192 additions and 147 deletions
|
@ -1,176 +1,201 @@
|
|||
package universalelectricity.core.electricity;
|
||||
|
||||
/**
|
||||
* An easy way to display information on electricity for the client.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
|
||||
/** An easy way to display information on electricity for the client.
|
||||
*
|
||||
* @author Calclavia */
|
||||
public class ElectricityDisplay
|
||||
{
|
||||
/**
|
||||
* Universal Electricity's units are in KILOJOULES, KILOWATTS and KILOVOLTS. Try to make your
|
||||
* energy ratio as close to real life as possible.
|
||||
*
|
||||
*/
|
||||
public static enum ElectricUnit
|
||||
{
|
||||
AMPERE("Amp", "I"), AMP_HOUR("Amp Hour", "Ah"), VOLTAGE("Volt", "V"), WATT("Watt", "W"),
|
||||
WATT_HOUR("Watt Hour", "Wh"), RESISTANCE("Ohm", "R"), CONDUCTANCE("Siemen", "S"),
|
||||
JOULES("Joule", "J");
|
||||
/** Universal Electricity's units are in KILOJOULES, KILOWATTS and KILOVOLTS. Try to make your
|
||||
* energy ratio as close to real life as possible. */
|
||||
public static enum ElectricUnit
|
||||
{
|
||||
AMPERE("Amp", "I"),
|
||||
AMP_HOUR("Amp Hour", "Ah"),
|
||||
VOLTAGE("Volt", "V"),
|
||||
WATT("Watt", "W"),
|
||||
WATT_HOUR("Watt Hour", "Wh"),
|
||||
RESISTANCE("Ohm", "R"),
|
||||
CONDUCTANCE("Siemen", "S"),
|
||||
JOULES("Joule", "J");
|
||||
|
||||
public String name;
|
||||
public String symbol;
|
||||
public String name;
|
||||
public String symbol;
|
||||
|
||||
private ElectricUnit(String name, String symbol)
|
||||
{
|
||||
this.name = name;
|
||||
this.symbol = symbol;
|
||||
}
|
||||
private ElectricUnit(String name, String symbol)
|
||||
{
|
||||
this.name = name;
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
public String getPlural()
|
||||
{
|
||||
return this.name + "s";
|
||||
}
|
||||
}
|
||||
public String getPlural()
|
||||
{
|
||||
return this.name + "s";
|
||||
}
|
||||
}
|
||||
|
||||
public static enum MeasurementUnit
|
||||
{
|
||||
MICRO("Micro", "mi", 0.000001), MILLI("Milli", "m", 0.001), KILO("Kilo", "k", 1000),
|
||||
MEGA("Mega", "M", 1000000), GIGA("Giga", "G", 1000000000);
|
||||
/** Metric system of measurement. */
|
||||
public static enum MeasurementUnit
|
||||
{
|
||||
MICRO("Micro", "u", 0.000001f),
|
||||
MILLI("Milli", "m", 0.001f),
|
||||
BASE("", "", 1),
|
||||
KILO("Kilo", "k", 1000f),
|
||||
MEGA("Mega", "M", 1000000f),
|
||||
GIGA("Giga", "G", 1000000000f),
|
||||
TERA("Tera", "T", 1000000000000f),
|
||||
PETA("Peta", "P", 1000000000000000f),
|
||||
EXA("Exa", "E", 1000000000000000000f),
|
||||
ZETTA("Zetta", "Z", 1000000000000000000000f),
|
||||
YOTTA("Yotta", "Y", 1000000000000000000000000f);
|
||||
|
||||
public String name;
|
||||
public String symbol;
|
||||
public double value;
|
||||
/** long name for the unit */
|
||||
public String name;
|
||||
/** short unit version of the unit */
|
||||
public String symbol;
|
||||
/** Point by which a number is consider to be of this unit */
|
||||
public float value;
|
||||
|
||||
private MeasurementUnit(String name, String symbol, double value)
|
||||
{
|
||||
this.name = name;
|
||||
this.symbol = symbol;
|
||||
this.value = value;
|
||||
}
|
||||
private MeasurementUnit(String name, String symbol, float value)
|
||||
{
|
||||
this.name = name;
|
||||
this.symbol = symbol;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName(boolean isSymbol)
|
||||
{
|
||||
if (isSymbol)
|
||||
{
|
||||
return symbol;
|
||||
}
|
||||
else
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
public String getName(boolean getShort)
|
||||
{
|
||||
if (getShort)
|
||||
{
|
||||
return symbol;
|
||||
}
|
||||
else
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public double process(double value)
|
||||
{
|
||||
return value / this.value;
|
||||
}
|
||||
}
|
||||
/** Divides the value by the unit value start */
|
||||
public double process(double value)
|
||||
{
|
||||
return value / this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, mods should store energy in Kilo-Joules, hence a multiplier of 1/1000.
|
||||
*/
|
||||
public static String getDisplay(float value, ElectricUnit unit, int decimalPlaces, boolean isShort)
|
||||
{
|
||||
return getDisplay(value, unit, decimalPlaces, isShort, 1000);
|
||||
}
|
||||
/** Checks if a value is above the unit value start */
|
||||
public boolean isAbove(float value)
|
||||
{
|
||||
return value > this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the unit as text. Works only for positive numbers.
|
||||
*/
|
||||
public static String getDisplay(float value, ElectricUnit unit, int decimalPlaces, boolean isShort, float multiplier)
|
||||
{
|
||||
value *= multiplier;
|
||||
/** Checks if a value is lower than the unit value start */
|
||||
public boolean isBellow(float value)
|
||||
{
|
||||
return value < this.value;
|
||||
}
|
||||
}
|
||||
|
||||
String unitName = unit.name;
|
||||
/** By default, mods should store energy in Kilo-Joules, hence a multiplier of 1/1000. */
|
||||
public static String getDisplay(float value, ElectricUnit unit, int decimalPlaces, boolean isShort)
|
||||
{
|
||||
return getDisplay(value, unit, decimalPlaces, isShort, 1000);
|
||||
}
|
||||
|
||||
if (isShort)
|
||||
{
|
||||
unitName = unit.symbol;
|
||||
}
|
||||
else if (value > 1)
|
||||
{
|
||||
unitName = unit.getPlural();
|
||||
}
|
||||
/** Displays the unit as text. Does handle negative numbers, and will place a negative sign in
|
||||
* front of the output string showing this. Use string.replace to remove the negative sign if unwanted */
|
||||
public static String getDisplay(float value, ElectricUnit unit, int decimalPlaces, boolean isShort, float multiplier)
|
||||
{
|
||||
String unitName = unit.name;
|
||||
String prefix = "";
|
||||
if (value < 0)
|
||||
{
|
||||
value = Math.abs(value);
|
||||
prefix = "-";
|
||||
}
|
||||
value *= multiplier;
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
return value + " " + unitName;
|
||||
}
|
||||
if (isShort)
|
||||
{
|
||||
unitName = unit.symbol;
|
||||
}
|
||||
else if (value > 1)
|
||||
{
|
||||
unitName = unit.getPlural();
|
||||
}
|
||||
|
||||
if (value <= MeasurementUnit.MILLI.value)
|
||||
{
|
||||
return roundDecimals(MeasurementUnit.MICRO.process(value), decimalPlaces) + " " + MeasurementUnit.MICRO.getName(isShort) + unitName;
|
||||
}
|
||||
if (value == 0)
|
||||
{
|
||||
return value + " " + unitName;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < MeasurementUnit.values().length; i++)
|
||||
{
|
||||
MeasurementUnit lowerMeasure = MeasurementUnit.values()[i];
|
||||
if (lowerMeasure.isBellow(value) && lowerMeasure.ordinal() == 0)
|
||||
{
|
||||
return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName;
|
||||
}
|
||||
if (lowerMeasure.ordinal() + 1 >= MeasurementUnit.values().length)
|
||||
{
|
||||
return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName;
|
||||
}
|
||||
MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1];
|
||||
if ((lowerMeasure.isAbove(value) && upperMeasure.isBellow(value)) || lowerMeasure.value == value)
|
||||
{
|
||||
return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (value < 1)
|
||||
{
|
||||
return roundDecimals(MeasurementUnit.MILLI.process(value), decimalPlaces) + " " + MeasurementUnit.MILLI.getName(isShort) + unitName;
|
||||
}
|
||||
return prefix + roundDecimals(value, decimalPlaces) + " " + unitName;
|
||||
}
|
||||
|
||||
if (value > MeasurementUnit.MEGA.value)
|
||||
{
|
||||
return roundDecimals(MeasurementUnit.MEGA.process(value), decimalPlaces) + " " + MeasurementUnit.MEGA.getName(isShort) + unitName;
|
||||
}
|
||||
public static String getDisplay(float value, ElectricUnit unit)
|
||||
{
|
||||
return getDisplay(value, unit, 2, false);
|
||||
}
|
||||
|
||||
if (value > MeasurementUnit.KILO.value)
|
||||
{
|
||||
return roundDecimals(MeasurementUnit.KILO.process(value), decimalPlaces) + " " + MeasurementUnit.KILO.getName(isShort) + unitName;
|
||||
}
|
||||
public static String getDisplayShort(float value, ElectricUnit unit)
|
||||
{
|
||||
return getDisplay(value, unit, 2, true);
|
||||
}
|
||||
|
||||
return roundDecimals(value, decimalPlaces) + " " + unitName;
|
||||
}
|
||||
public static String getDisplayShort(float value, ElectricUnit unit, int decimalPlaces)
|
||||
{
|
||||
return getDisplay(value, unit, decimalPlaces, true);
|
||||
}
|
||||
|
||||
public static String getDisplay(float value, ElectricUnit unit)
|
||||
{
|
||||
return getDisplay(value, unit, 2, false);
|
||||
}
|
||||
public static String getDisplaySimple(float value, ElectricUnit unit, int decimalPlaces)
|
||||
{
|
||||
if (value > 1)
|
||||
{
|
||||
if (decimalPlaces < 1)
|
||||
{
|
||||
return (int) value + " " + unit.getPlural();
|
||||
}
|
||||
|
||||
public static String getDisplayShort(float value, ElectricUnit unit)
|
||||
{
|
||||
return getDisplay(value, unit, 2, true);
|
||||
}
|
||||
return roundDecimals(value, decimalPlaces) + " " + unit.getPlural();
|
||||
}
|
||||
|
||||
public static String getDisplayShort(float value, ElectricUnit unit, int decimalPlaces)
|
||||
{
|
||||
return getDisplay(value, unit, decimalPlaces, true);
|
||||
}
|
||||
if (decimalPlaces < 1)
|
||||
{
|
||||
return (int) value + " " + unit.name;
|
||||
}
|
||||
|
||||
public static String getDisplaySimple(float value, ElectricUnit unit, int decimalPlaces)
|
||||
{
|
||||
if (value > 1)
|
||||
{
|
||||
if (decimalPlaces < 1)
|
||||
{
|
||||
return (int) value + " " + unit.getPlural();
|
||||
}
|
||||
return roundDecimals(value, decimalPlaces) + " " + unit.name;
|
||||
}
|
||||
|
||||
return roundDecimals(value, decimalPlaces) + " " + unit.getPlural();
|
||||
}
|
||||
/** Rounds a number to a specific number place places
|
||||
*
|
||||
* @param The number
|
||||
* @return The rounded number */
|
||||
public static double roundDecimals(double d, int decimalPlaces)
|
||||
{
|
||||
int j = (int) (d * Math.pow(10, decimalPlaces));
|
||||
return j / Math.pow(10, decimalPlaces);
|
||||
}
|
||||
|
||||
if (decimalPlaces < 1)
|
||||
{
|
||||
return (int) value + " " + unit.name;
|
||||
}
|
||||
|
||||
return roundDecimals(value, decimalPlaces) + " " + unit.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounds a number to a specific number place places
|
||||
*
|
||||
* @param The number
|
||||
* @return The rounded number
|
||||
*/
|
||||
public static double roundDecimals(double d, int decimalPlaces)
|
||||
{
|
||||
int j = (int) (d * Math.pow(10, decimalPlaces));
|
||||
return j / Math.pow(10, decimalPlaces);
|
||||
}
|
||||
|
||||
public static double roundDecimals(double d)
|
||||
{
|
||||
return roundDecimals(d, 2);
|
||||
}
|
||||
public static double roundDecimals(double d)
|
||||
{
|
||||
return roundDecimals(d, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
<exec dir="${dir.development}" executable="bash" osfamily="unix">
|
||||
<arg line="git.sh" />
|
||||
</exec>
|
||||
<exec dir="${dir.development}" executable="cmd" osfamily="windows">
|
||||
<arg line="gitLog.bat" />
|
||||
</exec>
|
||||
<exec dir="${dir.development}" executable="bash" osfamily="unix">
|
||||
<arg line="gitLog.sh" />
|
||||
</exec>
|
||||
<copy todir="${dir.mcp}/src/minecraft">
|
||||
|
||||
<fileset dir="${dir.development}src">
|
||||
|
|
1
gitLog.bat
Normal file
1
gitLog.bat
Normal file
|
@ -0,0 +1 @@
|
|||
git log --pretty="%s" >> changeLog.txt
|
13
gitLog.sh
Normal file
13
gitLog.sh
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
GIT_LOG_FORMAT="%ai %an: %s"
|
||||
USER=<username>
|
||||
API_TOKEN=<api_token>
|
||||
|
||||
LAST_SUCCESS_URL_SUFFIX="lastSuccessfulBuild/api/xml"
|
||||
#JOB_URL gets populated by Jenkins as part of the build environment
|
||||
URL="$JOB_URL$LAST_SUCCESS_URL_SUFFIX"
|
||||
|
||||
LAST_SUCCESS_REV=$(curl --silent --user $USER:$API_TOKEN $URL | grep "<lastBuiltRevision>" | sed 's|.*<lastBuiltRevision>.*<SHA1>\(.*\)</SHA1>.*<branch>.*|\1|')
|
||||
# Pulls all commit comments since the last successfully built revision
|
||||
LOG=$(git log --pretty="$GIT_LOG_FORMAT" $LAST_SUCCESS_REV..HEAD)
|
||||
echo $LOG
|
Loading…
Add table
Reference in a new issue