org.spigotmc.SpigotConfig Java Examples
The following examples show how to use
org.spigotmc.SpigotConfig.
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 File: OptimizedUserCache.java From Carbon with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void c() { ArrayList<UserCacheEntry> list = new ArrayList<UserCacheEntry>(); int saved = 0; for (UserCacheEntry entry : uuidToProfile.values()) { if (saved > SpigotConfig.userCacheCap) { break; } list.add(entry); saved++; } String data = gson.toJson(list); BufferedWriter bufferedwriter = null; try { bufferedwriter = Files.newWriter(userCacheFile, Charsets.UTF_8); bufferedwriter.write(data); } catch (FileNotFoundException filenotfoundexception) { } catch (IOException ioexception) { } finally { IOUtils.closeQuietly(bufferedwriter); } }
Example #2
Source File: SpigotPingResponseHandler.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override public ServerPingResponseEvent createResponse(Connection connection) { List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers()); String motd = Bukkit.getMotd(); int maxPlayers = Bukkit.getMaxPlayers(); InternalServerListPingEvent bevent = new InternalServerListPingEvent(connection.getAddress().getAddress(), motd, maxPlayers, players); bevent.setServerIcon(Bukkit.getServerIcon()); Bukkit.getPluginManager().callEvent(bevent); ServerPingResponseEvent revent = new ServerPingResponseEvent( connection, new ProtocolInfo(connection.getVersion(), createServerVersionString()), bevent.getIcon() != null ? ServerPlatform.get().getMiscUtils().convertBukkitIconToBase64(bevent.getIcon()) : null, bevent.getMotd(), bevent.getNumPlayers(), bevent.getMaxPlayers(), bevent.players.stream() .limit(SpigotConfig.playerSample) .map(Player::getName) .collect(Collectors.toList()) ); Bukkit.getPluginManager().callEvent(revent); return revent; }
Example #3
Source File: PGMServer.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
protected void setupProperties() { propertyManager = new EnvPropertyManager(options); setSpawnAnimals(propertyManager.getBoolean("spawn-animals", true)); setSpawnNPCs(propertyManager.getBoolean("spawn-npcs", true)); setPVP(propertyManager.getBoolean("pvp", true)); setAllowFlight(propertyManager.getBoolean("allow-flight", false)); setResourcePack( propertyManager.getString("resource-pack", ""), propertyManager.getString("resource-pack-hash", "")); setGamemode(WorldSettings.EnumGamemode.getById(propertyManager.getInt("gamemode", 0))); setForceGamemode(propertyManager.getBoolean("force-gamemode", false)); setIdleTimeout(propertyManager.getInt("player-idle-timeout", 0)); setMotd(propertyManager.getString("motd", "A Minecraft 1.8 Server")); setWorld(propertyManager.getString("level-name", "world")); setPort(propertyManager.getInt("port", 25565)); c(propertyManager.getInt("max-build-height", 256)); // setBuildHeight c(propertyManager.getString("server-ip", "0.0.0.0")); // setServerIp final String mode = propertyManager.getString("server-mode", "online"); if (mode.equalsIgnoreCase("bungee")) { SpigotConfig.bungee = true; } final boolean online = mode.equalsIgnoreCase("online") || mode.equalsIgnoreCase("true"); propertyManager.setProperty("online-mode", online); setOnlineMode(online); }
Example #4
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void sendPluginMessage(Plugin source, String channel, byte[] message) { StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message); if (getHandle().connection == null) return; if (channels.contains(channel) || SpigotConfig.bungee) { SPacketCustomPayload packet = new SPacketCustomPayload(channel, new PacketBuffer(Unpooled.wrappedBuffer(message))); getHandle().connection.sendPacket(packet); } }
Example #5
Source File: CraftPlayerProfile.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public boolean complete(boolean textures) { MinecraftServer server = MinecraftServer.getServerCB(); boolean isOnlineMode = server.isServerInOnlineMode() || (SpigotConfig.bungee); boolean isCompleteFromCache = this.completeFromCache(true); if (isOnlineMode && (!isCompleteFromCache || textures && !hasTextures())) { GameProfile result = server.getMinecraftSessionService().fillProfileProperties(profile, true); if (result != null) { this.profile = result; } } return profile.isComplete() && (!isOnlineMode || !textures || hasTextures()); }
Example #6
Source File: CraftServer.java From Thermos with GNU General Public License v3.0 | 5 votes |
@Override public long getConnectionThrottle() { // Spigot Start - Automatically set connection throttle for bungee configurations if (org.spigotmc.SpigotConfig.bungee) { return -1; } else { return this.configuration.getInt("settings.connection-throttle"); } // Spigot End }
Example #7
Source File: CraftServer.java From Thermos with GNU General Public License v3.0 | 5 votes |
public boolean dispatchVanillaCommand(CommandSender sender, String commandLine) { if (craftCommandMap.dispatch(sender, commandLine)) { return true; } sender.sendMessage(org.spigotmc.SpigotConfig.unknownCommandMessage); // Spigot return false; }
Example #8
Source File: CraftServer.java From Thermos with GNU General Public License v3.0 | 5 votes |
@Override @Deprecated public OfflinePlayer getOfflinePlayer(String name) { Validate.notNull(name, "Name cannot be null"); // If the name given cannot ever be a valid username give a dummy return, for scoreboard plugins if (!validUserPattern.matcher(name).matches()) { return new CraftOfflinePlayer(this, new GameProfile(invalidUserUUID, name)); } OfflinePlayer result = getPlayerExact(name); if (result == null) { // Spigot start GameProfile profile = null; if (MinecraftServer.getServer().isServerInOnlineMode() || org.spigotmc.SpigotConfig.bungee) { profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(name); } if (profile == null) { // Make an OfflinePlayer using an offline mode UUID since the name has no profile result = getOfflinePlayer(new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name)); } else { // Use the GameProfile even when we get a UUID so we ensure we still have a name result = getOfflinePlayer(profile); } } else { offlinePlayers.remove(result.getUniqueId()); } return result; }
Example #9
Source File: CraftServer.java From Thermos with GNU General Public License v3.0 | 5 votes |
public List<String> tabCompleteCommand(Player player, String message) { // Spigot Start if ( !org.spigotmc.SpigotConfig.tabComplete && !message.contains( " " ) ) { return ImmutableList.of(); } // Spigot End // Spigot Start List<String> completions = new ArrayList<String>(); try { message = message.substring( 1 ); List<String> bukkitCompletions = getCommandMap().tabComplete( player, message ); if ( bukkitCompletions != null ) { completions.addAll( bukkitCompletions ); } List<String> vanillaCompletions = org.spigotmc.VanillaCommandWrapper.complete( player, message ); if ( vanillaCompletions != null ) { completions.addAll( vanillaCompletions ); } // Spigot End } catch (CommandException ex) { player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command"); getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex); } return completions; // Spigot }
Example #10
Source File: Spigot_v1_15_R2.java From worldedit-adapters with GNU Lesser General Public License v3.0 | 5 votes |
public Spigot_v1_15_R2() throws NoSuchFieldException { // A simple test CraftServer.class.cast(Bukkit.getServer()); if (getDataVersion() != 2230) throw new UnsupportedClassVersionError("Not 1.15.2!"); // The list of tags on an NBTTagList nbtListTagListField = NBTTagList.class.getDeclaredField("list"); nbtListTagListField.setAccessible(true); serverWorldsField = CraftServer.class.getDeclaredField("worlds"); serverWorldsField.setAccessible(true); new DataConverters_1_15_R2(getDataVersion(), this).build(ForkJoinPool.commonPool()); Watchdog watchdog; try { Class.forName("org.spigotmc.WatchdogThread"); watchdog = new SpigotWatchdog(); } catch (ClassNotFoundException e) { try { watchdog = new MojangWatchdog(((CraftServer) Bukkit.getServer()).getServer()); } catch (NoSuchFieldException ex) { watchdog = null; } } this.watchdog = watchdog; try { Class.forName("org.spigotmc.SpigotConfig"); SpigotConfig.config.set("world-settings.worldeditregentempworld.verbose", false); } catch (ClassNotFoundException ignored) {} }
Example #11
Source File: Spigot_v1_14_R4.java From worldedit-adapters with GNU Lesser General Public License v3.0 | 5 votes |
public Spigot_v1_14_R4() throws NoSuchFieldException, NoSuchMethodException { // A simple test CraftServer.class.cast(Bukkit.getServer()); if (getDataVersion() != 1976) throw new UnsupportedClassVersionError("Not 1.14.4!"); // The list of tags on an NBTTagList nbtListTagListField = NBTTagList.class.getDeclaredField("list"); nbtListTagListField.setAccessible(true); serverWorldsField = CraftServer.class.getDeclaredField("worlds"); serverWorldsField.setAccessible(true); // The method to create an NBTBase tag given its type ID nbtCreateTagMethod = NBTBase.class.getDeclaredMethod("createTag", byte.class); nbtCreateTagMethod.setAccessible(true); new DataConverters_1_14_R4(getDataVersion(), this).build(ForkJoinPool.commonPool()); Watchdog watchdog; try { Class.forName("org.spigotmc.WatchdogThread"); watchdog = new SpigotWatchdog(); } catch (ClassNotFoundException e) { try { watchdog = new MojangWatchdog(((CraftServer) Bukkit.getServer()).getServer()); } catch (NoSuchFieldException ex) { watchdog = null; } } this.watchdog = watchdog; try { Class.forName("org.spigotmc.SpigotConfig"); SpigotConfig.config.set("world-settings.worldeditregentempworld.verbose", false); } catch (ClassNotFoundException ignored) {} }
Example #12
Source File: Spigot_v1_13_R2_2.java From worldedit-adapters with GNU Lesser General Public License v3.0 | 5 votes |
public Spigot_v1_13_R2_2() throws NoSuchFieldException, NoSuchMethodException { // A simple test CraftServer.class.cast(Bukkit.getServer()); // The list of tags on an NBTTagList nbtListTagListField = NBTTagList.class.getDeclaredField("list"); nbtListTagListField.setAccessible(true); serverWorldsField = CraftServer.class.getDeclaredField("worlds"); serverWorldsField.setAccessible(true); // The method to create an NBTBase tag given its type ID nbtCreateTagMethod = NBTBase.class.getDeclaredMethod("createTag", byte.class); nbtCreateTagMethod.setAccessible(true); // Spigot broke names mid-version, this is a test to see if it's before or after. new NBTTagString("test").asString(); new DataConverters_1_13_R2_2(getDataVersion(), this).build(ForkJoinPool.commonPool()); Watchdog watchdog; try { Class.forName("org.spigotmc.WatchdogThread"); watchdog = new SpigotWatchdog(); } catch (ClassNotFoundException e) { try { watchdog = new MojangWatchdog(((CraftServer) Bukkit.getServer()).getServer()); } catch (NoSuchFieldException ex) { watchdog = null; } } this.watchdog = watchdog; try { Class.forName("org.spigotmc.SpigotConfig"); SpigotConfig.config.set("world-settings.worldeditregentempworld.verbose", false); } catch (ClassNotFoundException ignored) {} }
Example #13
Source File: PaperPingResponseHandler.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public ServerPingResponseEvent createResponse(Connection connection) { PaperServerListPingEvent bevent = new PaperServerListPingEvent( new StatusClientImpl(connection), Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers(), createServerVersionString(), connection.getVersion().getId(), Bukkit.getServerIcon() ); List<PlayerProfile> playerSample = bevent.getPlayerSample(); Bukkit.getOnlinePlayers().stream() .limit(SpigotConfig.playerSample) .map(player -> new NameUUIDPlayerProfile(player.getUniqueId(), player.getName())) .forEach(playerSample::add); Bukkit.getPluginManager().callEvent(bevent); ServerPingResponseEvent revent = new ServerPingResponseEvent( connection, new ProtocolInfo(bevent.getProtocolVersion(), bevent.getVersion()), bevent.getServerIcon() != null ? ServerPlatform.get().getMiscUtils().convertBukkitIconToBase64(bevent.getServerIcon()) : null, bevent.getMotd(), bevent.getNumPlayers(), bevent.getMaxPlayers(), bevent.getPlayerSample().stream().map(PlayerProfile::getName).collect(Collectors.toList()) ); Bukkit.getPluginManager().callEvent(revent); return revent; }
Example #14
Source File: Spigot_v1_16_R1.java From worldedit-adapters with GNU Lesser General Public License v3.0 | 4 votes |
public Spigot_v1_16_R1() throws NoSuchFieldException, NoSuchMethodException { // A simple test CraftServer.class.cast(Bukkit.getServer()); if (getDataVersion() != 2567) throw new UnsupportedClassVersionError("Not 1.16.1!"); // The list of tags on an NBTTagList nbtListTagListField = NBTTagList.class.getDeclaredField("list"); nbtListTagListField.setAccessible(true); serverWorldsField = CraftServer.class.getDeclaredField("worlds"); serverWorldsField.setAccessible(true); getChunkFutureMethod = ChunkProviderServer.class.getDeclaredMethod("getChunkFutureMainThread", int.class, int.class, ChunkStatus.class, boolean.class); getChunkFutureMethod.setAccessible(true); chunkProviderExecutorField = ChunkProviderServer.class.getDeclaredField("serverThreadQueue"); chunkProviderExecutorField.setAccessible(true); new DataConverters_1_16_R1(getDataVersion(), this).build(ForkJoinPool.commonPool()); Watchdog watchdog; try { Class.forName("org.spigotmc.WatchdogThread"); watchdog = new SpigotWatchdog(); } catch (ClassNotFoundException e) { try { watchdog = new MojangWatchdog(((CraftServer) Bukkit.getServer()).getServer()); } catch (NoSuchFieldException ex) { watchdog = null; } } this.watchdog = watchdog; try { Class.forName("org.spigotmc.SpigotConfig"); SpigotConfig.config.set("world-settings.worldeditregentempworld.verbose", false); } catch (ClassNotFoundException ignored) {} }
Example #15
Source File: SpigotMiscUtils.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
@Override public String getOutdatedServerMessage() { return SpigotConfig.outdatedServerMessage; }
Example #16
Source File: SpigotMiscUtils.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
@Override public boolean isProxyEnabled() { return SpigotConfig.bungee; }