Java Code Examples for org.bukkit.Bukkit
The following examples show how to use
org.bukkit.Bukkit.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: UhcCore Author: Mezy File: MojangUtils.java License: GNU General Public License v3.0 | 6 votes |
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; } }
Example #2
Source Project: UhcCore Author: Mezy File: VaultManager.java License: GNU General Public License v3.0 | 6 votes |
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)); }
Example #3
Source Project: CardinalPGM Author: twizmwazin File: PunishmentCommands.java License: MIT License | 6 votes |
@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 + "-------"); }
Example #4
Source Project: QualityArmory Author: ZombieStriker File: Metrics.java License: GNU General Public License v3.0 | 6 votes |
/** * 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! }
Example #5
Source Project: PlayerVaults Author: drtshock File: VaultManager.java License: GNU General Public License v3.0 | 6 votes |
/** * 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); } }
Example #6
Source Project: Civs Author: Multitallented File: StructureUtil.java License: GNU General Public License v3.0 | 6 votes |
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); }
Example #7
Source Project: AnimatedFrames Author: InventivetalentDev File: AnimatedFrame.java License: MIT License | 6 votes |
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); } } } } }
Example #8
Source Project: Civs Author: Multitallented File: PeopleMenu.java License: GNU General Public License v3.0 | 6 votes |
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; } } }); }
Example #9
Source Project: Kettle Author: KettleFoundation File: ItemStack.java License: GNU General Public License v3.0 | 6 votes |
@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; }
Example #10
Source Project: civcraft Author: netizen539 File: ArenaManager.java License: GNU General Public License v2.0 | 6 votes |
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; }
Example #11
Source Project: ProjectAres Author: OvercastNetwork File: NicknameCommands.java License: GNU Affero General Public License v3.0 | 6 votes |
@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); }); }
Example #12
Source Project: AreaShop Author: NLthijs48 File: FriendsFeature.java License: GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example #13
Source Project: askyblock Author: tastybento File: ASkyBlock.java License: GNU General Public License v2.0 | 6 votes |
/** * @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; }
Example #14
Source Project: ChatItem Author: dadus33 File: ChatItem.java License: GNU General Public License v3.0 | 6 votes |
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; } }
Example #15
Source Project: AdditionsAPI Author: chrismin13 File: ArmorListener.java License: MIT License | 6 votes |
@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(); } } } } }
Example #16
Source Project: HeavySpleef Author: xaniox File: MoreFutures.java License: GNU General Public License v3.0 | 6 votes |
/** * 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); } }); } }); }
Example #17
Source Project: Civs Author: Multitallented File: ProtectionsTests.java License: GNU General Public License v3.0 | 6 votes |
@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()); }
Example #18
Source Project: Civs Author: Multitallented File: ProtectionsTests.java License: GNU General Public License v3.0 | 5 votes |
@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")); }
Example #19
Source Project: CardinalPGM Author: twizmwazin File: Poll.java License: MIT License | 5 votes |
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); }
Example #20
Source Project: ActionHealth Author: zeshan321 File: Main.java License: MIT License | 5 votes |
@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); }
Example #21
Source Project: HolographicDisplays Author: filoghost File: EntityNMSSlime.java License: GNU General Public License v3.0 | 5 votes |
@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; }
Example #22
Source Project: CombatLogX Author: SirBlobman File: CompatibilityGriefPrevention.java License: GNU General Public License v3.0 | 5 votes |
@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); } }
Example #23
Source Project: GlobalWarming Author: nsporillo File: WorldConfig.java License: GNU Lesser General Public License v3.0 | 5 votes |
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; }
Example #24
Source Project: Carbon Author: NavidK0 File: ParticleEffect.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * 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); } }
Example #25
Source Project: civcraft Author: netizen539 File: DebugCommand.java License: GNU General Public License v2.0 | 5 votes |
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"); }
Example #26
Source Project: StackMob-3 Author: Nathat23 File: PluginHook.java License: GNU General Public License v3.0 | 5 votes |
public PluginHook(IHookManager hm, StackMob sm, PluginCompat hooks){ plugin = Bukkit.getPluginManager().getPlugin(hooks.getName()); pluginName = hooks.getName(); stackMob = sm; pluginCompat = hooks; hookManager = hm; }
Example #27
Source Project: HoloAPI Author: DSH105 File: PlayerInjector.java License: GNU General Public License v3.0 | 5 votes |
@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); }
Example #28
Source Project: DungeonsXL Author: DRE2N File: DInstanceWorld.java License: GNU General Public License v3.0 | 5 votes |
@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())); } }
Example #29
Source Project: BedWars Author: ScreamingSandals File: ThirdPartyShopUtils.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * @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(); }
Example #30
Source Project: Skript Author: SkriptLang File: WorldGuardHook.java License: GNU General Public License v3.0 | 5 votes |
@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; }