2013-12-04 21:43:03 +01:00
|
|
|
package mekanism.common;
|
2014-06-03 19:54:45 +02:00
|
|
|
|
2014-06-11 11:57:49 +02:00
|
|
|
import mekanism.common.network.PacketBoxBlacklist.BoxBlacklistMessage;
|
|
|
|
import mekanism.common.network.PacketConfigSync.ConfigSyncMessage;
|
|
|
|
import mekanism.common.network.PacketJetpackData.JetpackDataMessage;
|
2014-06-14 01:35:25 +02:00
|
|
|
import mekanism.common.network.PacketJetpackData.JetpackPacket;
|
2014-06-11 11:57:49 +02:00
|
|
|
import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage;
|
2014-06-14 01:35:25 +02:00
|
|
|
import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
|
2016-04-30 17:26:12 +02:00
|
|
|
import mekanism.common.network.PacketSecurityUpdate.SecurityPacket;
|
|
|
|
import mekanism.common.network.PacketSecurityUpdate.SecurityUpdateMessage;
|
2014-06-02 16:01:21 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2014-06-03 19:54:45 +02:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2014-04-20 05:34:19 +02:00
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
2014-04-20 22:15:44 +02:00
|
|
|
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent;
|
2014-04-20 05:34:19 +02:00
|
|
|
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
2014-04-20 22:15:44 +02:00
|
|
|
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent;
|
2013-12-04 21:43:03 +01:00
|
|
|
|
2014-04-20 05:34:19 +02:00
|
|
|
public class CommonPlayerTracker
|
2013-12-04 21:43:03 +01:00
|
|
|
{
|
2014-06-03 19:54:45 +02:00
|
|
|
public CommonPlayerTracker()
|
2014-04-20 05:34:19 +02:00
|
|
|
{
|
2014-06-03 19:54:45 +02:00
|
|
|
MinecraftForge.EVENT_BUS.register(this);
|
2014-04-20 05:34:19 +02:00
|
|
|
}
|
2014-06-03 19:54:45 +02:00
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onPlayerLoginEvent(PlayerLoggedInEvent event)
|
2013-12-09 23:08:47 +01:00
|
|
|
{
|
2014-06-03 19:54:45 +02:00
|
|
|
if(!event.player.worldObj.isRemote)
|
2013-12-09 23:08:47 +01:00
|
|
|
{
|
2014-06-11 11:57:49 +02:00
|
|
|
Mekanism.packetHandler.sendTo(new ConfigSyncMessage(), (EntityPlayerMP)event.player);
|
|
|
|
Mekanism.packetHandler.sendTo(new BoxBlacklistMessage(), (EntityPlayerMP)event.player);
|
|
|
|
Mekanism.packetHandler.sendTo(new JetpackDataMessage(JetpackPacket.FULL, null, false), (EntityPlayerMP)event.player);
|
|
|
|
Mekanism.packetHandler.sendTo(new ScubaTankDataMessage(ScubaTankPacket.FULL, null, false), (EntityPlayerMP)event.player);
|
2016-04-30 17:26:12 +02:00
|
|
|
Mekanism.packetHandler.sendTo(new SecurityUpdateMessage(SecurityPacket.FULL, null, null), (EntityPlayerMP)event.player);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-06-03 19:54:45 +02:00
|
|
|
Mekanism.logger.info("Sent config to '" + event.player.getDisplayName() + ".'");
|
2013-12-09 23:08:47 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-04 21:43:03 +01:00
|
|
|
|
2014-04-20 22:15:44 +02:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onPlayerLogoutEvent(PlayerLoggedOutEvent event)
|
|
|
|
{
|
2015-03-20 06:39:22 +01:00
|
|
|
Mekanism.jetpackOn.remove(event.player.getCommandSenderName());
|
|
|
|
Mekanism.gasmaskOn.remove(event.player.getCommandSenderName());
|
|
|
|
Mekanism.flamethrowerActive.remove(event.player.getCommandSenderName());
|
2013-12-04 21:43:03 +01:00
|
|
|
}
|
|
|
|
|
2014-04-20 22:15:44 +02:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onPlayerDimChangedEvent(PlayerChangedDimensionEvent event)
|
|
|
|
{
|
2015-03-20 06:39:22 +01:00
|
|
|
Mekanism.jetpackOn.remove(event.player.getCommandSenderName());
|
|
|
|
Mekanism.gasmaskOn.remove(event.player.getCommandSenderName());
|
|
|
|
Mekanism.flamethrowerActive.remove(event.player.getCommandSenderName());
|
2014-05-30 23:49:24 +02:00
|
|
|
|
|
|
|
if(!event.player.worldObj.isRemote)
|
|
|
|
{
|
2014-06-11 11:57:49 +02:00
|
|
|
Mekanism.packetHandler.sendTo(new JetpackDataMessage(JetpackPacket.FULL, null, false), (EntityPlayerMP)event.player);
|
|
|
|
Mekanism.packetHandler.sendTo(new ScubaTankDataMessage(ScubaTankPacket.FULL, null, false), (EntityPlayerMP)event.player);
|
2014-05-30 23:49:24 +02:00
|
|
|
}
|
2014-04-20 22:15:44 +02:00
|
|
|
}
|
2013-12-04 21:43:03 +01:00
|
|
|
}
|