Skip to content

Commit

Permalink
bump vital api
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Jul 23, 2024
1 parent e4f02d3 commit f2c3101
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 29 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ dependencies {

implementation(libs.nbtapi)

compileOnly(libs.headdatabaseapi)

compileOnly(libs.placeholderapi)

compileOnly(libs.itemsadder)
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ triumph-cmd = "2.0.0-ALPHA-10"
tirumph-gui = "3.1.7"
jetbrains = "24.1.0"
kyori = "4.17.0"
vital = "1.9.8"
vital = "2.0.1"

# Plugins
itemsadder = "3.6.3-beta-14"
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/com/badbones69/crazyvouchers/CrazyVouchers.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,30 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.badbones69.crazyvouchers.config.types.ConfigKeys;
import java.util.Locale;

public class CrazyVouchers extends JavaPlugin {

public @NotNull static CrazyVouchers get() {
return JavaPlugin.getPlugin(CrazyVouchers.class);
}

private final long startTime;

public CrazyVouchers() {
this.startTime = System.nanoTime();
}

private InventoryManager inventoryManager;

private CrazyManager crazyManager;
private FileManager fileManager;

private HeadDatabaseAPI api;

private Server instance;

@Override
public void onEnable() {
this.instance = new Server(getDataFolder(), getComponentLogger());
Server server = new Server(this);

boolean loadOldWay = ConfigManager.getConfig().getProperty(ConfigKeys.mono_file);

Expand Down Expand Up @@ -90,6 +95,10 @@ public void onEnable() {
pluginManager.registerEvents(new VoucherMenu(), this);

registerCommand(getCommand("vouchers"), new VoucherTab(), new VoucherCommands());

if (server.isLogging()) {
getComponentLogger().info("Done ({})!", String.format(Locale.ROOT, "%.3fs", (double) (System.nanoTime() - this.startTime) / 1.0E9D));
}
}

private void registerCommand(PluginCommand pluginCommand, TabCompleter tabCompleter, CommandExecutor commandExecutor) {
Expand Down Expand Up @@ -119,8 +128,4 @@ private void registerCommand(PluginCommand pluginCommand, TabCompleter tabComple
public @NotNull final FileManager getFileManager() {
return this.fileManager;
}

public @NotNull final Server getInstance() {
return this.instance;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Sound;
import org.bukkit.configuration.file.FileConfiguration;
Expand Down Expand Up @@ -65,6 +66,26 @@ public class Voucher {

private String requiredPlaceholdersMessage;

public Voucher(int number) {
this.name = number + "";
this.usesArgs = false;
this.itemBuilder = new ItemBuilder().setMaterial(Material.STONE).setName(number + "");
this.usedMessage = "";
this.whitelistPermissionToggle = false;
this.whitelistPermissionMessage = "";
this.whitelistWorldsToggle = false;
this.whitelistWorldMessage = "";
this.blacklistPermissionsToggle = false;
this.blacklistPermissionMessage = "blacklistPermissionMessage";
this.limiterToggle = false;
this.limiterLimit = 0;
this.twoStepAuthentication = false;
this.soundToggle = false;
this.fireworkToggle = false;
this.isEdible = false;
this.glowing = false;
}

public Voucher(FileConfiguration fileConfiguration, String name) {
this.name = name;
this.usesArgs = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,41 @@
import com.badbones69.crazyvouchers.config.types.ConfigKeys;
import com.ryderbelserion.vital.core.Vital;
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.io.File;

public class Server extends Vital {

private final File directory;
private final JavaPlugin plugin;
private final File dataFolder;
private final ComponentLogger logger;

public Server(@NotNull final File directory, @NotNull final ComponentLogger logger) {
this.directory = directory;
this.logger = logger;
public Server(final JavaPlugin plugin) {
this.dataFolder = plugin.getDataFolder();
this.logger = plugin.getComponentLogger();
this.plugin = plugin;

ConfigManager.load(this.directory);
ConfigManager.load(this.dataFolder);
}

/**
* Reloads the plugin.
*/
public void reload() {
ConfigManager.refresh();
}

/**
* @return the plugin directory
*/
@Override
public @NotNull final File getDirectory() {
return this.directory;
return this.dataFolder;
}

/**
* @return the plugin logger
*/
@Override
public @NotNull final ComponentLogger getLogger() {
return this.logger;
}

@Override
public boolean isLogging() {
public void saveResource(String resourceName, boolean replaceExisting) {
this.plugin.saveResource(resourceName, replaceExisting);
}

@Override
public final boolean isLogging() {
return ConfigManager.getConfig().getProperty(ConfigKeys.verbose_logging);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N

case "reload" -> {
if (Methods.hasPermission(sender, "admin")) {
this.plugin.getInstance().reload();
ConfigManager.refresh();

this.fileManager.reloadFiles().init();

Expand Down

0 comments on commit f2c3101

Please sign in to comment.