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


Java PlayerGameModeChangeEvent.getNewGameMode方法代碼示例

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


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

示例1: onGamemodeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onGamemodeChange(PlayerGameModeChangeEvent event){
	GameMode newMode = event.getNewGameMode();
	String worldName = event.getPlayer().getWorld().getName();
	if(!event.getPlayer().hasPermission("spigotplus.gamemode." + worldName + "." + newMode)){
		boolean modeFound = false;
		for(GameMode mode : GameMode.values()){
			if(event.getPlayer().hasPermission("spigotplus.gamemode." + worldName + "." + mode)){
				modeFound = true;
				break;
			}
		}

		event.setCancelled(true);
		event.getPlayer().sendMessage("You are not permitted to use the " + newMode + " gamemode in this world");
		
		if(!modeFound){
			logWarn("The player " + event.getPlayer().getName() + " is not permitted to use any gamemode in the world \"" + worldName + "\"");
			event.getPlayer().kickPlayer("There is a configuration error with the gamemodes you are permitted to use. Please contact the server administrator");
		}
	}
}
 
開發者ID:robotman3000,項目名稱:Spigot-Plus,代碼行數:23,代碼來源:GamemodeManager.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: onGameModeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onGameModeChange(PlayerGameModeChangeEvent event) {
    GameMode gameMode = event.getPlayer().getGameMode();
    // check if we switch to survival from an exempt GameMode and update.
    if (Arc.COMPATIBILITY) {
        if ((gameMode == GameMode.CREATIVE && event.getNewGameMode() == GameMode.SURVIVAL)) {
            MovingData.getData(event.getPlayer()).setLastGameModeChange(System.currentTimeMillis());
        }
    } else {
        if ((gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR) && event.getNewGameMode() == GameMode.SURVIVAL) {
            MovingData.getData(event.getPlayer()).setLastGameModeChange(System.currentTimeMillis());
        }
    }
}
 
開發者ID:Vrekt,項目名稱:Arc-v2,代碼行數:15,代碼來源:PlayerListener.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: gameModeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void gameModeChange(final PlayerGameModeChangeEvent event) {
    Optional<User> optionalUser = UserManager.getInstance().getUser(event.getPlayer().getUniqueId());
    User user = optionalUser.orElseGet(() -> new User(event.getPlayer(), Participation.SPECTATOR));
    if (event.getPlayer().isOp() || event.getNewGameMode() == GameMode.CREATIVE) {
        user.setParticipation(Participation.ADMIN);
    } else {
        user.setParticipation(Participation.PARTICIPATOR);
    }
    UserManager.getInstance().addUser(user);
}
 
開發者ID:Project-Coalesce,項目名稱:UHC,代碼行數:12,代碼來源:JoinQuitHandlers.java

示例7: 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

示例8: 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

示例9: onPlayerGamemodeChanged

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerGamemodeChanged(PlayerGameModeChangeEvent evt) {
    InventoryKey beforeKey = new InventoryKey(evt.getPlayer().getUniqueId(), getGroupName(evt
            .getPlayer().getWorld().getName()), evt.getPlayer().getGameMode());
    InventoryKey afterKey = new InventoryKey(evt.getPlayer().getUniqueId(), getGroupName(evt
            .getPlayer().getWorld().getName()), evt.getNewGameMode());

    if (!beforeKey.equals(afterKey)) {
    	switchInventory(beforeKey, afterKey);
    }
}
 
開發者ID:robotman3000,項目名稱:Spigot-Plus,代碼行數:12,代碼來源:InventoryManager.java

示例10: gamemodeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void gamemodeChange(PlayerGameModeChangeEvent event){
	BTPlayer ply;
	try{
		ply = pdata.getBTPlayer(event.getPlayer());
	}
	catch (UnknownBTPlayerException e){
		return;
	}
	
	if(event.getNewGameMode() != GameMode.CREATIVE && ply.isBuildModeActive()){
		ply.setBuildModeActive(false);
		ply.sendMessage("Build mode deactivated.", ChatColor.RED);
	}
}
 
開發者ID:AddstarMC,項目名稱:BuildTools,代碼行數:16,代碼來源:Events.java

示例11: onGameMode

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onGameMode(PlayerGameModeChangeEvent e) {
	if(e.getNewGameMode() == GameMode.CREATIVE) {
		if(staff.containsKey(e.getPlayer().getName())) {
			Bukkit.getScheduler().cancelTask(staff.get(e.getPlayer().getName()));
			staff.remove(e.getPlayer().getName());
			sendMessage(e.getPlayer(), ChatColor.GRAY + "teleportation safety against damage has been " + ChatColor.RED + "worn off");
		}
	}
}
 
開發者ID:xEssentials,項目名稱:xEssentials-deprecated-bukkit,代碼行數:11,代碼來源:StaffSafeTeleportEvent.java

示例12: onGamemodeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
/**
 * Used to prevent spectators from changing their gamemode whilst spectating.
 */
@EventHandler(priority=EventPriority.HIGHEST)
public void onGamemodeChange(final PlayerGameModeChangeEvent e)
{
	final Spectator spectator = p.getPlayerData(e.getPlayer());

	if (spectator.isSpectating() && e.getNewGameMode() != GameMode.ADVENTURE && !spectator.isGamemodeChangeAllowed())
	{
		e.setCancelled(true);
		e.getPlayer().setAllowFlight(true);
	}
}
 
開發者ID:pgmann,項目名稱:SpectatorPlus,代碼行數:15,代碼來源:ServerActionsListener.java

示例13: onPlayerGameModeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerGameModeChange(final PlayerGameModeChangeEvent event) {
    if (event.getNewGameMode() == GameMode.CREATIVE) {
        this.tracker.cancelFall(event.getPlayer());
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:7,代碼來源:GravityListener.java


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