generated from Alathra/Template-Gradle-Plugin
-
-
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.
Revert "fix: Delete src/main/java/io/github/Alathra directory"
This reverts commit 9d9f116.
- Loading branch information
1 parent
9d9f116
commit 2ae7ac3
Showing
31 changed files
with
2,038 additions
and
0 deletions.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
src/main/java/io/github/Alathra/AlathraSkills/AlathraSkills.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,117 @@ | ||
package io.github.alathra.alathraskills; | ||
|
||
import com.github.milkdrinkers.colorparser.ColorParser; | ||
|
||
import io.github.alathra.alathraskills.api.SkillsManager; | ||
import io.github.alathra.alathraskills.api.SkillsPlayerManager; | ||
import io.github.alathra.alathraskills.command.CommandHandler; | ||
import io.github.alathra.alathraskills.config.ConfigHandler; | ||
import io.github.alathra.alathraskills.db.DatabaseHandler; | ||
import io.github.alathra.alathraskills.db.testing.TestGetExerienceCommand; | ||
import io.github.alathra.alathraskills.hooks.VaultHook; | ||
import io.github.alathra.alathraskills.listeners.ListenerHandler; | ||
import io.github.alathra.alathraskills.utility.Logger; | ||
|
||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class AlathraSkills extends JavaPlugin { | ||
private static AlathraSkills instance; | ||
private ConfigHandler configHandler; | ||
private DatabaseHandler databaseHandler; | ||
private CommandHandler commandHandler; | ||
private ListenerHandler listenerHandler; | ||
private static VaultHook vaultHook; | ||
|
||
// Internal managers | ||
private static SkillsManager skillsManager; | ||
private static SkillsPlayerManager skillsPlayerManager; | ||
|
||
public static AlathraSkills getInstance() { | ||
return instance; | ||
} | ||
|
||
@Override | ||
public void onLoad() { | ||
instance = this; | ||
configHandler = new ConfigHandler(instance); | ||
databaseHandler = new DatabaseHandler(instance); | ||
commandHandler = new CommandHandler(instance); | ||
listenerHandler = new ListenerHandler(instance); | ||
vaultHook = new VaultHook(instance); | ||
skillsManager = new SkillsManager(instance); | ||
skillsPlayerManager = new SkillsPlayerManager(instance); | ||
|
||
configHandler.onLoad(); | ||
databaseHandler.onLoad(); | ||
commandHandler.onLoad(); | ||
listenerHandler.onLoad(); | ||
vaultHook.onLoad(); | ||
skillsManager.onLoad(); | ||
skillsPlayerManager.onLoad(); | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
configHandler.onEnable(); | ||
databaseHandler.onEnable(); | ||
commandHandler.onEnable(); | ||
listenerHandler.onEnable(); | ||
vaultHook.onEnable(); | ||
skillsManager.onEnable(); | ||
skillsPlayerManager.onEnable(); | ||
|
||
if (vaultHook.isVaultLoaded()) { | ||
Logger.get().info(ColorParser.of("<green>Vault has been found on this server. Vault support enabled.").build()); | ||
} else { | ||
Logger.get().warn(ColorParser.of("<yellow>Vault is not installed on this server. Vault support has been disabled.").build()); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
configHandler.onDisable(); | ||
databaseHandler.onDisable(); | ||
commandHandler.onDisable(); | ||
listenerHandler.onDisable(); | ||
vaultHook.onDisable(); | ||
skillsManager.onDisable(); | ||
skillsPlayerManager.onDisable(); | ||
} | ||
|
||
/** | ||
* Gets data handler. | ||
* | ||
* @return the data handler | ||
*/ | ||
@NotNull | ||
public DatabaseHandler getDataHandler() { | ||
return databaseHandler; | ||
} | ||
|
||
/** | ||
* Gets config handler. | ||
* | ||
* @return the config handler | ||
*/ | ||
@NotNull | ||
public ConfigHandler getConfigHandler() { | ||
return configHandler; | ||
} | ||
|
||
/** | ||
* Gets vault hook. | ||
* | ||
* @return the vault hook | ||
*/ | ||
@NotNull | ||
public static VaultHook getVaultHook() { | ||
return vaultHook; | ||
} | ||
|
||
@NotNull | ||
public static SkillsManager getSkillsManager() { | ||
return skillsManager; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/io/github/Alathra/AlathraSkills/Reloadable.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 io.github.alathra.alathraskills; | ||
|
||
/** | ||
* Implemented in classes that should support being reloaded IE executing the methods during runtime after startup. | ||
*/ | ||
public interface Reloadable { | ||
/** | ||
* On plugin load. | ||
*/ | ||
void onLoad(); | ||
|
||
/** | ||
* On plugin enable. | ||
*/ | ||
void onEnable(); | ||
|
||
/** | ||
* On plugin disable. | ||
*/ | ||
void onDisable(); | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/io/github/Alathra/AlathraSkills/api/SkillsManager.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,50 @@ | ||
package io.github.alathra.alathraskills.api; | ||
|
||
import java.util.HashMap; | ||
|
||
import io.github.alathra.alathraskills.AlathraSkills; | ||
import io.github.alathra.alathraskills.Reloadable; | ||
import io.github.alathra.alathraskills.skills.SkillCategory; | ||
import io.github.alathra.alathraskills.skills.categories.FarmingSkillCategory; | ||
import io.github.alathra.alathraskills.skills.categories.MiningSkillCategory; | ||
import io.github.alathra.alathraskills.skills.categories.WoodcuttingSkillCategory; | ||
|
||
public class SkillsManager implements Reloadable { | ||
|
||
public static int FARMING_SKILL_ID = 1; | ||
public static int MINING_SKILL_ID = 2; | ||
public static int WOODCUTTING_SKILL_ID = 3; | ||
|
||
private final AlathraSkills plugin; | ||
|
||
// Id, SkillCategory | ||
public HashMap<Integer, SkillCategory> skillCategories = new HashMap<>(); | ||
|
||
public SkillsManager(AlathraSkills plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void onLoad() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
loadSkillCategories(); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
public void loadSkillCategories() { | ||
skillCategories.put(1, new FarmingSkillCategory(1)); | ||
skillCategories.put(2, new MiningSkillCategory(2)); | ||
skillCategories.put(3, new WoodcuttingSkillCategory(3)); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/io/github/Alathra/AlathraSkills/api/SkillsPlayerManager.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,34 @@ | ||
package io.github.alathra.alathraskills.api; | ||
|
||
import io.github.alathra.alathraskills.AlathraSkills; | ||
import io.github.alathra.alathraskills.Reloadable; | ||
|
||
public class SkillsPlayerManager implements Reloadable { | ||
|
||
private final AlathraSkills plugin; | ||
|
||
public SkillsPlayerManager(AlathraSkills plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void onLoad() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
//TODO | ||
// https://github.com/Rumsfield/konquest/blob/main/api/src/main/java/com/github/rumsfield/konquest/api/manager/KonquestPlayerManager.java | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/io/github/Alathra/AlathraSkills/command/CommandHandler.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,47 @@ | ||
package io.github.alathra.alathraskills.command; | ||
|
||
import io.github.alathra.alathraskills.AlathraSkills; | ||
import io.github.alathra.alathraskills.Reloadable; | ||
import io.github.alathra.alathraskills.db.testing.TestDeleteAllSkillsCommand; | ||
import io.github.alathra.alathraskills.db.testing.TestGetAllSkillsCommand; | ||
import io.github.alathra.alathraskills.db.testing.TestGetExerienceCommand; | ||
import io.github.alathra.alathraskills.db.testing.TestHasSkillCommand; | ||
import io.github.alathra.alathraskills.db.testing.TestSetExerienceCommand; | ||
import io.github.alathra.alathraskills.db.testing.TestSetSkillCommand; | ||
import dev.jorel.commandapi.CommandAPI; | ||
import dev.jorel.commandapi.CommandAPIBukkitConfig; | ||
|
||
/** | ||
* A class to handle registration of commands. | ||
*/ | ||
public class CommandHandler implements Reloadable { | ||
private final AlathraSkills plugin; | ||
|
||
public CommandHandler(AlathraSkills plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void onLoad() { | ||
CommandAPI.onLoad(new CommandAPIBukkitConfig(plugin).shouldHookPaperReload(true).silentLogs(true)); | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
CommandAPI.onEnable(); | ||
|
||
// Register commands here | ||
new TestGetExerienceCommand(); | ||
new TestSetExerienceCommand(); | ||
new TestDeleteAllSkillsCommand(); | ||
new TestGetAllSkillsCommand(); | ||
new TestSetSkillCommand(); | ||
new TestHasSkillCommand(); | ||
new ExampleCommand(); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
CommandAPI.onDisable(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/io/github/Alathra/AlathraSkills/command/ExampleCommand.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,25 @@ | ||
package io.github.alathra.alathraskills.command; | ||
|
||
import com.github.milkdrinkers.colorparser.ColorParser; | ||
import dev.jorel.commandapi.CommandAPICommand; | ||
import dev.jorel.commandapi.executors.CommandArguments; | ||
import org.bukkit.command.CommandSender; | ||
|
||
public class ExampleCommand { | ||
public ExampleCommand() { | ||
new CommandAPICommand("example") | ||
.withFullDescription("Example command.") | ||
.withShortDescription("Example command.") | ||
.withPermission("example.command") | ||
.executes(this::example) | ||
.register(); | ||
} | ||
|
||
private void example(CommandSender sender, CommandArguments args) { | ||
sender.sendMessage( | ||
ColorParser.of("<white>Read more about CommandAPI &9<click:open_url:https://commandapi.jorel.dev/9.0.3/>here</click><white>.") | ||
.parseLegacy() // Parse legacy color codes | ||
.build() | ||
); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/io/github/Alathra/AlathraSkills/config/ConfigHandler.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,47 @@ | ||
package io.github.alathra.alathraskills.config; | ||
|
||
import io.github.alathra.alathraskills.AlathraSkills; | ||
import io.github.alathra.alathraskills.Reloadable; | ||
import com.github.milkdrinkers.Crate.Config; | ||
|
||
import javax.inject.Singleton; | ||
|
||
/** | ||
* A class that generates/loads & provides access to a configuration file. | ||
*/ | ||
@Singleton | ||
public class ConfigHandler implements Reloadable { | ||
private final AlathraSkills plugin; | ||
private Config cfg; | ||
|
||
/** | ||
* Instantiates a new Config handler. | ||
* | ||
* @param plugin the plugin instance | ||
*/ | ||
public ConfigHandler(AlathraSkills plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void onLoad() { | ||
cfg = new Config("config", plugin.getDataFolder().getPath(), plugin.getResource("config.yml")); // Create a config file from the template in our resources folder | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
} | ||
|
||
/** | ||
* Gets examplePlugin config object. | ||
* | ||
* @return the examplePlugin config object | ||
*/ | ||
public Config getConfig() { | ||
return cfg; | ||
} | ||
} |
Oops, something went wrong.