-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
160 changed files
with
1,208 additions
and
1,392 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
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
27 changes: 0 additions & 27 deletions
27
src/main/java/me/alexdevs/solstice/api/events/ModuleEvents.java
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/main/java/me/alexdevs/solstice/api/events/ModuleRegistrationCallback.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,21 @@ | ||
package me.alexdevs.solstice.api.events; | ||
|
||
import me.alexdevs.solstice.api.module.ModuleBase; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
|
||
import java.util.HashSet; | ||
|
||
public interface ModuleRegistrationCallback { | ||
Event<ModuleRegistrationCallback> EVENT = EventFactory.createArrayBacked(ModuleRegistrationCallback.class, | ||
(listeners) -> () -> { | ||
var modules = new HashSet<ModuleBase>(); | ||
for (ModuleRegistrationCallback listener : listeners) { | ||
modules.addAll(listener.register()); | ||
} | ||
|
||
return modules; | ||
}); | ||
|
||
HashSet<? extends ModuleBase> register(); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...a/me/alexdevs/solstice/modules/Utils.java → ...e/alexdevs/solstice/api/module/Utils.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
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,41 @@ | ||
package me.alexdevs.solstice.core; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import me.alexdevs.solstice.api.events.ModuleRegistrationCallback; | ||
import me.alexdevs.solstice.api.module.ModuleBase; | ||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; | ||
import net.minecraft.command.CommandRegistryAccess; | ||
import net.minecraft.server.command.CommandManager; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
|
||
import java.util.HashSet; | ||
|
||
public class Modules { | ||
|
||
private HashSet<? extends ModuleBase> modules = new HashSet<>(); | ||
|
||
public Modules() { | ||
CommandRegistrationCallback.EVENT.register(this::registerCommands); | ||
} | ||
|
||
public <T> T getModule(Class<T> classOfModule) { | ||
for (var module : modules) { | ||
if (classOfModule.isInstance(module)) { | ||
return classOfModule.cast(module); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public void register() { | ||
modules = ModuleRegistrationCallback.EVENT.invoker().register(); | ||
} | ||
|
||
private void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess commandRegistry, CommandManager.RegistrationEnvironment environment) { | ||
for (var module : modules) { | ||
for(var command : module.getCommands()) { | ||
command.register(dispatcher, commandRegistry, environment); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.