org.bukkit.event.player.PlayerJoinEvent Java Examples

The following examples show how to use org.bukkit.event.player.PlayerJoinEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerJoin.java    From CratesPlus with GNU General Public License v3.0 8 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPlayerJoin(final PlayerJoinEvent event) {
    Bukkit.getScheduler().runTaskLater(cratesPlus, () -> {
        if (cratesPlus.isUpdateAvailable() && event.getPlayer().hasPermission("cratesplus.updates")) {
            event.getPlayer().sendMessage(cratesPlus.getUpdateMessage());
        }
        if (cratesPlus.getConfigBackup() != null && event.getPlayer().hasPermission("cratesplus.admin")) {
            event.getPlayer().sendMessage(cratesPlus.getPluginPrefix() + ChatColor.GREEN + "Your config has been updated. Your old config was backed up to " + cratesPlus.getConfigBackup());
            cratesPlus.setConfigBackup(null);
        }
        if (cratesPlus.getCrateHandler().hasPendingKeys(event.getPlayer().getUniqueId())) {
            if (cratesPlus.getConfigHandler().getClaimMessageDelay() > -1) {
                Bukkit.getScheduler().runTaskLater(cratesPlus, () -> MessageHandler.sendMessage(event.getPlayer(), "&aYou currently have keys waiting to be claimed, use /crate to claim", null, null), cratesPlus.getConfigHandler().getClaimMessageDelay() > 0 ? (20 * cratesPlus.getConfigHandler().getClaimMessageDelay()) : 0);
            }
        }
    }, 1L);
}
 
Example #2
Source File: ItemsTests.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void newPlayerShouldRecieveAShelterItem() {
    loadRegionTypeShelter();
    CivilianManager.getInstance();
    PlayerJoinEvent event = new PlayerJoinEvent(TestUtil.player, "blah");
    CivilianListener civilianListener = new CivilianListener();
    civilianListener.onCivilianJoin(event);
    Civilian civilian = CivilianManager.getInstance().getCivilian(TestUtil.player.getUniqueId());
    boolean hasShelter = false;
    for (String currentName : civilian.getStashItems().keySet()) {
        if (currentName.equalsIgnoreCase("shelter")) {
            hasShelter = true;
        }
    }
    assertTrue(hasShelter);
}
 
Example #3
Source File: CooldownManager.java    From Minepacks with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoinEvent(PlayerJoinEvent event)
{
	if(syncCooldown)
	{
		final UUID uuid = event.getPlayer().getUniqueId();
		cooldowns.put(uuid, System.currentTimeMillis() + cooldown); // Temporary cooldown till the data is loaded from the database
		plugin.getDatabase().getCooldown(event.getPlayer(), new Callback<Long>() {
			@Override
			public void onResult(Long dbCooldownTime)
			{
				if(dbCooldownTime > System.currentTimeMillis())
				{
					cooldowns.put(uuid, dbCooldownTime);
				}
			}

			@Override
			public void onFail() {}
		});
	}
	else if(addOnJoin)
	{
		setCooldown(event.getPlayer());
	}
}
 
Example #4
Source File: PlayerListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    final Game game = Main.getApi().getFirstWaitingGame();

    if (game != null) {
        game.joinToGame(event.getPlayer());
    } else if (!player.hasPermission("misat11.bw.admin")) {
        ByteArrayDataOutput out = ByteStreams.newDataOutput();

        out.writeUTF("Connect");
        out.writeUTF(Main.getApi().getHubServerName());

        player.sendPluginMessage(Main.getInstance(), "BungeeCord", out.toByteArray());
    }
}
 
Example #5
Source File: PlayerListenerTest.java    From AuthMeReloaded with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void shouldNotModifyJoinMessage() {
    // given
    Player player = mock(Player.class);
    String joinMsg = "The player joined";
    PlayerJoinEvent event = new PlayerJoinEvent(player, joinMsg);
    given(settings.getProperty(RegistrationSettings.REMOVE_JOIN_MESSAGE)).willReturn(false);
    given(settings.getProperty(RegistrationSettings.CUSTOM_JOIN_MESSAGE)).willReturn("");
    given(settings.getProperty(RegistrationSettings.DELAY_JOIN_MESSAGE)).willReturn(false);

    // when
    listener.onJoinMessage(event);

    // then
    assertThat(event.getJoinMessage(), equalTo(joinMsg));
    verifyNoInteractions(joinMessageService);
}
 
Example #6
Source File: PlayerTracker.java    From MineCloud with ISC License 6 votes vote down vote up
@EventHandler
public void playerJoin(PlayerJoinEvent event) {
    Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
        Server server = plugin.server();
        List<PlayerData> onlinePlayers = server.onlinePlayers();
        Player player = event.getPlayer();
        PlayerData data = new PlayerData();

        data.setHealth(player.getHealth());
        data.setMaxHealth(player.getMaxHealth());
        data.setName(player.getName());
        data.setId(player.getUniqueId().toString());

        onlinePlayers.add(data);

        server.setOnlinePlayers(onlinePlayers);
        plugin.updatePlayers(server);
        plugin.mongo().repositoryBy(Server.class).save(server);
    });
}
 
Example #7
Source File: PlayerListener.java    From AnimatedFrames with MIT License 6 votes vote down vote up
@EventHandler
public void on(final PlayerJoinEvent event) {
	Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
		@Override
		public void run() {
			for (AnimatedFrame frame : plugin.frameManager.getFrames()) {
				frame.addViewer(event.getPlayer());
			}
		}
	}, 20);

	if (event.getPlayer().hasPermission("animatedframes.updatecheck")) {
		plugin.spigetUpdate.checkForUpdate(new UpdateCallback() {
			@Override
			public void updateAvailable(String s, String s1, boolean b) {
				plugin.updateAvailable = true;
				event.getPlayer().sendMessage("§aA new version for §6AnimatedFrames §ais available (§7v" + s + "§a). Download it from https://r.spiget.org/5583");
			}

			@Override
			public void upToDate() {
			}
		});
	}
}
 
Example #8
Source File: ModerationCommand.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onLogin(PlayerJoinEvent event) {
  Optional<BannedAccountInfo> ban =
      getBanWithMatchingIP(event.getPlayer().getAddress().getAddress().getHostAddress());

  ban.ifPresent(
      info -> {
        if (!isBanStillValid(event.getPlayer())) {
          removeCachedBan(info);
          return;
        }

        final MatchPlayer matchPlayer = manager.getPlayer(event.getPlayer());
        final Match match = matchPlayer.getMatch();

        ChatDispatcher.broadcastAdminChatMessage(
            formatAltAccountBroadcast(info, matchPlayer), match);
      });
}
 
Example #9
Source File: PGMListener.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void addPlayerOnJoin(final PlayerJoinEvent event) {
  if (this.mm.getMatch(event.getWorld()) == null) {
    event
        .getPlayer()
        .kickPlayer(
            ChatColor.RED + TextTranslations.translate("misc.incorrectWorld", event.getPlayer()));
    this.parent
        .getLogger()
        .info(
            "Had to kick player "
                + event.getPlayer().getName()
                + " due to them spawning in the incorrect world");
    return;
  }

  this.mm.getMatch(event.getWorld()).addPlayer(event.getPlayer());
}
 
Example #10
Source File: ConnectionListener.java    From FastLogin with MIT License 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent joinEvent) {
    Player player = joinEvent.getPlayer();

    Bukkit.getScheduler().runTaskLater(plugin, () -> {
        // session exists so the player is ready for force login
        // cases: Paper (firing BungeeCord message before PlayerJoinEvent) or not running BungeeCord and already
        // having the login session from the login process
        BukkitLoginSession session = plugin.getSession(player.getAddress());
        if (session == null) {
            String sessionId = plugin.getSessionId(player.getAddress());
            plugin.getLog().info("No on-going login session for player: {} with ID {}", player, sessionId);
        } else {
            Runnable forceLoginTask = new ForceLoginTask(plugin.getCore(), player, session);
            Bukkit.getScheduler().runTaskAsynchronously(plugin, forceLoginTask);
        }

        plugin.getBungeeManager().markJoinEventFired(player);
        // delay the login process to let auth plugins initialize the player
        // Magic number however as there is no direct event from those plugins
    }, DELAY_LOGIN);
}
 
Example #11
Source File: Main.java    From TAB with Apache License 2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void a(PlayerJoinEvent e) {
	try {
		if (Shared.disabled) return;
		if (Configs.bukkitBridgeMode) return;
		ITabPlayer p = new TabPlayer(e.getPlayer());
		Shared.data.put(e.getPlayer().getUniqueId(), p);
		Shared.entityIdMap.put(e.getPlayer().getEntityId(), p);
		inject(e.getPlayer().getUniqueId());
		Shared.featureCpu.runMeasuredTask("processing player join", CPUFeature.OTHER, new Runnable() {

			public void run() {
				Shared.joinListeners.forEach(f -> f.onJoin(p));
				p.onJoinFinished = true;
			}
		});
	} catch (Throwable ex) {
		Shared.errorManager.criticalError("An error occurred when processing PlayerJoinEvent", ex);
	}
}
 
Example #12
Source File: BukkitPingCounter.java    From Plan with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPlayerJoin(PlayerJoinEvent joinEvent) {
    Player player = joinEvent.getPlayer();
    Long pingDelay = config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY);
    if (pingDelay >= TimeUnit.HOURS.toMillis(2L)) {
        return;
    }
    runnableFactory.create("Add Player to Ping list", new AbsRunnable() {
        @Override
        public void run() {
            if (player.isOnline()) {
                addPlayer(player);
            }
        }
    }).runTaskLater(TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS));
}
 
Example #13
Source File: EventListener.java    From iDisguise with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoinHighest(PlayerJoinEvent event) {
	Player player = event.getPlayer();
	ProfileHelper.getInstance().registerGameProfile(player);
	if(DisguiseManager.isDisguised(player)) {
		if(!plugin.getLanguage().JOIN_DISGUISED.isEmpty())
			player.sendMessage(plugin.getLanguage().JOIN_DISGUISED);
	}
	if(plugin.getConfiguration().MODIFY_MESSAGE_JOIN) {
		if(event.getJoinMessage() != null && DisguiseManager.isDisguised(player)) {
			if(DisguiseManager.getDisguise(player) instanceof PlayerDisguise) {
				event.setJoinMessage(event.getJoinMessage().replace(player.getName(), ((PlayerDisguise)DisguiseManager.getDisguise(player)).getDisplayName()));
			} else {
				event.setJoinMessage(null);
			}
		}
	}
	if(player.hasPermission("iDisguise.update") && plugin.getConfiguration().UPDATE_CHECK) {
		plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new UpdateCheck(plugin, player, plugin.getConfiguration().UPDATE_DOWNLOAD), 20L);
	}
}
 
Example #14
Source File: DPlayerListener.java    From DungeonsXL with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    if (plugin.checkPlayer(player)) {
        return;
    }

    DGlobalPlayer dPlayer = new DGlobalPlayer(plugin, player);
    if (dPlayer.getData().wasInGame()) {
        dPlayer.reset(dPlayer.getData().getOldLocation() != null ? dPlayer.getData().getOldLocation() : Bukkit.getWorlds().get(0).getSpawnLocation(),
                dPlayer.getData().getKeepInventoryAfterLogout());
    }

    if (!dPlayer.getData().hasFinishedTutorial() && config.isTutorialActivated()) {
        if (plugin.getInstanceCache().size() < config.getMaxInstances()) {
            dPlayer.startTutorial();
        } else {
            event.getPlayer().kickPlayer(DMessage.ERROR_TOO_MANY_TUTORIALS.getMessage());
        }
    }
}
 
Example #15
Source File: UHPluginListener.java    From KTP with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent ev) {
	if (!this.p.isGameRunning()) {
		ev.getPlayer().setGameMode(GameMode.CREATIVE);
		Location l = ev.getPlayer().getWorld().getSpawnLocation();
		ev.getPlayer().teleport(l.add(0,1,0));
	}
	p.addToScoreboard(ev.getPlayer());
	Bukkit.getScheduler().runTaskLater(this.p, new BukkitRunnable() {
		
		@Override
		public void run() {
			p.updatePlayerListName(ev.getPlayer());
		}
	}, 1L);
}
 
Example #16
Source File: ListenerLogin.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
public void onJoin(PlayerJoinEvent e) {
    Player player = e.getPlayer();
    player.setCanPickupItems(false);

    NPCManager npcManager = this.expansion.getNPCManager();
    NPC npc = npcManager.getNPC(player);
    if(npc != null) npc.despawn(DespawnReason.PLUGIN);
    
    Runnable task = () -> {
        punish(player);
        player.setCanPickupItems(true);
    };

    JavaPlugin plugin = this.expansion.getPlugin().getPlugin();
    BukkitScheduler scheduler = Bukkit.getScheduler();
    scheduler.runTaskLater(plugin, task, 1L);
}
 
Example #17
Source File: BonusGoodieManager.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR) 
public void OnPlayerJoinEvent(PlayerJoinEvent event) {
	Inventory inv = event.getPlayer().getInventory();
	
	for (ConfigTradeGood good : CivSettings.goods.values()) {
		for (Entry<Integer, ? extends ItemStack> itemEntry : inv.all(ItemManager.getMaterial(good.material)).entrySet()) {
			if (good.material_data != ItemManager.getData(itemEntry.getValue())) {
				continue;
			}
			
			BonusGoodie goodie = CivGlobal.getBonusGoodie(itemEntry.getValue());
			if (goodie != null) {
				inv.remove(itemEntry.getValue());				
			}
		}
	}
}
 
Example #18
Source File: PlayerListener.java    From Transport-Pipes with MIT License 6 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    if (generalConf.isCraftingEnabled()) {
        List<NamespacedKey> keys = new ArrayList<>();
        for (BaseDuctType bdt : ductRegister.baseDuctTypes()) {
            for (Object type : bdt.ductTypes()) {
                DuctType dt = (DuctType) type;
                if (dt.getDuctRecipe() != null) {
                    NamespacedKey key = ((Keyed) dt.getDuctRecipe()).getKey();
                    keys.add(key);
                }
            }
            if (bdt.is("pipe")) {
                keys.add(((PipeManager) bdt.getDuctManager()).getWrenchRecipe().getKey());
            }
        }
        event.getPlayer().discoverRecipes(keys);
    }
}
 
Example #19
Source File: PlayerJoin.java    From SkinsRestorerX with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent e) {
    Bukkit.getScheduler().runTaskAsynchronously(SkinsRestorer.getInstance(), () -> {
        try {
            if (Config.DISABLE_ONJOIN_SKINS) {
                // factory.applySkin(e.getPlayer(), SkinStorage.getSkinData(SkinStorage.getPlayerSkin(e.getPlayer().getName())));
                // shouldn't it just skip it if it's true?
                return;
            }

            // Don't change skin if player has no custom skin-name set and his username is invalid
            if (plugin.getSkinStorage().getPlayerSkin(e.getPlayer().getName()) == null && !C.validUsername(e.getPlayer().getName())) {
                System.out.println("[SkinsRestorer] Not applying skin to " + e.getPlayer().getName() + " (invalid username).");
                return;
            }

            String skin = plugin.getSkinStorage().getDefaultSkinNameIfEnabled(e.getPlayer().getName());

            SkinsRestorer.getInstance().getFactory().applySkin(e.getPlayer(), plugin.getSkinStorage().getOrCreateSkinForPlayer(skin));
        } catch (SkinRequestException ignored) {
        }
    });
}
 
Example #20
Source File: PlayerListenerTest.java    From AuthMeReloaded with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void shouldDelayJoinMessage() {
    // given
    Player player = mock(Player.class);
    given(player.getName()).willReturn("thename0");
    given(player.getDisplayName()).willReturn("(not used)");
    String joinMsg = "The player joined";
    PlayerJoinEvent event = new PlayerJoinEvent(player, joinMsg);
    given(settings.getProperty(RegistrationSettings.REMOVE_JOIN_MESSAGE)).willReturn(false);
    given(settings.getProperty(RegistrationSettings.CUSTOM_JOIN_MESSAGE))
        .willReturn("{PLAYERNAME} is joining us");
    given(settings.getProperty(RegistrationSettings.DELAY_JOIN_MESSAGE)).willReturn(true);

    // when
    listener.onJoinMessage(event);

    // then
    assertThat(event.getJoinMessage(), nullValue());
    verify(joinMessageService).putMessage("thename0", "thename0 is joining us");
}
 
Example #21
Source File: JoinQuitListener.java    From BetonQuest with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event) {
    String playerID = PlayerConverter.getID(event.getPlayer());
    // start objectives when the data is loaded
    PlayerData playerData = BetonQuest.getInstance().getPlayerData(playerID);
    // if the data still isn't loaded, force loading (this happens sometimes
    // probably because AsyncPlayerPreLoginEvent does not fire)
    if (playerData == null) {
        playerData = new PlayerData(playerID);
        BetonQuest.getInstance().putPlayerData(playerID, playerData);
        LogUtils.getLogger().log(Level.WARNING, "Failed to load data for player " + event.getPlayer().getName() + ", forcing.");
    }
    playerData.startObjectives();
    GlobalObjectives.startAll(playerID);
    // display changelog message to the admins
    if (event.getPlayer().hasPermission("betonquest.admin")
            && new File(BetonQuest.getInstance().getDataFolder(), "CHANGELOG.md").exists()) {
        Config.sendNotify(PlayerConverter.getID(event.getPlayer()), "changelog", null, "changelog,info");
    }
    if (Journal.hasJournal(playerID)) {
        playerData.getJournal().update();
    }
    if (playerData.getConversation() != null) {
        new ConversationResumer(playerID, playerData.getConversation());
    }
}
 
Example #22
Source File: PlayerListener.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
	if (!DiscordBotCore.getInstance().getConfiguration().isPlayerJoin() || event.getPlayer().hasPermission("DiscordBot.Silent")) {
		return;
	}
	
	Message message = new Message()
			.setChannel(DiscordBotCore.getInstance().getConfiguration().getChannels().get("InGame").getChannel())
			.setFormat(DiscordBotCore.getInstance().getConfiguration().getChannelFormat().get("InGame"))
			.setName(event.getPlayer().getName())
			.setNick(event.getPlayer().getDisplayName())
			.setServer("Unknown")
			.setMessage("Joined")
			.setDiscord(true)
			.setMinecraft(false)
			.setConsole(false)
			.setRedis(false);
	
	if (event.getPlayer().getServer() != null && event.getPlayer().getServer().getName() != null) {
		message.setServer(event.getPlayer().getServer().getName());
	}
	
	DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
	return;
}
 
Example #23
Source File: PlayerJoin.java    From StaffPlus with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void onJoin(PlayerJoinEvent event)
{
	Player player = event.getPlayer();
	UUID uuid = player.getUniqueId();
	
	manageUser(player);
	vanishHandler.updateVanish();
	
	if(permission.has(player, options.permissionMode) && options.modeEnableOnLogin)
	{
		modeCoordinator.addMode(player);
	}
	
	if(options.loginEnabled && permission.has(player, options.permissionMember))
	{
		if(securityHandler.hasPassword(uuid))
		{
			freezeHandler.addFreeze(player, player, false);
			message.send(player, messages.loginWaiting, messages.prefixGeneral);
		}else message.send(player, messages.loginRegister, messages.prefixGeneral);
	}
}
 
Example #24
Source File: SlimefunGuideListener.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent e) {
    if (giveOnFirstJoin && !e.getPlayer().hasPlayedBefore()) {
        Player p = e.getPlayer();

        if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
            return;
        }

        SlimefunGuideLayout type = SlimefunPlugin.getCfg().getBoolean("guide.default-view-book") ? SlimefunGuideLayout.BOOK : SlimefunGuideLayout.CHEST;
        p.getInventory().addItem(SlimefunGuide.getItem(type));
    }
}
 
Example #25
Source File: ChatCommand.java    From MarriageMaster with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event)
{
	if(allowChatSurveillance && event.getPlayer().hasPermission(Permissions.LISTEN_CHAT_AUTO_JOIN))
	{
		listeners.add(event.getPlayer());
	}
}
 
Example #26
Source File: VaultPreloadListener.java    From PlayerVaults with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
    final UUID uuid = event.getPlayer().getUniqueId();
    new BukkitRunnable() {
        @Override
        public void run() {
            vm.cachePlayerVaultFile(uuid.toString());
        }
    }.runTaskAsynchronously(PlayerVaults.getInstance());
}
 
Example #27
Source File: EventExecutor.java    From PlayerSQL with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler
public void handle(PlayerJoinEvent event) {
    Player player = event.getPlayer();

    if (!main.getConfig().getBoolean("bungee.mute")) {
        main.debug(String.format("PlayerJoin() -> send peer ready for %s", player.getName()));
        main.getHijUtils().addCustomChannel(player, PlayerSqlProtocol.NAMESPACE);// hacky add channels without register commands
        PeerReady ready = new PeerReady();
        ready.setId(player.getUniqueId());
        player.sendPluginMessage(main, PlayerSqlProtocol.NAMESPACE, ready.encode());
    }

    manager.lockUser(player);
    UUID id = player.getUniqueId();
    Object pend = pending.remove(id);
    if (pend == null) {
        FetchUserTask task = new FetchUserTask(player);
        pending.put(id, task);
        task.runTaskTimerAsynchronously(main, Config.SYN_DELAY, Config.SYN_DELAY);
    } else if (pend instanceof PlayerData) {
        main.debug("process pending data_buf on join event");
        UUID guid = GuidResolveService.getService().getGuid(player);
        main.run(() -> {
            manager.pend(player, (PlayerData) pend);
            runAsync(() -> manager.updateDataLock(guid, true));
        });
    }
}
 
Example #28
Source File: PlayerOnlineListener.java    From Plan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
    try {
        actOnJoinEvent(event);
    } catch (Exception e) {
        errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
    }
}
 
Example #29
Source File: AnniPlayer.java    From AnnihilationPro with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void playerCheck(PlayerJoinEvent event)
{
	final Player p = event.getPlayer();
	if(!exists(p))
		loadPlayer(p);
}
 
Example #30
Source File: TeleportListener.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Priority must be high enough so that whatever applies observer permissions
 * runs before this, since those include the teleport permission. Lobby does it
 * in PlayerListener and PGM does it in SpawnMatchModule.
 */
@EventHandler(priority = EventPriority.MONITOR)
public void onJoin(PlayerJoinEvent event) {
    Received received = requests.remove(event.getPlayer().getUniqueId());
    if(received != null) {
        doTeleport(event.getPlayer(), received.request);
    }
}