-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Dev0Louis/dev
Update
- Loading branch information
Showing
21 changed files
with
350 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created | ||
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle | ||
|
||
name: Gradle Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||
settings-path: ${{ github.workspace }} # location for the settings.xml file | ||
|
||
- name: Build with Gradle | ||
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 | ||
with: | ||
arguments: build | ||
|
||
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in | ||
# the publishing section of your build.gradle | ||
- name: Publish to GitHub Packages | ||
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 | ||
with: | ||
arguments: publish | ||
env: | ||
USERNAME: ${{ github.actor }} | ||
TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package dev.louis.nebula; | ||
|
||
import dev.louis.nebula.knowledgemanager.NebulaSpellKnowledgeManager; | ||
import dev.louis.nebula.knowledgemanager.SpellKnowledgeManager; | ||
import dev.louis.nebula.knowledgemanager.player.PlayerSpellKnowledgeManager; | ||
import dev.louis.nebula.manamanager.ManaManager; | ||
import dev.louis.nebula.manamanager.NebulaManaManager; | ||
import dev.louis.nebula.manamanager.player.PlayerManaManager; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.fabricmc.loader.api.ModContainer; | ||
import net.fabricmc.loader.api.metadata.ModMetadata; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
|
||
import java.util.Optional; | ||
|
||
public class NebulaManager { | ||
private static final String JSON_KEY_CONTAINS_MANAMANAGER = "nebula:contains_manamanager"; | ||
private static final String JSON_KEY_CONTAINS_SPELLKNOWLEDGEMANAGER = "nebula:contains_spellknowledgemanager"; | ||
public static final NebulaManager INSTANCE = new NebulaManager(); | ||
|
||
|
||
private boolean nebulaManaManagerActive = true; | ||
private boolean nebulaSpellManagerActive = true; | ||
private Optional<ManaManager> manaManager = Optional.empty(); | ||
private Optional<SpellKnowledgeManager> spellKnowledgeManager = Optional.empty(); | ||
|
||
|
||
private NebulaManager() { | ||
|
||
} | ||
|
||
public static void init() { | ||
INSTANCE.internal_init(); | ||
} | ||
private void internal_init() { | ||
load(); | ||
if(nebulaManaManagerActive) { | ||
registerManaManager(new NebulaManaManager()); | ||
} | ||
if(nebulaSpellManagerActive) { | ||
registerSpellKnowledgeManager(new NebulaSpellKnowledgeManager()); | ||
} | ||
} | ||
|
||
|
||
private void load() { | ||
for (ModContainer container : FabricLoader.getInstance().getAllMods()) { | ||
final ModMetadata meta = container.getMetadata(); | ||
if(meta.getId().equals("nebula"))continue; | ||
if (meta.containsCustomValue(JSON_KEY_CONTAINS_MANAMANAGER)) { | ||
nebulaManaManagerActive = false; | ||
} | ||
if (meta.containsCustomValue(JSON_KEY_CONTAINS_SPELLKNOWLEDGEMANAGER)) { | ||
nebulaSpellManagerActive = false; | ||
} | ||
} | ||
} | ||
public void registerManaManager(ManaManager<?> manaManager) { | ||
if (manaManager == null) { | ||
throw new NullPointerException("Attempt to register a NULL ManaManager"); | ||
} else if (this.manaManager.isPresent()) { | ||
throw new UnsupportedOperationException("A second ManaManager attempted to register. Multiple ManaManagers are not supported."); | ||
} else { | ||
this.manaManager = Optional.of(manaManager); | ||
manaManager.setUp(); | ||
} | ||
} | ||
|
||
public void registerSpellKnowledgeManager(SpellKnowledgeManager<?> spellKnowledgeManager) { | ||
if (spellKnowledgeManager == null) { | ||
throw new NullPointerException("Attempt to register a NULL SpellKnowledgeManager"); | ||
} else if (this.spellKnowledgeManager.isPresent()) { | ||
throw new UnsupportedOperationException("A SpellKnowledgeManager plug-in attempted to register. Multiple SpellKnowledgeManagers are not supported."); | ||
} else { | ||
this.spellKnowledgeManager = Optional.of(spellKnowledgeManager); | ||
spellKnowledgeManager.setUp(); | ||
} | ||
} | ||
|
||
|
||
|
||
public ManaManager<?> getManaManager() { | ||
return manaManager.orElseThrow(); | ||
} | ||
|
||
public SpellKnowledgeManager<?> getSpellKnowledgeManager() { | ||
return spellKnowledgeManager.orElseThrow(); | ||
} | ||
|
||
public PlayerManaManager createPlayerManaManager(PlayerEntity player) { | ||
return getManaManager().createPlayerManaManager(player); | ||
} | ||
|
||
public PlayerSpellKnowledgeManager createPlayerSpellKnowledgeManager(PlayerEntity player) { | ||
return getSpellKnowledgeManager().createPlayerSpellKnowledgeManager(player); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
src/main/java/dev/louis/nebula/event/SpellKnowledgeAddCallback.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/dev/louis/nebula/knowledgemanager/NebulaSpellKnowledgeManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dev.louis.nebula.knowledgemanager; | ||
|
||
import dev.louis.nebula.knowledgemanager.player.NebulaPlayerSpellKnowledgeManager; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
|
||
public class NebulaSpellKnowledgeManager implements SpellKnowledgeManager<NebulaPlayerSpellKnowledgeManager> { | ||
|
||
@Override | ||
public NebulaPlayerSpellKnowledgeManager createPlayerSpellKnowledgeManager(PlayerEntity player) { | ||
return new NebulaPlayerSpellKnowledgeManager(player); | ||
} | ||
|
||
@Override | ||
public void setUp() {} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/dev/louis/nebula/knowledgemanager/SpellKnowledgeManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package dev.louis.nebula.knowledgemanager; | ||
|
||
import dev.louis.nebula.knowledgemanager.player.PlayerSpellKnowledgeManager; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
|
||
public interface SpellKnowledgeManager<T extends PlayerSpellKnowledgeManager> { | ||
T createPlayerSpellKnowledgeManager(PlayerEntity player); | ||
void setUp(); | ||
} |
Oops, something went wrong.