Skip to content

Commit

Permalink
v1.0.8 Update
Browse files Browse the repository at this point in the history
- Updated Message.java.java class
- Updated InventoryBuilder.java class
- Updated ExampleMessage.java class
- Minor bug fixes

Signed-off-by: FranFrau <[email protected]>
  • Loading branch information
FranFrau committed Aug 12, 2020
1 parent 1d485a0 commit b127e0f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<String> s = new Message(getText() ,"I'm fine")
.getTextList();
s.forEach(System.out::println);
}


}
6 changes: 6 additions & 0 deletions Java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>annotations</artifactId>
<version>12.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
Expand Down
11 changes: 11 additions & 0 deletions Java/src/main/java/it/mycraft/powerlib/chat/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -35,6 +36,16 @@ public Message addPlaceHolder(String placeholder, Object value) {
return this;
}

@Nullable
public String getText(){
return message;
}

@Nullable
public List<String> getTextList(){
return messages;
}

public void send(CommandSender commandSender) {
if (messages.isEmpty())
commandSender.sendMessage(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -192,7 +189,6 @@ private Inventory fillBorder(Inventory inventory) {
inventory.setItem(j, fillBorder);
}
}
return inventory;
}

/**
Expand All @@ -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);
Expand All @@ -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++) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit b127e0f

Please sign in to comment.