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.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); } } } @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()); } @SubscribeEvent public void onPlayerConnection(PlayerConnectionEvent e) { ModDimensions.sendNotificationsForDimensions(e.getEntityPlayer()); } }