mirror of
https://github.com/songoda/EpicBuckets.git
synced 2024-11-13 05:45:16 +01:00
All guis added and working except for Bulk Shop
This commit is contained in:
parent
ba7319d43f
commit
9bf911cccb
48
pom.xml
48
pom.xml
@ -34,6 +34,29 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||
<shadedClassifierName>shaded</shadedClassifierName>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>co.aikar.commands</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.acf</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
@ -45,23 +68,24 @@
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>private</id>
|
||||
<id>11_private</id>
|
||||
<url>http://repo.songoda.com/repository/private</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vault</id>
|
||||
<id>22_vault</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aikar</id>
|
||||
<id>33_aikar</id>
|
||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>co.aikar</groupId>
|
||||
<artifactId>acf-bukkit</artifactId>
|
||||
<artifactId>acf-paper</artifactId>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.lucko</groupId>
|
||||
@ -73,81 +97,97 @@
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.13.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>arconix</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org</groupId>
|
||||
<artifactId>kingdoms</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.ryanhamshire</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldedit</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.2.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com</groupId>
|
||||
<artifactId>plotsquared</artifactId>
|
||||
<version>RELEASE</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.palmergames.bukkit</groupId>
|
||||
<artifactId>towny</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.wasteofplastic</groupId>
|
||||
<artifactId>askyblock</artifactId>
|
||||
<version>3.0.6.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>us.talabrek</groupId>
|
||||
<artifactId>ultimateskyblock</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.markeh</groupId>
|
||||
<artifactId>factionsframework</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>br.net.fabiozumbi12</groupId>
|
||||
<artifactId>RedProtect</artifactId>
|
||||
<version>7.3.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>epicspawners</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.massivecraft</groupId>
|
||||
<artifactId>factions</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.massivecraft</groupId>
|
||||
<artifactId>factionsuuid</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.songoda.epicbuckets;
|
||||
|
||||
import co.aikar.commands.PaperCommandManager;
|
||||
import com.songoda.epicbuckets.command.CommandGenbucket;
|
||||
import com.songoda.epicbuckets.file.ConfigManager;
|
||||
import com.songoda.epicbuckets.shop.ShopManager;
|
||||
import com.songoda.epicbuckets.util.Debugger;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class EpicBuckets extends JavaPlugin {
|
||||
@ -12,6 +16,8 @@ public class EpicBuckets extends JavaPlugin {
|
||||
private ConfigManager configManager;
|
||||
private ShopManager shopManager;
|
||||
private Debugger debugger;
|
||||
private Economy econ;
|
||||
PaperCommandManager commandManager;
|
||||
|
||||
public static EpicBuckets getInstance() { return instance; }
|
||||
|
||||
@ -19,9 +25,15 @@ public class EpicBuckets extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
debugger = new Debugger();
|
||||
configManager = new ConfigManager();
|
||||
shopManager = new ShopManager();
|
||||
debugger = new Debugger();
|
||||
shopManager.init();
|
||||
commandManager = new PaperCommandManager(this);
|
||||
|
||||
commandManager.registerCommand(new CommandGenbucket());
|
||||
|
||||
setupEconomy();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -29,6 +41,18 @@ public class EpicBuckets extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
private boolean setupEconomy() {
|
||||
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
return false;
|
||||
}
|
||||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp == null) {
|
||||
return false;
|
||||
}
|
||||
econ = rsp.getProvider();
|
||||
return econ != null;
|
||||
}
|
||||
|
||||
public ConfigManager getConfigManager() {
|
||||
return configManager;
|
||||
}
|
||||
@ -41,4 +65,8 @@ public class EpicBuckets extends JavaPlugin {
|
||||
return debugger;
|
||||
}
|
||||
|
||||
public Economy getEcon() {
|
||||
return econ;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.songoda.epicbuckets.command;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import com.songoda.epicbuckets.gui.GUIMain;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("genbucket")
|
||||
public class CommandGenbucket extends BaseCommand {
|
||||
|
||||
@Subcommand("shop")
|
||||
@Description("Opens up the Genbucket shop")
|
||||
@CommandPermission("genbucket.shop")
|
||||
public void shop(Player player) {
|
||||
new GUIMain(player).open();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.epicbuckets.file;
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
||||
import com.songoda.epicbuckets.util.Validator;
|
||||
import com.songoda.epicbuckets.util.XMaterial;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -21,14 +22,37 @@ public class ConfigManager {
|
||||
private String bulkShopIncreasePath = "BULK-SHOP-INVENTORY.increase-item";
|
||||
private String bulkShopDecreasePath = "BULK-SHOP-INVENTORY.decrease-item";
|
||||
private String bulkShopPurchasePath = "BULK-SHOP-INVENTORY.purchase-item";
|
||||
private String menuItemsPath = "MENU-ITEMS";
|
||||
|
||||
private List<String> ignoredMaterials;
|
||||
private List<String> psuedoMaterials;
|
||||
|
||||
private boolean supportFactions;
|
||||
private boolean supportWorldGuard;
|
||||
private boolean supportGriefPrevention;
|
||||
|
||||
private boolean gensInWilderness;
|
||||
private boolean enchantGenbuckets;
|
||||
private boolean spongeCheck;
|
||||
private int spongeRadius;
|
||||
private int maxGenbucketsPerPlayer;
|
||||
private boolean unlimitedGenbuckets;
|
||||
private int maxVerticalHeight;
|
||||
private int maxHorizontalLength;
|
||||
private int delay;
|
||||
private boolean enabled;
|
||||
private int inventorySize;
|
||||
private String inventoryName;
|
||||
private boolean fillInventory;
|
||||
|
||||
private ItemStack backButton;
|
||||
private ItemStack fillItem;
|
||||
|
||||
public ConfigManager() {
|
||||
this.epicBuckets = EpicBuckets.getInstance();
|
||||
ignoredMaterials = new ArrayList<>();
|
||||
psuedoMaterials = new ArrayList<>();
|
||||
configDatabase = new HashMap<>();
|
||||
|
||||
setup();
|
||||
}
|
||||
@ -44,21 +68,36 @@ public class ConfigManager {
|
||||
|
||||
private void loadData() {
|
||||
ignoredMaterials = epicBuckets.getConfig().getStringList("IGNORE-MATERIALS");
|
||||
//TODO: load in all config data
|
||||
supportFactions = epicBuckets.getConfig().getBoolean("FACTIONS-SUPPORT");
|
||||
supportWorldGuard = epicBuckets.getConfig().getBoolean("WORLDGUARD-SUPPORT");
|
||||
supportGriefPrevention = epicBuckets.getConfig().getBoolean("GRIEFPREVENTION-SUPPORT");
|
||||
gensInWilderness = epicBuckets.getConfig().getBoolean("ENABLE-GENS-IN-WILDERNESS");
|
||||
enchantGenbuckets = epicBuckets.getConfig().getBoolean("ENCHANT");
|
||||
spongeCheck = epicBuckets.getConfig().getBoolean("USE-SPONGE-SUPPORT");
|
||||
spongeRadius = epicBuckets.getConfig().getInt("SPONGE-RADIUS");
|
||||
maxGenbucketsPerPlayer = epicBuckets.getConfig().getInt("MAX-ACTIVE-GEN-PER-PLAYER");
|
||||
unlimitedGenbuckets = epicBuckets.getConfig().getBoolean("PLACE-UNLIMTED-GENS");
|
||||
maxVerticalHeight = epicBuckets.getConfig().getInt("MAX-VERTICAL-HEIGHT");
|
||||
maxHorizontalLength = epicBuckets.getConfig().getInt("MAX-HORIZONTAL-LENGTH");
|
||||
delay = epicBuckets.getConfig().getInt("DELAY");
|
||||
setEnabled(epicBuckets.getConfig().getBoolean("DISABLE-GENBUCKETS"));
|
||||
inventorySize = epicBuckets.getConfig().getInt(menuItemsPath + ".size");
|
||||
inventoryName = epicBuckets.getConfig().getString(menuItemsPath + ".inventory-name");
|
||||
fillInventory = epicBuckets.getConfig().getBoolean(menuItemsPath + ".fill");
|
||||
}
|
||||
|
||||
private void setupFillItem() {
|
||||
boolean m = Validator.getInstance().isMaterial(epicBuckets.getConfig().getString(getFillItemPath() + ".material"));
|
||||
boolean m = Validator.isMaterial(epicBuckets.getConfig().getString(getFillItemPath() + ".material"));
|
||||
|
||||
backButton = ((!m) ? XMaterial.BLACK_STAINED_GLASS_PANE.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(getFillItemPath() + ".material")).parseItem());
|
||||
backButton.getItemMeta().setDisplayName(epicBuckets.getConfig().getString(getFillItemPath() + ".name"));
|
||||
fillItem = ((!m) ? XMaterial.BLACK_STAINED_GLASS_PANE.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(getFillItemPath() + ".material")).parseItem());
|
||||
fillItem = InventoryHelper.setDisplayName(fillItem, epicBuckets.getConfig().getString(getFillItemPath() + ".name"));
|
||||
}
|
||||
|
||||
private void setupBackButton() {
|
||||
boolean m = Validator.getInstance().isMaterial(epicBuckets.getConfig().getString(getBackButtonPath() + ".material"));
|
||||
boolean m = Validator.isMaterial(epicBuckets.getConfig().getString(getBackButtonPath() + ".material"));
|
||||
|
||||
backButton = ((!m) ? XMaterial.BARRIER.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(getBackButtonPath() + ".material")).parseItem());
|
||||
backButton.getItemMeta().setDisplayName(epicBuckets.getConfig().getString(getBackButtonPath() + ".name"));
|
||||
backButton = InventoryHelper.setDisplayName(backButton, epicBuckets.getConfig().getString(getBackButtonPath() + ".name"));
|
||||
}
|
||||
|
||||
public void createConfig(String name, boolean resource) {
|
||||
@ -99,4 +138,88 @@ public class ConfigManager {
|
||||
public List<String> getIgnoredMaterials() {
|
||||
return ignoredMaterials;
|
||||
}
|
||||
|
||||
public List<String> getPsuedoMaterials() {
|
||||
return psuedoMaterials;
|
||||
}
|
||||
|
||||
public boolean isSupportFactions() {
|
||||
return supportFactions;
|
||||
}
|
||||
|
||||
public boolean isSupportWorldGuard() {
|
||||
return supportWorldGuard;
|
||||
}
|
||||
|
||||
public boolean isSupportGriefPrevention() {
|
||||
return supportGriefPrevention;
|
||||
}
|
||||
|
||||
public boolean isGensInWilderness() {
|
||||
return gensInWilderness;
|
||||
}
|
||||
|
||||
public boolean isEnchantGenbuckets() {
|
||||
return enchantGenbuckets;
|
||||
}
|
||||
|
||||
public boolean isSpongeCheck() {
|
||||
return spongeCheck;
|
||||
}
|
||||
|
||||
public int getSpongeRadius() {
|
||||
return spongeRadius;
|
||||
}
|
||||
|
||||
public int getMaxGenbucketsPerPlayer() {
|
||||
return maxGenbucketsPerPlayer;
|
||||
}
|
||||
|
||||
public boolean isUnlimitedGenbuckets() {
|
||||
return unlimitedGenbuckets;
|
||||
}
|
||||
|
||||
public int getMaxVerticalHeight() {
|
||||
return maxVerticalHeight;
|
||||
}
|
||||
|
||||
public int getMaxHorizontalLength() {
|
||||
return maxHorizontalLength;
|
||||
}
|
||||
|
||||
public int getDelay() {
|
||||
return delay;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public ItemStack getBackButton() {
|
||||
return backButton;
|
||||
}
|
||||
|
||||
public String getMenuItemsPath() {
|
||||
return menuItemsPath;
|
||||
}
|
||||
|
||||
public int getInventorySize() {
|
||||
return inventorySize;
|
||||
}
|
||||
|
||||
public String getInventoryName() {
|
||||
return inventoryName;
|
||||
}
|
||||
|
||||
public boolean isFillInventory() {
|
||||
return fillInventory;
|
||||
}
|
||||
|
||||
public ItemStack getFillItem() {
|
||||
return fillItem;
|
||||
}
|
||||
}
|
||||
|
70
src/main/java/com/songoda/epicbuckets/gui/GUIBulk.java
Normal file
70
src/main/java/com/songoda/epicbuckets/gui/GUIBulk.java
Normal file
@ -0,0 +1,70 @@
|
||||
package com.songoda.epicbuckets.gui;
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.file.ConfigManager;
|
||||
import com.songoda.epicbuckets.shop.ShopManager;
|
||||
import com.songoda.epicbuckets.shop.SubShop;
|
||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
||||
import me.lucko.helper.item.ItemStackBuilder;
|
||||
import me.lucko.helper.menu.Gui;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
public class GUIBulk extends Gui {
|
||||
|
||||
private EpicBuckets epicBuckets;
|
||||
private ConfigManager configManager;
|
||||
private ShopManager shopManager;
|
||||
private SubShop subShop;
|
||||
|
||||
public GUIBulk(SubShop subShop, Player player) {
|
||||
super(player, EpicBuckets.getInstance().getShopManager().getBulkInventorySize(), EpicBuckets.getInstance().getShopManager().getBulkInventoryName());
|
||||
epicBuckets = EpicBuckets.getInstance();
|
||||
configManager = epicBuckets.getConfigManager();
|
||||
shopManager = epicBuckets.getShopManager();
|
||||
this.subShop = subShop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redraw() {
|
||||
if (isFirstDraw()) {
|
||||
if (shopManager.isBulkFillInventory()) setItems(ItemStackBuilder.of(configManager.getFillItem()).buildItem().build(), InventoryHelper.emptySlots(configManager.getInventorySize() * 9));
|
||||
if (shopManager.isUseBackButtons()) {
|
||||
setItem(shopManager.getBulkBackButtonSlot(), ItemStackBuilder.of(configManager.getBackButton()).buildItem().build());
|
||||
getSlot(shopManager.getBulkBackButtonSlot()).bind(ClickType.LEFT, this::handleBack);
|
||||
}
|
||||
|
||||
shopManager.getDecreaseSlots().forEach(i -> {
|
||||
setItem(i, ItemStackBuilder.of(shopManager.getDecreaseItem()).buildItem().build());
|
||||
getSlot(i).bind(ClickType.LEFT, this::handleDecrease);
|
||||
});
|
||||
shopManager.getIncreaseSlots().forEach(i -> {
|
||||
setItem(i, ItemStackBuilder.of(shopManager.getIncreaseItem()).buildItem().build());
|
||||
getSlot(i).bind(ClickType.LEFT, this::handleIncrease);
|
||||
});
|
||||
setItem(1, ItemStackBuilder.of(subShop.getGenItem()).buildItem().build());
|
||||
getSlot(1).bind(ClickType.LEFT, () -> handleBuy());
|
||||
|
||||
setItem(shopManager.getPurchaseSlot(), ItemStackBuilder.of(shopManager.getPurchaseItem()).buildItem().build());
|
||||
getSlot(shopManager.getPurchaseSlot()).bind(ClickType.LEFT, this::handleBuy);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleBack() {
|
||||
new GUIShop(subShop.getParent(), getPlayer()).open();
|
||||
}
|
||||
|
||||
public void handleDecrease() {
|
||||
|
||||
}
|
||||
|
||||
public void handleIncrease() {
|
||||
|
||||
}
|
||||
|
||||
public void handleBuy() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
43
src/main/java/com/songoda/epicbuckets/gui/GUIMain.java
Normal file
43
src/main/java/com/songoda/epicbuckets/gui/GUIMain.java
Normal file
@ -0,0 +1,43 @@
|
||||
package com.songoda.epicbuckets.gui;
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.file.ConfigManager;
|
||||
import com.songoda.epicbuckets.shop.Shop;
|
||||
import com.songoda.epicbuckets.shop.ShopManager;
|
||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
||||
import me.lucko.helper.item.ItemStackBuilder;
|
||||
import me.lucko.helper.menu.Gui;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
public class GUIMain extends Gui {
|
||||
|
||||
private EpicBuckets epicBuckets;
|
||||
private ConfigManager configManager;
|
||||
private ShopManager shopManager;
|
||||
private Player holder;
|
||||
|
||||
public GUIMain(Player player) {
|
||||
super(player, EpicBuckets.getInstance().getConfigManager().getInventorySize(), EpicBuckets.getInstance().getConfigManager().getInventoryName());
|
||||
epicBuckets = EpicBuckets.getInstance();
|
||||
configManager = epicBuckets.getConfigManager();
|
||||
shopManager = epicBuckets.getShopManager();
|
||||
holder = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redraw() {
|
||||
if (isFirstDraw()) {
|
||||
if (configManager.isFillInventory()) setItems(ItemStackBuilder.of(configManager.getFillItem()).buildItem().build(), InventoryHelper.emptySlots(configManager.getInventorySize() * 9));
|
||||
|
||||
epicBuckets.getShopManager().getShops().stream().filter(Shop::isEnabled).forEach(shop -> {
|
||||
setItem(shop.getSlot(), ItemStackBuilder.of(shop.getShopItem()).buildItem().build());
|
||||
getSlot(shop.getSlot()).bind(ClickType.LEFT, () -> handleClick(shop));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleClick(Shop shop) {
|
||||
new GUIShop(shop, getPlayer()).open();
|
||||
}
|
||||
}
|
58
src/main/java/com/songoda/epicbuckets/gui/GUIShop.java
Normal file
58
src/main/java/com/songoda/epicbuckets/gui/GUIShop.java
Normal file
@ -0,0 +1,58 @@
|
||||
package com.songoda.epicbuckets.gui;
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.file.ConfigManager;
|
||||
import com.songoda.epicbuckets.shop.Shop;
|
||||
import com.songoda.epicbuckets.shop.ShopManager;
|
||||
import com.songoda.epicbuckets.shop.SubShop;
|
||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
||||
import me.lucko.helper.item.ItemStackBuilder;
|
||||
import me.lucko.helper.menu.Gui;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
public class GUIShop extends Gui {
|
||||
|
||||
private EpicBuckets epicBuckets;
|
||||
private ConfigManager configManager;
|
||||
private ShopManager shopManager;
|
||||
private Shop s;
|
||||
|
||||
public GUIShop(Shop s, Player player) {
|
||||
super(player, s.getInventorySize(), s.getInventoryName());
|
||||
epicBuckets = EpicBuckets.getInstance();
|
||||
configManager = epicBuckets.getConfigManager();
|
||||
shopManager = epicBuckets.getShopManager();
|
||||
this.s = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redraw() {
|
||||
if (isFirstDraw()) {
|
||||
if (s.isFillInventory()) setItems(ItemStackBuilder.of(configManager.getFillItem()).buildItem().build(), InventoryHelper.emptySlots(s.getInventorySize() * 9));
|
||||
if (shopManager.isUseBackButtons()) {
|
||||
setItem(s.getBackButtonSlot(), ItemStackBuilder.of(configManager.getBackButton()).buildItem().build());
|
||||
getSlot(s.getBackButtonSlot()).bind(ClickType.LEFT, this::handleBack);
|
||||
}
|
||||
|
||||
s.getSubShops().stream().filter(SubShop::isEnabled).forEach(subShop -> {
|
||||
setItem(subShop.getSlot(), ItemStackBuilder.of(subShop.getShopItem()).buildItem().build());
|
||||
getSlot(subShop.getSlot()).bind(ClickType.LEFT, () -> handleSubShop(subShop));
|
||||
getSlot(subShop.getSlot()).bind(ClickType.RIGHT, () -> handleBulk(subShop));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleBulk(SubShop s) {
|
||||
new GUIBulk(s, getPlayer()).open();
|
||||
}
|
||||
|
||||
private void handleBack() {
|
||||
new GUIMain(getPlayer()).open();
|
||||
}
|
||||
|
||||
private void handleSubShop(SubShop s) {
|
||||
if (shopManager.hasEnoughFunds(getPlayer(), s)) shopManager.buyFromShop(getPlayer(), s);
|
||||
}
|
||||
|
||||
}
|
@ -2,11 +2,13 @@ package com.songoda.epicbuckets.shop;
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
||||
import com.songoda.epicbuckets.util.Validator;
|
||||
import com.songoda.epicbuckets.util.XMaterial;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Shop {
|
||||
@ -24,7 +26,7 @@ public class Shop {
|
||||
private String path;
|
||||
private String shopPath;
|
||||
|
||||
private int backButton;
|
||||
private int backButtonSlot;
|
||||
private GenbucketType trait;
|
||||
private int inventorySize;
|
||||
private boolean fillInventory;
|
||||
@ -50,22 +52,22 @@ public class Shop {
|
||||
}
|
||||
|
||||
private void loadData() {
|
||||
trait = Validator.getInstance().genbucketType(shops.getString(shopPath + "trait"));
|
||||
backButton = Validator.getInstance().slot(shops.getString(shopPath + "goBackButton"));
|
||||
inventorySize = Validator.getInstance().inventorySize(shops.getString(shopPath + "size"));
|
||||
fillInventory = shops.getBoolean(shopPath + "fill");
|
||||
inventoryName = shops.getString(shopPath + "inventory-name");
|
||||
trait = Validator.genbucketType(shops.getString(shopPath + ".trait"));
|
||||
backButtonSlot = Validator.slot(shops.getString(shopPath + ".goBackButton"));
|
||||
inventorySize = Validator.inventorySize(shops.getString(shopPath + ".size"));
|
||||
fillInventory = shops.getBoolean(shopPath + ".fill");
|
||||
inventoryName = shops.getString(shopPath + ".inventory-name");
|
||||
|
||||
if (trait == null) {
|
||||
epicBuckets.getDebugger().invalidGenbucketType(shopPath + "trait");
|
||||
epicBuckets.getDebugger().invalidGenbucketType(shopPath + ".trait");
|
||||
setEnabled(false);
|
||||
}
|
||||
if (backButton == -1) {
|
||||
epicBuckets.getDebugger().invalidSlot(shopPath + "goBackButton");
|
||||
if (backButtonSlot == -1) {
|
||||
epicBuckets.getDebugger().invalidSlot(shopPath + ".goBackButton");
|
||||
setEnabled(false);
|
||||
}
|
||||
if (inventorySize == -1) {
|
||||
epicBuckets.getDebugger().invalidInventorySize(shopPath + "size");
|
||||
epicBuckets.getDebugger().invalidInventorySize(shopPath + ".size");
|
||||
setEnabled(false);
|
||||
}
|
||||
}
|
||||
@ -83,18 +85,20 @@ public class Shop {
|
||||
private void setupShopItem() {
|
||||
String itemPath = path + ".item";
|
||||
|
||||
slot = Validator.getInstance().slot(epicBuckets.getConfig().getString(itemPath + ".slot"));
|
||||
boolean m = Validator.getInstance().isMaterial(epicBuckets.getConfig().getString(itemPath + ".material"));
|
||||
slot = Validator.slot(epicBuckets.getConfig().getString(path + ".slot"));
|
||||
boolean m = Validator.isMaterial(epicBuckets.getConfig().getString(itemPath + ".material"));
|
||||
|
||||
if (slot == -1) {
|
||||
epicBuckets.getDebugger().invalidSlot(itemPath);
|
||||
epicBuckets.getDebugger().invalidSlot(itemPath + ".slot");
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
shopItem = ((!m) ? XMaterial.WATER_BUCKET.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(itemPath + ".material")).parseItem());
|
||||
shopItem = InventoryHelper.setLore(InventoryHelper.setDisplayName(shopItem, epicBuckets.getConfig().getString(itemPath + ".name")), epicBuckets.getConfig().getStringList(itemPath + ".lore"));
|
||||
}
|
||||
|
||||
shopItem.getItemMeta().setDisplayName(epicBuckets.getConfig().getString(itemPath + ".name"));
|
||||
shopItem.getItemMeta().setLore(epicBuckets.getConfig().getStringList(itemPath + ".lore"));
|
||||
public Collection<SubShop> getSubShops() {
|
||||
return subShops.values();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
@ -117,4 +121,27 @@ public class Shop {
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
public ItemStack getShopItem() {
|
||||
return shopItem;
|
||||
}
|
||||
|
||||
public int getBackButtonSlot() {
|
||||
return backButtonSlot;
|
||||
}
|
||||
|
||||
public GenbucketType getTrait() {
|
||||
return trait;
|
||||
}
|
||||
|
||||
public int getInventorySize() {
|
||||
return inventorySize;
|
||||
}
|
||||
|
||||
public boolean isFillInventory() {
|
||||
return fillInventory;
|
||||
}
|
||||
|
||||
public String getInventoryName() {
|
||||
return inventoryName;
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
package com.songoda.epicbuckets.shop;
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
||||
import com.songoda.epicbuckets.util.Validator;
|
||||
import com.songoda.epicbuckets.util.XMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class ShopManager {
|
||||
|
||||
@ -18,8 +18,8 @@ public class ShopManager {
|
||||
private FileConfiguration shops;
|
||||
private EpicBuckets epicBuckets;
|
||||
|
||||
private String configPath = "MENU-ITEMS";
|
||||
private String shopPath = "shops";
|
||||
private String bulkShopPath = "BULK-SHOP-INVENTORY";
|
||||
|
||||
private ItemStack increaseItem;
|
||||
private ItemStack decreaseItem;
|
||||
@ -29,7 +29,14 @@ public class ShopManager {
|
||||
private List<Integer> decreaseSlots;
|
||||
private int purchaseSlot;
|
||||
|
||||
private String bulkInventoryName;
|
||||
private int bulkInventorySize;
|
||||
private boolean bulkFillInventory;
|
||||
private int bulkBackButtonSlot;
|
||||
private int bulkMainItemSlot;
|
||||
|
||||
private boolean useBackButtons;
|
||||
private boolean closeAfterPurchase;
|
||||
|
||||
public ShopManager() {
|
||||
epicBuckets = EpicBuckets.getInstance();
|
||||
@ -37,50 +44,71 @@ public class ShopManager {
|
||||
increaseSlots = new ArrayList<>();
|
||||
decreaseSlots = new ArrayList<>();
|
||||
shops = EpicBuckets.getInstance().getConfigManager().getConfig("shops");
|
||||
}
|
||||
|
||||
public void init() {
|
||||
loadData();
|
||||
loadShops();
|
||||
setupBulkShop();
|
||||
}
|
||||
|
||||
private void setupBulkShop() {
|
||||
boolean i = Validator.getInstance().isMaterial(epicBuckets.getConfigManager().getBulkShopIncreasePath() + ".material");
|
||||
boolean d = Validator.getInstance().isMaterial(epicBuckets.getConfigManager().getBulkShopDecreasePath() + ".material");
|
||||
boolean p = Validator.getInstance().isMaterial(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".material");
|
||||
purchaseSlot = Validator.getInstance().slot(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".slot"));
|
||||
boolean i = Validator.isMaterial(epicBuckets.getConfigManager().getBulkShopIncreasePath() + ".material");
|
||||
boolean d = Validator.isMaterial(epicBuckets.getConfigManager().getBulkShopDecreasePath() + ".material");
|
||||
boolean p = Validator.isMaterial(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".material");
|
||||
purchaseSlot = Validator.slot(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".slot"));
|
||||
|
||||
if (purchaseSlot == -1) {
|
||||
purchaseSlot = 40;
|
||||
}
|
||||
|
||||
increaseItem = ((!i) ? XMaterial.GREEN_STAINED_GLASS_PANE.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopIncreasePath() + ".material")).parseItem());
|
||||
decreaseItem = ((!i) ? XMaterial.RED_STAINED_GLASS_PANE.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopDecreasePath() + ".material")).parseItem());
|
||||
purchaseItem = ((!i) ? XMaterial.YELLOW_STAINED_GLASS.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".material")).parseItem());
|
||||
decreaseItem = ((!d) ? XMaterial.RED_STAINED_GLASS_PANE.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopDecreasePath() + ".material")).parseItem());
|
||||
purchaseItem = ((!p) ? XMaterial.YELLOW_STAINED_GLASS.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".material")).parseItem());
|
||||
purchaseItem = InventoryHelper.setDisplayName(purchaseItem, epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".name"));
|
||||
|
||||
for (String s : epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopIncreasePath() + ".slots").split(",")) {
|
||||
increaseSlots.add(Integer.parseInt(s));
|
||||
}
|
||||
for (String s : epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopDecreasePath() + ".slots").split(",")) {
|
||||
increaseSlots.add(Integer.parseInt(s));
|
||||
decreaseSlots.add(Integer.parseInt(s));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void loadData() {
|
||||
useBackButtons = shops.getBoolean("use-back-buttons");
|
||||
closeAfterPurchase = epicBuckets.getConfig().getBoolean("CLOSE-GUI-AFTER-PURCHASE");
|
||||
bulkInventoryName = epicBuckets.getConfig().getString(bulkShopPath + ".inventory-name");
|
||||
bulkInventorySize = epicBuckets.getConfig().getInt(bulkShopPath + ".size");
|
||||
bulkBackButtonSlot = epicBuckets.getConfig().getInt(bulkShopPath + ".return-back-slot");
|
||||
bulkFillInventory = epicBuckets.getConfig().getBoolean(bulkShopPath + ".fill");
|
||||
bulkMainItemSlot = epicBuckets.getConfig().getInt(bulkShopPath + ".main-item-slot");
|
||||
}
|
||||
|
||||
private void loadShops() {
|
||||
for (String key : epicBuckets.getConfig().getConfigurationSection(configPath).getKeys(false)) {
|
||||
if (!epicBuckets.getConfig().isConfigurationSection(configPath + "." + key)) {
|
||||
for (String key : epicBuckets.getConfig().getConfigurationSection(epicBuckets.getConfigManager().getMenuItemsPath()).getKeys(false)) {
|
||||
if (!epicBuckets.getConfig().isConfigurationSection(epicBuckets.getConfigManager().getMenuItemsPath() + "." + key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
shopDatabase.put(epicBuckets.getConfig().getString(configPath + "." + key), new Shop(epicBuckets.getConfig().getString(configPath + "." + key), epicBuckets.getConfig().getString(configPath + "." + key + ".shop"), configPath + "." + key));
|
||||
shopDatabase.put(key, new Shop(key, epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getMenuItemsPath() + "." + key + ".shop"), epicBuckets.getConfigManager().getMenuItemsPath() + "." + key));
|
||||
}
|
||||
}
|
||||
|
||||
public String getConfigPath() {
|
||||
return configPath;
|
||||
public boolean hasEnoughFunds(Player buyer, SubShop s) {
|
||||
if (epicBuckets.getEcon().getBalance(Bukkit.getOfflinePlayer(buyer.getUniqueId())) >= s.getPrice()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void buyFromShop(Player buyer, SubShop s) {
|
||||
epicBuckets.getEcon().withdrawPlayer(Bukkit.getOfflinePlayer(buyer.getUniqueId()), s.getPrice());
|
||||
buyer.getInventory().addItem(s.getGenShopItem());
|
||||
}
|
||||
|
||||
public Collection<Shop> getShops() {
|
||||
return shopDatabase.values();
|
||||
}
|
||||
|
||||
public String getShopPath() {
|
||||
@ -115,4 +143,27 @@ public class ShopManager {
|
||||
return useBackButtons;
|
||||
}
|
||||
|
||||
public boolean isCloseAfterPurchase() {
|
||||
return closeAfterPurchase;
|
||||
}
|
||||
|
||||
public String getBulkInventoryName() {
|
||||
return bulkInventoryName;
|
||||
}
|
||||
|
||||
public int getBulkInventorySize() {
|
||||
return bulkInventorySize;
|
||||
}
|
||||
|
||||
public boolean isBulkFillInventory() {
|
||||
return bulkFillInventory;
|
||||
}
|
||||
|
||||
public int getBulkBackButtonSlot() {
|
||||
return bulkBackButtonSlot;
|
||||
}
|
||||
|
||||
public int getBulkMainItemSlot() {
|
||||
return bulkMainItemSlot;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.epicbuckets.shop;
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
||||
import com.songoda.epicbuckets.util.Validator;
|
||||
import com.songoda.epicbuckets.util.XMaterial;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -18,6 +19,7 @@ public class SubShop {
|
||||
|
||||
private ItemStack shopItem;
|
||||
private ItemStack genItem;
|
||||
private ItemStack genShopItem;
|
||||
|
||||
private Shop parent;
|
||||
private String item;
|
||||
@ -41,18 +43,20 @@ public class SubShop {
|
||||
|
||||
private void init() {
|
||||
FileConfiguration shops = EpicBuckets.getInstance().getConfigManager().getConfig("shops");
|
||||
subShopPath = epicBuckets.getShopManager().getShopPath() + "." + parent.getMenuItem() + "." + item;
|
||||
subShopPath = epicBuckets.getShopManager().getShopPath() + "." + parent.getShopName() + "." + item;
|
||||
|
||||
setEnabled(true);
|
||||
|
||||
loadData(shops);
|
||||
setupShopItem(shops);
|
||||
}
|
||||
|
||||
private void loadData(FileConfiguration shops) {
|
||||
boolean d = Validator.getInstance().isDouble(shops.getString(subShopPath + ".price"));
|
||||
price = Validator.price(shops.getString(subShopPath + ".price"));
|
||||
|
||||
if (!d) {
|
||||
if (price == -1.0) {
|
||||
epicBuckets.getDebugger().invalidPrice(subShopPath);
|
||||
enabled = false;
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
this.shopName = shops.getString(subShopPath + ".name");
|
||||
@ -61,17 +65,22 @@ public class SubShop {
|
||||
}
|
||||
|
||||
private void setupShopItem(FileConfiguration shops) {
|
||||
slot = Validator.getInstance().slot(shops.getString(subShopPath + ".slot"));
|
||||
boolean m = Validator.getInstance().isMaterial(shops.getString(subShopPath + ".icon"));
|
||||
boolean t = Validator.getInstance().isMaterial(shops.getString(subShopPath + ".type"));
|
||||
slot = Validator.slot(shops.getString(subShopPath + ".slot"));
|
||||
boolean m = Validator.isMaterial(shops.getString(subShopPath + ".icon"));
|
||||
boolean t = Validator.isMaterial(shops.getString(subShopPath + ".type"));
|
||||
|
||||
if (slot == -1) {
|
||||
epicBuckets.getDebugger().invalidSlot(subShopPath);
|
||||
enabled = false;
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
shopItem = ((!m) ? XMaterial.WATER_BUCKET.parseItem() : XMaterial.valueOf(shops.getString(subShopPath + ".icon")).parseItem());
|
||||
shopItem = InventoryHelper.setDisplayName(InventoryHelper.setLore(shopItem, getDescription()), getShopName());
|
||||
|
||||
genItem = ((!t) ? XMaterial.WATER_BUCKET.parseItem() : XMaterial.valueOf(shops.getString(subShopPath + ".type")).parseItem());
|
||||
|
||||
genShopItem = ((!m) ? XMaterial.WATER_BUCKET.parseItem() : XMaterial.valueOf(shops.getString(subShopPath + ".icon")).parseItem());
|
||||
genShopItem = InventoryHelper.setDisplayName(InventoryHelper.setLore(genShopItem, getGenItemLore()), getShopName());
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
@ -82,4 +91,39 @@ public class SubShop {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public ItemStack getShopItem() {
|
||||
return shopItem;
|
||||
}
|
||||
|
||||
public ItemStack getGenItem() {
|
||||
return genItem;
|
||||
}
|
||||
|
||||
public Shop getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
public double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public List<String> getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public List<String> getGenItemLore() {
|
||||
return genItemLore;
|
||||
}
|
||||
|
||||
public ItemStack getGenShopItem() {
|
||||
return genShopItem;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
package com.songoda.epicbuckets.util;
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class InventoryHelper {
|
||||
|
||||
public static int[] emptySlots(int size) {
|
||||
List<Integer> slots = new ArrayList<>();
|
||||
IntStream.range(0, size).forEach(slots::add);
|
||||
return slots.stream().mapToInt(i -> i).toArray();
|
||||
}
|
||||
|
||||
public static ItemStack setDisplayName(ItemStack item, String s) {
|
||||
ItemMeta im = item.getItemMeta();
|
||||
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', s));
|
||||
item.setItemMeta(im);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack setLore(ItemStack item, List<String> lore) {
|
||||
ItemMeta im = item.getItemMeta();
|
||||
List<String> newLore = new ArrayList<>();
|
||||
lore.forEach(s -> newLore.add(ChatColor.translateAlternateColorCodes('&', s)));
|
||||
im.setLore(newLore);
|
||||
item.setItemMeta(im);
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +1,19 @@
|
||||
package com.songoda.epicbuckets.util;
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||
|
||||
public class Validator {
|
||||
|
||||
static Validator instance = new Validator();
|
||||
|
||||
public static Validator getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private EpicBuckets epicBuckets = EpicBuckets.getInstance();
|
||||
|
||||
private Validator() {
|
||||
}
|
||||
|
||||
public int inventorySize(String s) {
|
||||
public static int inventorySize(String s) {
|
||||
int i;
|
||||
if (isInt(s)) {
|
||||
i = Integer.parseInt(s);
|
||||
if (i%9 == 0 && i<=54) return i;
|
||||
if (i<=6) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public GenbucketType genbucketType(String s) {
|
||||
public static GenbucketType genbucketType(String s) {
|
||||
try {
|
||||
return GenbucketType.valueOf(s);
|
||||
} catch (Exception e) {
|
||||
@ -33,7 +21,12 @@ public class Validator {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDouble(String s) {
|
||||
public static double price(String s) {
|
||||
if (isDouble(s)) return Double.parseDouble(s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static boolean isDouble(String s) {
|
||||
try {
|
||||
Double.parseDouble(s);
|
||||
return true;
|
||||
@ -42,7 +35,7 @@ public class Validator {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInt(String s) {
|
||||
public static boolean isInt(String s) {
|
||||
try {
|
||||
Integer.parseInt(s);
|
||||
return true;
|
||||
@ -51,7 +44,7 @@ public class Validator {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMaterial(String mat) {
|
||||
public static boolean isMaterial(String mat) {
|
||||
try {
|
||||
XMaterial.valueOf(mat);
|
||||
return true;
|
||||
@ -60,7 +53,7 @@ public class Validator {
|
||||
}
|
||||
}
|
||||
|
||||
public int slot(String s) {
|
||||
public static int slot(String s) {
|
||||
if (isInt(s)) return Integer.parseInt(s);
|
||||
return -1;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ MAX-ACTIVE-GEN-PER-PLAYER: 10 # Amount of gens a player can have active at time
|
||||
|
||||
PLACE-UNLIMTED-GENS: true # This will override MAX-ACTIVE-GEN-PER-PLAYER and let them place unlimted gens
|
||||
|
||||
MAX-VERTICAL-HEIGHT: 257 # Vertical gen height, the gen will stop if y > 256
|
||||
MAX-VERTICAL-HEIGHT: 256 # Vertical gen height, the gen will stop if y > 256
|
||||
|
||||
MAX-HORIZONTAL-LENGTH: 50 # Horizontal height
|
||||
|
||||
@ -65,24 +65,20 @@ FILL-ITEM:
|
||||
|
||||
name: " "
|
||||
|
||||
material: stained_glass_pane
|
||||
|
||||
damage: 15
|
||||
material: WHITE_STAINED_GLASS_PANE
|
||||
|
||||
BACK-BUTTON:
|
||||
|
||||
name: " &c&lReturn back to categories"
|
||||
|
||||
material: barrier
|
||||
|
||||
damage: 0
|
||||
material: BARRIER
|
||||
|
||||
|
||||
BULK-SHOP-INVENTORY:
|
||||
|
||||
inventory-name: "Bulk shop for {player}"
|
||||
|
||||
size: 54 # Must be one of these: 9, 18, 27, 36, 45, 54
|
||||
size: 5 # Number of lines in inventory
|
||||
|
||||
fill: false # recommended off
|
||||
|
||||
@ -92,17 +88,13 @@ BULK-SHOP-INVENTORY:
|
||||
|
||||
increase-item:
|
||||
|
||||
material: stained_glass_pane
|
||||
|
||||
damage: 5
|
||||
material: GREEN_STAINED_GLASS_PANE
|
||||
|
||||
slots: "24,25,26" # Put only three integers and separate with commas
|
||||
|
||||
decrease-item:
|
||||
|
||||
material: stained_glass_pane
|
||||
|
||||
damage: 14
|
||||
material: RED_STAINED_GLASS_PANE
|
||||
|
||||
slots: "18,19,20" # Put only three integers and separate with commas
|
||||
|
||||
@ -110,9 +102,7 @@ BULK-SHOP-INVENTORY:
|
||||
|
||||
name: "&a&lConfirm"
|
||||
|
||||
material: stained_glass
|
||||
|
||||
damage: 13
|
||||
material: YELLOW_STAINED_GLASS
|
||||
|
||||
slot: 40
|
||||
|
||||
@ -121,7 +111,7 @@ BULK-SHOP-INVENTORY:
|
||||
|
||||
MENU-ITEMS:
|
||||
|
||||
size: 27 # Must be one of these: 9, 18, 27, 36, 45, 54
|
||||
size: 3
|
||||
|
||||
fill: true # Fill inventory ?
|
||||
|
||||
@ -133,8 +123,6 @@ MENU-ITEMS:
|
||||
|
||||
material: WATER_BUCKET # material name
|
||||
|
||||
damage: 0 # also known as short
|
||||
|
||||
name: "&eVertical genbuckets" # Name of the item
|
||||
|
||||
lore: # Lore of the item
|
||||
@ -155,8 +143,6 @@ MENU-ITEMS:
|
||||
|
||||
material: WATER_BUCKET
|
||||
|
||||
damage: 0
|
||||
|
||||
name: "&eHorizontal genbuckets"
|
||||
|
||||
lore:
|
||||
@ -177,8 +163,6 @@ MENU-ITEMS:
|
||||
|
||||
material: WATER_BUCKET
|
||||
|
||||
damage: 0
|
||||
|
||||
name: "&eInfused genbuckets"
|
||||
|
||||
lore:
|
||||
@ -200,8 +184,6 @@ MENU-ITEMS:
|
||||
|
||||
material: WATER_BUCKET
|
||||
|
||||
damage: 0
|
||||
|
||||
name: "&ePsuedo genbuckets"
|
||||
|
||||
lore:
|
||||
|
@ -8,7 +8,7 @@ shops:
|
||||
|
||||
trait: "VERTICAL" # Which genbucket type does this shop have?
|
||||
|
||||
size: 36 # Must be one of these: 9, 18, 27, 36, 45, 54
|
||||
size: 4 # Number of lines in inventory
|
||||
|
||||
fill: true # Fill inventory ?
|
||||
|
||||
@ -22,14 +22,10 @@ shops:
|
||||
|
||||
type: "COBBLESTONE" # This is the material the bucket places
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 12 # This is the slot for the bucket in the GUI
|
||||
|
||||
price: 400 # This is the price for the bucket
|
||||
|
||||
damage: 0 # Material id if needed, for example if you want to spawn red wool in the guit
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -52,14 +48,10 @@ shops:
|
||||
|
||||
type: "SAND"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 13
|
||||
|
||||
price: 400
|
||||
|
||||
damage: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -82,14 +74,10 @@ shops:
|
||||
|
||||
type: "OBSIDIAN"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 14
|
||||
|
||||
price: 700
|
||||
|
||||
damage: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -110,7 +98,7 @@ shops:
|
||||
|
||||
trait: "INFUSED"
|
||||
|
||||
size: 36
|
||||
size: 4
|
||||
|
||||
fill: true
|
||||
|
||||
@ -124,16 +112,12 @@ shops:
|
||||
|
||||
type: "COBBLESTONE"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 12
|
||||
|
||||
price: 200
|
||||
|
||||
trait: "INFUSED"
|
||||
|
||||
material-id: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -156,16 +140,12 @@ shops:
|
||||
|
||||
type: "OBSIDIAN"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 13
|
||||
|
||||
price: 700
|
||||
|
||||
trait: "INFUSED"
|
||||
|
||||
material-id: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -189,16 +169,12 @@ shops:
|
||||
|
||||
type: "NETHERRACK"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 14
|
||||
|
||||
price: 31
|
||||
|
||||
trait: "INFUSED"
|
||||
|
||||
material-id: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -219,7 +195,7 @@ shops:
|
||||
|
||||
trait: "PSUEDO"
|
||||
|
||||
size: 36
|
||||
size: 4
|
||||
|
||||
fill: true
|
||||
|
||||
@ -233,14 +209,10 @@ shops:
|
||||
|
||||
type: "COBBLESTONE"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 12
|
||||
|
||||
price: 400
|
||||
|
||||
damage: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -263,14 +235,10 @@ shops:
|
||||
|
||||
type: "SAND"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 13
|
||||
|
||||
price: 400
|
||||
|
||||
damage: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -293,14 +261,10 @@ shops:
|
||||
|
||||
type: "OBSIDIAN"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 14
|
||||
|
||||
price: 700
|
||||
|
||||
damage: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -321,7 +285,7 @@ shops:
|
||||
|
||||
trait: "HORIZONTAL"
|
||||
|
||||
size: 36
|
||||
size: 4
|
||||
|
||||
fill: true
|
||||
|
||||
@ -335,14 +299,10 @@ shops:
|
||||
|
||||
type: "COBBLESTONE"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 12
|
||||
|
||||
price: 400
|
||||
|
||||
damage: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -365,14 +325,10 @@ shops:
|
||||
|
||||
type: "SAND"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 13
|
||||
|
||||
price: 400
|
||||
|
||||
damage: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
@ -395,14 +351,10 @@ shops:
|
||||
|
||||
type: "OBSIDIAN"
|
||||
|
||||
type-damage: 0 # Set a damage for the block the genbucket places
|
||||
|
||||
slot: 14
|
||||
|
||||
price: 700
|
||||
|
||||
damage: 0
|
||||
|
||||
description: # This is the lore of the bucket in the gui
|
||||
- ""
|
||||
- "&7&o((Left click to buy or right click to open bulk shop))"
|
||||
|
Loading…
Reference in New Issue
Block a user