123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package me.km.playerbank;
- import me.kcm.events.PlayerConnectionEvent;
- import me.km.KajetansMod;
- import me.km.api.Module;
- import me.km.api.ModuleListener;
- import me.km.api.Utils;
- import me.km.chatchannel.ChatChannel;
- import me.km.commands.CommandTeleportAccept;
- import me.km.dimensions.ModDimensions;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraftforge.fml.common.eventhandler.EventPriority;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- import net.minecraftforge.fml.common.gameevent.PlayerEvent;
- public class PlayerLogInOut extends ModuleListener
- {
- public PlayerLogInOut(Module m)
- {
- super(m);
- }
-
- @SubscribeEvent(priority = EventPriority.HIGH)
- public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent e)
- {
- EntityPlayer p = e.player;
- if(p == null)
- {
- return;
- }
-
- if(!Utils.hasPlayedBefore(p)) // first join
- {
- Utils.teleportEntity(p, Utils.getSpawn());
- }
-
- PlayerBank pb = KajetansMod.playerbank.getDataBank();
- if(!pb.contains(p))
- {
- pb.add(p.getGameProfile());
- this.getModule().sendToConsole(p.getName() + " wurde hinzugefügt.");
- }
- else
- {
- this.getModule().sendToConsole(p.getName() + " ist bereits vorhanden.");
- if(pb.getName(p.getUniqueID().toString()).equals(p.getName()))
- {
- this.getModule().sendToConsole(p.getName() + " hat noch den gleichen Namen.");
- }
- else
- {
- this.getModule().sendToConsole(p.getName() + " hat seinen Namen geändert.");
- pb.changeName(p);
- }
- }
-
- ChatChannel.onPlayerLogIn(p);
- }
-
- @SubscribeEvent(priority = EventPriority.LOW)
- public void onPlayerLeaveCleanup(PlayerEvent.PlayerLoggedOutEvent e)
- {
- EntityPlayer p = e.player;
- KajetansMod.generalCommands.getCommand(CommandTeleportAccept.class).tpaccept.remove(p.getUniqueID());
- KajetansMod.scoreboard.removeScoreboard(p.getUniqueID());
-
- ChatChannel.onPlayerLogOut(p);
- }
-
- @SubscribeEvent
- public void onPlayerConnection(PlayerConnectionEvent e)
- {
- ModDimensions.sendNotificationsForDimensions(e.getEntityPlayer());
- }
- }
|