Basic reformat, hit once, hope never again
This commit is contained in:
@@ -44,22 +44,22 @@ public class AchievementCraftingHandler
|
||||
@SubscribeEvent
|
||||
public void onPlayerCraftingEvent( PlayerEvent.ItemCraftedEvent event )
|
||||
{
|
||||
if ( this.differentiator.isNoPlayer( event.player ) || event.crafting == null )
|
||||
if( this.differentiator.isNoPlayer( event.player ) || event.crafting == null )
|
||||
return;
|
||||
|
||||
for ( Achievements achievement : Achievements.values() )
|
||||
for( Achievements achievement : Achievements.values() )
|
||||
{
|
||||
switch ( achievement.type )
|
||||
switch( achievement.type )
|
||||
{
|
||||
case Craft:
|
||||
if ( Platform.isSameItemPrecise( achievement.stack, event.crafting ) )
|
||||
if( Platform.isSameItemPrecise( achievement.stack, event.crafting ) )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case CraftItem:
|
||||
if ( achievement.stack != null && achievement.stack.getItem().getClass() == event.crafting.getItem().getClass() )
|
||||
if( achievement.stack != null && achievement.stack.getItem().getClass() == event.crafting.getItem().getClass() )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
|
||||
@@ -46,14 +46,14 @@ public class AchievementPickupHandler
|
||||
@SubscribeEvent
|
||||
public void onItemPickUp( PlayerEvent.ItemPickupEvent event )
|
||||
{
|
||||
if ( this.differentiator.isNoPlayer( event.player ) || event.pickedUp == null || event.pickedUp.getEntityItem() == null )
|
||||
if( this.differentiator.isNoPlayer( event.player ) || event.pickedUp == null || event.pickedUp.getEntityItem() == null )
|
||||
return;
|
||||
|
||||
ItemStack is = event.pickedUp.getEntityItem();
|
||||
|
||||
for ( Achievements achievement : Achievements.values() )
|
||||
for( Achievements achievement : Achievements.values() )
|
||||
{
|
||||
if ( achievement.type == AchievementType.Pickup && Platform.isSameItemPrecise( achievement.stack, is ) )
|
||||
if( achievement.type == AchievementType.Pickup && Platform.isSameItemPrecise( achievement.stack, is ) )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.stats;
|
||||
|
||||
|
||||
public enum AchievementType
|
||||
{
|
||||
|
||||
|
||||
@@ -114,25 +114,9 @@ public enum Achievements
|
||||
private Achievement parent;
|
||||
private Achievement stat;
|
||||
|
||||
public void setParent( Achievements parent )
|
||||
{
|
||||
this.parent = parent.getAchievement();
|
||||
}
|
||||
|
||||
public Achievement getAchievement()
|
||||
{
|
||||
if ( this.stat == null && this.stack != null )
|
||||
{
|
||||
this.stat = new Achievement( "achievement.ae2." + this.name(), "ae2." + this.name(), this.x, this.y, this.stack, this.parent );
|
||||
this.stat.registerStat();
|
||||
}
|
||||
|
||||
return this.stat;
|
||||
}
|
||||
|
||||
Achievements( int x, int y, AEColoredItemDefinition which, AchievementType type )
|
||||
{
|
||||
this.stack = (which != null) ? which.stack( AEColor.Transparent, 1 ) : null;
|
||||
this.stack = ( which != null ) ? which.stack( AEColor.Transparent, 1 ) : null;
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -154,6 +138,22 @@ public enum Achievements
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setParent( Achievements parent )
|
||||
{
|
||||
this.parent = parent.getAchievement();
|
||||
}
|
||||
|
||||
public Achievement getAchievement()
|
||||
{
|
||||
if( this.stat == null && this.stack != null )
|
||||
{
|
||||
this.stat = new Achievement( "achievement.ae2." + this.name(), "ae2." + this.name(), this.x, this.y, this.stack, this.parent );
|
||||
this.stat.registerStat();
|
||||
}
|
||||
|
||||
return this.stat;
|
||||
}
|
||||
|
||||
public void addToPlayer( EntityPlayer player )
|
||||
{
|
||||
player.addStat( this.getAchievement(), 1 );
|
||||
|
||||
@@ -38,7 +38,8 @@ public class PlayerDifferentiator
|
||||
* - dead
|
||||
* - fake
|
||||
*
|
||||
* @param player to be checked player
|
||||
* @param player to be checked player
|
||||
*
|
||||
* @return true if {@param player} is not a real player
|
||||
*/
|
||||
public boolean isNoPlayer( EntityPlayer player )
|
||||
|
||||
@@ -64,7 +64,7 @@ public class PlayerStatsRegistration
|
||||
*/
|
||||
public void registerAchievementHandlers()
|
||||
{
|
||||
if ( this.isAchievementFeatureEnabled )
|
||||
if( this.isAchievementFeatureEnabled )
|
||||
{
|
||||
final PlayerDifferentiator differentiator = new PlayerDifferentiator();
|
||||
final AchievementCraftingHandler craftingHandler = new AchievementCraftingHandler( differentiator );
|
||||
@@ -80,12 +80,12 @@ public class PlayerStatsRegistration
|
||||
*/
|
||||
public void registerAchievements()
|
||||
{
|
||||
if ( this.isAchievementFeatureEnabled )
|
||||
if( this.isAchievementFeatureEnabled )
|
||||
{
|
||||
final AchievementHierarchy hierarchy = new AchievementHierarchy();
|
||||
hierarchy.registerAchievementHierarchy();
|
||||
|
||||
for ( Stats s : Stats.values() )
|
||||
for( Stats s : Stats.values() )
|
||||
s.getStat();
|
||||
|
||||
/**
|
||||
@@ -93,10 +93,10 @@ public class PlayerStatsRegistration
|
||||
*/
|
||||
ArrayList<Achievement> list = new ArrayList<Achievement>();
|
||||
|
||||
for ( Achievements a : Achievements.values() )
|
||||
for( Achievements a : Achievements.values() )
|
||||
{
|
||||
Achievement ach = a.getAchievement();
|
||||
if ( ach != null )
|
||||
if( ach != null )
|
||||
list.add( ach );
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
|
||||
package appeng.core.stats;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.stats.StatBasic;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
|
||||
|
||||
public enum Stats
|
||||
{
|
||||
|
||||
@@ -36,9 +38,18 @@ public enum Stats
|
||||
|
||||
private StatBasic stat;
|
||||
|
||||
Stats()
|
||||
{
|
||||
}
|
||||
|
||||
public void addToPlayer( EntityPlayer player, int howMany )
|
||||
{
|
||||
player.addStat( this.getStat(), howMany );
|
||||
}
|
||||
|
||||
public StatBasic getStat()
|
||||
{
|
||||
if ( this.stat == null )
|
||||
if( this.stat == null )
|
||||
{
|
||||
this.stat = new StatBasic( "stat.ae2." + this.name(), new ChatComponentTranslation( "stat.ae2." + this.name() ) );
|
||||
this.stat.registerStat();
|
||||
@@ -47,12 +58,4 @@ public enum Stats
|
||||
return this.stat;
|
||||
}
|
||||
|
||||
Stats() {
|
||||
}
|
||||
|
||||
public void addToPlayer(EntityPlayer player, int howMany)
|
||||
{
|
||||
player.addStat( this.getStat(), howMany );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user