Skip to content

Commit

Permalink
javadoc update
Browse files Browse the repository at this point in the history
  • Loading branch information
poyrazinan committed Jun 20, 2023
1 parent 35086c6 commit 3672337
Show file tree
Hide file tree
Showing 49 changed files with 352 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-javadoc-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
javadoc-branch: javadoc
java-version: 17
java-version: 1.8
target-folder: javadoc # url will be https://<username>.github.io/<repo>/javadoc, This can be left as nothing to generate javadocs in the root folder.
project: maven # or gradle
# subdirectories: moduleA moduleB #for subdirectories support, needs to be run with custom command
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Use this section to tell people about which versions of your project are
currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
|---------|--------------------|
| v6 | :white_check_mark: |
| < v5 | :x: |

Expand Down
70 changes: 41 additions & 29 deletions src/main/java/xyz/geik/farmer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;

/**
* Main class of farmer
Expand All @@ -38,7 +37,9 @@
@Getter
public class Main extends JavaPlugin {

// Register module to this class
/**
* Listener list of modules
*/
public Map<FarmerModule, Listener> listenerList = new HashMap<>();

/**
Expand Down Expand Up @@ -102,7 +103,6 @@ public void onEnable() {
/**
* disable method calls from spigot api.
* executing it right before close.
*
* async tasks can be fail because server
* can't handle async tasks while shutting down
*/
Expand All @@ -111,49 +111,69 @@ public void onDisable() {
}

/**
* Getter for files, instance, integration, farmers, economy.
* Gets config file
* @return Config file
*/
public static Config getConfigFile() { return configFile; }

/**
* Gets items file
* @return Config file
*/
public static Config getItemsFile() { return itemsFile; }

/**
* Gets lang file
* @return Config file
*/
public static Config getLangFile() { return langFile; }

/**
* Gets instance
* @return Main class of main
*/
public static Main getInstance() { return instance; }

/**
* Gets Integration plugin instance
* @return Integrations plugin of integration
*/
public static Integrations getIntegration() { return integration; }

/**
* Gets items file
* @return Economy gets economy plugin
*/
public static Economy getEcon() { return econ; }

/**
* Integration setter
*
* @param data
* @param data data of integration
*/
public static void setIntegration(Integrations data) {
integration = data;
}

/**
* Basic color translate method which changing '&' to '§'
*
* Because minecraft using '§' for color example: '§a Hello World!'
* But it's hard to write so traditionally everyone using '&' for
* color codes. This method converting '&' to '§'.
* @param text
* @return
* Basic color translate method which changes minecraft color code to known one
* @param text String of message
* @return String of replaced text
*/
public static @NotNull String color(String text) {
return ChatColor.translateAlternateColorCodes('&', text);
}

/**
* Setup economy by Vault.
* @return
*/
private boolean setupEconomy() {
private void setupEconomy() {
if (Main.instance.getServer().getPluginManager().getPlugin("Vault") == null)
return false;
return;
RegisteredServiceProvider<Economy> rsp = Main.instance.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null)
return false;
return;
econ = rsp.getProvider();
return econ != null;
}

/**
Expand All @@ -171,18 +191,10 @@ private static void sendEnableMessage() {
*/
private void loadMetrics() {
Metrics metrics = new Metrics(Main.instance, 9646);
metrics.addCustomChart(new Metrics.SingleLineChart("ciftci_sayisi", new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return FarmerManager.getFarmers().size();
}
}));
metrics.addCustomChart(new Metrics.SimplePie("api_eklentisi", new Callable<String>() {
@Override
public String call() {
String[] data = getIntegration().getClass().getName().split(".");
return data[data.length-1];
}
metrics.addCustomChart(new Metrics.SingleLineChart("ciftci_sayisi", () -> FarmerManager.getFarmers().size()));
metrics.addCustomChart(new Metrics.SimplePie("api_eklentisi", () -> {
String[] data = getIntegration().getClass().getName().split(".");
return data[data.length-1];
}));
}

Expand Down
42 changes: 42 additions & 0 deletions src/main/java/xyz/geik/farmer/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

/**
* Metrics class which created by BStats
* @author BStats
*/
public class Metrics {

private final Plugin plugin;
Expand Down Expand Up @@ -135,6 +139,9 @@ private int getPlayerAmount() {
}
}

/**
*
*/
public static class MetricsBase {

/** The version of the Metrics class. */
Expand Down Expand Up @@ -227,6 +234,9 @@ public MetricsBase(
}
}

/**
* @param chart
*/
public void addCustomChart(CustomChart chart) {
this.customCharts.add(chart);
}
Expand Down Expand Up @@ -359,6 +369,9 @@ private static byte[] compress(final String str) throws IOException {
}
}

/**
*
*/
public static class AdvancedBarChart extends CustomChart {

private final Callable<Map<String, int[]>> callable;
Expand Down Expand Up @@ -399,6 +412,9 @@ protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
}
}

/**
*
*/
public static class SimpleBarChart extends CustomChart {

private final Callable<Map<String, Integer>> callable;
Expand Down Expand Up @@ -429,6 +445,9 @@ protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
}
}

/**
*
*/
public static class MultiLineChart extends CustomChart {

private final Callable<Map<String, Integer>> callable;
Expand Down Expand Up @@ -469,6 +488,9 @@ protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
}
}

/**
*
*/
public static class AdvancedPie extends CustomChart {

private final Callable<Map<String, Integer>> callable;
Expand Down Expand Up @@ -509,6 +531,9 @@ protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
}
}

/**
*
*/
public abstract static class CustomChart {

private final String chartId;
Expand All @@ -520,6 +545,11 @@ protected CustomChart(String chartId) {
this.chartId = chartId;
}

/**
* @param errorLogger
* @param logErrors
* @return
*/
public JsonObjectBuilder.JsonObject getRequestJsonObject(
BiConsumer<String, Throwable> errorLogger, boolean logErrors) {
JsonObjectBuilder builder = new JsonObjectBuilder();
Expand All @@ -543,6 +573,9 @@ public JsonObjectBuilder.JsonObject getRequestJsonObject(
protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception;
}

/**
*
*/
public static class SingleLineChart extends CustomChart {

private final Callable<Integer> callable;
Expand All @@ -569,6 +602,9 @@ protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
}
}

/**
*
*/
public static class SimplePie extends CustomChart {

private final Callable<String> callable;
Expand All @@ -595,6 +631,9 @@ protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
}
}

/**
*
*/
public static class DrilldownPie extends CustomChart {

private final Callable<Map<String, Map<String, Integer>>> callable;
Expand Down Expand Up @@ -651,6 +690,9 @@ public static class JsonObjectBuilder {

private boolean hasAtLeastOneField = false;

/**
*
*/
public JsonObjectBuilder() {
builder.append("{");
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/xyz/geik/farmer/api/FarmerAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static Main getInstance() {
/**
* Storage manager for config and json files.
* @see xyz.geik.farmer.api.managers.StorageManager
* @return StorageManager
*/
public static StorageManager getStorageManager() {
if (storageManager == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public HandlerList getHandlers() {
return HANDLERS;
}

/**
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return HANDLERS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public HandlerList getHandlers() {
return HANDLERS;
}

/**
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return HANDLERS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public HandlerList getHandlers() {
return HANDLERS;
}

/**
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return HANDLERS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public HandlerList getHandlers() {
return HANDLERS;
}

/**
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return HANDLERS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public HandlerList getHandlers() {
return HANDLERS;
}

/**
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return HANDLERS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public HandlerList getHandlers() {
return HANDLERS;
}

/**
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return HANDLERS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public HandlerList getHandlers() {
return HANDLERS;
}

/**
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return HANDLERS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public FarmerStorageFullEvent(Farmer farmer, ItemStack item, int leftAmount, Ite
this.itemSpawnEvent = itemSpawnEvent;
}

// Only setter method of event
/**
* @param arg0 boolean of cancelled or not default: false
*/
public void setCancelled(boolean arg0) {
this.isCancelled = arg0;
}
Expand All @@ -84,6 +86,9 @@ public HandlerList getHandlers() {
return HANDLERS;
}

/**
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return HANDLERS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void registerModule(@NotNull FarmerModule farmerModule) {
*
* @param farmerModule Module to add
* @see FarmerModule
* @throws ModuleExistException if module doesn't exist it throws this exception
*/
public void addModule(FarmerModule farmerModule) throws ModuleExistException {
if (getModuleList().contains(farmerModule))
Expand Down
Loading

0 comments on commit 3672337

Please sign in to comment.