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


Java PlayerGameModeChangeEvent.getPlayer方法代碼示例

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


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

示例1: onPlayerGameModeChangeEvent

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerGameModeChangeEvent(PlayerGameModeChangeEvent event)
{
	Player player = event.getPlayer();
	
	if (!WorldGuardUtils.hasBypass(player))
	{
		new BukkitRunnable()
		{
			@Override
			public void run()
			{
				try
				{
					event.getPlayer().setAllowFlight(WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(FlyFlag.class).getCurrentValue());
				}
				catch(Exception ignored)
				{
					
				}
			}
		}.runTask(WorldGuardExtraFlagsPlugin.getPlugin());
	}
}
 
開發者ID:isokissa3,項目名稱:WorldGuardExtraFlagsPlugin,代碼行數:25,代碼來源:PlayerListener.java

示例2: onPlayerGameModeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
    Player player = event.getPlayer();
    GameMode oldGameMode = player.getGameMode();
    GameMode newGameMode = event.getNewGameMode();
    Group group = plugin.getGroupManager().getGroupFromWorld(player.getWorld().getName());
    if (group == null) {
        group = new Group(player.getWorld().getName(), null, null);
    }

    plugin.getSerializer().writePlayerDataToFile(player,
            PlayerSerialization.serializePlayer(player, plugin),
            group,
            oldGameMode);

    plugin.getSerializer().getPlayerDataFromFile(
            player,
            group,
            newGameMode);
}
 
開發者ID:ThisIzEthan,項目名稱:NexusInventory,代碼行數:21,代碼來源:PlayerGameModeChangeListener.java

示例3: onPlayerQuitCreative

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerQuitCreative(final PlayerGameModeChangeEvent event) {
    if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
        final boolean wasFlying = event.getPlayer().isFlying();
        final Player player = event.getPlayer();
        if (Perms.hasFly(event.getPlayer()) && this.feature.hasFlyMode(event.getPlayer())) {
            Bukkit.getScheduler().runTaskLater(this.feature.getPlugin(), new BukkitRunnable() {

                @Override
                public void run() {
                    if (player.isOnline()) {
                        player.setAllowFlight(true);
                        player.setFlying(wasFlying);
                    }
                }
            }, 1L);
        }
    }
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:20,代碼來源:FlyModeListener.java

示例4: onChangeGM

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onChangeGM(PlayerGameModeChangeEvent e) {
	Player p = e.getPlayer();
       UUID pU = e.getPlayer().getUniqueId();
       
	int GamemodeTemp1 = 0; 
       if (e.getNewGameMode() == GameMode.SURVIVAL) {
       	GamemodeTemp1 = 0;
       } else if (e.getNewGameMode() == GameMode.CREATIVE) {
       	GamemodeTemp1 = 1;
       } else if (e.getNewGameMode() == GameMode.ADVENTURE) {
       	GamemodeTemp1 = 2;
       } else if (e.getNewGameMode() == GameMode.SPECTATOR) {
       	GamemodeTemp1 = 3;
       }
       int GamemodeTemp2 = Integer.valueOf(GamemodeTemp1);
       
       if (!ConfigTemp.getConfig().contains(String.valueOf(pU))) {
       	ConfigTemp.getConfig().set(pU+".Player", String.valueOf(p));
       	ConfigTemp.getConfig().set(pU+".Options.Gamemode", Integer.valueOf(GamemodeTemp2));
       	
       	ConfigTemp.saveConfigFile();
       } else if (ConfigTemp.getConfig().contains(String.valueOf(pU))) {
       	ConfigTemp.getConfig().set(pU+".Player", String.valueOf(p));
       	ConfigTemp.getConfig().set(pU+".Options.Gamemode", Integer.valueOf(GamemodeTemp2));
       	
       	ConfigTemp.saveConfigFile();
       }
}
 
開發者ID:DianoxDragon,項目名稱:UltimateSpawn,代碼行數:30,代碼來源:LittlesEvent.java

示例5: onGameModeSwitch

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

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (event.getNewGameMode() == GameMode.CREATIVE) {
        InventoryLocker.unlockSlots(player);
    } else if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
        InventoryLocker.lockSlots(player, true);
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:15,代碼來源:LockerListener.java

示例6: onGamemodeChange

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

	if (event.getNewGameMode() != GameMode.CREATIVE || Thirst.getInstance().getYAMLConfig().ignoreCreative)
	{
		ThirstManager.getThirst().displayThirst(player);
		return;
	}
	else if (event.getNewGameMode() == GameMode.CREATIVE && !Thirst.getInstance().getYAMLConfig().ignoreCreative)
	{
		for (PotionEffect effect : player.getActivePotionEffects())
		{
			player.removePotionEffect(effect.getType());
		}
	}

	if (Thirst.getInstance().getYAMLConfig().displayType.equalsIgnoreCase("scoreboard"))
	{
		if (Thirst.getInstance().getYAMLConfig().displayType.equalsIgnoreCase("SCOREBOARD"))
			player.setScoreboard(Bukkit.getServer().getScoreboardManager().getNewScoreboard());
	}
	else if (Thirst.getInstance().getYAMLConfig().displayType.equalsIgnoreCase("action"))
	{
		UtilActionBar.getInstance().sendActionBar(player, "");
	}
	else if (Thirst.getInstance().getYAMLConfig().displayType.equalsIgnoreCase("bossbar"))
	{
		ThirstData data = ThirstManager.getThirst().getThirstData(player);

		if (data.getBar() != null)
		{
			data.getBar().removePlayer(player);
		}
	}
}
 
開發者ID:GamerKing195,項目名稱:Thirst,代碼行數:38,代碼來源:PlayerGamemodeChangeListener.java

示例7: onGameModeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onGameModeChange(PlayerGameModeChangeEvent e) {
    Player p = e.getPlayer();
    if (playerStateInfoMap.containsKey(p) && e.getNewGameMode() != GameMode.SPECTATOR) {
        // Don't let low-priority event listeners cancel the gamemode change
        if (e.isCancelled()) e.setCancelled(false);
    }
}
 
開發者ID:MyzelYam,項目名稱:SuperVanish,代碼行數:9,代碼來源:SilentOpenChest.java

示例8: onPlayerGameModeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
    if (event.isCancelled()) {
        return;
    }

    Player player = event.getPlayer();
    Group group = groupManager.getGroupFromWorld(player.getWorld().getName());

    ConsoleLogger.debug("[GM PROCESS] Player '" + player.getName() + "' changed to GameMode '" +
            event.getNewGameMode().name() + "' in group '" + group.getName() + "'");

    playerManager.addPlayer(player, group);
    bukkitService.runTaskLater(() -> process.processGameModeChange(player, event.getNewGameMode(), group), 1L);
}
 
開發者ID:Gnat008,項目名稱:PerWorldInventory,代碼行數:16,代碼來源:PlayerGameModeChangeListener.java

示例9: onPlayerGameModeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event){
	if(enableEventGameModeChange) {
		try {
			Player player = (Player) event.getPlayer();

			if(!player.hasPermission("googleanalyticsplugin.ignore")) {
				plugin.getTracker().TrackAction(getClientName(plugin, player), getClientId(player), getClientIP(player.getAddress().getAddress()), player.getName(), "Game Mode Change", "Game Mode " + getGamemode(event.getNewGameMode()));
			}
		}
		catch(Exception e) {
			plugin.getLogger().warning("Event Listener Error: " + e.getMessage());
		}
	}
}
 
開發者ID:Fox32,項目名稱:GoogleAnalyticsPlugin,代碼行數:16,代碼來源:GoogleAnalyticsEventListener.java

示例10: gamemodeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void gamemodeChange(PlayerGameModeChangeEvent event) {

    RocketFunctions rocketFunctions = new RocketFunctions();
    CommonString commonString = new CommonString();
    GamemodeCheck gamemodeCheck = new GamemodeCheck();
    TitleSubtitle titleSubtitle = new TitleSubtitle();

    Player player = event.getPlayer();

    if (!RocketInit.rocketUsage.isEmpty())
        if (RocketInit.rocketUsage.contains(player.getUniqueId()))
            if (gamemodeCheck.check(player, GameMode.CREATIVE, GameMode.SPECTATOR)) {

                commonString.messageSend(RocketInit.getPlugin(), player, true, RocketLanguage.RB_GAMEMODE_ERROR);
                titleSubtitle.subtitle(player, 1, RocketLanguage.RB_GAMEMODE_ERROR);

                rocketFunctions.disableRocketBoots(player, false, false, false, false, false);

            }

}
 
開發者ID:Ullarah,項目名稱:MinecraftPlugins,代碼行數:23,代碼來源:PlayerGamemodeChange.java


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