From b127e0f5e7979aaf1ac020a43394d575be3f6684 Mon Sep 17 00:00:00 2001 From: Francesco Frau Date: Wed, 12 Aug 2020 19:09:40 +0200 Subject: [PATCH] v1.0.8 Update - Updated Message.java.java class - Updated InventoryBuilder.java class - Updated ExampleMessage.java class - Minor bug fixes Signed-off-by: FranFrau --- .../powerlibexample/ExampleMessage.java | 16 ++++++++++++++++ Java/pom.xml | 6 ++++++ .../it/mycraft/powerlib/chat/Message.java | 11 +++++++++++ .../powerlib/inventory/InventoryBuilder.java | 19 ++++++------------- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/Example/src/main/java/it/mycraft/powerlibexample/ExampleMessage.java b/Example/src/main/java/it/mycraft/powerlibexample/ExampleMessage.java index f500263..d4328b4 100644 --- a/Example/src/main/java/it/mycraft/powerlibexample/ExampleMessage.java +++ b/Example/src/main/java/it/mycraft/powerlibexample/ExampleMessage.java @@ -5,6 +5,8 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; +import java.util.List; + public class ExampleMessage { public void isOp(Player player) { @@ -24,4 +26,18 @@ public void sendListMessages(ConsoleCommandSender consoleCommandSender) { new Message("&6Hi console", "&eHow are you?") .send(consoleCommandSender); } + + public String getText(){ + return new Message("&4hi %player") + .addPlaceHolder("%player", "Pompiere1") + .getText(); + } + + public void textList(){ + List s = new Message(getText() ,"I'm fine") + .getTextList(); + s.forEach(System.out::println); + } + + } \ No newline at end of file diff --git a/Java/pom.xml b/Java/pom.xml index d59b5b6..ebc271d 100644 --- a/Java/pom.xml +++ b/Java/pom.xml @@ -59,6 +59,12 @@ + + com.intellij + annotations + 12.0 + compile + org.spigotmc spigot-api diff --git a/Java/src/main/java/it/mycraft/powerlib/chat/Message.java b/Java/src/main/java/it/mycraft/powerlib/chat/Message.java index 9129d7c..53ea94b 100644 --- a/Java/src/main/java/it/mycraft/powerlib/chat/Message.java +++ b/Java/src/main/java/it/mycraft/powerlib/chat/Message.java @@ -2,6 +2,7 @@ import it.mycraft.powerlib.utils.ColorAPI; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Arrays; @@ -35,6 +36,16 @@ public Message addPlaceHolder(String placeholder, Object value) { return this; } + @Nullable + public String getText(){ + return message; + } + + @Nullable + public List getTextList(){ + return messages; + } + public void send(CommandSender commandSender) { if (messages.isEmpty()) commandSender.sendMessage(message); diff --git a/Java/src/main/java/it/mycraft/powerlib/inventory/InventoryBuilder.java b/Java/src/main/java/it/mycraft/powerlib/inventory/InventoryBuilder.java index 088b10d..cf8da2d 100644 --- a/Java/src/main/java/it/mycraft/powerlib/inventory/InventoryBuilder.java +++ b/Java/src/main/java/it/mycraft/powerlib/inventory/InventoryBuilder.java @@ -162,21 +162,18 @@ private void open(Player player, InventoryBuilder inventoryBuilder) { * Fills an inventory with an item * * @param inventory The inventory - * @return The filled inventory */ - private Inventory fillInventory(Inventory inventory) { + private void fillInventory(Inventory inventory) { for (int i = 0; i < inventory.getSize(); i++) inventory.setItem(i, fillInventory); - return inventory; } /** * Fills the inventory's borders with an itemstack * * @param inventory The inventory - * @return The InventoryBuilder */ - private Inventory fillBorder(Inventory inventory) { + private void fillBorder(Inventory inventory) { for (int i = 1; i <= 2; i++) { int max = i == 2 ? (inventory.getSize() - 1) : (i * 9) - 1; int min = max - 8; @@ -192,7 +189,6 @@ private Inventory fillBorder(Inventory inventory) { inventory.setItem(j, fillBorder); } } - return inventory; } /** @@ -201,7 +197,7 @@ private Inventory fillBorder(Inventory inventory) { * @param inventory The inventory * @return The InventoryBuilder */ - private Inventory fillChessBorder(Inventory inventory) { + private void fillChessBorder(Inventory inventory) { int inventorySize = inventory.getSize(); boolean bool = true; ItemStack itemStack = bool ? fillChessBorder.get(0) : fillChessBorder.get(1); @@ -213,7 +209,7 @@ private Inventory fillChessBorder(Inventory inventory) { itemStack = bool ? fillChessBorder.get(0) : fillChessBorder.get(1); } if (inventorySize == 9) - return inventory; + return; int t = ((inventorySize / 9) - 2); for (int j = 0; j < t; j++) { @@ -231,13 +227,11 @@ private Inventory fillChessBorder(Inventory inventory) { } slot = inventorySize - 9; - for (int ignored = 0; slot < inventorySize; slot++, ignored++) { + for (int ignored = 0; slot < inventorySize; slot++) { inventory.setItem(slot, itemStack); bool = !bool; itemStack = bool ? fillChessBorder.get(0) : fillChessBorder.get(1); } - - return inventory; } private void setRowAndColumnItems(int row, int column, ItemStack itemStack) { @@ -265,13 +259,12 @@ private void setRowAndColumnItems(int row, int column, ItemStack itemStack) { * @param inventory The inventory * @return The inventory filled */ - private Inventory setItems(Inventory inventory) { + private void setItems(Inventory inventory) { if (setItem.size() != 0) { for (Integer integer : setItem.keySet()) { inventory.setItem(integer, setItem.get(integer)); } } - return inventory; } /**