Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 53 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: Bug
assignees: ''

---

## Describe the bug (REQUIRED)
<!-- A clear and concise description of what the bug is. -->


## Expected behaviour (REQUIRED)
<!-- A clear and concise description of what you expected to happen. -->


## Steps to Reproduce Issue (REQUIRED)
<!-- Tell us the exact steps to reproduce the issue -->
<!-- What events lead up to the issue occurring -->
<!-- If possible provide Youtube Video or Screenshots -->
1.
2.
3.


## Environment (REQUIRED)
<!-- Any issue without detailed version numbers will be closed -->
<!-- Indicate the type of server you are running (Spigot/Paper) and the version number -->
<!-- Detail the version number of Craftory that you are using and any plugins that use Craftory -->
<!-- Optionally - Detail any other plugins on the server and their versions -->
<!-- NOTE "latest" can not be used for a version number and you can screenshot version numbers -->

- Server Software:
- Minecraft Version:
- Craftory Version:
- Other Craftory Plugins:

## Server Log (OPTIONAL)
<!-- PROVIDE this if possible -->
<!-- Take a look at the Server Log, this can often provide the cause or details of the issue -->
<!-- Provide us with your server log by copying it into https://mclo.gs/ and adding the link here -->
<!-- You can find your full log under /logs/latest.log in your server folder -->


## Estimated Difficulty (OPTIONAL)
<!-- How hard is this bug will be to fix -->
<!-- If you don't have the technical knowledge an educated guess will help -->
<!-- Pick one of : [Very Low, Low, Medium, High, Very High] for the difficulty -->


## Additional context (OPTIONAL)
<!-- Any additional details you think are relevant to the issue -->
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Suggestion] "
labels: Feature, Suggestion
assignees: ''

---

<!-- Read First! -->
<!-- Each feature request should only contain one feature and no more -->
<!-- For example add xxxx new machine, or add xxx new system -->
<!-- If requests contain more they should be broken into separate requests -->


## Description of Feature (REQUIRED)
<!-- A clear and detailed description of the feature you want to be added. -->


## Details of Benefit (REQUIRED)
<!-- Provide details about how this feature would benefit Craftory and why it should be added -->
<!-- Mainly used to decide the priority of this feature -->


## Estimated Difficulty (OPTIONAL)
<!-- How hard is this feature to implement -->
<!-- If you don't have the technical knowledge, base this off how large the feature is -->
<!-- Pick one of : [Very Low, Low, Medium, High, Very High] for the difficulty -->
21 changes: 21 additions & 0 deletions .github/workflows/release-notes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release-Notes-Preview

on:
pull_request:
branches: [ master ]
issue_comment:
types: [ edited ]

jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow --tags
- uses: snyk/release-notes-preview@v1.6.1
with:
releaseBranch: master
env:
GITHUB_PR_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Publish package to GitHub Packages
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 11
- name: Change Project
run: cd api
- name: Publish package
run: mvn --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 9 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@
<sonar.projectKey>craftorystudios_Craftory_Core</sonar.projectKey>
<sonar.organization>craftorystudios</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

<artifactId>craftory-api</artifactId>
<packaging>jar</packaging>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub CraftoryStudios Apache Maven Packages</name>
<url>https://maven.pkg.github.com/CraftoryStudios/Craftory</url>
</repository>
</distributionManagement>

<build>
<plugins>
<plugin>
Expand Down
17 changes: 12 additions & 5 deletions api/src/main/java/studio/craftory/core/Craftory.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;
import studio.craftory.core.api.CustomBlockAPI;
import studio.craftory.core.blocks.BlockRenderManager;
import studio.craftory.core.blocks.CustomBlockManager;
import studio.craftory.core.blocks.CustomBlockRegistry;
import studio.craftory.core.commands.SpawnItemCommand;
Expand All @@ -22,6 +23,7 @@
import studio.craftory.core.listeners.CustomBlockListener;
import studio.craftory.core.listeners.WorldListener;
import studio.craftory.core.recipes.RecipeManager;
import studio.craftory.core.resourcepack.AssetLinker;
import studio.craftory.core.utils.Log;

public final class Craftory extends JavaPlugin {
Expand All @@ -34,19 +36,18 @@ public final class Craftory extends JavaPlugin {
private AsyncExecutionManager asyncExecutionManager;
private SyncExecutionManager syncExecutionManager;
private CustomBlockManager customBlockManager;
private BlockRenderManager blockRenderManager;

//External
private CustomItemManager customItemManager;
private RecipeManager recipeManager;

//External API
@Getter
CustomBlockAPI customBlockAPI;

private CustomBlockAPI customBlockAPI;

public static CustomItemManager getCustomItemManager() {
return instance.customItemManager;
}
public static RecipeManager getRecipeManager() { return instance.recipeManager; }
public static CustomBlockAPI getCustomBlockAPI() {return instance.customBlockAPI; }

@Override
public void onLoad() {
Expand All @@ -65,6 +66,7 @@ public void onLoad() {

//Custom Block
injector.getSingleton(CustomBlockRegistry.class);
blockRenderManager = injector.getSingleton(BlockRenderManager.class);
customBlockManager = injector.getSingleton(CustomBlockManager.class);

//API
Expand All @@ -80,17 +82,22 @@ public void onEnable() {

//Register Events
PluginManager pluginManager = getServer().getPluginManager();
pluginManager.registerEvents(blockRenderManager, instance);
pluginManager.registerEvents(injector.getSingleton(CustomBlockListener.class), instance);
pluginManager.registerEvents(injector.getSingleton(WorldListener.class), instance);
pluginManager.registerEvents(injector.getSingleton(ChunkListener.class), instance);
pluginManager.registerEvents(injector.getSingleton(ItemEventManager.class), instance);
pluginManager.registerEvents(recipeManager, instance);


//Executor
asyncExecutionManager.runTaskTimer(this, 20L, 1L);
syncExecutionManager.runTaskTimer(this, 20L,1L);
getServer().getPluginManager().registerEvents(new ItemEventManager(), this);

AssetLinker linker = injector.getSingleton(AssetLinker.class);
linker.runTaskLater(this, 1);

//Commands
PluginCommand spawnCommand = this.getCommand("spawnItem");
if(spawnCommand!=null) {
Expand Down
8 changes: 8 additions & 0 deletions api/src/main/java/studio/craftory/core/CraftoryAddon.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
package studio.craftory.core;

import java.net.URL;

public interface CraftoryAddon {

URL getAddonResources();

default void craftoryOnEnable() {

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface RenderData {
public @interface DefaultRendersData {
String northFacingModel() default "";
String southFacingModel() default "";
String eastFacingModel() default "";
String westFacingModel() default "";
String upFacingModel() default "";
String downFacingModel() default "";
String headModel() default "";
String all() default "";
}
16 changes: 14 additions & 2 deletions api/src/main/java/studio/craftory/core/api/CustomBlockAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
import org.bukkit.plugin.Plugin;
import studio.craftory.core.blocks.CustomBlockManager;
import studio.craftory.core.blocks.CustomBlockRegistry;
import studio.craftory.core.blocks.rendering.CraftoryRenderer;
import studio.craftory.core.blocks.rendering.renderers.DefaultRenderer;
import studio.craftory.core.blocks.templates.BaseCustomBlock;
import studio.craftory.core.data.CraftoryDirection;
import studio.craftory.core.data.keys.CraftoryDataKey;
import studio.craftory.core.data.keys.CraftoryBlockKey;
import studio.craftory.core.resourcepack.AssetLinker;
import studio.craftory.core.utils.Log;

public class CustomBlockAPI {
Expand All @@ -19,9 +22,18 @@ public class CustomBlockAPI {
public CustomBlockRegistry blockRegister;
@Inject
public CustomBlockManager customBlockManager;
@Inject
public AssetLinker assetLinker;

public void registerCustomBlock(@NonNull Plugin plugin, @NonNull Class<? extends BaseCustomBlock> customBlock,
@NonNull String[] textures, @NonNull Class<? extends CraftoryRenderer> renderer) {
CraftoryBlockKey blockKey = blockRegister.registerCustomBlockClass(plugin, customBlock);
assetLinker.registerBlockAssets(blockKey, renderer, textures);
}

public void registerCustomBlock(@NonNull Plugin plugin, @NonNull Class<? extends BaseCustomBlock> customBlock) {
blockRegister.registerCustomBlockClass(plugin, customBlock);
public void registerCustomBlock(@NonNull Plugin plugin, @NonNull Class<? extends BaseCustomBlock> customBlock,
@NonNull String[] textures) {
registerCustomBlock(plugin, customBlock, textures, DefaultRenderer.class);
}

public Optional<BaseCustomBlock> placeCustomBlock(@NonNull Location location, @NonNull Class<? extends BaseCustomBlock> customBlockClazz,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,49 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import lombok.Getter;
import lombok.NonNull;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import studio.craftory.core.Craftory;
import studio.craftory.core.blocks.renders.BlockStateRenderer;
import studio.craftory.core.blocks.renders.CraftoryRenderer;
import studio.craftory.core.blocks.renders.RenderData;
import studio.craftory.core.blocks.renders.Renderers;
import studio.craftory.core.blocks.rendering.renderers.DefaultRenderer;
import studio.craftory.core.blocks.rendering.CraftoryRenderer;
import studio.craftory.core.blocks.rendering.renderers.DefaultRotationalRenderer;
import studio.craftory.core.data.RenderData;
import studio.craftory.core.data.CraftoryDirection;
import studio.craftory.core.data.events.ResourcePackBuilt;
import studio.craftory.core.data.keys.CraftoryBlockKey;
import studio.craftory.core.utils.Log;

public class BlockRenderManager {
public class BlockRenderManager implements Listener {
private final ObjectMapper mapper;

@Getter
private Map<String, CraftoryRenderer> renderers = new HashMap<>();
private Map<String, RenderData> blockToRenderDataMap = new HashMap<>();

public BlockRenderManager() {
mapper = new ObjectMapper();

registerDefaultRenders();
}

@EventHandler
public void onResourcePackBuilt(ResourcePackBuilt event) {
loadRenderData();
}

private void registerDefaultRenders() {
registerRenderer(Renderers.BLOCK_STATE_RENDER, new BlockStateRenderer());
registerRenderer(Renderers.TRANSPARENT_BLOCK_STATE_RENDER, new BlockStateRenderer());
registerRenderer(DefaultRenderer.class);
registerRenderer(DefaultRotationalRenderer.class);
}

public void registerRenderer(String key, CraftoryRenderer renderer) {
renderers.putIfAbsent(key, renderer);
}
public void registerRenderer(Renderers key, CraftoryRenderer renderer) {
registerRenderer(key.value, renderer);
public void registerRenderer(@NonNull Class<? extends CraftoryRenderer> renderer) {
try {
renderers.putIfAbsent(renderer.getSimpleName(), renderer.getDeclaredConstructor().newInstance());
} catch (Exception e ) {
Log.error("Couldn't register renderer ", renderer.getName());
}
}

public void renderCustomBlock(CraftoryBlockKey blockKey, Block block, CraftoryDirection direction) {
Expand Down
Loading