Changes + Documentation
This commit is contained in:
@@ -60,7 +60,7 @@ public abstract class DisplayModule extends PluginDependent<EcoPlugin> {
|
||||
*
|
||||
* @return The plugin name.
|
||||
*/
|
||||
final String getPluginName() {
|
||||
public final String getPluginName() {
|
||||
return super.getPlugin().getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,16 @@ public abstract class Extension {
|
||||
return this.metadata.name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the author of the extension.
|
||||
*
|
||||
* @return The author of the metadata attached to the extension.
|
||||
*/
|
||||
public final String getAuthor() {
|
||||
Validate.notNull(metadata, "Metadata cannot be null!");
|
||||
return this.metadata.author();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version of the extension.
|
||||
*
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.willfp.eco.core.extensions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record ExtensionMetadata(@NotNull String version,
|
||||
@NotNull String name) {
|
||||
@NotNull String name,
|
||||
@NotNull String author) {
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,46 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface MenuBuilder {
|
||||
/**
|
||||
* Set the menu title.
|
||||
*
|
||||
* @param title The title.
|
||||
* @return The builder.
|
||||
*/
|
||||
MenuBuilder setTitle(@NotNull String title);
|
||||
|
||||
/**
|
||||
* Set a slot.
|
||||
*
|
||||
* @param row The row.
|
||||
* @param column The column.
|
||||
* @param slot The slot.
|
||||
* @return The builder.
|
||||
*/
|
||||
MenuBuilder setSlot(int row,
|
||||
int column,
|
||||
@NotNull Slot slot);
|
||||
int column,
|
||||
@NotNull Slot slot);
|
||||
|
||||
/**
|
||||
* Set the menu mask.
|
||||
*
|
||||
* @param mask The mask.
|
||||
* @return The builder.
|
||||
*/
|
||||
MenuBuilder setMask(@NotNull FillerMask mask);
|
||||
|
||||
/**
|
||||
* Set the menu close handler.
|
||||
*
|
||||
* @param action The handler.
|
||||
* @return The builder.
|
||||
*/
|
||||
MenuBuilder onClose(@NotNull Consumer<InventoryCloseEvent> action);
|
||||
|
||||
/**
|
||||
* Build the menu.
|
||||
*
|
||||
* @return The menu.
|
||||
*/
|
||||
Menu build();
|
||||
}
|
||||
|
||||
@@ -6,15 +6,50 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public interface SlotBuilder {
|
||||
/**
|
||||
* Set click handler.
|
||||
*
|
||||
* @param action The handler.
|
||||
* @return The builder.
|
||||
*/
|
||||
SlotBuilder onLeftClick(@NotNull BiConsumer<InventoryClickEvent, Slot> action);
|
||||
|
||||
/**
|
||||
* Set click handler.
|
||||
*
|
||||
* @param action The handler.
|
||||
* @return The builder.
|
||||
*/
|
||||
SlotBuilder onRightClick(@NotNull BiConsumer<InventoryClickEvent, Slot> action);
|
||||
|
||||
/**
|
||||
* Set click handler.
|
||||
*
|
||||
* @param action The handler.
|
||||
* @return The builder.
|
||||
*/
|
||||
SlotBuilder onShiftLeftClick(@NotNull BiConsumer<InventoryClickEvent, Slot> action);
|
||||
|
||||
/**
|
||||
* Set click handler.
|
||||
*
|
||||
* @param action The handler.
|
||||
* @return The builder.
|
||||
*/
|
||||
SlotBuilder onShiftRightClick(@NotNull BiConsumer<InventoryClickEvent, Slot> action);
|
||||
|
||||
/**
|
||||
* Set click handler.
|
||||
*
|
||||
* @param action The handler.
|
||||
* @return The builder.
|
||||
*/
|
||||
SlotBuilder onMiddleClick(@NotNull BiConsumer<InventoryClickEvent, Slot> action);
|
||||
|
||||
/**
|
||||
* Build the slot.
|
||||
*
|
||||
* @return The slot.
|
||||
*/
|
||||
Slot build();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.willfp.eco.core.web;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -12,6 +13,7 @@ import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Paste {
|
||||
/**
|
||||
@@ -31,45 +33,49 @@ public class Paste {
|
||||
|
||||
/**
|
||||
* Upload to hastebin and get a token.
|
||||
* <p>
|
||||
* Runs asynchronously to avoid hangups.
|
||||
*
|
||||
* @return The token.
|
||||
* @param responseHandler The consumer to accept the response token.
|
||||
*/
|
||||
public String getHastebinToken() {
|
||||
try {
|
||||
String url = "https://hastebin.com/documents";
|
||||
URL obj = new URL(url);
|
||||
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
||||
public void getHastebinToken(@NotNull final Consumer<String> responseHandler) {
|
||||
Eco.getHandler().getEcoPlugin().getScheduler().runAsync(() -> {
|
||||
try {
|
||||
String url = "https://hastebin.com/documents";
|
||||
URL obj = new URL(url);
|
||||
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
||||
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
|
||||
con.setDoOutput(true);
|
||||
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
|
||||
wr.writeBytes(URLEncoder.encode(contents, StandardCharsets.UTF_8));
|
||||
wr.flush();
|
||||
wr.close();
|
||||
con.setDoOutput(true);
|
||||
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
|
||||
wr.writeBytes(URLEncoder.encode(contents, StandardCharsets.UTF_8));
|
||||
wr.flush();
|
||||
wr.close();
|
||||
|
||||
BufferedReader iny = new BufferedReader(
|
||||
new InputStreamReader(con.getInputStream()));
|
||||
String output;
|
||||
StringBuilder responseBuilder = new StringBuilder();
|
||||
BufferedReader iny = new BufferedReader(
|
||||
new InputStreamReader(con.getInputStream()));
|
||||
String output;
|
||||
StringBuilder responseBuilder = new StringBuilder();
|
||||
|
||||
while ((output = iny.readLine()) != null) {
|
||||
responseBuilder.append(output);
|
||||
while ((output = iny.readLine()) != null) {
|
||||
responseBuilder.append(output);
|
||||
}
|
||||
iny.close();
|
||||
|
||||
String responseString = responseBuilder.toString();
|
||||
|
||||
responseString = responseString.replace("{\"key\":\"", "");
|
||||
responseString = responseString.replace("\"}", "");
|
||||
|
||||
responseHandler.accept(responseString);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
iny.close();
|
||||
|
||||
String responseString = responseBuilder.toString();
|
||||
|
||||
responseString = responseString.replace("{\"key\":\"", "");
|
||||
responseString = responseString.replace("\"}", "");
|
||||
|
||||
return responseString;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "";
|
||||
responseHandler.accept("");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +92,7 @@ public class Paste {
|
||||
conn.setRequestMethod("GET");
|
||||
try (var reader = new BufferedReader(
|
||||
new InputStreamReader(conn.getInputStream()))) {
|
||||
for (String line; (line = reader.readLine()) != null;) {
|
||||
for (String line; (line = reader.readLine()) != null; ) {
|
||||
result.append(line);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user