-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Merge branch 'develop' - Test github build
- Loading branch information
Showing
148 changed files
with
8,331 additions
and
32 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: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
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: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew buildAll | ||
|
||
# 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 | ||
run: ./gradlew 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
79 changes: 79 additions & 0 deletions
79
Essentials/src/main/java/fr/maxlego08/essentials/MainConfiguration.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,79 @@ | ||
package fr.maxlego08.essentials; | ||
|
||
import fr.maxlego08.essentials.api.Configuration; | ||
import fr.maxlego08.essentials.api.commands.CommandCooldown; | ||
import fr.maxlego08.essentials.api.storage.DatabaseConfiguration; | ||
import fr.maxlego08.essentials.api.storage.StorageType; | ||
import fr.maxlego08.essentials.api.utils.CompactMaterial; | ||
import fr.maxlego08.essentials.zutils.utils.YamlLoader; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
import org.bukkit.permissions.Permissible; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class MainConfiguration extends YamlLoader implements Configuration { | ||
|
||
private final ZEssentialsPlugin plugin; | ||
private final List<CommandCooldown> commandCooldowns = new ArrayList<>(); | ||
private final List<CompactMaterial> compactMaterials = new ArrayList<>(); | ||
private final StorageType storageType = StorageType.JSON; | ||
private boolean enableDebug; | ||
private boolean enableCooldownBypass; | ||
private int trashSize; | ||
private DatabaseConfiguration databaseConfiguration; | ||
|
||
public MainConfiguration(ZEssentialsPlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean isEnableDebug() { | ||
return this.enableDebug; | ||
} | ||
|
||
@Override | ||
public boolean isEnableCooldownBypass() { | ||
return this.enableCooldownBypass; | ||
} | ||
|
||
@Override | ||
public List<CommandCooldown> getCommandCooldown() { | ||
return this.commandCooldowns; | ||
} | ||
|
||
@Override | ||
public Optional<Integer> getCooldown(Permissible permissible, String command) { | ||
return this.commandCooldowns.stream().filter(e -> e.command().equalsIgnoreCase(command)).map(commandCooldown -> commandCooldown.permissions().stream().filter(e -> permissible.hasPermission((String) e.get("permission"))).mapToInt(e -> ((Number) e.get("cooldown")).intValue()).min().orElse(commandCooldown.cooldown())).findFirst(); | ||
} | ||
|
||
@Override | ||
public void load() { | ||
|
||
this.plugin.reloadConfig(); | ||
|
||
YamlConfiguration configuration = (YamlConfiguration) this.plugin.getConfig(); | ||
this.loadYamlConfirmation(configuration); | ||
} | ||
|
||
@Override | ||
public int getTrashSize() { | ||
return this.trashSize; | ||
} | ||
|
||
@Override | ||
public List<CompactMaterial> getCompactMaterials() { | ||
return this.compactMaterials; | ||
} | ||
|
||
@Override | ||
public StorageType getStorageType() { | ||
return this.storageType; | ||
} | ||
|
||
@Override | ||
public DatabaseConfiguration getDatabaseConfiguration() { | ||
return this.databaseConfiguration; | ||
} | ||
} |
223 changes: 223 additions & 0 deletions
223
Essentials/src/main/java/fr/maxlego08/essentials/ZEssentialsPlugin.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,223 @@ | ||
package fr.maxlego08.essentials; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import com.tcoded.folialib.FoliaLib; | ||
import com.tcoded.folialib.impl.ServerImplementation; | ||
import fr.maxlego08.essentials.api.Configuration; | ||
import fr.maxlego08.essentials.api.ConfigurationFile; | ||
import fr.maxlego08.essentials.api.EssentialsPlugin; | ||
import fr.maxlego08.essentials.api.commands.CommandManager; | ||
import fr.maxlego08.essentials.api.database.MigrationManager; | ||
import fr.maxlego08.essentials.api.economy.EconomyProvider; | ||
import fr.maxlego08.essentials.api.modules.ModuleManager; | ||
import fr.maxlego08.essentials.api.placeholders.Placeholder; | ||
import fr.maxlego08.essentials.api.placeholders.PlaceholderRegister; | ||
import fr.maxlego08.essentials.api.storage.Persist; | ||
import fr.maxlego08.essentials.api.storage.StorageManager; | ||
import fr.maxlego08.essentials.api.storage.adapter.LocationAdapter; | ||
import fr.maxlego08.essentials.api.user.User; | ||
import fr.maxlego08.essentials.buttons.ButtonTeleportationConfirm; | ||
import fr.maxlego08.essentials.commands.CommandLoader; | ||
import fr.maxlego08.essentials.commands.ZCommandManager; | ||
import fr.maxlego08.essentials.commands.commands.essentials.CommandEssentials; | ||
import fr.maxlego08.essentials.database.ZMigrationManager; | ||
import fr.maxlego08.essentials.economy.EconomyManager; | ||
import fr.maxlego08.essentials.hooks.VaultEconomy; | ||
import fr.maxlego08.essentials.listener.PlayerListener; | ||
import fr.maxlego08.essentials.messages.MessageLoader; | ||
import fr.maxlego08.essentials.module.ZModuleManager; | ||
import fr.maxlego08.essentials.placeholders.DistantPlaceholder; | ||
import fr.maxlego08.essentials.placeholders.LocalPlaceholder; | ||
import fr.maxlego08.essentials.storage.ZStorageManager; | ||
import fr.maxlego08.essentials.storage.adapter.UserTypeAdapter; | ||
import fr.maxlego08.essentials.user.UserPlaceholders; | ||
import fr.maxlego08.essentials.user.ZUser; | ||
import fr.maxlego08.essentials.zutils.ZPlugin; | ||
import fr.maxlego08.menu.api.ButtonManager; | ||
import fr.maxlego08.menu.api.InventoryManager; | ||
import fr.maxlego08.menu.api.pattern.PatternManager; | ||
import fr.maxlego08.menu.button.loader.NoneLoader; | ||
import org.bukkit.Location; | ||
|
||
import java.lang.reflect.Modifier; | ||
import java.util.List; | ||
|
||
public final class ZEssentialsPlugin extends ZPlugin implements EssentialsPlugin { | ||
|
||
private InventoryManager inventoryManager; | ||
private ButtonManager buttonManager; | ||
private PatternManager patternManager; | ||
|
||
@Override | ||
public void onEnable() { | ||
|
||
this.saveDefaultConfig(); | ||
|
||
FoliaLib foliaLib = new FoliaLib(this); | ||
this.serverImplementation = foliaLib.getImpl(); | ||
|
||
this.migrationManager = new ZMigrationManager(this); | ||
this.migrationManager.registerMigration(); | ||
|
||
this.placeholder = new LocalPlaceholder(this); | ||
DistantPlaceholder distantPlaceholder = new DistantPlaceholder(this, this.placeholder); | ||
distantPlaceholder.register(); | ||
|
||
this.economyProvider = new EconomyManager(this); | ||
|
||
this.inventoryManager = this.getProvider(InventoryManager.class); | ||
this.buttonManager = this.getProvider(ButtonManager.class); | ||
this.patternManager = this.getProvider(PatternManager.class); | ||
this.registerButtons(); | ||
|
||
this.moduleManager = new ZModuleManager(this); | ||
|
||
this.gson = getGsonBuilder().create(); | ||
this.persist = new Persist(this); | ||
|
||
// Configurations files | ||
this.registerConfiguration(new MessageLoader(this)); | ||
this.registerConfiguration(this.configuration = new MainConfiguration(this)); | ||
|
||
// Load configuration files | ||
this.configurationFiles.forEach(ConfigurationFile::load); | ||
|
||
// Commands | ||
this.commandManager = new ZCommandManager(this); | ||
this.registerCommand("zessentials", new CommandEssentials(this), "ess"); | ||
|
||
CommandLoader commandLoader = new CommandLoader(this); | ||
commandLoader.loadCommands(this.commandManager); | ||
|
||
this.getLogger().info("Create " + this.commandManager.countCommands() + " commands."); | ||
|
||
// Storage | ||
this.storageManager = new ZStorageManager(this); | ||
this.registerListener(this.storageManager); | ||
this.storageManager.onEnable(); | ||
|
||
this.moduleManager.loadModules(); | ||
|
||
this.registerListener(new PlayerListener(this)); | ||
this.registerPlaceholder(UserPlaceholders.class); | ||
} | ||
|
||
@Override | ||
public void onLoad() { | ||
|
||
try { | ||
Class.forName("net.milkbowl.vault.economy.Economy"); | ||
new VaultEconomy(this); | ||
getLogger().info("Register Vault Economy."); | ||
} catch (final ClassNotFoundException ignored) { | ||
ignored.printStackTrace(); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
|
||
// Storage | ||
if (this.storageManager != null) this.storageManager.onDisable(); | ||
} | ||
|
||
private void registerButtons() { | ||
|
||
this.buttonManager.register(new NoneLoader(this, ButtonTeleportationConfirm.class, "essentials_teleportation_confirm")); | ||
|
||
} | ||
|
||
@Override | ||
public CommandManager getCommandManager() { | ||
return this.commandManager; | ||
} | ||
|
||
@Override | ||
public List<ConfigurationFile> getConfigurationFiles() { | ||
return this.configurationFiles; | ||
} | ||
|
||
@Override | ||
public Gson getGson() { | ||
return this.gson; | ||
} | ||
|
||
@Override | ||
public Persist getPersist() { | ||
return this.persist; | ||
} | ||
|
||
@Override | ||
public ServerImplementation getScheduler() { | ||
return this.serverImplementation; | ||
} | ||
|
||
@Override | ||
public ModuleManager getModuleManager() { | ||
return this.moduleManager; | ||
} | ||
|
||
@Override | ||
public InventoryManager getInventoryManager() { | ||
return this.inventoryManager; | ||
} | ||
|
||
@Override | ||
public ButtonManager getButtonManager() { | ||
return this.buttonManager; | ||
} | ||
|
||
@Override | ||
public PatternManager getPatternManager() { | ||
return this.patternManager; | ||
} | ||
|
||
@Override | ||
public Placeholder getPlaceholder() { | ||
return this.placeholder; | ||
} | ||
|
||
@Override | ||
public StorageManager getStorageManager() { | ||
return this.storageManager; | ||
} | ||
|
||
private GsonBuilder getGsonBuilder() { | ||
return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().serializeNulls() | ||
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE) | ||
.registerTypeAdapter(Location.class, new LocationAdapter(this)) | ||
.registerTypeAdapter(User.class, new UserTypeAdapter(this)) | ||
.registerTypeAdapter(ZUser.class, new UserTypeAdapter(this)); | ||
} | ||
|
||
private void registerPlaceholder(Class<? extends PlaceholderRegister> placeholderClass) { | ||
try { | ||
PlaceholderRegister placeholderRegister = placeholderClass.getConstructor().newInstance(); | ||
placeholderRegister.register(this.placeholder, this); | ||
} catch (Exception exception) { | ||
exception.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public Configuration getConfiguration() { | ||
return this.configuration; | ||
} | ||
|
||
@Override | ||
public MigrationManager getMigrationManager() { | ||
return this.migrationManager; | ||
} | ||
|
||
@Override | ||
public boolean isEconomyEnable() { | ||
return this.economyProvider.isEnable(); | ||
} | ||
|
||
@Override | ||
public EconomyProvider getEconomyProvider() { | ||
return this.economyProvider; | ||
} | ||
} |
Oops, something went wrong.