Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add current api changes #795

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 0 additions & 114 deletions .github/ISSUE_TEMPLATE/bugs.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/ISSUE_TEMPLATE/features.yml

This file was deleted.

8 changes: 6 additions & 2 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ plugins {
}

project.group = "us.crazycrew.crazycrates"
project.version = "0.8"
project.version = "0.9"

repositories {
maven("https://repo.papermc.io/repository/maven-public")
}

dependencies {
compileOnly(libs.paper)
compileOnly(libs.bundles.adventure)

compileOnly(libs.vital.common)

compileOnly(libs.jetbrains)
}

val javaComponent: SoftwareComponent = components["java"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public class CratesProvider {
/**
* @return {@link IServer}
* @since 0.4
*
* @deprecated Use {@link CrazyCratesProvider#get()} from now on.
*/
@Deprecated(forRemoval = true, since = "0.9")
public static IServer get() {
if (instance == null) {
throw new IllegalStateException("CrazyCrates API is not loaded.");
Expand Down
79 changes: 79 additions & 0 deletions api/src/main/java/us/crazycrew/crazycrates/CrazyCratesApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package us.crazycrew.crazycrates;

import net.kyori.adventure.audience.Audience;
import org.jetbrains.annotations.NotNull;
import us.crazycrew.crazycrates.api.users.UserManager;
import us.crazycrew.crazycrates.platform.ISettings;
import java.io.File;
import java.util.List;
import java.util.Map;

/**
* CrazyCrates' API
*
* @author ryderbelserion
* @version 0.9
* @since 0.9
*/
public interface CrazyCratesApi {

/**
* Reloads the plugin
*
* @since 0.9
*/
void reload();

/**
* Gets the crates folder
*
* @return {@link File}
* @since 0.9
*/
@NotNull File getCrateFolder();

/**
* Gets the plugin/mods folder
*
* @return {@link File}
* @since 0.9
*/
@NotNull File getDataFolder();

/**
* Gets a list of crate files
*
* @return {@link List<String>}
* @since 0.9
*/
@NotNull List<String> getCrateFiles();

/**
* Gets the instance of the user manager
*
* @return {@link UserManager}
* @since 0.9
*/
@NotNull UserManager getUserManager();

/**
* Gets a current amount of settings
*
* @return {@link ISettings}
* @since 0.9
*/
@NotNull ISettings getSettings();

/**
* Parses a string, based on the sender, line, and placeholders
*
* @param audience {@link Audience}
* @param line {@link String}
* @param placeholders {@link Map} of placeholders
*
* @return {@link String}
* @since 0.9
*/
@NotNull String parse(Audience audience, String line, Map<String, String> placeholders);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package us.crazycrew.crazycrates;

import com.ryderbelserion.vital.common.util.StringUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import java.util.List;

public final class CrazyCratesProvider {

private static CrazyCratesApi instance = null;

public static @NotNull CrazyCratesApi get() {
CrazyCratesApi instance = CrazyCratesProvider.instance;

if (instance == null) {
throw new UnavailableException();
}

return instance;
}

@ApiStatus.Internal
public static void register(CrazyCratesApi instance) {
CrazyCratesProvider.instance = instance;
}

@ApiStatus.Internal
public static void unregister() {
CrazyCratesProvider.instance = null;
}

private static final class UnavailableException extends IllegalStateException {

private static final List<String> message = List.of(
"The CrazyCrates API isn't loaded yet.",
"",
"A list of potential reasons:",
" 1) CrazyCrates plugin did not enable, or is not installed.",
" 2) The plugin using CrazyCrates does not include it as a softdepend.",
" 3) The plugin is trying to use the api before the api enables."
);

UnavailableException() {
super(StringUtil.convertList(message));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package us.crazycrew.crazycrates.api.users.objects;

import net.kyori.adventure.text.Component;
import java.util.Locale;
import java.util.UUID;

public interface User {

Component getDisplayName();

Locale getLocale();

String getName();

UUID getUUID();

}
17 changes: 16 additions & 1 deletion api/src/main/java/us/crazycrew/crazycrates/platform/IServer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package us.crazycrew.crazycrates.platform;

import org.jetbrains.annotations.NotNull;
import us.crazycrew.crazycrates.CrazyCratesProvider;
import us.crazycrew.crazycrates.api.users.UserManager;
import java.io.File;
import java.util.List;
Expand All @@ -11,40 +12,54 @@
* @author Ryder Belserion
* @version 0.7
* @since 0.5
*
* @deprecated Use {@link CrazyCratesProvider#get()} from now on.
*/
@Deprecated(forRemoval = true, since = "0.9")
public interface IServer {

/**
* Reloads the plugin
*
* @since 0.5
*/
void reload();

/**
* Gets the crates folder
*
* @return {@link File}
* @since 0.5
*/
@NotNull File getCrateFolder();

/**
* Gets the plugin/mods folder
*
* @return {@link File}
* @since 0.8
*/
@NotNull File getDataFolder();

/**
* Gets a list of crate files
*
* @return {@link List<String>}
* @since 0.5
*/
List<String> getCrateFiles();
@NotNull List<String> getCrateFiles();

/**
* Gets the instance of the user manager
*
* @return {@link UserManager}
* @since 0.5
*/
@NotNull UserManager getUserManager();

/**
* Gets a current amount of settings
*
* @return {@link ISettings}
* @since 0.5
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public interface ISettings {
boolean isVirtualAcceptsPhysical();

/**
* Gets a list of worlds crates are disabled in
*
* @return a list of worlds crates are disabled in
* @since 0.5
*/
Expand Down
Loading