当前位置: 首页>>代码示例>>Java>>正文


Java PlayerGameModeChangeEvent.setCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerGameModeChangeEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerGameModeChangeEvent.setCancelled方法的具体用法?Java PlayerGameModeChangeEvent.setCancelled怎么用?Java PlayerGameModeChangeEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerGameModeChangeEvent的用法示例。


在下文中一共展示了PlayerGameModeChangeEvent.setCancelled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onGamemodeChange

import org.bukkit.event.player.PlayerGameModeChangeEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGH)
protected void onGamemodeChange(PlayerGameModeChangeEvent e) {
	if (SkyWarsReloaded.getPC().getPlayer(e.getPlayer().getUniqueId()) != null
			&& SkyWarsReloaded.getPC().getPlayer(e.getPlayer().getUniqueId()).isSpectating()
			&& !e.getNewGameMode().equals(GameMode.ADVENTURE)
			&& SkyWarsReloaded.getPC().getPlayer(e.getPlayer().getUniqueId()).gamemodeChangeAllowed()) {
		
		e.setCancelled(true);
		e.getPlayer().setAllowFlight(true);
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:12,代码来源:SpectatorListener.java

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

示例4: shouldDoNothingEventCancelled

import org.bukkit.event.player.PlayerGameModeChangeEvent; //导入方法依赖的package包/类
@Test
public void shouldDoNothingEventCancelled() {
    // given
    PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(mock(Player.class), GameMode.CREATIVE);
    event.setCancelled(true);

    // when
    listener.onPlayerGameModeChange(event);

    // then
    verifyZeroInteractions(groupManager);
    verifyZeroInteractions(playerManager);
    verifyZeroInteractions(bukkitService);
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:15,代码来源:PlayerGameModeChangeListenerTest.java

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


注:本文中的org.bukkit.event.player.PlayerGameModeChangeEvent.setCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。