Guest User

Untitled

a guest
Sep 25th, 2018
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package de.krokoyt.gswords.events;
  2.  
  3. import com.google.common.eventbus.Subscribe;
  4.  
  5. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  6. import cpw.mods.fml.common.gameevent.PlayerEvent;
  7. import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent;
  8. import de.krokoyt.gswords.Skills.*;
  9. import net.minecraft.entity.player.EntityPlayer;
  10. import net.minecraft.entity.player.EntityPlayerMP;
  11. import net.minecraft.nbt.NBTTagCompound;
  12. import net.minecraft.nbt.NBTTagList;
  13. import net.minecraftforge.event.entity.EntityEvent;
  14. import net.minecraftforge.event.entity.living.LivingDeathEvent;
  15.  
  16. public class QuitAndJoin {
  17.  
  18. @SubscribeEvent
  19. public void playerClone(net.minecraftforge.event.entity.player.PlayerEvent.Clone e) {
  20. AdventureHelper adnew = AdventureHelper.getProperties(e.entityPlayer);
  21. AdventureHelper adold = AdventureHelper.getProperties(e.original);
  22.  
  23. adnew.setLevel(adold.getLevel());
  24. adnew.setExperience(adold.getExperience());
  25. }
  26.  
  27. @SubscribeEvent
  28. public void onJoin(PlayerEvent.PlayerLoggedInEvent e) {
  29.  
  30. if ((e.player instanceof EntityPlayer))
  31. {
  32. EntityPlayer p = e.player;
  33. if ((p instanceof EntityPlayerMP))
  34. {
  35. AddPackets.network.sendTo(new AdventureMessage(AdventureHelper.getProperties(p).getLevel(), AdventureHelper.getProperties(p).progressPercentage()), (EntityPlayerMP)p);
  36. AddPackets.network.sendTo(new AntiGiftMessage(AntiGiftHelper.getProperties(p).getLevel(), AntiGiftHelper.getProperties(p).progressPercentage()), (EntityPlayerMP)p);
  37. AddPackets.network.sendTo(new DamageMessage(DamageHelper.getProperties(p).getLevel(), DamageHelper.getProperties(p).progressPercentage()), (EntityPlayerMP)p);
  38. AddPackets.network.sendTo(new FarmMessage(FarmHelper.getProperties(p).getLevel(), FarmHelper.getProperties(p).progressPercentage()), (EntityPlayerMP)p);
  39. AddPackets.network.sendTo(new GhostMessage(GhostHelper.getProperties(p).getLevel(), GhostHelper.getProperties(p).progressPercentage()), (EntityPlayerMP)p);
  40. AddPackets.network.sendTo(new HealthMessage(HealthHelper.getProperties(p).getLevel(), HealthHelper.getProperties(p).progressPercentage()), (EntityPlayerMP)p);
  41. AddPackets.network.sendTo(new JagerMessage(JagerHelper.getProperties(p).getLevel(), JagerHelper.getProperties(p).progressPercentage()), (EntityPlayerMP)p);
  42. AddPackets.network.sendTo(new MiningMessage(MiningHelper.getProperties(p).getLevel(), MiningHelper.getProperties(p).progressPercentage()), (EntityPlayerMP)p);
  43. AddPackets.network.sendTo(new RustungMessage(RustungHelper.getProperties(p).getLevel(), RustungHelper.getProperties(p).progressPercentage()), (EntityPlayerMP)p);
  44. AddPackets.network.sendTo(new TreeMessage(TreeHelper.getProperties(p).getLevel(), TreeHelper.getProperties(p).progressPercentage()), (EntityPlayerMP)p);
  45.  
  46. }
  47. }
  48. }
  49.  
  50. @Subscribe
  51. public void onQuit(PlayerEvent.PlayerLoggedOutEvent evt) {
  52. {
  53. NBTTagCompound tag = evt.player.getEntityData().getCompoundTag("PlayerPersisted");
  54.  
  55. AdventureHelper props = AdventureHelper.getProperties(evt.player);
  56. props.setLevel(tag.getInteger("AdLevel"));
  57. props.setExperience(tag.getFloat("Adxp"));
  58.  
  59. AntiGiftHelper props2 = AntiGiftHelper.getProperties(evt.player);
  60. props2.setLevel(tag.getInteger("AnLevel"));
  61. props2.setExperience(tag.getFloat("AnExp"));
  62.  
  63. DamageHelper props3 = DamageHelper.getProperties(evt.player);
  64. props3.setLevel(tag.getInteger("DaLevel"));
  65. props3.setExperience(tag.getFloat("DaExp"));
  66.  
  67. FarmHelper props4 = FarmHelper.getProperties(evt.player);
  68. props4.setLevel(tag.getInteger("FaLevel"));
  69. props4.setExperience(tag.getFloat("FaExp"));
  70.  
  71. GhostHelper props5 = GhostHelper.getProperties(evt.player);
  72. props5.setLevel(tag.getInteger("GhLevel"));
  73. props5.setExperience(tag.getFloat("GhExp"));
  74.  
  75. HealthHelper props6 = HealthHelper.getProperties(evt.player);
  76. props6.setLevel(tag.getInteger("HeLevel"));
  77. props6.setExperience(tag.getFloat("HeExp"));
  78.  
  79. JagerHelper props7 = JagerHelper.getProperties(evt.player);
  80. props7.setLevel(tag.getInteger("JaLevel"));
  81. props7.setExperience(tag.getFloat("JaExp"));
  82.  
  83. MiningHelper props8 = MiningHelper.getProperties(evt.player);
  84. props8.setLevel(tag.getInteger("MiLevel"));
  85. props8.setExperience(tag.getFloat("MiExp"));
  86.  
  87. RustungHelper props9 = RustungHelper.getProperties(evt.player);
  88. props9.setLevel(tag.getInteger("RuLevel"));
  89. props9.setExperience(tag.getFloat("RuExp"));
  90.  
  91. TreeHelper props10 = TreeHelper.getProperties(evt.player);
  92. props10.setLevel(tag.getInteger("TrLevel"));
  93. props10.setExperience(tag.getFloat("TrExp"));
  94.  
  95.  
  96.  
  97. evt.player.getEntityData().setTag("PlayerPersisted", tag);
  98. }
  99. }
  100.  
  101. @SubscribeEvent
  102. public void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent evt)
  103. {
  104. NBTTagCompound tag = evt.player.getEntityData().getCompoundTag("PlayerPersisted");
  105.  
  106. AdventureHelper props = AdventureHelper.getProperties(evt.player);
  107. props.setLevel(tag.getInteger("AdLevel"));
  108. props.setExperience(tag.getFloat("Adxp"));
  109.  
  110. AntiGiftHelper props2 = AntiGiftHelper.getProperties(evt.player);
  111. props2.setLevel(tag.getInteger("AnLevel"));
  112. props2.setExperience(tag.getFloat("AnExp"));
  113.  
  114. DamageHelper props3 = DamageHelper.getProperties(evt.player);
  115. props3.setLevel(tag.getInteger("DaLevel"));
  116. props3.setExperience(tag.getFloat("DaExp"));
  117.  
  118. FarmHelper props4 = FarmHelper.getProperties(evt.player);
  119. props4.setLevel(tag.getInteger("FaLevel"));
  120. props4.setExperience(tag.getFloat("FaExp"));
  121.  
  122. GhostHelper props5 = GhostHelper.getProperties(evt.player);
  123. props5.setLevel(tag.getInteger("GhLevel"));
  124. props5.setExperience(tag.getFloat("GhExp"));
  125.  
  126. HealthHelper props6 = HealthHelper.getProperties(evt.player);
  127. props6.setLevel(tag.getInteger("HeLevel"));
  128. props6.setExperience(tag.getFloat("HeExp"));
  129.  
  130. JagerHelper props7 = JagerHelper.getProperties(evt.player);
  131. props7.setLevel(tag.getInteger("JaLevel"));
  132. props7.setExperience(tag.getFloat("JaExp"));
  133.  
  134. MiningHelper props8 = MiningHelper.getProperties(evt.player);
  135. props8.setLevel(tag.getInteger("MiLevel"));
  136. props8.setExperience(tag.getFloat("MiExp"));
  137.  
  138. RustungHelper props9 = RustungHelper.getProperties(evt.player);
  139. props9.setLevel(tag.getInteger("RuLevel"));
  140. props9.setExperience(tag.getFloat("RuExp"));
  141.  
  142. TreeHelper props10 = TreeHelper.getProperties(evt.player);
  143. props10.setLevel(tag.getInteger("TrLevel"));
  144. props10.setExperience(tag.getFloat("TrExp"));
  145.  
  146.  
  147.  
  148. evt.player.getEntityData().setTag("PlayerPersisted", tag);
  149. }
  150.  
  151.  
  152. @SubscribeEvent
  153. public void onEntityConstructing(EntityEvent.EntityConstructing evt)
  154. {
  155. if(evt.entity instanceof EntityPlayerMP) {
  156. if (((evt.entity instanceof EntityPlayer)) && (AdventureHelper.getProperties((EntityPlayer)evt.entity) == null)) {
  157. AdventureHelper.addProperties((EntityPlayer)evt.entity);
  158. }
  159. if (((evt.entity instanceof EntityPlayer)) && (AntiGiftHelper.getProperties((EntityPlayer)evt.entity) == null)) {
  160. AntiGiftHelper.addProperties((EntityPlayer)evt.entity);
  161. }
  162. if (((evt.entity instanceof EntityPlayer)) && (DamageHelper.getProperties((EntityPlayer)evt.entity) == null)) {
  163. DamageHelper.addProperties((EntityPlayer)evt.entity);
  164. }
  165. if (((evt.entity instanceof EntityPlayer)) && (FarmHelper.getProperties((EntityPlayer)evt.entity) == null)) {
  166. FarmHelper.addProperties((EntityPlayer)evt.entity);
  167. }
  168. if (((evt.entity instanceof EntityPlayer)) && (GhostHelper.getProperties((EntityPlayer)evt.entity) == null)) {
  169. GhostHelper.addProperties((EntityPlayer)evt.entity);
  170. }
  171. if (((evt.entity instanceof EntityPlayer)) && (HealthHelper.getProperties((EntityPlayer)evt.entity) == null)) {
  172. HealthHelper.addProperties((EntityPlayer)evt.entity);
  173. }
  174. if (((evt.entity instanceof EntityPlayer)) && (JagerHelper.getProperties((EntityPlayer)evt.entity) == null)) {
  175. JagerHelper.addProperties((EntityPlayer)evt.entity);
  176. }
  177. if (((evt.entity instanceof EntityPlayer)) && (MiningHelper.getProperties((EntityPlayer)evt.entity) == null)) {
  178. MiningHelper.addProperties((EntityPlayer)evt.entity);
  179. }
  180. if (((evt.entity instanceof EntityPlayer)) && (RustungHelper.getProperties((EntityPlayer)evt.entity) == null)) {
  181. RustungHelper.addProperties((EntityPlayer)evt.entity);
  182. }
  183. if (((evt.entity instanceof EntityPlayer)) && (TreeHelper.getProperties((EntityPlayer)evt.entity) == null)) {
  184. TreeHelper.addProperties((EntityPlayer)evt.entity);
  185. }
  186. }
  187. }
  188.  
  189. @SubscribeEvent
  190. public void onPlayerDeath(LivingDeathEvent evt)
  191. {
  192. if ((evt.entity instanceof EntityPlayer))
  193. {
  194. EntityPlayer player = (EntityPlayer)evt.entity;
  195. AdventureHelper props = AdventureHelper.getProperties(player);
  196. NBTTagCompound tag = player.getEntityData().getCompoundTag("PlayerPersisted");
  197.  
  198. tag.setFloat("AdExp", props.getExperience());
  199. tag.setInteger("AdLevel", props.getLevel());
  200. player.getEntityData().setTag("PlayerPersisted", tag);
  201.  
  202. AntiGiftHelper props2 = AntiGiftHelper.getProperties(player);
  203. tag.setFloat("AnExp", props2.getExperience());
  204. tag.setInteger("AnLevel", props2.getLevel());
  205. player.getEntityData().setTag("PlayerPersisted", tag);
  206.  
  207. DamageHelper props3 = DamageHelper.getProperties(player);
  208. tag.setFloat("DaExp", props3.getExperience());
  209. tag.setInteger("DaLevel", props3.getLevel());
  210. player.getEntityData().setTag("PlayerPersisted", tag);
  211.  
  212. FarmHelper props4 = FarmHelper.getProperties(player);
  213. tag.setFloat("FaExp", props4.getExperience());
  214. tag.setInteger("FaLevel", props4.getLevel());
  215. player.getEntityData().setTag("PlayerPersisted", tag);
  216.  
  217. GhostHelper props5 = GhostHelper.getProperties(player);
  218. tag.setFloat("GhExp", props5.getExperience());
  219. tag.setInteger("GhLevel", props5.getLevel());
  220. player.getEntityData().setTag("PlayerPersisted", tag);
  221.  
  222. HealthHelper props6 = HealthHelper.getProperties(player);
  223. tag.setFloat("HeExp", props6.getExperience());
  224. tag.setInteger("HeLevel", props6.getLevel());
  225. player.getEntityData().setTag("PlayerPersisted", tag);
  226.  
  227. JagerHelper props7 = JagerHelper.getProperties(player);
  228. tag.setFloat("JaExp", props7.getExperience());
  229. tag.setInteger("JaLevel", props7.getLevel());
  230. player.getEntityData().setTag("PlayerPersisted", tag);
  231.  
  232. MiningHelper props8 = MiningHelper.getProperties(player);
  233. tag.setFloat("MiExp", props8.getExperience());
  234. tag.setInteger("MiLevel", props8.getLevel());
  235. player.getEntityData().setTag("PlayerPersisted", tag);
  236.  
  237. RustungHelper props9 = RustungHelper.getProperties(player);
  238. tag.setFloat("RuExp", props9.getExperience());
  239. tag.setInteger("RuLevel", props9.getLevel());
  240. player.getEntityData().setTag("PlayerPersisted", tag);
  241.  
  242. TreeHelper props10 = TreeHelper.getProperties(player);
  243. tag.setFloat("TrExp", props10.getExperience());
  244. tag.setInteger("TrLevel", props10.getLevel());
  245. player.getEntityData().setTag("PlayerPersisted", tag);
  246.  
  247. }
  248. }
  249. }
RAW Paste Data