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;
}
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();
}
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()));
}
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());
}
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;
}
Aggregations