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


Java GameMode.SPECTATOR属性代码示例

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


在下文中一共展示了GameMode.SPECTATOR属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onInventoryCloseEvent

@EventHandler
public void onInventoryCloseEvent(InventoryCloseEvent e) {
	if (e.getPlayer().getGameMode() == GameMode.SPECTATOR) {
		if (e.getInventory().getName().equalsIgnoreCase(wm1.inv.getName())) {
			Bukkit.getScheduler().scheduleSyncDelayedTask(SuperiorCraft.plugin, new Runnable() {
				@Override
				public void run() {
					e.getPlayer().openInventory(wm2.inv);
				}
			}, 1);

		}

		else if (e.getInventory().getName().equalsIgnoreCase(wm2.inv.getName())) {
			if (e.getInventory().getName().equalsIgnoreCase(wm2.inv.getName())) {
				Bukkit.getScheduler().scheduleSyncDelayedTask(SuperiorCraft.plugin, new Runnable() {
					@Override
					public void run() {
						e.getPlayer().setGameMode(GameMode.ADVENTURE);
					}
				}, 1);

			}		
		}
	}
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:26,代码来源:SuperiorCraft.java

示例2: parseGamemode

private GameMode parseGamemode(String gamemode) {
    switch (gamemode) {
        case "creativo":
        case "1":
        case "c":
            return GameMode.CREATIVE;
        case "survival":
        case "0":
        case "s":
            return GameMode.SURVIVAL;
        case "adventura":
        case "2":
        case "a":
            return GameMode.ADVENTURE;
        case "espectador":
        case "3":
        case "e":
            return GameMode.SPECTATOR;
        default:
            return GameMode.SURVIVAL;
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:22,代码来源:GamemodeCMD.java

示例3: leave

@EventHandler
public void leave(final PlayerQuitEvent event) {
    if(GameState.current() != GameState.LOBBY && event.getPlayer().getGameMode() != GameMode.SPECTATOR){
        event.setQuitMessage(colour("&6" + event.getPlayer().getName() + " has quit! " +
                "They have " + UHC.getInstance().getMainConfig().getDisconnectGracePeriodSeconds() + "s to reconnect."));

        bukkitRunnable(() -> disqualified(event.getPlayer().getUniqueId(), event.getPlayer().getName(),
                event.getPlayer().getLocation(), event.getPlayer().getInventory())).runTaskLater(UHC.getInstance(),
                TimeUnit.MILLISECONDS.convert(UHC.getInstance().getMainConfig().getDisconnectGracePeriodSeconds(), TimeUnit.SECONDS));

        //Zombie Spawning
        Zombie zombie = (Zombie) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getLocation(), EntityType.ZOMBIE);
        zombie.setCustomName(event.getPlayer().getName());
        zombie.setCustomNameVisible(true);
        //TODO Make no AI and invulnerable cough cough Proxi cough cough
        deadRepresentatives.put(event.getPlayer().getUniqueId(), zombie);
    }
}
 
开发者ID:Project-Coalesce,项目名称:UHC,代码行数:18,代码来源:JoinQuitHandlers.java

示例4: play

@Override
public void play(Player player)
{
    if (runnerList.containsKey(player.getUniqueId()) || player.getGameMode() == GameMode.SPECTATOR)
        return;

    YodelRunner runner = new YodelRunner(this.hub, this, player);
    runnerList.put(player.getUniqueId(), runner);
    runner.start();

    this.hub.getServer().getScheduler().runTask(this.hub, () -> SamaGamesAPI.get().getAchievementManager().getAchievementByID(58).unlock(player.getUniqueId()));
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:12,代码来源:Yodel.java

示例5: play

@Override
public void play(Player player)
{
    if (!this.squids.containsKey(player.getUniqueId()) && player.getGameMode() != GameMode.SPECTATOR)
    {
        WorldServer world = ((CraftWorld) player.getWorld()).getHandle();
        EntitySonicSquid sonicSquidEntity = new EntitySonicSquid(world, player);
        world.addEntity(sonicSquidEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);

        sonicSquidEntity.getBukkitEntity().setPassenger(player);

        this.squids.put(player.getUniqueId(), sonicSquidEntity);
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:14,代码来源:SonicSquid.java

示例6: onGameModeChange

@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,代码行数:14,代码来源:PlayerListener.java

示例7: isPlayerExempt

/**
 * Check if the player is exempt.
 *
 * @param check  the check
 * @param player the check
 * @return if we are exempted or not.
 */
public boolean isPlayerExempt(Player player, CheckType check) {

    // check for common exemptions first.
    boolean hasExemption = checkCommonExemptions(player, check);
    if (hasExemption) {
        return true;
    }

    // iterate through the array of checks that need to be exempted for if we are flying.
    for (CheckType element : EXEMPT_BECAUSE_FLYING) {
        if (!(element.equals(check))) {
            continue;
        }

        if (Arc.COMPATIBILITY) {
            hasExemption = player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight
                    () || player
                    .isFlying();
        } else {
            hasExemption = player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR || player
                    .getAllowFlight
                            () || player
                    .isFlying();
        }
        break;
    }

    return hasExemption;
}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:36,代码来源:ExemptionManager.java

示例8: onChangeGM

@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,代码行数:29,代码来源:LittlesEvent.java

示例9: isViewable

public static boolean isViewable(Player viewer, Entity target, boolean bypassGameMode) {
    if (target instanceof Player) {
        if (vanishNoPacket) {
            if (manager.isVanished((Player) target)) return false;
        }
        if (!viewer.canSee((Player) target)) return false;
        if (((Player) target).getGameMode() == GameMode.SPECTATOR) return false;
    }
    if (target instanceof LivingEntity) {
        if (((LivingEntity) target).hasPotionEffect(PotionEffectType.INVISIBILITY)) return false;
    }
    return !(viewer.getGameMode() == GameMode.SPECTATOR && !bypassGameMode);
}
 
开发者ID:iso2013,项目名称:MultiLineAPI,代码行数:13,代码来源:VisibilityUtil.java

示例10: onMove

@EventHandler
public void onMove(PlayerMoveEvent event) {
    Player player = event.getPlayer();
    if (!(player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR)) {
        if (BlockListener.inMineLocation(player.getLocation())) {
            if (player.getGameMode() != GameMode.SURVIVAL) {
                player.setGameMode(GameMode.SURVIVAL);
            }
        } else {
            if (player.getGameMode() != GameMode.ADVENTURE) {
                player.setGameMode(GameMode.ADVENTURE);
            }
        }
    }
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:15,代码来源:PlayerListener.java

示例11: isInCreativeOrSpectator

public final boolean isInCreativeOrSpectator() {
	final GameMode mode = getPlayer().getGameMode();
	return mode == GameMode.CREATIVE || mode == GameMode.SPECTATOR;
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:4,代码来源:Behaviour.java

示例12: call

@Override
public void call(Event event) {
	// Causes false positives.
	if (profile.getBehaviour().getMotion().isDescending()) {
		return;
	}

	if (event instanceof PlayerMoveEvent) {
		final Player player = profile.getPlayer();

		if (player.getGameMode() == GameMode.SPECTATOR || player.isInsideVehicle()) {
			/*
			 * If the player is in spectator mode, return out of the method
			 * as the speed function in this GameMode could cause false
			 * positives.
			 */
			return;
		}

		final PlayerMoveEvent pme = (PlayerMoveEvent) event;

		final int speedLevel = profile.getBehaviour().getPotionEffectLevel(PotionEffectType.SPEED);

		// Ignore if the player's speed is higher than two.
		if (speedLevel > 2) {
			return;
		}

		/*
		 * Ignore y for this check. We only want to check speed on the x and
		 * z axes.
		 */
		final Vector from = pme.getFrom().toVector().clone().setY(0.0),
				to = pme.getTo().toVector().clone().setY(0.0);

		double distance = to.distanceSquared(from);

		if (speedLevel > 0) {
			// Take into account speed potions.
			distance -= (distance / 100.0) * (speedLevel * 20.0);
		}

		/*
		 * Walking and flying (but not sprinting): 0.40, Sprinting and
		 * flying: 1.25
		 */
		final long current = System.currentTimeMillis();
		if ((player.isFlying() && player.isSprinting()) || (current
				- profile.getBehaviour().getMotion().getLastFly() <= 500
				&& current - profile.getBehaviour().getMotion()
						.getLastSprint() <= 500) /*
													 * Player is flying and
													 * sprinting and flying
													 * or has been in the
													 * last half a second.
													 */) {
			callback(distance > 1.25);
		} else {
			callback(distance > 0.40);
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:62,代码来源:SpeedA.java

示例13: onEnable

/**
 * Basic game enabling and loading method.<br>
 * <br>
 * For proper runs use:<br>
 * name = "GameName";<br>
 * super.onEnable();<br>
 * <br>
 * If you create teams add:<br>
 * team = new OMGTeam(...);<br>
 * Inventories.update();
 */
public void onEnable() {
    Bukkit.getPluginManager().registerEvents(this, this);
    Bukkit.getPluginManager().registerEvents(new BukkitEventHandler(), OMGPI.instance);

    gamefig = new Gamefig();
    state = GameState.PRELOBBY;
    gamePreparer = new ClijmartTeamAsserter();
    shootSources = new HashMap<>();

    mapsDirectory = new File(getDataFolder() + File.separator + "maps");

    defaultTeam = new OMGTeam("default", ChatColor.YELLOW + "Default", ChatColor.YELLOW + "", true, GameMode.ADVENTURE);
    spectatorTeam = new OMGTeam("spectator", ChatColor.GRAY + "Spectator", ChatColor.GRAY + "", false, GameMode.SPECTATOR);

    OMGKit.dir = new File(getDataFolder() + File.separator + "kits");
    OMGKit def = new OMGKit("Default");
    def.setUnpresent("displayItem", "{id:stone,Count:1,tag:{display:{Name:\"Default\"}}}");
    def.save();
    String[] kitarr = OMGKit.dir.list();
    List<String> kits = kitarr == null ? new ArrayList<>() : Arrays.asList(kitarr);
    kits.stream().filter(k -> k.endsWith(".kit") && OMGKit.kits.stream().noneMatch(k1 -> (k1 + ".kit").equalsIgnoreCase(k))).forEach(k -> new OMGKit(k.replaceAll("\\.kit", "")));

    OMGLoot.dir = new File(getDataFolder() + File.separator + "loots");
    String[] lootarr = OMGLoot.dir.list();
    List<String> loots = lootarr == null ? new ArrayList<>() : Arrays.asList(lootarr);
    loots.stream().filter(l -> l.endsWith(".loot") && OMGLoot.loots.stream().noneMatch(l1 -> (l1 + ".loot").equalsIgnoreCase(l))).forEach(l -> new OMGLoot(l.replaceAll("\\.loot", "")));

    settings = new GameSettings(this);

    infoBar = Bukkit.createBossBar(ChatColor.AQUA + "", BarColor.WHITE, BarStyle.SOLID);
    infoBar.setVisible(false);

    voteSystem = new VoteSystem();

    countdown = new Countdown();
    updator = new BukkitRunnable() {
        public void run() {
            update();
        }
    };
    updator.runTaskTimer(this, 0, 1);

    Inventories.update();

    Bukkit.getOnlinePlayers().forEach(p -> {
        while (OMGPlayer.get(p) == null) event_player_join(new OMGPlayer(p));
    });
    OMGPI.iLog(name + " initialized, can be played.");
}
 
开发者ID:BurnyDaKath,项目名称:OMGPI,代码行数:60,代码来源:Game.java

示例14: run

public void run() {
    if (!ragePlayer.isOnline() || ragePlayer == null) cancel();

    ragePlayer.sendActionBar("&cEstas en modo espectador, pon &6/lobby &cpara salir");

    if (ragePlayer.getPlayer().getGameMode() != GameMode.SPECTATOR) ragePlayer.getPlayer().setGameMode(GameMode.SPECTATOR);
}
 
开发者ID:cadox8,项目名称:PA,代码行数:7,代码来源:SpectatorTask.java


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