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


Java GameMode类代码示例

本文整理汇总了Java中org.bukkit.GameMode的典型用法代码示例。如果您正苦于以下问题:Java GameMode类的具体用法?Java GameMode怎么用?Java GameMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onPlayerMove

import org.bukkit.GameMode; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    if (!event.getFrom().getWorld().getName().equalsIgnoreCase("cave")) {
        return;
    }

    if (event.getTo().getBlock().getLightFromSky() == 0) {
        return;
    }

    if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
        return;
    }

    event.getPlayer().setHealth(0.0D);

    TextComponent message = new TextComponent("DU VOLLIDIOT! SONNE IST GEFÄHRLICH! HOFFE DU LERNST DARAUS");
    message.setColor(ChatColor.DARK_RED);

    event.getPlayer().spigot().sendMessage(message);
}
 
开发者ID:AnguliNetworks,项目名称:NoDaylight,代码行数:22,代码来源:PlayerMoveListener.java

示例2: endMatch

import org.bukkit.GameMode; //导入依赖的package包/类
public void endMatch(MatchTeam winningTeam) {
    List<MatchTeam> losers = new ArrayList<>();
    for (MatchTeam matchTeam : TGM.get().getModule(TeamManagerModule.class).getTeams()) {
        if (!matchTeam.isSpectator()) {
            matchTeam.getMembers().forEach(playerContext -> {
                playerContext.getPlayer().setGameMode(GameMode.ADVENTURE);
                playerContext.getPlayer().setAllowFlight(true);
                playerContext.getPlayer().setVelocity(new Vector(playerContext.getPlayer().getVelocity().getX(),
                        playerContext.getPlayer().getVelocity().getZ() + 1.0, playerContext.getPlayer().getVelocity().getZ()));
                playerContext.getPlayer().setFlying(true);
            });

            if (matchTeam != winningTeam) {
                losers.add(matchTeam);
            }
        }
    }
    match.disable();

    Bukkit.getPluginManager().callEvent(new MatchResultEvent(match, winningTeam, losers));
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:22,代码来源:MatchManager.java

示例3: spawnPlayer

import org.bukkit.GameMode; //导入依赖的package包/类
public void spawnPlayer(PlayerContext playerContext, MatchTeam matchTeam, boolean teleport) {
    Players.reset(playerContext.getPlayer(), true);

    if (matchTeam.isSpectator()) {
        spectatorModule.applySpectatorKit(playerContext);
        if (teleport) {
            playerContext.getPlayer().teleport(getTeamSpawn(matchTeam).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
        }
    } else {
        matchTeam.getKits().forEach(kit -> kit.apply(playerContext.getPlayer(), matchTeam));
        playerContext.getPlayer().updateInventory();

        if (teleport) {
            playerContext.getPlayer().teleport(getTeamSpawn(matchTeam).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
            playerContext.getPlayer().setGameMode(GameMode.SURVIVAL);
        }
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:19,代码来源:SpawnPointHandlerModule.java

示例4: onPlayerInteract

import org.bukkit.GameMode; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.LEFT_CLICK_BLOCK && event.hasItem()) {
        // The player didn't click an enchantment table, Creative players will instantly destroy.
        Player player = event.getPlayer();
        if (event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && player.getGameMode() != GameMode.CREATIVE) {

            // The player didn't click with an enchanted book.
            ItemStack stack = event.getItem();
            if (stack != null && stack.getType() == Material.ENCHANTED_BOOK) {
                ItemMeta meta = stack.getItemMeta();
                if (meta instanceof EnchantmentStorageMeta) {
                    EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) meta;
                    for (Enchantment enchantment : enchantmentStorageMeta.getStoredEnchants().keySet()) {
                        enchantmentStorageMeta.removeStoredEnchant(enchantment);
                    }

                    event.setCancelled(true);
                    player.setItemInHand(EMPTY_BOOK);
                    player.sendMessage(ChatColor.GREEN + "You reverted this item to its original form.");
                }
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:26,代码来源:BookDeenchantListener.java

示例5: message

import org.bukkit.GameMode; //导入依赖的package包/类
public void message(CommandContext context) {
    String targetString = context.getArgs().get(0);
    Player target = Bukkit.getPlayer(targetString);
    if (target == null) {
        context.send(colour("&cNobody was found with name '" + targetString + "'."));
        return;
    }

    if (context.getSender() instanceof Player &&
            Conditionals.ofBoth(((Player) context.getSender()).getGameMode(), target.getGameMode(), GameMode.SURVIVAL, GameMode.SPECTATOR)) {
        context.send(colour("&cGhosting is not allowed!"));
        return;
    }

    String finalMessage = String.join(" ", context.getArgs().subList(1, context.getArgs().size()));

    target.sendMessage(colour("&f<" + context.getSender().getName() + "&f -> Me&f> ") + finalMessage);
    context.send(colour("&f<Me -> " + target.getName() + "&f> ") + finalMessage);

    Bukkit.getOnlinePlayers().stream().filter(it -> UserManager.getInstance().getUser(it.getUniqueId()).orElseThrow(() -> new RuntimeException("An offline player is in Bukkit#getOnlinePlayers.")).getParticipation() == Participation.ADMIN)
            .forEach(it -> it.sendMessage(colour("&f<" + context.getSender().getName() + " -> " + target.getName() + "> ") + finalMessage));

    lastMessaged.put(context.getSender(), target);
}
 
开发者ID:Project-Coalesce,项目名称:UHC,代码行数:25,代码来源:Message.java

示例6: hitBlock

import org.bukkit.GameMode; //导入依赖的package包/类
public static boolean hitBlock(Player player, Block block) {
    if (player.getGameMode() == GameMode.CREATIVE)
        return true;

    PlayerBlockTracking playerBlockTracking = getPlayerBlockTracking(player);

    if (playerBlockTracking.isBlock(block)) {
        return true;
    }

    long time = playerBlockTracking.getTimeDifference();
    playerBlockTracking.incrementHackingIndicator();
    playerBlockTracking.setBlock(block);
    playerBlockTracking.updateTime();

    int decrement = (int) (time / OrebfuscatorConfig.AntiHitHackDecrementFactor);
    playerBlockTracking.decrementHackingIndicator(decrement);

    if (playerBlockTracking.getHackingIndicator() == OrebfuscatorConfig.AntiHitHackMaxViolation)
        playerBlockTracking.incrementHackingIndicator(OrebfuscatorConfig.AntiHitHackMaxViolation);

    if (playerBlockTracking.getHackingIndicator() > OrebfuscatorConfig.AntiHitHackMaxViolation)
        return false;

    return true;
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:27,代码来源:BlockHitManager.java

示例7: testGameMode

import org.bukkit.GameMode; //导入依赖的package包/类
@Test
public void testGameMode() throws InputException {
    Class[] inputTypes = {GameMode.class, GameMode.class};
    String[] input = {"1", "adventure"};

    Object[] output = InputFormatter.getTypesFromInput(inputTypes, Arrays.asList(input), null);

    // First let's make sure we didn't lose anything, or get anything
    assertEquals(inputTypes.length, output.length);

    // Next let's make sure everything is the right type
    for (Object object : output) {
        assertTrue(object instanceof GameMode);
    }

    // Finally, let's make sure the values are correct
    assertSame(output[0], GameMode.CREATIVE);
    assertSame(output[1], GameMode.ADVENTURE);
}
 
开发者ID:zachbr,项目名称:Debuggery,代码行数:20,代码来源:InputFormatterTest.java

示例8: onModerationJoin

import org.bukkit.GameMode; //导入依赖的package包/类
@Override
public void onModerationJoin(Player player)
{
    player.sendMessage(ChatColor.GOLD + "Vous avez rejoint cette arène en mode modération.");
    player.setGameMode(GameMode.SPECTATOR);

    List<Player> players = new ArrayList<>();
    players.addAll(Bukkit.getOnlinePlayers());
    players.stream().filter(gamePlayer -> !gamePlayer.getName().equals(player.getName())).forEach(gamePlayer -> {
        gamePlayer.hidePlayer(player);
    });

    if (teleportTargets.containsKey(player.getUniqueId()))
    {
        UUID target = teleportTargets.get(player.getUniqueId());
        Player tar = Bukkit.getPlayer(target);
        if (tar != null)
            player.teleport(tar);
        teleportTargets.remove(player.getUniqueId());
    }
}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:22,代码来源:ModerationJoinHandler.java

示例9: onPreStart

import org.bukkit.GameMode; //导入依赖的package包/类
@Override
public void onPreStart() {
    Location spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
    MaterialData materialData = Utils.parseMaterialData((String) this.getGameMap().fetchSetting("item"));
    ItemStack itemStack = new ItemStack(materialData.getItemType(), 1, materialData.getData());
    itemStack.addUnsafeEnchantment(Enchantment.KNOCKBACK,
        Integer.parseInt((String) this.getGameMap().fetchSetting("knockbackAmount")));
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(!this.getAPI().getGameManager().isAlive(player)) continue;
        player.teleport(spawnLocation);
        player.setGameMode(GameMode.ADVENTURE);
        player.getInventory().addItem(itemStack);
    }
    this.hill = new Cuboid(Utils.parseLocation((String) this.getGameMap().fetchSetting("hillBoundsA")),
        Utils.parseLocation((String) this.getGameMap().fetchSetting("hillBoundsB")));
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:17,代码来源:KingOfTheHillGame.java

示例10: setSpectating

import org.bukkit.GameMode; //导入依赖的package包/类
/**
 * Toggles whether a player is in Spectator Mode.
 * @param player
 * @param toggle
 */
public void setSpectating(Player player, boolean toggle) {
    if(toggle && spec.contains(player)) return;
    if(!toggle && !spec.contains(player)) return;
    if(toggle) {
        player.setAllowFlight(true);
        player.setFlying(true);
        player.setGameMode(GameMode.SPECTATOR);
        spec.add(player);
    } else {
        player.setGameMode(GameMode.ADVENTURE);
        spec.remove(player);
    }
    this.setAlive(player, false);
    Bukkit.getServer().getPluginManager().callEvent(new PlayerAliveStatusEvent(player, false, toggle));
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:21,代码来源:GameManager.java

示例11: parseGamemode

import org.bukkit.GameMode; //导入依赖的package包/类
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,代码行数:23,代码来源:GamemodeCMD.java

示例12: handleModeratorLogin

import org.bukkit.GameMode; //导入依赖的package包/类
/**
 * Override this to execute something when a moderator joins the game.
 *
 * You need to call the {@code super} method at the beginning of your own one.
 *
 * @param player The player who logged in.
 */
public void handleModeratorLogin(Player player)
{
    for (GamePlayer gamePlayer : this.gamePlayers.values())
    {
        Player p = gamePlayer.getPlayerIfOnline();

        if (p != null)
            p.hidePlayer(player);
    }

    this.gameModerators.add(player.getUniqueId());

    player.setGameMode(GameMode.SPECTATOR);
    player.sendMessage(ChatColor.GREEN + "Vous êtes invisibles aux yeux de tous, attention à vos actions !");
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:23,代码来源:Game.java

示例13: JoinTeam

import org.bukkit.GameMode; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static void JoinTeam(Player player,String area){
	
	String worldconfig = plugin.getConfig().getString("area."+area+".world");
	World world = Bukkit.getServer().getWorld(worldconfig);
	String Location = plugin.getConfig().getString("area."+area+".Location");
	String[] location = Location.split(",");
	int x = Integer.parseInt(location[0]);
	int y = Integer.parseInt(location[1]);
	int z = Integer.parseInt(location[2]);
	
	Location location2 = new Location(world, x, y, z);
	player.teleport(location2);
	player.setGameMode(GameMode.SURVIVAL);
	
	Team team = board.getTeam(area);
	PlayerInWhereArea.put(player, team);
	team.addPlayer(player);
	player.playSound(player.getLocation(), Sound.CLICK, 2F, 15F);
	player.sendMessage(ChatColor.BLUE + "�A�[�J�F�C��");
	
}
 
开发者ID:cocomine,项目名称:FastSpawn,代码行数:23,代码来源:Teams.java

示例14: finallyStart

import org.bukkit.GameMode; //导入依赖的package包/类
/**
 * Finally starts the game after the countdown
 * 
 * You have to load the chunk because the player could probably spawn in the
 * ground if the chunk is not loaded when the player is teleported
 */
public void finallyStart() {
	game.setStatus(GameStatus.INGAME);
	Chambers.getInstance().getTeamManager().getAllPlayerTeams().stream().forEach(team -> {
		if (!team.getHome().getChunk().isLoaded()) {
			team.getHome().getChunk().load();
		}
		team.getOnlinePlayers().stream().forEach(player -> {
			giveStartingItems(player);
			player.setGameMode(GameMode.SURVIVAL);
			player.setAllowFlight(false);
			player.setFlying(false);
			player.teleport(team.getHome());
		});
	});
	new GameTask().runTaskTimerAsynchronously(Chambers.getInstance(), 0L, 20L);
	Bukkit.broadcastMessage(" ");
	Bukkit.broadcastMessage(ChatColor.YELLOW + "The game has now started! Good luck!");
	Bukkit.broadcastMessage(" ");
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:26,代码来源:GameManager.java

示例15: onInventoryMove

import org.bukkit.GameMode; //导入依赖的package包/类
@EventHandler
public void onInventoryMove(InventoryClickEvent event) {
    if (!(event.getWhoClicked() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getWhoClicked();
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getStatus() == PlayerStatus.EDITING_KITS || profile.getStatus() == PlayerStatus.PLAYING) {
        return;
    }

    if ((player.hasPermission("practice.admin") || player.isOp()) && player.getGameMode() == GameMode.CREATIVE) {
        return;
    }

    event.setCancelled(true);
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:20,代码来源:PlayerListener.java


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