geforkt von Mirrors/Velocity
Fix build on Java 11
Dieser Commit ist enthalten in:
Ursprung
154b50992c
Commit
005c12fb0f
@ -11,6 +11,7 @@ import com.velocitypowered.api.proxy.config.ProxyConfig;
|
|||||||
import com.velocitypowered.api.util.Favicon;
|
import com.velocitypowered.api.util.Favicon;
|
||||||
import com.velocitypowered.proxy.util.AddressUtil;
|
import com.velocitypowered.proxy.util.AddressUtil;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -393,9 +394,15 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
* @return the deserialized Velocity configuration
|
* @return the deserialized Velocity configuration
|
||||||
* @throws IOException if we could not read from the {@code path}.
|
* @throws IOException if we could not read from the {@code path}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE",
|
||||||
|
justification = "I looked carefully and there's no way SpotBugs is right.")
|
||||||
public static VelocityConfiguration read(Path path) throws IOException {
|
public static VelocityConfiguration read(Path path) throws IOException {
|
||||||
URL defaultConfigLocation = VelocityConfiguration.class.getClassLoader()
|
URL defaultConfigLocation = VelocityConfiguration.class.getClassLoader()
|
||||||
.getResource("default-velocity.toml");
|
.getResource("default-velocity.toml");
|
||||||
|
if (defaultConfigLocation == null) {
|
||||||
|
throw new RuntimeException("Default configuration file does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
boolean mustResave = false;
|
boolean mustResave = false;
|
||||||
CommentedFileConfig config = CommentedFileConfig.builder(path)
|
CommentedFileConfig config = CommentedFileConfig.builder(path)
|
||||||
.defaultData(defaultConfigLocation)
|
.defaultData(defaultConfigLocation)
|
||||||
@ -411,7 +418,7 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
|
|
||||||
// Copy over default file to tmp location
|
// Copy over default file to tmp location
|
||||||
try (InputStream in = defaultConfigLocation.openStream()) {
|
try (InputStream in = defaultConfigLocation.openStream()) {
|
||||||
Files.copy(Objects.requireNonNull(in), tmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(in, tmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
CommentedFileConfig defaultConfig = CommentedFileConfig.of(tmpFile, TomlFormat.instance());
|
CommentedFileConfig defaultConfig = CommentedFileConfig.of(tmpFile, TomlFormat.instance());
|
||||||
defaultConfig.load();
|
defaultConfig.load();
|
||||||
|
@ -18,6 +18,7 @@ import com.velocitypowered.proxy.VelocityServer;
|
|||||||
import com.velocitypowered.proxy.plugin.loader.VelocityPluginContainer;
|
import com.velocitypowered.proxy.plugin.loader.VelocityPluginContainer;
|
||||||
import com.velocitypowered.proxy.plugin.loader.java.JavaPluginLoader;
|
import com.velocitypowered.proxy.plugin.loader.java.JavaPluginLoader;
|
||||||
import com.velocitypowered.proxy.plugin.util.PluginDependencyUtils;
|
import com.velocitypowered.proxy.plugin.util.PluginDependencyUtils;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.DirectoryStream;
|
import java.nio.file.DirectoryStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -59,6 +60,8 @@ public class VelocityPluginManager implements PluginManager {
|
|||||||
* @param directory the directory to load from
|
* @param directory the directory to load from
|
||||||
* @throws IOException if we could not open the directory
|
* @throws IOException if we could not open the directory
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE",
|
||||||
|
justification = "I looked carefully and there's no way SpotBugs is right.")
|
||||||
public void loadPlugins(Path directory) throws IOException {
|
public void loadPlugins(Path directory) throws IOException {
|
||||||
checkNotNull(directory, "directory");
|
checkNotNull(directory, "directory");
|
||||||
checkArgument(directory.toFile().isDirectory(), "provided path isn't a directory");
|
checkArgument(directory.toFile().isDirectory(), "provided path isn't a directory");
|
||||||
@ -66,8 +69,8 @@ public class VelocityPluginManager implements PluginManager {
|
|||||||
List<PluginDescription> found = new ArrayList<>();
|
List<PluginDescription> found = new ArrayList<>();
|
||||||
JavaPluginLoader loader = new JavaPluginLoader(server, directory);
|
JavaPluginLoader loader = new JavaPluginLoader(server, directory);
|
||||||
|
|
||||||
try (DirectoryStream<Path> stream = Files
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory,
|
||||||
.newDirectoryStream(directory, p -> p.toFile().isFile() && p.toString().endsWith(".jar"))) {
|
p -> p.toFile().isFile() && p.toString().endsWith(".jar"))) {
|
||||||
for (Path path : stream) {
|
for (Path path : stream) {
|
||||||
try {
|
try {
|
||||||
found.add(loader.loadPluginDescription(path));
|
found.add(loader.loadPluginDescription(path));
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren