本文整理汇总了Java中org.bukkit.entity.Player.setGameMode方法的典型用法代码示例。如果您正苦于以下问题:Java Player.setGameMode方法的具体用法?Java Player.setGameMode怎么用?Java Player.setGameMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.setGameMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: joinLobby
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public synchronized boolean joinLobby(Player player) {
if (this.canJoinLobby(player)) {
this.lobby.add(player);
this.storeTemporaryInventory(player);
player.getInventory().setArmorContents(new ItemStack[4]);
player.getInventory().clear();
player.updateInventory();
player.setHealth(player.getMaxHealth());
player.setFoodLevel(20);
player.setExp(0);
player.setLevel(0);
player.setGameMode(GameMode.ADVENTURE);
player.teleport(this.getArena().getLobbyMeta().getLobbySpawn());
return true;
}
return false;
}
示例2: onPreStart
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void onPreStart() {
this.startPosition = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
for(Player player : Bukkit.getOnlinePlayers()) {
if(!this.getAPI().getGameManager().isAlive(player)) continue;
player.teleport(startPosition);
player.setGameMode(GameMode.ADVENTURE);
}
this.targetPosition = Utils.parseLocation((String) this.getGameMap().fetchSetting("targetPosition"));
this.towards = (String) this.getGameMap().fetchSetting("targetTowards");
((RelativeDistanceSidebar) this.getSidebar()).setTarget(targetPosition, towards);
this.glass = new Cuboid(Utils.parseLocation((String) this.getGameMap().fetchSetting("glassBoundsA")),
Utils.parseLocation((String) this.getGameMap().fetchSetting("glassBoundsB")));
Iterator<Block> glassBlocks = glass.iterator();
while(glassBlocks.hasNext()) {
glassBlocks.next().setType(Material.GLASS);
}
}
示例3: addToQueue
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void addToQueue(Object object) {
Player player = (Player) object;
PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);
PlayerElo rating = profile.getLadderRatings().get(this.ladder);
if (rating == null) {
rating = new PlayerElo(1000);
}
QueueData participant = new QueueData(player.getUniqueId(), this, rating.toInteger());
this.searchList.offer(participant);
profile.setCurrentQueue(this);
profile.setQueueData(participant);
profile.setStatus(PlayerStatus.QUEUEING);
player.sendMessage(ChatColor.AQUA + (ranked ? "[Ranked] " : "[Unranked] ") + ChatColor.GRAY + "You have been added to the " + ChatColor.AQUA + this.ladder.getName() + " 1v1 " + ChatColor.GRAY + "queue, please wait while we find you an opponent.");
if (player.getGameMode() == GameMode.CREATIVE) {
player.setGameMode(GameMode.SURVIVAL);
}
}
示例4: JoinTeam
import org.bukkit.entity.Player; //导入方法依赖的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��");
}
示例5: startup
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**Called when the first button within the entry Module was just pushed
* Takes appropriate startup actions and then sets the state to RUNNING.
*/
private void startup() {
getServer().getPluginManager().registerEvents(this, this);
activePlayers = new LinkedList<>(getServer().getOnlinePlayers());
// Backing up player modes to restore upon dungeon stop
playersSnapshotAtStart = new ArrayList<GameMode>();// backup copy of gamemode
for (int i=0; i<activePlayers.size(); i++) {
playersSnapshotAtStart.add(activePlayers.get(i).getGameMode());
}
for (Player p : activePlayers) {
p.setFoodLevel(18);
p.setGameMode(GameMode.ADVENTURE);
p.sendMessage("Your mode was set to adventure...");
giveStartingGear(p);
}
state = State.RUNNING;
}
示例6: handleLogin
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void handleLogin(Player p)
{
super.handleLogin(p);
p.setGameMode(GameMode.ADVENTURE);
p.setLevel(0);
p.setExp(0);
p.setFoodLevel(20);
p.setSaturation(20);
Location spec = new Location(AgarMC.get().getWorld(), origin.getX() + dimensions / 2, origin.getY() + 20, origin.getZ() + dimensions / 2);
spec.setPitch(90);
p.teleport(spec);
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
if (gamePlayers.size() >= SamaGamesAPI.get().getGameManager().getGameProperties().getMaxSlots())
this.status = Status.IN_GAME;
Titles.sendTabTitle(p, ChatColor.GREEN + "Bienvenue sur " + ChatColor.AQUA + "SamaGames" + ChatColor.GREEN + " !\n",
ChatColor.AQUA + "\nTeamSpeak : " + ChatColor.GREEN + "ts.samagames.net");
}
示例7: onBlockBreakCreative
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreakCreative(BlockBreakEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("base.command.gamemode")) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
player.setGameMode(GameMode.SURVIVAL);
}
}
示例8: onPreStart
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void onPreStart() {
Location spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
ItemStack itemStack = new ItemStack(Material.DIAMOND_SPADE, 1);
for(Player player : Bukkit.getOnlinePlayers()) {
if(!this.getAPI().getGameManager().isAlive(player)) continue;
player.teleport(spawnLocation);
player.setGameMode(GameMode.SURVIVAL);
player.getInventory().addItem(itemStack);
}
}
示例9: onPreStart
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void onPreStart() {
this.spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
for(Player player : Bukkit.getOnlinePlayers()) {
if(!this.getAPI().getGameManager().isAlive(player)) continue;
player.teleport(spawnLocation);
player.setGameMode(GameMode.ADVENTURE);
}
String[] rawLocations = ((String) this.getGameMap().fetchSetting("cannonPositions")).split(";");
for(String location : rawLocations) {
cannonPositions.add(Utils.parseLocation(location));
}
this.cannonVelocityOffset = Double.valueOf(((String) this.getGameMap().fetchSetting("cannonVelocityOffset")));
}
示例10: onBlockPlaceCreative
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockPlaceCreative(BlockBreakEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("base.command.gamemode")) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
player.setGameMode(GameMode.SURVIVAL);
}
}
示例11: onPreStart
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void onPreStart() {
Location spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
for(Player player : Bukkit.getOnlinePlayers()) {
if(!this.getAPI().getGameManager().isAlive(player)) continue;
player.teleport(spawnLocation);
player.setGameMode(GameMode.ADVENTURE);
}
Cuboid pointSpawn = new Cuboid(Utils.parseLocation((String) this.getGameMap().fetchSetting("pointBoundsA")),
Utils.parseLocation((String) this.getGameMap().fetchSetting("pointBoundsB")));
Iterator<Block> pointSpawns = pointSpawn.iterator();
while(pointSpawns.hasNext()) {
this.spawnLocations.add(pointSpawns.next().getLocation());
}
}
示例12: leaveMod
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void leaveMod(Player p)
{
modMode.remove(p.getName());
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().clear();
loadInventory(p);
p.sendMessage(" §6§ §rYou have §cdisabled §rModerator Mode!");
}
示例13: addPlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Add a player to this game.
* @param player
*/
public void addPlayer(Player player) {
if (isPlaying(player)) {
player.sendMessage(ChatColor.RED + "You are already playing this game.");
return;
}
if (!canAdd(player))
return;
getPlayers().add(player);
player.setGameMode(GameMode.SURVIVAL);
onJoin(player);
}
示例14: removeSpectator
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void removeSpectator(Player player) {
player.setFoodLevel(20);
player.setLevel(0);
player.setGameMode(GameMode.SURVIVAL);
player.setAllowFlight(false);
player.setExp(0);
player.setHealthScale(20);
player.setHealth(20);
player.setTotalExperience(0);
player.setCanPickupItems(false);
for (PotionEffect eff : player.getActivePotionEffects()) {
player.removePotionEffect(eff.getType());
}
if (PREFIXES.containsKey(player.getName())) {
player.setCustomName(player.getDisplayName().replace(PREFIXES.get(player.getName()), ""));
player.setPlayerListName(player.getDisplayName().replace(PREFIXES.get(player.getName()), ""));
player.setDisplayName(player.getDisplayName().replace(PREFIXES.get(player.getName()), ""));
player.setCustomNameVisible(true);
}
for (Player p : Bukkit.getOnlinePlayers()) {
p.showPlayer(player);
}
PlayerUtil.removeDeadPlayer(player);
}
示例15: onMove
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@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);
}
}
}
}