當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerQuitEvent類代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerQuitEvent的典型用法代碼示例。如果您正苦於以下問題:Java PlayerQuitEvent類的具體用法?Java PlayerQuitEvent怎麽用?Java PlayerQuitEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PlayerQuitEvent類屬於org.bukkit.event.player包,在下文中一共展示了PlayerQuitEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onQuit

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onQuit(PlayerQuitEvent event) {
    if ((teamManagerModule.getTeam(event.getPlayer()) != null && teamManagerModule.getTeam(event.getPlayer()).isSpectator())) return;
    updateScoreboardTeamLine(teamManagerModule.getTeam(event.getPlayer()), getAlivePlayers(teamManagerModule.getTeam(event.getPlayer())).size() - 1);

    if (!TGM.get().getMatchManager().getMatch().getMatchStatus().equals(MatchStatus.MID)) return;

    if (lastTeamAlive()) {
        MatchTeam winnerTeam = teamManagerModule.getTeams().stream().filter(matchTeam -> !matchTeam.isSpectator()).filter(matchTeam -> getAlivePlayers(matchTeam).size() > 0).findFirst().get();
        if (winnerTeam == null) {
            winnerTeam = teamManagerModule.getTeams().get(1);
        }
        TGM.get().getMatchManager().endMatch(winnerTeam);
        return;
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:17,代碼來源:BlitzModule.java

示例2: ensureSetup

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
private static void ensureSetup() {
    if (SETUP.get()) {
        return;
    }

    if (!SETUP.getAndSet(true)) {

        // remove player metadata when they leave the server
        Events.subscribe(PlayerQuitEvent.class, EventPriority.MONITOR)
                .handler(e -> StandardMetadataRegistries.PLAYER.remove(e.getPlayer().getUniqueId()));

        // cache housekeeping task
        Scheduler.builder()
                .async()
                .afterAndEvery(1, TimeUnit.MINUTES)
                .run(() -> {
                    for (MetadataRegistry<?> registry : StandardMetadataRegistries.values()) {
                        registry.cleanup();
                    }
                });
    }
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:23,代碼來源:Metadata.java

示例3: handlePlayerQuit

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
private void handlePlayerQuit(PlayerQuitEvent event) {
    Player player = event.getPlayer();

    teams.values().forEach(t -> {
        t.unsubscribe(player, true);
        t.removePlayer(player);
    });
    objectives.values().forEach(o -> o.unsubscribe(player, true));

    Map<String, PacketScoreboardObjective> playerObjectives = this.playerObjectives.remove(player.getUniqueId());
    if (playerObjectives != null) {
        playerObjectives.values().forEach(o -> o.unsubscribe(player, true));
    }

    Map<String, PacketScoreboardTeam> playerTeams = this.playerTeams.remove(player.getUniqueId());
    if (playerTeams != null) {
        playerTeams.values().forEach(t -> {
            t.unsubscribe(player, true);
            t.removePlayer(player);
        });
    }
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:23,代碼來源:PacketScoreboard.java

示例4: playerLeave

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler
public void playerLeave(PlayerQuitEvent event){
	event.setQuitMessage("");
	VPPlayer player = getPlayer(event.getPlayer());
	player.setMenu(null);
	VPPLeaveEvent e = new  VPPLeaveEvent(player);
	if(getMsgPerm().has(player))
		e.setMessage(leave);
	e.save(player.save());
	player.setOffline();
	Bukkit.getServer().getPluginManager().callEvent(e);
	//TODO send removed event
	if(e.getMessage() != null)
		e.getMessage().addSReplacement(PlaceH.SENDER.get(), player).send();
	if(e.save())
		save(player, false);
}
 
開發者ID:dracnis,項目名稱:VanillaPlus,代碼行數:18,代碼來源:PlayerManager.java

示例5: onQuit

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler
public void onQuit(PlayerQuitEvent event) {
	// Removing Speed Miner effect
	if(speedMiner.get(event.getPlayer().getName()) != null) {
		speedMiner.get(event.getPlayer().getName()).removeEnchantment(Enchantment.DIG_SPEED);
		event.getPlayer().removePotionEffect(PotionEffectType.FAST_DIGGING);
		event.getPlayer().removePotionEffect(PotionEffectType.SPEED);
		speedMiner.remove(event.getPlayer().getName());
	}
	// Removing Rainbow Miner effect
	if(rainbowMiner.get(event.getPlayer().getName()) != null) {
		rainbowMiner.get(event.getPlayer().getName()).removeEnchantment(Enchantment.LOOT_BONUS_BLOCKS);
		event.getPlayer().removePotionEffect(PotionEffectType.FAST_DIGGING);
		rainbowMiner.remove(event.getPlayer().getName());
	}
	// Removing Diamond Miner effect
	if(diamondMiner.get(event.getPlayer().getName()) != null) {
		diamondMiner.remove(event.getPlayer().getName());
	}
	// Quiting challenge in case player is doing it
	if(plugin.getChallenges().getChallenge(event.getPlayer()) > 0){
		plugin.getChallenges().quitChallenge(event.getPlayer());
	}
	plugin.getPlayerManager().saveData(event.getPlayer());
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:26,代碼來源:PlayerListener.java

示例6: onQuit

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler
public void onQuit(PlayerQuitEvent e) {
    Player p = e.getPlayer();
    if (FakeAPI.getFakeEntities().containsKey(p.getName())) {
        PlayerFakeUtil.unFollowPlayer(p);
        PlayerFakeUtil.normalizeLook(p);
        PlayerFakeUtil.cancelAllSplittedTasks(p);

        ArmorstandFakeUtil.unFollowArmorstand(p);
        ArmorstandFakeUtil.cancelAllSplittedTasks(p);

        EndercrystalFakeUtil.cancelAllSplittedTasks(p);

        MobFakeUtil.unFollowPlayer(p);
        MobFakeUtil.normalizeLook(p);
        MobFakeUtil.cancelAllSplittedTasks(p);

        BigItemFakeUtil.cancelAllSplittedTasks(p);

        FakeAPI.getFakeEntities().remove(p.getName());
    }
}
 
開發者ID:AlphaHelixDev,項目名稱:AlphaLibary,代碼行數:23,代碼來源:FakeEventListener.java

示例7: onPlayerQuit

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
	event.setQuitMessage(null);
	if (SurvivalGames.getWinner() != null)
		return;
	
	Player p = event.getPlayer();
	Gamer t = Gamer.get(event.getPlayer());
	
	if (!Game.getTributes().contains(t))
		return;

	Hive.getInstance().kill(p, "quit", SurvivalGames.getGame().getGameID());
	t.setVariable("death-location", event.getPlayer().getLocation());
	Chat.server("&4[SG &6" + Gamer.get(p).getPrefix()  + t.getName() + " &6has quit the game!");
	Chat.server("&4[SG] &6There are " + (Game.getTributes().size() - 1) + " tributes remaining");
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:18,代碼來源:GameEvents.java

示例8: onPlayerLogout

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler
public void onPlayerLogout (PlayerQuitEvent event)
{
    Player eventPlayer = event.getPlayer ();

    PlayerManager.Instance ().removePlayer (eventPlayer.getUniqueId ());
}
 
開發者ID:MagnaRisa,項目名稱:CraftyProfessions,代碼行數:8,代碼來源:CoreListener.java

示例9: onPlayerQuit

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
    Player player = event.getPlayer();
    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
    if (playerFaction != null) {
        playerFaction.broadcast(prefix + ChatColor.GRAY + "Your faction member " + ChatColor.GOLD  + playerFaction.getMember(player).getRole().getAstrix() + player.getName() + ChatColor.GRAY + " has " + ChatColor.RED + "disconnected.");
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:9,代碼來源:FactionListener.java

示例10: onQuit

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler
public void onQuit(PlayerQuitEvent e){
	Player p = e.getPlayer();
	if(PlayerManager.confirmationReady.contains(p)){
		PlayerManager.confirmationReady.remove(p); 
	}
}
 
開發者ID:DiscowZombie,項目名稱:UltimateTs,代碼行數:8,代碼來源:TypeYesOrNo.java

示例11: onPlayerLeave

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event) {
    if (teamManager.getTeamById("infected").getMembers().size() == 0 && match.getMatchStatus().equals(MatchStatus.MID)) {
        PlayerContext player = teamManager.getTeamById("humans").getMembers().get(teamManager.getTeamById("humans").getMembers().size() - 1);
        broadcastMessage(String.format("&2&l%s &7has been infected!", player.getPlayer().getName()));

        infect(player.getPlayer());
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:10,代碼來源:InfectionModule.java

示例12: onPlayerQuit

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
    if (!this.useTaskInstead)
        return;
    BukkitTask task = wallBorderTask.remove(event.getPlayer().getUniqueId());
    if (task != null) {
        task.cancel();
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:10,代碼來源:WallBorderListener.java

示例13: setup

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@Override
public void setup(@Nonnull TerminableConsumer consumer) {
    Events.subscribe(PlayerLoginEvent.class, EventPriority.MONITOR)
            .filter(e -> e.getResult() == PlayerLoginEvent.Result.ALLOWED)
            .handler(e -> {
                plugin.getDataManager().logPlayer(e.getPlayer().getUniqueId(), e.getPlayer().getName());
                Metadata.provideForPlayer(e.getPlayer()).put(NetworkAnalytics.CONNECTION_TIME_SECONDS, (System.currentTimeMillis() / 1000L));
            })
            .bindWith(consumer);

    Events.subscribe(PlayerJoinEvent.class, EventPriority.MONITOR)
            .handler(e -> {
                ProtocolVersion protocolVersion = ProtocolSupportAPI.getProtocolVersion(e.getPlayer());
                if (protocolVersion != null) {
                    Metadata.provideForPlayer(e.getPlayer()).put(NetworkAnalytics.PROTOCOL_VERSION, protocolVersion);
                }
            })
            .bindWith(consumer);

    Events.subscribe(PlayerQuitEvent.class)
            .handler(e -> {
                Long loginTime = Metadata.provideForPlayer(e.getPlayer()).getOrNull(NetworkAnalytics.CONNECTION_TIME_SECONDS);
                long now = System.currentTimeMillis() / 1000L;
                if (loginTime != null) {
                    long diff = now - loginTime;
                    int mins = (int) TimeUnit.SECONDS.toMinutes(diff);
                    if (mins > 0) {
                        plugin.getDataManager().incrementPlayerMinutesPlayed(e.getPlayer().getUniqueId(), mins);
                    }
                }
            })
            .bindWith(consumer);
}
 
開發者ID:lucko,項目名稱:NetworkAnalytics,代碼行數:34,代碼來源:AnalyticsListener.java

示例14: onLogoff

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler
public void onLogoff(PlayerQuitEvent event) {
    Player player = event.getPlayer();

    if (timer != Timer.COMPLETE) // vote is running
        if (player.hasPermission("skipnight.vote")) { // player has permission
            Voter voter = new Voter(player.getUniqueId());
            if (voters.contains(voter)) { // player is in voter list
                voter = (Voter) voters.get(voters.lastIndexOf(voter));
                if (voter.getVote() == 1) yes--;
                if (voter.getVote() == -1) no--;
                voters.remove(voter);
            }
        }
}
 
開發者ID:mattboy9921,項目名稱:SkipNight,代碼行數:16,代碼來源:Vote.java

示例15: onPlayerQuit

import org.bukkit.event.player.PlayerQuitEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerQuit(PlayerQuitEvent event) {
    BlockHitManager.clearHistory(event.getPlayer());
    if (OrebfuscatorConfig.UseProximityHider) {
        ProximityHider.clearPlayer(event.getPlayer());
    }
}
 
開發者ID:SamaGames,項目名稱:AntiCheat,代碼行數:8,代碼來源:OrebfuscatorPlayerListener.java


注:本文中的org.bukkit.event.player.PlayerQuitEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。