diff options
Diffstat (limited to 'src/Java')
3 files changed, 130 insertions, 89 deletions
diff --git a/src/Java/gtPlusPlus/api/analytics/SegmentAnalytics.java b/src/Java/gtPlusPlus/api/analytics/SegmentAnalytics.java index 17be43f5d0..cdd38fd374 100644 --- a/src/Java/gtPlusPlus/api/analytics/SegmentAnalytics.java +++ b/src/Java/gtPlusPlus/api/analytics/SegmentAnalytics.java @@ -42,6 +42,7 @@ public class SegmentAnalytics { public final UUID mUUID; public final String mUserName; public final String mAnonymousId; + protected Map<String, Object> mProperties = new LinkedHashMap<>(); final protected Phaser mPhaser; //Build a new instance of this class @@ -98,25 +99,33 @@ public class SegmentAnalytics { if (!canProcess()){ return; } - Map<String, Object> properties = new LinkedHashMap<>(); - properties.put("username", mLocalName); - properties.put("gt_version", Utils.getGregtechVersionAsString()); + mProperties = new LinkedHashMap<>(); + mProperties.put("username", mLocalName); + mProperties.put("gt_version", Utils.getGregtechVersionAsString()); if (LoadedMods.IndustrialCraft2){ - properties.put("ic2_version", IC2.VERSION); + mProperties.put("ic2_version", IC2.VERSION); } - properties.put("country_code", CORE.USER_COUNTRY); - properties.put("gtnh", CORE.GTNH); + mProperties.put("country_code", CORE.USER_COUNTRY); + mProperties.put("gtnh", CORE.GTNH); LOG("Created new Data packet, queued for submission."); //Old Code, now passed to Helper Class /*mHelper.enqueue(IdentifyMessage.builder() .userId(mUserName) //Save Username as UUID, for future sessions to attach to. - .traits(properties) + .traits(mProperties) //.anonymousId(mAnonymousId) //Save Random Session UUID );*/ - mHelper.addUser(this.mUserName, properties); + mHelper.addUser(this.mUserName, mProperties); + + if (CORE.GTNH){ + mHelper.groupUser("GT:NewHorizons", this.mUserName); + } + else { + mHelper.groupUser("GT:Vanilla", this.mUserName); + } + } public void submitTrackingData(String aActionPerformed){ @@ -143,7 +152,7 @@ public class SegmentAnalytics { //Old Code, now passed to Helper Class /*mHelper.enqueue(TrackMessage.builder(aActionPerformed) // .userId(mUserName) // Save Username as UUID, for future sessions to attach to. - .properties(properties) //Save Stats + .properties(mProperties) //Save Stats //.anonymousId(mAnonymousId) //Save Random Session UUID ); flushData(); @@ -231,6 +240,10 @@ public class SegmentAnalytics { public final Analytics getAnalyticObject() { return mHelper.getAnalyticsClient(); } + + public final Map<String, Object> getPlayerProperties(){ + return this.mProperties; + } public Timer initTimer(EntityPlayer mPlayer) { diff --git a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java index 93786b1b3f..4b5bc96006 100644 --- a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java @@ -73,100 +73,101 @@ public class BlockEventHandler { } - + //Used to handle Thaumcraft Shards when TC is not installed. @SubscribeEvent public void harvestDrops(final BlockEvent.HarvestDropsEvent event) { try { - //Spawn Dull Shards (Can spawn from Tree Logs, Grass or Stone. Stone going to be the most common source.) - if (((event.block == Blocks.stone) || (event.block == Blocks.sandstone) || (event.block == Blocks.log) || (event.block == Blocks.log2) || (event.block == Blocks.grass)) - && !LoadedMods.Thaumcraft && (chanceToDropDrainedShard != 0)) { - //small chance for one to spawn per stone mined. 1 per 3 stacks~ - if (MathUtils.randInt(1, chanceToDropDrainedShard) == 1){ - //Let's sort out a lucky charm for the player. - final int FancyChance = MathUtils.randInt(1, 4); - if (MathUtils.randInt(1, 100) < 90){ - event.drops.add(new ItemStack(ModItems.shardDull)); - } - //Make a Fire Shard - else if (FancyChance == 1){ - event.drops.add(new ItemStack(ModItems.shardIgnis)); - } - //Make a Water Shard. - else if (FancyChance == 2){ - event.drops.add(new ItemStack(ModItems.shardAqua)); - } - //Make an Earth Shard. - else if (FancyChance == 3){ - event.drops.add(new ItemStack(ModItems.shardTerra)); + //Spawn Dull Shards (Can spawn from Tree Logs, Grass or Stone. Stone going to be the most common source.) + if (((event.block == Blocks.stone) || (event.block == Blocks.sandstone) || (event.block == Blocks.log) || (event.block == Blocks.log2) || (event.block == Blocks.grass)) + && !LoadedMods.Thaumcraft && (chanceToDropDrainedShard != 0)) { + //small chance for one to spawn per stone mined. 1 per 3 stacks~ + if (MathUtils.randInt(1, chanceToDropDrainedShard) == 1){ + //Let's sort out a lucky charm for the player. + final int FancyChance = MathUtils.randInt(1, 4); + if (MathUtils.randInt(1, 100) < 90){ + event.drops.add(new ItemStack(ModItems.shardDull)); + } + //Make a Fire Shard + else if (FancyChance == 1){ + event.drops.add(new ItemStack(ModItems.shardIgnis)); + } + //Make a Water Shard. + else if (FancyChance == 2){ + event.drops.add(new ItemStack(ModItems.shardAqua)); + } + //Make an Earth Shard. + else if (FancyChance == 3){ + event.drops.add(new ItemStack(ModItems.shardTerra)); + } + //Make an Air Shard. + else if (FancyChance == 4){ + event.drops.add(new ItemStack(ModItems.shardAer)); + } } - //Make an Air Shard. - else if (FancyChance == 4){ - event.drops.add(new ItemStack(ModItems.shardAer)); + else { + Utils.LOG_WARNING("invalid chance"); } } - else { - Utils.LOG_WARNING("invalid chance"); - } - } - //Spawns Fluorite from Lime Stone - if (chanceToDropFluoriteOre != 0){ - if (!oreLimestone.isEmpty() || !blockLimestone.isEmpty()){ + //Spawns Fluorite from Lime Stone + if (chanceToDropFluoriteOre != 0){ + if (!oreLimestone.isEmpty() || !blockLimestone.isEmpty()){ - ArrayList<Block> mBlockTypes = new ArrayList<Block>(); - if (!oreLimestone.isEmpty()){ - for (int i=0;i<oreLimestone.size();i++){ - mBlockTypes.add(Block.getBlockFromItem(oreLimestone.get(i).getItem())); + ArrayList<Block> mBlockTypes = new ArrayList<Block>(); + if (!oreLimestone.isEmpty()){ + for (int i=0;i<oreLimestone.size();i++){ + mBlockTypes.add(Block.getBlockFromItem(oreLimestone.get(i).getItem())); + } } - } - if (!blockLimestone.isEmpty()){ - for (int i=0;i<blockLimestone.size();i++){ - if (!mBlockTypes.contains(Block.getBlockFromItem(blockLimestone.get(i).getItem()))){ - mBlockTypes.add(Block.getBlockFromItem(blockLimestone.get(i).getItem())); + if (!blockLimestone.isEmpty()){ + for (int i=0;i<blockLimestone.size();i++){ + if (!mBlockTypes.contains(Block.getBlockFromItem(blockLimestone.get(i).getItem()))){ + mBlockTypes.add(Block.getBlockFromItem(blockLimestone.get(i).getItem())); + } } } - } - Utils.LOG_WARNING("Found Limestone in OreDict."); - if (!mBlockTypes.isEmpty()) { - Utils.LOG_WARNING("1a | "+event.block.getUnlocalizedName()); - for (final Block temp : mBlockTypes){ - Utils.LOG_WARNING("2a - "+temp.getUnlocalizedName()); - if (event.block == temp) { - Utils.LOG_WARNING("3a - found "+temp.getUnlocalizedName()); - if (MathUtils.randInt(1, chanceToDropFluoriteOre) == 1){ - Utils.LOG_WARNING("4a"); - event.drops.clear(); - event.drops.add(fluoriteOre.copy()); + Utils.LOG_WARNING("Found Limestone in OreDict."); + if (!mBlockTypes.isEmpty()) { + Utils.LOG_WARNING("1a | "+event.block.getUnlocalizedName()); + for (final Block temp : mBlockTypes){ + Utils.LOG_WARNING("2a - "+temp.getUnlocalizedName()); + if (event.block == temp) { + Utils.LOG_WARNING("3a - found "+temp.getUnlocalizedName()); + if (MathUtils.randInt(1, chanceToDropFluoriteOre) == 1){ + Utils.LOG_WARNING("4a"); + event.drops.clear(); + event.drops.add(fluoriteOre.copy()); + } } } } } - } - if (event.block.getUnlocalizedName().toLowerCase().contains("limestone")){ - Utils.LOG_WARNING("1c"); - if (MathUtils.randInt(1, chanceToDropFluoriteOre) == 1){ - Utils.LOG_WARNING("2c"); - event.drops.clear(); - event.drops.add(fluoriteOre.copy()); + if (event.block.getUnlocalizedName().toLowerCase().contains("limestone")){ + Utils.LOG_WARNING("1c"); + if (MathUtils.randInt(1, chanceToDropFluoriteOre) == 1){ + Utils.LOG_WARNING("2c"); + event.drops.clear(); + event.drops.add(fluoriteOre.copy()); + } } - } - if (event.block == Blocks.sandstone){ - if (MathUtils.randInt(1, chanceToDropFluoriteOre*20) == 1){ - event.drops.clear(); - event.drops.add(fluoriteOre.copy()); + if (event.block == Blocks.sandstone){ + if (MathUtils.randInt(1, chanceToDropFluoriteOre*20) == 1){ + event.drops.clear(); + event.drops.add(fluoriteOre.copy()); + } } } - } - - //Try submit some data for this event. - SegmentAnalytics.getAnalyticsForPlayer(event.harvester).submitTrackingData("Action_Block_Broken", event.block.getLocalizedName()); - + + //Try submit some data for this event. + if (event.harvester != null){ + //SegmentAnalytics.getAnalyticsForPlayer(event.harvester).submitTrackingData("Broke Block", event.block.getLocalizedName()); + } } catch (Throwable r){ Utils.LOG_INFO("Block Event Handler Failed. Please Report this to Alkalus."); diff --git a/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java index 7362674d68..fb1617d29e 100644 --- a/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java @@ -1,29 +1,56 @@ package gtPlusPlus.core.handler.events; +import java.lang.reflect.Field; + +import org.apache.commons.lang3.reflect.FieldUtils; + import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.api.analytics.SegmentHelper; import gtPlusPlus.core.util.Utils; import net.minecraftforge.event.entity.living.ZombieEvent; +import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent; public class ZombieBackupSpawnEventHandler { - + /** * * Do we really need this pathetic mechanic to exist when it doesn't work properly at all? * Or , well, maybe you enjoy Zombies spawning IN YOUR FUCKING FACE?! * */ - - @SubscribeEvent + + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onZombieReinforcement(final ZombieEvent.SummonAidEvent event) { - Utils.LOG_MACHINE_INFO("ZombieEvent.SummonAidEvent."); - event.setResult(Result.DENY); + try { + try { + Field mChance = FieldUtils.getDeclaredField(this.getClass(), "summonChance", true); + FieldUtils.removeFinalModifier(mChance, true); + mChance.set(this, 0); + } + catch(Throwable t){} + if (event.attacker != null){ + SegmentHelper.getInstance().trackUser(event.attacker.getUniqueID().toString(), "Zombie Backup"); + } + Utils.LOG_WARNING("[Zombie] ZombieEvent.SummonAidEvent."); + event.setResult(Result.DENY); + } + catch(Throwable t){} } - - @SubscribeEvent + + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onZombieReinforcement(final ZombieEvent event) { - Utils.LOG_MACHINE_INFO("ZombieEvent."); - event.setResult(Result.DENY); + try { + Utils.LOG_WARNING("[Zombie] ZombieEvent."); + if (event.entity != null){ + Utils.LOG_WARNING("Event Entity: "+event.entity.getCommandSenderName()); + } + event.setResult(Result.DENY); + } + catch(Throwable t){ + + } } - + } |