13
0
geforkt von Mirrors/Velocity

Remove unneeded null checks

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-11-20 12:23:28 -05:00
Ursprung 99960e5dd9
Commit 0d94080c74

Datei anzeigen

@ -72,24 +72,33 @@ public class VelocityServer implements ProxyServer {
.registerTypeHierarchyAdapter(GameProfile.class, new GameProfileSerializer()) .registerTypeHierarchyAdapter(GameProfile.class, new GameProfileSerializer())
.create(); .create();
private @MonotonicNonNull ConnectionManager cm; private ConnectionManager cm;
private @MonotonicNonNull VelocityConfiguration configuration; private @MonotonicNonNull VelocityConfiguration configuration;
private @MonotonicNonNull NettyHttpClient httpClient; private @MonotonicNonNull NettyHttpClient httpClient;
private @MonotonicNonNull KeyPair serverKeyPair; private @MonotonicNonNull KeyPair serverKeyPair;
private @MonotonicNonNull ServerMap servers; private ServerMap servers;
private final VelocityCommandManager commandManager = new VelocityCommandManager(); private final VelocityCommandManager commandManager = new VelocityCommandManager();
private final AtomicBoolean shutdownInProgress = new AtomicBoolean(false); private final AtomicBoolean shutdownInProgress = new AtomicBoolean(false);
private boolean shutdown = false; private boolean shutdown = false;
private @MonotonicNonNull VelocityPluginManager pluginManager; private VelocityPluginManager pluginManager;
private final Map<UUID, ConnectedPlayer> connectionsByUuid = new ConcurrentHashMap<>(); private final Map<UUID, ConnectedPlayer> connectionsByUuid = new ConcurrentHashMap<>();
private final Map<String, ConnectedPlayer> connectionsByName = new ConcurrentHashMap<>(); private final Map<String, ConnectedPlayer> connectionsByName = new ConcurrentHashMap<>();
private @MonotonicNonNull VelocityConsole console; private VelocityConsole console;
private @MonotonicNonNull Ratelimiter ipAttemptLimiter; private @MonotonicNonNull Ratelimiter ipAttemptLimiter;
private @MonotonicNonNull VelocityEventManager eventManager; private VelocityEventManager eventManager;
private @MonotonicNonNull VelocityScheduler scheduler; private VelocityScheduler scheduler;
private final VelocityChannelRegistrar channelRegistrar = new VelocityChannelRegistrar(); private final VelocityChannelRegistrar channelRegistrar = new VelocityChannelRegistrar();
VelocityServer() {
pluginManager = new VelocityPluginManager(this);
eventManager = new VelocityEventManager(pluginManager);
scheduler = new VelocityScheduler(pluginManager);
console = new VelocityConsole(this);
cm = new ConnectionManager(this);
servers = new ServerMap(this);
}
public KeyPair getServerKeyPair() { public KeyPair getServerKeyPair() {
if (serverKeyPair == null) { if (serverKeyPair == null) {
throw new AssertionError(); throw new AssertionError();
@ -135,12 +144,6 @@ public class VelocityServer implements ProxyServer {
logger.info("Booting up {} {}...", getVersion().getName(), getVersion().getVersion()); logger.info("Booting up {} {}...", getVersion().getName(), getVersion().getVersion());
serverKeyPair = EncryptionUtils.createRsaKeyPair(1024); serverKeyPair = EncryptionUtils.createRsaKeyPair(1024);
pluginManager = new VelocityPluginManager(this);
eventManager = new VelocityEventManager(pluginManager);
scheduler = new VelocityScheduler(pluginManager);
console = new VelocityConsole(this);
cm = new ConnectionManager(this);
servers = new ServerMap(this);
cm.logChannelInformation(); cm.logChannelInformation();
@ -224,9 +227,6 @@ public class VelocityServer implements ProxyServer {
} }
public Bootstrap initializeGenericBootstrap() { public Bootstrap initializeGenericBootstrap() {
if (cm == null) {
throw new IllegalStateException("Server did not initialize properly.");
}
return this.cm.createWorker(); return this.cm.createWorker();
} }
@ -362,66 +362,41 @@ public class VelocityServer implements ProxyServer {
@Override @Override
public Optional<RegisteredServer> getServer(String name) { public Optional<RegisteredServer> getServer(String name) {
Preconditions.checkNotNull(name, "name");
if (servers == null) {
throw new IllegalStateException("Server did not initialize properly.");
}
return servers.getServer(name); return servers.getServer(name);
} }
@Override @Override
public Collection<RegisteredServer> getAllServers() { public Collection<RegisteredServer> getAllServers() {
if (servers == null) {
throw new IllegalStateException("Server did not initialize properly.");
}
return servers.getAllServers(); return servers.getAllServers();
} }
@Override @Override
public RegisteredServer registerServer(ServerInfo server) { public RegisteredServer registerServer(ServerInfo server) {
if (servers == null) {
throw new IllegalStateException("Server did not initialize properly.");
}
return servers.register(server); return servers.register(server);
} }
@Override @Override
public void unregisterServer(ServerInfo server) { public void unregisterServer(ServerInfo server) {
if (servers == null) {
throw new IllegalStateException("Server did not initialize properly.");
}
servers.unregister(server); servers.unregister(server);
} }
@Override @Override
public VelocityConsole getConsoleCommandSource() { public VelocityConsole getConsoleCommandSource() {
if (console == null) {
throw new IllegalStateException("Server did not initialize properly.");
}
return console; return console;
} }
@Override @Override
public PluginManager getPluginManager() { public PluginManager getPluginManager() {
if (pluginManager == null) {
throw new IllegalStateException("Server did not initialize properly.");
}
return pluginManager; return pluginManager;
} }
@Override @Override
public EventManager getEventManager() { public EventManager getEventManager() {
if (eventManager == null) {
throw new IllegalStateException("Server did not initialize properly.");
}
return eventManager; return eventManager;
} }
@Override @Override
public VelocityScheduler getScheduler() { public VelocityScheduler getScheduler() {
if (scheduler == null) {
throw new IllegalStateException("Server did not initialize properly.");
}
return scheduler; return scheduler;
} }