Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
+58 -57
View File
@@ -18,6 +18,7 @@
package appeng.util;
import java.util.Comparator;
import appeng.api.config.SortDir;
@@ -27,108 +28,108 @@ import appeng.integration.IntegrationType;
import appeng.integration.abstraction.IInvTweaks;
import appeng.util.item.AEItemStack;
public class ItemSorters
{
public static SortDir Direction = SortDir.ASCENDING;
private static IInvTweaks api;
public static void init()
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_NAME = new Comparator<IAEItemStack>()
{
if ( api != null )
return;
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.InvTweaks ) )
api = (IInvTweaks) AppEng.instance.getIntegration( IntegrationType.InvTweaks );
else
api = null;
}
public static int compareInt(int a, int b)
{
if ( a == b )
return 0;
if ( a < b )
return -1;
return 1;
}
public static int compareLong(long a, long b)
{
if ( a == b )
return 0;
if ( a < b )
return -1;
return 1;
}
public static int compareDouble(double a, double b)
{
if ( a == b )
return 0;
if ( a < b )
return -1;
return 1;
}
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_NAME = new Comparator<IAEItemStack>() {
@Override
public int compare(IAEItemStack o1, IAEItemStack o2)
public int compare( IAEItemStack o1, IAEItemStack o2 )
{
if ( Direction == SortDir.ASCENDING )
if( Direction == SortDir.ASCENDING )
return Platform.getItemDisplayName( o1 ).compareToIgnoreCase( Platform.getItemDisplayName( o2 ) );
return Platform.getItemDisplayName( o2 ).compareToIgnoreCase( Platform.getItemDisplayName( o1 ) );
}
};
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_MOD = new Comparator<IAEItemStack>() {
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_MOD = new Comparator<IAEItemStack>()
{
@Override
public int compare(IAEItemStack o1, IAEItemStack o2)
public int compare( IAEItemStack o1, IAEItemStack o2 )
{
AEItemStack op1 = (AEItemStack) o1;
AEItemStack op2 = (AEItemStack) o2;
if ( Direction == SortDir.ASCENDING )
if( Direction == SortDir.ASCENDING )
return this.secondarySort( op2.getModID().compareToIgnoreCase( op1.getModID() ), o1, o2 );
return this.secondarySort( op1.getModID().compareToIgnoreCase( op2.getModID() ), o2, o1 );
}
private int secondarySort(int compareToIgnoreCase, IAEItemStack o1, IAEItemStack o2)
private int secondarySort( int compareToIgnoreCase, IAEItemStack o1, IAEItemStack o2 )
{
if ( compareToIgnoreCase == 0 )
if( compareToIgnoreCase == 0 )
return Platform.getItemDisplayName( o2 ).compareToIgnoreCase( Platform.getItemDisplayName( o1 ) );
return compareToIgnoreCase;
}
};
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_SIZE = new Comparator<IAEItemStack>() {
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_SIZE = new Comparator<IAEItemStack>()
{
@Override
public int compare(IAEItemStack o1, IAEItemStack o2)
public int compare( IAEItemStack o1, IAEItemStack o2 )
{
if ( Direction == SortDir.ASCENDING )
if( Direction == SortDir.ASCENDING )
return compareLong( o2.getStackSize(), o1.getStackSize() );
return compareLong( o1.getStackSize(), o2.getStackSize() );
}
};
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_INV_TWEAKS = new Comparator<IAEItemStack>() {
private static IInvTweaks api;
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_INV_TWEAKS = new Comparator<IAEItemStack>()
{
@Override
public int compare(IAEItemStack o1, IAEItemStack o2)
public int compare( IAEItemStack o1, IAEItemStack o2 )
{
if ( api == null )
if( api == null )
return CONFIG_BASED_SORT_BY_NAME.compare( o1, o2 );
int cmp = api.compareItems( o1.getItemStack(), o2.getItemStack() );
if ( Direction == SortDir.ASCENDING )
if( Direction == SortDir.ASCENDING )
return cmp;
return -cmp;
}
};
public static void init()
{
if( api != null )
return;
if( AppEng.instance.isIntegrationEnabled( IntegrationType.InvTweaks ) )
api = (IInvTweaks) AppEng.instance.getIntegration( IntegrationType.InvTweaks );
else
api = null;
}
public static int compareInt( int a, int b )
{
if( a == b )
return 0;
if( a < b )
return -1;
return 1;
}
public static int compareLong( long a, long b )
{
if( a == b )
return 0;
if( a < b )
return -1;
return 1;
}
public static int compareDouble( double a, double b )
{
if( a == b )
return 0;
if( a < b )
return -1;
return 1;
}
}