This commit is contained in:
Brianna O'Keefe 2018-10-25 00:26:09 -04:00
parent 9518428831
commit 4a69d7bda5
33 changed files with 4177 additions and 0 deletions

11
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,11 @@
stages:
- build
build:
stage: build
image: maven:3.3.9-jdk-8
script: "mvn clean package"
artifacts:
name: "EpicBuckets"
paths:
- "/builds/Songoda/epicbuckets/target/*.jar"

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
Copyright (c) 2018 Brianna OKeefe
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software with minimal restriction, including the rights to use, copy, modify or merge while excluding the rights to publish, (re)distribute, sub-license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The same distribution rights and limitations above shall similarly apply to any and all source code, and other means that can be used to emulate this work.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

154
pom.xml Normal file
View File

@ -0,0 +1,154 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<groupId>com.songoda</groupId>
<artifactId>EpicBuckets</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>1</version>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>EpicAnchors-API/src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<version>3.6.1</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-shade-plugin</artifactId>-->
<!--<version>3.0.0</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<phase>package</phase>-->
<!--<goals>-->
<!--<goal>shade</goal>-->
<!--</goals>-->
<!--<configuration>-->
<!--<minimizeJar>true</minimizeJar>-->
<!--</configuration>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<sourceDirectory>src/main/java</sourceDirectory>
</build>
<repositories>
<repository>
<id>private</id>
<url>http://repo.songoda.com/repository/private</url>
</repository>
<repository>
<id>vault</id>
<url>http://repo.songoda.com/repository/vault</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2</version>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>arconix</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org</groupId>
<artifactId>kingdoms</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>me.ryanhamshire</groupId>
<artifactId>GriefPrevention</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>6.2.2</version>
</dependency>
<dependency>
<groupId>com</groupId>
<artifactId>plotsquared</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>com.palmergames.bukkit</groupId>
<artifactId>towny</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.wasteofplastic</groupId>
<artifactId>askyblock</artifactId>
<version>3.0.6.8</version>
</dependency>
<dependency>
<groupId>us.talabrek</groupId>
<artifactId>ultimateskyblock</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>me.markeh</groupId>
<artifactId>factionsframework</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>br.net.fabiozumbi12</groupId>
<artifactId>RedProtect</artifactId>
<version>7.3.0</version>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>epicspawners</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>factions</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>factionsuuid</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,140 @@
package com.songoda.epicbuckets;
import com.songoda.epicbuckets.commands.GenbucketAdminCommand;
import com.songoda.epicbuckets.commands.GenbucketCommand;
import com.songoda.epicbuckets.filehandler.files.MessageFile;
import com.songoda.epicbuckets.filehandler.files.ShopFile;
import com.songoda.epicbuckets.listeners.GenbucketPlaceListener;
import com.songoda.epicbuckets.listeners.InventoryClickListener;
import com.songoda.epicbuckets.util.ChatUtil;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public class EpicBuckets extends JavaPlugin {
public static EpicBuckets main;
private static Permission permission = null;
private static Economy economy = null;
private static Chat chat = null;
public MessageFile messageFile;
public ShopFile shopFile;
public static EpicBuckets getInstance() {
return main;
}
@Override
public void onEnable() {
main = this;
//new AntiPiracy().enable();
if (!isEnabled())
return;
setUpFiles();
setupPermissions();
setupEconomy();
setupChat();
setUpCommands();
registerListeners();
}
@Override
public void onDisable() {
main = null;
}
private void setUpFiles() {
if (!getDataFolder().exists()) {
getDataFolder().mkdirs();
getLogger().warning("Folder not found, generating files!");
saveResource("messages.yml", false);
saveResource("shops.yml", false);
saveDefaultConfig();
}
messageFile = new MessageFile();
shopFile = new ShopFile();
}
public double getBalance(Player player) {
return economy.getBalance(player);
}
public void withdrawBalance(Player player, int amount, boolean sendMessage) {
if (sendMessage)
player.sendMessage(ChatUtil.colorPrefix(messageFile.config.getString("WITHDRAW-MESSAGE")).replace("{amount}", String.valueOf(amount)));
economy.withdrawPlayer(player, amount);
}
private void setUpCommands() {
getCommand("genbucket").setExecutor(new GenbucketCommand());
getCommand("genbucketadmin").setExecutor(new GenbucketAdminCommand());
}
private void registerListeners() {
this.getServer().getPluginManager().registerEvents(new InventoryClickListener(), this);
this.getServer().getPluginManager().registerEvents(new GenbucketPlaceListener(), this);
}
public void reloadFiles() {
messageFile.load();
shopFile.load();
reloadConfig();
}
private boolean setupPermissions() {
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
if (permissionProvider != null) {
permission = permissionProvider.getProvider();
}
return (permission != null);
}
private boolean setupChat() {
RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
if (chatProvider != null) {
chat = chatProvider.getProvider();
}
return (chat != null);
}
private boolean setupEconomy() {
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
}
return (economy != null);
}
}

View File

@ -0,0 +1,356 @@
package com.songoda.epicbuckets.commands;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.genbuckets.GenbucketItem;
import com.songoda.epicbuckets.genbuckets.GenbucketManager;
import com.songoda.epicbuckets.inventories.InventoryManager;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.util.Util;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* GenbucketAdminCommand created by: SoFocused
* Date Created: oktober 06 2018
* Time created: 11:56
*/
public class GenbucketAdminCommand implements CommandExecutor {
private EpicBuckets plugin = EpicBuckets.getInstance();
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 0) {
if (!sender.hasPermission("genbucketadmin.command.help")) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("NO-PERMISSION")));
return true;
}
sender.sendMessage("§a/genbucketadmin info §8- §fPlugin information");
sender.sendMessage("§a/genbucketadmin admin §8- §fToggle admin mode");
sender.sendMessage("§a/genbucketadmin reload §8- §fReload the configs");
sender.sendMessage("§a/genbucketadmin toggleStatus §8- §fEnable/Disable genbuckets");
sender.sendMessage("§a/genbucketadmin toggleSponge §8- §fEnable/Disable sponges");
sender.sendMessage("§a/genbucketadmin toggleEnchant §8- §fToggle glowing genbuckets");
sender.sendMessage("§a/genbucketadmin toggleInfinity §8- §fToggle infinite genbuckets");
sender.sendMessage("§a/genbucketadmin activepanel §8- §fOpens a GUI");
sender.sendMessage("§a/genbucketadmin setHeight <int> §8- §fModify vertical height");
sender.sendMessage("§a/genbucketadmin setLength <int> §8- §fModify horizontal length");
sender.sendMessage("§a/genbucketadmin give <player> <shop> <key> <amount>");
return true;
}
if (args.length == 1) {
String permission = "genbucketadmin.command." + args[0];
if (args[0].equalsIgnoreCase("admin")) {
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatUtil.colorPrefix(EpicBuckets.getInstance().messageFile.config.getString("NO-PERMISSION")));
return true;
}
if (!(sender instanceof Player)) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("PLAYER-COMMAND")));
return true;
}
Player player = (Player) sender;
boolean isPlayerInAdminMode = GenbucketManager.adminList.contains(player.getUniqueId());
if (isPlayerInAdminMode) {
// Player is in admin mode
GenbucketManager.adminList.remove(player.getUniqueId());
player.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("ADMIN-TOGGLE-OFF")));
} else {
// Player is not in admin mode
GenbucketManager.adminList.add(player.getUniqueId());
player.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("ADMIN-TOGGLE-ON")));
}
return true;
}
if (args[0].equalsIgnoreCase("reload")) {
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatUtil.colorPrefix(EpicBuckets.getInstance().messageFile.config.getString("NO-PERMISSION")));
return true;
}
try {
EpicBuckets.getInstance().reloadFiles();
} catch (Exception e) {
sender.sendMessage(ChatUtil.colorPrefix(EpicBuckets.getInstance().messageFile.config.getString("ERROR-OCCURED")));
e.printStackTrace();
}
sender.sendMessage(ChatUtil.colorPrefix(EpicBuckets.getInstance().messageFile.config.getString("RELOAD-CONFIG")));
return true;
}
if (args[0].equalsIgnoreCase("activepanel")) {
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("NO-PERMISSION")));
return true;
}
if (!(sender instanceof Player)) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("PLAYER-COMMAND")));
return true;
}
Player player = (Player) sender;
InventoryManager inventoryManager = new InventoryManager();
inventoryManager.openActiveGenbuckets(player);
return true;
}
if (args[0].equalsIgnoreCase("toggleStatus")) {
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("NO-PERMISSION")));
return true;
}
boolean oldValue = Util.disableGenbuckets();
plugin.getConfig().set("DISABLE-GENBUCKETS", !oldValue);
toggleSetting(sender, "disable-genbuckets", oldValue);
return true;
}
if (args[0].equalsIgnoreCase("toggleInfinity")) {
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("NO-PERMISSION")));
return true;
}
boolean oldValue = Util.infiniteGenbuckets();
plugin.getConfig().set("INFINITE-USE", !oldValue);
plugin.saveConfig();
toggleSetting(sender, "INFINITE-USE", oldValue);
return true;
}
if (args[0].equalsIgnoreCase("toggleSponge")) {
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("NO-PERMISSION")));
return true;
}
boolean oldValue = Util.useSpongeSupport();
plugin.getConfig().set("USE-SPONGE-SUPPORT", !oldValue);
plugin.saveConfig();
toggleSetting(sender, "use-sponge-support", oldValue);
return true;
}
if (args[0].equalsIgnoreCase("info")) {
String spigotUserId = "%%__USER__%%";
String resourceId = "%%__RESOURCE__%%";
String uniqueDownload = "%%__NONCE__%%";
sender.sendMessage("§aName: §c" + EpicBuckets.getInstance().getDescription().getName());
sender.sendMessage("§aVersion: §c" + EpicBuckets.getInstance().getDescription().getVersion());
sender.sendMessage("§aDeveloper: §c" + EpicBuckets.getInstance().getDescription().getAuthors());
sender.sendMessage("§aSpigot ID: §c" + spigotUserId);
sender.sendMessage("§aResource ID: §c" + resourceId);
sender.sendMessage("§aUnique download ID: §c" + uniqueDownload);
sender.sendMessage("§aRegistered to: §fhttps://www.spigotmc.org/members/" + spigotUserId);
return true;
}
if (args[0].equalsIgnoreCase("toggleEnchant")) {
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("NO-PERMISSION")));
return true;
}
boolean oldValue = Util.enchantGenbuckets();
plugin.getConfig().set("ENCHANT", !oldValue);
plugin.saveConfig();
toggleSetting(sender, "enchant", oldValue);
return true;
}
} // END of args.length == 1
if (args.length == 2) {
String permission = "genbucketadmin.command." + args[0];
if (args[0].equalsIgnoreCase("setheight")) {
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("NO-PERMISSION")));
return true;
}
int height;
try {
height = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
return true;
}
plugin.getConfig().set("MAX-VERTICAL-HEIGHT", height);
toggleSetting(sender, "MAX-VERTICAL-HEIGHT", String.valueOf(height));
plugin.saveConfig();
return true;
}
if (args[0].equalsIgnoreCase("setlength")) {
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("NO-PERMISSION")));
return true;
}
int height;
try {
height = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
return true;
}
plugin.getConfig().set("MAX-HORIZONTAL-LENGTH", height);
plugin.saveConfig();
toggleSetting(sender, "MAX-HORIZONTAL-LENGTH", String.valueOf(height));
return true;
}
}
if (args.length == 5) {
String permission = "genbucketadmin.command." + args[0];
if (args[0].equalsIgnoreCase("give")) {
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("NO-PERMISSION")));
return true;
}
// /genbucketadmin give <player> <shop> <key> <amount>
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
if (!player.hasPlayedBefore()) {
sender.sendMessage("§cPlayer '" + args[1] + "' has never joined");
return true;
} else if (!player.isOnline()) {
sender.sendMessage("§cPlayer '" + player.getName() + "' is not online!");
return true;
}
int amount;
try {
amount = Integer.parseInt(args[4]);
} catch (NumberFormatException e) {
sender.sendMessage("§cPlease specify a number");
return true;
}
String shopName = args[2];
String key = args[3];
try {
GenbucketItem genbucketItem = new GenbucketItem(shopName, key);
genbucketItem.setAmount(amount);
player.getPlayer().getInventory().addItem(genbucketItem.getGenbucketItem());
sender.sendMessage("§7You sent §e" + genbucketItem.getAmount() + "x " + genbucketItem.getItemName() + "§7 genbucket(s) to §e" + player.getName());
} catch (NullPointerException e) {
sender.sendMessage("§cError while making the genbucket, are you sure you specified a valid shop name and a valid key (config section)?");
}
return true;
}
return false;
}
return false;
}
private void toggleSetting(CommandSender sender, String setting, boolean oldValue) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("SETTING-MODIFY").replace("{setting}", setting.toUpperCase()).replace("{value}", String.valueOf(!oldValue))));
}
private void toggleSetting(CommandSender sender, String setting, String oldValue) {
sender.sendMessage(ChatUtil.colorPrefix(plugin.messageFile.config.getString("SETTING-MODIFY").replace("{setting}", setting.toUpperCase()).replace("{value}", String.valueOf(oldValue))));
}
}

View File

@ -0,0 +1,40 @@
package com.songoda.epicbuckets.commands;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.inventories.InventoryManager;
import com.songoda.epicbuckets.util.ChatUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* GenbucketCommand created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 23:20
*/
public class GenbucketCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatUtil.colorPrefix(EpicBuckets.getInstance().messageFile.config.getString("PLAYER-COMMAND")));
return true;
}
if (!sender.hasPermission("genbucket.command")) {
sender.sendMessage(ChatUtil.colorPrefix(EpicBuckets.getInstance().messageFile.config.getString("NO-PERMISSION")));
return true;
}
Player player = (Player) sender;
InventoryManager inventoryManager = new InventoryManager();
inventoryManager.openMainInventory(player);
return true;
}
}

View File

@ -0,0 +1,74 @@
package com.songoda.epicbuckets.events;
import com.songoda.epicbuckets.genbuckets.GenbucketItem;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import java.util.UUID;
/**
* GenbucketPlaceEvent created by: SoFocused
* Date Created: oktober 05 2018
* Time created: 22:15
*/
public class GenbucketPlaceEvent extends Event implements Cancellable {
private static final HandlerList HANDLERS = new HandlerList();
private boolean isCancelled = false;
private Player player;
private Location location;
private BlockFace blockFace;
private GenbucketItem genbucketItem;
private UUID genbucketUUID;
public GenbucketPlaceEvent(Player player, Location location, BlockFace blockFace, GenbucketItem genbucketItem, UUID genbucketUUID) {
this.player = player;
this.location = location;
this.blockFace = blockFace;
this.genbucketItem = genbucketItem;
this.genbucketUUID = genbucketUUID;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
public Player getPlayer() {
return player;
}
public Location getLocation() {
return location;
}
public BlockFace getBlockFace() {
return blockFace;
}
public GenbucketItem getGenbucketItem() {
return genbucketItem;
}
public UUID getGenbucketUUID() {
return genbucketUUID;
}
public HandlerList getHandlers() {
return HANDLERS;
}
public boolean isCancelled() {
return this.isCancelled;
}
public void setCancelled(boolean isCancelled) {
this.isCancelled = isCancelled;
}
}

View File

@ -0,0 +1,51 @@
package com.songoda.epicbuckets.filehandler;
import com.songoda.epicbuckets.EpicBuckets;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
/**
* FileManager created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 22:56
*/
public class FileManager {
public FileConfiguration config;
private File file;
public FileManager(String filename) {
EpicBuckets main = EpicBuckets.getInstance();
this.file = new File(main.getDataFolder(), filename);
if (!this.file.exists()) {
try {
boolean b = this.file.createNewFile();
if (b)
main.getLogger().info(filename + " was successfully created");
} catch (IOException e) {
e.printStackTrace();
}
}
this.config = YamlConfiguration.loadConfiguration(this.file);
}
public void save() {
try {
this.config.save(this.file);
} catch (IOException e) {
e.printStackTrace();
}
}
public void load() {
this.config = YamlConfiguration.loadConfiguration(this.file);
}
}

View File

@ -0,0 +1,16 @@
package com.songoda.epicbuckets.filehandler.files;
import com.songoda.epicbuckets.filehandler.FileManager;
/**
* MessageFile created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 22:57
*/
public class MessageFile extends FileManager {
public MessageFile() {
super("messages.yml");
}
}

View File

@ -0,0 +1,16 @@
package com.songoda.epicbuckets.filehandler.files;
import com.songoda.epicbuckets.filehandler.FileManager;
/**
* ShopFile created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 23:58
*/
public class ShopFile extends FileManager {
public ShopFile() {
super("shops.yml");
}
}

View File

@ -0,0 +1,248 @@
package com.songoda.epicbuckets.genbuckets;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.regionhandlers.*;
import com.songoda.epicbuckets.util.ChatUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
/**
* Genbucket created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 21:51
*/
public abstract class Genbucket {
protected EpicBuckets main = EpicBuckets.getInstance();
private GenbucketType genbucketType;
public Genbucket(GenbucketType genbucketType) {
this.genbucketType = genbucketType;
}
public abstract void run();
public EpicBuckets getInstance() {
return main;
}
protected void genbucketFinished(Player player, UUID uuid) {
int a = GenbucketManager.getActiveGenBuckets(player);
if (a - 1 < 0)
GenbucketManager.setActiveGenBuckets(player, 0);
else
GenbucketManager.setActiveGenBuckets(player, a - 1);
if (GenbucketManager.activeGenbucketItems.containsKey(uuid))
GenbucketManager.activeGenbucketItems.remove(uuid);
if (GenbucketManager.activeGenbucketLocation.containsKey(uuid))
GenbucketManager.activeGenbucketLocation.remove(uuid);
}
protected boolean canPlace(Player player, Location location) {
boolean factionsCheck = RegionFactions.canBuild(player, location);
boolean factionsUUIDCheck = RegionFactions.canBuild(player, location);
boolean griefPreventionCheck = RegionGriefPrevention.canBuild(player, location);
boolean worldGuardCheck = RegionWorldGuard.canBuild(player, location);
boolean worldBorderCheck = RegionWBorder.isOutsideOfBorder(location);
//ChatUtil.debugMSG(player, factionsCheck, factionsUUIDCheck, griefPreventionCheck, worldGuardCheck, worldBorderCheck);
if (!factionsCheck || !factionsUUIDCheck || !griefPreventionCheck || !worldGuardCheck || worldBorderCheck) {
player.sendMessage(ChatUtil.colorPrefix(main.messageFile.config.getString("YOU-CANNOT-PLACE-HERE")));
return false;
}
return true;
}
protected boolean canPlace(Player player, Location location, boolean sendMessage) {
boolean factionsCheck = RegionFactions.canBuild(player, location);
boolean factionsUUIDCheck = RegionFactions.canBuild(player, location);
boolean griefPreventionCheck = RegionGriefPrevention.canBuild(player, location);
boolean worldGuardCheck = RegionWorldGuard.canBuild(player, location);
boolean worldBorderCheck = RegionWBorder.isOutsideOfBorder(location);
if (!factionsCheck || !factionsUUIDCheck || !griefPreventionCheck || !worldGuardCheck || worldBorderCheck) {
if (sendMessage)
player.sendMessage(ChatUtil.colorPrefix(main.messageFile.config.getString("YOU-CANNOT-PLACE-HERE")));
return false;
}
return true;
}
private void removeBucket(Player player, ItemStack item) {
int genBuckets = item.getAmount();
if (genBuckets > 1)
item.setAmount(genBuckets - 1);
else
player.getInventory().clear(player.getInventory().getHeldItemSlot());
player.updateInventory();
}
protected boolean canPlayerPlaceAGenbucket(Player player) {
if (GenbucketManager.getActiveGenBuckets(player) >= maxActiveGenForPlayer(player) + 1) {
player.sendMessage(ChatUtil.colorPrefix(main.messageFile.config.getString("YOU-MUST-WAIT")));
return false;
}
return true;
}
protected void notifyAdmins(Player target) {
for (UUID uuid : GenbucketManager.adminList) {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
if (!offlinePlayer.isOnline())
continue;
offlinePlayer.getPlayer().sendMessage(ChatUtil.colorPrefix(main.messageFile.config.getString("ADMIN-MESSAGE").replace("{player}", target.getName()).replace("{type}", genbucketType.toString().toLowerCase())));
}
}
protected boolean withdrawMoney(Player player, GenbucketItem item) {
boolean useInfinityGens = main.getConfig().getBoolean("INFINITE-USE");
if (!useInfinityGens) {
removeBucket(player, player.getInventory().getItem(player.getInventory().getHeldItemSlot()));
return true;
}
double playerBalance = main.getBalance(player);
if (playerBalance >= item.getPrice()) {
main.withdrawBalance(player, item.getPrice(), true);
return true;
} else {
player.sendMessage(ChatUtil.colorPrefix(main.messageFile.config.getString("NOT-ENOUGH-MONEY").replace("{money}", String.valueOf((playerBalance - item.getPrice()) * -1))));
return false;
}
}
private int maxActiveGenForPlayer(Player player) {
int maxActiveGenForPlayer = 0;
boolean foundValue = false;
for (String maxAmountString : main.getConfig().getConfigurationSection("CUSTOM-ACTIVE-GEN-PER-PLAY").getKeys(false)) {
String value[] = main.getConfig().getString("CUSTOM-ACTIVE-GEN-PER-PLAY." + maxAmountString).split(":");
if (!player.hasPermission(value[1]))
continue;
maxActiveGenForPlayer = Integer.valueOf(value[0]);
foundValue = true;
break;
}
if (!foundValue)
maxActiveGenForPlayer = main.getConfig().getInt("MAX-ACTIVE-GEN-PER-PLAYER");
//ChatUtil.debugMSG(player, maxActiveGenForPlayer, foundValue);
return maxActiveGenForPlayer;
}
protected boolean foundSponge(Location loc) {
boolean useSponge = main.getConfig().getBoolean("USE-SPONGE-SUPPORT");
if (!useSponge)
return false;
int radius = main.getConfig().getInt("SPONGE-RADIUS");
if (radius < 0)
return false;
for (double x = loc.getX() - radius; x < loc.getX() + radius; x++) {
for (double y = loc.getY() - radius; y < loc.getY() + radius; y++) {
for (double z = loc.getZ() - radius; z < loc.getZ() + radius; z++) {
Material materialAt = new Location(loc.getWorld(), x, y, z).getBlock().getType();
if (materialAt.equals(Material.SPONGE))
return true;
}
}
}
return false;
}
protected Block moveBlock(Block b, BlockFace blockFace, int length) {
switch (blockFace) {
case NORTH:
return b.getRelative(0, 0, -length);
case SOUTH:
return b.getRelative(0, 0, length);
case EAST:
return b.getRelative(length, 0, 0);
case WEST:
return b.getRelative(-length, 0, 0);
}
return null;
}
protected Block getLastBlockPlaced(Block b, BlockFace blockFace) {
switch (blockFace) {
case NORTH:
return b.getRelative(0, 0, -1);
case SOUTH:
return b.getRelative(0, 0, 1);
case EAST:
return b.getRelative(1, 0, 0);
case WEST:
return b.getRelative(-1, 0, 0);
}
return null;
}
}

View File

@ -0,0 +1,119 @@
package com.songoda.epicbuckets.genbuckets;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.util.ItemStackUtil;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
import java.util.List;
/**
* GenbucketItem created by: SoFocused
* Date Created: oktober 05 2018
* Time created: 12:00
*/
public class GenbucketItem {
private EpicBuckets main = EpicBuckets.main;
private String itemName;
private List<String> itemLore;
private List<String> itemSecondLore;
private Material icon;
private int typeDamage;
private Material type;
private GenbucketType genbucketType;
private int amount;
private int damage;
private int price;
public GenbucketItem(String shopName, String key) {
FileConfiguration config = EpicBuckets.getInstance().shopFile.config;
this.itemName = ChatUtil.colorString(config.getString("shops." + shopName + "." + key + ".name"));
this.price = config.getInt("shops." + shopName + "." + key + ".price");
this.icon = Material.valueOf(config.getString("shops." + shopName + "." + key + ".icon").toUpperCase());
this.typeDamage = config.getInt("shops." + shopName + "." + key + ".type-damage");
this.type = Material.valueOf(config.getString("shops." + shopName + "." + key + ".type").toUpperCase());
this.itemLore = ChatUtil.colorList(config.getStringList("shops." + shopName + "." + key + ".item-lore"));
this.itemSecondLore = ChatUtil.colorList(config.getStringList("shops." + shopName + "." + key + ".description"), type, price);
this.damage = config.getInt("shops." + shopName + "." + key + ".damage");
this.genbucketType = GenbucketType.valueOf(config.getString("shops." + shopName + ".trait").toUpperCase());
amount = 1;
}
public String getItemName() {
return itemName;
}
public List<String> getItemLore() {
return itemLore;
}
public void setItemLore(List<String> itemLore) {
this.itemLore = itemLore;
}
public GenbucketType getGenbucketType() {
return genbucketType;
}
public List<String> getItemSecondLore() {
return itemSecondLore;
}
public Material getType() {
return type;
}
public Material getIcon() {
return icon;
}
public int getDamage() {
return damage;
}
public int getPrice() {
return price;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
public int getVerticalHeight() {
return main.getConfig().getInt("MAX-VERTICAL-HEIGHT");
}
public byte getTypeDamage() {
return (byte) typeDamage;
}
public int getHorizontalLength() {
return main.getConfig().getInt("MAX-HORIZONTAL-LENGTH");
}
public ItemStack getGenbucketItem() {
return ItemStackUtil.createItemStack(getItemName(), getItemLore(), getIcon(), getAmount(), getDamage(), true);
}
}

View File

@ -0,0 +1,116 @@
package com.songoda.epicbuckets.genbuckets;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.util.InventoryUtil;
import com.songoda.epicbuckets.util.ItemStackUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.*;
/**
* GenbucketManager created by: SoFocused
* Date Created: oktober 05 2018
* Time created: 12:41
*/
public class GenbucketManager {
public static HashMap<UUID, Integer> playerInteger = new HashMap<>();
public static HashMap<UUID, Integer> activeGenBuckets = new HashMap<>();
public static HashMap<UUID, ItemStack> activeGenbucketItems = new HashMap<>();
public static HashMap<UUID, Location> activeGenbucketLocation = new HashMap<>();
public static List<UUID> adminList = new ArrayList<>();
public static int getPlayerInteger(Player player) {
return playerInteger.getOrDefault(player.getUniqueId(), 1);
}
public static void setPlayerInteger(Player player, int amount) {
playerInteger.put(player.getUniqueId(), amount);
}
public static int getActiveGenBuckets(Player player) {
return activeGenBuckets.getOrDefault(player.getUniqueId(), 1);
}
public static void setActiveGenBuckets(Player player, int amount) {
activeGenBuckets.put(player.getUniqueId(), amount);
}
public void openBulkShop(Player player, GenbucketItem genbucketItem) {
FileConfiguration config = EpicBuckets.getInstance().getConfig();
String inventoryName = ChatUtil.colorString(config.getString("BULK-SHOP-INVENTORY.inventory-name").replace("{player}", player.getName()));
int size = config.getInt("BULK-SHOP-INVENTORY.size");
Inventory inventory = Bukkit.createInventory(player, size, inventoryName);
int mainItemSlot = config.getInt("BULK-SHOP-INVENTORY.main-item-slot");
int itemAmount = getPlayerInteger(player);
genbucketItem.setAmount(itemAmount);
genbucketItem.setItemLore(genbucketItem.getItemSecondLore());
int returnBackItemSlot = config.getInt("BULK-SHOP-INVENTORY.return-back-slot");
String purchaseItemName = ChatUtil.colorString(config.getString("BULK-SHOP-INVENTORY.purchase-item.name"));
Material purchaseItemMaterial = Material.valueOf(config.getString("BULK-SHOP-INVENTORY.purchase-item.material").toUpperCase());
int purchaseItemDamage = config.getInt("BULK-SHOP-INVENTORY.purchase-item.damage");
int purchaseItemSlot = config.getInt("BULK-SHOP-INVENTORY.purchase-item.slot");
InventoryUtil.fillInventory(inventory, config.getBoolean("BULK-SHOP-INVENTORY.fill"));
InventoryUtil.setBackButton(inventory, returnBackItemSlot, true);
inventory.setItem(purchaseItemSlot, ItemStackUtil.createItemStack(purchaseItemName, Arrays.asList("&f"), purchaseItemMaterial, 1, purchaseItemDamage, false));
inventory.setItem(mainItemSlot, genbucketItem.getGenbucketItem());
loadAmountModifiers(inventory, "increase");
loadAmountModifiers(inventory, "decrease");
player.getOpenInventory().close();
player.openInventory(inventory);
}
private void loadAmountModifiers(Inventory inventory, String key) {
FileConfiguration config = EpicBuckets.getInstance().getConfig();
int x = 1;
String operator = key.equalsIgnoreCase("increase") ? "§a§l+ " : "§c§l- ";
Material material = Material.valueOf(config.getString("BULK-SHOP-INVENTORY.increase-item.material").toUpperCase());
int damage = config.getInt("BULK-SHOP-INVENTORY." + key + "-item.damage");
for (String str : config.getString("BULK-SHOP-INVENTORY." + key + "-item.slots").split(",")) {
int slot = Integer.parseInt(str);
inventory.setItem(slot, ItemStackUtil.createItemStack(operator + x, Arrays.asList("&f"), material, 1, damage, false));
if (x == 1)
x = 10;
else
x = 64;
}
}
}

View File

@ -0,0 +1,26 @@
package com.songoda.epicbuckets.genbuckets;
/**
* GenbucketType created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 21:40
*/
public enum GenbucketType {
HORIZONTAL("HORIZONTAL"),
INFUSED("INFUSED"),
PSUEDO("PSUEDO"),
VERTICAL("VERTICAL");
public final String name;
GenbucketType(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
}

View File

@ -0,0 +1,143 @@
package com.songoda.epicbuckets.genbuckets.types;
import com.songoda.epicbuckets.events.GenbucketPlaceEvent;
import com.songoda.epicbuckets.genbuckets.Genbucket;
import com.songoda.epicbuckets.genbuckets.GenbucketItem;
import com.songoda.epicbuckets.genbuckets.GenbucketManager;
import com.songoda.epicbuckets.genbuckets.GenbucketType;
import com.songoda.epicbuckets.regionhandlers.RegionWBorder;
import com.songoda.epicbuckets.util.ChatUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.UUID;
/**
* Horizontal created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 21:40
*/
public class Horizontal extends Genbucket {
private Location genbucketLocation;
private int movedBlocks = 1;
private Player player;
private BlockFace blockFace;
private GenbucketItem genbucketItem;
private UUID genbucketUUID;
public Horizontal(Player player, Location genbucketLocation, BlockFace blockFace, GenbucketItem genbucketItem) {
super(GenbucketType.HORIZONTAL);
this.genbucketLocation = genbucketLocation;
this.player = player;
this.blockFace = blockFace;
this.genbucketItem = genbucketItem;
this.genbucketUUID = UUID.randomUUID();
run();
}
@Override
public void run() {
if ("DOWN".equalsIgnoreCase(blockFace.name()) || "UP".equalsIgnoreCase(blockFace.name())) {
player.sendMessage(ChatUtil.colorPrefix(main.messageFile.config.getString("GENBUCKET-PLACED-WRONG").replace("{direction}", main.messageFile.config.getString("TRANSLATE-DIRECTION-SIDE")).replace("{genbucket}", ChatUtil.stripColor(genbucketItem.getItemName()))));
return;
}
if (!canPlace(player, genbucketLocation))
return;
if (!canPlayerPlaceAGenbucket(player))
return;
if (!withdrawMoney(player, genbucketItem))
return;
long delay = main.getConfig().getInt("DELAY");
// Now we can start spawning the blocks
notifyAdmins(player);
GenbucketPlaceEvent genbucketPlaceEvent = new GenbucketPlaceEvent(player, genbucketLocation, blockFace, genbucketItem, genbucketUUID);
Bukkit.getPluginManager().callEvent(genbucketPlaceEvent);
if (genbucketPlaceEvent.isCancelled())
return;
new BukkitRunnable() {
public void run() {
final Block block = moveBlock(genbucketLocation.getBlock(), blockFace, movedBlocks);
if (foundSponge(block.getLocation())) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (movedBlocks > genbucketItem.getHorizontalLength()) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (!canPlace(player, block.getLocation())) {
//ChatUtil.debugMSG(player, "done from canPlace()");
if (RegionWBorder.isOutsideOfBorder(block.getLocation())) {
if (blockFace.name().equalsIgnoreCase("SOUTH") ||
blockFace.name().equalsIgnoreCase("EAST"))
moveBlock(genbucketLocation.getBlock(), blockFace, movedBlocks - 1).setType(Material.AIR);
}
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
boolean run = main.getConfig().getStringList("IGNORE-MATERIALS").contains(block.getType().name());
if (run) {
//ChatUtil.debugMSG(player, genbucketItem.getType(), genbucketItem.getTypeDamage(), movedBlocks);
block.setType(genbucketItem.getType());
block.setData(genbucketItem.getTypeDamage());
movedBlocks++;
} else {
genbucketFinished(player, genbucketUUID);
this.cancel();
}
}
}.runTaskTimer(main, 0L, delay);
}
}

View File

@ -0,0 +1,224 @@
package com.songoda.epicbuckets.genbuckets.types;
import com.songoda.epicbuckets.events.GenbucketPlaceEvent;
import com.songoda.epicbuckets.genbuckets.Genbucket;
import com.songoda.epicbuckets.genbuckets.GenbucketItem;
import com.songoda.epicbuckets.genbuckets.GenbucketManager;
import com.songoda.epicbuckets.genbuckets.GenbucketType;
import com.songoda.epicbuckets.util.ChatUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.UUID;
/**
* Infused created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 21:40
*/
public class Infused extends Genbucket {
private Location genbucketLocation;
private int movedBlocks = 1;
private Player player;
private BlockFace blockFace;
private GenbucketItem genbucketItem;
private boolean runPillarOne = true;
private boolean runPillarTwo = true;
private UUID genbucketUUID;
/**
* Creating the class constructor for a Infused genbucket
*
* @param player the player who placed the genbucket
* @param genbucketLocation the location of where the genbucket was placed
* @param blockFace the blockface received from the {GenbucketPlaceListener#onRightClickBlock}
* @param genbucketItem the genbucket that was placed
*/
public Infused(Player player, Location genbucketLocation, BlockFace blockFace, GenbucketItem genbucketItem) {
super(GenbucketType.INFUSED);
this.blockFace = blockFace;
this.genbucketLocation = genbucketLocation;
this.genbucketItem = genbucketItem;
this.player = player;
this.genbucketUUID = UUID.randomUUID();
// Call this to run the genbucket
run();
}
@Override
public void run() {
if (!"UP".equalsIgnoreCase(blockFace.name())) {
player.sendMessage(ChatUtil.colorPrefix(main.messageFile.config.getString("GENBUCKET-PLACED-WRONG").replace("{direction}", main.messageFile.config.getString("TRANSLATE-DIRECTION-UP")).replace("{genbucket}", ChatUtil.stripColor(genbucketItem.getItemName()))));
return;
}
final Block[] blocks = getBlocks(genbucketLocation.getBlock(), blockFace, player);
final Block blockL = blocks[0];
final Block blockR = blocks[1];
if (!canPlace(player, blockL.getLocation()) || !canPlace(player, blockR.getLocation()))
return;
if (!canPlayerPlaceAGenbucket(player))
return;
if (!withdrawMoney(player, genbucketItem))
return;
long delay = main.getConfig().getInt("DELAY");
// Now we can start spawning the blocks
notifyAdmins(player);
GenbucketPlaceEvent genbucketPlaceEvent = new GenbucketPlaceEvent(player, genbucketLocation, blockFace, genbucketItem, genbucketUUID);
Bukkit.getPluginManager().callEvent(genbucketPlaceEvent);
if (genbucketPlaceEvent.isCancelled())
return;
new BukkitRunnable() {
public void run() {
Block blockOne = blocks[0].getLocation().subtract(0, movedBlocks - 1, 0).getBlock();
Block blockTwo = blocks[1].getLocation().subtract(0, movedBlocks - 1, 0).getBlock();
if (foundSponge(blockOne.getLocation()))
runPillarOne = false;
if (foundSponge(blockTwo.getLocation()))
runPillarTwo = false;
if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (movedBlocks > genbucketItem.getHorizontalLength()) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
boolean runFirst = main.getConfig().getStringList("IGNORE-MATERIALS").contains(blockOne.getType().name());
if (runPillarOne && runFirst && canPlace(player, blockOne.getLocation(), false)) {
blockOne.setType(genbucketItem.getType());
blockOne.setData(genbucketItem.getTypeDamage());
} else
runPillarOne = false;
boolean runSecond = main.getConfig().getStringList("IGNORE-MATERIALS").contains(blockTwo.getType().name());
if (runPillarTwo && runSecond && canPlace(player, blockTwo.getLocation(), false)) {
blockTwo.setType(genbucketItem.getType());
blockTwo.setData(genbucketItem.getTypeDamage());
} else
runPillarTwo = false;
movedBlocks++;
if (!canPlace(player, blockOne.getLocation(), true) && !canPlace(player, blockTwo.getLocation(), false)) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
Block nextBlockOne = blockOne.getLocation().clone().subtract(0, 1, 0).getBlock();
Block nextBlockTwo = blockTwo.getLocation().clone().subtract(0, 1, 0).getBlock();
boolean checkNextBlock = main.getConfig().getStringList("IGNORE-MATERIALS").contains(nextBlockOne.getType().name());
boolean checkNextBlock_ = main.getConfig().getStringList("IGNORE-MATERIALS").contains(nextBlockTwo.getType().name());
if (!checkNextBlock && !checkNextBlock_ || !runPillarOne && !runPillarTwo) {
//ChatUtil.debugMSG(player, nextBlockOne.getType().name(), nextBlockTwo.getType().name());
genbucketFinished(player, genbucketUUID);
this.cancel();
}
}
}.runTaskTimer(main, 0L, delay);
}
private Block[] getBlocks(Block block, BlockFace blockFace, Player player) {
if ("NORTH".equalsIgnoreCase(blockFace.name()) || "SOUTH".equalsIgnoreCase(blockFace.name())) {
Block b1 = block.getRelative(blockFace, 1); // Left
Block b2 = block.getRelative(blockFace, -1); // Right
return new Block[]{b1, b2};
} else if ("EAST".equalsIgnoreCase(blockFace.name()) || "WEST".equalsIgnoreCase(blockFace.name())) {
Location loc1 = block.getLocation();
Location loc2 = block.getLocation();
loc1.setX(loc1.getX() + 1);
loc2.setX(loc1.getX() - 2);
Block b1 = loc1.getBlock();
Block b2 = loc2.getBlock();
return new Block[]{b1, b2};
}
if ("e".equalsIgnoreCase(getDirection(player)) || "w".equalsIgnoreCase(getDirection(player))) {
Location getLeftSide = new Location(player.getWorld(), block.getX(), block.getY(), block.getZ() + 1);
Location getRightSide = new Location(player.getWorld(), block.getX(), block.getY(), block.getZ() - 1);
return new Block[]{getLeftSide.getBlock(), getRightSide.getBlock()};
} else if (!"e".equalsIgnoreCase(getDirection(player)) || !"w".equalsIgnoreCase(getDirection(player)) && getDirection(player) != null) {
Location getLeftSide = new Location(player.getWorld(), block.getX() + 1, block.getY(), block.getZ());
Location getRightSide = new Location(player.getWorld(), block.getX() - 1, block.getY(), block.getZ());
return new Block[]{getLeftSide.getBlock(), getRightSide.getBlock()};
}
return null;
}
private String getDirection(Player player) {
double rot = (player.getLocation().getYaw() - 180) % 360;
if (rot < 0) {
rot += 360.0;
}
if (0 <= rot && rot < 22.5) {
return "N";
} else if (67.5 <= rot && rot < 112.5) {
return "E";
} else if (157.5 <= rot && rot < 202.5) {
return "S";
} else if (247.5 <= rot && rot < 292.5) {
return "W";
} else if (337.5 <= rot && rot < 360.0) {
return "N";
} else {
return null;
}
}
}

View File

@ -0,0 +1,195 @@
package com.songoda.epicbuckets.genbuckets.types;
import com.songoda.epicbuckets.events.GenbucketPlaceEvent;
import com.songoda.epicbuckets.genbuckets.Genbucket;
import com.songoda.epicbuckets.genbuckets.GenbucketItem;
import com.songoda.epicbuckets.genbuckets.GenbucketManager;
import com.songoda.epicbuckets.genbuckets.GenbucketType;
import com.songoda.epicbuckets.util.ChatUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.UUID;
/**
* PsuedoVertical created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 21:40
*/
public class PsuedoVertical extends Genbucket {
private Location genbucketLocation;
private int movedBlocks = 1;
private Player player;
private BlockFace blockFace;
private GenbucketItem genbucketItem;
private UUID genbucketUUID;
/**
* Creating the class constructor for a PsuedoVertical genbucket
*
* @param player the player who placed the genbucket
* @param genbucketLocation the location of where the genbucket was placed
* @param blockFace the blockface received from the {GenbucketPlaceListener#onRightClickBlock}
* @param genbucketItem the genbucket that was placed
*/
public PsuedoVertical(Player player, Location genbucketLocation, BlockFace blockFace, GenbucketItem genbucketItem) {
super(GenbucketType.PSUEDO);
this.genbucketLocation = genbucketLocation;
this.player = player;
this.blockFace = blockFace;
this.genbucketItem = genbucketItem;
this.genbucketUUID = UUID.randomUUID();
// Call this to run the genbucket
run();
}
@Override
public void run() {
// Get the material the player clicked the genbucket on
final Material clickedMaterial = genbucketLocation.getBlock().getType();
boolean validMaterial = false;
// This is a list of allowed material from the config
List<String> materialList = main.getConfig().getStringList("PSUEDO-MATERIALS");
// In the for loop we simply check if the material is
// valid if it is then validMaterial is set to true
for (String string : materialList) {
if (string.toUpperCase().equalsIgnoreCase(genbucketItem.getType().name().toUpperCase()))
validMaterial = true;
}
// If the material isn't valid we tell the player and stop the code
if (!validMaterial || !clickedMaterial.equals(genbucketItem.getType())) {
player.sendMessage(ChatUtil.colorPrefix(main.messageFile.config.getString("WRONG-MATERIAL-PSUEDO")));
return;
}
// Region support
if (!canPlace(player, genbucketLocation))
return;
// This checks if the player can place more
// genbuckets or if he has placed max
if (!canPlayerPlaceAGenbucket(player))
return;
// Tries to withdrawMoney, if successful then it
// returns true
if (!withdrawMoney(player, genbucketItem))
return;
// Delay from config
long delay = main.getConfig().getInt("DELAY");
// Now we can start spawning the blocks
// If any admins (or players with permission) has enabled the
// admin mode we will notify them
notifyAdmins(player);
// Call in the {@link GenbucketPlaceEvent}
GenbucketPlaceEvent genbucketPlaceEvent = new GenbucketPlaceEvent(player, genbucketLocation, blockFace, genbucketItem, genbucketUUID);
Bukkit.getPluginManager().callEvent(genbucketPlaceEvent);
if (genbucketPlaceEvent.isCancelled())
return;
new BukkitRunnable() {
public void run() {
final Block block = genbucketLocation.clone().subtract(0, movedBlocks, 0).getBlock();
if (foundSponge(block.getLocation())) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (foundSponge(block.getLocation())) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (movedBlocks > genbucketItem.getVerticalHeight()) {
//if (block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.SAND) || block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.GRAVEL))
//block.setType(Material.AIR);
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (!canPlace(player, block.getLocation())) {
//ChatUtil.debugMSG(player, "done from canPlace()");
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (block.getType().equals(Material.AIR) || block.getType().equals(Material.WATER) || block.getType().equals(Material.STATIONARY_WATER)
|| block.getType().equals(Material.LAVA) || block.getType().equals(Material.STATIONARY_LAVA)) {
block.setType(genbucketItem.getType());
block.setData(genbucketItem.getTypeDamage());
} else {
List<String> materialList = main.getConfig().getStringList("PSUEDO-MATERIALS");
boolean validMaterial = false;
for (String string : materialList) {
if (string.toUpperCase().equalsIgnoreCase(genbucketItem.getType().name().toUpperCase()))
validMaterial = true;
}
if (!validMaterial || !block.getType().equals(clickedMaterial)) {
//ChatUtil.debugMSG(player, "Last block: " + block.getType(), "Material:" + genbucketItem.getType());
genbucketFinished(player, genbucketUUID);
this.cancel();
}
//ChatUtil.debugMSG(player, block.getType().name(), validMaterial, movedBlocks);
}
movedBlocks++;
}
}.runTaskTimer(main, 0L, delay);
}
}

View File

@ -0,0 +1,378 @@
package com.songoda.epicbuckets.genbuckets.types;
import com.songoda.epicbuckets.events.GenbucketPlaceEvent;
import com.songoda.epicbuckets.genbuckets.Genbucket;
import com.songoda.epicbuckets.genbuckets.GenbucketItem;
import com.songoda.epicbuckets.genbuckets.GenbucketManager;
import com.songoda.epicbuckets.genbuckets.GenbucketType;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.UUID;
/**
* Vertical created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 21:39
*/
public class Vertical extends Genbucket {
private Location genbucketLocation;
private int movedBlocks = 1;
private Player player;
private BlockFace blockFace;
private GenbucketItem genbucketItem;
private UUID genbucketUUID;
private long delay = main.getConfig().getInt("DELAY");
/**
* Creating the class constructor for a Vertical genbucket
*
* @param player the player who placed the genbucket
* @param genbucketLocation the location of where the genbucket was placed
* @param blockFace the blockface received from the {GenbucketPlaceListener#onRightClickBlock}
* @param genbucketItem the genbucket that was placed
*/
public Vertical(Player player, Location genbucketLocation, BlockFace blockFace, GenbucketItem genbucketItem) {
super(GenbucketType.VERTICAL);
this.genbucketLocation = genbucketLocation;
this.player = player;
this.blockFace = blockFace;
this.genbucketItem = genbucketItem;
this.genbucketUUID = UUID.randomUUID();
// Call this to run the genbucket
run();
}
@Override
public void run() {
if (!canPlace(player, genbucketLocation))
return;
if (!canPlayerPlaceAGenbucket(player))
return;
if (!withdrawMoney(player, genbucketItem))
return;
// Now we can start spawning the blocks
notifyAdmins(player);
GenbucketPlaceEvent genbucketPlaceEvent = new GenbucketPlaceEvent(player, genbucketLocation, blockFace, genbucketItem, genbucketUUID);
Bukkit.getPluginManager().callEvent(genbucketPlaceEvent);
if (genbucketPlaceEvent.isCancelled())
return;
/**
* Compared to the other genbuckets the veritcal genbucket
* can be placed in 3 different locations. Therefore, we cannot
* use the same method as we've done with the other genbuckettypes.
*/
switch (blockFace) {
case DOWN:
directionDown();
break;
case UP:
directionUP();
break;
default:
directionSide();
break;
}
}
private void directionSide() {
final Block firstBlock = getLastBlockPlaced(genbucketLocation.getBlock(), blockFace);
// This is needed to stop sand/gravel genbuckets
// to destroy bedrock
if (firstBlock.getLocation().getBlockY() <= 1)
return;
new BukkitRunnable() {
public void run() {
final Block block = firstBlock.getLocation().clone().subtract(0, movedBlocks - 1, 0).getBlock();
if (foundSponge(block.getLocation())) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (movedBlocks > genbucketItem.getVerticalHeight()) {
if (block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.SAND) || block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.GRAVEL))
block.setType(Material.AIR);
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (!canPlace(player, block.getLocation())) {
//ChatUtil.debugMSG(player, "done from canPlace()");
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
boolean run = main.getConfig().getStringList("IGNORE-MATERIALS").contains(block.getType().name());
if (!run && genbucketItem.getType().equals(Material.SAND) || !run && genbucketItem.getType().equals(Material.GRAVEL) || run) {
//ChatUtil.debugMSG(player, genbucketItem.getType(), genbucketItem.getTypeDamage(), movedBlocks);
if (genbucketItem.getType().equals(Material.SAND) || genbucketItem.getType().equals(Material.GRAVEL)) {
block.setType(genbucketItem.getType());
Block block_ = block.getLocation().clone().subtract(0, 1, 0).getBlock();
block_.setType(Material.COBBLESTONE);
Block blockUnderCobbleStone = block.getLocation().clone().subtract(0, 2, 0).getBlock();
boolean ignoreBlock = main.getConfig().getStringList("IGNORE-MATERIALS").contains(blockUnderCobbleStone.getType().name());
if (!ignoreBlock) {
block_.setType(genbucketItem.getType());
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
} else {
block.setType(genbucketItem.getType());
block.setData(genbucketItem.getTypeDamage());
}
} else {
block.setType(genbucketItem.getType());
block.setData(genbucketItem.getTypeDamage());
}
movedBlocks++;
} else {
//ChatUtil.debugMSG(player, "Last block: " + block.getType(), "Material:" + genbucketItem.getType());
genbucketFinished(player, genbucketUUID);
this.cancel();
}
}
}.runTaskTimer(main, 0L, delay);
}
private void directionUP() {
new BukkitRunnable() {
public void run() {
final Block block = genbucketLocation.clone().add(0, movedBlocks, 0).getBlock();
if (foundSponge(block.getLocation())) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (movedBlocks > genbucketItem.getVerticalHeight() || block.getY() >= 257) {
if (block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.SAND) || block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.GRAVEL))
block.setType(Material.AIR);
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (!canPlace(player, block.getLocation())) {
//ChatUtil.debugMSG(player, "done from canPlace()");
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
boolean run = main.getConfig().getStringList("IGNORE-MATERIALS").contains(block.getType().name());
if (!run && genbucketItem.getType().equals(Material.SAND) || !run && genbucketItem.getType().equals(Material.GRAVEL) || run) {
//ChatUtil.debugMSG(player, genbucketItem.getType(), genbucketItem.getTypeDamage(), movedBlocks);
if (genbucketItem.getType().equals(Material.SAND) || genbucketItem.getType().equals(Material.GRAVEL)) {
block.setType(genbucketItem.getType());
Block block_ = block.getLocation().clone().add(0, 1, 0).getBlock();
block_.setType(Material.COBBLESTONE);
Block blockUnderCobbleStone = block.getLocation().clone().add(0, 2, 0).getBlock();
boolean ignoreBlock = main.getConfig().getStringList("IGNORE-MATERIALS").contains(blockUnderCobbleStone.getType().name());
if (!ignoreBlock) {
block_.setType(genbucketItem.getType());
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
} else {
block.setType(genbucketItem.getType());
block.setData(genbucketItem.getTypeDamage());
}
} else {
block.setType(genbucketItem.getType());
block.setData(genbucketItem.getTypeDamage());
}
movedBlocks++;
} else {
//ChatUtil.debugMSG(player, "Last block: " + block.getType(), "Material:" + genbucketItem.getType());
genbucketFinished(player, genbucketUUID);
this.cancel();
}
}
}.runTaskTimer(main, 0L, delay);
}
private void directionDown() {
// This is needed to stop sand/gravel genbuckets
// to destroy bedrock
if (genbucketLocation.getBlockY() <= 3)
return;
new BukkitRunnable() {
public void run() {
final Block block = genbucketLocation.clone().subtract(0, movedBlocks, 0).getBlock();
if (foundSponge(block.getLocation())) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) {
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (movedBlocks > genbucketItem.getVerticalHeight()) {
if (block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.SAND) || block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.GRAVEL))
block.setType(Material.AIR);
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
if (!canPlace(player, block.getLocation())) {
//ChatUtil.debugMSG(player, "done from canPlace()");
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
}
boolean run = main.getConfig().getStringList("IGNORE-MATERIALS").contains(block.getType().name());
if (!run && genbucketItem.getType().equals(Material.SAND) || !run && genbucketItem.getType().equals(Material.GRAVEL) || run) {
//ChatUtil.debugMSG(player, genbucketItem.getType(), genbucketItem.getTypeDamage(), movedBlocks);
if (genbucketItem.getType().equals(Material.SAND) || genbucketItem.getType().equals(Material.GRAVEL)) {
block.setType(genbucketItem.getType());
Block block_ = block.getLocation().clone().subtract(0, 1, 0).getBlock();
block_.setType(Material.COBBLESTONE);
Block blockUnderCobbleStone = block.getLocation().clone().subtract(0, 2, 0).getBlock();
boolean ignoreBlock = main.getConfig().getStringList("IGNORE-MATERIALS").contains(blockUnderCobbleStone.getType().name());
if (!ignoreBlock) {
block_.setType(genbucketItem.getType());
genbucketFinished(player, genbucketUUID);
this.cancel();
return;
} else {
block.setType(genbucketItem.getType());
block.setData(genbucketItem.getTypeDamage());
}
} else {
block.setType(genbucketItem.getType());
block.setData(genbucketItem.getTypeDamage());
}
movedBlocks++;
} else {
//ChatUtil.debugMSG(player, "Last block: " + block.getType(), "Material:" + genbucketItem.getType());
genbucketFinished(player, genbucketUUID);
this.cancel();
}
}
}.runTaskTimer(main, 0L, delay);
}
}

View File

@ -0,0 +1,192 @@
package com.songoda.epicbuckets.inventories;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.genbuckets.GenbucketManager;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.util.InventoryUtil;
import com.songoda.epicbuckets.util.ItemStackUtil;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
* InventoryManager created by: SoFocused
* Date Created: oktober 03 2018
* Time created: 16:24
*/
public class InventoryManager {
public void openMainInventory(Player player) {
FileConfiguration config = EpicBuckets.getInstance().getConfig();
boolean fillInventory = config.getBoolean("MENU-ITEMS.fill");
int size = config.getInt("MENU-ITEMS.size");
String inventoryName = ChatUtil.colorString(config.getString("MENU-ITEMS.inventory-name"));
Inventory inventory = Bukkit.createInventory(null, size, inventoryName);
InventoryUtil.fillInventory(inventory, fillInventory);
for (String key : config.getConfigurationSection("MENU-ITEMS").getKeys(false)) {
// Check if the key has the item category if not just skip
if (!config.contains("MENU-ITEMS." + key + ".item"))
continue;
// Now we know that we might have a possible item!
setBucketInMainGUI(inventory, "MENU-ITEMS.", key);
}
player.getOpenInventory().close();
player.openInventory(inventory);
}
public void loadSubInventory(Player player, String shopName) {
FileConfiguration config = EpicBuckets.getInstance().shopFile.config;
String inventoryName = ChatUtil.colorString(config.getString("shops." + shopName + ".inventory-name"));
int inventorySize = config.getInt("shops." + shopName + ".size");
boolean fillInventory = config.getBoolean("shops." + shopName + ".fill");
boolean useBackButton = config.getBoolean("use-back-buttons");
int backButtonSlot = config.getInt("shops." + shopName + ".goBackButton");
Inventory inventory = Bukkit.createInventory(null, inventorySize, inventoryName);
InventoryUtil.fillInventory(inventory, fillInventory);
InventoryUtil.setBackButton(inventory, backButtonSlot, useBackButton);
// Load in the buckets
for (String key : config.getConfigurationSection("shops." + shopName).getKeys(false)) {
// Make sure our key / path has a type in it
if (!config.contains("shops." + shopName + "." + key + ".type"))
continue;
// Now we can "safely" load in the genbucket
setBucketInSubGUI(inventory, shopName, key);
}
player.getOpenInventory().close();
player.openInventory(inventory);
}
private void setBucketInSubGUI(Inventory inventory, String shopName, String key) {
FileConfiguration config = EpicBuckets.getInstance().shopFile.config;
String name = ChatUtil.colorString(config.getString("shops." + shopName + "." + key + ".name"));
int price = config.getInt("shops." + shopName + "." + key + ".price");
Material icon = Material.valueOf(config.getString("shops." + shopName + "." + key + ".icon").toUpperCase());
Material type = Material.valueOf(config.getString("shops." + shopName + "." + key + ".type").toUpperCase());
List<String> lore = ChatUtil.colorList(config.getStringList("shops." + shopName + "." + key + ".description"), type, price);
int damage = config.getInt("shops." + shopName + "." + key + ".damage");
int slot = config.getInt("shops." + shopName + "." + key + ".slot");
inventory.setItem(slot, ItemStackUtil.createItemStack(name, lore, icon, 1, damage, true));
}
private void setBucketInMainGUI(Inventory inventory, String path, String key) {
FileConfiguration config = EpicBuckets.getInstance().getConfig();
String itemName = config.getString(path + key + ".item.name");
List<String> itemLore = config.getStringList(path + key + ".item.lore");
Material m = Material.valueOf(config.getString(path + key + ".item.material").toUpperCase());
int damage = config.getInt(path + key + ".item.damage");
int slot = config.getInt(path + key + ".slot");
ItemStack itemStack = ItemStackUtil.createItemStack(itemName, itemLore, m, 1, damage, true);
inventory.setItem(slot, itemStack);
}
public void openActiveGenbuckets(Player player) {
Inventory inventory = Bukkit.createInventory(null, 54, "Active genbuckets");
int i = 0;
for (UUID uuid : GenbucketManager.activeGenbucketItems.keySet()) {
inventory.setItem(i, GenbucketManager.activeGenbucketItems.get(uuid));
i++;
if (i == 54)
break;
}
inventory.setItem(53, ItemStackUtil.createItemStack("§a§lNext page", Arrays.asList("§7Current page 1"), Material.ARROW, 1, 0, true));
player.getOpenInventory().close();
player.openInventory(inventory);
}
public void loadNextInventory(Inventory inventory) {
int page = Integer.parseInt(ChatUtil.stripColor(inventory.getItem(53).getItemMeta().getLore().get(0).split(" ")[2])) + 1;
inventory.clear();
int i = 0;
int slot = 0;
for (UUID uuid : GenbucketManager.activeGenbucketItems.keySet()) {
i++;
if (i < 53 * page)
continue;
if (slot > 52)
break;
inventory.setItem(slot, GenbucketManager.activeGenbucketItems.get(uuid));
slot++;
}
inventory.setItem(53, ItemStackUtil.createItemStack("§a§lNext page", Arrays.asList("§7Current page " + page), Material.ARROW, 1, 0, true));
}
}

View File

@ -0,0 +1,200 @@
package com.songoda.epicbuckets.listeners;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.events.GenbucketPlaceEvent;
import com.songoda.epicbuckets.genbuckets.GenbucketItem;
import com.songoda.epicbuckets.genbuckets.GenbucketManager;
import com.songoda.epicbuckets.genbuckets.types.Horizontal;
import com.songoda.epicbuckets.genbuckets.types.Infused;
import com.songoda.epicbuckets.genbuckets.types.PsuedoVertical;
import com.songoda.epicbuckets.genbuckets.types.Vertical;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.util.ItemStackUtil;
import com.songoda.epicbuckets.util.Util;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.List;
/**
* GenbucketPlaceListener created by: SoFocused
* Date Created: oktober 05 2018
* Time created: 16:06
*/
public class GenbucketPlaceListener implements Listener {
private EpicBuckets plugin = EpicBuckets.getInstance();
// We have to do a double for loop to find the genbucket
// don't think this is going to be a big issue but eehhh
@EventHandler
public void onPlayerBucketEmptyEvent(PlayerBucketEmptyEvent event) {
FileConfiguration config = plugin.shopFile.config;
final Player player = event.getPlayer();
GenbucketItem genbucketItem;
ItemStack itemStack = player.getInventory().getItem(player.getInventory().getHeldItemSlot());
if (!itemStack.hasItemMeta())
return;
for (String path : config.getConfigurationSection("shops").getKeys(false)) {
for (String key : config.getConfigurationSection("shops." + path).getKeys(false)) {
if (!config.contains("shops." + path + "." + key + ".icon"))
continue;
genbucketItem = new GenbucketItem(path, key);
Material itemMaterial = itemStack.getType();
String itemName = ChatUtil.stripColor(itemStack.getItemMeta().getDisplayName());
List<String> itemLore = itemStack.getItemMeta().getLore();
if (!genbucketItem.getIcon().equals(itemMaterial))
continue;
if (!ChatUtil.stripColor(genbucketItem.getItemName()).equalsIgnoreCase(itemName))
continue;
if (!itemLore.equals(genbucketItem.getItemLore()))
continue;
event.setCancelled(true);
player.updateInventory();
event.getBlockClicked().getRelative(event.getBlockFace()).getState().update();
event.getBlockClicked().getState().update();
break;
}
}
}
@EventHandler
public void onRightClickBlock(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getItem() == null)
return;
if (!event.getItem().hasItemMeta())
return;
final Player player = event.getPlayer();
Block clickedBlock = event.getClickedBlock();
FileConfiguration config = plugin.shopFile.config;
boolean foundGenbucket = false;
GenbucketItem genbucketItem = null;
for (String path : config.getConfigurationSection("shops").getKeys(false)) {
if (foundGenbucket)
break;
for (String key : config.getConfigurationSection("shops." + path).getKeys(false)) {
if (!config.contains("shops." + path + "." + key + ".icon"))
continue;
genbucketItem = new GenbucketItem(path, key);
Material itemMaterial;
String itemName;
List<String> itemLore;
try {
itemMaterial = event.getItem().getType();
itemName = ChatUtil.stripColor(event.getItem().getItemMeta().getDisplayName());
itemLore = event.getItem().getItemMeta().getLore();
} catch (NullPointerException e) {
continue;
}
if (!genbucketItem.getIcon().equals(itemMaterial))
continue;
if (!ChatUtil.stripColor(genbucketItem.getItemName()).equalsIgnoreCase(itemName))
continue;
if (!itemLore.equals(genbucketItem.getItemLore()))
continue;
foundGenbucket = true;
event.setCancelled(true);
break;
}
}
if (!foundGenbucket)
return;
if (!player.hasPermission("genbucket.place")) {
player.sendMessage(ChatUtil.colorPrefix(EpicBuckets.getInstance().messageFile.config.getString("NO-PERMISSION")));
return;
}
if (Util.disableGenbuckets()) {
player.sendMessage(ChatUtil.colorPrefix(EpicBuckets.getInstance().messageFile.config.getString("GENBUCKET-DISABLED")));
player.updateInventory();
return;
}
switch (genbucketItem.getGenbucketType()) {
case PSUEDO:
new PsuedoVertical(player, clickedBlock.getLocation(), event.getBlockFace(), genbucketItem);
break;
case INFUSED:
new Infused(player, clickedBlock.getLocation(), event.getBlockFace(), genbucketItem);
break;
case VERTICAL:
new Vertical(player, clickedBlock.getLocation(), event.getBlockFace(), genbucketItem);
break;
case HORIZONTAL:
new Horizontal(player, clickedBlock.getLocation(), event.getBlockFace(), genbucketItem);
break;
}
player.updateInventory();
}
@EventHandler
public void onGenbucketPlace(GenbucketPlaceEvent event) {
ItemStack item = ItemStackUtil.createItemStack("§7" + event.getGenbucketUUID().toString(), Arrays.asList("", "§7Information:", " §eLeft click: §6Teleport to location", " §eRight click: §6Stop genbucket", " §ePlaced by §6SoFocused", " §eCordinates: §6" + ChatUtil.getCoordinatesFromLocation(event.getLocation()), " §eMaterial: §6" + event.getGenbucketItem().getType(), " §eDamage: §6" + event.getGenbucketItem().getTypeDamage()), Material.STAINED_GLASS_PANE, 1, 13, true);
GenbucketManager.activeGenbucketItems.put(event.getGenbucketUUID(), item);
GenbucketManager.activeGenbucketLocation.put(event.getGenbucketUUID(), event.getLocation());
if (!plugin.getConfig().getBoolean("PLACE-UNLIMTED-GENS"))
GenbucketManager.setActiveGenBuckets(event.getPlayer(), GenbucketManager.getActiveGenBuckets(event.getPlayer()) + 1);
}
}

View File

@ -0,0 +1,412 @@
package com.songoda.epicbuckets.listeners;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.genbuckets.GenbucketItem;
import com.songoda.epicbuckets.genbuckets.GenbucketManager;
import com.songoda.epicbuckets.inventories.InventoryManager;
import com.songoda.epicbuckets.util.ChatUtil;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.Map;
import java.util.UUID;
import java.util.WeakHashMap;
/**
* InventoryClickListener created by: SoFocused
* Date Created: oktober 03 2018
* Time created: 21:15
*/
public class InventoryClickListener implements Listener {
private EpicBuckets main = EpicBuckets.main;
private Map<UUID, String> shopMap = new WeakHashMap<>();
// Main inventory
@EventHandler
public void onClick(InventoryClickEvent event) {
String inventoryTitle = ChatUtil.stripColor(main.getConfig().getString("MENU-ITEMS.inventory-name"));
String clickedInventoryTitle = ChatColor.stripColor(event.getInventory().getTitle());
if (!clickedInventoryTitle.equalsIgnoreCase(inventoryTitle))
return;
if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals(Material.AIR))
return;
if (!event.getCurrentItem().hasItemMeta())
return;
event.setCancelled(true);
// I'm guessing the fastest way to find it is to check if the
// slot is in the config.yml itself?
int slot = event.getSlot();
FileConfiguration config = EpicBuckets.getInstance().getConfig();
Player player = (Player) event.getWhoClicked();
for (String key : config.getConfigurationSection("MENU-ITEMS").getKeys(false)) {
// Check if the key has the item category if not just skip
if (!config.contains("MENU-ITEMS." + key + ".slot"))
continue;
int configSlot = config.getInt("MENU-ITEMS." + key + ".slot");
if (slot == configSlot) {
// Now we know that the slot they clicked
// was found in the config!
String shopName = config.getString("MENU-ITEMS." + key + ".shop");
InventoryManager inventoryManager = new InventoryManager();
inventoryManager.loadSubInventory(player, shopName);
}
}
}
// Sub inventories
@EventHandler
public void onClickSubInventory(InventoryClickEvent event) {
FileConfiguration config = main.shopFile.config;
String clickedInventory = ChatUtil.stripColor(event.getInventory().getTitle());
boolean foundInventory = false;
String shopName = "";
for (String key : config.getConfigurationSection("shops").getKeys(false)) {
String inventoryName = ChatUtil.stripColor(config.getString("shops." + key + ".inventory-name"));
if (!clickedInventory.equalsIgnoreCase(inventoryName))
continue;
foundInventory = true;
shopName = key;
break;
}
if (!foundInventory || shopName.equalsIgnoreCase(""))
return;
event.setCancelled(true);
Player player = (Player) event.getWhoClicked();
int slot = event.getSlot();
int goBackButton = config.getInt("shops." + shopName + ".goBackButton");
boolean useBackButton = config.getBoolean("use-back-buttons");
// Player clicked on the back button
if (useBackButton && slot == goBackButton) {
player.getOpenInventory().close();
player.performCommand("genbucket");
return;
}
// They did not click on the back button so we
// have to check if they're trying to purchase
// a genbucket
// Loop thru all slots in the shops config to see
// if it equals with a genbucket
// Left click to buy or right click to open stacked shop
for (String key : config.getConfigurationSection("shops." + shopName).getKeys(false)) {
if (!config.contains("shops." + shopName + "." + key + ".slot"))
continue;
int configSlot = config.getInt("shops." + shopName + "." + key + ".slot");
if (configSlot != slot)
continue;
// I can init & declare because I know I have the
// necessary data
GenbucketItem genbucketItem = new GenbucketItem(shopName, key);
// Buy a singular genbucket
if (event.getClick().equals(ClickType.LEFT)) {
purchaseGenbucket(player, 1, genbucketItem);
} else {
// Open the multiple gui shop
final boolean infinite_gens = main.getConfig().getBoolean("INFINITE-USE");
if (infinite_gens) {
return;
}
shopMap.put(player.getUniqueId(), shopName + ":" + key);
GenbucketManager genbucketManager = new GenbucketManager();
genbucketManager.openBulkShop(player, genbucketItem);
}
break;
}
}
@EventHandler
public void onClickBulkShop(InventoryClickEvent event) {
FileConfiguration config = EpicBuckets.getInstance().getConfig();
String inventoryName = ChatUtil.stripColor(config.getString("BULK-SHOP-INVENTORY.inventory-name").replace("{player}", event.getWhoClicked().getName()));
String clickedInventoryName = ChatUtil.stripColor(event.getInventory().getTitle());
if (!inventoryName.equalsIgnoreCase(clickedInventoryName))
return;
if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals(Material.AIR))
return;
if (!event.getCurrentItem().hasItemMeta())
return;
event.setCancelled(true);
// Lets first check if they're trying to increase/decrease the amount
Player player = (Player) event.getWhoClicked();
// We have to case this to avoid NPE
if (!shopMap.containsKey(player.getUniqueId())) {
player.getOpenInventory().close();
return;
}
int clickedSlot = event.getSlot();
int returnBackItemSlot = config.getInt("BULK-SHOP-INVENTORY.return-back-slot");
int purchaseItemSlot = config.getInt("BULK-SHOP-INVENTORY.purchase-item.slot");
if (ArrayUtils.contains(modifySlotList(), clickedSlot)) {
modifyValue(event.getInventory(), player, event.getCurrentItem());
} else if (clickedSlot == returnBackItemSlot) {
player.getOpenInventory().close();
String[] genbucketDetails = shopMap.get(player.getUniqueId()).split(":");
InventoryManager inventoryManager = new InventoryManager();
inventoryManager.loadSubInventory(player, genbucketDetails[0]);
} else if (clickedSlot == purchaseItemSlot) {
String[] genbucketDetails = shopMap.get(player.getUniqueId()).split(":");
GenbucketItem genbucketItem = new GenbucketItem(genbucketDetails[0], genbucketDetails[1]);
purchaseGenbucket(player, GenbucketManager.getPlayerInteger(player), genbucketItem);
}
}
@EventHandler
public void onClickActGbInventory(InventoryClickEvent event) {
if (!event.getInventory().getTitle().equalsIgnoreCase("Active genbuckets"))
return;
if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals(Material.AIR))
return;
if (!event.getCurrentItem().hasItemMeta())
return;
event.setCancelled(true);
if (event.getSlot() == 53) {
InventoryManager inventoryManager = new InventoryManager();
inventoryManager.loadNextInventory(event.getInventory());
return;
}
UUID uuid = UUID.fromString(ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName()));
Player player = (Player) event.getWhoClicked();
ClickType clickType = event.getClick();
if (clickType.equals(ClickType.LEFT)) {
// Teleport
player.teleport(GenbucketManager.activeGenbucketLocation.get(uuid).clone().add(0, 50, 0));
player.sendMessage("§a§lTeleporting...");
} else {
GenbucketManager.activeGenbucketItems.remove(uuid);
event.getInventory().clear(event.getSlot());
player.sendMessage("§c§lStopping...");
}
}
private void modifyValue(Inventory inventory, Player player, ItemStack itemStack) {
boolean addition = ChatUtil.stripColor(itemStack.getItemMeta().getDisplayName().split(" ")[0]).equalsIgnoreCase("+");
int value = Integer.parseInt(itemStack.getItemMeta().getDisplayName().split(" ")[1]);
int oldAmount = GenbucketManager.getPlayerInteger(player);
int newAmount;
if (addition) {
newAmount = oldAmount + value;
if (newAmount > 64)
newAmount = newAmount - (newAmount - 64);
GenbucketManager.setPlayerInteger(player, newAmount);
} else {
newAmount = oldAmount - value;
if (newAmount == 0)
newAmount = 1;
else if (newAmount < 0)
newAmount = oldAmount - (oldAmount - 1);
GenbucketManager.setPlayerInteger(player, newAmount);
}
FileConfiguration config = main.getConfig();
int mainItemSlot = config.getInt("BULK-SHOP-INVENTORY.main-item-slot");
inventory.getItem(mainItemSlot).setAmount(GenbucketManager.getPlayerInteger(player));
player.updateInventory();
}
private int[] modifySlotList() {
FileConfiguration config = main.getConfig();
int[] modifyValueSlots = new int[6];
for (int i = 0; i < config.getString("BULK-SHOP-INVENTORY.increase-item.slots").split(",").length; i++)
modifyValueSlots[i] = Integer.parseInt(config.getString("BULK-SHOP-INVENTORY.increase-item.slots").split(",")[i]);
int x = 3;
for (int i = 0; i < config.getString("BULK-SHOP-INVENTORY.decrease-item.slots").split(",").length; i++) {
if (modifyValueSlots[x] == 0)
modifyValueSlots[x] = Integer.parseInt(config.getString("BULK-SHOP-INVENTORY.decrease-item.slots").split(",")[i]);
x++;
}
return modifyValueSlots;
}
private void purchaseGenbucket(Player player, int amount, GenbucketItem genbucketItem) {
if (player.getInventory().firstEmpty() == -1) {
player.sendMessage(ChatUtil.colorPrefix(main.messageFile.config.getString("INVENTORY-FULL")));
return;
}
int price = genbucketItem.getPrice() * amount;
double playerBalance = main.getBalance(player);
final boolean infinite_gens = main.getConfig().getBoolean("INFINITE-USE");
if (infinite_gens) {
player.getInventory().addItem(genbucketItem.getGenbucketItem());
return;
}
if (playerBalance >= price) {
// they have enough money
main.withdrawBalance(player, price, true);
genbucketItem.setAmount(amount);
player.getInventory().addItem(genbucketItem.getGenbucketItem());
} else {
// they have less money
player.sendMessage(ChatUtil.colorPrefix(main.messageFile.config.getString("NOT-ENOUGH-MONEY").replace("{money}", String.valueOf((playerBalance - price) * -1))));
}
boolean closeGUI = main.getConfig().getBoolean("CLOSE-GUI-AFTER-PURCHASE");
if (closeGUI)
player.getOpenInventory().close();
}
}

View File

@ -0,0 +1,36 @@
package com.songoda.epicbuckets.regionhandlers;
import com.songoda.epicbuckets.EpicBuckets;
import me.markeh.factionsframework.entities.FPlayers;
import me.markeh.factionsframework.entities.Faction;
import org.bukkit.Location;
import org.bukkit.entity.Player;
/**
* FactionsUUID created by: SoFocused
* Date Created: oktober 05 2018
* Time created: 18:00
*/
public class RegionFactions {
public static boolean canBuild(Player player, Location location) {
boolean isFactionsUUIDEnabled = EpicBuckets.getInstance().getConfig().getBoolean("FACTIONS-SUPPORT");
if (!isFactionsUUIDEnabled)
return true;
Faction factionAt = me.markeh.factionsframework.entities.Factions.getFactionAt(location);
boolean enableGensInWilderness = EpicBuckets.getInstance().getConfig().getBoolean("ENABLE-GENS-IN-WILDERNESS");
if (factionAt.isNone()) {
return enableGensInWilderness;
}
return false;
}
}

View File

@ -0,0 +1,38 @@
package com.songoda.epicbuckets.regionhandlers;
import com.songoda.epicbuckets.EpicBuckets;
import org.bukkit.Location;
import org.bukkit.entity.Player;
/**
* GriefPrevention created by: SoFocused
* Date Created: oktober 05 2018
* Time created: 18:00
*/
public class RegionGriefPrevention {
public static me.ryanhamshire.GriefPrevention.GriefPrevention getGriefPrevention() {
org.bukkit.plugin.Plugin pl = EpicBuckets.getInstance().getServer().getPluginManager().getPlugin("GriefPrevention");
if (pl == null) {
EpicBuckets.getInstance().getLogger().warning("GriefPrevention support is enabled but cannot find the plugin");
return null;
}
return (me.ryanhamshire.GriefPrevention.GriefPrevention) pl;
}
public static boolean canBuild(Player player, Location location) {
boolean isGriefPreventionEnabled = EpicBuckets.getInstance().getConfig().getBoolean("griefprevention-support");
// If we don't check for griefprevention, just let them place
if (!isGriefPreventionEnabled)
return true;
return getGriefPrevention().allowBreak(player, location.getBlock(), location) != null;
}
}

View File

@ -0,0 +1,27 @@
package com.songoda.epicbuckets.regionhandlers;
import com.songoda.epicbuckets.EpicBuckets;
import org.bukkit.Location;
import org.bukkit.WorldBorder;
/**
* WBorder created by: SoFocused
* Date Created: oktober 05 2018
* Time created: 22:06
*/
public class RegionWBorder {
public static boolean isOutsideOfBorder(Location loc) {
if (EpicBuckets.getInstance().getServer().getVersion().contains("1.7"))
return true;
WorldBorder border = loc.getWorld().getWorldBorder();
double size = border.getSize() / 2;
Location center = border.getCenter();
double x = loc.getX() - center.getX(), z = loc.getZ() - center.getZ();
return ((x > size || (-x) > size) || (z > size || (-z) > size));
}
}

View File

@ -0,0 +1,47 @@
package com.songoda.epicbuckets.regionhandlers;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.songoda.epicbuckets.EpicBuckets;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
/**
* WorldGuard created by: SoFocused
* Date Created: oktober 05 2018
* Time created: 18:00
*/
public class RegionWorldGuard {
public static WorldGuardPlugin getWorldGuard() {
// WorldGuard may not be loaded
Plugin plugin = EpicBuckets.getInstance().getServer().getPluginManager().getPlugin("WorldGuard");
if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
return null; // Maybe you want throw an exception instead
}
return (WorldGuardPlugin) plugin;
}
public static boolean canBuild(Player player, Location loc) {
boolean isWorldGuardEnabled = EpicBuckets.getInstance().getConfig().getBoolean("WORLDGUARD-SUPPORT");
if (!isWorldGuardEnabled)
return true;
RegionManager regionManager = getWorldGuard().getRegionManager(player.getLocation().getWorld());
ApplicableRegionSet set = regionManager.getApplicableRegions(loc);
for (ProtectedRegion region : set) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,93 @@
package com.songoda.epicbuckets.util;
import com.songoda.epicbuckets.EpicBuckets;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.StringJoiner;
/**
* ChatUtil created by: SoFocused
* Date Created: oktober 02 2018
* Time created: 22:54
*/
public class ChatUtil {
public static String colorPrefix(String msg) {
return ChatColor.translateAlternateColorCodes('&', getPrefix() + msg);
}
public static String colorString(String msg) {
return ChatColor.translateAlternateColorCodes('&', msg);
}
public static List<String> colorList(List<String> list) {
List<String> newList = new ArrayList<>();
list.forEach(string -> newList.add(colorString(string)));
return newList;
}
public static List<String> colorList(List<String> list, Material material, int price) {
List<String> newList = new ArrayList<>();
list.forEach(string -> newList.add(colorString(string.replace("{material}", properMaterialName(material).toLowerCase()).replace("{price}", String.valueOf(price)))));
return newList;
}
public static String stripColor(String input) {
return ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', input));
}
public static String getPrefix() {
return EpicBuckets.getInstance().messageFile.config.getString("PREFIX").equals("none") ? "" : EpicBuckets.getInstance().messageFile.config.getString("PREFIX") + " ";
}
public static void debugMSG(Player player, Object... args) {
StringJoiner stringBuilder = new StringJoiner("§8:");
for (int i = 0; i < args.length; i++)
stringBuilder.add("§a" + args[i].toString());
player.sendMessage(stringBuilder.toString());
}
public static String getCoordinatesFromLocation(Location l) {
return "X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ();
}
public static String properMaterialName(Material material) {
String materialName;
if (material.name().split("_").length > 1) {
StringJoiner stringJoiner = new StringJoiner(" ");
for (String str : material.name().split("_"))
stringJoiner.add(str);
materialName = stringJoiner.toString();
} else
materialName = material.name();
return materialName;
}
}

View File

@ -0,0 +1,63 @@
package com.songoda.epicbuckets.util;
import com.songoda.epicbuckets.EpicBuckets;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
/**
* InventoryUtil created by: SoFocused
* Date Created: oktober 03 2018
* Time created: 16:25
*/
public class InventoryUtil {
public static EpicBuckets plugin = EpicBuckets.getInstance();
public static ItemStack getFillItemStack() {
FileConfiguration config = plugin.getConfig();
Material m = Material.valueOf(config.getString("FILL-ITEM.material").toUpperCase());
int damage = config.getInt("FILL-ITEM.damage");
return ItemStackUtil.createItemStack(config.getString("FILL-ITEM.name"), Arrays.asList("&f"), m, 1, damage, false);
}
private static ItemStack getBackItemStack() {
FileConfiguration config = plugin.getConfig();
Material m = Material.valueOf(config.getString("BACK-BUTTON.material").toUpperCase());
int damage = config.getInt("BACK-BUTTON.damage");
return ItemStackUtil.createItemStack(config.getString("BACK-BUTTON.name"), Arrays.asList("&f"), m, 1, damage, false);
}
public static void fillInventory(Inventory inventory, boolean fillInventory) {
if (!fillInventory)
return;
for (int i = 0; i < inventory.getSize(); i++)
inventory.setItem(i, getFillItemStack());
}
public static void setBackButton(Inventory inventory, int slot, boolean setItem) {
if (setItem)
inventory.setItem(slot, getBackItemStack());
}
}

View File

@ -0,0 +1,43 @@
package com.songoda.epicbuckets.util;
import com.songoda.epicbuckets.EpicBuckets;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
/**
* ItemStackUtil created by: SoFocused
* Date Created: oktober 03 2018
* Time created: 16:26
*/
public class ItemStackUtil {
public static ItemStack createItemStack(String name, List<String> lore, Material m, int amount, int i, boolean enchantItem) {
ItemStack itemStack = new ItemStack(m, amount, (short) i);
ItemMeta itemMeta = itemStack.getItemMeta();
if (name != null)
itemMeta.setDisplayName(ChatUtil.colorString(name));
if (lore != null)
itemMeta.setLore(ChatUtil.colorList(lore));
if (enchantItem) {
itemMeta.addEnchant(Enchantment.DURABILITY, 1, false);
if (!EpicBuckets.getInstance().getServer().getVersion().contains("1.7"))
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemStack.setItemMeta(itemMeta);
return itemStack;
}
}

View File

@ -0,0 +1,28 @@
package com.songoda.epicbuckets.util;
import com.songoda.epicbuckets.EpicBuckets;
/**
* Util created by: SoFocused
* Date Created: oktober 06 2018
* Time created: 12:24
*/
public class Util {
public static boolean disableGenbuckets() {
return EpicBuckets.getInstance().getConfig().getBoolean("DISABLE-GENBUCKETS");
}
public static boolean useSpongeSupport() {
return EpicBuckets.getInstance().getConfig().getBoolean("USE-SPONGE-SUPPORT");
}
public static boolean enchantGenbuckets() {
return EpicBuckets.getInstance().getConfig().getBoolean("ENCHANT");
}
public static boolean infiniteGenbuckets() {
return EpicBuckets.getInstance().getConfig().getBoolean("INFINITE-USE");
}
}

View File

@ -0,0 +1,217 @@
###############################################
# EpicBuckets #
# Made by Songoda #
###############################################
# All config files can be found on
# https://www.spigotmc.org/resources/ezbucket-1-7-1-12-region-support-gui-horizontal-vertical-and-infused-gens-genbucket.50944/
FACTIONS-SUPPORT: false # MassiveCore and Factions/FactionsUUID/SavageFactions is needed
WORLDGUARD-SUPPORT: false # WorldEdit and WorldGuard is needed
GRIEFPREVENTION-SUPPORT: false # GriefPrevention is needed
ENABLE-GENS-IN-WILDERNESS: true
ENCHANT: false # Enchant genbuckets in all guis
CLOSE-GUI-AFTER-PURCHASE: false # Close the inventory after purchase
INFINITE-USE: false # If enabled, you won't lose a genbucket when you place it down
USE-SPONGE-SUPPORT: false # If a sponge is found it will stop the genbucket
SPONGE-RADIUS: 3 # <- SPONGE-RADIUS 3 == 3x3. I do not recommending putting this higher than 3
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-HORIZONTAL-LENGTH: 50 # Horizontal height
DELAY: 10 # If delay is set to 20 it will place one block every second. 10 will place two blocks each second
DISABLE-GENBUCKETS: false # If enabled placing any genbuckets wont be placeable
CUSTOM-ACTIVE-GEN-PER-PLAY: # Put the highest first
# Everyone with the permission genbucket.limit.god
# will be able to place 30 instead of the default value (MAX-ACTIVE-GEN-PER-PLAYER)
GOD: "30:genbucket.limit.god"
VETERAN: "25:genbucket.limit.veteran"
VIP: "20:genbucket.limit.vip"
# All genbuckets will run over these materials
# except the psuedo.
# Make all words capital!
IGNORE-MATERIALS:
- "AIR" # <- Don't remove unless you know what you're doing
- "SNOW"
- "LONG_GRASS"
- "DEAD_BUSH"
- "YELLOW_FLOWER"
- "DOUBLE_PLANT"
- "RED_ROSE"
PSUEDO-MATERIALS: # Which materials should the psuedo genbucket work on?
- "cobblestone"
- "sand"
- "obsidian"
FILL-ITEM:
name: " "
material: stained_glass_pane
damage: 15
BACK-BUTTON:
name: " &c&lReturn back to categories"
material: barrier
damage: 0
BULK-SHOP-INVENTORY:
inventory-name: "Bulk shop for {player}"
size: 54 # Must be one of these: 9, 18, 27, 36, 45, 54
fill: false # recommended off
return-back-slot: 49
main-item-slot: 22
increase-item:
material: stained_glass_pane
damage: 5
slots: "24,25,26" # Put only three integers and separate with commas
decrease-item:
material: stained_glass_pane
damage: 14
slots: "18,19,20" # Put only three integers and separate with commas
purchase-item:
name: "&a&lConfirm"
material: stained_glass
damage: 13
slot: 40
# All material names can be found @ https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
MENU-ITEMS:
size: 27 # Must be one of these: 9, 18, 27, 36, 45, 54
fill: true # Fill inventory ?
inventory-name: "Select a category"
'1': # Must be unique
item: # Item configuration
material: WATER_BUCKET # material name
damage: 0 # also known as short
name: "&eVertical genbuckets" # Name of the item
lore: # Lore of the item
- ""
- "&7&o(( Click to open shop ))"
- ""
- "&7Use vertical genbuckets to create"
- "&7vertical walls fast and efficient"
- ""
shop: "vertical" # make a shop in shops.yml
slot: 10 # slot in the gui
'2':
item:
material: WATER_BUCKET
damage: 0
name: "&eHorizontal genbuckets"
lore:
- ""
- "&7&o(( Click to open shop ))"
- ""
- "&7Use horizontal genbuckets to create"
- "&7roofs & floors fast and efficient"
- ""
shop: "horizontal"
slot: 12 # slot in the gui
'3':
item:
material: WATER_BUCKET
damage: 0
name: "&eInfused genbuckets"
lore:
- ""
- "&7&o(( Click to open shop ))"
- ""
- "&7Use infused genbuckets to place"
- "&7vertical walls on each side of the"
- "&7block"
- ""
shop: "infused"
slot: 14 # slot in the gui
'4':
item:
material: WATER_BUCKET
damage: 0
name: "&ePsuedo genbuckets"
lore:
- ""
- "&7&o(( Click to open shop ))"
- ""
- "&7Use psuedo genbuckets to repair"
- "&7broken walls"
- ""
shop: "psuedo"
slot: 16 # slot in the gui

View File

@ -0,0 +1,31 @@
PREFIX: "&e&lEZBUCKET>" # set to "none" if you don't want a prefix
NO-PERMISSION: "&7You do not have &epermission &7for this command"
PLAYER-COMMAND: "&c&lOnly players can use this"
ERROR-OCCURED: "&cAn error occurred, please contact an administrator"
RELOAD-CONFIG: "&7You've reloaded the config"
WITHDRAW-MESSAGE: "&e${amount}&7 was taken from your &eaccount&7!"
NOT-ENOUGH-MONEY: "&7You need &e${money} &7more to purchase this genbucket!"
INVENTORY-FULL: "&7Your inventory is &efull&7!"
YOU-CANNOT-PLACE-HERE: "&7You're not &eallowed&7 to place a genbucket here!"
YOU-MUST-WAIT: "&7You must &ewait&7 before your other gen(s) finishes!"
ADMIN-TOGGLE-ON: "&7You have toggled admin-mode &aon"
ADMIN-TOGGLE-OFF: "&7You have toggled admin-mode &coff"
ADMIN-MESSAGE: "&e{player} &7placed a &e{type} genbucket&7!"
WRONG-MATERIAL-PSUEDO: "&7You cannot use this genbucket on this &eblock!"
GENBUCKET-DISABLED: "&eGenbuckets &7are currently disabled!"
GENBUCKET-PLACED-WRONG: "&e{genbucket} &7can be placed {direction}" # {side} equals to TRANSLATE-DIRECTION-X
TRANSLATE-DIRECTION-UP: "on top of blocks"
TRANSLATE-DIRECTION-SIDE: "on the side of blocks"
SETTING-MODIFY: "&7You've set &e{setting}&7 to &e{value}"

View File

@ -0,0 +1,16 @@
name: EpicBuckets
version: 1
description: Generate walls fast and efficient with beautiful guis!
author: Songoda
main: club.sofocused.ezbucket.plugin.Plugin
softdepend: [WorldGuard, WorldEdit, Factions, MassiveCore, FactionsUUID, GriefPrevention]
depend: [Vault]
commands:
genbucket:
description: Open genbucket shop
aliases: [gb, gen, genbuckets, ezbucket, genshop]
usage: "/gb"
genbucketadmin:
description: Admin commands
aliases: [gbadmin, genadmin, genbucketadmin, ezbucketadmin]
usage: "/genbucketadmin"

View File

@ -0,0 +1,418 @@
use-back-buttons: true
shops:
vertical:
goBackButton: 31 # back button will display if enabled in config.yml
trait: "VERTICAL" # Which genbucket type does this shop have?
size: 36 # Must be one of these: 9, 18, 27, 36, 45, 54
fill: true # Fill inventory ?
inventory-name: "Vertical genbuckets"
'0': # Must be unique
name: "&eVertical Cobble" # Genbucket item name
icon: "WATER_BUCKET" # This is the item placed in the GUI and the item you will get when purchased
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
'1':
name: "&eVertical Sand"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
'2':
name: "&eVertical Obby"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
infused:
goBackButton: 31
trait: "INFUSED"
size: 36
fill: true
inventory-name: "Infused genbuckets"
'0':
name: "&eInfused Cobble"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
'1':
name: "&eInfused Obsidian"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
'2':
name: "&eInfused Netherrack"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
psuedo:
goBackButton: 31
trait: "PSUEDO"
size: 36
fill: true
inventory-name: "Psuedo genbuckets"
'0': # Must be unique
name: "&ePsuedo Cobble"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
'1':
name: "&ePsuedo Sand"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
'2':
name: "&ePsuedo Obby"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
horizontal:
goBackButton: 31
trait: "HORIZONTAL"
size: 36
fill: true
inventory-name: "Horizontal genbuckets"
'0': # Must be unique
name: "&eHorizontal Cobble"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
'1':
name: "&eHorizontal Sand"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""
'2':
name: "&eHorizontal Obby"
icon: "WATER_BUCKET"
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))"
- ""
- "&7Price for one &e${price}" # The {price} and {material} placeholders only works in description
- ""
- "&7Spawns &e{material} &7blocks"
- ""
item-lore: # New lore after the gen has been purchased
- ""
- "&7&oRight click a block to place"
- ""