This commit is contained in:
Brianna O'Keefe 2019-02-05 23:57:30 -05:00
parent ded93d2f01
commit 2130776df9
70 changed files with 545 additions and 553 deletions

View File

@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@ -7,7 +7,6 @@
<artifactId>EpicBuckets-Parent</artifactId>
<version>maven-version-number</version>
</parent>
<groupId>com.songoda</groupId>
<artifactId>EpicBuckets-Legacy-Hooks</artifactId>
<build>
<defaultGoal>clean install</defaultGoal>
@ -20,12 +19,6 @@
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>EpicBuckets-Plugin</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>

View File

@ -2,7 +2,7 @@ package com.songoda.epicbuckets.hooks.legacy;
import com.intellectualcrafters.plot.api.PlotAPI;
import com.plotsquared.bukkit.BukkitMain;
import com.songoda.epicbuckets.util.hooks.ProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

View File

@ -1,7 +1,7 @@
package com.songoda.epicbuckets.hooks.legacy;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.songoda.epicbuckets.util.hooks.ProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

View File

@ -1,4 +1,4 @@
package com.songoda.epicbuckets.util.hooks;
package com.songoda.epicbuckets.utils.hooks;
import org.bukkit.Location;
@ -8,17 +8,16 @@ import org.bukkit.Location;
* interface is not recommended over the ProtectionPluginHook interface as its methods
* will not often be used by implementation, though they are available if more information
* is desired. It is, however, recommended to use the former
*
*
* @author Parker Hawke - 2008Choco
*/
public interface ClaimableProtectionPluginHook extends ProtectionPluginHook {
/**
* Check whether the provided location is in the claim with the given String ID
*
*
* @param location the location to check
* @param id the ID of the claim to check
*
* @param id the ID of the claim to check
* @return true if the location is within the claim, false otherwise or if the
* claim ID does not exist
*/
@ -29,9 +28,8 @@ public interface ClaimableProtectionPluginHook extends ProtectionPluginHook {
* as unique IDs are not provided by a claim implementation, though for plugins
* such as factions, the passed parameter is the name of the faction and the
* returned String is its unique ID
*
*
* @param name the name of the claim to check
*
* @return the unique String ID. null if no claim exists
*/
public String getClaimID(String name);

View File

@ -1,6 +1,5 @@
package com.songoda.epicbuckets.util.hooks;
package com.songoda.epicbuckets.utils.hooks;
import com.songoda.epicbuckets.EpicBuckets;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -10,35 +9,31 @@ import org.bukkit.plugin.java.JavaPlugin;
* Represents a hook for a protection plugin. This is used by EpicBuckets to determine
* whether a block break should be successful or not according to the current state of
* another plugin. For plugins providing claims with unique String IDs, see the
* {@link ClaimableProtectionPluginHook} for a more detailed implementation. To register
* a protection hook implementation, see
* {@link EpicBuckets#registerProtectionHook(ProtectionPluginHook)}
* {@link ClaimableProtectionPluginHook} for a more detailed implementation.
*/
public interface ProtectionPluginHook {
/**
* The plugin to which this plugin hook belongs. Must not be null
*
*
* @return the hooking plugin
*/
public JavaPlugin getPlugin();
/**
* Check whether the provided player may build at the specified location
*
* @param player the player to check
*
* @param player the player to check
* @param location the location to check
*
* @return true if player is permitted to build, false otherwise
*/
public boolean canBuild(Player player, Location location);
/**
* Check whether the provided player may build at the specified block
*
*
* @param player the player to check
* @param block the block to check
*
* @param block the block to check
* @return true if player is permitted to build, false otherwise
*/
public default boolean canBuild(Player player, Block block) {

View File

@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

View File

@ -9,12 +9,12 @@ import com.songoda.epicbuckets.listeners.GenbucketPlaceListener;
import com.songoda.epicbuckets.listeners.PlayerJoinListeners;
import com.songoda.epicbuckets.listeners.SourceBlockBreakListener;
import com.songoda.epicbuckets.shop.ShopManager;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.util.ConfigWrapper;
import com.songoda.epicbuckets.util.Debugger;
import com.songoda.epicbuckets.util.ServerVersion;
import com.songoda.epicbuckets.util.hooks.ClaimableProtectionPluginHook;
import com.songoda.epicbuckets.util.hooks.ProtectionPluginHook;
import com.songoda.epicbuckets.utils.ChatUtil;
import com.songoda.epicbuckets.utils.ConfigWrapper;
import com.songoda.epicbuckets.utils.Debugger;
import com.songoda.epicbuckets.utils.ServerVersion;
import com.songoda.epicbuckets.utils.hooks.ClaimableProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
import net.milkbowl.vault.economy.Economy;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.Bukkit;
@ -51,6 +51,10 @@ public class EpicBuckets extends JavaPlugin {
private List<ProtectionPluginHook> protectionHooks = new ArrayList<>();
private ClaimableProtectionPluginHook factionsHook, townyHook, aSkyblockHook, uSkyblockHook, skyBlockEarhHook;
public static EpicBuckets getInstance() {
return INSTANCE;
}
@Override
public void onEnable() {
INSTANCE = this;
@ -81,14 +85,19 @@ public class EpicBuckets extends JavaPlugin {
pluginManager.registerEvents(new PlayerJoinListeners(this), this);
// Register default hooks
if (pluginManager.isPluginEnabled("ASkyBlock")) aSkyblockHook = (ClaimableProtectionPluginHook) this.register(HookASkyBlock::new);
if (pluginManager.isPluginEnabled("FactionsFramework")) factionsHook = (ClaimableProtectionPluginHook) this.register(HookFactions::new);
if (pluginManager.isPluginEnabled("ASkyBlock"))
aSkyblockHook = (ClaimableProtectionPluginHook) this.register(HookASkyBlock::new);
if (pluginManager.isPluginEnabled("FactionsFramework"))
factionsHook = (ClaimableProtectionPluginHook) this.register(HookFactions::new);
if (pluginManager.isPluginEnabled("GriefPrevention")) this.register(HookGriefPrevention::new);
if (pluginManager.isPluginEnabled("Kingdoms")) this.register(HookKingdoms::new);
if (pluginManager.isPluginEnabled("RedProtect")) this.register(HookRedProtect::new);
if (pluginManager.isPluginEnabled("Towny")) townyHook = (ClaimableProtectionPluginHook) this.register(HookTowny::new);
if (pluginManager.isPluginEnabled("USkyBlock")) uSkyblockHook = (ClaimableProtectionPluginHook) this.register(HookUSkyBlock::new);
if (pluginManager.isPluginEnabled("SkyBlock")) skyBlockEarhHook = (ClaimableProtectionPluginHook) this.register(HookSkyBlockEarth::new);
if (pluginManager.isPluginEnabled("Towny"))
townyHook = (ClaimableProtectionPluginHook) this.register(HookTowny::new);
if (pluginManager.isPluginEnabled("USkyBlock"))
uSkyblockHook = (ClaimableProtectionPluginHook) this.register(HookUSkyBlock::new);
if (pluginManager.isPluginEnabled("SkyBlock"))
skyBlockEarhHook = (ClaimableProtectionPluginHook) this.register(HookSkyBlockEarth::new);
if (isServerVersionAtLeast(ServerVersion.V1_13)) {
if (pluginManager.isPluginEnabled("WorldGuard")) this.register(HookWorldGuard::new);
@ -123,7 +132,6 @@ public class EpicBuckets extends JavaPlugin {
return this.registerProtectionHook(hookSupplier.get());
}
public ProtectionPluginHook registerProtectionHook(ProtectionPluginHook hook) {
Preconditions.checkNotNull(hook, "Cannot register null hook");
Preconditions.checkNotNull(hook.getPlugin(), "Protection plugin hook returns null plugin instance (#getPlugin())");
@ -219,6 +227,4 @@ public class EpicBuckets extends JavaPlugin {
public References getReferences() {
return references;
}
public static EpicBuckets getInstance() { return INSTANCE; }
}

View File

@ -23,11 +23,10 @@ import java.util.stream.Collectors;
*/
public class Locale {
private static JavaPlugin plugin;
private static final List<Locale> LOCALES = Lists.newArrayList();
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.{1}\\w+)*)\\s*=\\s*\"(.*)\"");
private static final String FILE_EXTENSION = ".lang";
private static JavaPlugin plugin;
private static File localeFolder;
private static String defaultLocale;
@ -52,122 +51,6 @@ public class Locale {
plugin.getLogger().info("Loaded locale " + fileName);
}
/**
* Get the name of the language that this locale is based on.
* (i.e. "en" for English, or "fr" for French)
*
* @return the name of the language
*/
public String getName() {
return name;
}
/**
* Get the name of the region that this locale is from.
* (i.e. "US" for United States or "CA" for Canada)
*
* @return the name of the region
*/
public String getRegion() {
return region;
}
/**
* Return the entire locale tag (i.e. "en_US")
*
* @return the language tag
*/
public String getLanguageTag() {
return name + "_" + region;
}
/**
* Get the file that represents this locale
*
* @return the locale file (.lang)
*/
public File getFile() {
return file;
}
/**
* Get a message set for a specific node
*
* @param node the node to get
* @return the message for the specified node
*/
public String getMessage(String node) {
return ChatColor.translateAlternateColorCodes('&', this.getMessageOrDefault(node, node));
}
/**
* Get a message set for a specific node and replace its params with a supplied arguments.
*
* @param node the node to get
* @param args the replacement arguments
* @return the message for the specified node
*/
public String getMessage(String node, Object... args) {
String message = getMessage(node);
for (Object arg : args) {
message = message.replaceFirst("\\%.*?\\%", arg.toString());
}
return message;
}
/**
* Get a message set for a specific node
*
* @param node the node to get
* @param defaultValue the default value given that a value for the node was not found
* @return the message for the specified node. Default if none found
*/
public String getMessageOrDefault(String node, String defaultValue) {
return this.nodes.getOrDefault(node, defaultValue);
}
/**
* Get the key-value map of nodes to messages
*
* @return node-message map
*/
public Map<String, String> getMessageNodeMap() {
return ImmutableMap.copyOf(nodes);
}
/**
* Clear the previous message cache and load new messages directly from file
*
* @return reload messages from file
*/
public boolean reloadMessages() {
if (!this.file.exists()) {
plugin.getLogger().warning("Could not find file for locale " + this.name);
return false;
}
this.nodes.clear(); // Clear previous data (if any)
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
String line;
for (int lineNumber = 0; (line = reader.readLine()) != null; lineNumber++) {
if (line.isEmpty() || line.startsWith("#") /* Comment */) continue;
Matcher matcher = NODE_PATTERN.matcher(line);
if (!matcher.find()) {
System.err.println("Invalid locale syntax at (line=" + lineNumber + ")");
continue;
}
nodes.put(matcher.group(1), matcher.group(2));
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
/**
* Initialize the locale class to generate information and search for localizations.
* This must be called before any other methods in the Locale class can be invoked.
@ -361,4 +244,120 @@ public class Locale {
return changed;
}
/**
* Get the name of the language that this locale is based on.
* (i.e. "en" for English, or "fr" for French)
*
* @return the name of the language
*/
public String getName() {
return name;
}
/**
* Get the name of the region that this locale is from.
* (i.e. "US" for United States or "CA" for Canada)
*
* @return the name of the region
*/
public String getRegion() {
return region;
}
/**
* Return the entire locale tag (i.e. "en_US")
*
* @return the language tag
*/
public String getLanguageTag() {
return name + "_" + region;
}
/**
* Get the file that represents this locale
*
* @return the locale file (.lang)
*/
public File getFile() {
return file;
}
/**
* Get a message set for a specific node
*
* @param node the node to get
* @return the message for the specified node
*/
public String getMessage(String node) {
return ChatColor.translateAlternateColorCodes('&', this.getMessageOrDefault(node, node));
}
/**
* Get a message set for a specific node and replace its params with a supplied arguments.
*
* @param node the node to get
* @param args the replacement arguments
* @return the message for the specified node
*/
public String getMessage(String node, Object... args) {
String message = getMessage(node);
for (Object arg : args) {
message = message.replaceFirst("\\%.*?\\%", arg.toString());
}
return message;
}
/**
* Get a message set for a specific node
*
* @param node the node to get
* @param defaultValue the default value given that a value for the node was not found
* @return the message for the specified node. Default if none found
*/
public String getMessageOrDefault(String node, String defaultValue) {
return this.nodes.getOrDefault(node, defaultValue);
}
/**
* Get the key-value map of nodes to messages
*
* @return node-message map
*/
public Map<String, String> getMessageNodeMap() {
return ImmutableMap.copyOf(nodes);
}
/**
* Clear the previous message cache and load new messages directly from file
*
* @return reload messages from file
*/
public boolean reloadMessages() {
if (!this.file.exists()) {
plugin.getLogger().warning("Could not find file for locale " + this.name);
return false;
}
this.nodes.clear(); // Clear previous data (if any)
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
String line;
for (int lineNumber = 0; (line = reader.readLine()) != null; lineNumber++) {
if (line.isEmpty() || line.startsWith("#") /* Comment */) continue;
Matcher matcher = NODE_PATTERN.matcher(line);
if (!matcher.find()) {
System.err.println("Invalid locale syntax at (line=" + lineNumber + ")");
continue;
}
nodes.put(matcher.group(1), matcher.group(2));
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
}

View File

@ -9,16 +9,12 @@ import java.util.List;
public abstract class AbstractCommand {
public enum ReturnType { SUCCESS, FAILURE, SYNTAX_ERROR }
private final AbstractCommand parent;
private final boolean noConsole;
private List<String> command;
private List<String> subCommand = new ArrayList<>();
private final boolean noConsole;
protected AbstractCommand(AbstractCommand parent, boolean noConsole, String... command) {
if (parent != null) {
this.subCommand = Arrays.asList(command);
@ -34,7 +30,6 @@ public abstract class AbstractCommand {
}
public List<String> getCommand() {
System.out.println(command + " " + (command != null && command.contains("epicbuckets")));
return command;
}
@ -57,4 +52,6 @@ public abstract class AbstractCommand {
public boolean isNoConsole() {
return noConsole;
}
public enum ReturnType {SUCCESS, FAILURE, SYNTAX_ERROR}
}

View File

@ -3,7 +3,7 @@ package com.songoda.epicbuckets.command;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.References;
import com.songoda.epicbuckets.command.commands.*;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.utils.ChatUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -67,11 +67,11 @@ public class CommandManager implements CommandExecutor {
return;
}
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
AbstractCommand.ReturnType returnType = command.runCommand(instance, sender, strings);
if (returnType == AbstractCommand.ReturnType.SYNTAX_ERROR) {
sender.sendMessage(References.getPrefix() + ChatUtil.colorString("&cInvalid Syntax!"));
sender.sendMessage(References.getPrefix() + ChatUtil.colorString("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
}
AbstractCommand.ReturnType returnType = command.runCommand(instance, sender, strings);
if (returnType == AbstractCommand.ReturnType.SYNTAX_ERROR) {
sender.sendMessage(References.getPrefix() + ChatUtil.colorString("&cInvalid Syntax!"));
sender.sendMessage(References.getPrefix() + ChatUtil.colorString("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
}
return;
}
sender.sendMessage(References.getPrefix() + instance.getLocale().getMessage("event.general.nopermission"));

View File

@ -14,7 +14,7 @@ public class CommandAdminPanel extends AbstractCommand {
@Override
protected ReturnType runCommand(EpicBuckets instance, CommandSender sender, String... args) {
new GUIPanel((Player)sender);
new GUIPanel((Player) sender);
return ReturnType.SUCCESS;
}

View File

@ -13,7 +13,7 @@ public class CommandAdminToggle extends AbstractCommand {
@Override
protected ReturnType runCommand(EpicBuckets instance, CommandSender sender, String... args) {
instance.getGenbucketManager().toggleAdmin((Player)sender);
instance.getGenbucketManager().toggleAdmin((Player) sender);
return ReturnType.SUCCESS;
}

View File

@ -15,7 +15,7 @@ public class CommandEpicBuckets extends AbstractCommand {
@Override
protected AbstractCommand.ReturnType runCommand(EpicBuckets instance, CommandSender sender, String... args) {
new GUIMain((Player)sender);
new GUIMain((Player) sender);
return ReturnType.SUCCESS;
}

View File

@ -5,8 +5,8 @@ import com.songoda.epicbuckets.References;
import com.songoda.epicbuckets.command.AbstractCommand;
import com.songoda.epicbuckets.shop.Shop;
import com.songoda.epicbuckets.shop.SubShop;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.util.Validator;
import com.songoda.epicbuckets.utils.ChatUtil;
import com.songoda.epicbuckets.utils.Validator;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -3,7 +3,7 @@ package com.songoda.epicbuckets.command.commands;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.References;
import com.songoda.epicbuckets.command.AbstractCommand;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.utils.ChatUtil;
import org.bukkit.command.CommandSender;
public class CommandHelp extends AbstractCommand {

View File

@ -2,7 +2,7 @@ package com.songoda.epicbuckets.command.commands;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.command.AbstractCommand;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.utils.ChatUtil;
import org.bukkit.command.CommandSender;
public class CommandReload extends AbstractCommand {

View File

@ -8,6 +8,10 @@ import org.bukkit.event.HandlerList;
public class GenbucketPlaceEvent extends Event implements Cancellable {
/*
Needed for the event
*/
private static final HandlerList HANDLERS = new HandlerList();
private final Player player;
private final Genbucket genbucket;
private boolean isCancelled;
@ -18,6 +22,10 @@ public class GenbucketPlaceEvent extends Event implements Cancellable {
this.isCancelled = false;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
public Player getPlayer() {
return this.player;
}
@ -26,19 +34,10 @@ public class GenbucketPlaceEvent extends Event implements Cancellable {
return this.genbucket;
}
/*
Needed for the event
*/
private static final HandlerList HANDLERS = new HandlerList();
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
@Override
public boolean isCancelled() {
return this.isCancelled;

View File

@ -2,9 +2,9 @@ package com.songoda.epicbuckets.file;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.genbucket.GenbucketType;
import com.songoda.epicbuckets.util.InventoryHelper;
import com.songoda.epicbuckets.util.Validator;
import com.songoda.epicbuckets.util.XMaterial;
import com.songoda.epicbuckets.utils.InventoryHelper;
import com.songoda.epicbuckets.utils.Validator;
import com.songoda.epicbuckets.utils.XMaterial;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@ -253,6 +253,10 @@ public class ConfigManager {
return backButtonPath;
}
public void setBackButtonPath(String backButtonPath) {
this.backButtonPath = backButtonPath;
}
public String getFillItemPath() {
return fillItemPath;
}
@ -281,18 +285,34 @@ public class ConfigManager {
return supportFactions;
}
public void setSupportFactions(boolean supportFactions) {
this.supportFactions = supportFactions;
}
public boolean isSupportWorldGuard() {
return supportWorldGuard;
}
public void setSupportWorldGuard(boolean supportWorldGuard) {
this.supportWorldGuard = supportWorldGuard;
}
public boolean isSupportGriefPrevention() {
return supportGriefPrevention;
}
public void setSupportGriefPrevention(boolean supportGriefPrevention) {
this.supportGriefPrevention = supportGriefPrevention;
}
public boolean isGensInWilderness() {
return gensInWilderness;
}
public void setGensInWilderness(boolean gensInWilderness) {
this.gensInWilderness = gensInWilderness;
}
public boolean isEnchantGenbuckets() {
return enchantGenbuckets;
}
@ -301,38 +321,66 @@ public class ConfigManager {
return spongeCheck;
}
public void setSpongeCheck(boolean spongeCheck) {
this.spongeCheck = spongeCheck;
}
public int getSpongeRadius() {
return spongeRadius;
}
public void setSpongeRadius(int spongeRadius) {
this.spongeRadius = spongeRadius;
}
public int getMaxGenbucketsPerPlayer() {
return maxGenbucketsPerPlayer;
}
public void setMaxGenbucketsPerPlayer(int maxGenbucketsPerPlayer) {
this.maxGenbucketsPerPlayer = maxGenbucketsPerPlayer;
}
public boolean isUnlimitedGenbuckets() {
return unlimitedGenbuckets;
}
public void setUnlimitedGenbuckets(boolean unlimitedGenbuckets) {
this.unlimitedGenbuckets = unlimitedGenbuckets;
}
public int getMaxVerticalHeight() {
return maxVerticalHeight;
}
public void setMaxVerticalHeight(int maxVerticalHeight) {
this.maxVerticalHeight = maxVerticalHeight;
}
public int getMaxHorizontalLength() {
return maxHorizontalLength;
}
public void setMaxHorizontalLength(int maxHorizontalLength) {
this.maxHorizontalLength = maxHorizontalLength;
}
public int getDelay() {
return delay;
}
public void setGenbucketsDisabled(boolean enabled) {
this.genbucketsDisabled = enabled;
public void setDelay(int delay) {
this.delay = delay;
}
public boolean isGenbucketsDisabled() {
return genbucketsDisabled;
}
public void setGenbucketsDisabled(boolean enabled) {
this.genbucketsDisabled = enabled;
}
public ItemStack getBackButton() {
return backButton;
}
@ -353,6 +401,10 @@ public class ConfigManager {
return fillInventory;
}
public void setFillInventory(boolean fillInventory) {
this.fillInventory = fillInventory;
}
public ItemStack getFillItem() {
return fillItem;
}
@ -377,10 +429,18 @@ public class ConfigManager {
return infiniteUse;
}
public void setInfiniteUse(boolean infiniteUse) {
this.infiniteUse = infiniteUse;
}
public boolean isChargeInfiniteUse() {
return chargeInfiniteUse;
}
public void setChargeInfiniteUse(boolean chargeInfiniteUse) {
this.chargeInfiniteUse = chargeInfiniteUse;
}
public double getInfiniteUseCostForGenbucketType(GenbucketType genbucketType, ItemStack item) {
for (ItemStack itemStack : infiniteUseCost.get(genbucketType).keySet()) {
if (itemStack.getType() == item.getType() && itemStack.getData() == item.getData()) {
@ -394,70 +454,10 @@ public class ConfigManager {
return genbucketDelay;
}
public void setBackButtonPath(String backButtonPath) {
this.backButtonPath = backButtonPath;
}
public void setSupportFactions(boolean supportFactions) {
this.supportFactions = supportFactions;
}
public void setSupportWorldGuard(boolean supportWorldGuard) {
this.supportWorldGuard = supportWorldGuard;
}
public void setSupportGriefPrevention(boolean supportGriefPrevention) {
this.supportGriefPrevention = supportGriefPrevention;
}
public void setGensInWilderness(boolean gensInWilderness) {
this.gensInWilderness = gensInWilderness;
}
public void setSpongeCheck(boolean spongeCheck) {
this.spongeCheck = spongeCheck;
}
public void setSpongeRadius(int spongeRadius) {
this.spongeRadius = spongeRadius;
}
public void setMaxGenbucketsPerPlayer(int maxGenbucketsPerPlayer) {
this.maxGenbucketsPerPlayer = maxGenbucketsPerPlayer;
}
public void setUnlimitedGenbuckets(boolean unlimitedGenbuckets) {
this.unlimitedGenbuckets = unlimitedGenbuckets;
}
public void setInfiniteUse(boolean infiniteUse) {
this.infiniteUse = infiniteUse;
}
public void setChargeInfiniteUse(boolean chargeInfiniteUse) {
this.chargeInfiniteUse = chargeInfiniteUse;
}
public void setGenbucketDelay(int genbucketDelay) {
this.genbucketDelay = genbucketDelay;
}
public void setMaxVerticalHeight(int maxVerticalHeight) {
this.maxVerticalHeight = maxVerticalHeight;
}
public void setMaxHorizontalLength(int maxHorizontalLength) {
this.maxHorizontalLength = maxHorizontalLength;
}
public void setDelay(int delay) {
this.delay = delay;
}
public void setFillInventory(boolean fillInventory) {
this.fillInventory = fillInventory;
}
public HashMap<String, Consumer<Boolean>> getSettingsGenbucketBooleans() {
return settingsGenbucketBooleans;
}

View File

@ -2,7 +2,7 @@ package com.songoda.epicbuckets.genbucket;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.shop.SubShop;
import com.songoda.epicbuckets.util.XMaterial;
import com.songoda.epicbuckets.utils.XMaterial;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -148,7 +148,8 @@ public abstract class Genbucket {
}
protected boolean placeGen(Block block) {
if (!epicBuckets.getConfigManager().getIgnoredMaterials().contains(XMaterial.requestXMaterial(block.getType().name(), block.getData()))) return false;
if (!epicBuckets.getConfigManager().getIgnoredMaterials().contains(XMaterial.requestXMaterial(block.getType().name(), block.getData())))
return false;
if (spongeInRange(block)) return false;
block.setType(getGenItem().getType());
return true;

View File

@ -1,7 +1,7 @@
package com.songoda.epicbuckets.genbucket;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.utils.ChatUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Player;
@ -63,7 +63,8 @@ public class GenbucketManager {
}
public void registerGenbucketForPlayer(Player owner, Genbucket genbucket) {
if (!activeGens.containsKey(owner.getUniqueId())) activeGens.put(owner.getUniqueId(), new ArrayList<>(Arrays.asList(genbucket)));
if (!activeGens.containsKey(owner.getUniqueId()))
activeGens.put(owner.getUniqueId(), new ArrayList<>(Arrays.asList(genbucket)));
List<Genbucket> genbucketItems = activeGens.get(owner.getUniqueId());
genbucketItems.add(genbucket);
activeGens.put(owner.getUniqueId(), genbucketItems);

View File

@ -5,7 +5,7 @@ import com.songoda.epicbuckets.file.ConfigManager;
import com.songoda.epicbuckets.shop.Shop;
import com.songoda.epicbuckets.shop.ShopManager;
import com.songoda.epicbuckets.shop.SubShop;
import com.songoda.epicbuckets.util.gui.AbstractGUI;
import com.songoda.epicbuckets.utils.gui.AbstractGUI;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -70,16 +70,16 @@ public class GUIBulk extends AbstractGUI {
shopManager.getDecreaseSlots().forEach(i ->
registerClickable(i, ((player1, inventory1, cursor, slot, type) -> {
ItemStack genbucket = inventory.getItem(shopManager.getBulkMainItemSlot());
int amount = shopManager.getBulkAmounts().get(shopManager.getDecreaseSlots().indexOf(i));
genbucket.setAmount(genbucket.getAmount() - amount < 1 ? 1 : genbucket.getAmount() - amount);
ItemStack genbucket = inventory.getItem(shopManager.getBulkMainItemSlot());
int amount = shopManager.getBulkAmounts().get(shopManager.getDecreaseSlots().indexOf(i));
genbucket.setAmount(genbucket.getAmount() - amount < 1 ? 1 : genbucket.getAmount() - amount);
})));
shopManager.getIncreaseSlots().forEach(i ->
registerClickable(i, ((player1, inventory1, cursor, slot, type) -> {
ItemStack genbucket = inventory.getItem(shopManager.getBulkMainItemSlot());
int amount = shopManager.getBulkAmounts().get(shopManager.getIncreaseSlots().indexOf(i));
genbucket.setAmount(genbucket.getAmount() + amount > 64 ? 64 : genbucket.getAmount() + amount);
ItemStack genbucket = inventory.getItem(shopManager.getBulkMainItemSlot());
int amount = shopManager.getBulkAmounts().get(shopManager.getIncreaseSlots().indexOf(i));
genbucket.setAmount(genbucket.getAmount() + amount > 64 ? 64 : genbucket.getAmount() + amount);
})));
registerClickable(shopManager.getPurchaseSlot(), ((player1, inventory1, cursor, slot, type) -> {

View File

@ -4,7 +4,7 @@ import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.file.ConfigManager;
import com.songoda.epicbuckets.shop.Shop;
import com.songoda.epicbuckets.shop.ShopManager;
import com.songoda.epicbuckets.util.gui.AbstractGUI;
import com.songoda.epicbuckets.utils.gui.AbstractGUI;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

View File

@ -2,9 +2,9 @@ package com.songoda.epicbuckets.gui;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.genbucket.Genbucket;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.util.XMaterial;
import com.songoda.epicbuckets.util.gui.AbstractGUI;
import com.songoda.epicbuckets.utils.ChatUtil;
import com.songoda.epicbuckets.utils.XMaterial;
import com.songoda.epicbuckets.utils.gui.AbstractGUI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -42,8 +42,8 @@ public class GUIPanel extends AbstractGUI {
inventory.setItem(place, skull);
registerClickable(place, ((player1, inventory1, cursor, slot, type) ->
player.teleport(genbucket.getPlayerLocation()
)));
place ++;
)));
place++;
}
}
}

View File

@ -5,7 +5,7 @@ import com.songoda.epicbuckets.file.ConfigManager;
import com.songoda.epicbuckets.shop.Shop;
import com.songoda.epicbuckets.shop.ShopManager;
import com.songoda.epicbuckets.shop.SubShop;
import com.songoda.epicbuckets.util.gui.AbstractGUI;
import com.songoda.epicbuckets.utils.gui.AbstractGUI;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
@ -56,9 +56,10 @@ public class GUIShop extends AbstractGUI {
registerClickable(shop.getBackButtonSlot(), ((player, inventory, cursor, slot, type) -> new GUIMain(player)));
}
shop.getSubShops().stream().filter(SubShop::isEnabled).forEach(subShop -> {
shop.getSubShops().stream().filter(SubShop::isEnabled).forEach(subShop -> {
registerClickable(subShop.getSlot(), ClickType.LEFT, ((player1, inventory1, cursor, slot, type) -> {
if (shopManager.hasEnoughFunds(player1, subShop, 1) && !shopManager.inventoryFull(player)) shopManager.buyFromShop(player, subShop, 1);
if (shopManager.hasEnoughFunds(player1, subShop, 1) && !shopManager.inventoryFull(player))
shopManager.buyFromShop(player, subShop, 1);
if (shopManager.isCloseAfterPurchase()) new GUIMain(player);
}));
registerClickable(subShop.getSlot(), ClickType.RIGHT, ((player1, inventory1, cursor, slot, type) -> new GUIBulk(player, shop, subShop)));

View File

@ -1,6 +1,6 @@
package com.songoda.epicbuckets.hooks;
import com.songoda.epicbuckets.util.hooks.ClaimableProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ClaimableProtectionPluginHook;
import com.wasteofplastic.askyblock.ASkyBlock;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import com.wasteofplastic.askyblock.Island;

View File

@ -1,6 +1,6 @@
package com.songoda.epicbuckets.hooks;
import com.songoda.epicbuckets.util.hooks.ClaimableProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ClaimableProtectionPluginHook;
import me.markeh.factionsframework.FactionsFramework;
import me.markeh.factionsframework.entities.FPlayer;
import me.markeh.factionsframework.entities.FPlayers;

View File

@ -1,6 +1,6 @@
package com.songoda.epicbuckets.hooks;
import com.songoda.epicbuckets.util.hooks.ProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.bukkit.Location;

View File

@ -1,6 +1,6 @@
package com.songoda.epicbuckets.hooks;
import com.songoda.epicbuckets.util.hooks.ProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

View File

@ -2,7 +2,7 @@ package com.songoda.epicbuckets.hooks;
import com.intellectualcrafters.plot.api.PlotAPI;
import com.plotsquared.bukkit.BukkitMain;
import com.songoda.epicbuckets.util.hooks.ProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

View File

@ -3,7 +3,7 @@ package com.songoda.epicbuckets.hooks;
import br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI;
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
import br.net.fabiozumbi12.RedProtect.Bukkit.Region;
import com.songoda.epicbuckets.util.hooks.ProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

View File

@ -1,6 +1,6 @@
package com.songoda.epicbuckets.hooks;
import com.songoda.epicbuckets.util.hooks.ClaimableProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ClaimableProtectionPluginHook;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.island.Island;
import org.bukkit.Location;

View File

@ -4,8 +4,7 @@ import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import com.songoda.epicbuckets.util.hooks.ClaimableProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ClaimableProtectionPluginHook;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

View File

@ -1,6 +1,6 @@
package com.songoda.epicbuckets.hooks;
import com.songoda.epicbuckets.util.hooks.ClaimableProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ClaimableProtectionPluginHook;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;

View File

@ -1,7 +1,7 @@
package com.songoda.epicbuckets.hooks;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.songoda.epicbuckets.util.hooks.ProtectionPluginHook;
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

View File

@ -9,8 +9,8 @@ import com.songoda.epicbuckets.genbucket.types.Horizontal;
import com.songoda.epicbuckets.genbucket.types.Infused;
import com.songoda.epicbuckets.genbucket.types.PsuedoVertical;
import com.songoda.epicbuckets.genbucket.types.Vertical;
import com.songoda.epicbuckets.util.XMaterial;
import com.songoda.epicbuckets.util.itemnbtapi.NBTItem;
import com.songoda.epicbuckets.utils.XMaterial;
import com.songoda.epicbuckets.utils.itemnbtapi.NBTItem;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.event.EventHandler;
@ -20,9 +20,9 @@ import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class GenbucketPlaceListener implements Listener {
private final EpicBuckets instance;
public GenbucketPlaceListener(EpicBuckets instance) {
this.instance = instance;
}

View File

@ -2,7 +2,7 @@ package com.songoda.epicbuckets.listeners;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.References;
import com.songoda.epicbuckets.util.ChatUtil;
import com.songoda.epicbuckets.utils.ChatUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -21,19 +21,19 @@ public class PlayerJoinListeners implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (player.isOp()) {
if (instance.getServer().getPluginManager().getPlugin("Factions") != null && instance.getServer().getPluginManager().getPlugin("FactionsFramework") == null) {
player.sendMessage("");
player.sendMessage(ChatUtil.colorString(References.getPrefix() + "&7Here's the deal,"));
player.sendMessage(ChatUtil.colorString("&7I cannot give you full support for Factions out of the box."));
player.sendMessage(ChatUtil.colorString("&7Things will work without it but if you wan't a flawless"));
player.sendMessage(ChatUtil.colorString("&7experience you need to download"));
player.sendMessage(ChatUtil.colorString("&7&6https://www.spigotmc.org/resources/54337/&7."));
player.sendMessage(ChatUtil.colorString("&7If you don't care and don't want to see this message again"));
player.sendMessage(ChatUtil.colorString("&7turn &6Helpful-Tips &7off in the config."));
player.sendMessage("");
}
Player player = event.getPlayer();
if (player.isOp()) {
if (instance.getServer().getPluginManager().getPlugin("Factions") != null && instance.getServer().getPluginManager().getPlugin("FactionsFramework") == null) {
player.sendMessage("");
player.sendMessage(ChatUtil.colorString(References.getPrefix() + "&7Here's the deal,"));
player.sendMessage(ChatUtil.colorString("&7I cannot give you full support for Factions out of the box."));
player.sendMessage(ChatUtil.colorString("&7Things will work without it but if you wan't a flawless"));
player.sendMessage(ChatUtil.colorString("&7experience you need to download"));
player.sendMessage(ChatUtil.colorString("&7&6https://www.spigotmc.org/resources/54337/&7."));
player.sendMessage(ChatUtil.colorString("&7If you don't care and don't want to see this message again"));
player.sendMessage(ChatUtil.colorString("&7turn &6Helpful-Tips &7off in the config."));
player.sendMessage("");
}
}
}
}

View File

@ -2,9 +2,9 @@ package com.songoda.epicbuckets.shop;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.genbucket.GenbucketType;
import com.songoda.epicbuckets.util.InventoryHelper;
import com.songoda.epicbuckets.util.Validator;
import com.songoda.epicbuckets.util.XMaterial;
import com.songoda.epicbuckets.utils.InventoryHelper;
import com.songoda.epicbuckets.utils.Validator;
import com.songoda.epicbuckets.utils.XMaterial;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
@ -109,21 +109,21 @@ public class Shop {
public SubShop getSubShop(XMaterial mat) {
for (SubShop subShop : subShops.values()) {
if (subShop.getGenItem().getType() == mat.parseMaterial() &&
subShop.getGenItem().getDurability() == mat.parseItem().getDurability()) {
subShop.getGenItem().getDurability() == mat.parseItem().getDurability()) {
return subShop;
}
}
return null;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public int getSlot() {
return slot;
}

View File

@ -2,7 +2,7 @@ package com.songoda.epicbuckets.shop;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.genbucket.GenbucketType;
import com.songoda.epicbuckets.util.*;
import com.songoda.epicbuckets.utils.*;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@ -171,10 +171,18 @@ public class ShopManager {
return useBackButtons;
}
public void setUseBackButtons(boolean useBackButtons) {
this.useBackButtons = useBackButtons;
}
public boolean isCloseAfterPurchase() {
return closeAfterPurchase;
}
public void setCloseAfterPurchase(boolean closeAfterPurchase) {
this.closeAfterPurchase = closeAfterPurchase;
}
public String getBulkInventoryName() {
return bulkInventoryName;
}
@ -187,6 +195,10 @@ public class ShopManager {
return bulkFillInventory;
}
public void setBulkFillInventory(boolean bulkFillInventory) {
this.bulkFillInventory = bulkFillInventory;
}
public int getBulkBackButtonSlot() {
return bulkBackButtonSlot;
}
@ -202,16 +214,4 @@ public class ShopManager {
public void setShopDatabase(HashMap<String, Shop> shopDatabase) {
this.shopDatabase = shopDatabase;
}
public void setBulkFillInventory(boolean bulkFillInventory) {
this.bulkFillInventory = bulkFillInventory;
}
public void setUseBackButtons(boolean useBackButtons) {
this.useBackButtons = useBackButtons;
}
public void setCloseAfterPurchase(boolean closeAfterPurchase) {
this.closeAfterPurchase = closeAfterPurchase;
}
}

View File

@ -1,9 +1,9 @@
package com.songoda.epicbuckets.shop;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.util.InventoryHelper;
import com.songoda.epicbuckets.util.Validator;
import com.songoda.epicbuckets.util.XMaterial;
import com.songoda.epicbuckets.utils.InventoryHelper;
import com.songoda.epicbuckets.utils.Validator;
import com.songoda.epicbuckets.utils.XMaterial;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
@ -85,14 +85,14 @@ public class SubShop {
genShopItem = InventoryHelper.setDisplayName(InventoryHelper.setLore(genShopItem, getGenItemLore()), getShopName());
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public ItemStack getShopItem() {
return shopItem;
}

View File

@ -1,4 +1,4 @@
package com.songoda.epicbuckets.util;
package com.songoda.epicbuckets.utils;
import com.songoda.epicbuckets.EpicBuckets;
import org.bukkit.ChatColor;

View File

@ -1,4 +1,4 @@
package com.songoda.epicbuckets.util;
package com.songoda.epicbuckets.utils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

View File

@ -1,4 +1,4 @@
package com.songoda.epicbuckets.util;
package com.songoda.epicbuckets.utils;
import com.songoda.epicbuckets.EpicBuckets;
import org.bukkit.ChatColor;

View File

@ -1,4 +1,4 @@
package com.songoda.epicbuckets.util;
package com.songoda.epicbuckets.utils;
import com.songoda.epicbuckets.EpicBuckets;
import com.songoda.epicbuckets.shop.SubShop;
@ -52,7 +52,8 @@ public class InventoryHelper {
lore.forEach(s -> {
String line = s;
if (line.contains("%price%")) line = line.replace("%price%", subShop.getPrice() + "");
if (line.contains("%material%")) line = line.replace("%material%", subShop.getType().parseMaterial().name());
if (line.contains("%material%"))
line = line.replace("%material%", subShop.getType().parseMaterial().name());
newLore.add(ChatColor.translateAlternateColorCodes('&', line));
});
im.setLore(newLore);

View File

@ -1,8 +1,8 @@
package com.songoda.epicbuckets.util;
package com.songoda.epicbuckets.utils;
import com.songoda.epicbuckets.genbucket.GenbucketType;
import com.songoda.epicbuckets.shop.SubShop;
import com.songoda.epicbuckets.util.itemnbtapi.NBTItem;
import com.songoda.epicbuckets.utils.itemnbtapi.NBTItem;
import org.bukkit.inventory.ItemStack;
public class NBTHelper {

View File

@ -1,4 +1,4 @@
package com.songoda.epicbuckets.util;
package com.songoda.epicbuckets.utils;
public enum ServerVersion {

View File

@ -1,4 +1,4 @@
package com.songoda.epicbuckets.util;
package com.songoda.epicbuckets.utils;
import com.songoda.epicbuckets.genbucket.GenbucketType;
@ -8,7 +8,7 @@ public class Validator {
int i;
if (isInt(s)) {
i = Integer.parseInt(s);
if (i<=6) return i;
if (i <= 6) return i;
}
return -1;
}

View File

@ -1,18 +1,19 @@
package com.songoda.epicbuckets.util;
/** The MIT License (MIT)
*
package com.songoda.epicbuckets.utils;
/**
* The MIT License (MIT)
* <p>
* Copyright (c) 2018 Hex_27
*
* <p>
* 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 without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* <p>
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* <p>
* 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.
@ -22,11 +23,11 @@ package com.songoda.epicbuckets.util;
* DEALINGS IN THE SOFTWARE.
**/
import java.util.HashMap;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
public enum XMaterial {
ACACIA_BOAT("BOAT_ACACIA", 0),
@ -878,29 +879,22 @@ public enum XMaterial {
ZOMBIE_PIGMAN_SPAWN_EGG("MONSTER_EGG", 0),
ZOMBIE_SPAWN_EGG("MONSTER_EGG", 0),
ZOMBIE_VILLAGER_SPAWN_EGG("MONSTER_EGG", 0),
ZOMBIE_WALL_HEAD("SKULL", 0),
;
ZOMBIE_WALL_HEAD("SKULL", 0),;
static int newV = -1;
private static HashMap<String, XMaterial> cachedSearch = new HashMap<>();
String m;
int data;
XMaterial(String m, int data ){
XMaterial(String m, int data) {
this.m = m;
this.data = data;
}
public ItemStack parseItem(){
Material mat = parseMaterial();
if(isNewVersion()){
return new ItemStack(mat);
}
return new ItemStack(mat,1,(byte) data);
}
static int newV = -1;
public static boolean isNewVersion(){
if(newV == 0) return false;
if(newV == 1) return true;
public static boolean isNewVersion() {
if (newV == 0) return false;
if (newV == 1) return true;
Material mat = Material.matchMaterial("RED_WOOL");
if(mat != null){
if (mat != null) {
newV = 1;
return true;
}
@ -908,43 +902,67 @@ public enum XMaterial {
return false;
}
private static HashMap<String, XMaterial> cachedSearch = new HashMap<>();
public static XMaterial requestXMaterial(String name, byte data){
if(cachedSearch.containsKey(name.toUpperCase()+","+data)){
return cachedSearch.get(name.toUpperCase()+","+data);
public static XMaterial requestXMaterial(String name, byte data) {
if (cachedSearch.containsKey(name.toUpperCase() + "," + data)) {
return cachedSearch.get(name.toUpperCase() + "," + data);
}
for(XMaterial mat:XMaterial.values()){
if(name.toUpperCase().equals(mat.m) && ((byte)mat.data) == data){
cachedSearch.put(mat.m+","+data,mat);
for (XMaterial mat : XMaterial.values()) {
if (name.toUpperCase().equals(mat.m) && ((byte) mat.data) == data) {
cachedSearch.put(mat.m + "," + data, mat);
return mat;
}
}
return null;
}
public boolean isSameMaterial(ItemStack comp){
if(isNewVersion()){
public static XMaterial fromString(String key) {
XMaterial xmat = null;
try {
xmat = XMaterial.valueOf(key);
return xmat;
} catch (IllegalArgumentException e) {
String[] split = key.split(":");
if (split.length == 1) {
xmat = requestXMaterial(key, (byte) 0);
} else {
xmat = requestXMaterial(split[0], (byte) Integer.parseInt(split[1]));
}
return xmat;
}
}
public ItemStack parseItem() {
Material mat = parseMaterial();
if (isNewVersion()) {
return new ItemStack(mat);
}
return new ItemStack(mat, 1, (byte) data);
}
public boolean isSameMaterial(ItemStack comp) {
if (isNewVersion()) {
return comp.getType() == this.parseMaterial();
}
if(comp.getType() == this.parseMaterial() &&
(int) comp.getData().getData() == (int) this.data){
if (comp.getType() == this.parseMaterial() &&
(int) comp.getData().getData() == (int) this.data) {
return true;
}
XMaterial xmat = fromMaterial(comp.getType());
if(isDamageable(xmat)){
if(this.parseMaterial() == comp.getType()){
if (isDamageable(xmat)) {
if (this.parseMaterial() == comp.getType()) {
return true;
}
}
return false;
}
public XMaterial fromMaterial(Material mat){
try{
public XMaterial fromMaterial(Material mat) {
try {
return XMaterial.valueOf(mat.toString());
}catch(IllegalArgumentException e){
for(XMaterial xmat:XMaterial.values()){
if(xmat.m.equals(mat.toString())){
} catch (IllegalArgumentException e) {
for (XMaterial xmat : XMaterial.values()) {
if (xmat.m.equals(mat.toString())) {
return xmat;
}
}
@ -952,27 +970,10 @@ public enum XMaterial {
return null;
}
public static XMaterial fromString(String key){
XMaterial xmat = null;
try{
xmat = XMaterial.valueOf(key);
return xmat;
}catch(IllegalArgumentException e){
String[] split = key.split(":");
if(split.length == 1){
xmat = requestXMaterial(key,(byte) 0);
}else{
xmat = requestXMaterial(split[0],(byte) Integer.parseInt(split[1]));
}
return xmat;
}
}
public boolean isDamageable(XMaterial type){
public boolean isDamageable(XMaterial type) {
String[] split = type.toString().split("_");
int length = split.length;
switch(split[length-1]){
switch (split[length - 1]) {
case "HELMET":
return true;
case "CHESTPLATE":
@ -1006,9 +1007,9 @@ public enum XMaterial {
}
}
public Material parseMaterial(){
public Material parseMaterial() {
Material mat = Material.matchMaterial(this.toString());
if(mat != null){
if (mat != null) {
return mat;
}
return Material.matchMaterial(m);

View File

@ -1,151 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>EpicBuckets</artifactId>
<version>1.0.2</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<defaultGoal>clean package</defaultGoal>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedClassifierName>shaded</shadedClassifierName>
<artifactSet>
<excludes>
<exclude>org.spigotmc:spigot</exclude>
<exclude>com.songoda:arconix</exclude>
<exclude>net.milkbowl.vault:VaultAPI</exclude>
<exclude>me.ryanhamshire:GriefPrevention</exclude>
<exclude>com.sk89q</exclude>
<exclude>com:plotsquared</exclude>
<exclude>me.markeh:factionsframework</exclude>
<exclude>com.massivecraft</exclude>
</excludes>
</artifactSet>
<relocations>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}.acf</shadedPattern>
</relocation>
<relocation>
<pattern>de.tr7zw.itemnbtapi</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}.itemnbtapi</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>11_private</id>
<url>http://repo.songoda.com/repository/private</url>
</repository>
<repository>
<id>22_vault</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>3_aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
<repository>
<id>44_jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.13.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>arconix</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>LATEST</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>org.bukkit</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>me.ryanhamshire</groupId>
<artifactId>GriefPrevention</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>6.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com</groupId>
<artifactId>plotsquared</artifactId>
<version>RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.markeh</groupId>
<artifactId>factionsframework</artifactId>
<version>1.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>factions</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>factionsuuid</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
</dependencies>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>EpicBuckets</artifactId>
<version>1.0.2</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<defaultGoal>clean package</defaultGoal>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedClassifierName>shaded</shadedClassifierName>
<artifactSet>
<excludes>
<exclude>org.spigotmc:spigot</exclude>
<exclude>com.songoda:arconix</exclude>
<exclude>net.milkbowl.vault:VaultAPI</exclude>
<exclude>me.ryanhamshire:GriefPrevention</exclude>
<exclude>com.sk89q</exclude>
<exclude>com:plotsquared</exclude>
<exclude>me.markeh:factionsframework</exclude>
<exclude>com.massivecraft</exclude>
</excludes>
</artifactSet>
<relocations>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}.acf</shadedPattern>
</relocation>
<relocation>
<pattern>de.tr7zw.itemnbtapi</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}.itemnbtapi</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>11_private</id>
<url>http://repo.songoda.com/repository/private</url>
</repository>
<repository>
<id>22_vault</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>3_aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
<repository>
<id>44_jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.13.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>arconix</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>LATEST</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>org.bukkit</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>me.ryanhamshire</groupId>
<artifactId>GriefPrevention</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>6.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com</groupId>
<artifactId>plotsquared</artifactId>
<version>RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.markeh</groupId>
<artifactId>factionsframework</artifactId>
<version>1.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>factions</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>factionsuuid</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>