类org.bukkit.Bukkit源码实例Demo

下面列出了怎么用org.bukkit.Bukkit的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: UhcCore   文件: MojangUtils.java
public static String getPlayerName(String name){
    if (Bukkit.isPrimaryThread()){
        throw new RuntimeException("Requesting player UUID is not allowed on the primary thread!");
    }

    try {
        URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.connect();

        JsonParser parser = new JsonParser();
        JsonElement json = parser.parse(new InputStreamReader(connection.getInputStream()));

        connection.disconnect();

        if (!json.isJsonObject()){
            return name;
        }

        return json.getAsJsonObject().get("name").getAsString();
    }catch (IOException ex){
        ex.printStackTrace();
        return name;
    }
}
 
源代码2 项目: UhcCore   文件: VaultManager.java
public static void addMoney(final Player player, final double amount){
	Validate.notNull(player);

	if(!GameManager.getGameManager().getConfiguration().getVaultLoaded()){
		return;
	}

	if(economy == null){
		Bukkit.getLogger().warning("[UhcCore] Vault is not loaded! Couldn't pay "+amount+" to "+player.getName()+"!");
		return;
	}

	final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.getUniqueId());

	Bukkit.getScheduler().runTaskAsynchronously(UhcCore.getPlugin(), () -> economy.depositPlayer(offlinePlayer, amount));
}
 
源代码3 项目: CardinalPGM   文件: PunishmentCommands.java
@Command(aliases = {"warn", "w"}, usage = "<player> [reason]", desc = "Warn a player.", min = 1)
@CommandPermissions("cardinal.punish.warn")
public static void warn(CommandContext cmd, CommandSender sender) throws CommandException {
    Player warned = Bukkit.getPlayer(cmd.getString(0));
    if (warned == null) {
        throw new CommandException(ChatConstant.ERROR_NO_PLAYER_MATCH.getMessage(ChatUtil.getLocale(sender)));
    }
    String reason = cmd.argsLength() > 1 ? cmd.getJoinedStrings(1) : "You have been warned!";
    ChatChannel channel = GameHandler.getGameHandler().getMatch().getModules().getModule(AdminChannel.class);
    channel.sendMessage("[" + ChatColor.GOLD + "A" + ChatColor.WHITE + "] " + ((sender instanceof Player) ? Teams.getTeamColorByPlayer((Player) sender) + ((Player) sender).getDisplayName() : ChatColor.YELLOW + "*Console") + ChatColor.GOLD + " warned " + Teams.getTeamColorByPlayer(warned) + warned.getDisplayName() + ChatColor.GOLD + " for " + reason);
    warned.sendMessage(ChatColor.RED + "" + ChatColor.MAGIC + "-------" + ChatColor.YELLOW + "WARNING" + ChatColor.RED + ChatColor.MAGIC + "-------");
    warned.sendMessage(ChatColor.GREEN + reason);
    warned.sendMessage(ChatColor.YELLOW + reason);
    warned.sendMessage(ChatColor.RED + reason);
    warned.sendMessage(ChatColor.RED + "" + ChatColor.MAGIC + "-------" + ChatColor.YELLOW + "WARNING" + ChatColor.RED + ChatColor.MAGIC + "-------");
}
 
源代码4 项目: QualityArmory   文件: Metrics.java
/**
 * Starts the Scheduler which submits our data every 30 minutes.
 */
private void startSubmitting() {
    final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
    timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            if (!plugin.isEnabled()) { // Plugin was disabled
                timer.cancel();
                return;
            }
            // Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
            // Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
            Bukkit.getScheduler().runTask(plugin, new Runnable() {
                @Override
                public void run() {
                    submitData();
                }
            });
        }
    }, 1000*60*5, 1000*60*30);
    // Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
    // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
    // WARNING: Just don't do it!
}
 
源代码5 项目: PlayerVaults   文件: VaultManager.java
/**
 * Load the player's vault and return it.
 *
 * @param player The holder of the vault.
 * @param number The vault number.
 */
public Inventory loadOwnVault(Player player, int number, int size) {
    if (size % 9 != 0) {
        size = PlayerVaults.getInstance().getDefaultVaultSize();
    }

    PlayerVaults.debug("Loading self vault for " + player.getName() + " (" + player.getUniqueId() + ')');

    String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(number)).replace("%p", player.getName());
    VaultViewInfo info = new VaultViewInfo(player.getUniqueId().toString(), number);
    if (PlayerVaults.getInstance().getOpenInventories().containsKey(info.toString())) {
        PlayerVaults.debug("Already open");
        return PlayerVaults.getInstance().getOpenInventories().get(info.toString());
    }

    YamlConfiguration playerFile = getPlayerVaultFile(player.getUniqueId().toString(), true);
    VaultHolder vaultHolder = new VaultHolder(number);
    if (playerFile.getString(String.format(VAULTKEY, number)) == null) {
        PlayerVaults.debug("No vault matching number");
        Inventory inv = Bukkit.createInventory(vaultHolder, size, title);
        vaultHolder.setInventory(inv);
        return inv;
    } else {
        return getInventory(vaultHolder, player.getUniqueId().toString(), playerFile, size, number, title);
    }
}
 
源代码6 项目: Civs   文件: StructureUtil.java
public static void removeBoundingBox(UUID uuid) {
    Player player = Bukkit.getPlayer(uuid);
    if (player == null || !player.isOnline()) {
        return;
    }
    StructureUtil.BoundingBox boundingBox = boundingBoxes.get(uuid);
    if (boundingBox == null) {
        return;
    }
    Map<Location, Color> locations = boundingBoxes.get(uuid).getLocations();
    if (locations == null) {
        return;
    }
    if (!ConfigManager.getInstance().isUseParticleBoundingBoxes()) {
        for (Location location : locations.keySet()) {
            if (!Util.isLocationWithinSightOfPlayer(location)) {
                continue;
            }
            player.sendBlockChange(location, Material.AIR.createBlockData());
        }
    }
    boundingBoxes.remove(uuid);
}
 
源代码7 项目: AnimatedFrames   文件: AnimatedFrame.java
private void displayCurrentFrame() {
	MultiMapController controller = ((MultiMapController) this.mapWrappers[this.currentFrame].getController());
	for (Iterator<UUID> iterator = this.worldPlayers.iterator(); iterator.hasNext(); ) {
		OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(iterator.next());
		Player player = offlinePlayer != null ? offlinePlayer.getPlayer() : null;
		if (player != null) {
			if (player.getWorld().getName().equals(worldName)) {
				if (player.getLocation().distanceSquared(baseVector.toBukkitLocation(getWorld())) < plugin.maxAnimateDistanceSquared) {
					controller.showInFrames(player.getPlayer(), this.itemFrameIds);
				}
			}
		} else {
			iterator.remove();
			if (offlinePlayer != null) {
				for (MapWrapper wrapper : this.mapWrappers) {
					wrapper.getController().removeViewer(offlinePlayer);
				}
			}
		}
	}
}
 
源代码8 项目: Civs   文件: PeopleMenu.java
private void alphabeticalSort(List<Civilian> civilians) {
    civilians.sort(new Comparator<Civilian>() {
        @Override
        public int compare(Civilian civilian1, Civilian civilian2) {
            OfflinePlayer offlinePlayer1 = Bukkit.getOfflinePlayer(civilian1.getUuid());
            OfflinePlayer offlinePlayer2 = Bukkit.getOfflinePlayer(civilian2.getUuid());
            try {
                return offlinePlayer1.getName().compareTo(offlinePlayer2.getName());
            } catch (Exception e) {
                Object[] args = { Civs.NAME, offlinePlayer1.getName(), offlinePlayer2.getName()};
                Civs.logger.log(Level.WARNING, "{0} Failed to compare name {1} with {2}", args);
                return 0;
            }
        }
    });
}
 
源代码9 项目: Kettle   文件: ItemStack.java
@Utility
public Map<String, Object> serialize() {
    Map<String, Object> result = new LinkedHashMap<String, Object>();

    result.put("type", getType().name());

    if (getDurability() != 0) {
        result.put("damage", getDurability());
    }

    if (getAmount() != 1) {
        result.put("amount", getAmount());
    }

    ItemMeta meta = getItemMeta();
    if (!Bukkit.getItemFactory().equals(meta, null)) {
        result.put("meta", meta);
    }

    return result;
}
 
源代码10 项目: civcraft   文件: ArenaManager.java
private static World createArenaWorld(ConfigArena arena, String name) {
	World world;
	world = Bukkit.getServer().getWorld(name);
	if (world == null) {
		WorldCreator wc = new WorldCreator(name);
		wc.environment(Environment.NORMAL);
		wc.type(WorldType.FLAT);
		wc.generateStructures(false);
		
		world = Bukkit.getServer().createWorld(wc);
		world.setAutoSave(false);
		world.setSpawnFlags(false, false);
		world.setKeepSpawnInMemory(false);
		ChunkCoord.addWorld(world);
	}
	
	return world;
}
 
源代码11 项目: ProjectAres   文件: NicknameCommands.java
@Override
public void enable() {
    final PermissionAttachment attachment = Bukkit.getConsoleSender().addAttachment(plugin);
    Stream.of(
        PERMISSION,
        PERMISSION_GET,
        PERMISSION_SET,
        PERMISSION_ANY,
        PERMISSION_ANY_GET,
        PERMISSION_ANY_SET,
        PERMISSION_IMMEDIATE
    ).forEach(name -> {
        final Permission permission = new Permission(name, PermissionDefault.FALSE);
        pluginManager.addPermission(permission);
        attachment.setPermission(permission, true);
    });
}
 
源代码12 项目: AreaShop   文件: FriendsFeature.java
/**
 * Delete a friend from the region.
 * @param player The UUID of the player to delete
 * @param by     The CommandSender that is adding the friend, or null
 * @return true if the friend has been added, false if adding a friend was cancelled by another plugin
 */
public boolean deleteFriend(UUID player, CommandSender by) {
	// Fire and check event
	DeletedFriendEvent event = new DeletedFriendEvent(getRegion(), Bukkit.getOfflinePlayer(player), by);
	Bukkit.getPluginManager().callEvent(event);
	if(event.isCancelled()) {
		plugin.message(by, "general-cancelled", event.getReason(), this);
		return false;
	}

	Set<String> friends = new HashSet<>(getRegion().getConfig().getStringList("general.friends"));
	friends.remove(player.toString());
	List<String> list = new ArrayList<>(friends);
	if(list.isEmpty()) {
		getRegion().setSetting("general.friends", null);
	} else {
		getRegion().setSetting("general.friends", list);
	}
	return true;
}
 
源代码13 项目: askyblock   文件: ASkyBlock.java
/**
 * @return the netherWorld
 */
public static World getNetherWorld() {
    if (netherWorld == null && Settings.createNether) {
        if (Settings.useOwnGenerator) {
            return Bukkit.getServer().getWorld(Settings.worldName +"_nether");
        }
        if (plugin.getServer().getWorld(Settings.worldName + "_nether") == null) {
            Bukkit.getLogger().info("Creating " + plugin.getName() + "'s Nether...");
        }
        if (!Settings.newNether) {
            netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
        } else {
            netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.FLAT).generator(new ChunkGeneratorWorld())
                    .environment(World.Environment.NETHER).createWorld();
        }
        netherWorld.setMonsterSpawnLimit(Settings.monsterSpawnLimit);
        netherWorld.setAnimalSpawnLimit(Settings.animalSpawnLimit);
    }
    return netherWorld;
}
 
源代码14 项目: ChatItem   文件: ChatItem.java
private boolean isMc112Orlater(){
    switch(getVersion(Bukkit.getServer())){
        case "v1_7_R1": return false;
        case "v1_7_R2": return false;
        case "v1_7_R3": return false;
        case "v1_7_R4": return false;
        case "v1_8_R1": return false;
        case "v1_8_R2": return false;
        case "v1_8_R3": return false;
        case "v1_9_R1": return false;
        case "v1_9_R2": return false;
        case "v1_10_R1": return false;
        case "v1_10_R2": return false;
        case "v1_11_R1": return false;
        default: return true;
    }
}
 
源代码15 项目: AdditionsAPI   文件: ArmorListener.java
@EventHandler(priority =  EventPriority.HIGHEST, ignoreCancelled = true)
public void playerInteractEvent(PlayerInteractEvent e){
	if(e.getAction() == Action.PHYSICAL) return;
	if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
		Player player = e.getPlayer();
		ArmorType newArmorType = ArmorType.matchType(e.getItem());
		if(newArmorType != null){
			if(newArmorType.equals(ArmorType.HELMET) && isAirOrNull(e.getPlayer().getInventory().getHelmet()) || newArmorType.equals(ArmorType.CHESTPLATE) && isAirOrNull(e.getPlayer().getInventory().getChestplate()) || newArmorType.equals(ArmorType.LEGGINGS) && isAirOrNull(e.getPlayer().getInventory().getLeggings()) || newArmorType.equals(ArmorType.BOOTS) && isAirOrNull(e.getPlayer().getInventory().getBoots())){
				ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(e.getPlayer(), EquipMethod.HOTBAR, ArmorType.matchType(e.getItem()), null, e.getItem());
				Bukkit.getServer().getPluginManager().callEvent(armorEquipEvent);
				if(armorEquipEvent.isCancelled()){
					e.setCancelled(true);
					player.updateInventory();
				}
			}
		}
	}
}
 
源代码16 项目: HeavySpleef   文件: MoreFutures.java
/**
 * Add a callback to a {@link ListenableFuture}
 * to be run on the bukkit main thread
 * 
 * @param plugin The plugin registering the callback
 * @param future The {@link ListenableFuture} to add this callback
 * @param callback The callback to be called
 */
public static <T> void addBukkitSyncCallback(final Plugin plugin, ListenableFuture<T> future, final FutureCallback<T> callback) {
	Futures.addCallback(future, new FutureCallback<T>() {
		@Override
		public void onFailure(final Throwable cause) {
			Bukkit.getScheduler().runTask(plugin, new Runnable() {
				
				@Override
				public void run() {
					callback.onFailure(cause);
				}
			});
		}
		@Override
		public void onSuccess(final T result) {
			Bukkit.getScheduler().runTask(plugin, new Runnable() {
				
				@Override
				public void run() {
					callback.onSuccess(result);
				}
			});
		}
	});
}
 
源代码17 项目: Civs   文件: ProtectionsTests.java
@Test
public void blockPlaceShouldNotBeCancelledInUnprotected() {
    RegionsTests.loadRegionTypeDirt();

    Player player = mock(Player.class);
    UUID uuid = new UUID(1, 2);
    when(player.getUniqueId()).thenReturn(uuid);

    Player player2 = mock(Player.class);
    UUID uuid2 = new UUID(1, 3);
    when(player2.getUniqueId()).thenReturn(uuid2);

    HashMap<UUID, String> owners = new HashMap<>();
    owners.put(uuid2, Constants.OWNER);
    Location regionLocation = new Location(Bukkit.getWorld("world"), 0,0,0);
    RegionManager.getInstance().addRegion(new Region("dirt", owners, regionLocation, RegionsTests.getRadii(), new HashMap<String, String>(),0));

    ProtectionHandler protectionHandler = new ProtectionHandler();
    BlockBreakEvent event = new BlockBreakEvent(TestUtil.block3, player);
    protectionHandler.onBlockBreak(event);
    assertFalse(event.isCancelled());
}
 
源代码18 项目: Civs   文件: ProtectionsTests.java
@Test
public void chestAccessAtFourCornersShouldBeBlocked() {
    RegionsTests.loadRegionTypeShelter();
    Region shelter = RegionsTests.createNewRegion("shelter"); // 4.5 0.5 0.5
    Location location1 = new Location(Bukkit.getWorld("world"), 10, 0,6);
    Location location2 = new Location(Bukkit.getWorld("world"), 10, 0,-5);
    Location location3 = new Location(Bukkit.getWorld("world"), -1, 0,6);
    Location location4 = new Location(Bukkit.getWorld("world"), -1, 0,-5);
    ProtectionHandler protectionHandler = new ProtectionHandler();
    assertEquals(location1.getWorld().getUID() + "~4.5~0.5~0.5", shelter.getId());
    assertTrue(ProtectionHandler.shouldBlockAction(location1,null, "chest_use"));
    assertTrue(ProtectionHandler.shouldBlockAction(location2,null, "chest_use"));
    assertTrue(ProtectionHandler.shouldBlockAction(location3,null, "chest_use"));
    assertTrue(ProtectionHandler.shouldBlockAction(location4,null, "chest_use"));
}
 
源代码19 项目: CardinalPGM   文件: Poll.java
private void end() {
    boolean succeed = votedYes.size() > votedNo.size();
    ChatColor color = succeed ? ChatColor.DARK_GREEN : ChatColor.DARK_RED;
    ChatUtil.getGlobalChannel().sendLocalizedMessage(new UnlocalizedChatMessage(color + "{0}", new LocalizedChatMessage(succeed ? ChatConstant.GENERIC_POLL_SUCCEEDED : ChatConstant.GENERIC_POLL_FAILED, command() + color, result())));
    stop(null);
    if (succeed) Bukkit.dispatchCommand(sender, command);
}
 
源代码20 项目: ActionHealth   文件: Main.java
@Override
public void onEnable() {
    saveDefaultConfig();

    // Register health util
    this.healthUtil = new HealthUtil(this);

    // Load config settings
    configStore = new ConfigStore(this);

    // Create player folder
    File file = new File("plugins/ActionHealth/players/");
    file.mkdirs();

    // Register listeners
    getServer().getPluginManager().registerEvents(new HealthListeners(this), this);
    getServer().getPluginManager().registerEvents(new ActionListener(this, new ActionHelper(this)), this);

    // Register commands
    getCommand("Actionhealth").setExecutor(new HealthCommand(this));

    if (Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard")) {
        this.worldGuardPlugin = ((WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard"));
        this.worldGuardAPI = new WorldGuardAPI(this);
    }

    if (Bukkit.getServer().getPluginManager().isPluginEnabled("mcMMO")) {
        mcMMOEnabled = true;
    }

    if (Bukkit.getServer().getPluginManager().isPluginEnabled("MythicMobs")) {
        mythicMobsEnabled = true;
    }

    if (Bukkit.getServer().getPluginManager().isPluginEnabled("LangUtils")) {
        langUtilsEnabled = true;
    }

    actionTask = new ActionTask(this).runTaskTimer(this, 0, configStore.checkTicks);
}
 
源代码21 项目: HolographicDisplays   文件: EntityNMSSlime.java
@Override
public boolean damageEntity(DamageSource damageSource, float amount) {
	if (damageSource instanceof EntityDamageSource) {
		EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
		if (entityDamageSource.getEntity() instanceof EntityPlayer) {
			Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
		}
	}
	return false;
}
 
源代码22 项目: CombatLogX   文件: CompatibilityGriefPrevention.java
@Override
public void onActualEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();

    PluginManager manager = Bukkit.getPluginManager();
    Logger logger = getLogger();

    Plugin pluginGriefPrevention = manager.getPlugin("GriefPrevention");
    if(pluginGriefPrevention == null) {
        logger.info("The GriefPrevention plugin could not be found. This expansion will be automatically disabled.");
        expansionManager.disableExpansion(this);
        return;
    }

    String version = pluginGriefPrevention.getDescription().getVersion();
    logger.info("Successfully hooked into GriefPrevention v" + version);

    saveDefaultConfig("griefprevention-compatibility.yml");
    this.noEntryHandler = new GriefPreventionNoEntryHandler(this);

    NoEntryListener listener = new NoEntryListener(this);
    expansionManager.registerListener(this, listener);

    Plugin pluginProtocolLib = manager.getPlugin("ProtocolLib");
    if(pluginProtocolLib != null) {
        NoEntryForceFieldListener forceFieldListener = new NoEntryForceFieldListener(this);
        expansionManager.registerListener(this, forceFieldListener);

        String versionProtocolLib = pluginProtocolLib.getDescription().getVersion();
        logger.info("Successfully hooked into ProtocolLib v" + versionProtocolLib);
    }
}
 
源代码23 项目: GlobalWarming   文件: WorldConfig.java
public static String getDisplayName(UUID worldId) {
    String worldName = "UNKNOWN";
    if (worldId != null) {
        World world = Bukkit.getWorld(worldId);
        if (world != null) {
            worldName = world.getName();
        }
    }

    return worldName;
}
 
源代码24 项目: Carbon   文件: ParticleEffect.java
/**
 * Sends the packet to all players in a certain range
 * 
 * @param center Center location of the effect
 * @param range Range in which players will receive the packet (Maximum range for particles is usually 16, but it can differ for some types)
 * @throws IllegalArgumentException If the range is lower than 1
 * @see #sendTo(Location center, Player player)
 */
public void sendTo(Location center, double range) throws IllegalArgumentException {
	if (range < 1) {
		throw new IllegalArgumentException("The range is lower than 1");
	}
	String worldName = center.getWorld().getName();
	double squared = range * range;
	for (Player player : Bukkit.getOnlinePlayers()) {
		if (!player.getWorld().getName().equals(worldName) || player.getLocation().distanceSquared(center) > squared) {
			continue;
		}
		sendTo(center, player);
	}
}
 
源代码25 项目: civcraft   文件: DebugCommand.java
public void flashedges_cmd() throws CivException {
	Town town = getNamedTown(1);
	
	for (TownChunk chunk : town.savedEdgeBlocks) {
		for (int x = 0; x < 16; x++) {
			for (int z = 0; z < 16; z++) {
				Block b = Bukkit.getWorld("world").getHighestBlockAt(((chunk.getChunkCoord().getX()+x<<4)+x), 
						((chunk.getChunkCoord().getZ()<<4)+z));
				Bukkit.getWorld("world").playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
			}
		}
	}
	CivMessage.sendSuccess(sender, "flashed");
}
 
源代码26 项目: StackMob-3   文件: PluginHook.java
public PluginHook(IHookManager hm, StackMob sm, PluginCompat hooks){
    plugin = Bukkit.getPluginManager().getPlugin(hooks.getName());
    pluginName = hooks.getName();
    stackMob = sm;
    pluginCompat = hooks;
    hookManager = hm;
}
 
源代码27 项目: HoloAPI   文件: PlayerInjector.java
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    // Handle the packet
    final WrappedPacket packet = new WrappedPacket(msg);

    if (packet.getPacketType().equals(PacketType.Play.Client.USE_ENTITY))
        Bukkit.getScheduler().scheduleSyncDelayedTask(HoloAPI.getCore(), new Runnable() {
            @Override
            public void run() {
                PlayerInjector.this.injectionManager.handlePacket(packet, PlayerInjector.this);
            }
        });

    super.channelRead(ctx, msg);
}
 
源代码28 项目: DungeonsXL   文件: DInstanceWorld.java
@Override
public void kickAllPlayers() {
    getPlayers().forEach(p -> p.leave());
    // Players who shouldn't be in the dungeon but still are for some reason
    if (world != null) {
        getWorld().getPlayers().forEach(p -> p.teleport(Bukkit.getWorlds().get(0).getSpawnLocation()));
    }
}
 
源代码29 项目: BedWars   文件: ThirdPartyShopUtils.java
/**
 * @param player
 * @param stack
 * @param propertyName
 * @param onBuy
 * @param entries
 * @return
 */
public static ItemStack applyPropertyToItem(Player player, ItemStack stack, String propertyName, boolean onBuy,
                                            Object... entries) {
    BedwarsAPI api = BedwarsAPI.getInstance();
    if (!api.isPlayerPlayingAnyGame(player)) {
        return stack;
    }

    Game game = api.getGameOfPlayer(player);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", propertyName);

    String lastEntry = null;
    for (Object obj : entries) {
        if (lastEntry == null) {
            if (obj instanceof String) {
                lastEntry = (String) obj;
            }
        } else {
            map.put(lastEntry, obj);
            lastEntry = null;
        }
    }

    BedwarsApplyPropertyToItem event;
    if (onBuy) {
        event = new BedwarsApplyPropertyToBoughtItem(game, player, stack, map);
    } else {
        event = new BedwarsApplyPropertyToDisplayedItem(game, player, stack, map);
    }
    Bukkit.getPluginManager().callEvent(event);

    return event.getStack();
}
 
源代码30 项目: Skript   文件: WorldGuardHook.java
@Override
public Collection<OfflinePlayer> getMembers() {
	final Collection<UUID> ids = region.getMembers().getUniqueIds();
	final Collection<OfflinePlayer> r = new ArrayList<>(ids.size());
	for (final UUID id : ids)
		r.add(Bukkit.getOfflinePlayer(id));
	return r;
}
 
 类所在包
 同包方法