Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a0b710e
Add resource manager for data packs
mattmess1221 Nov 28, 2017
8e0fc0e
Resource.getReader now returns a BufferedReader
mattmess1221 Jan 8, 2018
cb2f431
ResourcePath is iterable on it's parents
mattmess1221 Jan 9, 2018
2efe859
Fixup some javadoc
mattmess1221 Jan 9, 2018
84a1b55
Add some filename related methods
mattmess1221 Jan 10, 2018
aa40cf5
Add some methods to ResourceReloadEvent.Pre for manipulating the pack…
mattmess1221 Jan 10, 2018
425b94e
Add a method in Pack.Builder for providing from a file
mattmess1221 Jan 10, 2018
12cc2f6
Rework the resource system to be more inline with vanilla.
mattmess1221 Nov 11, 2018
abd3024
Add a PackRepository and PackInfo. The PackInfo is used to get the Pack,
mattmess1221 Nov 11, 2018
58020b5
Update some javadocs and modify a few methods
mattmess1221 Nov 12, 2018
0cf1c83
Add resourcetype argument to PluginContainer.getPack()
mattmess1221 Jan 21, 2019
2a78632
Change for 1.14
mattmess1221 May 3, 2019
30fe7de
Fix the build
mattmess1221 May 3, 2019
1052aab
Fix some rebase artifacts
mattmess1221 May 5, 2019
84cf0d9
AsyncReloader had too much impl.
mattmess1221 May 12, 2019
309d66e
Pack should be closeable.
mattmess1221 May 12, 2019
d6dc2a0
Fixes to javadocs and nitpicks
mattmess1221 May 12, 2019
a47186a
Change PackTypes.ASSETS to RESOURCES
mattmess1221 May 12, 2019
b124bb8
Remove the assets package.
mattmess1221 May 15, 2019
f540f2b
Fix some nitpicks
mattmess1221 May 15, 2019
fcfb76c
Remove WillNotClose from Resource copy.
mattmess1221 Jun 18, 2019
b195b1d
Change getInputStream javadoc to represent current code.
mattmess1221 Jun 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ sortClassFields {
add 'main', 'org.spongepowered.api.item.inventory.equipment.EquipmentTypes'
add 'main', 'org.spongepowered.api.item.inventory.query.QueryOperationTypes'
add 'main', 'org.spongepowered.api.item.potion.PotionTypes'
add 'main', 'org.spongepowered.api.resource.pack.PackTypes'
add 'main', 'org.spongepowered.api.scoreboard.CollisionRules'
add 'main', 'org.spongepowered.api.scoreboard.Visibilities'
add 'main', 'org.spongepowered.api.scoreboard.criteria.Criteria'
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/org/spongepowered/api/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
package org.spongepowered.api;

import org.spongepowered.api.client.Client;
import org.spongepowered.api.resource.ResourceManager;
import org.spongepowered.api.resource.pack.PackRepository;
import org.spongepowered.api.scheduler.Scheduler;

import java.util.concurrent.CompletableFuture;

/**
* Shared functionality between {@link Client} and {@link Server} engines.
*/
Expand All @@ -39,6 +43,29 @@ public interface Engine {
*/
Scheduler getScheduler();

/**
* Gets the {@link ResourceManager} for the server instance. As of
* Minecraft 1.13 there is only one instance of the resource manager per
* server/client instance. It is not per-world.
*
* @return The resource manager
*/
ResourceManager getResourceManager();

/**
* Gets the {@link PackRepository} for the game, which discovers and
* activates resource and data packs.
*/
PackRepository getPackRepository();

/**
* Reloads resources from the {@link ResourceManager} using active packs
* from the {@link PackRepository}.
*
* @return The future when it will finish.
*/
CompletableFuture<Void> reloadResources();

/**
* Checks if the {@link Thread#currentThread() current thread} is the main thread of the engine.
*
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/spongepowered/api/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package org.spongepowered.api;

import org.spongepowered.api.asset.AssetManager;
import org.spongepowered.api.client.Client;
import org.spongepowered.api.config.ConfigManager;
import org.spongepowered.api.data.DataManager;
Expand Down Expand Up @@ -163,15 +162,6 @@ default EventManager getEventManager() {
return Sponge.getEventManager();
}

/**
* Gets the {@link AssetManager}.
*
* @return The asset manager
*/
default AssetManager getAssetManager() {
return Sponge.getAssetManager();
}

/**
* Gets the {@link ConfigManager} used to load and manage configuration files
* for plugins.
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/org/spongepowered/api/Sponge.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import com.google.inject.Inject;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.asset.AssetManager;
import org.spongepowered.api.command.manager.CommandManager;
import org.spongepowered.api.config.ConfigManager;
import org.spongepowered.api.data.DataManager;
Expand Down Expand Up @@ -58,7 +57,6 @@ public final class Sponge {
@Inject private static PropertyRegistry propertyRegistry;
@Inject private static PluginManager pluginManager;
@Inject private static EventManager eventManager;
@Inject private static AssetManager assetManager;
@Inject private static ConfigManager configManager;
@Inject private static ServiceManager serviceManager;
@Inject private static ChannelRegistrar channelRegistrar;
Expand Down Expand Up @@ -140,15 +138,6 @@ public static EventManager getEventManager() {
return check(eventManager);
}

/**
* Gets the {@link AssetManager} instance.
*
* @return The asset manager instance
*/
public static AssetManager getAssetManager() {
return check(assetManager);
}

/**
* Gets the {@link ConfigManager} used to load and manage configuration files
* for plugins.
Expand Down
217 changes: 0 additions & 217 deletions src/main/java/org/spongepowered/api/asset/Asset.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,34 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.asset;
package org.spongepowered.api.event.resource;

import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer;

import java.util.Optional;
import org.spongepowered.api.Engine;
import org.spongepowered.api.event.Event;
import org.spongepowered.api.resource.ResourceManager;

/**
* The AssetManager offers a convenient way to easily retrieve resources from
* Sponge {@link Plugin}s. The asset manager will attempt to find the
* asset of the specified name at: <code>assets/&lt;plugin_id&gt;</code>
* Base class for events related to resources.
*/
public interface AssetManager {
public interface ResourceEvent extends Event {
Comment thread
mattmess1221 marked this conversation as resolved.

/**
* Gets the engine of the resources
* @return The engine
*/
Engine getEngine();

/**
* Returns the {@link Asset} of the specified name for the specified
* {@link Plugin} instance.
*
* @param plugin Plugin instance
* @param name Name of resource to retrieve
* @return Asset if present, empty otherwise
* Gets the {@link ResourceManager}.
* @return The resource manager
*/
Optional<Asset> getAsset(PluginContainer plugin, String name);
ResourceManager getResourceManager();

/**
* Returns the {@link Asset} of the specified name within the domain of the
* implementation. This method will typically call
* {@link #getAsset(PluginContainer, String)} using a dummy
* {@link PluginContainer} for the SpongeAPI implementation.
*
* @param name Name of resource to retrieve
* @return Asset if present, empty otherwise
* Fired after a {@link ResourceManager} has been reloaded. This can be
* used to reload some systems that are resource based.
*/
Optional<Asset> getAsset(String name);
interface Reload extends ResourceEvent {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please allow plugins to work async! This will increase load on the server and cannot be profiled by vanilla loading bar, etc.


}
}
Loading