Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-van-dijkhuizen committed Jul 1, 2021
2 parents 3a460f5 + 4c1fa3e commit 555829b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 17 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>timvandijkhuizen</groupId>
<artifactId>spigot-utils</artifactId>
<version>1.2.3</version>
<version>1.2.4</version>
<name>SpigotUtils</name>

<distributionManagement>
Expand Down Expand Up @@ -62,14 +62,14 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>7.5.4</version>
<version>8.1.0</version>
</dependency>
</dependencies>
</project>
3 changes: 2 additions & 1 deletion src/nl/timvandijkhuizen/spigotutils/config/ConfigOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.cryptomorin.xseries.XMaterial;

import nl.timvandijkhuizen.spigotutils.data.DataArguments;
import nl.timvandijkhuizen.spigotutils.helpers.InventoryHelper;
import nl.timvandijkhuizen.spigotutils.menu.MenuClick;

public class ConfigOption<T> {
Expand All @@ -32,7 +33,7 @@ public ConfigOption(String path, String name, Material icon, ConfigType<T> type)
}

public ConfigOption(String path, String name, XMaterial icon, ConfigType<T> type) {
this(path, name, icon.parseMaterial(true), type);
this(path, name, InventoryHelper.parseMaterial(icon), type);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package nl.timvandijkhuizen.spigotutils.config.types;

import java.util.Currency;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
Expand All @@ -19,6 +21,10 @@

public class ConfigTypeCurrency implements ConfigType<Currency> {

private static final Set<Currency> CURRENCIES = Currency.getAvailableCurrencies().stream() //
.sorted((a, b) -> a.getDisplayName().compareTo(b.getDisplayName())) //
.collect(Collectors.toSet());

@Override
public Currency getValue(OptionConfig config, ConfigOption<Currency> option) {
try {
Expand Down Expand Up @@ -55,7 +61,7 @@ public void getValueInput(OptionConfig config, ConfigOption<Currency> option, Me
Player player = event.getPlayer();
Currency selected = getValue(config, option);

for (Currency currency : Currency.getAvailableCurrencies()) {
for (Currency currency : CURRENCIES) {
MenuItemBuilder item = new MenuItemBuilder(XMaterial.SUNFLOWER);

item.setName(UI.color(currency.getDisplayName(), UI.COLOR_PRIMARY, ChatColor.BOLD));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import nl.timvandijkhuizen.spigotutils.config.OptionConfig;
import nl.timvandijkhuizen.spigotutils.data.TypedValue;
import nl.timvandijkhuizen.spigotutils.helpers.ConsoleHelper;
import nl.timvandijkhuizen.spigotutils.helpers.InventoryHelper;
import nl.timvandijkhuizen.spigotutils.menu.MenuClick;
import nl.timvandijkhuizen.spigotutils.menu.items.MenuItemBuilder;
import nl.timvandijkhuizen.spigotutils.menu.items.MenuItems;
Expand All @@ -38,7 +39,7 @@ public ConfigTypeList(Class<T> clazz, String menuTitle, Material menuIcon) {
}

public ConfigTypeList(Class<T> clazz, String menuTitle, XMaterial menuIcon) {
this(clazz, menuTitle, menuIcon.parseMaterial(true));
this(clazz, menuTitle, InventoryHelper.parseMaterial(menuIcon));
}

public ConfigTypeList(Class<T> clazz, String menuTitle) {
Expand Down
19 changes: 19 additions & 0 deletions src/nl/timvandijkhuizen/spigotutils/helpers/InventoryHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package nl.timvandijkhuizen.spigotutils.helpers;

import org.bukkit.Material;

import com.cryptomorin.xseries.XMaterial;

public class InventoryHelper {

public static Material parseMaterial(XMaterial material) {
Material output = material.parseMaterial();

if(output != null) {
return output;
}

return Material.BARRIER;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.cryptomorin.xseries.SkullUtils;
import com.cryptomorin.xseries.XMaterial;

import nl.timvandijkhuizen.spigotutils.helpers.InventoryHelper;

public class ItemBuilder {

protected ItemStack itemStack;
Expand All @@ -35,7 +37,7 @@ public ItemBuilder(XMaterial material) {
}

public ItemBuilder(XMaterial material, int amount) {
this(material.parseMaterial(true), amount);
this(InventoryHelper.parseMaterial(material), amount);
}

public ItemBuilder(ItemStack itemStack) {
Expand Down Expand Up @@ -69,7 +71,7 @@ public ItemBuilder setType(Material material) {
* @return
*/
public ItemBuilder setType(XMaterial material) {
return setType(material.parseMaterial(true));
return setType(InventoryHelper.parseMaterial(material));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import com.cryptomorin.xseries.XMaterial;

import nl.timvandijkhuizen.spigotutils.helpers.InventoryHelper;
import nl.timvandijkhuizen.spigotutils.inventory.ItemBuilder;
import nl.timvandijkhuizen.spigotutils.menu.MenuClickListener;

Expand Down Expand Up @@ -44,7 +45,7 @@ public MenuItemBuilder(XMaterial material) {
}

public MenuItemBuilder(XMaterial material, int amount) {
super(material.parseMaterial(true), amount);
super(InventoryHelper.parseMaterial(material), amount);
}

public MenuItemBuilder(ItemStack itemStack) {
Expand Down
16 changes: 8 additions & 8 deletions src/nl/timvandijkhuizen/spigotutils/menu/items/MenuItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

public class MenuItems {

public static final MenuItemBuilder BACK = new MenuItemBuilder(XMaterial.RED_BED.parseItem(true)).setName(UI.color("Go Back", UI.COLOR_SECONDARY, ChatColor.BOLD));
public static final MenuItemBuilder CLOSE = new MenuItemBuilder(XMaterial.OAK_DOOR.parseItem(true)).setName(UI.color("Close", ChatColor.RED, ChatColor.BOLD));
public static final MenuItemBuilder CANCEL = new MenuItemBuilder(XMaterial.GRAY_DYE.parseItem(true)).setName(UI.color("Cancel", ChatColor.GRAY, ChatColor.BOLD));
public static final MenuItemBuilder SAVE = new MenuItemBuilder(XMaterial.LIME_DYE.parseItem(true)).setName(UI.color("Save", ChatColor.GREEN, ChatColor.BOLD));
public static final MenuItemBuilder BACKGROUND = new MenuItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseItem(true));
public static final MenuItemBuilder BACK = new MenuItemBuilder(XMaterial.RED_BED.parseItem()).setName(UI.color("Go Back", UI.COLOR_SECONDARY, ChatColor.BOLD));
public static final MenuItemBuilder CLOSE = new MenuItemBuilder(XMaterial.OAK_DOOR.parseItem()).setName(UI.color("Close", ChatColor.RED, ChatColor.BOLD));
public static final MenuItemBuilder CANCEL = new MenuItemBuilder(XMaterial.GRAY_DYE.parseItem()).setName(UI.color("Cancel", ChatColor.GRAY, ChatColor.BOLD));
public static final MenuItemBuilder SAVE = new MenuItemBuilder(XMaterial.LIME_DYE.parseItem()).setName(UI.color("Save", ChatColor.GREEN, ChatColor.BOLD));
public static final MenuItemBuilder BACKGROUND = new MenuItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseItem());

public static final MenuItemBuilder PREVIOUS = new MenuItemBuilder(XMaterial.ARROW.parseItem(true)).setName(UI.color("Previous Page", UI.COLOR_SECONDARY, ChatColor.BOLD));
public static final MenuItemBuilder NEXT = new MenuItemBuilder(XMaterial.ARROW.parseItem(true)).setName(UI.color("Next Page", UI.COLOR_SECONDARY, ChatColor.BOLD));
public static final MenuItemBuilder CURRENT = new MenuItemBuilder(XMaterial.MAP.parseItem(true));
public static final MenuItemBuilder PREVIOUS = new MenuItemBuilder(XMaterial.ARROW.parseItem()).setName(UI.color("Previous Page", UI.COLOR_SECONDARY, ChatColor.BOLD));
public static final MenuItemBuilder NEXT = new MenuItemBuilder(XMaterial.ARROW.parseItem()).setName(UI.color("Next Page", UI.COLOR_SECONDARY, ChatColor.BOLD));
public static final MenuItemBuilder CURRENT = new MenuItemBuilder(XMaterial.MAP.parseItem());

}

0 comments on commit 555829b

Please sign in to comment.