Cleanup.
This commit is contained in:
parent
ded93d2f01
commit
2130776df9
|
@ -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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
||||||
<artifactId>EpicBuckets-Parent</artifactId>
|
<artifactId>EpicBuckets-Parent</artifactId>
|
||||||
<version>maven-version-number</version>
|
<version>maven-version-number</version>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.songoda</groupId>
|
|
||||||
<artifactId>EpicBuckets-Legacy-Hooks</artifactId>
|
<artifactId>EpicBuckets-Legacy-Hooks</artifactId>
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean install</defaultGoal>
|
<defaultGoal>clean install</defaultGoal>
|
||||||
|
@ -20,12 +19,6 @@
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.songoda</groupId>
|
|
||||||
<artifactId>EpicBuckets-Plugin</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
<artifactId>worldguard</artifactId>
|
<artifactId>worldguard</artifactId>
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.songoda.epicbuckets.hooks.legacy;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.api.PlotAPI;
|
import com.intellectualcrafters.plot.api.PlotAPI;
|
||||||
import com.plotsquared.bukkit.BukkitMain;
|
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.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.songoda.epicbuckets.hooks.legacy;
|
package com.songoda.epicbuckets.hooks.legacy;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
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.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.songoda.epicbuckets.util.hooks;
|
package com.songoda.epicbuckets.utils.hooks;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ public interface ClaimableProtectionPluginHook extends ProtectionPluginHook {
|
||||||
*
|
*
|
||||||
* @param location the location to check
|
* @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
|
* @return true if the location is within the claim, false otherwise or if the
|
||||||
* claim ID does not exist
|
* claim ID does not exist
|
||||||
*/
|
*/
|
||||||
|
@ -31,7 +30,6 @@ public interface ClaimableProtectionPluginHook extends ProtectionPluginHook {
|
||||||
* returned String is its unique ID
|
* returned String is its unique ID
|
||||||
*
|
*
|
||||||
* @param name the name of the claim to check
|
* @param name the name of the claim to check
|
||||||
*
|
|
||||||
* @return the unique String ID. null if no claim exists
|
* @return the unique String ID. null if no claim exists
|
||||||
*/
|
*/
|
||||||
public String getClaimID(String name);
|
public String getClaimID(String name);
|
|
@ -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.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -10,9 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
* Represents a hook for a protection plugin. This is used by EpicBuckets to determine
|
* 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
|
* 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
|
* another plugin. For plugins providing claims with unique String IDs, see the
|
||||||
* {@link ClaimableProtectionPluginHook} for a more detailed implementation. To register
|
* {@link ClaimableProtectionPluginHook} for a more detailed implementation.
|
||||||
* a protection hook implementation, see
|
|
||||||
* {@link EpicBuckets#registerProtectionHook(ProtectionPluginHook)}
|
|
||||||
*/
|
*/
|
||||||
public interface ProtectionPluginHook {
|
public interface ProtectionPluginHook {
|
||||||
|
|
||||||
|
@ -28,7 +25,6 @@ public interface ProtectionPluginHook {
|
||||||
*
|
*
|
||||||
* @param player the player to check
|
* @param player the player to check
|
||||||
* @param location the location to check
|
* @param location the location to check
|
||||||
*
|
|
||||||
* @return true if player is permitted to build, false otherwise
|
* @return true if player is permitted to build, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean canBuild(Player player, Location location);
|
public boolean canBuild(Player player, Location location);
|
||||||
|
@ -38,7 +34,6 @@ public interface ProtectionPluginHook {
|
||||||
*
|
*
|
||||||
* @param player the player to check
|
* @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
|
* @return true if player is permitted to build, false otherwise
|
||||||
*/
|
*/
|
||||||
public default boolean canBuild(Player player, Block block) {
|
public default boolean canBuild(Player player, Block block) {
|
|
@ -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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@ import com.songoda.epicbuckets.listeners.GenbucketPlaceListener;
|
||||||
import com.songoda.epicbuckets.listeners.PlayerJoinListeners;
|
import com.songoda.epicbuckets.listeners.PlayerJoinListeners;
|
||||||
import com.songoda.epicbuckets.listeners.SourceBlockBreakListener;
|
import com.songoda.epicbuckets.listeners.SourceBlockBreakListener;
|
||||||
import com.songoda.epicbuckets.shop.ShopManager;
|
import com.songoda.epicbuckets.shop.ShopManager;
|
||||||
import com.songoda.epicbuckets.util.ChatUtil;
|
import com.songoda.epicbuckets.utils.ChatUtil;
|
||||||
import com.songoda.epicbuckets.util.ConfigWrapper;
|
import com.songoda.epicbuckets.utils.ConfigWrapper;
|
||||||
import com.songoda.epicbuckets.util.Debugger;
|
import com.songoda.epicbuckets.utils.Debugger;
|
||||||
import com.songoda.epicbuckets.util.ServerVersion;
|
import com.songoda.epicbuckets.utils.ServerVersion;
|
||||||
import com.songoda.epicbuckets.util.hooks.ClaimableProtectionPluginHook;
|
import com.songoda.epicbuckets.utils.hooks.ClaimableProtectionPluginHook;
|
||||||
import com.songoda.epicbuckets.util.hooks.ProtectionPluginHook;
|
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -51,6 +51,10 @@ public class EpicBuckets extends JavaPlugin {
|
||||||
private List<ProtectionPluginHook> protectionHooks = new ArrayList<>();
|
private List<ProtectionPluginHook> protectionHooks = new ArrayList<>();
|
||||||
private ClaimableProtectionPluginHook factionsHook, townyHook, aSkyblockHook, uSkyblockHook, skyBlockEarhHook;
|
private ClaimableProtectionPluginHook factionsHook, townyHook, aSkyblockHook, uSkyblockHook, skyBlockEarhHook;
|
||||||
|
|
||||||
|
public static EpicBuckets getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
|
@ -81,14 +85,19 @@ public class EpicBuckets extends JavaPlugin {
|
||||||
pluginManager.registerEvents(new PlayerJoinListeners(this), this);
|
pluginManager.registerEvents(new PlayerJoinListeners(this), this);
|
||||||
|
|
||||||
// Register default hooks
|
// Register default hooks
|
||||||
if (pluginManager.isPluginEnabled("ASkyBlock")) aSkyblockHook = (ClaimableProtectionPluginHook) this.register(HookASkyBlock::new);
|
if (pluginManager.isPluginEnabled("ASkyBlock"))
|
||||||
if (pluginManager.isPluginEnabled("FactionsFramework")) factionsHook = (ClaimableProtectionPluginHook) this.register(HookFactions::new);
|
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("GriefPrevention")) this.register(HookGriefPrevention::new);
|
||||||
if (pluginManager.isPluginEnabled("Kingdoms")) this.register(HookKingdoms::new);
|
if (pluginManager.isPluginEnabled("Kingdoms")) this.register(HookKingdoms::new);
|
||||||
if (pluginManager.isPluginEnabled("RedProtect")) this.register(HookRedProtect::new);
|
if (pluginManager.isPluginEnabled("RedProtect")) this.register(HookRedProtect::new);
|
||||||
if (pluginManager.isPluginEnabled("Towny")) townyHook = (ClaimableProtectionPluginHook) this.register(HookTowny::new);
|
if (pluginManager.isPluginEnabled("Towny"))
|
||||||
if (pluginManager.isPluginEnabled("USkyBlock")) uSkyblockHook = (ClaimableProtectionPluginHook) this.register(HookUSkyBlock::new);
|
townyHook = (ClaimableProtectionPluginHook) this.register(HookTowny::new);
|
||||||
if (pluginManager.isPluginEnabled("SkyBlock")) skyBlockEarhHook = (ClaimableProtectionPluginHook) this.register(HookSkyBlockEarth::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 (isServerVersionAtLeast(ServerVersion.V1_13)) {
|
||||||
if (pluginManager.isPluginEnabled("WorldGuard")) this.register(HookWorldGuard::new);
|
if (pluginManager.isPluginEnabled("WorldGuard")) this.register(HookWorldGuard::new);
|
||||||
|
@ -123,7 +132,6 @@ public class EpicBuckets extends JavaPlugin {
|
||||||
return this.registerProtectionHook(hookSupplier.get());
|
return this.registerProtectionHook(hookSupplier.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ProtectionPluginHook registerProtectionHook(ProtectionPluginHook hook) {
|
public ProtectionPluginHook registerProtectionHook(ProtectionPluginHook hook) {
|
||||||
Preconditions.checkNotNull(hook, "Cannot register null hook");
|
Preconditions.checkNotNull(hook, "Cannot register null hook");
|
||||||
Preconditions.checkNotNull(hook.getPlugin(), "Protection plugin hook returns null plugin instance (#getPlugin())");
|
Preconditions.checkNotNull(hook.getPlugin(), "Protection plugin hook returns null plugin instance (#getPlugin())");
|
||||||
|
@ -219,6 +227,4 @@ public class EpicBuckets extends JavaPlugin {
|
||||||
public References getReferences() {
|
public References getReferences() {
|
||||||
return references;
|
return references;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EpicBuckets getInstance() { return INSTANCE; }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,10 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
public class Locale {
|
public class Locale {
|
||||||
|
|
||||||
private static JavaPlugin plugin;
|
|
||||||
private static final List<Locale> LOCALES = Lists.newArrayList();
|
private static final List<Locale> LOCALES = Lists.newArrayList();
|
||||||
|
|
||||||
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.{1}\\w+)*)\\s*=\\s*\"(.*)\"");
|
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.{1}\\w+)*)\\s*=\\s*\"(.*)\"");
|
||||||
private static final String FILE_EXTENSION = ".lang";
|
private static final String FILE_EXTENSION = ".lang";
|
||||||
|
private static JavaPlugin plugin;
|
||||||
private static File localeFolder;
|
private static File localeFolder;
|
||||||
|
|
||||||
private static String defaultLocale;
|
private static String defaultLocale;
|
||||||
|
@ -52,122 +51,6 @@ public class Locale {
|
||||||
plugin.getLogger().info("Loaded locale " + fileName);
|
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.
|
* 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.
|
* This must be called before any other methods in the Locale class can be invoked.
|
||||||
|
@ -361,4 +244,120 @@ public class Locale {
|
||||||
return changed;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,16 +9,12 @@ import java.util.List;
|
||||||
|
|
||||||
public abstract class AbstractCommand {
|
public abstract class AbstractCommand {
|
||||||
|
|
||||||
public enum ReturnType { SUCCESS, FAILURE, SYNTAX_ERROR }
|
|
||||||
|
|
||||||
private final AbstractCommand parent;
|
private final AbstractCommand parent;
|
||||||
|
private final boolean noConsole;
|
||||||
private List<String> command;
|
private List<String> command;
|
||||||
|
|
||||||
private List<String> subCommand = new ArrayList<>();
|
private List<String> subCommand = new ArrayList<>();
|
||||||
|
|
||||||
private final boolean noConsole;
|
|
||||||
|
|
||||||
protected AbstractCommand(AbstractCommand parent, boolean noConsole, String... command) {
|
protected AbstractCommand(AbstractCommand parent, boolean noConsole, String... command) {
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
this.subCommand = Arrays.asList(command);
|
this.subCommand = Arrays.asList(command);
|
||||||
|
@ -34,7 +30,6 @@ public abstract class AbstractCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getCommand() {
|
public List<String> getCommand() {
|
||||||
System.out.println(command + " " + (command != null && command.contains("epicbuckets")));
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,4 +52,6 @@ public abstract class AbstractCommand {
|
||||||
public boolean isNoConsole() {
|
public boolean isNoConsole() {
|
||||||
return noConsole;
|
return noConsole;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ReturnType {SUCCESS, FAILURE, SYNTAX_ERROR}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.songoda.epicbuckets.command;
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.References;
|
import com.songoda.epicbuckets.References;
|
||||||
import com.songoda.epicbuckets.command.commands.*;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
|
@ -5,8 +5,8 @@ import com.songoda.epicbuckets.References;
|
||||||
import com.songoda.epicbuckets.command.AbstractCommand;
|
import com.songoda.epicbuckets.command.AbstractCommand;
|
||||||
import com.songoda.epicbuckets.shop.Shop;
|
import com.songoda.epicbuckets.shop.Shop;
|
||||||
import com.songoda.epicbuckets.shop.SubShop;
|
import com.songoda.epicbuckets.shop.SubShop;
|
||||||
import com.songoda.epicbuckets.util.ChatUtil;
|
import com.songoda.epicbuckets.utils.ChatUtil;
|
||||||
import com.songoda.epicbuckets.util.Validator;
|
import com.songoda.epicbuckets.utils.Validator;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.songoda.epicbuckets.command.commands;
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.References;
|
import com.songoda.epicbuckets.References;
|
||||||
import com.songoda.epicbuckets.command.AbstractCommand;
|
import com.songoda.epicbuckets.command.AbstractCommand;
|
||||||
import com.songoda.epicbuckets.util.ChatUtil;
|
import com.songoda.epicbuckets.utils.ChatUtil;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class CommandHelp extends AbstractCommand {
|
public class CommandHelp extends AbstractCommand {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.songoda.epicbuckets.command.commands;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.command.AbstractCommand;
|
import com.songoda.epicbuckets.command.AbstractCommand;
|
||||||
import com.songoda.epicbuckets.util.ChatUtil;
|
import com.songoda.epicbuckets.utils.ChatUtil;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class CommandReload extends AbstractCommand {
|
public class CommandReload extends AbstractCommand {
|
||||||
|
|
|
@ -8,6 +8,10 @@ import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class GenbucketPlaceEvent extends Event implements Cancellable {
|
public class GenbucketPlaceEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
/*
|
||||||
|
Needed for the event
|
||||||
|
*/
|
||||||
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final Genbucket genbucket;
|
private final Genbucket genbucket;
|
||||||
private boolean isCancelled;
|
private boolean isCancelled;
|
||||||
|
@ -18,6 +22,10 @@ public class GenbucketPlaceEvent extends Event implements Cancellable {
|
||||||
this.isCancelled = false;
|
this.isCancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return this.player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
@ -26,19 +34,10 @@ public class GenbucketPlaceEvent extends Event implements Cancellable {
|
||||||
return this.genbucket;
|
return this.genbucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Needed for the event
|
|
||||||
*/
|
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return HANDLERS;
|
return HANDLERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return HANDLERS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return this.isCancelled;
|
return this.isCancelled;
|
||||||
|
|
|
@ -2,9 +2,9 @@ package com.songoda.epicbuckets.file;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
import com.songoda.epicbuckets.utils.InventoryHelper;
|
||||||
import com.songoda.epicbuckets.util.Validator;
|
import com.songoda.epicbuckets.utils.Validator;
|
||||||
import com.songoda.epicbuckets.util.XMaterial;
|
import com.songoda.epicbuckets.utils.XMaterial;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -253,6 +253,10 @@ public class ConfigManager {
|
||||||
return backButtonPath;
|
return backButtonPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBackButtonPath(String backButtonPath) {
|
||||||
|
this.backButtonPath = backButtonPath;
|
||||||
|
}
|
||||||
|
|
||||||
public String getFillItemPath() {
|
public String getFillItemPath() {
|
||||||
return fillItemPath;
|
return fillItemPath;
|
||||||
}
|
}
|
||||||
|
@ -281,18 +285,34 @@ public class ConfigManager {
|
||||||
return supportFactions;
|
return supportFactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSupportFactions(boolean supportFactions) {
|
||||||
|
this.supportFactions = supportFactions;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSupportWorldGuard() {
|
public boolean isSupportWorldGuard() {
|
||||||
return supportWorldGuard;
|
return supportWorldGuard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSupportWorldGuard(boolean supportWorldGuard) {
|
||||||
|
this.supportWorldGuard = supportWorldGuard;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSupportGriefPrevention() {
|
public boolean isSupportGriefPrevention() {
|
||||||
return supportGriefPrevention;
|
return supportGriefPrevention;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSupportGriefPrevention(boolean supportGriefPrevention) {
|
||||||
|
this.supportGriefPrevention = supportGriefPrevention;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isGensInWilderness() {
|
public boolean isGensInWilderness() {
|
||||||
return gensInWilderness;
|
return gensInWilderness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGensInWilderness(boolean gensInWilderness) {
|
||||||
|
this.gensInWilderness = gensInWilderness;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEnchantGenbuckets() {
|
public boolean isEnchantGenbuckets() {
|
||||||
return enchantGenbuckets;
|
return enchantGenbuckets;
|
||||||
}
|
}
|
||||||
|
@ -301,38 +321,66 @@ public class ConfigManager {
|
||||||
return spongeCheck;
|
return spongeCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSpongeCheck(boolean spongeCheck) {
|
||||||
|
this.spongeCheck = spongeCheck;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSpongeRadius() {
|
public int getSpongeRadius() {
|
||||||
return spongeRadius;
|
return spongeRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSpongeRadius(int spongeRadius) {
|
||||||
|
this.spongeRadius = spongeRadius;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMaxGenbucketsPerPlayer() {
|
public int getMaxGenbucketsPerPlayer() {
|
||||||
return maxGenbucketsPerPlayer;
|
return maxGenbucketsPerPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMaxGenbucketsPerPlayer(int maxGenbucketsPerPlayer) {
|
||||||
|
this.maxGenbucketsPerPlayer = maxGenbucketsPerPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isUnlimitedGenbuckets() {
|
public boolean isUnlimitedGenbuckets() {
|
||||||
return unlimitedGenbuckets;
|
return unlimitedGenbuckets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUnlimitedGenbuckets(boolean unlimitedGenbuckets) {
|
||||||
|
this.unlimitedGenbuckets = unlimitedGenbuckets;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMaxVerticalHeight() {
|
public int getMaxVerticalHeight() {
|
||||||
return maxVerticalHeight;
|
return maxVerticalHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMaxVerticalHeight(int maxVerticalHeight) {
|
||||||
|
this.maxVerticalHeight = maxVerticalHeight;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMaxHorizontalLength() {
|
public int getMaxHorizontalLength() {
|
||||||
return maxHorizontalLength;
|
return maxHorizontalLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMaxHorizontalLength(int maxHorizontalLength) {
|
||||||
|
this.maxHorizontalLength = maxHorizontalLength;
|
||||||
|
}
|
||||||
|
|
||||||
public int getDelay() {
|
public int getDelay() {
|
||||||
return delay;
|
return delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGenbucketsDisabled(boolean enabled) {
|
public void setDelay(int delay) {
|
||||||
this.genbucketsDisabled = enabled;
|
this.delay = delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGenbucketsDisabled() {
|
public boolean isGenbucketsDisabled() {
|
||||||
return genbucketsDisabled;
|
return genbucketsDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGenbucketsDisabled(boolean enabled) {
|
||||||
|
this.genbucketsDisabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemStack getBackButton() {
|
public ItemStack getBackButton() {
|
||||||
return backButton;
|
return backButton;
|
||||||
}
|
}
|
||||||
|
@ -353,6 +401,10 @@ public class ConfigManager {
|
||||||
return fillInventory;
|
return fillInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFillInventory(boolean fillInventory) {
|
||||||
|
this.fillInventory = fillInventory;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemStack getFillItem() {
|
public ItemStack getFillItem() {
|
||||||
return fillItem;
|
return fillItem;
|
||||||
}
|
}
|
||||||
|
@ -377,10 +429,18 @@ public class ConfigManager {
|
||||||
return infiniteUse;
|
return infiniteUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInfiniteUse(boolean infiniteUse) {
|
||||||
|
this.infiniteUse = infiniteUse;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isChargeInfiniteUse() {
|
public boolean isChargeInfiniteUse() {
|
||||||
return chargeInfiniteUse;
|
return chargeInfiniteUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setChargeInfiniteUse(boolean chargeInfiniteUse) {
|
||||||
|
this.chargeInfiniteUse = chargeInfiniteUse;
|
||||||
|
}
|
||||||
|
|
||||||
public double getInfiniteUseCostForGenbucketType(GenbucketType genbucketType, ItemStack item) {
|
public double getInfiniteUseCostForGenbucketType(GenbucketType genbucketType, ItemStack item) {
|
||||||
for (ItemStack itemStack : infiniteUseCost.get(genbucketType).keySet()) {
|
for (ItemStack itemStack : infiniteUseCost.get(genbucketType).keySet()) {
|
||||||
if (itemStack.getType() == item.getType() && itemStack.getData() == item.getData()) {
|
if (itemStack.getType() == item.getType() && itemStack.getData() == item.getData()) {
|
||||||
|
@ -394,70 +454,10 @@ public class ConfigManager {
|
||||||
return genbucketDelay;
|
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) {
|
public void setGenbucketDelay(int genbucketDelay) {
|
||||||
this.genbucketDelay = 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() {
|
public HashMap<String, Consumer<Boolean>> getSettingsGenbucketBooleans() {
|
||||||
return settingsGenbucketBooleans;
|
return settingsGenbucketBooleans;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.songoda.epicbuckets.genbucket;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.shop.SubShop;
|
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.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
@ -148,7 +148,8 @@ public abstract class Genbucket {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean placeGen(Block block) {
|
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;
|
if (spongeInRange(block)) return false;
|
||||||
block.setType(getGenItem().getType());
|
block.setType(getGenItem().getType());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.songoda.epicbuckets.genbucket;
|
package com.songoda.epicbuckets.genbucket;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
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.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -63,7 +63,8 @@ public class GenbucketManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerGenbucketForPlayer(Player owner, Genbucket genbucket) {
|
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());
|
List<Genbucket> genbucketItems = activeGens.get(owner.getUniqueId());
|
||||||
genbucketItems.add(genbucket);
|
genbucketItems.add(genbucket);
|
||||||
activeGens.put(owner.getUniqueId(), genbucketItems);
|
activeGens.put(owner.getUniqueId(), genbucketItems);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.songoda.epicbuckets.file.ConfigManager;
|
||||||
import com.songoda.epicbuckets.shop.Shop;
|
import com.songoda.epicbuckets.shop.Shop;
|
||||||
import com.songoda.epicbuckets.shop.ShopManager;
|
import com.songoda.epicbuckets.shop.ShopManager;
|
||||||
import com.songoda.epicbuckets.shop.SubShop;
|
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.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.file.ConfigManager;
|
import com.songoda.epicbuckets.file.ConfigManager;
|
||||||
import com.songoda.epicbuckets.shop.Shop;
|
import com.songoda.epicbuckets.shop.Shop;
|
||||||
import com.songoda.epicbuckets.shop.ShopManager;
|
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.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ package com.songoda.epicbuckets.gui;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.genbucket.Genbucket;
|
import com.songoda.epicbuckets.genbucket.Genbucket;
|
||||||
import com.songoda.epicbuckets.util.ChatUtil;
|
import com.songoda.epicbuckets.utils.ChatUtil;
|
||||||
import com.songoda.epicbuckets.util.XMaterial;
|
import com.songoda.epicbuckets.utils.XMaterial;
|
||||||
import com.songoda.epicbuckets.util.gui.AbstractGUI;
|
import com.songoda.epicbuckets.utils.gui.AbstractGUI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.songoda.epicbuckets.file.ConfigManager;
|
||||||
import com.songoda.epicbuckets.shop.Shop;
|
import com.songoda.epicbuckets.shop.Shop;
|
||||||
import com.songoda.epicbuckets.shop.ShopManager;
|
import com.songoda.epicbuckets.shop.ShopManager;
|
||||||
import com.songoda.epicbuckets.shop.SubShop;
|
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.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -58,7 +58,8 @@ public class GUIShop extends AbstractGUI {
|
||||||
|
|
||||||
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) -> {
|
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);
|
if (shopManager.isCloseAfterPurchase()) new GUIMain(player);
|
||||||
}));
|
}));
|
||||||
registerClickable(subShop.getSlot(), ClickType.RIGHT, ((player1, inventory1, cursor, slot, type) -> new GUIBulk(player, shop, subShop)));
|
registerClickable(subShop.getSlot(), ClickType.RIGHT, ((player1, inventory1, cursor, slot, type) -> new GUIBulk(player, shop, subShop)));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.songoda.epicbuckets.hooks;
|
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.ASkyBlock;
|
||||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||||
import com.wasteofplastic.askyblock.Island;
|
import com.wasteofplastic.askyblock.Island;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.songoda.epicbuckets.hooks;
|
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.FactionsFramework;
|
||||||
import me.markeh.factionsframework.entities.FPlayer;
|
import me.markeh.factionsframework.entities.FPlayer;
|
||||||
import me.markeh.factionsframework.entities.FPlayers;
|
import me.markeh.factionsframework.entities.FPlayers;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.songoda.epicbuckets.hooks;
|
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.Claim;
|
||||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.songoda.epicbuckets.hooks;
|
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.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.songoda.epicbuckets.hooks;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.api.PlotAPI;
|
import com.intellectualcrafters.plot.api.PlotAPI;
|
||||||
import com.plotsquared.bukkit.BukkitMain;
|
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.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.songoda.epicbuckets.hooks;
|
||||||
import br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI;
|
import br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI;
|
||||||
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
|
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
|
||||||
import br.net.fabiozumbi12.RedProtect.Bukkit.Region;
|
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.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.songoda.epicbuckets.hooks;
|
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.SkyBlock;
|
||||||
import me.goodandevil.skyblock.island.Island;
|
import me.goodandevil.skyblock.island.Island;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
|
@ -4,8 +4,7 @@ import com.palmergames.bukkit.towny.Towny;
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
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.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.songoda.epicbuckets.hooks;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.songoda.epicbuckets.hooks;
|
package com.songoda.epicbuckets.hooks;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
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.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
|
@ -9,8 +9,8 @@ import com.songoda.epicbuckets.genbucket.types.Horizontal;
|
||||||
import com.songoda.epicbuckets.genbucket.types.Infused;
|
import com.songoda.epicbuckets.genbucket.types.Infused;
|
||||||
import com.songoda.epicbuckets.genbucket.types.PsuedoVertical;
|
import com.songoda.epicbuckets.genbucket.types.PsuedoVertical;
|
||||||
import com.songoda.epicbuckets.genbucket.types.Vertical;
|
import com.songoda.epicbuckets.genbucket.types.Vertical;
|
||||||
import com.songoda.epicbuckets.util.XMaterial;
|
import com.songoda.epicbuckets.utils.XMaterial;
|
||||||
import com.songoda.epicbuckets.util.itemnbtapi.NBTItem;
|
import com.songoda.epicbuckets.utils.itemnbtapi.NBTItem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.songoda.epicbuckets.listeners;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.References;
|
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.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
|
@ -2,9 +2,9 @@ package com.songoda.epicbuckets.shop;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
import com.songoda.epicbuckets.utils.InventoryHelper;
|
||||||
import com.songoda.epicbuckets.util.Validator;
|
import com.songoda.epicbuckets.utils.Validator;
|
||||||
import com.songoda.epicbuckets.util.XMaterial;
|
import com.songoda.epicbuckets.utils.XMaterial;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
@ -116,14 +116,14 @@ public class Shop {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSlot() {
|
public int getSlot() {
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.songoda.epicbuckets.shop;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||||
import com.songoda.epicbuckets.util.*;
|
import com.songoda.epicbuckets.utils.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -171,10 +171,18 @@ public class ShopManager {
|
||||||
return useBackButtons;
|
return useBackButtons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseBackButtons(boolean useBackButtons) {
|
||||||
|
this.useBackButtons = useBackButtons;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCloseAfterPurchase() {
|
public boolean isCloseAfterPurchase() {
|
||||||
return closeAfterPurchase;
|
return closeAfterPurchase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCloseAfterPurchase(boolean closeAfterPurchase) {
|
||||||
|
this.closeAfterPurchase = closeAfterPurchase;
|
||||||
|
}
|
||||||
|
|
||||||
public String getBulkInventoryName() {
|
public String getBulkInventoryName() {
|
||||||
return bulkInventoryName;
|
return bulkInventoryName;
|
||||||
}
|
}
|
||||||
|
@ -187,6 +195,10 @@ public class ShopManager {
|
||||||
return bulkFillInventory;
|
return bulkFillInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBulkFillInventory(boolean bulkFillInventory) {
|
||||||
|
this.bulkFillInventory = bulkFillInventory;
|
||||||
|
}
|
||||||
|
|
||||||
public int getBulkBackButtonSlot() {
|
public int getBulkBackButtonSlot() {
|
||||||
return bulkBackButtonSlot;
|
return bulkBackButtonSlot;
|
||||||
}
|
}
|
||||||
|
@ -202,16 +214,4 @@ public class ShopManager {
|
||||||
public void setShopDatabase(HashMap<String, Shop> shopDatabase) {
|
public void setShopDatabase(HashMap<String, Shop> shopDatabase) {
|
||||||
this.shopDatabase = 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.songoda.epicbuckets.shop;
|
package com.songoda.epicbuckets.shop;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
import com.songoda.epicbuckets.utils.InventoryHelper;
|
||||||
import com.songoda.epicbuckets.util.Validator;
|
import com.songoda.epicbuckets.utils.Validator;
|
||||||
import com.songoda.epicbuckets.util.XMaterial;
|
import com.songoda.epicbuckets.utils.XMaterial;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
@ -85,14 +85,14 @@ public class SubShop {
|
||||||
genShopItem = InventoryHelper.setDisplayName(InventoryHelper.setLore(genShopItem, getGenItemLore()), getShopName());
|
genShopItem = InventoryHelper.setDisplayName(InventoryHelper.setLore(genShopItem, getGenItemLore()), getShopName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemStack getShopItem() {
|
public ItemStack getShopItem() {
|
||||||
return shopItem;
|
return shopItem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.songoda.epicbuckets.util;
|
package com.songoda.epicbuckets.utils;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
|
@ -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.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.songoda.epicbuckets.util;
|
package com.songoda.epicbuckets.utils;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.songoda.epicbuckets.util;
|
package com.songoda.epicbuckets.utils;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.shop.SubShop;
|
import com.songoda.epicbuckets.shop.SubShop;
|
||||||
|
@ -52,7 +52,8 @@ public class InventoryHelper {
|
||||||
lore.forEach(s -> {
|
lore.forEach(s -> {
|
||||||
String line = s;
|
String line = s;
|
||||||
if (line.contains("%price%")) line = line.replace("%price%", subShop.getPrice() + "");
|
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));
|
newLore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||||
});
|
});
|
||||||
im.setLore(newLore);
|
im.setLore(newLore);
|
|
@ -1,8 +1,8 @@
|
||||||
package com.songoda.epicbuckets.util;
|
package com.songoda.epicbuckets.utils;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||||
import com.songoda.epicbuckets.shop.SubShop;
|
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;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class NBTHelper {
|
public class NBTHelper {
|
|
@ -1,4 +1,4 @@
|
||||||
package com.songoda.epicbuckets.util;
|
package com.songoda.epicbuckets.utils;
|
||||||
|
|
||||||
public enum ServerVersion {
|
public enum ServerVersion {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.songoda.epicbuckets.util;
|
package com.songoda.epicbuckets.utils;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
package com.songoda.epicbuckets.util;
|
package com.songoda.epicbuckets.utils;
|
||||||
/** The MIT License (MIT)
|
/**
|
||||||
*
|
* The MIT License (MIT)
|
||||||
|
* <p>
|
||||||
* Copyright (c) 2018 Hex_27
|
* Copyright (c) 2018 Hex_27
|
||||||
*
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"),
|
* of this software and associated documentation files (the "Software"),
|
||||||
* to deal in the Software without restriction, including without limitation
|
* to deal in the Software without restriction, including without limitation
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the
|
* 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:
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
*
|
* <p>
|
||||||
* The above copyright notice and this permission notice shall be included
|
* The above copyright notice and this permission notice shall be included
|
||||||
* in all copies or substantial portions of the Software.
|
* in all copies or substantial portions of the Software.
|
||||||
*
|
* <p>
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
* OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
@ -22,11 +23,11 @@ package com.songoda.epicbuckets.util;
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public enum XMaterial {
|
public enum XMaterial {
|
||||||
|
|
||||||
ACACIA_BOAT("BOAT_ACACIA", 0),
|
ACACIA_BOAT("BOAT_ACACIA", 0),
|
||||||
|
@ -878,8 +879,9 @@ public enum XMaterial {
|
||||||
ZOMBIE_PIGMAN_SPAWN_EGG("MONSTER_EGG", 0),
|
ZOMBIE_PIGMAN_SPAWN_EGG("MONSTER_EGG", 0),
|
||||||
ZOMBIE_SPAWN_EGG("MONSTER_EGG", 0),
|
ZOMBIE_SPAWN_EGG("MONSTER_EGG", 0),
|
||||||
ZOMBIE_VILLAGER_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;
|
String m;
|
||||||
int data;
|
int data;
|
||||||
|
|
||||||
|
@ -888,14 +890,6 @@ public enum XMaterial {
|
||||||
this.data = data;
|
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() {
|
public static boolean isNewVersion() {
|
||||||
if (newV == 0) return false;
|
if (newV == 0) return false;
|
||||||
if (newV == 1) return true;
|
if (newV == 1) return true;
|
||||||
|
@ -908,7 +902,6 @@ public enum XMaterial {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<String, XMaterial> cachedSearch = new HashMap<>();
|
|
||||||
public static XMaterial requestXMaterial(String name, byte data) {
|
public static XMaterial requestXMaterial(String name, byte data) {
|
||||||
if (cachedSearch.containsKey(name.toUpperCase() + "," + data)) {
|
if (cachedSearch.containsKey(name.toUpperCase() + "," + data)) {
|
||||||
return cachedSearch.get(name.toUpperCase() + "," + data);
|
return cachedSearch.get(name.toUpperCase() + "," + data);
|
||||||
|
@ -922,6 +915,31 @@ public enum XMaterial {
|
||||||
return null;
|
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 ItemStack parseItem() {
|
||||||
|
Material mat = parseMaterial();
|
||||||
|
if (isNewVersion()) {
|
||||||
|
return new ItemStack(mat);
|
||||||
|
}
|
||||||
|
return new ItemStack(mat, 1, (byte) data);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSameMaterial(ItemStack comp) {
|
public boolean isSameMaterial(ItemStack comp) {
|
||||||
if (isNewVersion()) {
|
if (isNewVersion()) {
|
||||||
return comp.getType() == this.parseMaterial();
|
return comp.getType() == this.parseMaterial();
|
||||||
|
@ -952,23 +970,6 @@ public enum XMaterial {
|
||||||
return null;
|
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("_");
|
String[] split = type.toString().split("_");
|
||||||
int length = split.length;
|
int length = split.length;
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.songoda</groupId>
|
<groupId>com.songoda</groupId>
|
||||||
<artifactId>EpicBuckets</artifactId>
|
<artifactId>EpicBuckets</artifactId>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue