Search in sources :

Example 1 with GameMode

use of org.bukkit.GameMode in project TotalFreedomMod by TotalFreedom.

the class Command_opall method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    FUtil.adminAction(sender.getName(), "Opping all players on the server", false);
    boolean doSetGamemode = false;
    GameMode targetGamemode = GameMode.CREATIVE;
    if (args.length != 0) {
        if (args[0].equals("-c")) {
            doSetGamemode = true;
            targetGamemode = GameMode.CREATIVE;
        } else if (args[0].equals("-s")) {
            doSetGamemode = true;
            targetGamemode = GameMode.SURVIVAL;
        }
    }
    for (Player player : server.getOnlinePlayers()) {
        player.setOp(true);
        player.sendMessage(FreedomCommand.YOU_ARE_OP);
        if (doSetGamemode) {
            player.setGameMode(targetGamemode);
        }
    }
    return true;
}
Also used : GameMode(org.bukkit.GameMode) Player(org.bukkit.entity.Player)

Example 2 with GameMode

use of org.bukkit.GameMode in project Minigames by AddstarMC.

the class MinigamePlayer method storePlayerData.

public void storePlayerData() {
    ItemStack[] storedItems = player.getInventory().getContents();
    ItemStack[] storedArmour = player.getInventory().getArmorContents();
    int food = player.getFoodLevel();
    double health = player.getHealth();
    float saturation = player.getSaturation();
    lastScoreboard = player.getScoreboard();
    GameMode lastGM = player.getGameMode();
    float exp = player.getExp();
    int level = player.getLevel();
    player.setSaturation(15);
    player.setFoodLevel(20);
    player.setHealth(player.getMaxHealth());
    player.getInventory().clear();
    player.getInventory().setArmorContents(null);
    player.setLevel(0);
    player.setExp(0);
    oply = new OfflineMinigamePlayer(getPlayer().getUniqueId().toString(), storedItems, storedArmour, food, health, saturation, lastGM, exp, level, null);
    player.updateInventory();
}
Also used : GameMode(org.bukkit.GameMode) ItemStack(org.bukkit.inventory.ItemStack)

Example 3 with GameMode

use of org.bukkit.GameMode in project Essentials by drtshock.

the class Commandgamemode method run.

@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
    GameMode gameMode;
    if (args.length == 0) {
        gameMode = matchGameMode(commandLabel);
    } else if (args.length > 1 && args[1].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others")) {
        gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
        gamemodeOtherPlayers(server, user.getSource(), gameMode, args[1]);
        return;
    } else {
        try {
            gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
        } catch (NotEnoughArgumentsException e) {
            if (user.isAuthorized("essentials.gamemode.others")) {
                gameMode = matchGameMode(commandLabel);
                gamemodeOtherPlayers(server, user.getSource(), gameMode, args[0]);
                return;
            }
            throw new NotEnoughArgumentsException();
        }
    }
    if (gameMode == null) {
        gameMode = user.getBase().getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : user.getBase().getGameMode() == GameMode.CREATIVE ? GameMode.ADVENTURE : GameMode.SURVIVAL;
    }
    if (!canChangeToMode(user, gameMode)) {
        user.sendMessage(tl("cantGamemode", gameMode.name()));
        return;
    }
    user.getBase().setGameMode(gameMode);
    user.sendMessage(tl("gameMode", tl(user.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
}
Also used : GameMode(org.bukkit.GameMode)

Example 4 with GameMode

use of org.bukkit.GameMode in project Citizens2 by CitizensDev.

the class NPCCommands method gamemode.

@Command(aliases = { "npc" }, usage = "gamemode [gamemode]", desc = "Changes the gamemode", modifiers = { "gamemode" }, min = 1, max = 2, permission = "citizens.npc.gravity")
@Requirements(selected = true, ownership = true, types = { EntityType.PLAYER })
public void gamemode(CommandContext args, CommandSender sender, NPC npc) {
    Player player = (Player) npc.getEntity();
    if (args.argsLength() == 1) {
        Messaging.sendTr(sender, Messages.GAMEMODE_DESCRIBE, npc.getName(), player.getGameMode().name().toLowerCase());
        return;
    }
    GameMode mode = null;
    try {
        int value = args.getInteger(1);
        mode = GameMode.getByValue(value);
    } catch (NumberFormatException ex) {
        try {
            mode = GameMode.valueOf(args.getString(1));
        } catch (IllegalArgumentException e) {
        }
    }
    if (mode == null) {
        Messaging.sendErrorTr(sender, Messages.GAMEMODE_INVALID, args.getString(1));
        return;
    }
    player.setGameMode(mode);
    Messaging.sendTr(sender, Messages.GAMEMODE_SET, mode.name().toLowerCase());
}
Also used : GameMode(org.bukkit.GameMode) Player(org.bukkit.entity.Player) Command(net.citizensnpcs.api.command.Command) Requirements(net.citizensnpcs.api.command.Requirements)

Example 5 with GameMode

use of org.bukkit.GameMode in project NoCheatPlus by NoCheatPlus.

the class MovingConfig method getModelFlying.

public ModelFlying getModelFlying(final Player player, final PlayerLocation fromLocation, final MovingData data, final MovingConfig cc) {
    final GameMode gameMode = player.getGameMode();
    final ModelFlying modelGameMode = flyingModelGameMode.get(gameMode);
    switch(gameMode) {
        case SURVIVAL:
        case ADVENTURE:
        case CREATIVE:
            // Specific checks.
            break;
        default:
            // Default by game mode (spectator, yet unknown).
            return modelGameMode;
    }
    final boolean isGlidingWithElytra = Bridge1_9.isGlidingWithElytra(player) && MovingUtil.isGlidingWithElytraValid(player, fromLocation, data, cc);
    // Actual flying (ignoreAllowFlight is a legacy option for rocket boots like flying).
    if (player.isFlying() || !isGlidingWithElytra && !ignoreAllowFlight && player.getAllowFlight()) {
        return modelGameMode;
    }
    // Elytra.
    if (isGlidingWithElytra) {
        // Defensive: don't demand isGliding.
        return flyingModelElytra;
    }
    // Levitation.
    if (gameMode != GameMode.CREATIVE && !Double.isInfinite(Bridge1_9.getLevitationAmplifier(player)) && !fromLocation.isInLiquid()) {
        return flyingModelLevitation;
    }
    // Default by game mode.
    return modelGameMode;
}
Also used : GameMode(org.bukkit.GameMode) ModelFlying(fr.neatmonster.nocheatplus.checks.moving.model.ModelFlying)

Aggregations

GameMode (org.bukkit.GameMode)22 Player (org.bukkit.entity.Player)7 Location (org.bukkit.Location)3 ItemStack (org.bukkit.inventory.ItemStack)3 ModelFlying (fr.neatmonster.nocheatplus.checks.moving.model.ModelFlying)2 ResourceBundle (java.util.ResourceBundle)2 LocalizedStringImpl (net.glowstone.i18n.LocalizedStringImpl)2 Entity (org.bukkit.entity.Entity)2 EventHandler (org.bukkit.event.EventHandler)2 MinigameType (au.com.mineauz.minigames.gametypes.MinigameType)1 GameMechanicBase (au.com.mineauz.minigames.mechanics.GameMechanicBase)1 Callback (au.com.mineauz.minigames.menu.Callback)1 Menu (au.com.mineauz.minigames.menu.Menu)1 MenuItem (au.com.mineauz.minigames.menu.MenuItem)1 MenuItemAddFlag (au.com.mineauz.minigames.menu.MenuItemAddFlag)1 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)1 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)1 MenuItemDisplayLoadout (au.com.mineauz.minigames.menu.MenuItemDisplayLoadout)1 MenuItemDisplayWhitelist (au.com.mineauz.minigames.menu.MenuItemDisplayWhitelist)1 MenuItemFlag (au.com.mineauz.minigames.menu.MenuItemFlag)1