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


Java PlayerGameModeChangeEvent類代碼示例

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


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

示例1: setGameMode

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入依賴的package包/類
@Override
public void setGameMode(GameMode mode) {
    if (getHandle().playerNetServerHandler == null) return;

    if (mode == null) {
        throw new IllegalArgumentException("Mode cannot be null");
    }

    if (mode != getGameMode()) {
        PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this, mode);
        server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }

        getHandle().theItemInWorldManager.setGameType(net.minecraft.world.WorldSettings.GameType.getByID(mode.getValue()));
        getHandle().fallDistance = 0;
        getHandle().playerNetServerHandler.sendPacket(new net.minecraft.network.play.server.S2BPacketChangeGameState(3, mode.getValue()));
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:21,代碼來源:CraftPlayer.java

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

示例3: shouldDoEverything

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入依賴的package包/類
@Test
public void shouldDoEverything() {
    // given
    Player player = mock(Player.class);
    World world = mock(World.class);
    given(world.getName()).willReturn("world");
    given(player.getWorld()).willReturn(world);
    Group group = mockGroup("world");
    given(groupManager.getGroupFromWorld("world")).willReturn(group);

    PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(player, GameMode.CREATIVE);

    // when
    listener.onPlayerGameModeChange(event);

    // then
    verify(groupManager).getGroupFromWorld("world");
    verify(playerManager).addPlayer(player, group);
    verify(bukkitService).runTaskLater(any(Runnable.class), any(Long.class));
}
 
開發者ID:Gnat008,項目名稱:PerWorldInventory,代碼行數:21,代碼來源:PlayerGameModeChangeListenerTest.java

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

示例5: setGameMode

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入依賴的package包/類
@Override
public void setGameMode(GameMode mode) {
    if (getHandle().playerConnection == null) return;

    if (mode == null) {
        throw new IllegalArgumentException("Mode cannot be null");
    }

    if (mode != getGameMode()) {
        PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this, mode);
        server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }

        getHandle().playerInteractManager.setGameMode(EnumGamemode.getById(mode.getValue()));
        getHandle().fallDistance = 0;
        getHandle().playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, mode.getValue()));
    }
}
 
開發者ID:OvercastNetwork,項目名稱:CraftBukkit,代碼行數:21,代碼來源:CraftPlayer.java

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

示例7: setGameMode

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入依賴的package包/類
@Override
public void setGameMode(GameMode mode) {
    if (getHandle().playerConnection == null) return;

    if (mode == null) {
        throw new IllegalArgumentException("Mode cannot be null");
    }

    if (mode != getGameMode()) {
        PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this, mode);
        server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }
        
        getHandle().setSpectatorTarget(getHandle());
        getHandle().playerInteractManager.setGameMode(WorldSettings.EnumGamemode.getById(mode.getValue()));
        getHandle().fallDistance = 0;
        getHandle().playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, mode.getValue()));
    }
}
 
開發者ID:tgnmc,項目名稱:Craftbukkit,代碼行數:22,代碼來源:CraftPlayer.java

示例8: setGameMode

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入依賴的package包/類
@Override
public void setGameMode(GameMode mode) {
    if (getHandle().playerConnection == null) return;

    if (mode == null) {
        throw new IllegalArgumentException("Mode cannot be null");
    }

    if (mode != getGameMode()) {
        PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this, mode);
        server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }

        getHandle().playerInteractManager.setGameMode(EnumGamemode.a(mode.getValue()));
        getHandle().playerConnection.sendPacket(new Packet70Bed(3, mode.getValue()));
    }
}
 
開發者ID:AlmuraDev,項目名稱:Almura-Server,代碼行數:20,代碼來源:CraftPlayer.java

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

示例10: setGameMode

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入依賴的package包/類
@Override
public void setGameMode(GameMode mode) {
    if (getHandle().field_71135_a == null) return;

    if (mode == null) {
        throw new IllegalArgumentException("Mode cannot be null");
    }

    if (mode != getGameMode()) {
        PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this, mode);
        server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }

        getHandle().field_71134_c.func_73076_a(net.minecraft.world.EnumGameType.func_77146_a(mode.getValue()));
        getHandle().field_71135_a.func_72567_b(new net.minecraft.network.packet.Packet70GameEvent(3, mode.getValue()));
    }
}
 
開發者ID:agaricusb,項目名稱:MCPBukkit,代碼行數:20,代碼來源:CraftPlayer.java

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

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

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

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

示例15: onGameMode

import org.bukkit.event.player.PlayerGameModeChangeEvent; //導入依賴的package包/類
@EventHandler
public void onGameMode(PlayerGameModeChangeEvent e) {
    if (e.getNewGameMode().equals(GameMode.SPECTATOR) && !e.getPlayer().getGameMode().equals(GameMode.SPECTATOR)) {
        packet.despawnAllStacks(e.getPlayer());
    } else if (!e.getNewGameMode().equals(GameMode.SPECTATOR) &&
            e.getPlayer().getGameMode().equals(GameMode.SPECTATOR)) {
        packet.spawnAllStacks(e.getPlayer());
    }
}
 
開發者ID:iso2013,項目名稱:MultiLineAPI,代碼行數:10,代碼來源:EventListener.java


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