Skip to content

Commit

Permalink
Remove "get" prefixes from API methods
Browse files Browse the repository at this point in the history
Co-authored-by: Riley Park <[email protected]>
  • Loading branch information
dualspiral and kashike committed Mar 21, 2021
1 parent 9dd5497 commit 2d955d1
Show file tree
Hide file tree
Showing 851 changed files with 4,957 additions and 4,993 deletions.
2 changes: 1 addition & 1 deletion SpongeAPI
Submodule SpongeAPI updated 665 files
6 changes: 3 additions & 3 deletions src/launch/java/org/spongepowered/common/launch/Launch.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public final boolean isDeveloperEnvironment() {

public final PluginContainer getMinecraftPlugin() {
if (this.minecraftPlugin == null) {
this.minecraftPlugin = this.pluginManager.getPlugin("minecraft").orElse(null);
this.minecraftPlugin = this.pluginManager.plugin("minecraft").orElse(null);

if (this.minecraftPlugin == null) {
throw new RuntimeException("Could not find the plugin representing Minecraft, this is a serious issue!");
Expand All @@ -101,7 +101,7 @@ public final PluginContainer getMinecraftPlugin() {

public final PluginContainer getApiPlugin() {
if (this.apiPlugin == null) {
this.apiPlugin = this.pluginManager.getPlugin("spongeapi").orElse(null);
this.apiPlugin = this.pluginManager.plugin("spongeapi").orElse(null);

if (this.apiPlugin == null) {
throw new RuntimeException("Could not find the plugin representing SpongeAPI, this is a serious issue!");
Expand All @@ -113,7 +113,7 @@ public final PluginContainer getApiPlugin() {

public final PluginContainer getCommonPlugin() {
if (this.commonPlugin == null) {
this.commonPlugin = this.pluginManager.getPlugin("sponge").orElse(null);
this.commonPlugin = this.pluginManager.plugin("sponge").orElse(null);

if (this.commonPlugin == null) {
throw new RuntimeException("Could not find the plugin representing Sponge, this is a serious issue!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public AbstractResourceKeyed(final ResourceKey key) {
}

@Override
public final ResourceKey getKey() {
public final ResourceKey key() {
return this.key;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static void perform(final String engineName, final Runnable engineStart)
SpongeBootstrap.lifecycle.establishGameServices();
SpongeBootstrap.lifecycle.establishDataKeyListeners();

SpongePacketHandler.init((SpongeChannelRegistry) Sponge.getChannelRegistry());
SpongePacketHandler.init((SpongeChannelRegistry) Sponge.channelRegistry());

Launch.getInstance().getLogger().info("Loading Minecraft {}, please wait...", engineName);
engineStart.run();
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/spongepowered/common/SpongeCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private SpongeCommon() {
final @Nullable SpongeGame game = SpongeCommon.game;
if (game != null) {
try {
game.getConfigManager().close();
game.configManager().close();
} catch (final IOException e) {
SpongeCommon.getLogger().error("Failed to shut down configuration watch service", e);
}
Expand All @@ -95,19 +95,19 @@ public static SpongeGame getGame() {
}

public static MinecraftServer getServer() {
return (MinecraftServer) Sponge.getServer();
return (MinecraftServer) Sponge.server();
}

public static SpongeGameRegistry getRegistry() {
return (SpongeGameRegistry) Sponge.getRegistry();
return (SpongeGameRegistry) Sponge.registry();
}

public static ServerScheduler getServerScheduler() {
return (ServerScheduler) Sponge.getServer().getScheduler();
return (ServerScheduler) Sponge.server().scheduler();
}

public static AsyncScheduler getAsyncScheduler() {
return SpongeCommon.getGame().getAsyncScheduler();
return SpongeCommon.getGame().asyncScheduler();
}

public static Path getGameDirectory() {
Expand Down Expand Up @@ -157,12 +157,12 @@ public static void setActivePlugin(@Nullable final PluginContainer plugin) {
* @return True if the event is cancellable and is cancelled, false if not cancelled
*/
public static boolean postEvent(Event event) {
return Sponge.getEventManager().post(event);
return Sponge.eventManager().post(event);
}

@Deprecated
public static boolean postEvent(Event event, boolean allowClientThread) {
return Sponge.getEventManager().post(event);
return Sponge.eventManager().post(event);
}

public static int directionToIndex(Direction direction) {
Expand Down
43 changes: 21 additions & 22 deletions src/main/java/org/spongepowered/common/SpongeGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.spongepowered.api.Platform;
import org.spongepowered.api.Server;
import org.spongepowered.api.asset.AssetManager;
import org.spongepowered.api.command.manager.CommandManager;
import org.spongepowered.api.data.DataManager;
import org.spongepowered.api.event.EventManager;
import org.spongepowered.api.network.channel.ChannelRegistry;
Expand Down Expand Up @@ -106,106 +105,106 @@ public SpongeGame(final Platform platform, final GameRegistry registry, final Bu
}

@Override
public Path getGameDirectory() {
public Path gameDirectory() {
return SpongeCommon.getGameDirectory();
}

@Override
public ServerConsoleSystemSubject getSystemSubject() {
public ServerConsoleSystemSubject systemSubject() {
if (this.systemSubject == null) {
this.systemSubject = new ServerConsoleSystemSubject();
}
return this.systemSubject;
}

@Override
public Platform getPlatform() {
public Platform platform() {
return this.platform;
}

@Override
public GameRegistry getRegistry() {
public GameRegistry registry() {
return this.registry;
}

@Override
public BuilderProvider getBuilderProvider() {
public BuilderProvider builderProvider() {
return this.builderProvider;
}

@Override
public FactoryProvider getFactoryProvider() {
public FactoryProvider factoryProvider() {
return this.factoryProvider;
}

@Override
public DataManager getDataManager() {
public DataManager dataManager() {
return this.dataManager;
}

@Override
public PluginManager getPluginManager() {
public PluginManager pluginManager() {
return this.pluginManager;
}

@Override
public EventManager getEventManager() {
public EventManager eventManager() {
return this.eventManager;
}

@Override
public AssetManager getAssetManager() {
public AssetManager assetManager() {
return this.assetManager;
}

@Override
public PluginConfigManager getConfigManager() {
public PluginConfigManager configManager() {
return this.configManager;
}

@Override
public ChannelRegistry getChannelRegistry() {
public ChannelRegistry channelRegistry() {
return this.channelRegistry;
}

@Override
public MetricsConfigManager getMetricsConfigManager() {
public MetricsConfigManager metricsConfigManager() {
return this.metricsConfigManager;
}

@Override
public SqlManager getSqlManager() {
public SqlManager sqlManager() {
return this.sqlManager;
}

@Override
public ServiceProvider.GameScoped getServiceProvider() {
public ServiceProvider.GameScoped serviceProvider() {
return this.serviceProvider;
}

@Override
public AsyncScheduler getAsyncScheduler() {
public AsyncScheduler asyncScheduler() {
return this.asyncScheduler;
}

@Override
public Locale getLocale(final String locale) {
public Locale locale(final String locale) {
return LocaleCache.getLocale(Preconditions.checkNotNull(locale));
}

@Override
public boolean isServerAvailable() {
if (this.client != null) {
return this.client.getServer().isPresent();
return this.client.server().isPresent();
}

return this.server != null;
}

@Override
public Server getServer() {
public Server server() {
if (this.client != null) {
return this.client.getServer().orElseThrow(() -> new IllegalStateException("The singleplayer server is not available!"));
return this.client.server().orElseThrow(() -> new IllegalStateException("The singleplayer server is not available!"));
}

Preconditions.checkState(this.server != null, "The dedicated server is not available!");
Expand All @@ -222,7 +221,7 @@ public boolean isClientAvailable() {
}

@Override
public Client getClient() {
public Client client() {
Preconditions.checkState(this.client != null, "The client is not available!");
return this.client;
}
Expand Down
56 changes: 28 additions & 28 deletions src/main/java/org/spongepowered/common/SpongeLifecycle.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,20 @@ public SpongeLifecycle(final Game game, final Injector injector) {
}

public void establishFactories() {
((SpongeFactoryProvider) this.game.getFactoryProvider()).registerDefaultFactories();
((SpongeFactoryProvider) this.game.factoryProvider()).registerDefaultFactories();
}

public void establishBuilders() {
((SpongeBuilderProvider) this.game.getBuilderProvider()).registerDefaultBuilders();
((SpongeDataManager) this.game.getDataManager()).registerDefaultBuilders();
((SpongeBuilderProvider) this.game.builderProvider()).registerDefaultBuilders();
((SpongeDataManager) this.game.dataManager()).registerDefaultBuilders();
}

public void callRegisterFactoryEvent() {
this.game.getEventManager().post(new RegisterFactoryEventImpl(Cause.of(EventContext.empty(), this.game), this.game));
this.game.eventManager().post(new RegisterFactoryEventImpl(Cause.of(EventContext.empty(), this.game), this.game));
}

public void callRegisterBuilderEvent() {
this.game.getEventManager().post(new RegisterBuilderEventImpl(Cause.of(EventContext.empty(), this.game), this.game));
this.game.eventManager().post(new RegisterBuilderEventImpl(Cause.of(EventContext.empty(), this.game), this.game));
}

public void establishGlobalRegistries() {
Expand All @@ -101,21 +101,21 @@ public void establishGlobalRegistries() {

SpongeRegistries.registerGlobalRegistries((SpongeRegistryHolder) this.game.registries());

this.game.getEventManager().post(new AbstractRegisterRegistryEvent.GameScopedImpl(Cause.of(EventContext.empty(), this.game), this.game));
this.game.getEventManager().post(new AbstractRegisterRegistryValueEvent.GameScopedImpl(Cause.of(EventContext.empty(), this.game), this.game));
this.game.eventManager().post(new AbstractRegisterRegistryEvent.GameScopedImpl(Cause.of(EventContext.empty(), this.game), this.game));
this.game.eventManager().post(new AbstractRegisterRegistryValueEvent.GameScopedImpl(Cause.of(EventContext.empty(), this.game), this.game));
}

public void callRegisterDataEvent() {
this.game.getEventManager().post(new RegisterDataEventImpl(Cause.of(EventContext.empty(), Sponge.getGame()), Sponge.getGame(),
(SpongeDataManager) this.game.getDataManager()));
this.game.eventManager().post(new RegisterDataEventImpl(Cause.of(EventContext.empty(), Sponge.game()), Sponge.game(),
(SpongeDataManager) this.game.dataManager()));
}

public void establishDataProviders() {
((SpongeDataManager) this.game.getDataManager()).registerDefaultProviders();
((SpongeDataManager) this.game.dataManager()).registerDefaultProviders();
}

public void establishDataKeyListeners() {
((SpongeDataManager) this.game.getDataManager()).registerKeyListeners();
((SpongeDataManager) this.game.dataManager()).registerKeyListeners();
}

public void callRegisterDataPackValueEvent(final Path datapackDir) {
Expand All @@ -129,24 +129,24 @@ public void callRegisterDataPackValueEvent(final Path datapackDir) {
}

public void callRegisterChannelEvent() {
((SpongeChannelRegistry) this.game.getChannelRegistry()).postRegistryEvent();
((SpongeChannelRegistry) this.game.channelRegistry()).postRegistryEvent();
}

public void initTimings() {
((SpongeTimingsFactory) this.game.getFactoryProvider().provide(TimingsFactory.class)).init();
((SpongeTimingsFactory) this.game.factoryProvider().provide(TimingsFactory.class)).init();
}

public void establishGameServices() {
((SpongeServiceProvider) this.game.getServiceProvider()).init();
((SpongeServiceProvider) this.game.serviceProvider()).init();
}

public void establishServerServices() {
((MinecraftServerBridge) this.game.getServer()).bridge$initServices(this.game, this.injector);
((MinecraftServerBridge) this.game.server()).bridge$initServices(this.game, this.injector);
}

public void establishServerFeatures() {
// Yes this looks odd but prevents having to do sided lifecycle solely to always point at the Server
((SpongeServer) this.game.getServer()).getUsernameCache().load();
((SpongeServer) this.game.server()).getUsernameCache().load();
}

public SpongeCommandManager createCommandManager() {
Expand All @@ -156,54 +156,54 @@ public SpongeCommandManager createCommandManager() {
}

public void registerPluginListeners() {
for (final PluginContainer plugin : this.filterInternalPlugins(this.game.getPluginManager().getPlugins())) {
this.game.getEventManager().registerListeners(plugin, plugin.getInstance());
for (final PluginContainer plugin : this.filterInternalPlugins(this.game.pluginManager().plugins())) {
this.game.eventManager().registerListeners(plugin, plugin.getInstance());
}
}

// Methods are in order of the SpongeCommon lifecycle

public void callConstructEvent() {
for (final PluginContainer plugin : this.filterInternalPlugins(this.game.getPluginManager().getPlugins())) {
((SpongeEventManager) this.game.getEventManager()).post(SpongeEventFactory.createConstructPluginEvent(Cause.of(EventContext.empty(),
for (final PluginContainer plugin : this.filterInternalPlugins(this.game.pluginManager().plugins())) {
((SpongeEventManager) this.game.eventManager()).post(SpongeEventFactory.createConstructPluginEvent(Cause.of(EventContext.empty(),
this.game), this.game, plugin), plugin);
}
}

public void establishServerRegistries(final Server server) {
SpongeRegistries.registerServerRegistries((SpongeRegistryHolder) server.registries());

this.game.getEventManager().post(new AbstractRegisterRegistryEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), this.game,
this.game.eventManager().post(new AbstractRegisterRegistryEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), this.game,
server));

this.game.getEventManager().post(new AbstractRegisterRegistryValueEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game),
this.game.eventManager().post(new AbstractRegisterRegistryValueEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game),
this.game, server));
}

public void establishClientRegistries(final Client client) {
this.game.getEventManager().post(new AbstractRegisterRegistryEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), this.game,
this.game.eventManager().post(new AbstractRegisterRegistryEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), this.game,
client));

this.game.getEventManager().post(new AbstractRegisterRegistryValueEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game),
this.game.eventManager().post(new AbstractRegisterRegistryValueEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game),
this.game, client));
}

public void callStartingEngineEvent(final Engine engine) {
this.game.getEventManager().post(SpongeEventFactory.createStartingEngineEvent(PhaseTracker.getCauseStackManager().getCurrentCause(),
this.game.eventManager().post(SpongeEventFactory.createStartingEngineEvent(PhaseTracker.getCauseStackManager().currentCause(),
engine, this.game, (TypeToken<Engine>) TypeToken.get(engine.getClass())));
}

public void callStartedEngineEvent(final Engine engine) {
this.game.getEventManager().post(SpongeEventFactory.createStartedEngineEvent(PhaseTracker.getCauseStackManager().getCurrentCause(),
this.game.eventManager().post(SpongeEventFactory.createStartedEngineEvent(PhaseTracker.getCauseStackManager().currentCause(),
engine, this.game, (TypeToken<Engine>) TypeToken.get(engine.getClass())));
}

public void callLoadedGameEvent() {
this.game.getEventManager().post(SpongeEventFactory.createLoadedGameEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), this.game));
this.game.eventManager().post(SpongeEventFactory.createLoadedGameEvent(PhaseTracker.getCauseStackManager().currentCause(), this.game));
}

public void callStoppingEngineEvent(final Engine engine) {
this.game.getEventManager().post(SpongeEventFactory.createStoppingEngineEvent(PhaseTracker.getCauseStackManager().getCurrentCause(),
this.game.eventManager().post(SpongeEventFactory.createStoppingEngineEvent(PhaseTracker.getCauseStackManager().currentCause(),
engine, this.game, (TypeToken<Engine>) TypeToken.get(engine.getClass())));
}

Expand Down
Loading

0 comments on commit 2d955d1

Please sign in to comment.