Java Code Examples for org.bukkit.event.player.PlayerJoinEvent

The following examples show how to use org.bukkit.event.player.PlayerJoinEvent. These examples are extracted from open source projects. 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 Project: CratesPlus   Author: ConnorLinfoot   File: PlayerJoin.java    License: 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 Project: AuthMeReloaded   Author: AuthMe   File: PlayerListenerTest.java    License: 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 #3
Source Project: BedWars   Author: ScreamingSandals   File: PlayerListener.java    License: 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 #4
Source Project: MineCloud   Author: mkotb   File: PlayerTracker.java    License: 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 #5
Source Project: PGM   Author: PGMDev   File: ModerationCommand.java    License: 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 #6
Source Project: PGM   Author: PGMDev   File: PGMListener.java    License: 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 #7
Source Project: TAB   Author: NEZNAMY   File: Main.java    License: 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 #8
Source Project: DungeonsXL   Author: DRE2N   File: DPlayerListener.java    License: 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 #9
Source Project: CombatLogX   Author: SirBlobman   File: ListenerLogin.java    License: 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 #10
Source Project: DiscordBot   Author: LXGaming   File: PlayerListener.java    License: 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 #11
Source Project: FastLogin   Author: games647   File: ConnectionListener.java    License: 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 #12
Source Project: StaffPlus   Author: Shortninja66   File: PlayerJoin.java    License: 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 #13
Source Project: BetonQuest   Author: BetonQuest   File: JoinQuitListener.java    License: 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 #14
Source Project: AuthMeReloaded   Author: AuthMe   File: PlayerListenerTest.java    License: 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 #15
Source Project: SkinsRestorerX   Author: SkinsRestorer   File: PlayerJoin.java    License: 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 #16
Source Project: Transport-Pipes   Author: RoboTricker   File: PlayerListener.java    License: 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 #17
Source Project: civcraft   Author: netizen539   File: BonusGoodieManager.java    License: 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 Project: KTP   Author: Azenet   File: UHPluginListener.java    License: 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 #19
Source Project: iDisguise   Author: robingrether   File: EventListener.java    License: 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 #20
Source Project: Plan   Author: plan-player-analytics   File: BukkitPingCounter.java    License: 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 #21
Source Project: AnimatedFrames   Author: InventivetalentDev   File: PlayerListener.java    License: 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 #22
Source Project: Civs   Author: Multitallented   File: ItemsTests.java    License: 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 #23
Source Project: Minepacks   Author: GeorgH93   File: CooldownManager.java    License: 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 #24
Source Project: AnnihilationPro   Author: MrLittleKitty   File: AnniPlayer.java    License: 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 #25
Source Project: IridiumSkyblock   Author: IridiumLLC   File: PlayerJoinLeaveListener.java    License: GNU General Public License v2.0 5 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    try {
        final Player player = event.getPlayer();
        final IridiumSkyblock plugin = IridiumSkyblock.getInstance();
        if (player.isOp()) {
            final String latest = plugin.getLatest();
            if (plugin.getLatest() != null
                    && IridiumSkyblock.getConfiguration().notifyAvailableUpdate
                    && !latest.equals(plugin.getDescription().getVersion())) {
                final String prefix = IridiumSkyblock.getConfiguration().prefix;
                player.sendMessage(Utils.color(prefix + " &7This message is only seen by opped players."));
                player.sendMessage(Utils.color(prefix + " &7Newer version available: " + latest));
            }
        }

        final Location location = player.getLocation();
        final IslandManager islandManager = IridiumSkyblock.getIslandManager();
        if (!islandManager.isIslandWorld(location)) return;

        final User user = User.getUser(player);
        user.name = player.getName();

        if (user.flying && (user.getIsland() == null || user.getIsland().getFlightBooster() == 0)) {
            player.setAllowFlight(false);
            player.setFlying(false);
            user.flying = false;
        }
        user.bypassing = false;

        final Island island = islandManager.getIslandViaLocation(location);
        if (island == null) return;

        Bukkit.getScheduler().runTaskLater(plugin, () -> island.sendBorder(player), 1);
    } catch (Exception e) {
        IridiumSkyblock.getInstance().sendErrorMessage(e);
    }
}
 
Example #26
Source Project: mcspring-boot   Author: Alan-Gomes   File: ListenerTest.java    License: MIT License 5 votes vote down vote up
@Test
public void shouldRegisterAllEventsInTheListener() {
    verify(server.getPluginManager()).registerEvent(eq(PlayerJoinEvent.class), eq(testListener),
            eq(EventPriority.NORMAL), notNull(), eq(plugin), eq(true));
    verify(server.getPluginManager()).registerEvent(eq(PlayerQuitEvent.class), eq(testListener),
            eq(EventPriority.HIGHEST), notNull(), eq(plugin), eq(false));
}
 
Example #27
Source Project: mcspring-boot   Author: Alan-Gomes   File: ListenerTest.java    License: MIT License 5 votes vote down vote up
@Test
@SneakyThrows
public void shouldExecuteEventOnListener() {
    springEventExecutor
            .create(TestListener.class.getDeclaredMethod("onJoin", PlayerJoinEvent.class))
            .execute(testListener, new PlayerJoinEvent(player, ""));

    verify(player).sendMessage("join");
    verify(player, never()).sendMessage("quit");
}
 
Example #28
Source Project: PGM   Author: PGMDev   File: FreezeMatchModule.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
  if (freeze.isCached(event.getPlayer().getUniqueId())) {
    freeze.removeCachedPlayer(event.getPlayer().getUniqueId());
    freeze.setFrozen(Bukkit.getConsoleSender(), match.getPlayer(event.getPlayer()), true, true);
  }
}
 
Example #29
Source Project: BetonQuest   Author: BetonQuest   File: BetonLangAPIIntegrator.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void hook() {
    new LangChangeListener();
    for (Player player : Bukkit.getOnlinePlayers()) {
        updateLang(player);
    }
    Bukkit.getPluginManager().registerEvents(new Listener() {
        @EventHandler(ignoreCancelled = true)
        public void onJoin(PlayerJoinEvent event) {
            updateLang(event.getPlayer());
        }
    }, BetonQuest.getInstance());
    plugin.registerEvents("language", BetonLangAPIEvent.class);
}
 
Example #30
Source Project: TrMenu   Author: Arasple   File: Updater.java    License: MIT License 5 votes vote down vote up
@EventHandler
public void onJoin(PlayerJoinEvent e) {
    Player p = e.getPlayer();

    if (old && !noticed.contains(p.getUniqueId()) && p.hasPermission("trmenu.admin")) {
        noticed.add(p.getUniqueId());
        Bukkit.getScheduler().runTaskLaterAsynchronously(TrMenu.getPlugin(), () -> TLocale.sendTo(p, "PLUGIN.UPDATER.OLD", newVersion), 1);
    }
}