Skip to content

Commit

Permalink
Update Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ZockerAxel committed Dec 5, 2021
1 parent 14bbb0f commit 7cd6d38
Show file tree
Hide file tree
Showing 24 changed files with 340 additions and 49 deletions.
14 changes: 14 additions & 0 deletions src/eu/endercentral/crazy_advancements/CrazyAdvancementsAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,19 @@
import net.minecraft.network.protocol.game.PacketPlayOutSelectAdvancementTab;
import net.minecraft.resources.MinecraftKey;

/**
* Represents the API's Plugin
*
* @author Axel
*
*/
public class CrazyAdvancementsAPI extends JavaPlugin implements Listener {

private static CrazyAdvancementsAPI instance;

/**
* Criterion Instance for Internal Use
*/
public static final Criterion CRITERION = new Criterion(new CriterionInstance() {
@Override
public JsonObject a(LootSerializationContext arg0) {
Expand Down Expand Up @@ -81,6 +90,11 @@ public void onDisable() {
}
}

/**
* Gets the Instance
*
* @return The Instance
*/
public static CrazyAdvancementsAPI getInstance() {
return instance;
}
Expand Down
13 changes: 11 additions & 2 deletions src/eu/endercentral/crazy_advancements/JSONMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,36 @@
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.chat.IChatBaseComponent.ChatSerializer;

/**
* Represents a Message in JSON Format
*
* @author Axel
*
*/
public class JSONMessage {

private final BaseComponent json;

/**
* Constructor for creating a JSON Message
*
* @param json A JSON representation of an ingame Message {@link <a href="https://github.com/skylinerw/guides/blob/master/java/text%20component.md">Read More</a>}
* @param json A JSON representation of an ingame Message <a href="https://www.spigotmc.org/wiki/the-chat-component-api/">Read More</a>
*/
public JSONMessage(BaseComponent json) {
this.json = json;
}

/**
* Gets the Message as a BaseComponent
*
* @return the JSON representation of an ingame Message
* @return the BaseComponent of an ingame Message
*/
public BaseComponent getJson() {
return json;
}

/**
* Gets an NMS representation of an ingame Message
*
* @return An {@link IChatBaseComponent} representation of an ingame Message
*/
Expand Down
14 changes: 12 additions & 2 deletions src/eu/endercentral/crazy_advancements/NameKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

import net.minecraft.resources.MinecraftKey;

/**
* Represents a Unique Name
*
* @author Axel
*
*/
public class NameKey {

private final String namespace;
Expand All @@ -10,8 +16,9 @@ public class NameKey {
private transient MinecraftKey mcKey;

/**
* Constructor for creating a NameKey
*
* @param namespace The namespace, choose something representing your plugin/project
* @param namespace The namespace, choose something representing your plugin/project/subproject
* @param key The Unique key inside your namespace
*/
public NameKey(String namespace, String key) {
Expand All @@ -20,6 +27,7 @@ public NameKey(String namespace, String key) {
}

/**
* Constructor for creating a NameKey
*
* @param key The key inside the default namespace "minecraft" or a NameSpacedKey seperated by a colon
*/
Expand All @@ -37,14 +45,15 @@ public NameKey(String key) {
/**
* Generates a {@link NameKey}
*
* @param from
* @param from The MinecraftKey to generate from
*/
public NameKey(MinecraftKey from) {
this.namespace = from.b().toLowerCase();
this.key = from.a().toLowerCase();
}

/**
* Gets the namespace
*
* @return The namespace
*/
Expand All @@ -53,6 +62,7 @@ public String getNamespace() {
}

/**
* Gets the key
*
* @return The key
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
import net.md_5.bungee.api.chat.TranslatableComponent;
import net.md_5.bungee.api.chat.hover.content.Text;

/**
* Represents an Advancement
*
* @author Axel
*
*/
public class Advancement {

private final NameKey name;
Expand Down Expand Up @@ -330,10 +336,10 @@ public AdvancementProgress getProgress(Player player) {
}

/**
* Gets a player's progress
* Gets a Player's progress
*
* @param uuid The uuid of the player to check
* @return
* @return The Player's progress
*/
public AdvancementProgress getProgress(UUID uuid) {
if(!progressMap.containsKey(uuid.toString())) {
Expand Down Expand Up @@ -416,6 +422,7 @@ public boolean getVisibilityStatus(Player player) {
/**
* Gets a Toast Notification for this Advancement
*
* @return The Toast Notification
*/
public ToastNotification getToastNotification() {
ToastNotification notification = new ToastNotification(getDisplay().getIcon(), getDisplay().getTitle(), getDisplay().getFrame());
Expand All @@ -436,7 +443,7 @@ public void displayToast(Player player) {
* Gets an Advancement Message
*
* @param player Player who has recieved the advancement
* @return
* @return The Advancement Message as a Base Component
*/
public BaseComponent getMessage(Player player) {
String translation = "chat.type.advancement." + display.getFrame().name().toLowerCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.advancements.AdvancementFrameType;

/**
* Represents the Display Information of an Advancement
*
* @author Axel
*
*/
public class AdvancementDisplay {

private ItemStack icon;
Expand All @@ -28,8 +34,6 @@ public class AdvancementDisplay {
* @param title Title {@link JSONMessage}
* @param description Description {@link JSONMessage}
* @param frame {@link AdvancementFrame}
* @param showToast Should toast messages be shown
* @param announceChat Should advancements be announced in chat
* @param visibility When an advancement is visible
*/
public AdvancementDisplay(Material icon, JSONMessage title, JSONMessage description, AdvancementFrame frame, AdvancementVisibility visibility) {
Expand All @@ -46,8 +50,6 @@ public AdvancementDisplay(Material icon, JSONMessage title, JSONMessage descript
* @param title Title {@link String}
* @param description Description {@link String}
* @param frame {@link AdvancementFrame}
* @param showToast Should toast messages be shown
* @param announceChat Should advancements be announced in chat
* @param visibility When an advancement is visible
*/
public AdvancementDisplay(Material icon, String title, String description, AdvancementFrame frame, AdvancementVisibility visibility) {
Expand All @@ -66,8 +68,6 @@ public AdvancementDisplay(Material icon, String title, String description, Advan
* @param description Description {@link JSONMessage}
* @param frame {@link AdvancementFrame}
* @param backgroundTexture Background texture path
* @param showToast Should toast messages be shown
* @param announceChat Should advancements be announced in chat
* @param visibility When an advancement is visible
*/
public AdvancementDisplay(Material icon, JSONMessage title, JSONMessage description, AdvancementFrame frame, String backgroundTexture, AdvancementVisibility visibility) {
Expand All @@ -86,8 +86,6 @@ public AdvancementDisplay(Material icon, JSONMessage title, JSONMessage descript
* @param description Description {@link String}
* @param frame {@link AdvancementFrame}
* @param backgroundTexture Background texture path
* @param showToast Should toast messages be shown
* @param announceChat Should advancements be announced in chat
* @param visibility When an advancement is visible
*/
public AdvancementDisplay(Material icon, String title, String description, AdvancementFrame frame, String backgroundTexture, AdvancementVisibility visibility) {
Expand All @@ -108,8 +106,6 @@ public AdvancementDisplay(Material icon, String title, String description, Advan
* @param title Title {@link JSONMessage}
* @param description Description {@link JSONMessage}
* @param frame {@link AdvancementFrame}
* @param showToast Should toast messages be shown
* @param announceChat Should advancements be announced in chat
* @param visibility When an advancement is visible
*/
public AdvancementDisplay(ItemStack icon, JSONMessage title, JSONMessage description, AdvancementFrame frame, AdvancementVisibility visibility) {
Expand All @@ -126,8 +122,6 @@ public AdvancementDisplay(ItemStack icon, JSONMessage title, JSONMessage descrip
* @param title Title {@link String}
* @param description Description {@link String}
* @param frame {@link AdvancementFrame}
* @param showToast Should toast messages be shown
* @param announceChat Should advancements be announced in chat
* @param visibility When an advancement is visible
*/
public AdvancementDisplay(ItemStack icon, String title, String description, AdvancementFrame frame, AdvancementVisibility visibility) {
Expand All @@ -146,8 +140,6 @@ public AdvancementDisplay(ItemStack icon, String title, String description, Adva
* @param description Description {@link JSONMessage}
* @param frame {@link AdvancementFrame}
* @param backgroundTexture Background texture path
* @param showToast Should toast messages be shown
* @param announceChat Should advancements be announced in chat
* @param visibility When an advancement is visible
*/
public AdvancementDisplay(ItemStack icon, JSONMessage title, JSONMessage description, AdvancementFrame frame, String backgroundTexture, AdvancementVisibility visibility) {
Expand All @@ -166,8 +158,6 @@ public AdvancementDisplay(ItemStack icon, JSONMessage title, JSONMessage descrip
* @param description Description {@link String}
* @param frame {@link AdvancementFrame}
* @param backgroundTexture Background texture path
* @param showToast Should toast messages be shown
* @param announceChat Should advancements be announced in chat
* @param visibility When an advancement is visible
*/
public AdvancementDisplay(ItemStack icon, String title, String description, AdvancementFrame frame, String backgroundTexture, AdvancementVisibility visibility) {
Expand All @@ -180,10 +170,25 @@ public AdvancementDisplay(ItemStack icon, String title, String description, Adva
setVisibility(visibility);
}

/**
* Represents the Frame of an Advancement
*
* @author Axel
*
*/
public static enum AdvancementFrame {

/**
* A Task has the default Frame and defaults to a green Color in Completion Messages
*/
TASK(AdvancementFrameType.a),
/**
* A Goal has a rounded off Frame and defaults to a green Color in Completion Messages
*/
GOAL(AdvancementFrameType.b),
/**
* A Challenge has a differently shaped Frame and defaults to a purple Color in Completion Messages and it's Toast plays a Sound when displayed
*/
CHALLENGE(AdvancementFrameType.c)
;

Expand All @@ -193,6 +198,11 @@ private AdvancementFrame(AdvancementFrameType nms) {
this.nms = nms;
}

/**
* Get the NMS Representation of this AdvancementFrame
*
* @return THE NMS Representation
*/
public AdvancementFrameType getNMS() {
return nms;
}
Expand Down Expand Up @@ -365,7 +375,7 @@ public void setTitle(String title) {
/**
* Changes the Description
*
* @param title New title {@link JSONMessage}
* @param description New description {@link JSONMessage}
*/
public void setDescription(JSONMessage description) {
this.description = description;
Expand All @@ -374,7 +384,7 @@ public void setDescription(JSONMessage description) {
/**
* Changes the Description
*
* @param title New Title {@link String}
* @param description New Description {@link String}
*/
public void setDescription(String description) {
this.description = new JSONMessage(new TextComponent(description));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
package eu.endercentral.crazy_advancements.advancement;

/**
* Alters the behavior of Advancements
*
* @author Axel
*
*/
public enum AdvancementFlag {

/**
* Advancements with this Flag will display a Toast upon Completion
*/
SHOW_TOAST,
/**
* Advancements with this Flag will broadcast a Message in Chat upon Completion
*/
DISPLAY_MESSAGE,
/**
* Advancements with this Flag will be sent with the hidden boolean set to true allowing the creation of empty Advancement Tabs or to draw lines
*/
SEND_WITH_HIDDEN_BOOLEAN,

;

/**
* Shorthand for combining Toast Notifications and Chat Messages
*/
public static final AdvancementFlag[] TOAST_AND_MESSAGE = new AdvancementFlag[] {SHOW_TOAST, DISPLAY_MESSAGE};

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@

import org.bukkit.entity.Player;

/**
* Represents a Reward that is awarded upon Completion of an Advancement
*
* @author Axel
*
*/
public abstract class AdvancementReward {

/**
* Gives the Reward
*
* @param player The Receiver
*/
public abstract void onGrant(Player player);

}
Loading

0 comments on commit 7cd6d38

Please sign in to comment.