コード例 #1
0
ファイル: LobbyListener.java プロジェクト: kieranbehn/Lobby
 @EventHandler
 public void onGamemodeChange(PlayerGameModeChangeEvent e) {
   if (e.getNewGameMode().equals(GameMode.ADVENTURE)) {
     Player p = e.getPlayer();
     p.setAllowFlight(true);
     p.setFlying(false);
   }
 }
コード例 #2
0
 @EventHandler(priority = EventPriority.MONITOR)
 public void onGamemode(PlayerGameModeChangeEvent e) {
   if (!plugin.getConfig().getBoolean("Complete")) return;
   Player p = e.getPlayer();
   if (plugin.spieler == p) {
     if (e.getNewGameMode() == GameMode.CREATIVE) {
       e.setCancelled(true);
     }
   }
 }
コード例 #3
0
	@EventHandler(priority = EventPriority.HIGH)
	public void onGamemodeChange(PlayerGameModeChangeEvent e) {
		SpleefPlayer player = HeavySpleef.getInstance().getSpleefPlayer(e.getPlayer());

		if (!player.isActive()) {
			return;
		}

		if (e.getNewGameMode() == GameMode.SURVIVAL) {
			return;
		}

		player.sendMessage(I18N._("cantChangeGamemode"));
		e.setCancelled(true);
	}
コード例 #4
0
  @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(EnumGameType.getByID(mode.getValue()));
      getHandle()
          .playerNetServerHandler
          .sendPacketToPlayer(new Packet70GameEvent(3, mode.getValue()));
    }
  }
コード例 #5
0
ファイル: CraftPlayer.java プロジェクト: ktulych/MCPBukkit
  @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()));
    }
  }
コード例 #6
0
ファイル: playerListener.java プロジェクト: BigJeyEm/MCMEPVP
 @EventHandler(priority = EventPriority.HIGH)
 void onGamemodeChange(PlayerGameModeChangeEvent event) {
   if (teamUtil.getPlayerTeam(event.getPlayer()).equalsIgnoreCase("spectator")) {
     event.getPlayer().setAllowFlight(true);
   }
 }