From ef9abec1a770984d2f772bec58586900d16e373e Mon Sep 17 00:00:00 2001 From: Kino Date: Fri, 4 Aug 2017 20:17:21 -0400 Subject: [PATCH] #160 - Perks checked through server thread. --- .../aether/common/player/PlayerAether.java | 3 -- .../common/player/PlayerAetherEvents.java | 10 ++----- .../common/player/perks/AetherPerkThread.java | 30 +++++++++++++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/legacy/aether/common/player/perks/AetherPerkThread.java diff --git a/src/main/java/com/legacy/aether/common/player/PlayerAether.java b/src/main/java/com/legacy/aether/common/player/PlayerAether.java index 5abe596..b8f761b 100644 --- a/src/main/java/com/legacy/aether/common/player/PlayerAether.java +++ b/src/main/java/com/legacy/aether/common/player/PlayerAether.java @@ -12,17 +12,14 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.server.management.PlayerList; import net.minecraft.util.DamageSource; -import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.ReflectionHelper; diff --git a/src/main/java/com/legacy/aether/common/player/PlayerAetherEvents.java b/src/main/java/com/legacy/aether/common/player/PlayerAetherEvents.java index 36c0e70..fa62f6f 100644 --- a/src/main/java/com/legacy/aether/common/player/PlayerAetherEvents.java +++ b/src/main/java/com/legacy/aether/common/player/PlayerAetherEvents.java @@ -28,10 +28,8 @@ import com.legacy.aether.common.Aether; import com.legacy.aether.common.items.ItemsAether; import com.legacy.aether.common.networking.AetherNetworkingManager; import com.legacy.aether.common.networking.packets.PacketAchievement; -import com.legacy.aether.common.networking.packets.PacketPerkChanged; import com.legacy.aether.common.player.capability.PlayerAetherProvider; -import com.legacy.aether.common.player.perks.AetherPerks; -import com.legacy.aether.common.player.perks.util.EnumAetherPerkType; +import com.legacy.aether.common.player.perks.AetherPerkThread; import com.legacy.aether.common.registry.achievements.AchievementsAether; import com.legacy.aether.common.registry.objects.AetherAchievement; @@ -151,11 +149,7 @@ public class PlayerAetherEvents { playerAether.accessories.markDirty(); - boolean isDonator = AetherPerks.isDonator(player.getUniqueID()); - - playerAether.setDonator(isDonator); - - AetherNetworkingManager.sendTo(new PacketPerkChanged(player.getEntityId(), EnumAetherPerkType.Information, isDonator), (EntityPlayerMP) player); + FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(new AetherPerkThread(playerAether)); } } diff --git a/src/main/java/com/legacy/aether/common/player/perks/AetherPerkThread.java b/src/main/java/com/legacy/aether/common/player/perks/AetherPerkThread.java new file mode 100644 index 0000000..8215514 --- /dev/null +++ b/src/main/java/com/legacy/aether/common/player/perks/AetherPerkThread.java @@ -0,0 +1,30 @@ +package com.legacy.aether.common.player.perks; + +import net.minecraft.entity.player.EntityPlayerMP; + +import com.legacy.aether.common.networking.AetherNetworkingManager; +import com.legacy.aether.common.networking.packets.PacketPerkChanged; +import com.legacy.aether.common.player.PlayerAether; +import com.legacy.aether.common.player.perks.util.EnumAetherPerkType; + +public class AetherPerkThread implements Runnable +{ + + private PlayerAether playerAether; + + public AetherPerkThread(PlayerAether playerAether) + { + this.playerAether = playerAether; + } + + @Override + public void run() + { + boolean isDonator = AetherPerks.isDonator(this.playerAether.thePlayer.getUniqueID()); + + this.playerAether.setDonator(isDonator); + + AetherNetworkingManager.sendTo(new PacketPerkChanged(this.playerAether.thePlayer.getEntityId(), EnumAetherPerkType.Information, isDonator), (EntityPlayerMP) this.playerAether.thePlayer); + } + +} \ No newline at end of file