mirror of
https://github.com/songoda/EpicFurnaces.git
synced 2025-02-13 10:01:27 +01:00
Merge branch 'development'
This commit is contained in:
commit
08589f5c63
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "EpicFurnaces"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "4.2.2"
|
||||
version: "4.5"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
@ -14,7 +14,7 @@ build:
|
||||
- find $path/ -type f -name "*.yml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
|
||||
- mvn clean package
|
||||
- find $path/ -depth -path '*original*' -delete
|
||||
- mv $path/core/target/*.jar $path/
|
||||
- mv $path/target/*.jar $path/
|
||||
artifacts:
|
||||
name: $name-$version
|
||||
paths:
|
||||
|
140
core/pom.xml
140
core/pom.xml
@ -1,140 +0,0 @@
|
||||
<?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/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>EpicFurnaces-Parent</artifactId>
|
||||
<groupId>com.songoda</groupId>
|
||||
<version>maven-version-number</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>EpicFurnaces</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EpicFurnaces</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<url>https://songoda.com/</url>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>com.songoda.epicfurnaces</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:songodaupdater</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>CodeMC</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.14-pre5-2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>songodaupdater</artifactId>
|
||||
<version>1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl</groupId>
|
||||
<artifactId>vault</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,300 +0,0 @@
|
||||
package com.songoda.epicfurnaces;
|
||||
|
||||
import com.songoda.epicfurnaces.command.CommandManager;
|
||||
import com.songoda.epicfurnaces.handlers.BlacklistHandler;
|
||||
import com.songoda.epicfurnaces.listeners.BlockListeners;
|
||||
import com.songoda.epicfurnaces.listeners.FurnaceListeners;
|
||||
import com.songoda.epicfurnaces.listeners.InteractListeners;
|
||||
import com.songoda.epicfurnaces.listeners.InventoryListeners;
|
||||
import com.songoda.epicfurnaces.managers.BoostManager;
|
||||
import com.songoda.epicfurnaces.managers.FurnaceManager;
|
||||
import com.songoda.epicfurnaces.managers.HologramManager;
|
||||
import com.songoda.epicfurnaces.managers.LevelManager;
|
||||
import com.songoda.epicfurnaces.storage.Storage;
|
||||
import com.songoda.epicfurnaces.storage.types.StorageMysql;
|
||||
import com.songoda.epicfurnaces.storage.types.StorageYaml;
|
||||
import com.songoda.epicfurnaces.tasks.FurnaceTask;
|
||||
import com.songoda.epicfurnaces.tasks.HologramTask;
|
||||
import com.songoda.epicfurnaces.utils.BukkitEnums;
|
||||
import com.songoda.epicfurnaces.utils.Methods;
|
||||
import com.songoda.epicfurnaces.utils.StringUtils;
|
||||
import com.songoda.epicfurnaces.utils.gui.FastInv;
|
||||
import com.songoda.epicfurnaces.utils.updateModules.LocaleModule;
|
||||
import com.songoda.update.Plugin;
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.songoda.epicfurnaces.utils.StringUtils.formatText;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class EpicFurnaces extends JavaPlugin {
|
||||
private static Map<String, FileConfiguration> configurations = new HashMap<>();
|
||||
private BlacklistHandler blacklistHandler;
|
||||
private BoostManager boostManager;
|
||||
private BukkitEnums bukkitEnums;
|
||||
private CommandManager commandManager;
|
||||
private FurnaceManager furnaceManager;
|
||||
private LevelManager levelManager;
|
||||
private Locale locale;
|
||||
private Storage storage;
|
||||
private HologramManager hologramManager;
|
||||
private Economy economy;
|
||||
private int currentVersion;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getConsoleSender().sendMessage(formatText("&a============================="));
|
||||
Bukkit.getConsoleSender().sendMessage(formatText("&7EpicFurnaces " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
|
||||
Bukkit.getConsoleSender().sendMessage(formatText("&7Action: &aEnabling&7..."));
|
||||
|
||||
if (!checkVersion()) {
|
||||
getPluginLoader().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String name : asList("config", "data", "hooks", "blacklist", "Furnace Recipes")) {
|
||||
File file = new File(getDataFolder(), name + ".yml");
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
saveResource(file.getName(), false);
|
||||
}
|
||||
FileConfiguration configuration = new YamlConfiguration();
|
||||
try {
|
||||
configuration.load(file);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
configurations.put(name, configuration);
|
||||
}
|
||||
|
||||
String langMode = getConfig().getString("System.Language Mode");
|
||||
Locale.init(this);
|
||||
Locale.saveDefaultLocale("en_US");
|
||||
this.locale = Locale.getLocale(getConfig().getString("System.Language Mode", langMode));
|
||||
|
||||
|
||||
//Running Songoda Updater
|
||||
Plugin plugin = new Plugin(this, 22);
|
||||
plugin.addModule(new LocaleModule());
|
||||
SongodaUpdate.load(plugin);
|
||||
|
||||
FastInv.init(this);
|
||||
Methods.init(this);
|
||||
StringUtils.init(this);
|
||||
|
||||
this.furnaceManager = new FurnaceManager(this);
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.boostManager = new BoostManager(this);
|
||||
this.blacklistHandler = new BlacklistHandler(this);
|
||||
this.bukkitEnums = new BukkitEnums(this);
|
||||
this.levelManager = new LevelManager(this);
|
||||
|
||||
if (!setupEconomy()) {
|
||||
getLogger().severe("Economy provider not found/not supported, disabling...");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
Bukkit.getConsoleSender().sendMessage(formatText("&a============================="));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays") && getConfig().getBoolean("Main.Furnaces Have Holograms")) {
|
||||
this.hologramManager = new HologramManager(this);
|
||||
}
|
||||
|
||||
checkStorage();
|
||||
levelManager.loadLevelManager();
|
||||
setupRecipes();
|
||||
|
||||
int timeout = getConfig().getInt("Main.Auto Save Interval In Seconds") * 60 * 20;
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this, furnaceManager::loadFurnaces, 10);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> storage.doSave(), timeout, timeout);
|
||||
|
||||
// Start Tasks
|
||||
HologramTask.startTask(this);
|
||||
FurnaceTask.startTask(this);
|
||||
|
||||
// Register Listeners
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
new HashSet<>(asList(
|
||||
new BlockListeners(this),
|
||||
new FurnaceListeners(this),
|
||||
new InteractListeners(this),
|
||||
new InventoryListeners(this))).forEach(listener -> pluginManager.registerEvents(listener, this));
|
||||
|
||||
new Metrics(this);
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(formatText("&a============================="));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Bukkit.getConsoleSender().sendMessage(formatText("&a============================="));
|
||||
Bukkit.getConsoleSender().sendMessage(formatText("&7EpicFurnaces " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
|
||||
Bukkit.getConsoleSender().sendMessage(formatText("&7Action: &cDisabling&7..."));
|
||||
Bukkit.getConsoleSender().sendMessage(formatText("&a============================="));
|
||||
getHologramManager().ifPresent(HologramManager::clearAll);
|
||||
this.hologramManager = null;
|
||||
storage.doSave();
|
||||
storage.closeConnection();
|
||||
|
||||
Map<Inventory, Location> loadedFurnaceInventories = this.furnaceManager.getLoadedFurnaceInventories();
|
||||
for (Inventory inventory : loadedFurnaceInventories.keySet())
|
||||
loadedFurnaceInventories.get(inventory).getChunk().load();
|
||||
loadedFurnaceInventories.clear();
|
||||
}
|
||||
|
||||
private void checkStorage() {
|
||||
if (getConfig().getBoolean("Database.Activate Mysql Support")) {
|
||||
this.storage = new StorageMysql(this);
|
||||
} else {
|
||||
this.storage = new StorageYaml(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
reloadConfig();
|
||||
saveConfig();
|
||||
onDisable();
|
||||
onEnable();
|
||||
}
|
||||
|
||||
private void setupRecipes() {
|
||||
if (!getConfig().getBoolean("Main.Use Custom Recipes")) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationSection cs = getConfiguration("Furnace Recipes").getConfigurationSection("Recipes");
|
||||
|
||||
for (String key : cs.getKeys(false)) {
|
||||
Material item = Material.matchMaterial(key.toUpperCase());
|
||||
|
||||
if (item == null) {
|
||||
getLogger().info("Invalid material from recipes files: " + key.toUpperCase());
|
||||
continue;
|
||||
}
|
||||
|
||||
Material result = Material.matchMaterial(cs.getString(key.toUpperCase() + ".result"));
|
||||
|
||||
if (result == null) {
|
||||
getLogger().info("Invalid material from recipes files: " + cs.getString(key.toUpperCase() + ".result"));
|
||||
continue;
|
||||
}
|
||||
|
||||
int amount = cs.getInt(key.toUpperCase() + ".amount");
|
||||
getServer().addRecipe(new FurnaceRecipe(new ItemStack(result, amount), item));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void save(String configuration) {
|
||||
try {
|
||||
File configurationFile = new File(getDataFolder(), configuration + ".yml");
|
||||
getConfiguration(configuration).save(configurationFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkVersion() {
|
||||
String version = getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
currentVersion = Integer.parseInt(version.split("_")[1]);
|
||||
int workingVersion = 8;
|
||||
|
||||
if (currentVersion < workingVersion) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||
Bukkit.getConsoleSender().sendMessage("");
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "You installed the 1." + workingVersion + "+ version of " +
|
||||
this.getDescription().getName() + " on a 1." + currentVersion + " server. " +
|
||||
"We currently do not support " + currentVersion + " and below.");
|
||||
Bukkit.getConsoleSender().sendMessage("");
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean setupEconomy() {
|
||||
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
return false;
|
||||
}
|
||||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp == null) {
|
||||
return false;
|
||||
}
|
||||
economy = rsp.getProvider();
|
||||
return economy != null;
|
||||
}
|
||||
|
||||
|
||||
public FileConfiguration getConfiguration(String name) {
|
||||
return configurations.get(name);
|
||||
}
|
||||
|
||||
public BlacklistHandler getBlacklistHandler() {
|
||||
return blacklistHandler;
|
||||
}
|
||||
|
||||
public BoostManager getBoostManager() {
|
||||
return boostManager;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public FurnaceManager getFurnaceManager() {
|
||||
return furnaceManager;
|
||||
}
|
||||
|
||||
public LevelManager getLevelManager() {
|
||||
return levelManager;
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public BukkitEnums getBukkitEnums() {
|
||||
return bukkitEnums;
|
||||
}
|
||||
|
||||
public Optional<HologramManager> getHologramManager() {
|
||||
return Optional.ofNullable(hologramManager);
|
||||
}
|
||||
|
||||
public Storage getStorage() {
|
||||
return storage;
|
||||
}
|
||||
|
||||
public Economy getEconomy() {
|
||||
return economy;
|
||||
}
|
||||
|
||||
public int getCurrentVersion() {
|
||||
return currentVersion;
|
||||
}
|
||||
}
|
@ -1,381 +0,0 @@
|
||||
package com.songoda.epicfurnaces;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Assists in the creation of multiple localizations and languages,
|
||||
* as well as the generation of default .lang files
|
||||
*
|
||||
* @author Parker Hawke - 2008Choco
|
||||
*/
|
||||
public class Locale {
|
||||
|
||||
private static final List<Locale> LOCALES = Lists.newArrayList();
|
||||
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.\\w+)*)\\s*=\\s*\"(.*)\"");
|
||||
private static final String FILE_EXTENSION = ".lang";
|
||||
private static JavaPlugin plugin;
|
||||
private static File localeFolder;
|
||||
|
||||
private static String defaultLocale;
|
||||
|
||||
private final Map<String, String> nodes = new HashMap<>();
|
||||
|
||||
private final File file;
|
||||
private final String name, region;
|
||||
|
||||
private Locale(String name, String region) {
|
||||
if (plugin == null)
|
||||
throw new IllegalStateException("Cannot generate locales without first initializing the class (Locale#init(JavaPlugin))");
|
||||
|
||||
this.name = name.toLowerCase();
|
||||
this.region = region.toUpperCase();
|
||||
|
||||
String fileName = name + "_" + region + FILE_EXTENSION;
|
||||
this.file = new File(localeFolder, fileName);
|
||||
|
||||
if (this.reloadMessages()) return;
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage("Loaded locale " + fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Note that this will also call {@link #searchForLocales()}, so there is no need to
|
||||
* invoke it for yourself after the initialization
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
*/
|
||||
public static void init(JavaPlugin plugin) {
|
||||
Locale.plugin = plugin;
|
||||
|
||||
if (localeFolder == null) {
|
||||
localeFolder = new File(plugin.getDataFolder(), "locales/");
|
||||
}
|
||||
|
||||
localeFolder.mkdirs();
|
||||
Locale.searchForLocales();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all .lang file locales under the "locales" folder
|
||||
*/
|
||||
public static void searchForLocales() {
|
||||
if (!localeFolder.exists()) {
|
||||
localeFolder.mkdirs();
|
||||
}
|
||||
|
||||
for (File file : localeFolder.listFiles()) {
|
||||
String name = file.getName();
|
||||
if (!name.endsWith(".lang")) continue;
|
||||
|
||||
String fileName = name.substring(0, name.lastIndexOf('.'));
|
||||
String[] localeValues = fileName.split("_");
|
||||
|
||||
if (localeValues.length != 2) continue;
|
||||
if (localeExists(localeValues[0] + "_" + localeValues[1])) continue;
|
||||
|
||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||
Bukkit.getConsoleSender().sendMessage("Found and loaded locale \"" + fileName + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale by its entire proper name (i.e. "en_US")
|
||||
*
|
||||
* @param name the full name of the locale
|
||||
* @return locale of the specified name
|
||||
*/
|
||||
public static Locale getLocale(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getLanguageTag().equalsIgnoreCase(name)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale from the cache by its name (i.e. "en" from "en_US")
|
||||
*
|
||||
* @param name the name of the language
|
||||
* @return locale of the specified language. Null if not cached
|
||||
*/
|
||||
public static Locale getLocaleByName(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getName().equalsIgnoreCase(name)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale from the cache by its region (i.e. "US" from "en_US")
|
||||
*
|
||||
* @param region the name of the region
|
||||
* @return locale of the specified region. Null if not cached
|
||||
*/
|
||||
public static Locale getLocaleByRegion(String region) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getRegion().equalsIgnoreCase(region)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a locale exists and is registered or not
|
||||
*
|
||||
* @param name the whole language tag (i.e. "en_US")
|
||||
* @return true if it exists
|
||||
*/
|
||||
public static boolean localeExists(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getLanguageTag().equals(name)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an immutable list of all currently loaded locales
|
||||
*
|
||||
* @return list of all locales
|
||||
*/
|
||||
public static List<Locale> getLocales() {
|
||||
return ImmutableList.copyOf(LOCALES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a default locale file from the project source directory, to the locale folder
|
||||
*
|
||||
* @param in file to save
|
||||
* @param fileName the name of the file to save
|
||||
* @return true if the operation was successful, false otherwise
|
||||
*/
|
||||
public static boolean saveDefaultLocale(InputStream in, String fileName) {
|
||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
||||
|
||||
if (!fileName.endsWith(FILE_EXTENSION))
|
||||
fileName = (fileName.lastIndexOf(".") == -1 ? fileName : fileName.substring(0, fileName.lastIndexOf('.'))) + FILE_EXTENSION;
|
||||
|
||||
File destinationFile = new File(localeFolder, fileName);
|
||||
if (destinationFile.exists()) {
|
||||
return compareFiles(plugin.getResource(fileName), destinationFile);
|
||||
}
|
||||
|
||||
try (OutputStream outputStream = new FileOutputStream(destinationFile)) {
|
||||
copy(in == null ? plugin.getResource(fileName) : in, outputStream);
|
||||
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||
String[] localeValues = fileName.split("_");
|
||||
|
||||
if (localeValues.length != 2) return false;
|
||||
|
||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||
if (defaultLocale == null) defaultLocale = fileName;
|
||||
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a default locale file from the project source directory, to the locale folder
|
||||
*
|
||||
* @param fileName the name of the file to save
|
||||
* @return true if the operation was successful, false otherwise
|
||||
*/
|
||||
public static boolean saveDefaultLocale(String fileName) {
|
||||
return saveDefaultLocale(null, fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all current locale data
|
||||
*/
|
||||
public static void clearLocaleData() {
|
||||
for (Locale locale : LOCALES)
|
||||
locale.nodes.clear();
|
||||
LOCALES.clear();
|
||||
}
|
||||
|
||||
// Write new changes to existing files, if any at all
|
||||
private static boolean compareFiles(InputStream defaultFile, File existingFile) {
|
||||
// Look for default
|
||||
if (defaultFile == null) {
|
||||
defaultFile = plugin.getResource(defaultLocale != null ? defaultLocale : "en_US");
|
||||
if (defaultFile == null) return false; // No default at all
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
List<String> defaultLines, existingLines;
|
||||
try (BufferedReader defaultReader = new BufferedReader(new InputStreamReader(defaultFile));
|
||||
BufferedReader existingReader = new BufferedReader(new FileReader(existingFile));
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(existingFile, true))) {
|
||||
defaultLines = defaultReader.lines().collect(Collectors.toList());
|
||||
existingLines = existingReader.lines().map(s -> s.split("\\s*=")[0]).collect(Collectors.toList());
|
||||
|
||||
for (String defaultValue : defaultLines) {
|
||||
if (defaultValue.isEmpty() || defaultValue.startsWith("#")) continue;
|
||||
|
||||
String key = defaultValue.split("\\s*=")[0];
|
||||
|
||||
if (!existingLines.contains(key)) {
|
||||
if (!changed) {
|
||||
writer.newLine();
|
||||
writer.newLine();
|
||||
writer.write("# New messages for " + plugin.getName() + " v" + plugin.getDescription().getVersion());
|
||||
}
|
||||
|
||||
writer.newLine();
|
||||
writer.write(defaultValue);
|
||||
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static void copy(InputStream input, OutputStream output) {
|
||||
int n;
|
||||
byte[] buffer = new byte[1024 * 4];
|
||||
|
||||
try {
|
||||
while ((n = input.read(buffer)) != -1) {
|
||||
output.write(buffer, 0, n);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.trim().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;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return getMessage("general.nametag.prefix") + " ";
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.songoda.epicfurnaces.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public abstract class AbstractCommand {
|
||||
|
||||
private final AbstractCommand parent;
|
||||
private final String command;
|
||||
private final boolean noConsole;
|
||||
|
||||
protected AbstractCommand(String command, AbstractCommand parent, boolean noConsole) {
|
||||
this.command = command;
|
||||
this.parent = parent;
|
||||
this.noConsole = noConsole;
|
||||
}
|
||||
|
||||
public AbstractCommand getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public boolean isNoConsole() {
|
||||
return noConsole;
|
||||
}
|
||||
|
||||
protected abstract ReturnType runCommand(CommandSender sender, String... args);
|
||||
|
||||
public abstract String getPermissionNode();
|
||||
|
||||
public abstract String getSyntax();
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
public enum ReturnType {SUCCESS, FAILURE, SYNTAX_ERROR}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package com.songoda.epicfurnaces.command;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.command.commands.*;
|
||||
import com.songoda.epicfurnaces.utils.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.songoda.epicfurnaces.command.AbstractCommand.ReturnType.SYNTAX_ERROR;
|
||||
|
||||
public class CommandManager implements CommandExecutor {
|
||||
|
||||
private EpicFurnaces instance;
|
||||
|
||||
private List<AbstractCommand> commands = new ArrayList<>();
|
||||
|
||||
public CommandManager(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
|
||||
instance.getCommand("EpicFurnaces").setExecutor(this);
|
||||
|
||||
AbstractCommand commandEpicFurnaces = addCommand(new CommandEpicFurnaces(instance));
|
||||
|
||||
addCommand(new CommandReload(instance, commandEpicFurnaces));
|
||||
addCommand(new CommandRemote(instance, commandEpicFurnaces));
|
||||
addCommand(new CommandGive(instance, commandEpicFurnaces));
|
||||
addCommand(new CommandBoost(instance, commandEpicFurnaces));
|
||||
addCommand(new CommandHelp(instance, commandEpicFurnaces));
|
||||
}
|
||||
|
||||
private AbstractCommand addCommand(AbstractCommand abstractCommand) {
|
||||
commands.add(abstractCommand);
|
||||
return abstractCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
for (AbstractCommand abstractCommand : commands) {
|
||||
if (abstractCommand.getCommand().equalsIgnoreCase(command.getName())) {
|
||||
if (strings.length == 0) {
|
||||
processRequirements(abstractCommand, commandSender, strings);
|
||||
return true;
|
||||
}
|
||||
} else if (strings.length != 0 && abstractCommand.getParent() != null && abstractCommand.getParent().getCommand().equalsIgnoreCase(command.getName())) {
|
||||
String cmd = strings[0];
|
||||
if (cmd.equalsIgnoreCase(abstractCommand.getCommand())) {
|
||||
processRequirements(abstractCommand, commandSender, strings);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
commandSender.sendMessage(instance.getLocale().getPrefix() + StringUtils.formatText("&7The command you entered does not exist or is spelt incorrectly."));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void processRequirements(AbstractCommand command, CommandSender sender, String[] strings) {
|
||||
if (!(sender instanceof Player) && command.isNoConsole()) {
|
||||
sender.sendMessage("You must be a player to use this command.");
|
||||
return;
|
||||
}
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
AbstractCommand.ReturnType returnType = command.runCommand(sender, strings);
|
||||
if (returnType == SYNTAX_ERROR) {
|
||||
sender.sendMessage(instance.getLocale().getPrefix() + StringUtils.formatText("&cInvalid Syntax!"));
|
||||
sender.sendMessage(instance.getLocale().getPrefix() + StringUtils.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("event.general.nopermission"));
|
||||
}
|
||||
|
||||
public List<AbstractCommand> getCommands() {
|
||||
return Collections.unmodifiableList(commands);
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package com.songoda.epicfurnaces.command.commands;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.command.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.objects.BoostData;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class CommandBoost extends AbstractCommand {
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public CommandBoost(EpicFurnaces instance, AbstractCommand parent) {
|
||||
super("boost", parent, false);
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 3) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (Bukkit.getPlayer(args[1]) == null) {
|
||||
sender.sendMessage(com.songoda.epicfurnaces.utils.StringUtils.formatText(instance.getLocale().getPrefix() + "&cThat player does not exist..."));
|
||||
return ReturnType.FAILURE;
|
||||
} else if (!StringUtils.isNumeric(args[2])) {
|
||||
sender.sendMessage(com.songoda.epicfurnaces.utils.StringUtils.formatText(instance.getLocale().getPrefix() + "&6" + args[2] + " &7is not a number..."));
|
||||
return ReturnType.FAILURE;
|
||||
} else {
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date currentDate = new Date();
|
||||
c.setTime(currentDate);
|
||||
|
||||
String time = "&7.";
|
||||
|
||||
if (args.length > 3) {
|
||||
if (args[3].contains("m:")) {
|
||||
String[] arr2 = (args[3]).split(":");
|
||||
c.add(Calendar.MINUTE, Integer.parseInt(arr2[1]));
|
||||
time = " &7for &6" + arr2[1] + " minutes&7.";
|
||||
} else if (args[3].contains("h:")) {
|
||||
String[] arr2 = (args[3]).split(":");
|
||||
c.add(Calendar.HOUR, Integer.parseInt(arr2[1]));
|
||||
time = " &7for &6" + arr2[1] + " hours&7.";
|
||||
} else if (args[3].contains("d:")) {
|
||||
String[] arr2 = (args[3]).split(":");
|
||||
c.add(Calendar.HOUR, Integer.parseInt(arr2[1]) * 24);
|
||||
time = " &7for &6" + arr2[1] + " days&7.";
|
||||
} else if (args[3].contains("y:")) {
|
||||
String[] arr2 = (args[3]).split(":");
|
||||
c.add(Calendar.YEAR, Integer.parseInt(arr2[1]));
|
||||
time = " &7for &6" + arr2[1] + " years&7.";
|
||||
} else {
|
||||
sender.sendMessage(com.songoda.epicfurnaces.utils.StringUtils.formatText(instance.getLocale().getPrefix() + "&7" + args[3] + " &7is invalid."));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
} else {
|
||||
c.add(Calendar.YEAR, 10);
|
||||
}
|
||||
|
||||
BoostData boostData = new BoostData(Integer.parseInt(args[2]), c.getTime().getTime(), Bukkit.getPlayer(args[1]).getUniqueId());
|
||||
instance.getBoostManager().addBoostToPlayer(boostData);
|
||||
sender.sendMessage(com.songoda.epicfurnaces.utils.StringUtils.formatText(instance.getLocale().getPrefix() + "&7Successfully boosted &6" + Bukkit.getPlayer(args[1]).getName() + "'s &7furnaces reward amounts by &6" + args[2] + "x" + time));
|
||||
}
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "epicfurnaces.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef boost <player> <multiplier> [m:minute, h:hour, d:day, y:year]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "This allows you to boost a players objects reward amounts by a multiplier (Put 2 for double, 3 for triple and so on).";
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package com.songoda.epicfurnaces.command.commands;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.command.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.utils.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CommandEpicFurnaces extends AbstractCommand {
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public CommandEpicFurnaces(EpicFurnaces instance) {
|
||||
super("EpicFurnaces", null, false);
|
||||
this.instance = instance;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(StringUtils.formatText(instance.getLocale().getPrefix() + "&7Version " + instance.getDescription().getVersion() + " Created with <3 by &5&l&oSongoda"));
|
||||
|
||||
for (AbstractCommand command : instance.getCommandManager().getCommands()) {
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
sender.sendMessage(StringUtils.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
}
|
||||
}
|
||||
sender.sendMessage("");
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Displays this page.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef";
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package com.songoda.epicfurnaces.command.commands;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.command.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.objects.Level;
|
||||
import com.songoda.epicfurnaces.utils.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandGive extends AbstractCommand {
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public CommandGive(EpicFurnaces instance, AbstractCommand parent) {
|
||||
super("give", parent, false);
|
||||
this.instance = instance;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length == 2) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
Level level = instance.getLevelManager().getLowestLevel();
|
||||
Player player;
|
||||
if (args.length != 1 && Bukkit.getPlayer(args[1]) == null) {
|
||||
sender.sendMessage(instance.getLocale().getPrefix() + StringUtils.formatText("&cThat player does not exist or is currently offline."));
|
||||
return ReturnType.FAILURE;
|
||||
} else if (args.length == 1) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(instance.getLocale().getPrefix() + StringUtils.formatText("&cYou need to be a player to give a farm item to yourself."));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
player = (Player) sender;
|
||||
} else {
|
||||
player = Bukkit.getPlayer(args[1]);
|
||||
}
|
||||
|
||||
|
||||
if (args.length >= 3 && !instance.getLevelManager().isLevel(Integer.parseInt(args[2]))) {
|
||||
sender.sendMessage(instance.getLocale().getPrefix() + StringUtils.formatText("&cNot a valid level... The current valid levels are: &4" + instance.getLevelManager().getLowestLevel().getLevel() + "-" + instance.getLevelManager().getHighestLevel().getLevel() + "&c."));
|
||||
return ReturnType.FAILURE;
|
||||
} else if (args.length != 1) {
|
||||
|
||||
level = instance.getLevelManager().getLevel(Integer.parseInt(args[2]));
|
||||
}
|
||||
player.getInventory().addItem(instance.getFurnaceManager().createLeveledFurnace(level.getLevel(), 0, instance));
|
||||
player.sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("command.give.success", level.getLevel()));
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "epicfurnaces.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef give [player] <level>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Give a leveled objects to a player.";
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package com.songoda.epicfurnaces.command.commands;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.command.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.utils.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CommandHelp extends AbstractCommand {
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public CommandHelp(EpicFurnaces instance, AbstractCommand parent) {
|
||||
super("help", parent, false);
|
||||
this.instance = instance;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCommand.ReturnType runCommand(CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(StringUtils.formatText(instance.getLocale().getPrefix() + "&7Version " + instance.getDescription().getVersion() + " Created with <3 by &5&l&oSongoda"));
|
||||
|
||||
for (AbstractCommand command : instance.getCommandManager().getCommands()) {
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
sender.sendMessage(StringUtils.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
}
|
||||
}
|
||||
sender.sendMessage("");
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Displays the help page.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef help";
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package com.songoda.epicfurnaces.command.commands;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.command.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.utils.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CommandReload extends AbstractCommand {
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public CommandReload(EpicFurnaces instance, AbstractCommand parent) {
|
||||
super("reload", parent, false);
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
instance.reload();
|
||||
sender.sendMessage(StringUtils.formatText(instance.getLocale().getPrefix() + "&7Configuration and Language files reloaded."));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "epicfurnaces.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Reload the Configuration and Language files.";
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package com.songoda.epicfurnaces.command.commands;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.command.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.objects.FurnaceObject;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandRemote extends AbstractCommand {
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public CommandRemote(EpicFurnaces instance, AbstractCommand abstractCommand) {
|
||||
super("remote", abstractCommand, true);
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (!instance.getConfig().getBoolean("Main.Access Furnaces Remotely") || !sender.hasPermission("EpicFurnaces.Remote")) {
|
||||
sender.sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("event.general.nopermission"));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
/*if (!instance.getConfiguration("data").contains("data.charged")) {
|
||||
return ReturnType.FAILURE;
|
||||
}*/
|
||||
|
||||
if (args.length < 2) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
String furnaceName = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
|
||||
|
||||
for (FurnaceObject furnace : instance.getFurnaceManager().getAllFurnaces().values()) {
|
||||
if (furnace.getNickname() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!furnace.getNickname().equalsIgnoreCase(furnaceName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (UUID uuid : furnace.getAccessList()) {
|
||||
if (!uuid.equals(((Player) sender).getUniqueId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Furnace furnaceBlock = (Furnace) furnace.getLocation().getBlock().getState();
|
||||
|
||||
this.instance.getFurnaceManager().getLoadedFurnaceInventories().put(furnaceBlock.getInventory(), furnaceBlock.getLocation());
|
||||
furnaceBlock.getChunk().load();
|
||||
|
||||
((Player) sender).openInventory(furnaceBlock.getInventory());
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
sender.sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("event.general.nopermission"));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
sender.sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("event.remote.notfound"));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef remote [nickname]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Remote control your objects.";
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.songoda.epicfurnaces.handlers;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/25/2017.
|
||||
*/
|
||||
public class BlacklistHandler {
|
||||
|
||||
private final EpicFurnaces instance;
|
||||
private FileConfiguration blackFile;
|
||||
|
||||
public BlacklistHandler(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
this.blackFile = instance.getConfiguration("blacklist");
|
||||
}
|
||||
|
||||
public boolean isBlacklisted(Player player) {
|
||||
boolean blacklisted = false;
|
||||
List<String> list = blackFile.getStringList("settings.blacklist");
|
||||
String cWorld = player.getWorld().getName();
|
||||
for (String world : list) {
|
||||
if (cWorld.equalsIgnoreCase(world)) {
|
||||
blacklisted = true;
|
||||
}
|
||||
}
|
||||
return blacklisted;
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
instance.save("blacklist");
|
||||
blackFile = instance.getConfiguration("blacklist");
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
package com.songoda.epicfurnaces.listeners;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.objects.FurnaceObject;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.songoda.epicfurnaces.objects.FurnaceObject.BoostType.OVERHEAT;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/26/2017.
|
||||
*/
|
||||
public class BlockListeners implements Listener {
|
||||
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public BlockListeners(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onSnowLand(BlockFormEvent event) {
|
||||
if (event.getNewState().getType() != Material.SNOW && event.getNewState().getType() != Material.ICE) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (FurnaceObject furnace : instance.getFurnaceManager().getFurnaces().values()) {
|
||||
if (furnace.getRadius(OVERHEAT) == null || ((Furnace) furnace.getLocation().getBlock().getState()).getBurnTime() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Location location : furnace.getRadius(OVERHEAT)) {
|
||||
if (location.getX() != event.getNewState().getX() || location.getY() != event.getNewState().getY() || location.getZ() != event.getNewState().getZ()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (event.getBlock().getType() != Material.FURNACE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = event.getItemInHand();
|
||||
Location location = event.getBlock().getLocation();
|
||||
|
||||
if (instance.getBlacklistHandler().isBlacklisted(event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
FurnaceObject furnaceObject = new FurnaceObject(instance,
|
||||
location,
|
||||
instance.getLevelManager().getLevel(instance.getFurnaceManager().getFurnaceLevel(item)),
|
||||
null,
|
||||
instance.getFurnaceManager().getFurnaceUses(item),
|
||||
0,
|
||||
new ArrayList<>(),
|
||||
event.getPlayer().getUniqueId());
|
||||
|
||||
instance.getFurnaceManager().addFurnace(location, furnaceObject);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (!event.getPlayer().hasPermission("epicfurnaces.overview") && !event.getPlayer().hasPermission("epicfurnaces.*")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.getBlacklistHandler().isBlacklisted(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getBlock().getType() != Material.FURNACE && event.getBlock().getType() != instance.getBukkitEnums().getMaterial("BURNING_FURNACE").getType()) {
|
||||
return;
|
||||
}
|
||||
|
||||
instance.getFurnaceManager().getFurnace(event.getBlock().getLocation()).ifPresent(this::handleBreak);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onBlockExplode(EntityExplodeEvent event) {
|
||||
Set<FurnaceObject> furnaces = event.blockList().parallelStream()
|
||||
.map(block -> instance.getFurnaceManager().getFurnace(block.getLocation()))
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
furnaces.forEach(this::handleBreak);
|
||||
}
|
||||
|
||||
private void handleBreak(FurnaceObject furnaceObject) {
|
||||
ItemStack item = instance.getFurnaceManager().createLeveledFurnace(furnaceObject.getLevel().getLevel(), furnaceObject.getUses(), instance);
|
||||
furnaceObject.getLocation().getBlock().setType(Material.AIR);
|
||||
furnaceObject.getLocation().getWorld().dropItemNaturally(furnaceObject.getLocation().getBlock().getLocation(), item);
|
||||
|
||||
instance.getFurnaceManager().removeFurnace(furnaceObject);
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package com.songoda.epicfurnaces.listeners;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.objects.FurnaceObject;
|
||||
import com.songoda.epicfurnaces.objects.Level;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/26/2017.
|
||||
*/
|
||||
public class FurnaceListeners implements Listener {
|
||||
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public FurnaceListeners(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCook(FurnaceSmeltEvent event) {
|
||||
if ((event.getBlock().isBlockPowered() && instance.getConfig().getBoolean("Main.Redstone Deactivates Furnaces"))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<FurnaceObject> furnace = instance.getFurnaceManager().getFurnace(event.getBlock().getLocation());
|
||||
|
||||
if (furnace.isPresent() && event.getSource().getType() != instance.getBukkitEnums().getMaterial("WET_SPONGE").getType()) {
|
||||
furnace.get().plus(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFuel(FurnaceBurnEvent event) {
|
||||
if (event.getFuel() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<FurnaceObject> furnace = instance.getFurnaceManager().getFurnace(event.getBlock().getLocation());
|
||||
Level level = furnace.isPresent() ? furnace.get().getLevel() : instance.getLevelManager().getLowestLevel();
|
||||
|
||||
if (level.getFuelDuration() != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int num = level.getFuelDuration();
|
||||
int per = (event.getBurnTime() / 100) * num;
|
||||
event.setBurnTime(event.getBurnTime() + per);
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package com.songoda.epicfurnaces.listeners;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/26/2017.
|
||||
*/
|
||||
public class InteractListeners implements Listener {
|
||||
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public InteractListeners(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onClick(PlayerInteractEvent event) {
|
||||
if (event.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.getBlacklistHandler().isBlacklisted(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (!player.hasPermission("EpicFurnaces.overview")
|
||||
|| event.getAction() != Action.LEFT_CLICK_BLOCK
|
||||
|| player.isSneaking()
|
||||
|| (block.getType() != Material.FURNACE && block.getType() != instance.getBukkitEnums().getMaterial("BURNING_FURNACE").getType())
|
||||
|| player.getInventory().getItemInHand().getType().name().contains("PICKAXE")) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
instance.getFurnaceManager().getFurnace(block.getLocation()).orElseGet(() -> instance.getFurnaceManager().createFurnace(block.getLocation())).openOverview(player);
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package com.songoda.epicfurnaces.listeners;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.objects.FurnaceObject;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.bukkit.event.inventory.InventoryAction.NOTHING;
|
||||
import static org.bukkit.event.inventory.InventoryType.*;
|
||||
import static org.bukkit.event.inventory.InventoryType.SlotType.CRAFTING;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/26/2017.
|
||||
*/
|
||||
public class InventoryListeners implements Listener {
|
||||
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public InventoryListeners(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
Inventory inventory = event.getInventory();
|
||||
Map<Inventory, Location> loadedFurnaceInventories = this.instance.getFurnaceManager().getLoadedFurnaceInventories();
|
||||
Location location = loadedFurnaceInventories.get(inventory);
|
||||
if (location == null)
|
||||
return;
|
||||
|
||||
location.getChunk().unload();
|
||||
loadedFurnaceInventories.remove(inventory);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryMove(InventoryMoveItemEvent event) {
|
||||
if (!event.getDestination().getType().equals(FURNACE)
|
||||
|| event.getDestination().getItem(0) == null
|
||||
|| event.getDestination().getItem(0).getType() != event.getItem().getType()
|
||||
|| event.getDestination().getItem(0).getAmount() != 1) {
|
||||
return;
|
||||
}
|
||||
instance.getFurnaceManager().getFurnace(((Furnace) event.getDestination().getHolder()).getLocation()).ifPresent(FurnaceObject::updateCook);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getInventory().getType().equals(FURNACE)
|
||||
&& event.getInventory().getHolder() != null
|
||||
&& event.getSlotType() == CRAFTING) {
|
||||
Block block = ((Furnace) event.getInventory().getHolder()).getLocation().getBlock();
|
||||
instance.getFurnaceManager().getFurnace(block.getLocation()).ifPresent(FurnaceObject::updateCook);
|
||||
}
|
||||
|
||||
if (event.getSlot() == 64537 || event.getInventory().getType() != ANVIL || event.getAction() == NOTHING) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCurrentItem().getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = event.getCurrentItem();
|
||||
|
||||
if (item.getType() == Material.FURNACE) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
package com.songoda.epicfurnaces.managers;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.objects.BoostData;
|
||||
import com.songoda.epicfurnaces.objects.FurnaceObject;
|
||||
import com.songoda.epicfurnaces.storage.Storage;
|
||||
import com.songoda.epicfurnaces.storage.StorageItem;
|
||||
import com.songoda.epicfurnaces.storage.StorageRow;
|
||||
import com.songoda.epicfurnaces.utils.Methods;
|
||||
import com.songoda.epicfurnaces.utils.gui.ItemBuilder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.bukkit.Material.FURNACE;
|
||||
|
||||
public class FurnaceManager {
|
||||
|
||||
private final Map<Location, FurnaceObject> registeredFurnaces = new HashMap<>();
|
||||
private final Map<Inventory, Location> loadedFurnaceInventories = new HashMap<>();
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public FurnaceManager(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public FurnaceObject addFurnace(Location location, FurnaceObject furnace) {
|
||||
instance.getHologramManager().ifPresent(manager -> manager.updateHologram(furnace));
|
||||
registeredFurnaces.put(roundLocation(location), furnace);
|
||||
return furnace;
|
||||
}
|
||||
|
||||
public FurnaceObject createFurnace(Location location) {
|
||||
return addFurnace(location, new FurnaceObject(instance, location, instance.getLevelManager().getLowestLevel(), null, 0, 0, new ArrayList<>(), null));
|
||||
}
|
||||
|
||||
public void removeFurnace(FurnaceObject furnaceObject) {
|
||||
removeFurnace(furnaceObject.getLocation());
|
||||
}
|
||||
|
||||
public void removeFurnace(Location location) {
|
||||
instance.getHologramManager().ifPresent(manager -> manager.remove(registeredFurnaces.remove(location)));
|
||||
}
|
||||
|
||||
public Optional<FurnaceObject> getFurnace(Location location) {
|
||||
return Optional.ofNullable(registeredFurnaces.get(location));
|
||||
}
|
||||
|
||||
public int getFurnaceLevel(ItemStack item) {
|
||||
if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
String[] arr = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
return StringUtils.isNumeric(arr[0]) ? Integer.parseInt(arr[0]) : 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getFurnaceUses(ItemStack item) {
|
||||
if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
String[] arr = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
return StringUtils.isNumeric(arr[1]) ? Integer.parseInt(arr[1]) : 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private Location roundLocation(Location location) {
|
||||
return location.getBlock().getLocation().clone();
|
||||
}
|
||||
|
||||
public ItemStack createLeveledFurnace(int level, int uses, EpicFurnaces epicFurnaces) {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(FURNACE);
|
||||
|
||||
if (epicFurnaces.getConfig().getBoolean("Main.Remember Furnace Item Levels")) {
|
||||
itemBuilder.name(com.songoda.epicfurnaces.utils.StringUtils.formatText(com.songoda.epicfurnaces.utils.StringUtils.formatName(level, uses, true)));
|
||||
}
|
||||
|
||||
return itemBuilder.build();
|
||||
}
|
||||
|
||||
public void loadFurnaces() {
|
||||
Storage storage = instance.getStorage();
|
||||
if (storage.containsGroup("charged")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("charged")) {
|
||||
Location location = Methods.deserializeLocation(row.getKey());
|
||||
if (location == null || location.getBlock() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int level = row.get("level").asInt();
|
||||
int uses = row.get("uses").asInt();
|
||||
int toLevel = row.get("level").asInt();
|
||||
String nickname = row.get("nickname").asString();
|
||||
List<String> accessList = row.get("accesslist").asStringList();
|
||||
String placedByStr = row.get("placedBy").asString();
|
||||
UUID placedBy = placedByStr == null ? null : UUID.fromString(placedByStr);
|
||||
FurnaceObject furnace = new FurnaceObject(instance, location, instance.getLevelManager().getLevel(level), nickname, uses, toLevel, accessList, placedBy);
|
||||
|
||||
addFurnace(location, furnace);
|
||||
}
|
||||
}
|
||||
|
||||
if (storage.containsGroup("boosts")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("boosts")) {
|
||||
if (row.getItems().get("uuid").asObject() != null) {
|
||||
continue;
|
||||
}
|
||||
BoostData boostData = new BoostData(row.get("amount").asInt(), Long.parseLong(row.getKey()), UUID.fromString(row.get("uuid").asString()));
|
||||
instance.getBoostManager().addBoostToPlayer(boostData);
|
||||
}
|
||||
}
|
||||
|
||||
if (!instance.getConfig().getBoolean("Main.Furnaces Have Holograms")) {
|
||||
return;
|
||||
}
|
||||
|
||||
getFurnaces().values().forEach(furnace -> instance.getHologramManager().ifPresent(manager -> manager.updateHologram(furnace)));
|
||||
}
|
||||
|
||||
public Map<Inventory, Location> getLoadedFurnaceInventories() {
|
||||
return this.loadedFurnaceInventories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Map of all furnaces that are in loaded chunks
|
||||
*
|
||||
* @return All furnaces in memory that are in loaded chunks
|
||||
*/
|
||||
public Map<Location, FurnaceObject> getFurnaces() {
|
||||
Map<Location, FurnaceObject> furnaces = new HashMap<>();
|
||||
for (Location location : this.registeredFurnaces.keySet())
|
||||
if (location.getWorld() != null && location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4))
|
||||
furnaces.put(location, this.registeredFurnaces.get(location));
|
||||
return furnaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Map of all furnaces, regardless if they are in loaded chunks or not.
|
||||
* Getting the furnace's block in an unloaded chunk will load the chunk.
|
||||
*
|
||||
* @return All furnaces in memory
|
||||
*/
|
||||
public Map<Location, FurnaceObject> getAllFurnaces() {
|
||||
return Collections.unmodifiableMap(this.registeredFurnaces);
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
package com.songoda.epicfurnaces.managers;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
import com.gmail.filoghost.holographicdisplays.api.line.TextLine;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.objects.FurnaceObject;
|
||||
import com.songoda.epicfurnaces.utils.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Furnace;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class HologramManager {
|
||||
private final Map<FurnaceObject, Hologram> hologramMap;
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public HologramManager(EpicFurnaces instance) {
|
||||
this.hologramMap = new HashMap<>();
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public void updateHologram(FurnaceObject furnaceObject) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (furnaceObject.getLocation().getBlock().getType() != Material.FURNACE &&
|
||||
furnaceObject.getLocation().getBlock().getType() != instance.getBukkitEnums().getMaterial("BURNING_FURNACE").getType()) {
|
||||
if (hologramMap.containsKey(furnaceObject)) {
|
||||
hologramMap.remove(furnaceObject).delete();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Furnace furnaceBlock = (Furnace) furnaceObject.getLocation().getBlock().getState();
|
||||
|
||||
int performance = (furnaceBlock.getCookTime() - furnaceObject.getPerformanceTotal()) <= 0 ? 0 : furnaceObject.getPerformanceTotal();
|
||||
float percent = (float) (furnaceBlock.getCookTime() - performance) / (200 - performance);
|
||||
int progressBars = (int) (6 * percent) + (percent == 0 ? 0 : 1);
|
||||
int leftOver = (6 - progressBars);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < progressBars; i++) {
|
||||
sb.append("&a=");
|
||||
}
|
||||
|
||||
for (int i = 0; i < leftOver; i++) {
|
||||
sb.append("&c=");
|
||||
}
|
||||
|
||||
String progress = StringUtils.formatText(sb.toString());
|
||||
|
||||
if (furnaceBlock.getInventory().getFuel() == null) {
|
||||
progress = instance.getLocale().getMessage("general.hologram.outoffuel");
|
||||
}
|
||||
|
||||
int inAmt = 0;
|
||||
int outAmt = 0;
|
||||
|
||||
if (furnaceBlock.getInventory().getSmelting() != null) {
|
||||
inAmt = furnaceBlock.getInventory().getSmelting().getAmount();
|
||||
}
|
||||
|
||||
if (furnaceBlock.getInventory().getResult() != null) {
|
||||
outAmt = furnaceBlock.getInventory().getResult().getAmount();
|
||||
}
|
||||
|
||||
String stats = instance.getLocale().getMessage("general.hologram.stats", inAmt, outAmt > 64 ? 64 : outAmt);
|
||||
Hologram hologram;
|
||||
|
||||
if (!hologramMap.containsKey(furnaceObject)) {
|
||||
BlockFace direction = ((org.bukkit.material.Furnace) furnaceBlock.getData()).getFacing();
|
||||
Location location = instance.getConfig().getBoolean("Main.Hologram in front") ?
|
||||
furnaceObject.getLocation().getBlock().getRelative(direction).getLocation().add(0.5, 0.8, 0.5) :
|
||||
furnaceBlock.getLocation().add(0.5, 1.8, 0.5);
|
||||
hologram = HologramsAPI.createHologram(instance, location);
|
||||
} else {
|
||||
hologram = hologramMap.get(furnaceObject);
|
||||
}
|
||||
|
||||
if (hologram.size() == 0) {
|
||||
hologram.clearLines();
|
||||
hologram.insertTextLine(0, progress);
|
||||
hologram.insertTextLine(1, stats);
|
||||
} else {
|
||||
((TextLine) hologram.getLine(0)).setText(progress);
|
||||
((TextLine) hologram.getLine(1)).setText(stats);
|
||||
}
|
||||
hologramMap.put(furnaceObject, hologram);
|
||||
});
|
||||
}
|
||||
|
||||
public void remove(FurnaceObject furnaceObject) {
|
||||
Optional.ofNullable(hologramMap.remove(furnaceObject)).ifPresent(Hologram::delete);
|
||||
}
|
||||
|
||||
|
||||
public void clearAll() {
|
||||
hologramMap.values().forEach(Hologram::delete);
|
||||
hologramMap.clear();
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package com.songoda.epicfurnaces.managers;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.objects.Level;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LevelManager {
|
||||
|
||||
private final NavigableMap<Integer, Level> registeredLevels = new TreeMap<>();
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public LevelManager(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
|
||||
public void addLevel(int level, int costExperience, int costEconomy, int performance, String reward, int fuelDuration, int overheat, int fuelShare) {
|
||||
registeredLevels.put(level, new Level(instance, level, costExperience, costEconomy, performance, reward, fuelDuration, overheat, fuelShare));
|
||||
}
|
||||
|
||||
public void loadLevelManager() {
|
||||
clear();
|
||||
for (String levelName : instance.getConfig().getConfigurationSection("settings.levels").getKeys(false)) {
|
||||
int level = Integer.valueOf(levelName.split("-")[1]);
|
||||
int costExperience = instance.getConfig().getInt("settings.levels." + levelName + ".Cost-xp");
|
||||
int costEconomy = instance.getConfig().getInt("settings.levels." + levelName + ".Cost-eco");
|
||||
|
||||
String performanceStr = instance.getConfig().getString("settings.levels." + levelName + ".Performance");
|
||||
int performance = performanceStr == null ? 0 : Integer.parseInt(performanceStr.substring(0, performanceStr.length() - 1));
|
||||
|
||||
String reward = instance.getConfig().getString("settings.levels." + levelName + ".Reward");
|
||||
|
||||
String fuelDurationStr = instance.getConfig().getString("settings.levels." + levelName + ".Fuel-duration");
|
||||
int fuelDuration = fuelDurationStr == null ? 0 : Integer.parseInt(fuelDurationStr.substring(0, fuelDurationStr.length() - 1));
|
||||
|
||||
int overheat = instance.getConfig().getInt("settings.levels." + levelName + ".Overheat");
|
||||
int fuelShare = instance.getConfig().getInt("settings.levels." + levelName + ".Fuel-share");
|
||||
|
||||
addLevel(level, costExperience, costEconomy, performance, reward, fuelDuration, overheat, fuelShare);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Level getLevel(int level) {
|
||||
return registeredLevels.get(level);
|
||||
}
|
||||
|
||||
|
||||
public Level getLowestLevel() {
|
||||
return registeredLevels.firstEntry().getValue();
|
||||
}
|
||||
|
||||
|
||||
public Level getHighestLevel() {
|
||||
return registeredLevels.lastEntry().getValue();
|
||||
}
|
||||
|
||||
|
||||
public boolean isLevel(int level) {
|
||||
return registeredLevels.containsKey(level);
|
||||
}
|
||||
|
||||
|
||||
public Map<Integer, Level> getLevels() {
|
||||
return Collections.unmodifiableMap(registeredLevels);
|
||||
}
|
||||
|
||||
|
||||
public void clear() {
|
||||
registeredLevels.clear();
|
||||
}
|
||||
}
|
@ -1,213 +0,0 @@
|
||||
package com.songoda.epicfurnaces.menus;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.objects.BoostData;
|
||||
import com.songoda.epicfurnaces.objects.FurnaceObject;
|
||||
import com.songoda.epicfurnaces.objects.Level;
|
||||
import com.songoda.epicfurnaces.utils.Methods;
|
||||
import com.songoda.epicfurnaces.utils.StringUtils;
|
||||
import com.songoda.epicfurnaces.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.epicfurnaces.utils.gui.FastInv;
|
||||
import com.songoda.epicfurnaces.utils.gui.ItemBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.songoda.epicfurnaces.utils.gui.AbstractAnvilGUI.AnvilSlot.INPUT_LEFT;
|
||||
import static org.bukkit.Material.*;
|
||||
|
||||
public class OverviewMenu extends FastInv {
|
||||
|
||||
public OverviewMenu(EpicFurnaces instance, FurnaceObject furnace, Player accessor) {
|
||||
super(27, StringUtils.formatName(furnace.getLevel().getLevel(), 0, false));
|
||||
|
||||
Level nextLevel = instance.getLevelManager().getHighestLevel().getLevel() > furnace.getLevel().getLevel() ? instance.getLevelManager().getLevel(furnace.getLevel().getLevel() + 1) : null;
|
||||
int multi = instance.getConfig().getInt("Main.Level Cost Multiplier");
|
||||
int needed = (multi * furnace.getLevel().getLevel()) - furnace.getToLevel();
|
||||
|
||||
ItemBuilder currentLevel = new ItemBuilder(FURNACE);
|
||||
currentLevel.name(instance.getLocale().getMessage("interface.furnace.currentlevel", furnace.getLevel().getLevel()));
|
||||
currentLevel.lore(instance.getLocale().getMessage("interface.furnace.smeltedx", furnace.getUses()));
|
||||
currentLevel.addLore(furnace.getLevel().getDescription());
|
||||
currentLevel.addLore("");
|
||||
|
||||
if (nextLevel == null)
|
||||
currentLevel.addLore(instance.getLocale().getMessage("interface.furnace.alreadymaxed"));
|
||||
else {
|
||||
currentLevel.addLore(instance.getLocale().getMessage("interface.furnace.level", nextLevel.getLevel()));
|
||||
currentLevel.addLore(nextLevel.getDescription());
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Upgrade By Smelting Materials")) {
|
||||
currentLevel.addLore(instance.getLocale().getMessage("interface.furnace.tolevel", needed, StringUtils.cleanString(instance.getConfig().getString("Main.Furnace Upgrade Cost"))));
|
||||
}
|
||||
}
|
||||
|
||||
BoostData boostData = instance.getBoostManager().getBoost(furnace.getPlacedBy());
|
||||
if (boostData != null) {
|
||||
String[] parts = instance.getLocale().getMessage("interface.button.boostedstats", "" + boostData.getMultiplier(), StringUtils.msToString(boostData.getEndTime() - System.currentTimeMillis())).split("\\|");
|
||||
currentLevel.addLore("");
|
||||
for (String line : parts) {
|
||||
currentLevel.addLore(StringUtils.formatText(line));
|
||||
}
|
||||
}
|
||||
|
||||
fill(Methods.getGlass());
|
||||
|
||||
ItemBuilder performance = new ItemBuilder(instance.getBukkitEnums().getMaterial(instance.getConfig().getString("Interfaces.Performance Icon")));
|
||||
performance.name(instance.getLocale().getMessage("interface.furnace.performancetitle"));
|
||||
String[] parts = instance.getLocale().getMessage("interface.furnace.performanceinfo", furnace.getLevel().getPerformance()).split("\\|");
|
||||
performance.lore(Arrays.stream(parts).map(StringUtils::formatText).collect(Collectors.toList()));
|
||||
|
||||
ItemBuilder reward = new ItemBuilder(instance.getBukkitEnums().getMaterial(instance.getConfig().getString("Interfaces.Reward Icon")));
|
||||
reward.name(instance.getLocale().getMessage("interface.furnace.rewardtitle"));
|
||||
parts = instance.getLocale().getMessage("interface.furnace.rewardinfo", furnace.getLevel().getReward().split(":")[0].replace("%", "")).split("\\|");
|
||||
reward.lore(Arrays.stream(parts).map(StringUtils::formatText).collect(Collectors.toList()));
|
||||
|
||||
ItemBuilder duration = new ItemBuilder(instance.getBukkitEnums().getMaterial(instance.getConfig().getString("Interfaces.FuelDuration Icon")));
|
||||
duration.name(instance.getLocale().getMessage("interface.furnace.fueldurationtitle"));
|
||||
parts = instance.getLocale().getMessage("interface.furnace.fueldurationinfo", furnace.getLevel().getFuelDuration()).split("\\|");
|
||||
duration.lore(Arrays.stream(parts).map(StringUtils::formatText).collect(Collectors.toList()));
|
||||
|
||||
ItemBuilder overheat = new ItemBuilder(instance.getBukkitEnums().getMaterial(instance.getConfig().getString("Interfaces.Overheat Icon")));
|
||||
overheat.name(instance.getLocale().getMessage("interface.furnace.overheattitle"));
|
||||
parts = instance.getLocale().getMessage("interface.furnace.overheatinfo", furnace.getLevel().getOverheat() * 3).split("\\|");
|
||||
overheat.lore(Arrays.stream(parts).map(StringUtils::formatText).collect(Collectors.toList()));
|
||||
|
||||
ItemBuilder fuelShare = new ItemBuilder(instance.getBukkitEnums().getMaterial(instance.getConfig().getString("Interfaces.FuelShare Icon")));
|
||||
fuelShare.name(instance.getLocale().getMessage("interface.furnace.fuelsharetitle"));
|
||||
parts = instance.getLocale().getMessage("interface.furnace.fuelshareinfo", furnace.getLevel().getFuelShare() * 3).split("\\|");
|
||||
fuelShare.lore(Arrays.stream(parts).map(StringUtils::formatText).collect(Collectors.toList()));
|
||||
|
||||
ItemBuilder xp = new ItemBuilder(instance.getBukkitEnums().getMaterial(instance.getConfig().getString("Interfaces.XP Icon")));
|
||||
xp.name(instance.getLocale().getMessage("interface.furnace.upgradewithxp"));
|
||||
xp.lore(nextLevel == null ? instance.getLocale().getMessage("interface.furnace.alreadymaxed") :
|
||||
instance.getLocale().getMessage("interface.furnace.upgradewithxplore", furnace.getLevel().getCostExperience()));
|
||||
|
||||
ItemBuilder eco = new ItemBuilder(instance.getBukkitEnums().getMaterial(instance.getConfig().getString("Interfaces.Economy Icon")));
|
||||
eco.name(instance.getLocale().getMessage("interface.furnace.upgradewitheconomy"));
|
||||
eco.lore(nextLevel == null ? instance.getLocale().getMessage("interface.furnace.alreadymaxed") :
|
||||
instance.getLocale().getMessage("interface.furnace.upgradewitheconomylore", StringUtils.formatEconomy(furnace.getLevel().getCostEconomy())));
|
||||
|
||||
ItemBuilder remote = new ItemBuilder(TRIPWIRE_HOOK);
|
||||
remote.name(instance.getLocale().getMessage("interface.furnace.remotefurnace"));
|
||||
parts = instance.getLocale().getMessage("interface.furnace.remotefurnacelore", furnace.getNickname() == null ? "Unset" : furnace.getNickname()).split("\\|");
|
||||
remote.lore(Arrays.stream(parts).map(StringUtils::formatText).collect(Collectors.toList()));
|
||||
|
||||
if (furnace.getNickname() != null) {
|
||||
parts = instance.getLocale().getMessage("interface.furnace.utilize", furnace.getNickname()).split("\\|");
|
||||
remote.addLore(Arrays.stream(parts).map(StringUtils::formatText).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
if (!furnace.getOriginalAccessList().isEmpty()) {
|
||||
remote.addLore("");
|
||||
remote.addLore(instance.getLocale().getMessage("interface.furnace.remotelist"));
|
||||
}
|
||||
|
||||
for (String line : furnace.getOriginalAccessList()) {
|
||||
String[] halfs = line.split(":");
|
||||
String name = halfs[1];
|
||||
Player player = Bukkit.getPlayer(halfs[0]);
|
||||
|
||||
if (player != null) {
|
||||
name = player.getDisplayName();
|
||||
}
|
||||
remote.addLore(StringUtils.formatText("&6" + name));
|
||||
}
|
||||
|
||||
addItem(new int[]{0, 1, 7, 8, 9, 17, 18, 19, 25, 26}, Methods.getBackgroundGlass(true));
|
||||
addItem(new int[]{2, 6, 10, 16, 20, 24}, Methods.getBackgroundGlass(false));
|
||||
|
||||
int num = -1;
|
||||
Map<Integer, int[]> spots = new HashMap<Integer, int[]>() {{
|
||||
put(0, new int[]{22});
|
||||
put(1, new int[]{21, 23});
|
||||
put(2, new int[]{21, 22, 23});
|
||||
put(3, new int[]{20, 21, 23, 24});
|
||||
put(4, new int[]{20, 21, 22, 23, 24});
|
||||
}};
|
||||
|
||||
num += furnace.getLevel().getPerformance() == 0 ? 0 : 1;
|
||||
num += (furnace.getLevel().getReward() == null ? 0 : 1);
|
||||
num += furnace.getLevel().getFuelDuration() == 0 ? 0 : 1;
|
||||
num += furnace.getLevel().getFuelShare() == 0 ? 0 : 1;
|
||||
num += furnace.getLevel().getOverheat() == 0 ? 0 : 1;
|
||||
|
||||
int[] order = spots.get(num);
|
||||
int current = 0;
|
||||
|
||||
if (furnace.getLevel().getPerformance() != 0) {
|
||||
addItem(order[current], performance.build());
|
||||
current++;
|
||||
}
|
||||
if (furnace.getLevel().getReward() != null) {
|
||||
addItem(order[current], reward.build());
|
||||
current++;
|
||||
}
|
||||
if (furnace.getLevel().getFuelDuration() != 0) {
|
||||
addItem(order[current], duration.build());
|
||||
current++;
|
||||
}
|
||||
if (furnace.getLevel().getFuelShare() != 0) {
|
||||
addItem(order[current], fuelShare.build());
|
||||
current++;
|
||||
}
|
||||
if (furnace.getLevel().getOverheat() != 0) {
|
||||
addItem(order[current], overheat.build());
|
||||
}
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Access Furnaces Remotely") && accessor.hasPermission("EpicFurnaces.Remote")) {
|
||||
addItem(4, remote.build(), event -> {
|
||||
if (event.getClickType().isLeftClick()) {
|
||||
event.getPlayer().sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("event.remote.enter"));
|
||||
|
||||
AbstractAnvilGUI anvilGUI = new AbstractAnvilGUI(instance, event.getPlayer(), anvilEvent -> {
|
||||
for (FurnaceObject other : instance.getFurnaceManager().getAllFurnaces().values()) {
|
||||
if (other.getNickname() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (other.getNickname().equalsIgnoreCase(anvilEvent.getName())) {
|
||||
event.getPlayer().sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("event.remote.nicknameinuse"));
|
||||
furnace.openOverview(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
furnace.setNickname(anvilEvent.getName());
|
||||
furnace.openOverview(event.getPlayer());
|
||||
event.getPlayer().sendMessage(instance.getLocale().getPrefix() + instance.getLocale().getMessage("event.remote.nicknamesuccess"));
|
||||
});
|
||||
|
||||
anvilGUI.setOnClose((closer, inv) -> furnace.openOverview(closer));
|
||||
anvilGUI.setSlot(INPUT_LEFT, new ItemBuilder(PAPER).name("Enter a nickname").build());
|
||||
anvilGUI.open();
|
||||
} else if (event.getClickType().isRightClick()) {
|
||||
if (!furnace.getAccessList().contains(event.getPlayer().getUniqueId())) {
|
||||
furnace.addToAccessList(event.getPlayer().getUniqueId().toString() + ":" + event.getPlayer().getName());
|
||||
furnace.openOverview(event.getPlayer());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Upgrade With XP") && accessor.hasPermission("EpicFurnaces.Upgrade.XP")) {
|
||||
addItem(11, xp.build(), event -> {
|
||||
furnace.upgrade("XP", event.getPlayer());
|
||||
furnace.openOverview(event.getPlayer());
|
||||
});
|
||||
}
|
||||
if (instance.getConfig().getBoolean("Main.Upgrade With Economy") && accessor.hasPermission("EpicFurnaces.Upgrade.ECO")) {
|
||||
addItem(15, eco.build(), event -> {
|
||||
furnace.upgrade("ECO", event.getPlayer());
|
||||
furnace.openOverview(event.getPlayer());
|
||||
});
|
||||
}
|
||||
|
||||
addItem(13, currentLevel.build());
|
||||
|
||||
}
|
||||
}
|
@ -1,339 +0,0 @@
|
||||
package com.songoda.epicfurnaces.objects;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.menus.OverviewMenu;
|
||||
import com.songoda.epicfurnaces.utils.NMSUtil;
|
||||
import com.songoda.epicfurnaces.utils.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
import static com.songoda.epicfurnaces.objects.FurnaceObject.BoostType.*;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/7/2017.
|
||||
*/
|
||||
public class FurnaceObject {
|
||||
|
||||
private final EpicFurnaces instance;
|
||||
private Location location;
|
||||
private Level level;
|
||||
private String nickname;
|
||||
private UUID placedBy;
|
||||
private int uses, toLevel, radiusOverheatLast, radiusFuelShareLast;
|
||||
private List<Location> radiusOverheat = new ArrayList<>();
|
||||
private List<Location> radiusFuelShare = new ArrayList<>();
|
||||
private List<String> accessList;
|
||||
|
||||
public FurnaceObject(EpicFurnaces instance, Location location, Level level, String nickname, int uses, int toLevel, List<String> accessList, UUID placedBy) {
|
||||
this.instance = instance;
|
||||
this.location = location;
|
||||
this.level = level;
|
||||
this.uses = uses;
|
||||
this.toLevel = toLevel;
|
||||
this.nickname = nickname;
|
||||
this.placedBy = placedBy;
|
||||
this.accessList = accessList;
|
||||
this.syncName();
|
||||
}
|
||||
|
||||
public void openOverview(Player player) {
|
||||
if (!player.hasPermission("epicfurnaces.overview")) {
|
||||
return;
|
||||
}
|
||||
|
||||
new OverviewMenu(instance, this, player).open(player);
|
||||
}
|
||||
|
||||
public void plus(FurnaceSmeltEvent e) {
|
||||
Block block = location.getBlock();
|
||||
if (block.getType() != Material.FURNACE && block.getType() != instance.getBukkitEnums().getMaterial("BURNING_FURNACE").getType()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.uses++;
|
||||
this.toLevel++;
|
||||
|
||||
int multi = instance.getConfig().getInt("Main.Level Cost Multiplier");
|
||||
|
||||
if (level.getReward() == null) return;
|
||||
|
||||
String reward = level.getReward();
|
||||
String[] amt = {"1", "1"};
|
||||
if (reward.contains(":")) {
|
||||
String[] rewardSplit = reward.split(":");
|
||||
reward = rewardSplit[0].substring(0, rewardSplit[0].length() - 1);
|
||||
if (rewardSplit[1].contains("-"))
|
||||
amt = rewardSplit[1].split("-");
|
||||
else {
|
||||
amt[0] = rewardSplit[1];
|
||||
amt[1] = rewardSplit[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int needed = ((multi * level.getLevel()) - toLevel) - 1;
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Upgrade By Smelting Materials")
|
||||
&& needed <= 0
|
||||
&& instance.getConfig().contains("settings.levels.Level-" + (level.getLevel() + 1))) {
|
||||
toLevel = 0;
|
||||
level = instance.getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
}
|
||||
|
||||
updateCook();
|
||||
|
||||
FurnaceInventory inventory = (FurnaceInventory) ((InventoryHolder) block.getState()).getInventory();
|
||||
|
||||
int num = Integer.parseInt(reward);
|
||||
double rand = Math.random() * 100;
|
||||
if (rand >= num
|
||||
|| e.getResult().getType().equals(Material.SPONGE)
|
||||
|| instance.getConfig().getBoolean("Main.No Rewards From Custom Recipes")
|
||||
&& instance.getConfiguration("Furnace Recipes").contains("Recipes." + inventory.getSmelting().getType().toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
int r = Integer.parseInt(amt[0]);
|
||||
if (Integer.parseInt(amt[0]) !=
|
||||
Integer.parseInt(amt[1].replace("%", "")))
|
||||
r = (int) (Math.random() * ((Integer.parseInt(amt[1].replace("%", "")) - Integer.parseInt(amt[0])))) + Integer.parseInt(amt[0]);
|
||||
|
||||
BoostData boostData = instance.getBoostManager().getBoost(placedBy);
|
||||
r = r * (boostData == null ? 1 : boostData.getMultiplier());
|
||||
|
||||
e.getResult().setAmount(e.getResult().getAmount() + r);
|
||||
}
|
||||
|
||||
public void upgrade(String type, Player player) {
|
||||
if (!instance.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1))
|
||||
return;
|
||||
|
||||
int cost = type.equals("XP") ? level.getCostExperience() : level.getCostEconomy();
|
||||
Level level = instance.getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
|
||||
if (type.equals("ECO")) {
|
||||
if (instance.getEconomy().has(player, cost)) {
|
||||
instance.getEconomy().withdrawPlayer(player, cost);
|
||||
upgradeFinal(level, player);
|
||||
return;
|
||||
}
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.cannotafford"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getLevel() >= cost || player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
player.setLevel(player.getLevel() - cost);
|
||||
}
|
||||
upgradeFinal(level, player);
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.cannotafford"));
|
||||
}
|
||||
|
||||
private void upgradeFinal(Level level, Player player) {
|
||||
this.level = level;
|
||||
syncName();
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.success", level.getLevel()));
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.maxed", level.getLevel()));
|
||||
}
|
||||
|
||||
Location loc = location.clone().add(.5, .5, .5);
|
||||
|
||||
if (instance.getCurrentVersion() > 8)
|
||||
location.getWorld().spawnParticle(Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), loc.getX(), loc.getY(), loc.getZ(), 200, .5, .5, .5);
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Sounds Enabled")) {
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
player.playSound(player.getLocation(), instance.getBukkitEnums().getSound("ENTITY_PLAYER_LEVELUP"), 0.6F, 15.0F);
|
||||
} else {
|
||||
player.playSound(player.getLocation(), instance.getBukkitEnums().getSound("ENTITY_PLAYER_LEVELUP"), 2F, 25.0F);
|
||||
player.playSound(player.getLocation(), instance.getBukkitEnums().getSound("BLOCK_NOTE_BLOCK_CHIME"), 2F, 25.0F);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.playSound(player.getLocation(), instance.getBukkitEnums().getSound("BLOCK_NOTE_BLOCK_CHIME"), 1.2F, 35.0F), 5L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.playSound(player.getLocation(), instance.getBukkitEnums().getSound("BLOCK_NOTE_BLOCK_CHIME"), 1.8F, 35.0F), 10L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void syncName() {
|
||||
if (location.getBlock().getType() != Material.FURNACE && location.getBlock().getType() != instance.getBukkitEnums().getMaterial("BURNING_FURNACE").getType()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = StringUtils.formatName(level.getLevel(), uses, false);
|
||||
|
||||
try {
|
||||
Furnace craftFurnace = (Furnace) location.getBlock().getState();
|
||||
craftFurnace.setCustomName(name);
|
||||
craftFurnace.update(true);
|
||||
} catch (Exception | Error e) {
|
||||
try {
|
||||
Object craftFurnace = NMSUtil.getCraftClass("block.CraftFurnace").cast(location.getBlock().getState());
|
||||
Method getTileEntity = craftFurnace.getClass().getDeclaredMethod("getTileEntity");
|
||||
Object tileEntity = getTileEntity.invoke(craftFurnace);
|
||||
Method a = tileEntity.getClass().getDeclaredMethod("a", String.class);
|
||||
a.invoke(tileEntity, name);
|
||||
} catch (Exception | Error ignore) {
|
||||
}
|
||||
} finally {
|
||||
location.getBlock().getState().update(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCook() {
|
||||
Block block = location.getBlock();
|
||||
if (block == null || (block.getType() != Material.FURNACE && block.getType() != instance.getBukkitEnums().getMaterial("BURNING_FURNACE").getType())) {
|
||||
return;
|
||||
}
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
int num = getPerformanceTotal();
|
||||
|
||||
if (num > 200) {
|
||||
num = 200;
|
||||
}
|
||||
|
||||
if (num != 0) {
|
||||
BlockState bs = (block.getState()); // max is 200
|
||||
((Furnace) bs).setCookTime(Short.parseShort(Integer.toString(num)));
|
||||
bs.update();
|
||||
}
|
||||
}, 1L);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean addToAccessList(String string) {
|
||||
return accessList.add(string);
|
||||
}
|
||||
|
||||
|
||||
public boolean removeFromAccessList(String string) {
|
||||
return accessList.remove(string);
|
||||
}
|
||||
|
||||
|
||||
public void clearAccessList() {
|
||||
accessList.clear();
|
||||
}
|
||||
|
||||
|
||||
public List<Location> getRadius(BoostType boostType) {
|
||||
if (boostType == OVERHEAT) {
|
||||
return radiusOverheat.isEmpty() ? null : Collections.unmodifiableList(radiusOverheat);
|
||||
} else if (boostType == FUEL_SHARE) {
|
||||
return radiusFuelShare.isEmpty() ? null : Collections.unmodifiableList(radiusFuelShare);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void addToRadius(Location location, BoostType boostType) {
|
||||
if (boostType == OVERHEAT) {
|
||||
radiusOverheat.add(location);
|
||||
} else if (boostType == FUEL_SHARE) {
|
||||
radiusFuelShare.add(location);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void clearRadius(BoostType boostType) {
|
||||
if (boostType == OVERHEAT) {
|
||||
radiusOverheat.clear();
|
||||
} else if (boostType == FUEL_SHARE) {
|
||||
radiusFuelShare.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getRadiusLast(BoostType boostType) {
|
||||
if (boostType == OVERHEAT) {
|
||||
return radiusOverheatLast;
|
||||
} else if (boostType == FUEL_SHARE) {
|
||||
return radiusFuelShareLast;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public void setRadiusLast(int radiusLast, BoostType boostType) {
|
||||
if (boostType == OVERHEAT) {
|
||||
this.radiusOverheatLast = radiusLast;
|
||||
} else if (boostType == FUEL_SHARE) {
|
||||
this.radiusFuelShareLast = radiusLast;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<UUID> getAccessList() {
|
||||
List<UUID> list = new ArrayList<>();
|
||||
for (String line : accessList) {
|
||||
String[] halfs = line.split(":");
|
||||
list.add(UUID.fromString(halfs[0]));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
|
||||
public Location getLocation() {
|
||||
return location.clone();
|
||||
}
|
||||
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getOriginalAccessList() {
|
||||
return Collections.unmodifiableList(accessList);
|
||||
}
|
||||
|
||||
|
||||
public int getPerformanceTotal() {
|
||||
return (int) Math.round((level.getPerformance() / 100.0) * 200);
|
||||
}
|
||||
|
||||
|
||||
public UUID getPlacedBy() {
|
||||
return placedBy;
|
||||
}
|
||||
|
||||
|
||||
public int getToLevel() {
|
||||
return toLevel;
|
||||
}
|
||||
|
||||
|
||||
public int getUses() {
|
||||
return uses;
|
||||
}
|
||||
|
||||
public enum BoostType {
|
||||
OVERHEAT, FUEL_SHARE
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package com.songoda.epicfurnaces.storage;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.objects.BoostData;
|
||||
import com.songoda.epicfurnaces.objects.FurnaceObject;
|
||||
import com.songoda.epicfurnaces.utils.ConfigWrapper;
|
||||
import com.songoda.epicfurnaces.utils.Methods;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Storage {
|
||||
|
||||
protected final EpicFurnaces instance;
|
||||
protected final ConfigWrapper dataFile;
|
||||
|
||||
public Storage(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
this.dataFile = new ConfigWrapper(instance, "", "data.yml");
|
||||
this.dataFile.createNewFile(null, "EpicFurnaces Data File");
|
||||
this.dataFile.getConfig().options().copyDefaults(true);
|
||||
this.dataFile.saveConfig();
|
||||
}
|
||||
|
||||
public abstract boolean containsGroup(String group);
|
||||
|
||||
public abstract List<StorageRow> getRowsByGroup(String group);
|
||||
|
||||
public abstract void prepareSaveItem(String group, StorageItem... items);
|
||||
|
||||
public void updateData(EpicFurnaces instance) {
|
||||
// Save game data
|
||||
for (FurnaceObject furnace : instance.getFurnaceManager().getAllFurnaces().values()) {
|
||||
if (furnace == null || furnace.getLocation() == null || furnace.getLocation().getWorld() == null) {
|
||||
continue;
|
||||
}
|
||||
String locationStr = Methods.serializeLocation(furnace.getLocation());
|
||||
|
||||
instance.getStorage().prepareSaveItem("charged",
|
||||
new StorageItem("location", locationStr),
|
||||
new StorageItem("level", furnace.getLevel().getLevel()),
|
||||
new StorageItem("uses", furnace.getUses()),
|
||||
new StorageItem("tolevel", furnace.getToLevel()),
|
||||
new StorageItem("nickname", furnace.getNickname()),
|
||||
new StorageItem("accesslist", furnace.getOriginalAccessList()),
|
||||
new StorageItem("placedby", furnace.getPlacedBy() == null ? null : furnace.getPlacedBy().toString()));
|
||||
}
|
||||
|
||||
for (BoostData boostData : instance.getBoostManager().getBoosts()) {
|
||||
instance.getStorage().prepareSaveItem("boosts", new StorageItem("endtime", String.valueOf(boostData.getEndTime())),
|
||||
new StorageItem("amount", boostData.getMultiplier()),
|
||||
new StorageItem("uuid", boostData.getPlayer().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void doSave();
|
||||
|
||||
public abstract void save();
|
||||
|
||||
public abstract void makeBackup();
|
||||
|
||||
public abstract void closeConnection();
|
||||
|
||||
}
|
@ -1,195 +0,0 @@
|
||||
package com.songoda.epicfurnaces.storage.types;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.storage.Storage;
|
||||
import com.songoda.epicfurnaces.storage.StorageItem;
|
||||
import com.songoda.epicfurnaces.storage.StorageRow;
|
||||
import com.songoda.epicfurnaces.utils.MySQLDatabase;
|
||||
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StorageMysql extends Storage {
|
||||
|
||||
private static Map<String, StorageItem[]> toSave = new HashMap<>();
|
||||
private static Map<String, StorageItem[]> lastSave = new HashMap<>();
|
||||
private MySQLDatabase database;
|
||||
|
||||
public StorageMysql(EpicFurnaces instance) {
|
||||
super(instance);
|
||||
this.database = new MySQLDatabase(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsGroup(String group) {
|
||||
try {
|
||||
DatabaseMetaData dbm = database.getConnection().getMetaData();
|
||||
ResultSet rs = dbm.getTables(null, null, instance.getConfig().getString("Database.Prefix") + group, null);
|
||||
if (rs.next()) {
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageRow> getRowsByGroup(String group) {
|
||||
List<StorageRow> rows = new ArrayList<>();
|
||||
try {
|
||||
ResultSet set = database.getConnection().createStatement().executeQuery(String.format("SELECT * FROM `" + instance.getConfig().getString("Database.Prefix") + "%s`", group));
|
||||
while (set.next()) {
|
||||
Map<String, StorageItem> items = new HashMap<>();
|
||||
|
||||
String key = set.getString(1);
|
||||
for (int i = 2; i <= set.getMetaData().getColumnCount(); i++) {
|
||||
if (set.getObject(i) == null || set.getObject(i) == "") continue;
|
||||
StorageItem item = new StorageItem(set.getObject(i));
|
||||
items.put(set.getMetaData().getColumnName(i), item);
|
||||
}
|
||||
StorageRow row = new StorageRow(key, items);
|
||||
rows.add(row);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareSaveItem(String group, StorageItem... items) {
|
||||
toSave.put(group + "]" + items[0].asObject().toString(), items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSave() {
|
||||
this.updateData(instance);
|
||||
if (toSave.isEmpty()) return;
|
||||
Map<String, StorageItem[]> nextSave = new HashMap<>(toSave);
|
||||
|
||||
if (lastSave.isEmpty())
|
||||
lastSave.putAll(toSave);
|
||||
|
||||
this.makeBackup();
|
||||
this.save();
|
||||
|
||||
toSave.clear();
|
||||
lastSave.clear();
|
||||
lastSave.putAll(nextSave);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
try {
|
||||
Statement stmt = database.getConnection().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
|
||||
|
||||
last:
|
||||
for (Map.Entry<String, StorageItem[]> last : lastSave.entrySet()) {
|
||||
String lastKey = last.getKey().split("]")[0];
|
||||
String lastValue = last.getValue()[0].asObject().toString();
|
||||
|
||||
for (Map.Entry<String, StorageItem[]> to : toSave.entrySet()) {
|
||||
String toKey = to.getKey().split("]")[0];
|
||||
if (!toKey.equals(lastKey)
|
||||
|| !to.getValue()[0].asObject().equals(lastValue)
|
||||
|| to.getValue().length != last.getValue().length)
|
||||
continue;
|
||||
toSave.remove(toKey);
|
||||
for (int i = 0; i < to.getValue().length - 1; i ++) {
|
||||
if (to.getValue()[i].asObject() != null
|
||||
&& !to.getValue()[i].asObject().toString()
|
||||
.equals(last.getValue()[i].asObject().toString())) {
|
||||
//Update
|
||||
StorageItem[] items = to.getValue();
|
||||
StringBuilder sql = new StringBuilder(String.format("UPDATE `" + instance.getConfig().getString("Database.Prefix") + "%s`", toKey));
|
||||
|
||||
sql.append(" SET");
|
||||
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
String key = item.getKey().split("]")[0];
|
||||
sql.append(String.format("`%s` = '%s', ", key, item.asObject().toString()));
|
||||
}
|
||||
|
||||
sql = new StringBuilder(sql.substring(0, sql.length() - 2));
|
||||
|
||||
sql.append(String.format(" WHERE `%s`='%s'", last.getValue()[0].getKey(), last.getValue()[0].asObject().toString()));
|
||||
|
||||
stmt.addBatch(sql.toString());
|
||||
|
||||
continue last;
|
||||
}
|
||||
}
|
||||
// Already up to date.
|
||||
|
||||
continue last;
|
||||
}
|
||||
//Was not found delete.
|
||||
StringBuilder sql = new StringBuilder(String.format("DELETE FROM `" + instance.getConfig().getString("Database.Prefix") + "%s`", lastKey));
|
||||
sql.append(String.format(" WHERE `%s`='%s'", last.getValue()[0].getKey(), last.getValue()[0].asObject().toString()));
|
||||
stmt.addBatch(sql.toString());
|
||||
|
||||
}
|
||||
|
||||
for (Map.Entry<String, StorageItem[]> to : toSave.entrySet()) {
|
||||
String toKey = to.getKey().split("]")[0];
|
||||
//Add
|
||||
StorageItem[] items = to.getValue();
|
||||
StringBuilder sql = new StringBuilder(String.format("INSERT INTO `" + instance.getConfig().getString("Database.Prefix") + "%s`", toKey));
|
||||
|
||||
sql.append(" (");
|
||||
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
String key = item.getKey().split("]")[0];
|
||||
sql.append(String.format("`%s`, ", key));
|
||||
}
|
||||
|
||||
sql = new StringBuilder(sql.substring(0, sql.length() - 2));
|
||||
|
||||
sql.append(") VALUES (");
|
||||
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
sql.append(String.format("'%s', ", item.asObject().toString()));
|
||||
}
|
||||
|
||||
sql = new StringBuilder(sql.substring(0, sql.length() - 2));
|
||||
|
||||
sql.append(");");
|
||||
|
||||
stmt.addBatch(sql.toString());
|
||||
}
|
||||
|
||||
stmt.executeBatch();
|
||||
|
||||
toSave.clear();
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeBackup() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
try {
|
||||
database.getConnection().close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,164 +0,0 @@
|
||||
package com.songoda.epicfurnaces.tasks;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.objects.FurnaceObject;
|
||||
import com.songoda.epicfurnaces.objects.FurnaceObject.BoostType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static com.songoda.epicfurnaces.objects.FurnaceObject.BoostType.*;
|
||||
|
||||
public class FurnaceTask extends BukkitRunnable {
|
||||
|
||||
private static FurnaceTask plugin;
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
private FurnaceTask(EpicFurnaces plugin) {
|
||||
this.instance = plugin;
|
||||
}
|
||||
|
||||
public static void startTask(EpicFurnaces plugin) {
|
||||
if (FurnaceTask.plugin == null) {
|
||||
FurnaceTask.plugin = new FurnaceTask(plugin);
|
||||
FurnaceTask.plugin.runTaskTimer(plugin, 0, plugin.getConfig().getInt("Main.Furnace Tick Speed"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (FurnaceObject furnace : instance.getFurnaceManager().getFurnaces().values()) {
|
||||
Location furnaceLocation = furnace.getLocation();
|
||||
|
||||
if (furnaceLocation == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (furnaceLocation.getWorld() == null) {
|
||||
instance.getFurnaceManager().removeFurnace(furnaceLocation);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (furnace.getLocation().getBlock().getType() != Material.FURNACE &&
|
||||
furnace.getLocation().getBlock().getType() != instance.getBukkitEnums().getMaterial("BURNING_FURNACE").getType()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((Furnace) furnaceLocation.getBlock().getState()).getBurnTime() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (furnace.getLevel().getOverheat() != 0) {
|
||||
overheat(furnace);
|
||||
}
|
||||
|
||||
if (furnace.getLevel().getFuelShare() != 0) {
|
||||
fuelShare(furnace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void overheat(FurnaceObject furnace) {
|
||||
if (furnace.getRadius(OVERHEAT) == null || furnace.getRadiusLast(OVERHEAT) != furnace.getLevel().getOverheat()) {
|
||||
furnace.setRadiusLast(furnace.getLevel().getOverheat(), OVERHEAT);
|
||||
cache(furnace, OVERHEAT);
|
||||
}
|
||||
|
||||
for (Location location : furnace.getRadius(OVERHEAT)) {
|
||||
int random = ThreadLocalRandom.current().nextInt(0, 10);
|
||||
|
||||
if (random != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = location.getBlock();
|
||||
|
||||
if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
broadcastParticles(location);
|
||||
|
||||
if (block.getType() == Material.SNOW) {
|
||||
block.setType(Material.AIR);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (block.getType() == Material.ICE || block.getType() == Material.PACKED_ICE) {
|
||||
block.setType(Material.WATER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fuelShare(FurnaceObject furnace) {
|
||||
if (furnace.getRadius(FUEL_SHARE) == null || furnace.getRadiusLast(FUEL_SHARE) != furnace.getLevel().getFuelShare()) {
|
||||
furnace.setRadiusLast(furnace.getLevel().getFuelShare(), FUEL_SHARE);
|
||||
cache(furnace, FUEL_SHARE);
|
||||
}
|
||||
|
||||
for (Location location : furnace.getRadius(FUEL_SHARE)) {
|
||||
int random = ThreadLocalRandom.current().nextInt(0, 10);
|
||||
|
||||
if (random != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = location.getBlock();
|
||||
|
||||
if (block.getType() != Material.FURNACE && block.getType() != instance.getBukkitEnums().getMaterial("BURNING_FURNACE").getType()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FurnaceObject other = instance.getFurnaceManager().getFurnace(block.getLocation()).orElseGet(() -> instance.getFurnaceManager().createFurnace(block.getLocation()));
|
||||
|
||||
if (furnace.equals(other)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((Furnace) furnace.getLocation().getBlock().getState()).getInventory().getFuel() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Furnace furnaceBlock = ((Furnace) block.getState());
|
||||
|
||||
if (furnaceBlock.getBurnTime() == 0) {
|
||||
furnaceBlock.setBurnTime((short) 205);
|
||||
furnaceBlock.update();
|
||||
broadcastParticles(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cache(FurnaceObject furnace, BoostType boostType) {
|
||||
Block block = furnace.getLocation().getBlock();
|
||||
int radius = 3 * (boostType == OVERHEAT ? furnace.getLevel().getOverheat() : furnace.getLevel().getFuelShare());
|
||||
int rSquared = radius * radius;
|
||||
int bx = block.getX();
|
||||
int by = block.getY();
|
||||
int bz = block.getZ();
|
||||
|
||||
for (int fx = -radius; fx <= radius; fx++) {
|
||||
for (int fy = -2; fy <= 1; fy++) {
|
||||
for (int fz = -radius; fz <= radius; fz++) {
|
||||
if ((fx * fx) + (fz * fz) <= rSquared) {
|
||||
Location location = new Location(block.getWorld(), bx + fx, by + fy, bz + fz);
|
||||
furnace.addToRadius(location, boostType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastParticles(Location location) {
|
||||
if (instance.getConfig().getBoolean("Main.Overheat Particles")) {
|
||||
if (instance.getCurrentVersion() > 8)
|
||||
location.getWorld().spawnParticle(Particle.SMOKE_NORMAL, location.getX(), location.getY(), location.getZ(), 25, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.songoda.epicfurnaces.tasks;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class HologramTask extends BukkitRunnable {
|
||||
|
||||
private static HologramTask task;
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
private HologramTask(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public static void startTask(EpicFurnaces plugin) {
|
||||
if (task == null) {
|
||||
task = new HologramTask(plugin);
|
||||
task.runTaskTimer(plugin, 0, 20L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!instance.getConfig().getBoolean("Main.Furnaces Have Holograms")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.getFurnaceManager() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
instance.getFurnaceManager().getFurnaces().values().stream()
|
||||
.filter(furnace -> furnace.getLocation().getBlock() != null)
|
||||
.forEach(furnace -> instance.getHologramManager().ifPresent(manager -> manager.updateHologram(furnace)));
|
||||
}
|
||||
}
|
@ -1,922 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BukkitEnums {
|
||||
private final EpicFurnaces instance;
|
||||
private final Map<String, String> soundMap = new HashMap<String, String>() {{
|
||||
put("ENTITY_PLAYER_LEVELUP", "LEVEL_UP");
|
||||
put("BLOCK_NOTE_BLOCK_CHIME", "NOTE_PLING");
|
||||
put("NAN", "NAN");
|
||||
}};
|
||||
|
||||
public BukkitEnums(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public Sound getSound(String name) {
|
||||
if (Arrays.stream(Sound.values()).anyMatch(s -> s.toString().equalsIgnoreCase(name))) {
|
||||
return Sound.valueOf(name.toUpperCase());
|
||||
}
|
||||
|
||||
if (Arrays.stream(Sound.values()).anyMatch(s -> s.toString().equalsIgnoreCase(soundMap.getOrDefault(name, "NAN")))) {
|
||||
return Sound.valueOf(soundMap.get(name.toUpperCase()));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getMaterial(String string) {
|
||||
Material material = Material.matchMaterial(string);
|
||||
|
||||
if (material != null) {
|
||||
return new ItemStack(material);
|
||||
}
|
||||
|
||||
return VersionEnum.requestMaterial(string);
|
||||
}
|
||||
|
||||
private enum VersionEnum {
|
||||
ACACIA_BOAT(0, "BOAT_ACACIA"),
|
||||
ACACIA_BUTTON(0, "WOOD_BUTTON"),
|
||||
ACACIA_DOOR(0, "ACACIA_DOOR", "ACACIA_DOOR_ITEM"),
|
||||
ACACIA_FENCE(0, "ACACIA_FENCE"),
|
||||
ACACIA_FENCE_GATE(0, "ACACIA_FENCE_GATE"),
|
||||
ACACIA_LEAVES(0, "LEAVES_2"),
|
||||
ACACIA_LOG(0, "LOG_2"),
|
||||
ACACIA_PLANKS(4, "WOOD"),
|
||||
ACACIA_PRESSURE_PLATE(0, "WOOD_PLATE"),
|
||||
ACACIA_SAPLING(4, "SAPLING"),
|
||||
ACACIA_SLAB(4, "WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"),
|
||||
ACACIA_STAIRS(4, "ACACIA_STAIRS"),
|
||||
ACACIA_TRAPDOOR(0, "TRAP_DOOR"),
|
||||
ACACIA_WOOD(0, "LOG_2"),
|
||||
ACTIVATOR_RAIL(0, "ACTIVATOR_RAIL"),
|
||||
AIR(0, "AIR"),
|
||||
ALLIUM(2, "RED_ROSE"),
|
||||
ANDESITE(5, "STONE"),
|
||||
ANVIL(0, "ANVIL"),
|
||||
APPLE(0, "APPLE"),
|
||||
ARMOR_STAND(0, "ARMOR_STAND"),
|
||||
ARROW(0, "ARROW"),
|
||||
ATTACHED_MELON_STEM(7, "MELON_STEM"),
|
||||
ATTACHED_PUMPKIN_STEM(7, "PUMPKIN_STEM"),
|
||||
AZURE_BLUET(3, "RED_ROSE"),
|
||||
BAKED_POTATO(0, "BAKED_POTATO"),
|
||||
BARRIER(0, "BARRIER"),
|
||||
BAT_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
BEACON(0, "BEACON"),
|
||||
BEDROCK(0, "BEDROCK"),
|
||||
BEEF(0, "RAW_BEEF"),
|
||||
BEETROOT(0, "BEETROOT"),
|
||||
BEETROOTS(0, "BEETROOT", "BEETROOT_BLOCK"),
|
||||
BEETROOT_SEEDS(0, "BEETROOT_SEEDS"),
|
||||
BEETROOT_SOUP(0, "BEETROOT_SOUP"),
|
||||
BIRCH_BOAT(0, "BOAT_BIRCH"),
|
||||
BIRCH_BUTTON(0, "WOOD_BUTTON"),
|
||||
BIRCH_DOOR(0, "BIRCH_DOOR", "BIRCH_DOOR_ITEM"),
|
||||
BIRCH_FENCE(0, "BIRCH_FENCE"),
|
||||
BIRCH_FENCE_GATE(0, "BIRCH_FENCE_GATE"),
|
||||
BIRCH_LEAVES(2, "LEAVES"),
|
||||
BIRCH_LOG(2, "LOG"),
|
||||
BIRCH_PLANKS(2, "WOOD"),
|
||||
BIRCH_PRESSURE_PLATE(0, "WOOD_PLATE"),
|
||||
BIRCH_SAPLING(2, "SAPLING"),
|
||||
BIRCH_SLAB(2, "WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"),
|
||||
BIRCH_STAIRS(0, "BIRCH_WOOD_STAIRS"),
|
||||
BIRCH_TRAPDOOR(0, "TRAP_DOOR"),
|
||||
BIRCH_WOOD(2, "LOG"),
|
||||
BLACK_BANNER(0, "BANNER", "STANDING_BANNER"),
|
||||
BLACK_BED(15, "BED", "BED_BLOCK"),
|
||||
BLACK_CARPET(15, "CARPET"),
|
||||
BLACK_CONCRETE(15, "CONCRETE"),
|
||||
BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"),
|
||||
BLACK_GLAZED_TERRACOTTA(0, "BLACK_GLAZED_TERRACOTTA"),
|
||||
BLACK_SHULKER_BOX(0, "BLACK_SHULKER_BOX"),
|
||||
BLACK_STAINED_GLASS(15, "STAINED_GLASS"),
|
||||
BLACK_STAINED_GLASS_PANE(15, "STAINED_GLASS_PANE"),
|
||||
BLACK_TERRACOTTA(15, "STAINED_CLAY"),
|
||||
BLACK_WALL_BANNER(0, "WALL_BANNER"),
|
||||
BLACK_WOOL(15, "WOOL"),
|
||||
BLAZE_POWDER(0, "BLAZE_POWDER"),
|
||||
BLAZE_ROD(0, "BLAZE_ROD"),
|
||||
BLAZE_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
BLUE_BANNER(11, "BANNER", "STANDING_BANNER"),
|
||||
BLUE_BED(4, "BED", "BED_BLOCK"),
|
||||
BLUE_CARPET(11, "CARPET"),
|
||||
BLUE_CONCRETE(11, "CONCRETE"),
|
||||
BLUE_CONCRETE_POWDER(11, "CONCRETE_POWDER"),
|
||||
BLUE_GLAZED_TERRACOTTA(0, "BLUE_GLAZED_TERRACOTTA"),
|
||||
BLUE_ICE(0, "PACKED_ICE"),
|
||||
BLUE_ORCHID(1, "RED_ROSE"),
|
||||
BLUE_SHULKER_BOX(0, "BLUE_SHULKER_BOX"),
|
||||
BLUE_STAINED_GLASS(11, "STAINED_GLASS"),
|
||||
BLUE_STAINED_GLASS_PANE(11, "STAINED_GLASS_PANE"),
|
||||
BLUE_TERRACOTTA(11, "STAINED_CLAY"),
|
||||
BLUE_WALL_BANNER(11, "WALL_BANNER"),
|
||||
BLUE_WOOL(11, "WOOL"),
|
||||
BONE(0, "BONE"),
|
||||
BONE_BLOCK(0, "BONE_BLOCK"),
|
||||
BONE_MEAL(15, "INK_SACK"),
|
||||
BOOK(0, "BOOK"),
|
||||
BOOKSHELF(0, "BOOKSHELF"),
|
||||
BOW(0, "BOW"),
|
||||
BOWL(0, "BOWL"),
|
||||
BRAIN_CORAL(0, "STONE"),
|
||||
BRAIN_CORAL_BLOCK(0, "STONE"),
|
||||
BRAIN_CORAL_FAN(0, "STONE"),
|
||||
BREAD(0, "BREAD"),
|
||||
BREWING_STAND(0, "BREWING_STAND", "BREWING_STAND_ITEM"),
|
||||
BRICK(0, "CLAY_BRICK"),
|
||||
BRICKS(0, "BRICK"),
|
||||
BRICK_SLAB(4, "STEP"),
|
||||
BRICK_STAIRS(0, "BRICK_STAIRS"),
|
||||
BROWN_BANNER(3, "BANNER", "STANDING_BANNER"),
|
||||
BROWN_BED(12, "BED", "BED_BLOCK"),
|
||||
BROWN_CARPET(12, "CARPET"),
|
||||
BROWN_CONCRETE(12, "CONCRETE"),
|
||||
BROWN_CONCRETE_POWDER(12, "CONCRETE_POWDER"),
|
||||
BROWN_GLAZED_TERRACOTTA(0, "BROWN_GLAZED_TERRACOTTA"),
|
||||
BROWN_MUSHROOM(0, "BROWN_MUSHROOM"),
|
||||
BROWN_MUSHROOM_BLOCK(0, "BROWN_MUSHROOM", "HUGE_MUSHROOM_1"),
|
||||
BROWN_SHULKER_BOX(0, "BROWN_SHULKER_BOX"),
|
||||
BROWN_STAINED_GLASS(12, "STAINED_GLASS"),
|
||||
BROWN_STAINED_GLASS_PANE(12, "STAINED_GLASS_PANE"),
|
||||
BROWN_TERRACOTTA(12, "STAINED_CLAY"),
|
||||
BROWN_WALL_BANNER(3, "WALL_BANNER"),
|
||||
BROWN_WOOL(12, "WOOL"),
|
||||
BUBBLE_COLUMN(0, "STONE"),
|
||||
BUBBLE_CORAL(0, "STONE"),
|
||||
BUBBLE_CORAL_BLOCK(0, "STONE"),
|
||||
BUBBLE_CORAL_FAN(0, "STONE"),
|
||||
BUCKET(0, "BUCKET"),
|
||||
CACTUS(0, "CACTUS"),
|
||||
CACTUS_GREEN(2, "INK_SACK"),
|
||||
CAKE(0, "CAKE", "CAKE_BLOCK"),
|
||||
CARROT(0, "CARROT_ITEM"),
|
||||
CARROTS(0, "CARROT"),
|
||||
CARROT_ON_A_STICK(0, "CARROT_STICK"),
|
||||
CARVED_PUMPKIN(0, "PUMPKIN"),
|
||||
CAULDRON(0, "CAULDRON", "CAULDRON_ITEM"),
|
||||
CAVE_AIR(0, "AIR"),
|
||||
CAVE_SPIDER_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
CHAINMAIL_BOOTS(0, "CHAINMAIL_BOOTS"),
|
||||
CHAINMAIL_CHESTPLATE(0, "CHAINMAIL_CHESTPLATE"),
|
||||
CHAINMAIL_HELMET(0, "CHAINMAIL_HELMET"),
|
||||
CHAINMAIL_LEGGINGS(0, "CHAINMAIL_LEGGINGS"),
|
||||
CHAIN_COMMAND_BLOCK(0, "COMMAND_CHAIN"),
|
||||
CHARCOAL(1, "COAL"),
|
||||
CHEST(0, "CHEST", "LOCKED_CHEST"),
|
||||
CHEST_MINECART(0, "STORAGE_MINECART"),
|
||||
CHICKEN(0, "RAW_CHICKEN"),
|
||||
CHICKEN_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
CHIPPED_ANVIL(1, "ANVIL"),
|
||||
CHISELED_QUARTZ_BLOCK(1, "QUARTZ_BLOCK"),
|
||||
CHISELED_RED_SANDSTONE(1, "RED_SANDSTONE"),
|
||||
CHISELED_SANDSTONE(1, "SANDSTONE"),
|
||||
CHISELED_STONE_BRICKS(3, "SMOOTH_BRICK"),
|
||||
CHORUS_FLOWER(0, "CHORUS_FLOWER"),
|
||||
CHORUS_FRUIT(0, "CHORUS_FRUIT"),
|
||||
CHORUS_PLANT(0, "CHORUS_PLANT"),
|
||||
CLAY(0, "CLAY"),
|
||||
CLAY_BALL(0, "CLAY_BALL"),
|
||||
CLOCK(0, "WATCH"),
|
||||
COAL(0, "COAL"),
|
||||
COAL_BLOCK(0, "COAL_BLOCK"),
|
||||
COAL_ORE(0, "COAL_ORE"),
|
||||
COARSE_DIRT(1, "DIRT"),
|
||||
COBBLESTONE(0, "COBBLESTONE"),
|
||||
COBBLESTONE_SLAB(3, "STEP"),
|
||||
COBBLESTONE_STAIRS(0, "COBBLESTONE_STAIRS"),
|
||||
COBBLESTONE_WALL(0, "COBBLE_WALL"),
|
||||
COBWEB(0, "WEB"),
|
||||
COCOA(0, "COCOA"),
|
||||
COCOA_BEANS(3, "INK_SACK"),
|
||||
COD(0, "RAW_FISH"),
|
||||
COD_BUCKET(0, "BUCKET"),
|
||||
COD_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
COMMAND_BLOCK(0, "COMMAND"),
|
||||
COMMAND_BLOCK_MINECART(0, "COMMAND_MINECART"),
|
||||
COMPARATOR(0, "REDSTONE_COMPARATOR", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR_OFF"),
|
||||
COMPASS(0, "COMPASS"),
|
||||
CONDUIT(0, "STONE"),
|
||||
COOKED_BEEF(0, "COOKED_BEEF"),
|
||||
COOKED_CHICKEN(0, "COOKED_CHICKEN"),
|
||||
COOKED_COD(0, "COOKED_FISH"),
|
||||
COOKED_MUTTON(0, "COOKED_MUTTON"),
|
||||
COOKED_PORKCHOP(0, "GRILLED_PORK"),
|
||||
COOKED_RABBIT(0, "COOKED_RABBIT"),
|
||||
COOKED_SALMON(1, "COOKED_FISH"),
|
||||
COOKIE(0, "COOKIE"),
|
||||
COW_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
CRACKED_STONE_BRICKS(2, "SMOOTH_BRICK"),
|
||||
CRAFTING_TABLE(0, "WORKBENCH"),
|
||||
CREEPER_HEAD(0, "SKULL", "SKULL_ITEM"),
|
||||
CREEPER_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
CREEPER_WALL_HEAD(0, "SKULL", "SKULL_ITEM"),
|
||||
CUT_RED_SANDSTONE(0, "STONE"),
|
||||
CUT_SANDSTONE(0, "STONE"),
|
||||
CYAN_BANNER(6, "BANNER", "STANDING_BANNER"),
|
||||
CYAN_BED(9, "BED", "BED_BLOCK"),
|
||||
CYAN_CARPET(9, "CARPET"),
|
||||
CYAN_CONCRETE(9, "CONCRETE"),
|
||||
CYAN_CONCRETE_POWDER(9, "CONCRETE_POWDER"),
|
||||
CYAN_DYE(6, "INK_SACK"),
|
||||
CYAN_GLAZED_TERRACOTTA(0, "CYAN_GLAZED_TERRACOTTA"),
|
||||
CYAN_SHULKER_BOX(0, "CYAN_SHULKER_BOX"),
|
||||
CYAN_STAINED_GLASS(9, "STAINED_GLASS"),
|
||||
CYAN_STAINED_GLASS_PANE(9, "STAINED_GLASS_PANE"),
|
||||
CYAN_TERRACOTTA(9, "STAINED_CLAY"),
|
||||
CYAN_WALL_BANNER(0, "WALL_BANNER"),
|
||||
CYAN_WOOL(9, "WOOL"),
|
||||
DAMAGED_ANVIL(2, "ANVIL"),
|
||||
DANDELION(0, "YELLOW_FLOWER"),
|
||||
DANDELION_YELLOW(11, "INK_SACK"),
|
||||
DARK_OAK_BOAT(0, "BOAT_DARK_OAK"),
|
||||
DARK_OAK_BUTTON(0, "WOOD_BUTTON"),
|
||||
DARK_OAK_DOOR(0, "DARK_OAK_DOOR", "DARK_OAK_DOOR_ITEM"),
|
||||
DARK_OAK_FENCE(0, "DARK_OAK_FENCE"),
|
||||
DARK_OAK_FENCE_GATE(0, "DARK_OAK_FENCE_GATE"),
|
||||
DARK_OAK_LEAVES(1, "LEAVES_2"),
|
||||
DARK_OAK_LOG(1, "LOG_2"),
|
||||
DARK_OAK_PLANKS(5, "WOOD"),
|
||||
DARK_OAK_PRESSURE_PLATE(0, "WOOD_PLATE"),
|
||||
DARK_OAK_SAPLING(5, "SAPLING"),
|
||||
DARK_OAK_SLAB(0, "WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"),
|
||||
DARK_OAK_STAIRS(0, "DARK_OAK_STAIRS"),
|
||||
DARK_OAK_TRAPDOOR(0, "TRAP_DOOR"),
|
||||
DARK_OAK_WOOD(1, "LOG_2"),
|
||||
DARK_PRISMARINE(2, "PRISMARINE"),
|
||||
DARK_PRISMARINE_SLAB(0, "STONE"),
|
||||
DARK_PRISMARINE_STAIRS(0, "STONE"),
|
||||
DAYLIGHT_DETECTOR(0, "DAYLIGHT_DETECTOR", "DAYLIGHT_DETECTOR_INVERTED"),
|
||||
DEAD_BRAIN_CORAL_BLOCK(0, "STONE"),
|
||||
DEAD_BUBBLE_CORAL_BLOCK(0, "STONE"),
|
||||
DEAD_BUSH(0, "DEAD_BUSH"),
|
||||
DEAD_FIRE_CORAL_BLOCK(0, "STONE"),
|
||||
DEAD_HORN_CORAL_BLOCK(0, "STONE"),
|
||||
DEAD_TUBE_CORAL_BLOCK(0, "STONE"),
|
||||
DEBUG_STICK(0, "STICK"),
|
||||
DETECTOR_RAIL(0, "DETECTOR_RAIL"),
|
||||
DIAMOND(0, "DIAMOND"),
|
||||
DIAMOND_AXE(0, "DIAMOND_AXE"),
|
||||
DIAMOND_BLOCK(0, "DIAMOND_BLOCK"),
|
||||
DIAMOND_BOOTS(0, "DIAMOND_BOOTS"),
|
||||
DIAMOND_CHESTPLATE(0, "DIAMOND_CHESTPLATE"),
|
||||
DIAMOND_HELMET(0, "DIAMOND_HELMET"),
|
||||
DIAMOND_HOE(0, "DIAMOND_HOE"),
|
||||
DIAMOND_HORSE_ARMOR(0, "DIAMOND_BARDING"),
|
||||
DIAMOND_LEGGINGS(0, "DIAMOND_LEGGINGS"),
|
||||
DIAMOND_ORE(0, "DIAMOND_ORE"),
|
||||
DIAMOND_PICKAXE(0, "DIAMOND_PICKAXE"),
|
||||
DIAMOND_SHOVEL(0, "DIAMOND_SPADE"),
|
||||
DIAMOND_SWORD(0, "DIAMOND_SWORD"),
|
||||
DIORITE(3, "STONE"),
|
||||
DIRT(0, "DIRT"),
|
||||
DISPENSER(0, "DISPENSER"),
|
||||
DOLPHIN_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
DONKEY_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
DRAGON_BREATH(0, "DRAGONS_BREATH"),
|
||||
DRAGON_EGG(0, "DRAGON_EGG"),
|
||||
DRAGON_HEAD(5, "SKULL", "SKULL_ITEM"),
|
||||
DRAGON_WALL_HEAD(0, "SKULL", "SKULL_ITEM"),
|
||||
DRIED_KELP(0, "STONE"),
|
||||
DRIED_KELP_BLOCK(0, "STONE"),
|
||||
DROPPER(0, "DROPPER"),
|
||||
DROWNED_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
EGG(0, "EGG"),
|
||||
ELDER_GUARDIAN_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
ELYTRA(0, "ELYTRA"),
|
||||
EMERALD(0, "EMERALD"),
|
||||
EMERALD_BLOCK(0, "EMERALD_BLOCK"),
|
||||
EMERALD_ORE(0, "EMERALD_ORE"),
|
||||
ENCHANTED_BOOK(0, "ENCHANTED_BOOK"),
|
||||
ENCHANTED_GOLDEN_APPLE(1, "GOLDEN_APPLE"),
|
||||
ENCHANTING_TABLE(0, "ENCHANTMENT_TABLE"),
|
||||
ENDERMAN_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
ENDERMITE_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
ENDER_CHEST(0, "ENDER_CHEST"),
|
||||
ENDER_EYE(0, "EYE_OF_ENDER"),
|
||||
ENDER_PEARL(0, "ENDER_PEARL"),
|
||||
END_CRYSTAL(0, "END_CRYSTAL"),
|
||||
END_GATEWAY(0, "END_GATEWAY"),
|
||||
END_PORTAL(0, "ENDER_PORTAL"),
|
||||
END_PORTAL_FRAME(0, "ENDER_PORTAL_FRAME"),
|
||||
END_ROD(0, "END_ROD"),
|
||||
END_STONE(0, "ENDER_STONE"),
|
||||
END_STONE_BRICKS(0, "END_BRICKS"),
|
||||
EVOKER_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
EXPERIENCE_BOTTLE(0, "EXP_BOTTLE"),
|
||||
FARMLAND(0, "SOIL"),
|
||||
FEATHER(0, "FEATHER"),
|
||||
FERMENTED_SPIDER_EYE(0, "FERMENTED_SPIDER_EYE"),
|
||||
FERN(2, "LONG_GRASS"),
|
||||
FILLED_MAP(0, "MAP"),
|
||||
FIRE(0, "FIRE"),
|
||||
FIREWORK_ROCKET(0, "FIREWORK"),
|
||||
FIREWORK_STAR(0, "FIREWORK_CHARGE"),
|
||||
FIRE_CHARGE(0, "FIREBALL"),
|
||||
FIRE_CORAL(0, "STONE"),
|
||||
FIRE_CORAL_BLOCK(0, "STONE"),
|
||||
FIRE_CORAL_FAN(0, "STONE"),
|
||||
FISHING_ROD(0, "FISHING_ROD"),
|
||||
FLINT(0, "FLINT"),
|
||||
FLINT_AND_STEEL(0, "FLINT_AND_STEEL"),
|
||||
FLOWER_POT(0, "FLOWER_POT", "FLOWER_POT_ITEM"),
|
||||
FROSTED_ICE(0, "FROSTED_ICE"),
|
||||
FURNACE(0, "FURNACE", "BURNING_FURNACE"),
|
||||
FURNACE_MINECART(0, "POWERED_MINECART"),
|
||||
GHAST_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
GHAST_TEAR(0, "GHAST_TEAR"),
|
||||
GLASS(0, "GLASS"),
|
||||
GLASS_BOTTLE(0, "GLASS_BOTTLE"),
|
||||
GLASS_PANE(0, "THIN_GLASS"),
|
||||
GLISTERING_MELON_SLICE(0, "SPECKLED_MELON"),
|
||||
GLOWSTONE(0, "GLOWSTONE"),
|
||||
GLOWSTONE_DUST(0, "GLOWSTONE_DUST"),
|
||||
GOLDEN_APPLE(0, "GOLDEN_APPLE"),
|
||||
GOLDEN_AXE(0, "GOLD_AXE"),
|
||||
GOLDEN_BOOTS(0, "GOLD_BOOTS"),
|
||||
GOLDEN_CARROT(0, "GOLDEN_CARROT"),
|
||||
GOLDEN_CHESTPLATE(0, "GOLD_CHESTPLATE"),
|
||||
GOLDEN_HELMET(0, "GOLD_HELMET"),
|
||||
GOLDEN_HOE(0, "GOLD_HOE"),
|
||||
GOLDEN_HORSE_ARMOR(0, "GOLD_BARDING"),
|
||||
GOLDEN_LEGGINGS(0, "GOLD_LEGGINGS"),
|
||||
GOLDEN_PICKAXE(0, "GOLD_PICKAXE"),
|
||||
GOLDEN_SHOVEL(0, "GOLD_SPADE"),
|
||||
GOLDEN_SWORD(0, "GOLD_SWORD"),
|
||||
GOLD_BLOCK(0, "GOLD_BLOCK"),
|
||||
GOLD_INGOT(0, "GOLD_INGOT"),
|
||||
GOLD_NUGGET(0, "GOLD_NUGGET"),
|
||||
GOLD_ORE(0, "GOLD_ORE"),
|
||||
GRANITE(1, "STONE"),
|
||||
GRASS(0, "GRASS"),
|
||||
GRASS_BLOCK(0, "GRASS"),
|
||||
GRASS_PATH(0, "GRASS_PATH"),
|
||||
GRAVEL(0, "GRAVEL"),
|
||||
GRAY_BANNER(8, "BANNER", "STANDING_BANNER"),
|
||||
GRAY_BED(7, "BED", "BED_BLOCK"),
|
||||
GRAY_CARPET(7, "CARPET"),
|
||||
GRAY_CONCRETE(7, "CONCRETE"),
|
||||
GRAY_CONCRETE_POWDER(7, "CONCRETE_POWDER"),
|
||||
GRAY_DYE(8, "INK_SACK"),
|
||||
GRAY_GLAZED_TERRACOTTA(0, "GRAY_GLAZED_TERRACOTTA"),
|
||||
GRAY_SHULKER_BOX(0, "GRAY_SHULKER_BOX"),
|
||||
GRAY_STAINED_GLASS(7, "STAINED_GLASS"),
|
||||
GRAY_STAINED_GLASS_PANE(7, "STAINED_GLASS_PANE"),
|
||||
GRAY_TERRACOTTA(7, "STAINED_CLAY"),
|
||||
GRAY_WALL_BANNER(0, "WALL_BANNER"),
|
||||
GRAY_WOOL(7, "WOOL"),
|
||||
GREEN_BANNER(2, "BANNER", "STANDING_BANNER"),
|
||||
GREEN_BED(13, "BED", "BED_BLOCK"),
|
||||
GREEN_CARPET(13, "CARPET"),
|
||||
GREEN_CONCRETE(13, "CONCRETE"),
|
||||
GREEN_CONCRETE_POWDER(13, "CONCRETE_POWDER"),
|
||||
GREEN_GLAZED_TERRACOTTA(0, "GREEN_GLAZED_TERRACOTTA"),
|
||||
GREEN_SHULKER_BOX(0, "GREEN_SHULKER_BOX"),
|
||||
GREEN_STAINED_GLASS(13, "STAINED_GLASS"),
|
||||
GREEN_STAINED_GLASS_PANE(13, "STAINED_GLASS_PANE"),
|
||||
GREEN_TERRACOTTA(13, "STAINED_CLAY"),
|
||||
GREEN_WALL_BANNER(0, "WALL_BANNER"),
|
||||
GREEN_WOOL(13, "WOOL"),
|
||||
GUARDIAN_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
GUNPOWDER(0, "SULPHUR"),
|
||||
HAY_BLOCK(0, "HAY_BLOCK"),
|
||||
HEART_OF_THE_SEA(0, "STONE"),
|
||||
HEAVY_WEIGHTED_PRESSURE_PLATE(0, "IRON_PLATE"),
|
||||
HOPPER(0, "HOPPER"),
|
||||
HOPPER_MINECART(0, "HOPPER_MINECART"),
|
||||
HORN_CORAL(0, "STONE"),
|
||||
HORN_CORAL_BLOCK(0, "STONE"),
|
||||
HORN_CORAL_FAN(0, "STONE"),
|
||||
HORSE_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
HUSK_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
ICE(0, "ICE"),
|
||||
INFESTED_CHISELED_STONE_BRICKS(5, "MONSTER_EGGS"),
|
||||
INFESTED_COBBLESTONE(1, "MONSTER_EGGS"),
|
||||
INFESTED_CRACKED_STONE_BRICKS(4, "MONSTER_EGGS"),
|
||||
INFESTED_MOSSY_STONE_BRICKS(3, "MONSTER_EGGS"),
|
||||
INFESTED_STONE(0, "MONSTER_EGGS"),
|
||||
INFESTED_STONE_BRICKS(2, "MONSTER_EGGS"),
|
||||
INK_SAC(0, "INK_SACK"),
|
||||
IRON_AXE(0, "IRON_AXE"),
|
||||
IRON_BARS(0, "IRON_FENCE"),
|
||||
IRON_BLOCK(0, "IRON_BLOCK"),
|
||||
IRON_BOOTS(0, "IRON_BOOTS"),
|
||||
IRON_CHESTPLATE(0, "IRON_CHESTPLATE"),
|
||||
IRON_DOOR(0, "IRON_DOOR", "IRON_DOOR_BLOCK"),
|
||||
IRON_HELMET(0, "IRON_HELMET"),
|
||||
IRON_HOE(0, "IRON_HOE"),
|
||||
IRON_HORSE_ARMOR(0, "IRON_BARDING"),
|
||||
IRON_INGOT(0, "IRON_INGOT"),
|
||||
IRON_LEGGINGS(0, "IRON_LEGGINGS"),
|
||||
IRON_NUGGET(0, "IRON_NUGGET"),
|
||||
IRON_ORE(0, "IRON_ORE"),
|
||||
IRON_PICKAXE(0, "IRON_PICKAXE"),
|
||||
IRON_SHOVEL(0, "IRON_SPADE"),
|
||||
IRON_SWORD(0, "IRON_SWORD"),
|
||||
IRON_TRAPDOOR(0, "IRON_TRAPDOOR"),
|
||||
ITEM_FRAME(0, "ITEM_FRAME"),
|
||||
JACK_O_LANTERN(0, "JACK_O_LANTERN"),
|
||||
JUKEBOX(0, "JUKEBOX"),
|
||||
JUNGLE_BOAT(0, "BOAT_JUNGLE"),
|
||||
JUNGLE_BUTTON(0, "WOOD_BUTTON"),
|
||||
JUNGLE_DOOR(0, "JUNGLE_DOOR", "JUNGLE_DOOR_ITEM"),
|
||||
JUNGLE_FENCE(0, "JUNGLE_FENCE"),
|
||||
JUNGLE_FENCE_GATE(0, "JUNGLE_FENCE_GATE"),
|
||||
JUNGLE_LEAVES(3, "LEAVES"),
|
||||
JUNGLE_LOG(3, "LOG"),
|
||||
JUNGLE_PLANKS(3, "WOOD"),
|
||||
JUNGLE_PRESSURE_PLATE(0, "WOOD_PLATE"),
|
||||
JUNGLE_SAPLING(3, "SAPLING"),
|
||||
JUNGLE_SLAB(3, "WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"),
|
||||
JUNGLE_STAIRS(0, "JUNGLE_WOOD_STAIRS"),
|
||||
JUNGLE_TRAPDOOR(0, "TRAP_DOOR"),
|
||||
JUNGLE_WOOD(3, "LOG"),
|
||||
KELP(0, "STONE"),
|
||||
KELP_PLANT(0, "STONE"),
|
||||
KNOWLEDGE_BOOK(0, "KNOWLEDGE_BOOK"),
|
||||
LADDER(0, "LADDER"),
|
||||
LAPIS_BLOCK(0, "LAPIS_BLOCK"),
|
||||
LAPIS_LAZULI(4, "INK_SACK"),
|
||||
LAPIS_ORE(0, "LAPIS_ORE"),
|
||||
LARGE_FERN(3, "DOUBLE_PLANT"),
|
||||
LAVA(0, "LAVA", "STATIONARY_LAVA"),
|
||||
LAVA_BUCKET(0, "LAVA_BUCKET"),
|
||||
LEAD(0, "LEASH"),
|
||||
LEATHER(0, "LEATHER"),
|
||||
LEATHER_BOOTS(0, "LEATHER_BOOTS"),
|
||||
LEATHER_CHESTPLATE(0, "LEATHER_CHESTPLATE"),
|
||||
LEATHER_HELMET(0, "LEATHER_HELMET"),
|
||||
LEATHER_LEGGINGS(0, "LEATHER_LEGGINGS"),
|
||||
LEVER(0, "LEVER"),
|
||||
LIGHT_BLUE_BANNER(12, "BANNER", "STANDING_BANNER"),
|
||||
LIGHT_BLUE_BED(3, "BED", "BED_BLOCK"),
|
||||
LIGHT_BLUE_CARPET(3, "CARPET"),
|
||||
LIGHT_BLUE_CONCRETE(3, "CONCRETE"),
|
||||
LIGHT_BLUE_CONCRETE_POWDER(3, "CONCRETE_POWDER"),
|
||||
LIGHT_BLUE_DYE(12, "INK_SACK"),
|
||||
LIGHT_BLUE_GLAZED_TERRACOTTA(0, "LIGHT_BLUE_GLAZED_TERRACOTTA"),
|
||||
LIGHT_BLUE_SHULKER_BOX(0, "LIGHT_BLUE_SHULKER_BOX"),
|
||||
LIGHT_BLUE_STAINED_GLASS(3, "STAINED_GLASS"),
|
||||
LIGHT_BLUE_STAINED_GLASS_PANE(3, "STAINED_GLASS_PANE"),
|
||||
LIGHT_BLUE_TERRACOTTA(3, "STAINED_CLAY"),
|
||||
LIGHT_BLUE_WALL_BANNER(0, "BANNER", "STANDING_BANNER"),
|
||||
LIGHT_BLUE_WOOL(3, "WOOL"),
|
||||
LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"),
|
||||
LIGHT_GRAY_BED(8, "BED", "BED_BLOCK"),
|
||||
LIGHT_GRAY_CARPET(8, "CARPET"),
|
||||
LIGHT_GRAY_CONCRETE(8, "CONCRETE"),
|
||||
LIGHT_GRAY_CONCRETE_POWDER(8, "CONCRETE_POWDER"),
|
||||
LIGHT_GRAY_DYE(7, "INK_SACK"),
|
||||
LIGHT_GRAY_GLAZED_TERRACOTTA(0, "SILVER_GLAZED_TERRACOTTA"),
|
||||
LIGHT_GRAY_SHULKER_BOX(0, "SILVER_SHULKER_BOX"),
|
||||
LIGHT_GRAY_STAINED_GLASS(8, "STAINED_GLASS"),
|
||||
LIGHT_GRAY_STAINED_GLASS_PANE(8, "STAINED_GLASS_PANE"),
|
||||
LIGHT_GRAY_TERRACOTTA(8, "STAINED_CLAY"),
|
||||
LIGHT_GRAY_WALL_BANNER(0, "WALL_BANNER"),
|
||||
LIGHT_GRAY_WOOL(8, "WOOL"),
|
||||
LIGHT_WEIGHTED_PRESSURE_PLATE(0, "GOLD_PLATE"),
|
||||
LILAC(1, "DOUBLE_PLANT"),
|
||||
LILY_PAD(0, "WATER_LILY"),
|
||||
LIME_BANNER(10, "BANNER", "STANDING_BANNER"),
|
||||
LIME_BED(5, "BED", "BED_BLOCK"),
|
||||
LIME_CARPET(5, "CARPET"),
|
||||
LIME_CONCRETE(5, "CONCRETE"),
|
||||
LIME_CONCRETE_POWDER(5, "CONCRETE_POWDER"),
|
||||
LIME_DYE(10, "INK_SACK"),
|
||||
LIME_GLAZED_TERRACOTTA(0, "LIME_GLAZED_TERRACOTTA"),
|
||||
LIME_SHULKER_BOX(0, "LIME_SHULKER_BOX"),
|
||||
LIME_STAINED_GLASS(5, "STAINED_GLASS"),
|
||||
LIME_STAINED_GLASS_PANE(5, "STAINED_GLASS_PANE"),
|
||||
LIME_TERRACOTTA(5, "STAINED_CLAY"),
|
||||
LIME_WALL_BANNER(0, "WALL_BANNER"),
|
||||
LIME_WOOL(5, "WOOL"),
|
||||
LINGERING_POTION(0, "LINGERING_POTION"),
|
||||
LLAMA_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"),
|
||||
MAGENTA_BED(2, "BED", "BED_BLOCK"),
|
||||
MAGENTA_CARPET(2, "CARPET"),
|
||||
MAGENTA_CONCRETE(2, "CONCRETE"),
|
||||
MAGENTA_CONCRETE_POWDER(2, "CONCRETE_POWDER"),
|
||||
MAGENTA_DYE(13, "INK_SACK"),
|
||||
MAGENTA_GLAZED_TERRACOTTA(0, "MAGENTA_GLAZED_TERRACOTTA"),
|
||||
MAGENTA_SHULKER_BOX(0, "MAGENTA_SHULKER_BOX"),
|
||||
MAGENTA_STAINED_GLASS(2, "STAINED_GLASS"),
|
||||
MAGENTA_STAINED_GLASS_PANE(2, "STAINED_GLASS_PANE"),
|
||||
MAGENTA_TERRACOTTA(2, "STAINED_CLAY"),
|
||||
MAGENTA_WALL_BANNER(0, "WALL_BANNER"),
|
||||
MAGENTA_WOOL(2, "WOOL"),
|
||||
MAGMA_BLOCK(0, "MAGMA"),
|
||||
MAGMA_CREAM(0, "MAGMA_CREAM"),
|
||||
MAGMA_CUBE_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
MAP(0, "MAP", "EMPTY_MAP"),
|
||||
MELON(0, "MELON_BLOCK"),
|
||||
MELON_SEEDS(0, "MELON_SEEDS"),
|
||||
MELON_SLICE(0, "MELON"),
|
||||
MELON_STEM(0, "MELON_STEM"),
|
||||
MILK_BUCKET(0, "MILK_BUCKET"),
|
||||
MINECART(0, "MINECART"),
|
||||
MOOSHROOM_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
MOSSY_COBBLESTONE(0, "MOSSY_COBBLESTONE"),
|
||||
MOSSY_COBBLESTONE_WALL(1, "COBBLE_WALL"),
|
||||
MOSSY_STONE_BRICKS(1, "SMOOTH_BRICK"),
|
||||
MOVING_PISTON(0, "PISTON_MOVING_PIECE"),
|
||||
MULE_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
MUSHROOM_STEM(0, "BROWN_MUSHROOM"),
|
||||
MUSHROOM_STEW(0, "MUSHROOM_SOUP"),
|
||||
MUSIC_DISC_11(0, "GOLD_RECORD"),
|
||||
MUSIC_DISC_13(0, "GREEN_RECORD"),
|
||||
MUSIC_DISC_BLOCKS(0, "RECORD_3"),
|
||||
MUSIC_DISC_CAT(0, "RECORD_4"),
|
||||
MUSIC_DISC_CHIRP(0, "RECORD_5"),
|
||||
MUSIC_DISC_FAR(0, "RECORD_6"),
|
||||
MUSIC_DISC_MALL(0, "RECORD_7"),
|
||||
MUSIC_DISC_MELLOHI(0, "RECORD_8"),
|
||||
MUSIC_DISC_STAL(0, "RECORD_9"),
|
||||
MUSIC_DISC_STRAD(0, "RECORD_10"),
|
||||
MUSIC_DISC_WAIT(0, "RECORD_11"),
|
||||
MUSIC_DISC_WARD(0, "RECORD_12"),
|
||||
MUTTON(0, "MUTTON"),
|
||||
MYCELIUM(0, "MYCEL"),
|
||||
NAME_TAG(0, "NAME_TAG"),
|
||||
NAUTILUS_SHELL(0, "STONE"),
|
||||
NETHERRACK(0, "NETHERRACK"),
|
||||
NETHER_BRICK(0, "NETHER_BRICK"),
|
||||
NETHER_BRICKS(0, "NETHER_BRICK"),
|
||||
NETHER_BRICK_FENCE(0, "NETHER_FENCE"),
|
||||
NETHER_BRICK_SLAB(6, "STEP"),
|
||||
NETHER_BRICK_STAIRS(0, "NETHER_BRICK_STAIRS"),
|
||||
NETHER_PORTAL(0, "PORTAL"),
|
||||
NETHER_QUARTZ_ORE(0, "QUARTZ_ORE"),
|
||||
NETHER_STAR(0, "NETHER_STAR"),
|
||||
NETHER_WART(0, "NETHER_STALK"),
|
||||
NETHER_WART_BLOCK(0, "NETHER_WART_BLOCK", "NETHER_WARTS"),
|
||||
NOTE_BLOCK(0, "NOTE_BLOCK"),
|
||||
OAK_BOAT(0, "BOAT"),
|
||||
OAK_BUTTON(0, "WOOD_BUTTON"),
|
||||
OAK_DOOR(0, "WOODEN_DOOR", "WOOD_DOOR"),
|
||||
OAK_FENCE(0, "FENCE"),
|
||||
OAK_FENCE_GATE(0, "FENCE_GATE"),
|
||||
OAK_LEAVES(0, "LEAVES"),
|
||||
OAK_LOG(0, "LOG"),
|
||||
OAK_PLANKS(0, "WOOD"),
|
||||
OAK_PRESSURE_PLATE(0, "WOOD_PLATE"),
|
||||
OAK_SAPLING(0, "SAPLING"),
|
||||
OAK_SLAB(0, "WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"),
|
||||
OAK_STAIRS(0, "WOOD_STAIRS"),
|
||||
OAK_TRAPDOOR(0, "TRAP_DOOR"),
|
||||
OAK_WOOD(0, "LOG"),
|
||||
OBSERVER(0, "OBSERVER"),
|
||||
OBSIDIAN(0, "OBSIDIAN"),
|
||||
OCELOT_SPAWN_EGG(0, "RECORD_12"),
|
||||
ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"),
|
||||
ORANGE_BED(1, "BED", "BED_BLOCK"),
|
||||
ORANGE_CARPET(1, "CARPET"),
|
||||
ORANGE_CONCRETE(1, "CONCRETE"),
|
||||
ORANGE_CONCRETE_POWDER(1, "CONCRETE_POWDER"),
|
||||
ORANGE_DYE(14, "INK_SACK"),
|
||||
ORANGE_GLAZED_TERRACOTTA(0, "ORANGE_GLAZED_TERRACOTTA"),
|
||||
ORANGE_SHULKER_BOX(0, "ORANGE_SHULKER_BOX"),
|
||||
ORANGE_STAINED_GLASS(1, "STAINED_GLASS"),
|
||||
ORANGE_STAINED_GLASS_PANE(1, "STAINED_GLASS_PANE"),
|
||||
ORANGE_TERRACOTTA(1, "STAINED_CLAY"),
|
||||
ORANGE_TULIP(5, "RED_ROSE"),
|
||||
ORANGE_WALL_BANNER(0, "WALL_BANNER"),
|
||||
ORANGE_WOOL(1, "WOOL"),
|
||||
OXEYE_DAISY(8, "RED_ROSE"),
|
||||
PACKED_ICE(0, "PACKED_ICE"),
|
||||
PAINTING(0, "PAINTING"),
|
||||
PAPER(0, "PAPER"),
|
||||
PARROT_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
PEONY(5, "DOUBLE_PLANT"),
|
||||
PETRIFIED_OAK_SLAB(0, "STONE"),
|
||||
PHANTOM_MEMBRANE(0, "STONE"),
|
||||
PHANTOM_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
PIG_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
PINK_BANNER(9, "BANNER", "STANDING_BANNER"),
|
||||
PINK_BED(6, "BED", "BED_BLOCK"),
|
||||
PINK_CARPET(6, "CARPET"),
|
||||
PINK_CONCRETE(6, "CONCRETE"),
|
||||
PINK_CONCRETE_POWDER(6, "CONCRETE_POWDER"),
|
||||
PINK_DYE(9, "INK_SACK"),
|
||||
PINK_GLAZED_TERRACOTTA(0, "PINK_GLAZED_TERRACOTTA"),
|
||||
PINK_SHULKER_BOX(0, "PINK_SHULKER_BOX"),
|
||||
PINK_STAINED_GLASS(6, "STAINED_GLASS"),
|
||||
PINK_STAINED_GLASS_PANE(6, "STAINED_GLASS_PANE"),
|
||||
PINK_TERRACOTTA(6, "STAINED_CLAY"),
|
||||
PINK_TULIP(7, "RED_ROSE"),
|
||||
PINK_WALL_BANNER(0, "WALL_BANNER"),
|
||||
PINK_WOOL(6, "WOOL"),
|
||||
PISTON(0, "PISTON_BASE"),
|
||||
PISTON_HEAD(0, "PISTON_EXTENSION"),
|
||||
PLAYER_HEAD(0, "SKULL", "SKULL_ITEM"),
|
||||
PLAYER_WALL_HEAD(0, "SKULL", "SKULL_ITEM"),
|
||||
PODZOL(2, "DIRT"),
|
||||
POISONOUS_POTATO(0, "POISONOUS_POTATO"),
|
||||
POLAR_BEAR_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
POLISHED_ANDESITE(6, "STONE"),
|
||||
POLISHED_DIORITE(4, "STONE"),
|
||||
POLISHED_GRANITE(2, "STONE"),
|
||||
POPPED_CHORUS_FRUIT(0, "CHORUS_FRUIT_POPPED"),
|
||||
POPPY(0, "RED_ROSE"),
|
||||
PORKCHOP(0, "PORK"),
|
||||
POTATO(0, "POTATO_ITEM"),
|
||||
POTATOES(0, "POTATO"),
|
||||
POTION(0, "POTION"),
|
||||
POTTED_ACACIA_SAPLING(0, "FLOWER_POT"),
|
||||
POTTED_ALLIUM(0, "FLOWER_POT"),
|
||||
POTTED_AZURE_BLUET(0, "FLOWER_POT"),
|
||||
POTTED_BIRCH_SAPLING(0, "FLOWER_POT"),
|
||||
POTTED_BLUE_ORCHID(0, "FLOWER_POT"),
|
||||
POTTED_BROWN_MUSHROOM(0, "FLOWER_POT"),
|
||||
POTTED_CACTUS(0, "FLOWER_POT"),
|
||||
POTTED_DANDELION(0, "FLOWER_POT"),
|
||||
POTTED_DARK_OAK_SAPLING(0, "FLOWER_POT"),
|
||||
POTTED_DEAD_BUSH(0, "FLOWER_POT"),
|
||||
POTTED_FERN(0, "FLOWER_POT"),
|
||||
POTTED_JUNGLE_SAPLING(0, "FLOWER_POT"),
|
||||
POTTED_OAK_SAPLING(0, "FLOWER_POT"),
|
||||
POTTED_ORANGE_TULIP(0, "FLOWER_POT"),
|
||||
POTTED_OXEYE_DAISY(0, "FLOWER_POT"),
|
||||
POTTED_PINK_TULIP(0, "FLOWER_POT"),
|
||||
POTTED_POPPY(0, "FLOWER_POT"),
|
||||
POTTED_RED_MUSHROOM(0, "FLOWER_POT"),
|
||||
POTTED_RED_TULIP(0, "FLOWER_POT"),
|
||||
POTTED_SPRUCE_SAPLING(0, "FLOWER_POT"),
|
||||
POTTED_WHITE_TULIP(0, "FLOWER_POT"),
|
||||
POWERED_RAIL(0, "POWERED_RAIL"),
|
||||
PRISMARINE(0, "PRISMARINE"),
|
||||
PRISMARINE_BRICKS(1, "PRISMARINE"),
|
||||
PRISMARINE_BRICK_SLAB(0, "STONE"),
|
||||
PRISMARINE_BRICK_STAIRS(0, "STONE"),
|
||||
PRISMARINE_CRYSTALS(0, "PRISMARINE_CRYSTALS"),
|
||||
PRISMARINE_SHARD(0, "PRISMARINE_SHARD"),
|
||||
PRISMARINE_SLAB(0, "STONE"),
|
||||
PRISMARINE_STAIRS(0, "STONE"),
|
||||
PUFFERFISH(3, "RAW_FISH"),
|
||||
PUFFERFISH_BUCKET(0, "STONE"),
|
||||
PUFFERFISH_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
PUMPKIN(0, "PUMPKIN"),
|
||||
PUMPKIN_PIE(0, "PUMPKIN_PIE"),
|
||||
PUMPKIN_SEEDS(0, "PUMPKIN_SEEDS"),
|
||||
PUMPKIN_STEM(0, "PUMPKIN_STEM"),
|
||||
PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"),
|
||||
PURPLE_BED(10, "BED", "BED_BLOCK"),
|
||||
PURPLE_CARPET(10, "CARPET"),
|
||||
PURPLE_CONCRETE(10, "CONCRETE"),
|
||||
PURPLE_CONCRETE_POWDER(10, "CONCRETE_POWDER"),
|
||||
PURPLE_DYE(5, "INK_SACK"),
|
||||
PURPLE_GLAZED_TERRACOTTA(0, "PURPLE_GLAZED_TERRACOTTA"),
|
||||
PURPLE_SHULKER_BOX(0, "PURPLE_SHULKER_BOX"),
|
||||
PURPLE_STAINED_GLASS(10, "STAINED_GLASS"),
|
||||
PURPLE_STAINED_GLASS_PANE(10, "STAINED_GLASS_PANE"),
|
||||
PURPLE_TERRACOTTA(10, "STAINED_CLAY"),
|
||||
PURPLE_WALL_BANNER(0, "WALL_BANNER"),
|
||||
PURPLE_WOOL(10, "WOOL"),
|
||||
PURPUR_BLOCK(0, "PURPUR_BLOCK"),
|
||||
PURPUR_PILLAR(0, "PURPUR_PILLAR"),
|
||||
PURPUR_SLAB(0, "PURPUR_SLAB", "PURPUR_DOUBLE_SLAB"),
|
||||
PURPUR_STAIRS(0, "PURPUR_STAIRS"),
|
||||
QUARTZ(0, "QUARTZ"),
|
||||
QUARTZ_BLOCK(0, "QUARTZ_BLOCK"),
|
||||
QUARTZ_PILLAR(2, "QUARTZ_BLOCK"),
|
||||
QUARTZ_SLAB(7, "STEP"),
|
||||
QUARTZ_STAIRS(0, "QUARTZ_STAIRS"),
|
||||
RABBIT(0, "RABBIT"),
|
||||
RABBIT_FOOT(0, "RABBIT_FOOT"),
|
||||
RABBIT_HIDE(0, "RABBIT_HIDE"),
|
||||
RABBIT_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
RABBIT_STEW(0, "RABBIT_STEW"),
|
||||
RAIL(0, "RAILS"),
|
||||
REDSTONE(0, "REDSTONE"),
|
||||
REDSTONE_BLOCK(0, "REDSTONE_BLOCK"),
|
||||
REDSTONE_LAMP(0, "REDSTONE_LAMP_ON", "REDSTONE_LAMP_OFF"),
|
||||
REDSTONE_ORE(0, "REDSTONE_ORE", "GLOWING_REDSTONE_ORE"),
|
||||
REDSTONE_TORCH(0, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"),
|
||||
REDSTONE_WALL_TORCH(1, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"),
|
||||
REDSTONE_WIRE(0, "REDSTONE_WIRE"),
|
||||
RED_BANNER(1, "BANNER", "STANDING_BANNER"),
|
||||
RED_BED(14, "BED", "BED_BLOCK"),
|
||||
RED_CARPET(14, "CARPET"),
|
||||
RED_CONCRETE(14, "CONCRETE"),
|
||||
RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"),
|
||||
RED_GLAZED_TERRACOTTA(0, "RED_GLAZED_TERRACOTTA"),
|
||||
RED_MUSHROOM(0, "RED_MUSHROOM"),
|
||||
RED_MUSHROOM_BLOCK(0, "RED_MUSHROOM", "HUGE_MUSHROOM_2"),
|
||||
RED_NETHER_BRICKS(0, "RED_NETHER_BRICK"),
|
||||
RED_SAND(1, "SAND"),
|
||||
RED_SANDSTONE(0, "RED_SANDSTONE"),
|
||||
RED_SANDSTONE_SLAB(0, "STONE_SLAB2", "DOUBLE_STONE_SLAB2"),
|
||||
RED_SANDSTONE_STAIRS(0, "RED_SANDSTONE_STAIRS"),
|
||||
RED_SHULKER_BOX(0, "RED_SHULKER_BOX"),
|
||||
RED_STAINED_GLASS(14, "STAINED_GLASS"),
|
||||
RED_STAINED_GLASS_PANE(14, "STAINED_GLASS_PANE"),
|
||||
RED_TERRACOTTA(14, "STAINED_CLAY"),
|
||||
RED_TULIP(4, "RED_ROSE"),
|
||||
RED_WALL_BANNER(0, "WALL_BANNER"),
|
||||
RED_WOOL(14, "WOOL"),
|
||||
REPEATER(0, "DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"),
|
||||
REPEATING_COMMAND_BLOCK(0, "COMMAND_REPEATING"),
|
||||
ROSE_BUSH(4, "DOUBLE_PLANT"),
|
||||
ROSE_RED(1, "INK_SACK"),
|
||||
ROTTEN_FLESH(0, "ROTTEN_FLESH"),
|
||||
SADDLE(0, "SADDLE"),
|
||||
SALMON(1, "RAW_FISH"),
|
||||
SALMON_BUCKET(0, "BUCKET"),
|
||||
SALMON_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
SAND(0, "SAND"),
|
||||
SANDSTONE(0, "SANDSTONE"),
|
||||
SANDSTONE_SLAB(1, "STONE_SLAB", "STEP", "DOUBLE_STEP"),
|
||||
SANDSTONE_STAIRS(0, "SANDSTONE_STAIRS"),
|
||||
SCUTE(0, "STONE"),
|
||||
SEAGRASS(0, "STONE"),
|
||||
SEA_LANTERN(0, "SEA_LANTERN"),
|
||||
SEA_PICKLE(0, "STONE"),
|
||||
SHEARS(0, "SHEARS"),
|
||||
SHEEP_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
SHIELD(0, "SHIELD"),
|
||||
SHULKER_BOX(0, "PURPLE_SHULKER_BOX"),
|
||||
SHULKER_SHELL(0, "SHULKER_SHELL"),
|
||||
SHULKER_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
SIGN(0, "SIGN"),
|
||||
SILVERFISH_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
SKELETON_HORSE_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
SKELETON_SKULL(0, "SKULL", "SKULL_ITEM"),
|
||||
SKELETON_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
SKELETON_WALL_SKULL(0, "SKULL", "SKULL_ITEM"),
|
||||
SLIME_BALL(0, "SLIME_BALL"),
|
||||
SLIME_BLOCK(0, "SLIME_BLOCK"),
|
||||
SLIME_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
SMOOTH_QUARTZ(0, "STONE"),
|
||||
SMOOTH_RED_SANDSTONE(2, "RED_SANDSTONE"),
|
||||
SMOOTH_SANDSTONE(2, "SANDSTONE"),
|
||||
SMOOTH_STONE(0, "STEP"),
|
||||
SNOW(0, "SNOW"),
|
||||
SNOWBALL(0, "SNOW_BALL"),
|
||||
SNOW_BLOCK(0, "SNOW_BLOCK"),
|
||||
SOUL_SAND(0, "SOUL_SAND"),
|
||||
SPAWNER(0, "MOB_SPAWNER"),
|
||||
SPECTRAL_ARROW(0, "SPECTRAL_ARROW"),
|
||||
SPIDER_EYE(0, "SPIDER_EYE"),
|
||||
SPIDER_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
SPLASH_POTION(0, "SPLASH_POTION"),
|
||||
SPONGE(0, "SPONGE"),
|
||||
SPRUCE_BOAT(0, "BOAT_SPRUCE"),
|
||||
SPRUCE_BUTTON(0, "WOOD_BUTTON"),
|
||||
SPRUCE_DOOR(0, "SPRUCE_DOOR", "SPRUCE_DOOR_ITEM"),
|
||||
SPRUCE_FENCE(0, "SPRUCE_FENCE"),
|
||||
SPRUCE_FENCE_GATE(0, "SPRUCE_FENCE_GATE"),
|
||||
SPRUCE_LEAVES(1, "LEAVES"),
|
||||
SPRUCE_LOG(1, "LOG"),
|
||||
SPRUCE_PLANKS(1, "WOOD"),
|
||||
SPRUCE_PRESSURE_PLATE(0, "WOOD_PLATE"),
|
||||
SPRUCE_SAPLING(1, "SAPLING"),
|
||||
SPRUCE_SLAB(1, "WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"),
|
||||
SPRUCE_STAIRS(0, "SPRUCE_WOOD_STAIRS"),
|
||||
SPRUCE_TRAPDOOR(0, "TRAP_DOOR"),
|
||||
SPRUCE_WOOD(1, "LOG"),
|
||||
SQUID_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
STICK(0, "STICK"),
|
||||
STICKY_PISTON(0, "PISTON_STICKY_BASE"),
|
||||
STONE(0, "STONE"),
|
||||
STONE_AXE(0, "STONE_AXE"),
|
||||
STONE_BRICKS(0, "SMOOTH_BRICK"),
|
||||
STONE_BRICK_SLAB(5, "STONE_SLAB", "STEP", "DOUBLE_STEP"),
|
||||
STONE_BRICK_STAIRS(0, "SMOOTH_STAIRS"),
|
||||
STONE_BUTTON(0, "STONE_BUTTON"),
|
||||
STONE_HOE(0, "STONE_HOE"),
|
||||
STONE_PICKAXE(0, "STONE_PICKAXE"),
|
||||
STONE_PRESSURE_PLATE(0, "STONE_PLATE"),
|
||||
STONE_SHOVEL(0, "STONE_SPADE"),
|
||||
STONE_SLAB(0, "STONE_SLAB", "STEP", "DOUBLE_STEP"),
|
||||
STONE_SWORD(0, "STONE_SWORD"),
|
||||
STRAY_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
STRING(0, "STRING"),
|
||||
STRIPPED_ACACIA_LOG(0, "STONE"),
|
||||
STRIPPED_ACACIA_WOOD(0, "STONE"),
|
||||
STRIPPED_BIRCH_LOG(0, "STONE"),
|
||||
STRIPPED_BIRCH_WOOD(0, "STONE"),
|
||||
STRIPPED_DARK_OAK_LOG(0, "STONE"),
|
||||
STRIPPED_DARK_OAK_WOOD(0, "STONE"),
|
||||
STRIPPED_JUNGLE_LOG(0, "STONE"),
|
||||
STRIPPED_JUNGLE_WOOD(0, "STONE"),
|
||||
STRIPPED_OAK_LOG(0, "STONE"),
|
||||
STRIPPED_OAK_WOOD(0, "STONE"),
|
||||
STRIPPED_SPRUCE_LOG(0, "STONE"),
|
||||
STRIPPED_SPRUCE_WOOD(0, "STONE"),
|
||||
STRUCTURE_BLOCK(0, "STRUCTURE_BLOCK"),
|
||||
STRUCTURE_VOID(0, "STRUCTURE_VOID"),
|
||||
SUGAR(0, "SUGAR"),
|
||||
SUGAR_CANE(0, "SUGAR_CANE", "SUGAR_CANE_BLOCK"),
|
||||
SUNFLOWER(0, "DOUBLE_PLANT"),
|
||||
TALL_GRASS(2, "DOUBLE_PLANT"),
|
||||
TALL_SEAGRASS(0, "STONE"),
|
||||
TERRACOTTA(0, "HARD_CLAY"),
|
||||
TIPPED_ARROW(0, "TIPPED_ARROW"),
|
||||
TNT(0, "TNT"),
|
||||
TNT_MINECART(0, "EXPLOSIVE_MINECART"),
|
||||
TORCH(0, "TORCH"),
|
||||
TOTEM_OF_UNDYING(0, "TOTEM"),
|
||||
TRAPPED_CHEST(0, "TRAPPED_CHEST"),
|
||||
TRIDENT(0, "STONE"),
|
||||
TRIPWIRE(0, "TRIPWIRE"),
|
||||
TRIPWIRE_HOOK(0, "TRIPWIRE_HOOK"),
|
||||
TROPICAL_FISH(0, "RAW_FISH"),
|
||||
TROPICAL_FISH_BUCKET(0, "BUCKET"),
|
||||
TROPICAL_FISH_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
TUBE_CORAL(0, "STONE"),
|
||||
TUBE_CORAL_BLOCK(0, "STONE"),
|
||||
TUBE_CORAL_FAN(0, "STONE"),
|
||||
TURTLE_EGG(0, "MONSTER_EGG"),
|
||||
TURTLE_HELMET(0, "STONE"),
|
||||
TURTLE_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
VEX_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
VILLAGER_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
VINDICATOR_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
VINE(0, "VINE"),
|
||||
VOID_AIR(0, "AIR"),
|
||||
WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"),
|
||||
WALL_TORCH(1, "TORCH"),
|
||||
WATER(0, "WATER", "STATIONARY_WATER"),
|
||||
WATER_BUCKET(0, "WATER_BUCKET"),
|
||||
WET_SPONGE(1, "SPONGE"),
|
||||
WHEAT(0, "WHEAT", "CROPS"),
|
||||
WHEAT_SEEDS(0, "WHEAT_SEEDS", "SEEDS"),
|
||||
WHITE_BANNER(15, "BANNER", "STANDING_BANNER"),
|
||||
WHITE_BED(0, "BED", "BED_BLOCK"),
|
||||
WHITE_CARPET(0, "CARPET"),
|
||||
WHITE_CONCRETE(0, "CONCRETE"),
|
||||
WHITE_CONCRETE_POWDER(0, "CONCRETE_POWDER"),
|
||||
WHITE_GLAZED_TERRACOTTA(0, "WHITE_GLAZED_TERRACOTTA"),
|
||||
WHITE_SHULKER_BOX(0, "WHITE_SHULKER_BOX"),
|
||||
WHITE_STAINED_GLASS(0, "STAINED_GLASS"),
|
||||
WHITE_STAINED_GLASS_PANE(0, "STAINED_GLASS_PANE"),
|
||||
WHITE_TERRACOTTA(0, "TERRACOTTA"),
|
||||
WHITE_TULIP(6, "RED_ROSE"),
|
||||
WHITE_WALL_BANNER(0, "WALL_BANNER"),
|
||||
WHITE_WOOL(0, "WOOL"),
|
||||
WITCH_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
WITHER_SKELETON_SKULL(0, "SKULL", "SKULL_ITEM"),
|
||||
WITHER_SKELETON_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
WITHER_SKELETON_WALL_SKULL(0, "SKULL", "SKULL_ITEM"),
|
||||
WOLF_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
WOODEN_AXE(0, "WOOD_AXE"),
|
||||
WOODEN_HOE(0, "WOOD_HOE"),
|
||||
WOODEN_PICKAXE(0, "WOOD_PICKAXE"),
|
||||
WOODEN_SHOVEL(0, "WOOD_SPADE"),
|
||||
WOODEN_SWORD(0, "WOOD_SWORD"),
|
||||
WRITABLE_BOOK(0, "BOOK_AND_QUILL"),
|
||||
WRITTEN_BOOK(0, "WRITTEN_BOOK"),
|
||||
YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"),
|
||||
YELLOW_BED(4, "BED", "BED_BLOCK"),
|
||||
YELLOW_CARPET(4, "CARPET"),
|
||||
YELLOW_CONCRETE(4, "CONCRETE"),
|
||||
YELLOW_CONCRETE_POWDER(4, "CONCRETE_POWDER"),
|
||||
YELLOW_GLAZED_TERRACOTTA(0, "YELLOW_GLAZED_TERRACOTTA"),
|
||||
YELLOW_SHULKER_BOX(0, "YELLOW_SHULKER_BOX"),
|
||||
YELLOW_STAINED_GLASS(4, "STAINED_GLASS"),
|
||||
YELLOW_STAINED_GLASS_PANE(4, "STAINED_GLASS_PANE"),
|
||||
YELLOW_TERRACOTTA(4, "STAINED_CLAY"),
|
||||
YELLOW_WALL_BANNER(0, "WALL_BANNER"),
|
||||
YELLOW_WOOL(4, "WOOL"),
|
||||
ZOMBIE_HEAD(0, "SKULL", "SKULL_ITEM"),
|
||||
ZOMBIE_HORSE_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
ZOMBIE_PIGMAN_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
ZOMBIE_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
ZOMBIE_VILLAGER_SPAWN_EGG(0, "MONSTER_EGG"),
|
||||
ZOMBIE_WALL_HEAD(0, "SKULL", "SKULL_ITEM");
|
||||
|
||||
private static HashMap<String, ItemStack> cachedSearch = new HashMap<>();
|
||||
int data;
|
||||
String[] m;
|
||||
|
||||
VersionEnum(int data, String... m) {
|
||||
this.m = m;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static ItemStack requestMaterial(String name) {
|
||||
if (cachedSearch.containsKey(name.toUpperCase())) {
|
||||
return cachedSearch.get(name.toUpperCase());
|
||||
}
|
||||
|
||||
for (VersionEnum value : VersionEnum.values()) {
|
||||
if (name.toUpperCase().equals(value.toString())) {
|
||||
ItemStack itemStack = new ItemStack(Material.valueOf(value.m[0]), 1, (short) value.data);
|
||||
cachedSearch.put(name, itemStack);
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* ConfigWrapper made by @clip
|
||||
*/
|
||||
public class ConfigWrapper {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final String folderName, fileName;
|
||||
private FileConfiguration config;
|
||||
private File configFile;
|
||||
|
||||
public ConfigWrapper(final JavaPlugin instance, final String folderName, final String fileName) {
|
||||
this.plugin = instance;
|
||||
this.folderName = folderName;
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public void createNewFile(final String message, final String header) {
|
||||
reloadConfig();
|
||||
saveConfig();
|
||||
loadConfig(header);
|
||||
|
||||
if (message != null) {
|
||||
plugin.getLogger().info(message);
|
||||
}
|
||||
}
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
if (config == null) {
|
||||
reloadConfig();
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
public void loadConfig(final String header) {
|
||||
config.options().header(header);
|
||||
config.options().copyDefaults(true);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
if (configFile == null) {
|
||||
configFile = new File(plugin.getDataFolder() + folderName, fileName);
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
if (config == null || configFile == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
getConfig().save(configFile);
|
||||
} catch (final IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Could not save config to " + configFile, ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/25/2017.
|
||||
*/
|
||||
public class Methods {
|
||||
|
||||
private static EpicFurnaces instance;
|
||||
|
||||
public static void init(EpicFurnaces main) {
|
||||
instance = main;
|
||||
}
|
||||
|
||||
public static ItemStack getGlass(Boolean rainbow, int type) {
|
||||
int randomNum = 1 + (int) (Math.random() * 6.0D);
|
||||
ItemStack glass;
|
||||
|
||||
if (rainbow) {
|
||||
glass = new ItemStack(instance.getBukkitEnums().getMaterial("WHITE_STAINED_GLASS_PANE").getType(), 1, (short) randomNum);
|
||||
} else {
|
||||
glass = new ItemStack(instance.getBukkitEnums().getMaterial("WHITE_STAINED_GLASS_PANE").getType(), 1, (short) type);
|
||||
}
|
||||
|
||||
ItemMeta glassMeta = glass.getItemMeta();
|
||||
glassMeta.setDisplayName("§l");
|
||||
glass.setItemMeta(glassMeta);
|
||||
return glass;
|
||||
}
|
||||
|
||||
public static ItemStack getBackgroundGlass(boolean type) {
|
||||
if (type) {
|
||||
return getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 2"));
|
||||
}
|
||||
|
||||
return getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 3"));
|
||||
}
|
||||
|
||||
public static String serializeLocation(Location location) {
|
||||
if (location == null) {
|
||||
return "";
|
||||
}
|
||||
return "w:" + location.getWorld().getName() + "x:" + location.getBlockX() + "y:" + location.getBlockY() + "z:" + location.getBlockZ();
|
||||
}
|
||||
|
||||
public static Location deserializeLocation(String string) {
|
||||
if (string == null || string.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
string = string.replace("y:", ":").replace("z:", ":").replace("w:", "").replace("x:", ":").replace("/", ".");
|
||||
String[] args = string.split(":");
|
||||
World world = Bukkit.getWorld(args[0]);
|
||||
int x = Integer.parseInt(args[1]);
|
||||
int y = Integer.parseInt(args[2]);
|
||||
int z = Integer.parseInt(args[3]);
|
||||
return new Location(world, x, y, z, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
public static ItemStack getGlass() {
|
||||
return getGlass(instance.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), instance.getConfig().getInt("Interfaces.Glass Type 1"));
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class MySQLDatabase {
|
||||
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
private Connection connection;
|
||||
|
||||
public MySQLDatabase(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
String url = "jdbc:mysql://" + instance.getConfig().getString("Database.IP") + ":" + instance.getConfig().getString("Database.Port") + "/" + instance.getConfig().getString("Database.Database Name") + "?autoReconnect=true&useSSL=false";
|
||||
this.connection = DriverManager.getConnection(url, instance.getConfig().getString("Database.Username"), instance.getConfig().getString("Database.Password"));
|
||||
|
||||
//ToDo: This is sloppy
|
||||
connection.createStatement().execute(
|
||||
"CREATE TABLE IF NOT EXISTS `" + instance.getConfig().getString("Database.Prefix") + "charged` (\n" +
|
||||
"\t`location` TEXT NULL,\n" +
|
||||
"\t`level` INT NULL,\n" +
|
||||
"\t`uses` INT NULL,\n" +
|
||||
"\t`tolevel` INT NULL,\n" +
|
||||
"\t`nickname` TEXT NULL,\n" +
|
||||
"\t`accesslist` TEXT NULL,\n" +
|
||||
"\t`placedby` TEXT NULL\n" +
|
||||
")");
|
||||
|
||||
connection.createStatement().execute("CREATE TABLE IF NOT EXISTS `" + instance.getConfig().getString("Database.Prefix") + "boosts` (\n" +
|
||||
"\t`endtime` TEXT NULL,\n" +
|
||||
"\t`amount` INT NULL,\n" +
|
||||
"\t`uuid` TEXT NULL\n" +
|
||||
")");
|
||||
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
instance.getLogger().severe("Database connection failed.");
|
||||
}
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils;
|
||||
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class NMSUtil {
|
||||
|
||||
public static String getVersion() {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
||||
public static int getVersionNumber() {
|
||||
String name = getVersion().substring(3);
|
||||
return Integer.valueOf(name.substring(0, name.length() - 4));
|
||||
}
|
||||
|
||||
public static int getVersionReleaseNumber() {
|
||||
String NMSVersion = getVersion();
|
||||
return Integer.valueOf(NMSVersion.substring(NMSVersion.length() - 2).replace(".", ""));
|
||||
}
|
||||
|
||||
public static Class<?> getNMSClass(String className) {
|
||||
try {
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
return Class.forName(fullName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getCraftClass(String className) {
|
||||
try {
|
||||
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||
return Class.forName(fullName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Field getField(Class<?> clazz, String name, boolean declared) {
|
||||
try {
|
||||
Field field;
|
||||
|
||||
if (declared) {
|
||||
field = clazz.getDeclaredField(name);
|
||||
} else {
|
||||
field = clazz.getField(name);
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getFieldObject(Object object, Field field) {
|
||||
try {
|
||||
return field.get(object);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setField(Object object, String fieldName, Object fieldValue, boolean declared) {
|
||||
try {
|
||||
Field field;
|
||||
|
||||
if (declared) {
|
||||
field = object.getClass().getDeclaredField(fieldName);
|
||||
} else {
|
||||
field = object.getClass().getField(fieldName);
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
field.set(object, fieldValue);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPacket(Player player, Object packet) {
|
||||
try {
|
||||
Object handle = player.getClass().getMethod("getHandle").invoke(player);
|
||||
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
|
||||
playerConnection.getClass().getMethod("sendPacket", getNMSClass("Packet")).invoke(playerConnection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,109 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
private static final NavigableMap<Long, String> suffixes = new TreeMap<>();
|
||||
private static EpicFurnaces instance;
|
||||
|
||||
static {
|
||||
suffixes.put(1_000L, "k");
|
||||
suffixes.put(1_000_000L, "M");
|
||||
suffixes.put(1_000_000_000L, "B");
|
||||
suffixes.put(1_000_000_000_000L, "T");
|
||||
suffixes.put(1_000_000_000_000_000L, "P");
|
||||
suffixes.put(1_000_000_000_000_000_000L, "E");
|
||||
}
|
||||
|
||||
public static void init(EpicFurnaces main) {
|
||||
instance = main;
|
||||
}
|
||||
|
||||
public static String msToString(Long milli) {
|
||||
milli -= 24 * 60 * 60 * 1000;
|
||||
Date date = new Date(milli);
|
||||
boolean days = MILLISECONDS.toDays(milli) != 0;
|
||||
boolean hours = MILLISECONDS.toHours(milli) != 0;
|
||||
boolean minutes = MILLISECONDS.toMinutes(milli) != 0;
|
||||
|
||||
DateFormat formatter = new SimpleDateFormat((days ? "D 'Days' " : "") + (hours ? "HH 'hours' " : "") + (minutes ? "mm 'minutes'" : "") + " ss's' ");
|
||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
return formatter.format(date);
|
||||
}
|
||||
|
||||
public static String cleanString(String string) {
|
||||
string = string.replaceAll("_", " ");
|
||||
|
||||
if (string.split(" ").length == 2) {
|
||||
string = ChatColor.stripColor(string.substring(0, 1).toUpperCase() + string.toLowerCase().substring(1));
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String formatName(int level, int uses, boolean full) {
|
||||
String name = instance.getLocale().getMessage("general.nametag.nameformat", level);
|
||||
String info = "";
|
||||
|
||||
if (full) {
|
||||
info += encode(level + ":" + uses + ":");
|
||||
}
|
||||
|
||||
return info + formatText(name);
|
||||
}
|
||||
|
||||
public static String formatText(String string) {
|
||||
return string != null && !string.equals("") ? formatText(string, false) : "";
|
||||
}
|
||||
|
||||
public static String formatText(String string, boolean cap) {
|
||||
if (string != null && !string.equals("")) {
|
||||
if (cap) {
|
||||
string = string.substring(0, 1).toUpperCase() + string.substring(1);
|
||||
}
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static String encode(String toEncode) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (char c : toEncode.toCharArray()) {
|
||||
builder.append(ChatColor.COLOR_CHAR).append(c);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private static int decode(String toDecode) {
|
||||
String decoded = toDecode.replaceAll(String.valueOf(ChatColor.COLOR_CHAR), "");
|
||||
return Integer.parseInt(decoded);
|
||||
}
|
||||
|
||||
public static String formatEconomy(long value) {
|
||||
//Long.MIN_VALUE == -Long.MIN_VALUE so we need an adjustment here
|
||||
if (value == Long.MIN_VALUE) return formatEconomy(Long.MIN_VALUE + 1);
|
||||
if (value < 0) return "-" + formatEconomy(-value);
|
||||
if (value < 1000) return Long.toString(value); //deal with easy case
|
||||
|
||||
Map.Entry<Long, String> e = suffixes.floorEntry(value);
|
||||
Long divideBy = e.getKey();
|
||||
String suffix = e.getValue();
|
||||
|
||||
long truncated = value / (divideBy / 10); //the number part of the output times 10
|
||||
boolean hasDecimal = truncated < 100 && (truncated / 10d) != (truncated / 10);
|
||||
return hasDecimal ? (truncated / 10d) + suffix : (truncated / 10) + suffix;
|
||||
}
|
||||
|
||||
}
|
@ -1,288 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils.gui;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.utils.NMSUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AbstractAnvilGUI {
|
||||
private static Class<?> BlockPositionClass;
|
||||
private static Class<?> PacketPlayOutOpenWindowClass;
|
||||
private static Class<?> IChatBaseComponentClass;
|
||||
private static Class<?> ICraftingClass;
|
||||
private static Class<?> ContainerAnvilClass;
|
||||
private static Class<?> ChatMessageClass;
|
||||
private static Class<?> EntityHumanClass;
|
||||
private static Class<?> ContainerClass;
|
||||
private static Class<?> ContainerAccessClass;
|
||||
private static Class<?> WorldClass;
|
||||
private static Class<?> PlayerInventoryClass;
|
||||
private static Class<?> ContainersClass;
|
||||
private static Class<?> CraftPlayerClass;
|
||||
|
||||
private Player player;
|
||||
private Map<AnvilSlot, ItemStack> items = new HashMap<>();
|
||||
private OnClose onClose = null;
|
||||
private Inventory inv;
|
||||
private Listener listener;
|
||||
|
||||
static {
|
||||
BlockPositionClass = NMSUtil.getNMSClass("BlockPosition");
|
||||
PacketPlayOutOpenWindowClass = NMSUtil.getNMSClass("PacketPlayOutOpenWindow");
|
||||
IChatBaseComponentClass = NMSUtil.getNMSClass("IChatBaseComponent");
|
||||
ICraftingClass = NMSUtil.getNMSClass("ICrafting");
|
||||
ContainerAnvilClass = NMSUtil.getNMSClass("ContainerAnvil");
|
||||
EntityHumanClass = NMSUtil.getNMSClass("EntityHuman");
|
||||
ChatMessageClass = NMSUtil.getNMSClass("ChatMessage");
|
||||
ContainerClass = NMSUtil.getNMSClass("Container");
|
||||
WorldClass = NMSUtil.getNMSClass("World");
|
||||
PlayerInventoryClass = NMSUtil.getNMSClass("PlayerInventory");
|
||||
CraftPlayerClass = NMSUtil.getCraftClass("entity.CraftPlayer");
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
ContainerAccessClass = NMSUtil.getNMSClass("ContainerAccess");
|
||||
ContainersClass = NMSUtil.getNMSClass("Containers");
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractAnvilGUI(EpicFurnaces instance, Player player, AnvilClickEventHandler handler) {
|
||||
this.player = player;
|
||||
|
||||
this.listener = new Listener() {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player && event.getInventory().equals(AbstractAnvilGUI.this.inv)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
ItemStack item = event.getCurrentItem();
|
||||
int slot = event.getRawSlot();
|
||||
|
||||
if (item == null || item.getType().equals(Material.AIR) || slot != 2)
|
||||
return;
|
||||
|
||||
String name = "";
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null && meta.hasDisplayName())
|
||||
name = meta.getDisplayName();
|
||||
|
||||
AnvilClickEvent clickEvent = new AnvilClickEvent(AnvilSlot.bySlot(slot), name);
|
||||
handler.onAnvilClick(clickEvent);
|
||||
|
||||
if (clickEvent.getWillClose())
|
||||
event.getWhoClicked().closeInventory();
|
||||
|
||||
if (clickEvent.getWillDestroy())
|
||||
AbstractAnvilGUI.this.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
if (event.getPlayer() instanceof Player && AbstractAnvilGUI.this.inv.equals(event.getInventory())) {
|
||||
Inventory inv = event.getInventory();
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
inv.clear();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (AbstractAnvilGUI.this.onClose != null)
|
||||
AbstractAnvilGUI.this.onClose.onClose(player, inv);
|
||||
AbstractAnvilGUI.this.destroy();
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (event.getPlayer().equals(AbstractAnvilGUI.this.player)) {
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
AbstractAnvilGUI.this.destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this.listener, instance);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public void setSlot(AnvilSlot slot, ItemStack item) {
|
||||
this.items.put(slot, item);
|
||||
}
|
||||
|
||||
public void open() {
|
||||
this.player.setLevel(this.player.getLevel() + 1);
|
||||
|
||||
try {
|
||||
Object craftPlayer = CraftPlayerClass.cast(this.player);
|
||||
Method getHandleMethod = CraftPlayerClass.getMethod("getHandle");
|
||||
Object entityPlayer = getHandleMethod.invoke(craftPlayer);
|
||||
Object playerInventory = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "inventory", false));
|
||||
Object world = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "world", false));
|
||||
Object blockPosition = BlockPositionClass.getConstructor(int.class, int.class, int.class).newInstance(0, 0, 0);
|
||||
|
||||
Object container;
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
container = ContainerAnvilClass
|
||||
.getConstructor(int.class, PlayerInventoryClass, ContainerAccessClass)
|
||||
.newInstance(7, playerInventory, ContainerAccessClass.getMethod("at", WorldClass, BlockPositionClass).invoke(null, world, blockPosition));
|
||||
} else {
|
||||
container = ContainerAnvilClass
|
||||
.getConstructor(PlayerInventoryClass, WorldClass, BlockPositionClass, EntityHumanClass)
|
||||
.newInstance(playerInventory, world, blockPosition, entityPlayer);
|
||||
}
|
||||
|
||||
NMSUtil.getField(ContainerClass, "checkReachable", true).set(container, false);
|
||||
|
||||
Method getBukkitViewMethod = container.getClass().getMethod("getBukkitView");
|
||||
Object bukkitView = getBukkitViewMethod.invoke(container);
|
||||
Method getTopInventoryMethod = bukkitView.getClass().getMethod("getTopInventory");
|
||||
this.inv = (Inventory) getTopInventoryMethod.invoke(bukkitView);
|
||||
|
||||
for (AnvilSlot slot : this.items.keySet()) {
|
||||
this.inv.setItem(slot.getSlot(), this.items.get(slot));
|
||||
}
|
||||
|
||||
Method nextContainerCounterMethod = entityPlayer.getClass().getMethod("nextContainerCounter");
|
||||
int c = (int) nextContainerCounterMethod.invoke(entityPlayer);
|
||||
|
||||
Constructor<?> chatMessageConstructor = ChatMessageClass.getConstructor(String.class, Object[].class);
|
||||
Object inventoryTitle = chatMessageConstructor.newInstance("Repairing", new Object[]{});
|
||||
|
||||
Object packet;
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
packet = PacketPlayOutOpenWindowClass
|
||||
.getConstructor(int.class, ContainersClass, IChatBaseComponentClass)
|
||||
.newInstance(c, ContainersClass.getField("ANVIL").get(null), inventoryTitle);
|
||||
} else {
|
||||
packet = PacketPlayOutOpenWindowClass
|
||||
.getConstructor(int.class, String.class, IChatBaseComponentClass, int.class)
|
||||
.newInstance(c, "minecraft:anvil", inventoryTitle, 0);
|
||||
}
|
||||
|
||||
NMSUtil.sendPacket(this.player, packet);
|
||||
|
||||
Field activeContainerField = NMSUtil.getField(EntityHumanClass, "activeContainer", true);
|
||||
|
||||
if (activeContainerField != null) {
|
||||
activeContainerField.set(entityPlayer, container);
|
||||
NMSUtil.getField(ContainerClass, "windowId", true).set(activeContainerField.get(entityPlayer), c);
|
||||
Method addSlotListenerMethod = activeContainerField.get(entityPlayer).getClass().getMethod("addSlotListener", ICraftingClass);
|
||||
addSlotListenerMethod.invoke(activeContainerField.get(entityPlayer), entityPlayer);
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
ContainerClass.getMethod("setTitle", IChatBaseComponentClass).invoke(container, inventoryTitle);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
this.player = null;
|
||||
this.items = null;
|
||||
|
||||
HandlerList.unregisterAll(this.listener);
|
||||
|
||||
this.listener = null;
|
||||
}
|
||||
|
||||
private OnClose getOnClose() {
|
||||
return this.onClose;
|
||||
}
|
||||
|
||||
public void setOnClose(OnClose onClose) {
|
||||
this.onClose = onClose;
|
||||
}
|
||||
|
||||
public enum AnvilSlot {
|
||||
INPUT_LEFT(0),
|
||||
INPUT_RIGHT(1),
|
||||
OUTPUT(2);
|
||||
|
||||
private int slot;
|
||||
|
||||
AnvilSlot(int slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public static AnvilSlot bySlot(int slot) {
|
||||
for (AnvilSlot anvilSlot : values()) {
|
||||
if (anvilSlot.getSlot() == slot) {
|
||||
return anvilSlot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface AnvilClickEventHandler {
|
||||
void onAnvilClick(AnvilClickEvent event);
|
||||
}
|
||||
|
||||
public class AnvilClickEvent {
|
||||
private AnvilSlot slot;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean close = true;
|
||||
private boolean destroy = true;
|
||||
|
||||
public AnvilClickEvent(AnvilSlot slot, String name) {
|
||||
this.slot = slot;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public AnvilSlot getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean getWillClose() {
|
||||
return this.close;
|
||||
}
|
||||
|
||||
public void setWillClose(boolean close) {
|
||||
this.close = close;
|
||||
}
|
||||
|
||||
public boolean getWillDestroy() {
|
||||
return this.destroy;
|
||||
}
|
||||
|
||||
public void setWillDestroy(boolean destroy) {
|
||||
this.destroy = destroy;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,522 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils.gui;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A fast API to easily create advanced GUI.
|
||||
* The project is on <a href="https://github.com/MrMicky-FR/FastInv">GitHub</a>
|
||||
*
|
||||
* @author MrMicky
|
||||
* @version 2.0.3 - Now supports async operations
|
||||
*/
|
||||
public class FastInv implements InventoryHolder {
|
||||
|
||||
private static Plugin plugin = null;
|
||||
private boolean cancelTasksOnClose = true;
|
||||
private Set<FastInvCloseListener> closeListeners = new HashSet<>();
|
||||
private Set<FastInvClickListener> clickListeners = new HashSet<>();
|
||||
private Map<Integer, FastInvClickListener> itemListeners = new HashMap<>();
|
||||
private Set<BukkitTask> tasks = new HashSet<>();
|
||||
private Inventory inventory;
|
||||
|
||||
/**
|
||||
* Create a new FastInv with a custom size.
|
||||
*
|
||||
* @param size The size of the menus.
|
||||
*/
|
||||
public FastInv(int size) {
|
||||
this(size, InventoryType.CHEST.getDefaultTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new FastInv with a custom size and title.
|
||||
*
|
||||
* @param size The size of the menus.
|
||||
* @param title The title (name) of the menus.
|
||||
*/
|
||||
public FastInv(int size, String title) {
|
||||
this(size, InventoryType.CHEST, title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new FastInv with a custom type.
|
||||
*
|
||||
* @param type The type of the menus.
|
||||
*/
|
||||
public FastInv(InventoryType type) {
|
||||
this(type, type.getDefaultTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new FastInv with a custom type and title.
|
||||
*
|
||||
* @param type The type of the menus.
|
||||
* @param title The title of the menus.
|
||||
* @throws IllegalStateException if FastInv is not init with FastInv.init(Plugin plugin)
|
||||
*/
|
||||
public FastInv(InventoryType type, String title) {
|
||||
this(0, type, title);
|
||||
}
|
||||
|
||||
private FastInv(int size, InventoryType type, String title) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalStateException("FastInv is not initialised");
|
||||
}
|
||||
|
||||
runSync(() -> {
|
||||
if (type == InventoryType.CHEST && size > 0) {
|
||||
inventory = Bukkit.createInventory(this, size, title);
|
||||
} else {
|
||||
inventory = Bukkit.createInventory(this, type, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register your FastInv instance.
|
||||
*
|
||||
* @param plugin The plugin that uses FastInv.
|
||||
*/
|
||||
public static void init(Plugin plugin) {
|
||||
if (FastInv.plugin == null) {
|
||||
FastInv.plugin = plugin;
|
||||
Bukkit.getPluginManager().registerEvents(getListener(), plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus.
|
||||
*
|
||||
* @param item The item to add
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(ItemStack item) {
|
||||
return addItem(item, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus with a {@link FastInvClickListener} to handle clicks.
|
||||
*
|
||||
* @param item The item to add.
|
||||
* @param listener The {@link FastInvClickListener} for the item.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(ItemStack item, FastInvClickListener listener) {
|
||||
runSync(() -> {
|
||||
int slot = inventory.firstEmpty();
|
||||
if (slot >= 0) {
|
||||
addItem(slot, item, listener);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on a specific slot.
|
||||
*
|
||||
* @param slot The slot of the item.
|
||||
* @param item The item to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int slot, ItemStack item) {
|
||||
return addItem(slot, item, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on specific slot with a {@link FastInvClickListener} to handle clicks.
|
||||
*
|
||||
* @param slot The slot of the item.
|
||||
* @param item The item to add.
|
||||
* @param listener The FastInvClickListener for the item.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int slot, ItemStack item, FastInvClickListener listener) {
|
||||
runSync(() -> {
|
||||
inventory.setItem(slot, item);
|
||||
|
||||
if (listener != null) {
|
||||
itemListeners.put(slot, listener);
|
||||
} else {
|
||||
itemListeners.remove(slot);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on a range of slots.
|
||||
*
|
||||
* @param slotFrom Starting slot to put the item in.
|
||||
* @param slotTo Ending slot to put the item in.
|
||||
* @param item The item to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int slotFrom, int slotTo, ItemStack item) {
|
||||
return addItem(slotFrom, slotTo, item, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on a range of slots with a {@link FastInvClickListener} to handle clicks.
|
||||
*
|
||||
* @param slotFrom Starting slot to put the item in.
|
||||
* @param slotTo Ending slot to put the item in.
|
||||
* @param item The item to add.
|
||||
* @param listener The FastInvClickListener for the item.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int slotFrom, int slotTo, ItemStack item, FastInvClickListener listener) {
|
||||
for (int i = slotFrom; i <= slotTo; i++) {
|
||||
addItem(i, item, listener);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on multiple slots.
|
||||
*
|
||||
* @param slots The slot of the item.
|
||||
* @param item The item to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int[] slots, ItemStack item) {
|
||||
return addItem(slots, item, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on the edges.
|
||||
*
|
||||
* @param item The item to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv edge(ItemStack item) {
|
||||
int height = inventory.getSize() / 9;
|
||||
|
||||
addItem(0, 9, item);
|
||||
addItem(inventory.getSize() - 9, inventory.getSize() - 1, item);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
addItem(i * 9, item);
|
||||
addItem(i * 9 + 8, item);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on multiples slots with a {@link FastInvClickListener} to handle click.
|
||||
*
|
||||
* @param slots The slots to place the item.
|
||||
* @param item The item to add.
|
||||
* @param listener The FastInvClickListener for the item.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int[] slots, ItemStack item, FastInvClickListener listener) {
|
||||
for (int slot : slots) {
|
||||
addItem(slot, item, listener);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public FastInv fill(ItemStack itemStack) {
|
||||
runSync(() -> {
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
if (inventory.getItem(i) == null) {
|
||||
addItem(i, itemStack);
|
||||
}
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a {@link FastInvCloseListener} to listen on menus close.
|
||||
*
|
||||
* @param listener The {@link FastInvCloseListener} to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv onClose(FastInvCloseListener listener) {
|
||||
closeListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a {@link FastInvClickListener} to listen on menus click.
|
||||
*
|
||||
* @param listener The {@link FastInvClickListener} to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv onClick(FastInvClickListener listener) {
|
||||
clickListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a task to run.
|
||||
*
|
||||
* @param period Delay between each run.
|
||||
* @param runnable The {@link Runnable} task to run.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv onUpdate(long period, Runnable runnable) {
|
||||
return onUpdate(period, period, runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a task to run with a delay before starting.
|
||||
*
|
||||
* @param delay Ticks to wait before starting the task.
|
||||
* @param period Delay between each run.
|
||||
* @param runnable The {@link Runnable} task to run.
|
||||
* @return This FastInv instance, for chaining
|
||||
*/
|
||||
public FastInv onUpdate(long delay, long period, Runnable runnable) {
|
||||
tasks.add(Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the menus to a player.
|
||||
*
|
||||
* @param player The player to open the menu.
|
||||
*/
|
||||
public void open(Player player) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(inventory));
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the menus to players.
|
||||
*
|
||||
* @param players The players to open the menu.
|
||||
*/
|
||||
public void open(Player... players) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
for (Player p : players) {
|
||||
p.openInventory(inventory);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel all tasks.
|
||||
*/
|
||||
public void cancelTasks() {
|
||||
tasks.forEach(BukkitTask::cancel);
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task on the server primary thread.
|
||||
*
|
||||
* @param runnable The runnable to run on the main thread
|
||||
*/
|
||||
public void runSync(Runnable runnable) {
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
runnable.run();
|
||||
} else {
|
||||
Bukkit.getScheduler().runTask(plugin, runnable);
|
||||
}
|
||||
}
|
||||
|
||||
public interface FastInvClickListener {
|
||||
void onClick(FastInvClickEvent event);
|
||||
}
|
||||
|
||||
public interface FastInvCloseListener {
|
||||
void onClose(FastInvCloseEvent event);
|
||||
}
|
||||
|
||||
public static abstract class FastInvEvent {
|
||||
|
||||
private Player player;
|
||||
private FastInv inventory;
|
||||
private boolean cancelled;
|
||||
|
||||
FastInvEvent(Player player, FastInv inventory, boolean cancelled) {
|
||||
this.player = player;
|
||||
this.inventory = inventory;
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the FastInv menus.
|
||||
*
|
||||
* @return This associated FastInv instance.
|
||||
*/
|
||||
public FastInv getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link Player} who clicked.
|
||||
*
|
||||
* @return the player who clicked.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the event is cancelled or not.
|
||||
*
|
||||
* @return Whether the event was cancelled.
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the event will be cancel or not.
|
||||
*
|
||||
* @param cancel Whether the event should be cancelled.
|
||||
*/
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FastInvClickEvent extends FastInvEvent {
|
||||
|
||||
private int slot;
|
||||
private ItemStack item;
|
||||
private InventoryAction action;
|
||||
private ClickType clickType;
|
||||
|
||||
private FastInvClickEvent(Player player, FastInv inventory, int slot, ItemStack item,
|
||||
boolean cancelled, InventoryAction action, ClickType clickType) {
|
||||
super(player, inventory, cancelled);
|
||||
this.slot = slot;
|
||||
this.item = item;
|
||||
this.action = action;
|
||||
this.clickType = clickType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The action of the event
|
||||
*/
|
||||
public InventoryAction getAction() {
|
||||
return this.action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The click type
|
||||
*/
|
||||
public ClickType getClickType() {
|
||||
return this.clickType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the clicked {@link ItemStack}
|
||||
*
|
||||
* @return The clicked item
|
||||
*/
|
||||
public ItemStack getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of the clicked slot
|
||||
*
|
||||
* @return The slot number
|
||||
*/
|
||||
public int getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FastInvCloseEvent extends FastInvEvent {
|
||||
private FastInvCloseEvent(Player player, FastInv inventory, boolean cancelled) {
|
||||
super(player, inventory, cancelled);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Bukkit menus associated with this FastInv instance.
|
||||
*
|
||||
* @return The Bukkit {@link Inventory}.
|
||||
*/
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
private static Listener getListener() {
|
||||
return new Listener() {
|
||||
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent event) {
|
||||
if (event.getInventory().getHolder() instanceof FastInv && event.getWhoClicked() instanceof Player) {
|
||||
int slot = event.getRawSlot();
|
||||
FastInv inv = (FastInv) event.getInventory().getHolder();
|
||||
|
||||
FastInvClickEvent clickEvent = new FastInvClickEvent((Player) event.getWhoClicked(), inv, slot,
|
||||
event.getCurrentItem(), true, event.getAction(), event.getClick());
|
||||
|
||||
if (inv.itemListeners.containsKey(slot)) {
|
||||
inv.itemListeners.get(slot).onClick(clickEvent);
|
||||
}
|
||||
|
||||
inv.clickListeners.forEach(listener -> listener.onClick(clickEvent));
|
||||
|
||||
if (clickEvent.isCancelled()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClose(InventoryCloseEvent event) {
|
||||
if (event.getInventory().getHolder() instanceof FastInv && event.getPlayer() instanceof Player) {
|
||||
Player player = (Player) event.getPlayer();
|
||||
FastInv inv = (FastInv) event.getInventory().getHolder();
|
||||
|
||||
FastInvCloseEvent closeEvent = new FastInvCloseEvent(player, inv, false);
|
||||
inv.closeListeners.forEach(listener -> listener.onClose(closeEvent));
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
// Tiny delay to prevent errors.
|
||||
if (closeEvent.isCancelled() && player.isOnline()) {
|
||||
player.openInventory(inv.getInventory());
|
||||
} else if (inv.getInventory().getViewers().isEmpty() && inv.cancelTasksOnClose) {
|
||||
inv.cancelTasks();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisable(PluginDisableEvent event) {
|
||||
if (event.getPlugin().equals(plugin)) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (player.getOpenInventory().getTopInventory().getHolder() instanceof FastInv) {
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the tasks will be cancel on menus close.
|
||||
*
|
||||
* @param cancelTasksOnClose Set if the tasks will be cancel
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv setCancelTasksOnClose(boolean cancelTasksOnClose) {
|
||||
this.cancelTasksOnClose = cancelTasksOnClose;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,294 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils.gui;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A complete {@link ItemStack} builder for FastInv (only works on 1.8+).
|
||||
* <p>
|
||||
* The project is on <a href="https://github.com/MrMicky-FR/FastInv">GitHub</a>
|
||||
*
|
||||
* @author MrMicky
|
||||
*/
|
||||
public class ItemBuilder {
|
||||
|
||||
private final ItemStack item;
|
||||
private ItemMeta meta;
|
||||
|
||||
/*
|
||||
* Constructors:
|
||||
*/
|
||||
public ItemBuilder(Material material) {
|
||||
this(new ItemStack(material));
|
||||
}
|
||||
|
||||
public ItemBuilder(Material material, int amount) {
|
||||
this(new ItemStack(material, amount));
|
||||
}
|
||||
|
||||
public ItemBuilder(Material material, byte data) {
|
||||
this(new ItemStack(material, 1, data));
|
||||
}
|
||||
|
||||
public ItemBuilder(Material material, int amount, byte data) {
|
||||
this(new ItemStack(material, amount, data));
|
||||
}
|
||||
|
||||
public ItemBuilder(ItemStack item) {
|
||||
this.item = item;
|
||||
this.meta = item.getItemMeta();
|
||||
}
|
||||
|
||||
/*
|
||||
* Meta:
|
||||
*/
|
||||
public boolean hasMeta() {
|
||||
return getMeta() != null;
|
||||
}
|
||||
|
||||
public ItemMeta getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public ItemBuilder meta(ItemMeta meta) {
|
||||
this.meta = meta;
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Name:
|
||||
*/
|
||||
public boolean hasName() {
|
||||
return meta.hasDisplayName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return meta.getDisplayName();
|
||||
}
|
||||
|
||||
public ItemBuilder name(String name) {
|
||||
meta.setDisplayName(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lore:
|
||||
*/
|
||||
public boolean hasLore() {
|
||||
return meta.hasLore();
|
||||
}
|
||||
|
||||
public List<String> getLore() {
|
||||
return meta.getLore();
|
||||
}
|
||||
|
||||
public ItemBuilder lore(String... lore) {
|
||||
return lore(Arrays.asList(lore));
|
||||
}
|
||||
|
||||
public ItemBuilder lore(List<String> lore) {
|
||||
meta.setLore(lore);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addLore(List<String> lore) {
|
||||
if (!meta.hasLore()) {
|
||||
meta.setLore(lore);
|
||||
return this;
|
||||
}
|
||||
|
||||
List<String> toAdd = meta.getLore();
|
||||
toAdd.addAll(lore);
|
||||
meta.setLore(toAdd);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addLore(String... lore) {
|
||||
return addLore(Arrays.asList(lore));
|
||||
}
|
||||
|
||||
/*
|
||||
* Enchantments:
|
||||
*/
|
||||
public boolean hasEnchants() {
|
||||
return meta.hasEnchants();
|
||||
}
|
||||
|
||||
public boolean hasEnchant(Enchantment enchantment) {
|
||||
return meta.hasEnchant(enchantment);
|
||||
}
|
||||
|
||||
public boolean hasConflictingEnchant(Enchantment enchantment) {
|
||||
return meta.hasConflictingEnchant(enchantment);
|
||||
}
|
||||
|
||||
public Map<Enchantment, Integer> getEnchants() {
|
||||
return meta.getEnchants();
|
||||
}
|
||||
|
||||
public ItemBuilder enchant(Enchantment enchantment, int level) {
|
||||
meta.addEnchant(enchantment, level, true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder removeEnchant(Enchantment enchantment) {
|
||||
meta.removeEnchant(enchantment);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flags:
|
||||
*/
|
||||
public boolean hasFlag(ItemFlag flag) {
|
||||
return meta.hasItemFlag(flag);
|
||||
}
|
||||
|
||||
public Set<ItemFlag> getFlags() {
|
||||
return meta.getItemFlags();
|
||||
}
|
||||
|
||||
public ItemBuilder addFlags(ItemFlag... flags) {
|
||||
meta.addItemFlags(flags);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder removeFlags(ItemFlag... flags) {
|
||||
meta.removeItemFlags(flags);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unbreakability:
|
||||
*/
|
||||
public boolean isUnbreakable() {
|
||||
return meta.spigot().isUnbreakable();
|
||||
}
|
||||
|
||||
public ItemBuilder unbreakable() {
|
||||
return unbreakable(true);
|
||||
}
|
||||
|
||||
public ItemBuilder unbreakable(boolean unbreakable) {
|
||||
meta.spigot().setUnbreakable(unbreakable);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* ==========================
|
||||
*
|
||||
* SPECIFIC META
|
||||
*
|
||||
* ==========================
|
||||
*/
|
||||
|
||||
/*
|
||||
* Banners:
|
||||
*/
|
||||
public DyeColor getBannerBaseColor() {
|
||||
return ((BannerMeta) meta).getBaseColor();
|
||||
}
|
||||
|
||||
public List<Pattern> getBannerPatterns() {
|
||||
return ((BannerMeta) meta).getPatterns();
|
||||
}
|
||||
|
||||
public ItemBuilder bannerBaseColor(DyeColor color) {
|
||||
((BannerMeta) meta).setBaseColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder bannerPatterns(List<Pattern> patterns) {
|
||||
((BannerMeta) meta).setPatterns(patterns);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder bannerPattern(int i, Pattern pattern) {
|
||||
((BannerMeta) meta).setPattern(i, pattern);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addBannerPatterns(Pattern pattern) {
|
||||
((BannerMeta) meta).addPattern(pattern);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder removeBannerPattern(int i) {
|
||||
((BannerMeta) meta).removePattern(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Leather armor:
|
||||
*/
|
||||
public Color getLeatherArmorColor() {
|
||||
return ((LeatherArmorMeta) meta).getColor();
|
||||
}
|
||||
|
||||
public ItemBuilder leatherArmorColor(Color color) {
|
||||
((LeatherArmorMeta) meta).setColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skulls:
|
||||
*/
|
||||
public boolean hasSkullOwner() {
|
||||
return ((SkullMeta) meta).hasOwner();
|
||||
}
|
||||
|
||||
public String getSkullOwner() {
|
||||
return ((SkullMeta) meta).getOwner();
|
||||
}
|
||||
|
||||
public ItemBuilder skullOwner(String owner) {
|
||||
item.setDurability((short) 3);
|
||||
((SkullMeta) meta).setOwner(owner);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder durability(int durability) {
|
||||
item.setDurability((short) durability);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Potions:
|
||||
*/
|
||||
public boolean hasPotionEffect(PotionEffectType type) {
|
||||
return ((PotionMeta) meta).hasCustomEffect(type);
|
||||
}
|
||||
|
||||
public boolean hasPotionEffects() {
|
||||
return ((PotionMeta) meta).hasCustomEffects();
|
||||
}
|
||||
|
||||
public List<PotionEffect> getPotionEffects() {
|
||||
return ((PotionMeta) meta).getCustomEffects();
|
||||
}
|
||||
|
||||
public ItemBuilder addPotionEffect(PotionEffect effect, boolean overwrite) {
|
||||
((PotionMeta) meta).addCustomEffect(effect, overwrite);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build the ItemStack.
|
||||
*/
|
||||
public ItemStack build() {
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public interface OnClose {
|
||||
|
||||
void onClose(Player player, Inventory inventory);
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.songoda.epicfurnaces.utils.updateModules;
|
||||
|
||||
import com.songoda.epicfurnaces.Locale;
|
||||
import com.songoda.update.Module;
|
||||
import com.songoda.update.Plugin;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
public class LocaleModule implements Module {
|
||||
|
||||
@Override
|
||||
public void run(Plugin plugin) {
|
||||
JSONObject json = plugin.getJson();
|
||||
try {
|
||||
JSONArray files = (JSONArray) json.get("neededFiles");
|
||||
for (Object o : files) {
|
||||
JSONObject file = (JSONObject) o;
|
||||
|
||||
if (file.get("type").equals("locale")) {
|
||||
InputStream in = new URL((String) file.get("link")).openStream();
|
||||
Locale.saveDefaultLocale(in, (String) file.get("name"));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
Recipes:
|
||||
DIAMOND_SWORD:
|
||||
result: DIAMOND
|
||||
amount: 2
|
||||
DIAMOND_PICKAXE:
|
||||
result: DIAMOND
|
||||
amount: 3
|
||||
DIAMOND_AXE:
|
||||
result: DIAMOND
|
||||
amount: 3
|
||||
DIAMOND_SPADE:
|
||||
result: DIAMOND
|
||||
amount: 1
|
||||
DIAMOND_HOE:
|
||||
result: DIAMOND
|
||||
amount: 2
|
||||
DIAMOND_HELMET:
|
||||
result: DIAMOND
|
||||
amount: 5
|
||||
DIAMOND_CHESTPLATE:
|
||||
result: DIAMOND
|
||||
amount: 8
|
||||
DIAMOND_LEGGINGS:
|
||||
result: DIAMOND
|
||||
amount: 7
|
||||
DIAMOND_BOOTS:
|
||||
result: DIAMOND
|
||||
amount: 4
|
||||
IRON_SWORD:
|
||||
result: IRON_INGOT
|
||||
amount: 2
|
||||
IRON_PICKAXE:
|
||||
result: IRON_INGOT
|
||||
amount: 3
|
||||
IRON_AXE:
|
||||
result: IRON_INGOT
|
||||
amount: 3
|
||||
IRON_SPADE:
|
||||
result: IRON_INGOT
|
||||
amount: 1
|
||||
IRON_HOE:
|
||||
result: IRON_INGOT
|
||||
amount: 2
|
||||
IRON_HELMET:
|
||||
result: IRON_INGOT
|
||||
amount: 5
|
||||
IRON_CHESTPLATE:
|
||||
result: IRON_INGOT
|
||||
amount: 8
|
||||
IRON_LEGGINGS:
|
||||
result: IRON_INGOT
|
||||
amount: 7
|
||||
IRON_BOOTS:
|
||||
result: IRON_INGOT
|
||||
amount: 4
|
||||
GOLD_SWORD:
|
||||
result: GOLD_INGOT
|
||||
amount: 2
|
||||
GOLD_PICKAXE:
|
||||
result: GOLD_INGOT
|
||||
amount: 3
|
||||
GOLD_AXE:
|
||||
result: GOLD_INGOT
|
||||
amount: 3
|
||||
GOLD_SPADE:
|
||||
result: GOLD_INGOT
|
||||
amount: 1
|
||||
GOLD_HOE:
|
||||
result: GOLD_INGOT
|
||||
amount: 2
|
||||
GOLD_HELMET:
|
||||
result: GOLD_INGOT
|
||||
amount: 5
|
||||
GOLD_CHESTPLATE:
|
||||
result: GOLD_INGOT
|
||||
amount: 8
|
||||
GOLD_LEGGINGS:
|
||||
result: GOLD_INGOT
|
||||
amount: 7
|
||||
GOLD_BOOTS:
|
||||
result: GOLD_INGOT
|
||||
amount: 4
|
||||
CHAINMAIL_HELMET:
|
||||
result: IRON_INGOT
|
||||
amount: 3
|
||||
CHAINMAIL_CHESTPLATE:
|
||||
result: IRON_INGOT
|
||||
amount: 5
|
||||
CHAINMAIL_LEGGINGS:
|
||||
result: IRON_INGOT
|
||||
amount: 4
|
||||
CHAINMAIL_BOOTS:
|
||||
result: IRON_INGOT
|
||||
amount: 2
|
||||
LEATHER_HELMET:
|
||||
result: LEATHER
|
||||
amount: 5
|
||||
LEATHER_CHESTPLATE:
|
||||
result: LEATHER
|
||||
amount: 8
|
||||
LEATHER_LEGGINGS:
|
||||
result: LEATHER
|
||||
amount: 7
|
||||
LEATHER_BOOTS:
|
||||
result: LEATHER
|
||||
amount: 4
|
||||
STONE_SWORD:
|
||||
result: COBBLESTONE
|
||||
amount: 2
|
||||
STONE_PICKAXE:
|
||||
result: COBBLESTONE
|
||||
amount: 3
|
||||
STONE_AXE:
|
||||
result: COBBLESTONE
|
||||
amount: 3
|
||||
STONE_SPADE:
|
||||
result: COBBLESTONE
|
||||
amount: 1
|
||||
STONE_HOE:
|
||||
result: COBBLESTONE
|
||||
amount: 2
|
||||
WOOD_SWORD:
|
||||
result: COAL
|
||||
amount: 2
|
||||
WOOD_PICKAXE:
|
||||
result: COAL
|
||||
amount: 3
|
||||
WOOD_AXE:
|
||||
result: COAL
|
||||
amount: 3
|
||||
WOOD_SPADE:
|
||||
result: COAL
|
||||
amount: 1
|
||||
WOOD_HOE:
|
||||
result: COAL
|
||||
amount: 2
|
||||
BOW:
|
||||
result: COAL
|
||||
amount: 3
|
||||
FISHING_ROD:
|
||||
result: COAL
|
||||
amount: 3
|
||||
COMPASS:
|
||||
result: IRON_INGOT
|
||||
amount: 4
|
||||
WATCH:
|
||||
result: GOLD_INGOT
|
||||
amount: 4
|
||||
SHEARS:
|
||||
result: IRON_INGOT
|
||||
amount: 2
|
||||
BUCKET:
|
||||
result: IRON_INGOT
|
||||
amount: 3
|
||||
MINECART:
|
||||
result: IRON_INGOT
|
||||
amount: 5
|
||||
FLINT_AND_STEEL:
|
||||
result: IRON_INGOT
|
||||
amount: 1
|
@ -1,6 +0,0 @@
|
||||
settings:
|
||||
blacklist:
|
||||
- world2
|
||||
- world3
|
||||
- world4
|
||||
- world5
|
@ -1,80 +0,0 @@
|
||||
Main:
|
||||
Sounds Enabled: true
|
||||
Hologram in front: false
|
||||
Upgrade By Smelting Materials: true
|
||||
Upgrade With Economy: true
|
||||
Upgrade With XP: true
|
||||
Level Cost Multiplier: 50
|
||||
Remember Furnace Item Levels: true
|
||||
Furnaces Have Holograms: true
|
||||
Redstone Deactivates Furnaces: true
|
||||
Furnace Upgrade Cost: IRON_INGOT
|
||||
Use Custom Recipes: true
|
||||
No Rewards From Custom Recipes: true
|
||||
Upgrade Particle Type: SPELL_WITCH
|
||||
Access Furnaces Remotely: true
|
||||
Furnace Tick Speed: 10
|
||||
Auto Save Interval In Seconds: 15
|
||||
Overheat Particles: true
|
||||
Interfaces:
|
||||
Reward Icon: GOLDEN_APPLE
|
||||
Performance Icon: REDSTONE
|
||||
FuelShare Icon: COAL_BLOCK
|
||||
FuelDuration Icon: COAL
|
||||
Overheat Icon: FIRE_CHARGE
|
||||
Economy Icon: SUNFLOWER
|
||||
XP Icon: EXPERIENCE_BOTTLE
|
||||
Glass Type 1: 7
|
||||
Glass Type 2: 11
|
||||
Glass Type 3: 3
|
||||
Replace Glass Type 1 With Rainbow Glass: false
|
||||
Database:
|
||||
Activate Mysql Support: false
|
||||
IP: 127.0.0.1
|
||||
Port: 3306
|
||||
Database Name: EpicFurnaces
|
||||
Prefix: EF-
|
||||
Username: PUT_USERNAME_HERE
|
||||
Password: PUT_PASSWORD_HERE
|
||||
System:
|
||||
Language Mode: en_US
|
||||
Debugger Enabled: false
|
||||
settings:
|
||||
levels:
|
||||
Level-1:
|
||||
Performance: 10%
|
||||
Reward: 10%:1
|
||||
Cost-xp: 20
|
||||
Cost-eco: 5000
|
||||
Level-2:
|
||||
Performance: 25%
|
||||
Reward: 20%:1-2
|
||||
Cost-xp: 25
|
||||
Cost-eco: 7500
|
||||
Level-3:
|
||||
Performance: 40%
|
||||
Reward: 35%:2-3
|
||||
Fuel-duration: 10%
|
||||
Cost-xp: 30
|
||||
Cost-eco: 10000
|
||||
Level-4:
|
||||
Performance: 55%
|
||||
Reward: 50%:2-4
|
||||
Fuel-duration: 25%
|
||||
Cost-xp: 35
|
||||
Cost-eco: 12000
|
||||
Level-5:
|
||||
Performance: 75%
|
||||
Reward: 70%:3-4
|
||||
Fuel-duration: 45%
|
||||
Overheat: 1
|
||||
Cost-xp: 40
|
||||
Cost-eco: 15000
|
||||
Level-6:
|
||||
Performance: 75%
|
||||
Reward: 70%:3-4
|
||||
Fuel-duration: 45%
|
||||
Overheat: 2
|
||||
Fuel-share: 1
|
||||
Cost-xp: 40
|
||||
Cost-eco: 15000
|
@ -1,55 +0,0 @@
|
||||
#General Messages
|
||||
|
||||
general.nametag.prefix= "&8[&6EpicFurnaces&8]"
|
||||
general.nametag.next= "&9Next"
|
||||
general.nametag.back= "&9Back"
|
||||
general.nametag.nameformat= "&eLevel %level% &fFurnace"
|
||||
general.hologram.outoffuel= "&cNo Fuel"
|
||||
general.hologram.stats= "&a%in%&7/&c%out%";
|
||||
|
||||
#Interface Messages
|
||||
|
||||
interface.furnace.upgradewithxp= "&aUpgrade with XP"
|
||||
interface.furnace.upgradewithxplore= "&7Cost: &a%cost% Levels"
|
||||
interface.furnace.upgradewitheconomy= "&aUpgrade with ECO"
|
||||
interface.furnace.upgradewitheconomylore= "&7Cost: &a$%cost%"
|
||||
interface.furnace.currentlevel= "&6Furnace Level &7%level%"
|
||||
interface.furnace.level= "&6Next Level &7%level%"
|
||||
interface.furnace.performance= "&7Performance: &6%amount%"
|
||||
interface.furnace.reward= "&7Reward: &6%amount%"
|
||||
interface.furnace.performancetitle= "&a&lPerformance"
|
||||
interface.furnace.rewardtitle= "&c&lReward"
|
||||
interface.furnace.fueldurationtitle= "&7&lFuel Duration"
|
||||
interface.furnace.fuelduration= "&7Fuel Duration: &6%amount%"
|
||||
interface.furnace.fuelshare= "&7Fuel Share: &6%amount%&7."
|
||||
interface.furnace.fuelsharetitle= "&6&lFuel Share"
|
||||
interface.furnace.fuelshareinfo= "&7This furnace will power other|&7furnaces within a &6%amount%&7 block radius."
|
||||
interface.furnace.overheat= "&7Overheat: &6%amount%&7."
|
||||
interface.furnace.overheattitle= "&6&lOverheat"
|
||||
interface.furnace.overheatinfo= "&7This furnace will melt snow |&7and ice within a &6%amount%&7 block radius."
|
||||
interface.furnace.performanceinfo= "&7This furnaces performance is |&7currently boosted an extra &6%amount%%&7. | |&7Performance boosts the speed in |&7which a furnace processes |&7materials."
|
||||
interface.furnace.rewardinfo= "&7This furnace currently |&7has a &6%amount%%&7 chance of |&7producing multiple resources."
|
||||
interface.furnace.fueldurationinfo= "&7This furnaces fuel duration is |&7currently boosted by &6%amount%%&7. | |&7Fuel Duration boosts how long |&7fuel in the furnace lasts."
|
||||
interface.furnace.smeltedx= "&7Smelted &6%amount% Materials&7."
|
||||
interface.furnace.tolevel= "&6%amount% %type%s &7away from leveling up."
|
||||
interface.furnace.remotefurnace= "&5&lRemote Control"
|
||||
interface.furnace.remotefurnacelore= "&7Left-Click to assign a nickname.|&7Right-Click to give yourself |&7remote access.|&7Current nickname is: &6%nickname%&7."
|
||||
interface.furnace.utilize= "|&7To utilize remote access|&7use the command:|&6/EF Remote %nickname%"
|
||||
interface.furnace.remotelist= "&7Players with remote access:"
|
||||
interface.furnace.alreadymaxed= "&7This furnace is already maxed out!"
|
||||
interface.button.boostedstats= "&a&lCurrently boosted!|&7Reward multiplied by &6%amount%x&7.|&7Expires in &6%time%&7."
|
||||
|
||||
#Command Messages
|
||||
|
||||
command.give.success= "&7You have been given a &6level %level% &7Furnace."
|
||||
|
||||
#Event Messages
|
||||
|
||||
event.general.nopermission= "&cYou do not have permission to do that."
|
||||
event.upgrade.cannotafford= "&cYou cannot afford this upgrade."
|
||||
event.upgrade.success= "&7You successfully upgraded this furnace to &6level %level%&7!"
|
||||
event.upgrade.maxed= "&7You maxed out this furnace at &6level %level%&7."
|
||||
event.remote.enter= "&7Enter a unique nickname for the furnace."
|
||||
event.remote.notfound= "&cRemote furnace not found."
|
||||
event.remote.nicknamesuccess= "&aNickname set successfully."
|
||||
event.remote.nicknameinuse= "&cThat nickname is already in use."
|
@ -1,13 +0,0 @@
|
||||
name: EpicFurnaces
|
||||
version: maven-version-number
|
||||
main: com.songoda.epicfurnaces.EpicFurnaces
|
||||
authors: [Brianna, GB6]
|
||||
website: https://songoda.com/
|
||||
depend: [Vault]
|
||||
softdepend: [PlotSquared, GriefPrevention, USkyBlock, SkyBlock, WorldGuard, Factions, HolographicDisplays, FabledSkyBlock]
|
||||
commands:
|
||||
epicfurnaces:
|
||||
description: Default command for the EpicFurnaces plugin.
|
||||
default: true
|
||||
aliases: [ef]
|
||||
usage: /<command> [reload]
|
67
pom.xml
67
pom.xml
@ -1,18 +1,11 @@
|
||||
<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/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicFurnaces-Parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<artifactId>EpicFurnaces</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>maven-version-number</version>
|
||||
|
||||
<modules>
|
||||
<module>core</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>EpicFurnaces-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -23,6 +16,45 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:SongodaCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.songoda.core</pattern>
|
||||
<shadedPattern>${project.groupId}.epicfurnaces.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
@ -31,4 +63,17 @@
|
||||
<url>http://repo.songoda.com/artifactory/private/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.14.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
381
src/main/java/com/songoda/epicfurnaces/EpicFurnaces.java
Normal file
381
src/main/java/com/songoda/epicfurnaces/EpicFurnaces.java
Normal file
@ -0,0 +1,381 @@
|
||||
package com.songoda.epicfurnaces;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
import com.songoda.core.commands.CommandManager;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.hooks.HologramManager;
|
||||
import com.songoda.epicfurnaces.boost.BoostData;
|
||||
import com.songoda.epicfurnaces.boost.BoostManager;
|
||||
import com.songoda.epicfurnaces.commands.*;
|
||||
import com.songoda.epicfurnaces.furnace.Furnace;
|
||||
import com.songoda.epicfurnaces.furnace.FurnaceBuilder;
|
||||
import com.songoda.epicfurnaces.furnace.FurnaceManager;
|
||||
import com.songoda.epicfurnaces.furnace.levels.LevelManager;
|
||||
import com.songoda.epicfurnaces.handlers.BlacklistHandler;
|
||||
import com.songoda.epicfurnaces.listeners.BlockListeners;
|
||||
import com.songoda.epicfurnaces.listeners.FurnaceListeners;
|
||||
import com.songoda.epicfurnaces.listeners.InteractListeners;
|
||||
import com.songoda.epicfurnaces.listeners.InventoryListeners;
|
||||
import com.songoda.epicfurnaces.settings.Settings;
|
||||
import com.songoda.epicfurnaces.storage.Storage;
|
||||
import com.songoda.epicfurnaces.storage.StorageRow;
|
||||
import com.songoda.epicfurnaces.storage.types.StorageYaml;
|
||||
import com.songoda.epicfurnaces.tasks.FurnaceTask;
|
||||
import com.songoda.epicfurnaces.tasks.HologramTask;
|
||||
import com.songoda.epicfurnaces.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EpicFurnaces extends SongodaPlugin {
|
||||
|
||||
private static EpicFurnaces INSTANCE;
|
||||
|
||||
private final Config furnaceRecipeFile = new Config(this, "Furnace Recipes.yml");
|
||||
private final Config levelsFile = new Config(this, "levels.yml");
|
||||
private final Config dataFile = new Config(this, "data.yml");
|
||||
|
||||
private final GuiManager guiManager = new GuiManager(this);
|
||||
private LevelManager levelManager;
|
||||
private FurnaceManager furnaceManager;
|
||||
private BoostManager boostManager;
|
||||
private CommandManager commandManager;
|
||||
|
||||
private BlacklistHandler blacklistHandler;
|
||||
|
||||
private Storage storage;
|
||||
|
||||
public static EpicFurnaces getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
saveToFile();
|
||||
this.storage.closeConnection();
|
||||
HologramManager.removeAllHolograms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginEnable() {
|
||||
// Run Songoda Updater
|
||||
SongodaCore.registerPlugin(this, 22, CompatibleMaterial.FURNACE);
|
||||
|
||||
// Load Economy
|
||||
EconomyManager.load();
|
||||
// Register Hologram Plugin
|
||||
HologramManager.load(this);
|
||||
|
||||
// Setup Config
|
||||
Settings.setupConfig();
|
||||
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
|
||||
|
||||
// Set Economy & Hologram preference
|
||||
EconomyManager.getManager().setPreferredHook(Settings.ECONOMY_PLUGIN.getString());
|
||||
HologramManager.getManager().setPreferredHook(Settings.HOLOGRAM_PLUGIN.getString());
|
||||
|
||||
|
||||
// Register commands
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.commandManager.addCommand(new CommandEpicFurnaces(this))
|
||||
.addSubCommands(
|
||||
new CommandBoost(this),
|
||||
new CommandGive(this),
|
||||
new CommandReload(this),
|
||||
new CommandRemote(this),
|
||||
new CommandSettings(this, guiManager)
|
||||
);
|
||||
|
||||
loadLevelManager();
|
||||
|
||||
this.furnaceManager = new FurnaceManager();
|
||||
this.boostManager = new BoostManager();
|
||||
this.blacklistHandler = new BlacklistHandler();
|
||||
|
||||
// Load from file
|
||||
dataFile.load();
|
||||
this.storage = new StorageYaml(this);
|
||||
loadFromFile();
|
||||
|
||||
setupRecipies();
|
||||
|
||||
// Start Tasks
|
||||
FurnaceTask.startTask(this);
|
||||
HologramTask.startTask(this);
|
||||
|
||||
// Register Listeners
|
||||
guiManager.init();
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
pluginManager.registerEvents(new BlockListeners(this), this);
|
||||
pluginManager.registerEvents(new FurnaceListeners(this), this);
|
||||
pluginManager.registerEvents(new InteractListeners(this, guiManager), this);
|
||||
pluginManager.registerEvents(new InventoryListeners(this), this);
|
||||
|
||||
// Start auto save
|
||||
int saveInterval = Settings.AUTOSAVE.getInt() * 60 * 20;
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this, this::saveToFile, saveInterval, saveInterval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigReload() {
|
||||
this.setLocale(getConfig().getString("System.Language Mode"), true);
|
||||
this.locale.reloadMessages();
|
||||
this.blacklistHandler.reload();
|
||||
loadLevelManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Config> getExtraConfig() {
|
||||
return Arrays.asList(levelsFile);
|
||||
}
|
||||
|
||||
public void clearHologram(Furnace furnace) {
|
||||
HologramManager.removeHologram(furnace.getLocation().add(0, .15, 0));
|
||||
}
|
||||
|
||||
public void updateHologram(Furnace furnace) {
|
||||
// are holograms enabled?
|
||||
if (!Settings.HOLOGRAMS.getBoolean() || !HologramManager.getManager().isEnabled()) return;
|
||||
// don't try to load furnaces in chunks that aren't loaded
|
||||
if (!furnace.isInLoadedChunk()) return;
|
||||
|
||||
BlockState state = furnace.getLocation().getBlock().getState();
|
||||
|
||||
// verify that this is a furnace
|
||||
if (!(state instanceof org.bukkit.block.Furnace)) return;
|
||||
|
||||
org.bukkit.block.Furnace furnaceBlock = ((org.bukkit.block.Furnace) state);
|
||||
|
||||
int performance = (furnaceBlock.getCookTime() - furnace.getPerformanceTotal()) <= 0 ? 0 : furnace.getPerformanceTotal();
|
||||
|
||||
float percent = (float) (furnaceBlock.getCookTime() - performance) / (200 - performance);
|
||||
|
||||
int progressBars = (int) (6 * percent) + (percent == 0 ? 0 : 1);
|
||||
int leftOver = (6 - progressBars);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < progressBars; i++) {
|
||||
sb.append("&a=");
|
||||
}
|
||||
for (int i = 0; i < leftOver; i++) {
|
||||
sb.append("&c=");
|
||||
}
|
||||
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
|
||||
String progress = Methods.formatText(sb.toString());
|
||||
|
||||
if (furnaceBlock.getInventory().getFuel() == null) {
|
||||
progress = getLocale().getMessage("general.hologram.outoffuel").getMessage();
|
||||
}
|
||||
|
||||
int inAmt = 0;
|
||||
int outAmt = 0;
|
||||
if (furnaceBlock.getInventory().getSmelting() != null) {
|
||||
inAmt = furnaceBlock.getInventory().getSmelting().getAmount();
|
||||
}
|
||||
if (furnaceBlock.getInventory().getResult() != null) {
|
||||
outAmt = furnaceBlock.getInventory().getResult().getAmount();
|
||||
}
|
||||
|
||||
String stats = getLocale().getMessage("general.hologram.stats")
|
||||
.processPlaceholder("in", inAmt)
|
||||
.processPlaceholder("out", Math.min(outAmt, 64)).getMessage();
|
||||
|
||||
lines.add(progress);
|
||||
lines.add(stats);
|
||||
|
||||
// create the hologram
|
||||
HologramManager.updateHologram(furnace.getLocation().add(0, .15, 0), lines);
|
||||
}
|
||||
|
||||
private void loadFromFile() {
|
||||
/*
|
||||
* Register furnaces into FurnaceManger from configuration
|
||||
*/
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
if (storage.containsGroup("charged")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("charged")) {
|
||||
Location location = Methods.unserializeLocation(row.getKey());
|
||||
if (location == null) continue;
|
||||
|
||||
if (row.get("level").asInt() == 0) continue;
|
||||
|
||||
String placedByStr = row.get("placedBy").asString();
|
||||
UUID placedBy = placedByStr == null ? null : UUID.fromString(placedByStr);
|
||||
|
||||
Furnace furnace = new FurnaceBuilder(location)
|
||||
.setLevel(levelManager.getLevel(row.get("level").asInt()))
|
||||
.setNickname(row.get("nickname").asString())
|
||||
.setUses(row.get("uses").asInt())
|
||||
.setToLevel(row.get("tolevel").asInt())
|
||||
.setAccessList(row.get("accesslist").asStringList())
|
||||
.setPlacedBy(placedBy).build();
|
||||
|
||||
furnaceManager.addFurnace(furnace);
|
||||
}
|
||||
}
|
||||
|
||||
// Adding in Boosts
|
||||
if (storage.containsGroup("boosts")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("boosts")) {
|
||||
if (row.getItems().get("uuid").asObject() != null)
|
||||
continue;
|
||||
|
||||
BoostData boostData = new BoostData(
|
||||
row.get("amount").asInt(),
|
||||
Long.parseLong(row.getKey()),
|
||||
UUID.fromString(row.get("uuid").asString()));
|
||||
|
||||
this.boostManager.addBoostToPlayer(boostData);
|
||||
}
|
||||
}
|
||||
|
||||
// Register Hologram Plugin
|
||||
if (Settings.HOLOGRAMS.getBoolean()) {
|
||||
for (Furnace furnace : getFurnaceManager().getFurnaces().values()) {
|
||||
if (furnace.getLocation() == null || furnace.getLocation().getWorld() == null)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Save data initially so that if the person reloads again fast they don't lose all their data.
|
||||
this.saveToFile();
|
||||
}, 10);
|
||||
}
|
||||
|
||||
private void loadLevelManager() {
|
||||
if (!levelsFile.getFile().exists())
|
||||
this.saveResource("levels.yml", false);
|
||||
levelsFile.load();
|
||||
|
||||
// Load an plugin of LevelManager
|
||||
levelManager = new LevelManager();
|
||||
/*
|
||||
* Register Levels into LevelManager from configuration.
|
||||
*/
|
||||
levelManager.clear();
|
||||
for (String levelName : levelsFile.getKeys(false)) {
|
||||
int level = Integer.parseInt(levelName.split("-")[1]);
|
||||
|
||||
ConfigurationSection levels = levelsFile.getConfigurationSection(levelName);
|
||||
|
||||
int costExperiance = levels.getInt("Cost-xp");
|
||||
int costEconomy = levels.getInt("Cost-eco");
|
||||
|
||||
String performanceStr = levels.getString("Performance");
|
||||
int performance = performanceStr == null ? 0 : Integer.parseInt(performanceStr.substring(0, performanceStr.length() - 1));
|
||||
|
||||
String reward = levels.getString("Reward");
|
||||
|
||||
String fuelDurationStr = levels.getString("Fuel-duration");
|
||||
int fuelDuration = fuelDurationStr == null ? 0 : Integer.parseInt(fuelDurationStr.substring(0, fuelDurationStr.length() - 1));
|
||||
|
||||
int overheat = levels.getInt("Overheat");
|
||||
int fuelShare = levels.getInt("Fuel-share");
|
||||
|
||||
levelManager.addLevel(level, costExperiance, costEconomy, performance, reward, fuelDuration, overheat, fuelShare);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Saves registered furnaces to file.
|
||||
*/
|
||||
private void saveToFile() {
|
||||
storage.doSave();
|
||||
}
|
||||
|
||||
private void setupRecipies() {
|
||||
File config = new File(getDataFolder(), "Furnace Recipes.yml");
|
||||
if (!config.exists()) {
|
||||
saveResource("Furnace Recipes.yml", false);
|
||||
}
|
||||
furnaceRecipeFile.load();
|
||||
|
||||
if (Settings.CUSTOM_RECIPES.getBoolean()) {
|
||||
ConfigurationSection cs = furnaceRecipeFile.getConfigurationSection("Recipes");
|
||||
for (String key : cs.getKeys(false)) {
|
||||
Material item = Material.valueOf(key.toUpperCase());
|
||||
Material result = Material.valueOf(furnaceRecipeFile.getString("Recipes." + key.toUpperCase() + ".result"));
|
||||
int amount = furnaceRecipeFile.getInt("Recipes." + key.toUpperCase() + ".amount");
|
||||
|
||||
getServer().addRecipe(new FurnaceRecipe(new ItemStack(result, amount), item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack createLeveledFurnace(Material material, int level, int uses) {
|
||||
ItemStack item = new ItemStack(material, 1);
|
||||
|
||||
if (Settings.FURNACE_ITEM.getBoolean()) {
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
itemmeta.setDisplayName(Methods.formatText(Methods.formatName(level, uses, true)));
|
||||
item.setItemMeta(itemmeta);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getFurnceLevel(ItemStack item) {
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
String arr[] = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
return Integer.parseInt(arr[0]);
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getFurnaceUses(ItemStack item) {
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
String arr[] = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
return Integer.parseInt(arr[1]);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Config getFurnaceRecipeFile() {
|
||||
return furnaceRecipeFile;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public BoostManager getBoostManager() {
|
||||
return boostManager;
|
||||
}
|
||||
|
||||
public BlacklistHandler getBlacklistHandler() {
|
||||
return blacklistHandler;
|
||||
}
|
||||
|
||||
public FurnaceManager getFurnaceManager() {
|
||||
return furnaceManager;
|
||||
}
|
||||
|
||||
public LevelManager getLevelManager() {
|
||||
return levelManager;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicfurnaces.objects;
|
||||
package com.songoda.epicfurnaces.boost;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
@ -1,19 +1,13 @@
|
||||
package com.songoda.epicfurnaces.managers;
|
||||
package com.songoda.epicfurnaces.boost;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.objects.BoostData;
|
||||
import com.songoda.epicfurnaces.storage.StorageItem;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BoostManager {
|
||||
|
||||
private final Set<BoostData> registeredBoosts = new HashSet<>();
|
||||
private final EpicFurnaces instance;
|
||||
|
||||
public BoostManager(EpicFurnaces instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public void addBoostToPlayer(BoostData data) {
|
||||
this.registeredBoosts.add(data);
|
@ -0,0 +1,93 @@
|
||||
package com.songoda.epicfurnaces.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.boost.BoostData;
|
||||
import com.songoda.epicfurnaces.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBoost extends AbstractCommand {
|
||||
|
||||
final EpicFurnaces plugin;
|
||||
|
||||
public CommandBoost(EpicFurnaces plugin) {
|
||||
super(false, "boost");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 2) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
if (Bukkit.getPlayer(args[0]) == null) {
|
||||
plugin.getLocale().newMessage("&cThat player does not exist...").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
} else if (!Methods.isInt(args[1])) {
|
||||
plugin.getLocale().newMessage("&6" + args[1] + " &7is not a number...").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
} else {
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date currentDate = new Date();
|
||||
c.setTime(currentDate);
|
||||
|
||||
String time = "&7.";
|
||||
|
||||
if (args.length > 2) {
|
||||
if (args[2].contains("m:")) {
|
||||
String[] arr2 = (args[2]).split(":");
|
||||
c.add(Calendar.MINUTE, Integer.parseInt(arr2[0]));
|
||||
time = " &7for &6" + arr2[0] + " minutes&7.";
|
||||
} else if (args[2].contains("h:")) {
|
||||
String[] arr2 = (args[2]).split(":");
|
||||
c.add(Calendar.HOUR, Integer.parseInt(arr2[0]));
|
||||
time = " &7for &6" + arr2[0] + " hours&7.";
|
||||
} else if (args[2].contains("d:")) {
|
||||
String[] arr2 = (args[2]).split(":");
|
||||
c.add(Calendar.HOUR, Integer.parseInt(arr2[0]) * 24);
|
||||
time = " &7for &6" + arr2[0] + " days&7.";
|
||||
} else if (args[2].contains("y:")) {
|
||||
String[] arr2 = (args[2]).split(":");
|
||||
c.add(Calendar.YEAR, Integer.parseInt(arr2[0]));
|
||||
time = " &7for &6" + arr2[0] + " years&7.";
|
||||
} else {
|
||||
plugin.getLocale().newMessage("&7" + args[2] + " &7is invalid.").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
} else {
|
||||
c.add(Calendar.YEAR, 10);
|
||||
}
|
||||
|
||||
BoostData boostData = new BoostData(Integer.parseInt(args[2]), c.getTime().getTime(), Bukkit.getPlayer(args[0]).getUniqueId());
|
||||
plugin.getBoostManager().addBoostToPlayer(boostData);
|
||||
plugin.getLocale().newMessage("&7Successfully boosted &6" + Bukkit.getPlayer(args[0]).getName()
|
||||
+ "'s &7furnaces reward amounts by &6" + args[2] + "x" + time).sendPrefixedMessage(sender);
|
||||
}
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... strings) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "epicfurnaces.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef boost <player> <multiplier> [m:minute, h:hour, d:day, y:year]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "This allows you to boost a players furnace reward amounts by a multiplier (Put 2 for double, 3 for triple and so on).";
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.songoda.epicfurnaces.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandEpicFurnaces extends AbstractCommand {
|
||||
|
||||
final EpicFurnaces plugin;
|
||||
|
||||
public CommandEpicFurnaces(EpicFurnaces plugin) {
|
||||
super(false, "EpicFurnaces");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
plugin.getLocale().newMessage("&7Version " + plugin.getDescription().getVersion()
|
||||
+ " Created with <3 by &5&l&oSongoda").sendPrefixedMessage(sender);
|
||||
|
||||
for (AbstractCommand command : plugin.getCommandManager().getAllCommands()) {
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
}
|
||||
}
|
||||
sender.sendMessage("");
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... strings) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/EpicFurnaces";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Displays this page.";
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.songoda.epicfurnaces.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.furnace.levels.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandGive extends AbstractCommand {
|
||||
|
||||
final EpicFurnaces plugin;
|
||||
|
||||
public CommandGive(EpicFurnaces plugin) {
|
||||
super(false, "give");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length == 1) return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Level level = plugin.getLevelManager().getLowestLevel();
|
||||
Player player;
|
||||
if (args.length != 0 && Bukkit.getPlayer(args[0]) == null) {
|
||||
plugin.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
} else if (args.length == 0) {
|
||||
if (!(sender instanceof Player)) {
|
||||
plugin.getLocale().newMessage("&cYou need to be a player to give a farm item to yourself.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
player = (Player) sender;
|
||||
} else {
|
||||
player = Bukkit.getPlayer(args[0]);
|
||||
}
|
||||
|
||||
|
||||
if (args.length >= 2 && !plugin.getLevelManager().isLevel(Integer.parseInt(args[1]))) {
|
||||
plugin.getLocale().newMessage("&cNot a valid level... The current valid levels are: &4"
|
||||
+ plugin.getLevelManager().getLowestLevel().getLevel() + "-"
|
||||
+ plugin.getLevelManager().getHighestLevel().getLevel() + "&c.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
} else if (args.length != 0) {
|
||||
level = plugin.getLevelManager().getLevel(Integer.parseInt(args[1]));
|
||||
}
|
||||
player.getInventory().addItem(plugin.createLeveledFurnace(Material.FURNACE, level.getLevel(), 0));
|
||||
plugin.getLocale().getMessage("command.give.success")
|
||||
.processPlaceholder("level", level.getLevel()).sendPrefixedMessage(sender);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... strings) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "epicfurnaces.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef give [player] <level>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Give a leveled furnace to a player.";
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.songoda.epicfurnaces.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandReload extends AbstractCommand {
|
||||
|
||||
private final EpicFurnaces plugin;
|
||||
|
||||
public CommandReload(EpicFurnaces plugin) {
|
||||
super(false, "reload");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCommand.ReturnType runCommand(CommandSender sender, String... args) {
|
||||
plugin.reloadConfig();
|
||||
plugin.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "epicfurnaces.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Reload the Configuration and Language files.";
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.songoda.epicfurnaces.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.furnace.Furnace;
|
||||
import com.songoda.epicfurnaces.settings.Settings;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandRemote extends AbstractCommand {
|
||||
|
||||
final EpicFurnaces plugin;
|
||||
|
||||
public CommandRemote(EpicFurnaces plugin) {
|
||||
super(true, "remote");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
|
||||
if (!Settings.REMOTE.getBoolean() || !sender.hasPermission("EpicFurnaces.Remote")) {
|
||||
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
if (args.length < 1) return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
StringBuilder name = new StringBuilder();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
name.append(" ").append(args[i]);
|
||||
}
|
||||
name = new StringBuilder(name.toString().trim());
|
||||
for (Furnace furnace : plugin.getFurnaceManager().getFurnaces().values()) {
|
||||
if (furnace.getNickname() == null) continue;
|
||||
|
||||
if (!furnace.getNickname().equalsIgnoreCase(name.toString())) {
|
||||
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender);
|
||||
continue;
|
||||
}
|
||||
for (UUID uuid : furnace.getAccessList()) {
|
||||
if (!uuid.equals(((Player) sender).getUniqueId())) {
|
||||
continue;
|
||||
}
|
||||
Block b = furnace.getLocation().getBlock();
|
||||
org.bukkit.block.Furnace furnaceBlock = (org.bukkit.block.Furnace) b.getState();
|
||||
((Player) sender).openInventory(furnaceBlock.getInventory());
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
plugin.getLocale().getMessage("event.remote.notfound").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... strings) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef remote [nickname]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Remote control your furnace.";
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.songoda.epicfurnaces.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.configuration.editor.PluginConfigGui;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandSettings extends AbstractCommand {
|
||||
|
||||
final EpicFurnaces plugin;
|
||||
final GuiManager guiManager;
|
||||
|
||||
public CommandSettings(EpicFurnaces plugin, GuiManager guiManager) {
|
||||
super(true, "settings");
|
||||
this.plugin = plugin;
|
||||
this.guiManager = guiManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
guiManager.showGUI((Player) sender, new PluginConfigGui(plugin));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... strings) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "epicfurnaces.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ef settings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Edit the EpicFurnaces Settings.";
|
||||
}
|
||||
}
|
365
src/main/java/com/songoda/epicfurnaces/furnace/Furnace.java
Normal file
365
src/main/java/com/songoda/epicfurnaces/furnace/Furnace.java
Normal file
@ -0,0 +1,365 @@
|
||||
package com.songoda.epicfurnaces.furnace;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.boost.BoostData;
|
||||
import com.songoda.epicfurnaces.furnace.levels.Level;
|
||||
import com.songoda.epicfurnaces.gui.GUIOverview;
|
||||
import com.songoda.epicfurnaces.settings.Settings;
|
||||
import com.songoda.epicfurnaces.utils.CostType;
|
||||
import com.songoda.epicfurnaces.utils.Methods;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/7/2017.
|
||||
*/
|
||||
public class Furnace {
|
||||
|
||||
private final EpicFurnaces plugin = EpicFurnaces.getInstance();
|
||||
|
||||
private final Location location;
|
||||
private Level level = plugin.getLevelManager().getLowestLevel();
|
||||
private String nickname = null;
|
||||
private UUID placedBy = null;
|
||||
private int uses, tolevel, radiusOverheatLast, radiusFuelshareLast = 0;
|
||||
private final List<Location> radiusOverheat = new ArrayList<>();
|
||||
private final List<Location> radiusFuelshare = new ArrayList<>();
|
||||
private final List<String> accessList = new ArrayList<>();
|
||||
private final Map<String, Integer> cache = new HashMap<>();
|
||||
|
||||
public Furnace(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public void overview(GuiManager guiManager, Player player) {
|
||||
if (placedBy == null) placedBy = player.getUniqueId();
|
||||
|
||||
if (!player.hasPermission("epicfurnaces.overview")) return;
|
||||
guiManager.showGUI(player, new GUIOverview(plugin, this, player));
|
||||
}
|
||||
|
||||
public void plus(FurnaceSmeltEvent e) {
|
||||
Block block = location.getBlock();
|
||||
if (!block.getType().name().contains("FURNACE")) return;
|
||||
|
||||
this.uses++;
|
||||
this.tolevel++;
|
||||
|
||||
int multi = Settings.LEVEL_MULTIPLIER.getInt();
|
||||
|
||||
if (level.getReward() == null) return;
|
||||
|
||||
String reward = level.getReward();
|
||||
String[] amt = {"1", "1"};
|
||||
if (reward.contains(":")) {
|
||||
String[] rewardSplit = reward.split(":");
|
||||
reward = rewardSplit[0].substring(0, rewardSplit[0].length() - 1);
|
||||
if (rewardSplit[1].contains("-"))
|
||||
amt = rewardSplit[1].split("-");
|
||||
else {
|
||||
amt[0] = rewardSplit[1];
|
||||
amt[1] = rewardSplit[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int needed = ((multi * level.getLevel()) - tolevel) - 1;
|
||||
|
||||
if (Settings.UPGRADE_BY_SMELTING.getBoolean()
|
||||
&& needed <= 0
|
||||
&& plugin.getLevelManager().getLevel(level.getLevel() + 1) != null) {
|
||||
tolevel = 0;
|
||||
level = plugin.getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
}
|
||||
|
||||
this.updateCook();
|
||||
|
||||
FurnaceInventory i = (FurnaceInventory) ((InventoryHolder) block.getState()).getInventory();
|
||||
|
||||
int num = Integer.parseInt(reward);
|
||||
double rand = Math.random() * 100;
|
||||
if (rand >= num
|
||||
|| e.getResult().equals(Material.SPONGE)
|
||||
|| Settings.NO_REWARDS_FROM_RECIPES.getBoolean()
|
||||
&& plugin.getFurnaceRecipeFile().contains("Recipes." + i.getSmelting().getType().toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
int r = Integer.parseInt(amt[0]);
|
||||
if (Integer.parseInt(amt[0]) !=
|
||||
Integer.parseInt(amt[1].replace("%", "")))
|
||||
r = (int) (Math.random() * ((Integer.parseInt(amt[1].replace("%", "")) - Integer.parseInt(amt[0])))) + Integer.parseInt(amt[0]);
|
||||
|
||||
BoostData boostData = plugin.getBoostManager().getBoost(placedBy);
|
||||
r = r * (boostData == null ? 1 : boostData.getMultiplier());
|
||||
|
||||
|
||||
e.getResult().setAmount(e.getResult().getAmount() + r);
|
||||
}
|
||||
|
||||
public void upgrade(Player player, CostType type) {
|
||||
if (plugin.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) {
|
||||
|
||||
Level level = plugin.getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
int cost = type == CostType.ECONOMY ? level.getCostEconomy() : level.getCostExperience();
|
||||
|
||||
if (type == CostType.ECONOMY) {
|
||||
if (!EconomyManager.isEnabled()) {
|
||||
player.sendMessage("Economy not enabled.");
|
||||
return;
|
||||
}
|
||||
if (!EconomyManager.hasBalance(player, cost)) {
|
||||
|
||||
plugin.getLocale().getMessage("event.upgrade.cannotafford").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
EconomyManager.withdrawBalance(player, cost);
|
||||
upgradeFinal(level, player);
|
||||
} else if (type == CostType.EXPERIENCE) {
|
||||
if (player.getLevel() >= cost || player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
player.setLevel(player.getLevel() - cost);
|
||||
}
|
||||
upgradeFinal(level, player);
|
||||
} else {
|
||||
plugin.getLocale().getMessage("event.upgrade.cannotafford").sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void upgradeFinal(Level level, Player player) {
|
||||
this.level = level;
|
||||
syncName();
|
||||
if (plugin.getLevelManager().getHighestLevel() != level) {
|
||||
plugin.getLocale().getMessage("event.upgrade.success")
|
||||
.processPlaceholder("level", level.getLevel()).sendPrefixedMessage(player);
|
||||
|
||||
} else {
|
||||
plugin.getLocale().getMessage("event.upgrade.maxed")
|
||||
.processPlaceholder("level", level.getLevel()).sendPrefixedMessage(player);
|
||||
}
|
||||
Location loc = location.clone().add(.5, .5, .5);
|
||||
|
||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) return;
|
||||
|
||||
player.getWorld().spawnParticle(org.bukkit.Particle.valueOf(plugin.getConfig().getString("Main.Upgrade Particle Type")), loc, 200, .5, .5, .5);
|
||||
|
||||
if (plugin.getLevelManager().getHighestLevel() != level) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.6F, 15.0F);
|
||||
} else {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 2F, 25.0F);
|
||||
|
||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) return;
|
||||
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 2F, 25.0F);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.2F, 35.0F), 5L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.8F, 35.0F), 10L);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncName() {
|
||||
org.bukkit.block.Furnace furnace = (org.bukkit.block.Furnace) location.getBlock().getState();
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10))
|
||||
furnace.setCustomName(Methods.formatName(level.getLevel(), uses, false));
|
||||
furnace.update(true);
|
||||
}
|
||||
|
||||
public void updateCook() {
|
||||
Block block = location.getBlock();
|
||||
if (!block.getType().name().contains("FURNACE")) return;
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
int num = getPerformanceTotal();
|
||||
|
||||
if (num > 200)
|
||||
num = 200;
|
||||
|
||||
if (num != 0) {
|
||||
BlockState bs = (block.getState()); // max is 200
|
||||
((org.bukkit.block.Furnace) bs).setCookTime(Short.parseShort(Integer.toString(num)));
|
||||
bs.update();
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
|
||||
public List<UUID> getAccessList() {
|
||||
List<UUID> list = new ArrayList<>();
|
||||
for (String line : accessList) {
|
||||
String[] halfs = line.split(":");
|
||||
list.add(UUID.fromString(halfs[0]));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<String> getRawAccessList() {
|
||||
return new ArrayList<>(accessList);
|
||||
}
|
||||
|
||||
|
||||
public int getPerformanceTotal() {
|
||||
String equation = "(" + level.getPerformance() + " / 100) * 200";
|
||||
try {
|
||||
if (!cache.containsKey(equation)) {
|
||||
ScriptEngineManager mgr = new ScriptEngineManager();
|
||||
ScriptEngine engine = mgr.getEngineByName("JavaScript");
|
||||
int num = (int) Math.round(Double.parseDouble(engine.eval("(" + level.getPerformance() + " / 100) * 200").toString()));
|
||||
cache.put(equation, num);
|
||||
return num;
|
||||
} else {
|
||||
return cache.get(equation);
|
||||
}
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getOriginalAccessList() {
|
||||
return Collections.unmodifiableList(accessList);
|
||||
}
|
||||
|
||||
|
||||
public boolean addToAccessList(Player player) {
|
||||
String formatted = player.getUniqueId().toString() + ":" + player.getName();
|
||||
if (accessList.contains(formatted)) return false;
|
||||
return addToAccessList(formatted);
|
||||
}
|
||||
|
||||
public boolean addToAccessList(String formatted) {
|
||||
if (accessList.contains(formatted)) return false;
|
||||
return accessList.add(formatted);
|
||||
}
|
||||
|
||||
|
||||
public boolean removeFromAccessList(String string) {
|
||||
return accessList.remove(string);
|
||||
}
|
||||
|
||||
|
||||
public void clearAccessList() {
|
||||
accessList.clear();
|
||||
}
|
||||
|
||||
public List<Location> getRadius(boolean overHeat) {
|
||||
if (overHeat)
|
||||
return radiusOverheat.isEmpty() ? null : Collections.unmodifiableList(radiusOverheat);
|
||||
else
|
||||
return radiusFuelshare.isEmpty() ? null : Collections.unmodifiableList(radiusFuelshare);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void addToRadius(Location location, boolean overHeat) {
|
||||
if (overHeat)
|
||||
radiusOverheat.add(location);
|
||||
else
|
||||
radiusFuelshare.add(location);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void clearRadius(boolean overHeat) {
|
||||
if (overHeat)
|
||||
radiusOverheat.clear();
|
||||
else
|
||||
radiusFuelshare.clear();
|
||||
}
|
||||
|
||||
|
||||
public int getRadiusLast(boolean overHeat) {
|
||||
if (overHeat)
|
||||
return radiusOverheatLast;
|
||||
else
|
||||
return radiusFuelshareLast;
|
||||
}
|
||||
|
||||
|
||||
public void setRadiusLast(int radiusLast, boolean overHeat) {
|
||||
if (overHeat)
|
||||
this.radiusOverheatLast = radiusLast;
|
||||
else
|
||||
this.radiusFuelshareLast = radiusLast;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location.clone();
|
||||
}
|
||||
|
||||
public boolean isInLoadedChunk() {
|
||||
return location != null && location.getWorld() != null && location.getWorld().isChunkLoaded(((int) location.getX()) >> 4, ((int) location.getZ()) >> 4);
|
||||
}
|
||||
|
||||
public void setLevel(Level level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public UUID getPlacedBy() {
|
||||
return placedBy;
|
||||
}
|
||||
|
||||
public void setPlacedBy(UUID placedBy) {
|
||||
this.placedBy = placedBy;
|
||||
}
|
||||
|
||||
public int getUses() {
|
||||
return uses;
|
||||
}
|
||||
|
||||
public void setUses(int uses) {
|
||||
this.uses = uses;
|
||||
}
|
||||
|
||||
public int getTolevel() {
|
||||
return tolevel;
|
||||
}
|
||||
|
||||
public void setTolevel(int tolevel) {
|
||||
this.tolevel = tolevel;
|
||||
}
|
||||
|
||||
public int getRadiusOverheatLast() {
|
||||
return radiusOverheatLast;
|
||||
}
|
||||
|
||||
public void setRadiusOverheatLast(int radiusOverheatLast) {
|
||||
this.radiusOverheatLast = radiusOverheatLast;
|
||||
}
|
||||
|
||||
public int getRadiusFuelshareLast() {
|
||||
return radiusFuelshareLast;
|
||||
}
|
||||
|
||||
public void setRadiusFuelshareLast(int radiusFuelshareLast) {
|
||||
this.radiusFuelshareLast = radiusFuelshareLast;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.songoda.epicfurnaces.furnace;
|
||||
|
||||
import com.songoda.epicfurnaces.furnace.levels.Level;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FurnaceBuilder {
|
||||
|
||||
//Level level, String nickname, int uses, int tolevel, List<String> accessList, UUID placedBy
|
||||
|
||||
private final Furnace furnace;
|
||||
|
||||
public FurnaceBuilder(Location location) {
|
||||
this.furnace = new Furnace(location);
|
||||
}
|
||||
|
||||
public FurnaceBuilder setLevel(Level level) {
|
||||
this.furnace.setLevel(level);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FurnaceBuilder setNickname(String nickname) {
|
||||
this.furnace.setNickname(nickname);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FurnaceBuilder setUses(int uses) {
|
||||
this.furnace.setUses(uses);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FurnaceBuilder setToLevel(int toLevel) {
|
||||
this.furnace.setTolevel(toLevel);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FurnaceBuilder setAccessList(List<String> accessList) {
|
||||
for (String line : accessList)
|
||||
this.furnace.addToAccessList(line);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FurnaceBuilder setPlacedBy(UUID uuid) {
|
||||
this.furnace.setPlacedBy(uuid);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Furnace build() {
|
||||
return this.furnace;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.songoda.epicfurnaces.furnace;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FurnaceManager {
|
||||
|
||||
private final Map<Location, Furnace> registeredFurnaces = new HashMap<>();
|
||||
|
||||
|
||||
public Furnace addFurnace(Furnace furnace) {
|
||||
return registeredFurnaces.put(roundLocation(furnace.getLocation()), furnace);
|
||||
}
|
||||
|
||||
public Furnace removeFurnace(Location location) {
|
||||
return registeredFurnaces.remove(location);
|
||||
}
|
||||
|
||||
public Furnace getFurnace(Location location) {
|
||||
if (!registeredFurnaces.containsKey(location)) {
|
||||
addFurnace(new FurnaceBuilder(location).build());
|
||||
}
|
||||
return registeredFurnaces.get(location);
|
||||
}
|
||||
|
||||
public Furnace getFurnace(Block block) {
|
||||
return getFurnace(block.getLocation());
|
||||
}
|
||||
|
||||
public Map<Location, Furnace> getFurnaces() {
|
||||
return Collections.unmodifiableMap(registeredFurnaces);
|
||||
}
|
||||
|
||||
private Location roundLocation(Location location) {
|
||||
location = location.clone();
|
||||
location.setX(location.getBlockX());
|
||||
location.setY(location.getBlockY());
|
||||
location.setZ(location.getBlockZ());
|
||||
return location;
|
||||
}
|
||||
}
|
@ -1,18 +1,19 @@
|
||||
package com.songoda.epicfurnaces.objects;
|
||||
package com.songoda.epicfurnaces.furnace.levels;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Level {
|
||||
|
||||
private List<String> description = new ArrayList<>();
|
||||
private int level, costExperience, costEconomy, performance, fuelDuration, overheat, fuelShare;
|
||||
|
||||
private String reward;
|
||||
|
||||
public Level(EpicFurnaces instance, int level, int costExperience, int costEconomy, int performance, String reward, int fuelDuration, int overheat, int fuelShare) {
|
||||
private List<String> description = new ArrayList<>();
|
||||
|
||||
Level(int level, int costExperience, int costEconomy, int performance, String reward, int fuelDuration, int overheat, int fuelShare) {
|
||||
this.level = level;
|
||||
this.costExperience = costExperience;
|
||||
this.costEconomy = costEconomy;
|
||||
@ -22,25 +23,32 @@ public class Level {
|
||||
this.overheat = overheat;
|
||||
this.fuelShare = fuelShare;
|
||||
|
||||
EpicFurnaces plugin = EpicFurnaces.getInstance();
|
||||
|
||||
if (performance != 0)
|
||||
description.add(instance.getLocale().getMessage("interface.furnace.performance", performance + "%"));
|
||||
description.add(plugin.getLocale().getMessage("interface.furnace.performance")
|
||||
.processPlaceholder("amount", performance + "%").getMessage());
|
||||
|
||||
if (reward != null)
|
||||
description.add(instance.getLocale().getMessage("interface.furnace.reward", reward.split("%:")[0] + "%"));
|
||||
description.add(plugin.getLocale().getMessage("interface.furnace.reward")
|
||||
.processPlaceholder("amount", reward.split("%:")[0] + "%").getMessage());
|
||||
|
||||
if (fuelDuration != 0)
|
||||
description.add(instance.getLocale().getMessage("interface.furnace.fuelduration", fuelDuration + "%"));
|
||||
description.add(plugin.getLocale().getMessage("interface.furnace.fuelduration")
|
||||
.processPlaceholder("amount", fuelDuration + "%").getMessage());
|
||||
|
||||
if (fuelShare != 0)
|
||||
description.add(instance.getLocale().getMessage("interface.furnace.fuelshare", fuelShare));
|
||||
description.add(plugin.getLocale().getMessage("interface.furnace.fuelshare")
|
||||
.processPlaceholder("amount", fuelShare).getMessage());
|
||||
|
||||
if (overheat != 0)
|
||||
description.add(instance.getLocale().getMessage("interface.furnace.overheat", overheat));
|
||||
description.add(plugin.getLocale().getMessage("interface.furnace.overheat")
|
||||
.processPlaceholder("amount", overheat).getMessage());
|
||||
}
|
||||
|
||||
|
||||
public List<String> getDescription() {
|
||||
return Collections.unmodifiableList(description);
|
||||
return new ArrayList<>(description);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,46 @@
|
||||
package com.songoda.epicfurnaces.furnace.levels;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class LevelManager {
|
||||
|
||||
private final NavigableMap<Integer, Level> registeredLevels = new TreeMap<>();
|
||||
|
||||
|
||||
public void addLevel(int level, int costExperiance, int costEconomy, int performance, String reward, int fuelDuration, int overheat, int fuelShare) {
|
||||
registeredLevels.put(level, new Level(level, costExperiance, costEconomy, performance, reward, fuelDuration, overheat, fuelShare));
|
||||
}
|
||||
|
||||
|
||||
public Level getLevel(int level) {
|
||||
return registeredLevels.get(level);
|
||||
}
|
||||
|
||||
|
||||
public Level getLowestLevel() {
|
||||
return registeredLevels.firstEntry().getValue();
|
||||
}
|
||||
|
||||
|
||||
public Level getHighestLevel() {
|
||||
return registeredLevels.lastEntry().getValue();
|
||||
}
|
||||
|
||||
|
||||
public boolean isLevel(int level) {
|
||||
return registeredLevels.containsKey(level);
|
||||
}
|
||||
|
||||
|
||||
public Map<Integer, Level> getLevels() {
|
||||
return Collections.unmodifiableMap(registeredLevels);
|
||||
}
|
||||
|
||||
|
||||
public void clear() {
|
||||
registeredLevels.clear();
|
||||
}
|
||||
}
|
248
src/main/java/com/songoda/epicfurnaces/gui/GUIOverview.java
Normal file
248
src/main/java/com/songoda/epicfurnaces/gui/GUIOverview.java
Normal file
@ -0,0 +1,248 @@
|
||||
package com.songoda.epicfurnaces.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.boost.BoostData;
|
||||
import com.songoda.epicfurnaces.furnace.Furnace;
|
||||
import com.songoda.epicfurnaces.furnace.levels.Level;
|
||||
import com.songoda.epicfurnaces.settings.Settings;
|
||||
import com.songoda.epicfurnaces.utils.CostType;
|
||||
import com.songoda.epicfurnaces.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GUIOverview extends Gui {
|
||||
|
||||
private final EpicFurnaces plugin;
|
||||
private final Furnace furnace;
|
||||
private final Player player;
|
||||
static int[][] infoIconOrder = new int[][]{{22}, {21, 23}, {21, 22, 23}, {20, 21, 23, 24}, {20, 21, 22, 23, 24}};
|
||||
|
||||
private int task;
|
||||
|
||||
public GUIOverview(EpicFurnaces plugin, Furnace furnace, Player player) {
|
||||
this.plugin = plugin;
|
||||
this.furnace = furnace;
|
||||
this.player = player;
|
||||
|
||||
setRows(3);
|
||||
setTitle(Methods.formatName(furnace.getLevel().getLevel(), furnace.getUses(), false));
|
||||
runTask();
|
||||
constructGUI();
|
||||
this.setOnClose(action -> Bukkit.getScheduler().cancelTask(task));
|
||||
}
|
||||
|
||||
private void constructGUI() {
|
||||
ItemStack glass1 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_1.getMaterial());
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial());
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial());
|
||||
|
||||
setDefaultItem(glass1);
|
||||
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(this, 1, 0, false, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 1, false, true, glass3);
|
||||
|
||||
Level level = furnace.getLevel();
|
||||
Level nextLevel = plugin.getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? plugin.getLevelManager().getLevel(level.getLevel() + 1) : null;
|
||||
|
||||
// main furnace information icon
|
||||
setItem(1, 4, GuiUtils.createButtonItem(CompatibleMaterial.FURNACE,
|
||||
plugin.getLocale().getMessage("interface.furnace.currentlevel")
|
||||
.processPlaceholder("level", level.getLevel()).getMessage(),
|
||||
getFurnaceDescription(furnace, level, nextLevel)));
|
||||
|
||||
// check how many info icons we have to show
|
||||
int num = -1;
|
||||
if (level.getPerformance() != 0) {
|
||||
num++;
|
||||
}
|
||||
if (level.getReward() != null) {
|
||||
num++;
|
||||
}
|
||||
if (level.getFuelDuration() != 0) {
|
||||
num++;
|
||||
}
|
||||
if (level.getFuelShare() != 0) {
|
||||
num++;
|
||||
}
|
||||
if (level.getOverheat() != 0) {
|
||||
num++;
|
||||
}
|
||||
|
||||
int current = 0;
|
||||
|
||||
if (level.getPerformance() != 0) {
|
||||
setItem(infoIconOrder[num][current++], GuiUtils.createButtonItem(
|
||||
Settings.PERFORMANCE_ICON.getMaterial(CompatibleMaterial.REDSTONE),
|
||||
plugin.getLocale().getMessage("interface.furnace.performancetitle").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.furnace.performanceinfo")
|
||||
.processPlaceholder("amount", level.getPerformance()).getMessage().split("\\|")));
|
||||
}
|
||||
if (level.getReward() != null) {
|
||||
setItem(infoIconOrder[num][current++], GuiUtils.createButtonItem(
|
||||
Settings.REWARD_ICON.getMaterial(CompatibleMaterial.GOLDEN_APPLE),
|
||||
plugin.getLocale().getMessage("interface.furnace.rewardtitle").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.furnace.rewardinfo")
|
||||
.processPlaceholder("amount", level.getReward().split(":")[0].replace("%", ""))
|
||||
.getMessage().split("\\|")));
|
||||
}
|
||||
if (level.getFuelDuration() != 0) {
|
||||
setItem(infoIconOrder[num][current++], GuiUtils.createButtonItem(
|
||||
Settings.FUEL_DURATION_ICON.getMaterial(CompatibleMaterial.COAL),
|
||||
plugin.getLocale().getMessage("interface.furnace.fueldurationtitle").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.furnace.fueldurationinfo")
|
||||
.processPlaceholder("amount", level.getFuelDuration())
|
||||
.getMessage().split("\\|")));
|
||||
}
|
||||
if (level.getFuelShare() != 0) {
|
||||
setItem(infoIconOrder[num][current++], GuiUtils.createButtonItem(
|
||||
Settings.FUEL_SHARE_ICON.getMaterial(CompatibleMaterial.COAL_BLOCK),
|
||||
plugin.getLocale().getMessage("interface.furnace.fuelsharetitle").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.furnace.fuelshareinfo")
|
||||
.processPlaceholder("amount", level.getOverheat() * 3)
|
||||
.getMessage().split("\\|")));
|
||||
}
|
||||
if (level.getOverheat() != 0) {
|
||||
setItem(infoIconOrder[num][current++], GuiUtils.createButtonItem(
|
||||
Settings.OVERHEAT_ICON.getMaterial(CompatibleMaterial.FIRE_CHARGE),
|
||||
plugin.getLocale().getMessage("interface.furnace.overheattitle").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.furnace.overheatinfo")
|
||||
.processPlaceholder("amount", level.getOverheat() * 3)
|
||||
.getMessage().split("\\|")));
|
||||
}
|
||||
|
||||
// remote control
|
||||
if (Settings.REMOTE.getBoolean() && player.hasPermission("EpicFurnaces.Remote")) {
|
||||
setButton(4, GuiUtils.createButtonItem(
|
||||
CompatibleMaterial.TRIPWIRE_HOOK,
|
||||
plugin.getLocale().getMessage("interface.furnace.remotefurnace").getMessage(),
|
||||
getFurnaceRemoteLore(furnace)),
|
||||
ClickType.LEFT, (event) -> {
|
||||
|
||||
player.sendMessage(furnace.getNickname() == null ? "Enter a nickname" : furnace.getNickname());
|
||||
ChatPrompt.showPrompt(plugin, event.player, plugin.getLocale().getMessage("event.remote.enter").getMessage(),
|
||||
promptEvent -> {
|
||||
for (Furnace other : plugin.getFurnaceManager().getFurnaces().values()) {
|
||||
if (other.getNickname() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (other.getNickname().equalsIgnoreCase(promptEvent.getMessage())) {
|
||||
plugin.getLocale().getMessage("event.remote.nicknameinuse").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
furnace.setNickname(promptEvent.getMessage());
|
||||
plugin.getLocale().getMessage("event.remote.nicknamesuccess").sendPrefixedMessage(player);
|
||||
}).setOnClose(this::constructGUI);
|
||||
|
||||
}).setAction(4, ClickType.RIGHT, (event) -> {
|
||||
furnace.addToAccessList(player);
|
||||
constructGUI();
|
||||
});
|
||||
}
|
||||
|
||||
if (Settings.UPGRADE_WITH_XP.getBoolean()
|
||||
&& level.getCostExperience() != -1
|
||||
&& player.hasPermission("EpicFurnaces.Upgrade.XP")) {
|
||||
setButton(1, 2, GuiUtils.createButtonItem(
|
||||
Settings.XP_ICON.getMaterial(CompatibleMaterial.EXPERIENCE_BOTTLE),
|
||||
plugin.getLocale().getMessage("interface.furnace.upgradewithxp").getMessage(),
|
||||
nextLevel != null
|
||||
? plugin.getLocale().getMessage("interface.furnace.upgradewithxplore")
|
||||
.processPlaceholder("cost", nextLevel.getCostExperience()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.furnace.alreadymaxed").getMessage()),
|
||||
(event) -> {
|
||||
furnace.upgrade(player, CostType.EXPERIENCE);
|
||||
furnace.overview(guiManager, player);
|
||||
});
|
||||
}
|
||||
if (Settings.UPGRADE_WITH_ECONOMY.getBoolean()
|
||||
&& level.getCostEconomy() != -1
|
||||
&& player.hasPermission("EpicFurnaces.Upgrade.ECO")) {
|
||||
setButton(1, 6, GuiUtils.createButtonItem(
|
||||
Settings.ECO_ICON.getMaterial(CompatibleMaterial.SUNFLOWER),
|
||||
plugin.getLocale().getMessage("interface.furnace.upgradewitheconomy").getMessage(),
|
||||
nextLevel != null
|
||||
? plugin.getLocale().getMessage("interface.furnace.upgradewitheconomylore")
|
||||
.processPlaceholder("cost", nextLevel.getCostExperience()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.furnace.alreadymaxed").getMessage()),
|
||||
(event) -> {
|
||||
furnace.upgrade(player, CostType.ECONOMY);
|
||||
furnace.overview(guiManager, player);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void runTask() {
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::constructGUI, 5L, 5L);
|
||||
}
|
||||
|
||||
List<String> getFurnaceDescription(Furnace furnace, Level level, Level nextLevel) {
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(plugin.getLocale().getMessage("interface.furnace.smeltedx")
|
||||
.processPlaceholder("amount", furnace.getUses()).getMessage());
|
||||
lore.addAll(level.getDescription());
|
||||
lore.add("");
|
||||
if (nextLevel == null) {
|
||||
lore.add(plugin.getLocale().getMessage("interface.furnace.alreadymaxed").getMessage());
|
||||
} else {
|
||||
lore.add(plugin.getLocale().getMessage("interface.furnace.level")
|
||||
.processPlaceholder("level", nextLevel.getLevel()).getMessage());
|
||||
lore.addAll(nextLevel.getDescription());
|
||||
|
||||
if (Settings.UPGRADE_BY_SMELTING.getBoolean()) {
|
||||
lore.add(plugin.getLocale().getMessage("interface.furnace.tolevel")
|
||||
.processPlaceholder("amount", (Settings.LEVEL_MULTIPLIER.getInt() * level.getLevel()) - furnace.getTolevel())
|
||||
.processPlaceholder("type", Methods.cleanString(Settings.UPGRADE_COST.getString()))
|
||||
.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
BoostData boostData = plugin.getBoostManager().getBoost(furnace.getPlacedBy());
|
||||
if (boostData != null) {
|
||||
lore.addAll(Arrays.asList(plugin.getLocale().getMessage("interface.button.boostedstats")
|
||||
.processPlaceholder("amount", Integer.toString(boostData.getMultiplier()))
|
||||
.processPlaceholder("time", Methods.makeReadable(boostData.getEndTime() - System.currentTimeMillis()))
|
||||
.getMessage().split("\\|")));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
List<String> getFurnaceRemoteLore(Furnace furnace) {
|
||||
String nickname = furnace.getNickname();
|
||||
ArrayList<String> lorehook = new ArrayList<>(Arrays.asList(plugin.getLocale().getMessage("interface.furnace.remotefurnacelore")
|
||||
.processPlaceholder("nickname", nickname == null ? "Unset" : nickname).getMessage().split("\\|")));
|
||||
|
||||
if (nickname != null) {
|
||||
lorehook.addAll(Arrays.asList(plugin.getLocale().getMessage("interface.furnace.utilize")
|
||||
.processPlaceholder("nickname", nickname).getMessage().split("\\|")));
|
||||
}
|
||||
|
||||
lorehook.add("");
|
||||
lorehook.add(plugin.getLocale().getMessage("interface.furnace.remotelist").getMessage());
|
||||
for (String line : furnace.getRawAccessList()) {
|
||||
String[] halfs = line.split(":");
|
||||
String name = halfs[1];
|
||||
Player remotePlayer = Bukkit.getPlayer(halfs[0]);
|
||||
if (remotePlayer != null) {
|
||||
name = remotePlayer.getDisplayName();
|
||||
}
|
||||
lorehook.add(Methods.formatText("&6" + name));
|
||||
}
|
||||
return lorehook;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.songoda.epicfurnaces.handlers;
|
||||
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/25/2017.
|
||||
*/
|
||||
public class BlacklistHandler {
|
||||
|
||||
private final Config blackConfig = new Config(EpicFurnaces.getInstance(), "blacklist.yml");
|
||||
|
||||
public BlacklistHandler() {
|
||||
loadBlacklistFile();
|
||||
}
|
||||
|
||||
public boolean isBlacklisted(World world) {
|
||||
List<String> list = blackConfig.getStringList("settings.blacklist");
|
||||
final String checkWorld = world.getName();
|
||||
return list.stream().anyMatch(w -> w.equalsIgnoreCase(checkWorld));
|
||||
}
|
||||
|
||||
private void loadBlacklistFile() {
|
||||
blackConfig.addDefault("settings.blacklist", Arrays.asList("world2", "world3", "world4", "world5"));
|
||||
blackConfig.load();
|
||||
|
||||
blackConfig.saveChanges();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
loadBlacklistFile();
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.songoda.epicfurnaces.listeners;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.furnace.Furnace;
|
||||
import com.songoda.epicfurnaces.furnace.FurnaceBuilder;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/26/2017.
|
||||
*/
|
||||
public class BlockListeners implements Listener {
|
||||
|
||||
private final EpicFurnaces plugin;
|
||||
|
||||
public BlockListeners(EpicFurnaces plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSnowLand(BlockFormEvent event) {
|
||||
Material material = event.getNewState().getType();
|
||||
|
||||
if (material != Material.SNOW && material != Material.ICE) return;
|
||||
|
||||
for (Furnace furnace : plugin.getFurnaceManager().getFurnaces().values()) {
|
||||
if (furnace.getRadius(false) == null || ((org.bukkit.block.Furnace) furnace.getLocation().getBlock().getState()).getBurnTime() == 0)
|
||||
continue;
|
||||
for (Location location : furnace.getRadius(false)) {
|
||||
if (location.getX() != event.getNewState().getX() || location.getY() != event.getNewState().getY() || location.getZ() != event.getNewState().getZ())
|
||||
continue;
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
|
||||
if (plugin.getBlacklistHandler().isBlacklisted(event.getPlayer().getWorld())
|
||||
|| !event.getBlock().getType().name().contains("FURNACE"))
|
||||
return;
|
||||
|
||||
ItemStack item = event.getItemInHand();
|
||||
|
||||
Location location = event.getBlock().getLocation();
|
||||
|
||||
Furnace furnace = event.getItemInHand().getItemMeta().hasDisplayName() && plugin.getFurnceLevel(item) != 1
|
||||
? new FurnaceBuilder(location)
|
||||
.setLevel(plugin.getLevelManager().getLevel(plugin.getFurnceLevel(item)))
|
||||
.setUses(plugin.getFurnaceUses(item))
|
||||
.setPlacedBy(event.getPlayer().getUniqueId()).build()
|
||||
: new FurnaceBuilder(location).setPlacedBy(event.getPlayer().getUniqueId()).build();
|
||||
|
||||
plugin.getFurnaceManager().addFurnace(furnace);
|
||||
|
||||
plugin.updateHologram(furnace);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (!event.getPlayer().hasPermission("EpicFurnaces.overview") && !event.getPlayer().hasPermission("epicfurnaces.*")) {
|
||||
return;
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
if (!block.getType().name().contains("FURNACE")
|
||||
|| plugin.getBlacklistHandler().isBlacklisted(event.getPlayer().getWorld()))
|
||||
return;
|
||||
|
||||
Furnace furnace = plugin.getFurnaceManager().getFurnace(block);
|
||||
int level = plugin.getFurnaceManager().getFurnace(block).getLevel().getLevel();
|
||||
|
||||
plugin.clearHologram(furnace);
|
||||
|
||||
if (level != 0) {
|
||||
event.setCancelled(true);
|
||||
|
||||
ItemStack item = plugin.createLeveledFurnace(block.getType().name().contains("BURNING") ? Material.FURNACE
|
||||
: block.getType(), level, furnace.getUses());
|
||||
|
||||
event.getBlock().setType(Material.AIR);
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
|
||||
}
|
||||
plugin.getFurnaceManager().removeFurnace(block.getLocation());
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.songoda.epicfurnaces.listeners;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.furnace.Furnace;
|
||||
import com.songoda.epicfurnaces.furnace.levels.Level;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/26/2017.
|
||||
*/
|
||||
public class FurnaceListeners implements Listener {
|
||||
|
||||
private final EpicFurnaces plugin;
|
||||
|
||||
public FurnaceListeners(EpicFurnaces plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCook(FurnaceSmeltEvent event) {
|
||||
Block block = event.getBlock();
|
||||
if ((event.getBlock().isBlockPowered() && plugin.getConfig().getBoolean("Main.Redstone Deactivates Furnaces")) || event.getResult() == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Furnace furnace = plugin.getFurnaceManager().getFurnace(block.getLocation());
|
||||
|
||||
if (furnace != null && !event.getSource().getType().name().contains("SPONGE"))
|
||||
furnace.plus(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFuel(FurnaceBurnEvent event) {
|
||||
Furnace furnace = plugin.getFurnaceManager().getFurnace(event.getBlock().getLocation());
|
||||
|
||||
Level level = furnace != null ? furnace.getLevel() : plugin.getLevelManager().getLowestLevel();
|
||||
|
||||
if (level.getFuelDuration() != 0) return;
|
||||
|
||||
int num = level.getFuelDuration();
|
||||
int per = (event.getBurnTime() / 100) * num;
|
||||
event.setBurnTime(event.getBurnTime() + per);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.songoda.epicfurnaces.listeners;
|
||||
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/26/2017.
|
||||
*/
|
||||
public class InteractListeners implements Listener {
|
||||
|
||||
private final EpicFurnaces plugin;
|
||||
private final GuiManager guiManager;
|
||||
|
||||
public InteractListeners(EpicFurnaces plugin, GuiManager guiManager) {
|
||||
this.plugin = plugin;
|
||||
this.guiManager = guiManager;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onClick(PlayerInteractEvent event) {
|
||||
final Block block = event.getClickedBlock();
|
||||
if (block == null) return;
|
||||
|
||||
if (plugin.getBlacklistHandler().isBlacklisted(block.getWorld())) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK
|
||||
|| (!block.getType().name().contains("FURNACE"))
|
||||
|| player.isSneaking()
|
||||
|| player.getInventory().getItemInHand().getType().name().contains("PICKAXE")
|
||||
|| !player.hasPermission("EpicFurnaces.overview")) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
plugin.getFurnaceManager().getFurnace(block.getLocation()).overview(guiManager, player);
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.songoda.epicfurnaces.listeners;
|
||||
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/26/2017.
|
||||
*/
|
||||
public class InventoryListeners implements Listener {
|
||||
|
||||
private final EpicFurnaces plugin;
|
||||
|
||||
public InventoryListeners(EpicFurnaces plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryMove(InventoryMoveItemEvent event) {
|
||||
if (!event.getDestination().getType().equals(InventoryType.FURNACE)
|
||||
|| event.getDestination().getItem(0) == null
|
||||
|| event.getDestination().getItem(0).getType() != event.getItem().getType()
|
||||
|| event.getDestination().getItem(0).getAmount() != 1) {
|
||||
return;
|
||||
}
|
||||
plugin.getFurnaceManager().getFurnace(((org.bukkit.block.Furnace)
|
||||
event.getDestination().getHolder()).getLocation()).updateCook();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getSlot() != 64537) {
|
||||
if (event.getInventory().getType() == InventoryType.ANVIL) {
|
||||
if (event.getAction() != InventoryAction.NOTHING) {
|
||||
if (event.getCurrentItem().getType() != Material.AIR) {
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (item.getType().name().contains("FURNACE")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
109
src/main/java/com/songoda/epicfurnaces/settings/Settings.java
Normal file
109
src/main/java/com/songoda/epicfurnaces/settings/Settings.java
Normal file
@ -0,0 +1,109 @@
|
||||
package com.songoda.epicfurnaces.settings;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.configuration.ConfigSetting;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.hooks.HologramManager;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Settings {
|
||||
|
||||
static final Config config = EpicFurnaces.getInstance().getConfig().getCoreConfig();
|
||||
|
||||
public static final ConfigSetting UPGRADE_BY_SMELTING = new ConfigSetting(config, "Main.Upgrade By Smelting Materials", true);
|
||||
|
||||
public static final ConfigSetting UPGRADE_WITH_ECONOMY = new ConfigSetting(config, "Main.Upgrade With Economy", true,
|
||||
"Should you be able to upgrade furnaces with economy?");
|
||||
|
||||
public static final ConfigSetting UPGRADE_WITH_XP = new ConfigSetting(config, "Main.Upgrade With XP", true,
|
||||
"Should you be able to upgrade furnaces with experience?");
|
||||
|
||||
public static final ConfigSetting AUTOSAVE = new ConfigSetting(config, "Main.Auto Save Interval In Seconds", 15,
|
||||
"The amount of time in between saving to file.",
|
||||
"This is purely a safety function to prevent against unplanned crashes or",
|
||||
"restarts. With that said it is advised to keep this enabled.",
|
||||
"If however you enjoy living on the edge, feel free to turn it off.");
|
||||
|
||||
public static final ConfigSetting LEVEL_MULTIPLIER = new ConfigSetting(config, "Main.Level Cost Multiplier", 50);
|
||||
|
||||
public static final ConfigSetting FURNACE_ITEM = new ConfigSetting(config, "Main.Remember Furnace Item Levels", true,
|
||||
"Should furnace levels be remembered when broken?");
|
||||
|
||||
public static final ConfigSetting HOLOGRAM_PLUGIN = new ConfigSetting(config, "Main.Hologram",
|
||||
HologramManager.getHolograms() == null ? "HolographicDisplays" : HologramManager.getHolograms().getName(),
|
||||
"Which hologram plugin should be used?",
|
||||
"You can choose from \"" + HologramManager.getManager().getRegisteredPlugins().stream().collect(Collectors.joining(", ")) + "\".");
|
||||
|
||||
|
||||
public static final ConfigSetting HOLOGRAMS = new ConfigSetting(config, "Main.Furnaces Have Holograms", true);
|
||||
|
||||
public static final ConfigSetting REDSTONE_DEACTIVATES = new ConfigSetting(config, "Main.Redstone Deactivates Furnaces", true);
|
||||
|
||||
public static final ConfigSetting UPGRADE_COST = new ConfigSetting(config, "Main.Furnace Upgrade Cost", "IRON_INGOT");
|
||||
public static final ConfigSetting CUSTOM_RECIPES = new ConfigSetting(config, "Main.Use Custom Recipes", true);
|
||||
public static final ConfigSetting NO_REWARDS_FROM_RECIPES = new ConfigSetting(config, "Main.No Rewards From Custom Recipes", true);
|
||||
|
||||
public static final ConfigSetting PARTICLE_TYPE = new ConfigSetting(config, "Main.Upgrade Particle Type", "SPELL_WITCH",
|
||||
"The type of particle shown when a furnace is upgraded.");
|
||||
|
||||
public static final ConfigSetting REMOTE = new ConfigSetting(config, "Main.Access Furnaces Remotely", true);
|
||||
|
||||
public static final ConfigSetting TICK_SPEED = new ConfigSetting(config, "Main.Furnace Tick Speed", 10);
|
||||
public static final ConfigSetting OVERHEAT_PARTICLES = new ConfigSetting(config, "Main.Overheat Particles", true);
|
||||
|
||||
public static final ConfigSetting ECONOMY_PLUGIN = new ConfigSetting(config, "Main.Economy", EconomyManager.getEconomy() == null ? "Vault" : EconomyManager.getEconomy().getName(),
|
||||
"Which economy plugin should be used?",
|
||||
"Supported plugins you have installed: \"" + EconomyManager.getManager().getRegisteredPlugins().stream().collect(Collectors.joining("\", \"")) + "\".");
|
||||
|
||||
public static final ConfigSetting REWARD_ICON = new ConfigSetting(config, "Interfaces.Reward Icon", "GOLDEN_APPLE");
|
||||
public static final ConfigSetting PERFORMANCE_ICON = new ConfigSetting(config, "Interfaces.Performance Icon", "REDSTONE");
|
||||
public static final ConfigSetting FUEL_SHARE_ICON = new ConfigSetting(config, "Interfaces.FuelShare Icon", "COAL_BLOCK");
|
||||
public static final ConfigSetting FUEL_DURATION_ICON = new ConfigSetting(config, "Interfaces.FuelDuration Icon", "COAL");
|
||||
public static final ConfigSetting OVERHEAT_ICON = new ConfigSetting(config, "Interfaces.Overheat Icon", "FIRE_CHARGE");
|
||||
|
||||
public static final ConfigSetting ECO_ICON = new ConfigSetting(config, "Interfaces.Economy Icon", "SUNFLOWER");
|
||||
public static final ConfigSetting XP_ICON = new ConfigSetting(config, "Interfaces.XP Icon", "EXPERIENCE_BOTTLE");
|
||||
|
||||
public static final ConfigSetting GLASS_TYPE_1 = new ConfigSetting(config, "Interfaces.Glass Type 1", "GRAY_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GLASS_TYPE_2 = new ConfigSetting(config, "Interfaces.Glass Type 2", "BLUE_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GLASS_TYPE_3 = new ConfigSetting(config, "Interfaces.Glass Type 3", "LIGHT_BLUE_STAINED_GLASS_PANE");
|
||||
|
||||
public static final ConfigSetting LANGUGE_MODE = new ConfigSetting(config, "System.Language Mode", "en_US",
|
||||
"The enabled language file.",
|
||||
"More language files (if available) can be found in the plugins data folder.");
|
||||
|
||||
/**
|
||||
* In order to set dynamic economy comment correctly, this needs to be
|
||||
* called after EconomyManager load
|
||||
*/
|
||||
public static void setupConfig() {
|
||||
config.load();
|
||||
config.setAutoremove(true).setAutosave(true);
|
||||
|
||||
// convert glass pane settings
|
||||
int color;
|
||||
if ((color = GLASS_TYPE_1.getInt(-1)) != -1) {
|
||||
config.set(GLASS_TYPE_1.getKey(), CompatibleMaterial.getGlassPaneColor(color).name());
|
||||
}
|
||||
if ((color = GLASS_TYPE_2.getInt(-1)) != -1) {
|
||||
config.set(GLASS_TYPE_2.getKey(), CompatibleMaterial.getGlassPaneColor(color).name());
|
||||
}
|
||||
if ((color = GLASS_TYPE_3.getInt(-1)) != -1) {
|
||||
config.set(GLASS_TYPE_3.getKey(), CompatibleMaterial.getGlassPaneColor(color).name());
|
||||
}
|
||||
|
||||
// convert economy settings
|
||||
if (config.getBoolean("Economy.Use Vault Economy") && EconomyManager.getManager().isEnabled("Vault")) {
|
||||
config.set("Main.Economy", "Vault");
|
||||
} else if (config.getBoolean("Economy.Use Reserve Economy") && EconomyManager.getManager().isEnabled("Reserve")) {
|
||||
config.set("Main.Economy", "Reserve");
|
||||
} else if (config.getBoolean("Economy.Use Player Points Economy") && EconomyManager.getManager().isEnabled("PlayerPoints")) {
|
||||
config.set("Main.Economy", "PlayerPoints");
|
||||
}
|
||||
|
||||
config.saveChanges();
|
||||
}
|
||||
}
|
67
src/main/java/com/songoda/epicfurnaces/storage/Storage.java
Normal file
67
src/main/java/com/songoda/epicfurnaces/storage/Storage.java
Normal file
@ -0,0 +1,67 @@
|
||||
package com.songoda.epicfurnaces.storage;
|
||||
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.boost.BoostData;
|
||||
import com.songoda.epicfurnaces.furnace.Furnace;
|
||||
import com.songoda.epicfurnaces.utils.Methods;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Storage {
|
||||
|
||||
protected final EpicFurnaces plugin;
|
||||
protected final Config dataFile;
|
||||
|
||||
|
||||
public Storage(EpicFurnaces plugin) {
|
||||
this.plugin = plugin;
|
||||
this.dataFile = new Config(plugin, "data.yml");
|
||||
this.dataFile.load();
|
||||
}
|
||||
|
||||
public abstract boolean containsGroup(String group);
|
||||
|
||||
public abstract List<StorageRow> getRowsByGroup(String group);
|
||||
|
||||
public abstract void prepareSaveItem(String group, StorageItem... items);
|
||||
|
||||
public void updateData(EpicFurnaces plugin) {
|
||||
/*
|
||||
* Dump FurnaceManager to file.
|
||||
*/
|
||||
for (Furnace furnace : plugin.getFurnaceManager().getFurnaces().values()) {
|
||||
if (furnace == null
|
||||
|| furnace.getLocation() == null
|
||||
|| furnace.getLocation().getWorld() == null
|
||||
|| furnace.getLevel() == null) continue;
|
||||
String locationStr = Methods.serializeLocation(furnace.getLocation());
|
||||
|
||||
prepareSaveItem("charged", new StorageItem("location", locationStr),
|
||||
new StorageItem("level", furnace.getLevel().getLevel()),
|
||||
new StorageItem("uses", furnace.getUses()),
|
||||
new StorageItem("tolevel", furnace.getTolevel()),
|
||||
new StorageItem("nickname", furnace.getNickname()),
|
||||
new StorageItem("accesslist", furnace.getOriginalAccessList()),
|
||||
new StorageItem("placedby", furnace.getPlacedBy() == null ? null : furnace.getPlacedBy().toString()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump BoostManager to file.
|
||||
*/
|
||||
for (BoostData boostData : plugin.getBoostManager().getBoosts()) {
|
||||
prepareSaveItem("boosts", new StorageItem("endtime", String.valueOf(boostData.getEndTime())),
|
||||
new StorageItem("amount", boostData.getMultiplier()),
|
||||
new StorageItem("uuid", boostData.getPlayer().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void doSave();
|
||||
|
||||
public abstract void save();
|
||||
|
||||
public abstract void makeBackup();
|
||||
|
||||
public abstract void closeConnection();
|
||||
|
||||
}
|
@ -1,13 +1,15 @@
|
||||
package com.songoda.epicfurnaces.storage;
|
||||
|
||||
import com.songoda.epicfurnaces.utils.Methods;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StorageItem {
|
||||
|
||||
private String key = null;
|
||||
|
||||
private final Object object;
|
||||
private String key = null;
|
||||
|
||||
public StorageItem(Object object) {
|
||||
this.object = object;
|
||||
@ -27,6 +29,16 @@ public class StorageItem {
|
||||
this.object = object.toString();
|
||||
}
|
||||
|
||||
public StorageItem(String key, boolean type, List<Location> blocks) {
|
||||
StringBuilder object = new StringBuilder();
|
||||
for (Location location : blocks) {
|
||||
object.append(Methods.serializeLocation(location));
|
||||
object.append(";;");
|
||||
}
|
||||
this.key = key;
|
||||
this.object = object.toString();
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
@ -38,6 +50,7 @@ public class StorageItem {
|
||||
|
||||
public boolean asBoolean() {
|
||||
if (object == null) return false;
|
||||
if (object instanceof Integer) return (Integer) object == 1;
|
||||
return (boolean) object;
|
||||
}
|
||||
|
||||
@ -47,6 +60,8 @@ public class StorageItem {
|
||||
}
|
||||
|
||||
public Object asObject() {
|
||||
if (object == null) return null;
|
||||
if (object instanceof Boolean) return (Boolean) object ? 1 : 0;
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -61,4 +76,5 @@ public class StorageItem {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicfurnaces.storage.types;
|
||||
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.storage.Storage;
|
||||
import com.songoda.epicfurnaces.storage.StorageItem;
|
||||
@ -12,30 +13,30 @@ import java.util.*;
|
||||
|
||||
public class StorageYaml extends Storage {
|
||||
|
||||
private static final Map<String, Object> toSave = new HashMap<>();
|
||||
private static final Map<String, Object> lastSave = new HashMap<>();
|
||||
private final Map<String, Object> toSave = new HashMap<>();
|
||||
private Map<String, Object> lastSave = null;
|
||||
|
||||
public StorageYaml(EpicFurnaces instance) {
|
||||
super(instance);
|
||||
public StorageYaml(EpicFurnaces plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsGroup(String group) {
|
||||
return dataFile.getConfig().contains("data." + group);
|
||||
return dataFile.contains("data." + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageRow> getRowsByGroup(String group) {
|
||||
List<StorageRow> rows = new ArrayList<>();
|
||||
ConfigurationSection currentSection = dataFile.getConfig().getConfigurationSection("data." + group);
|
||||
ConfigurationSection currentSection = dataFile.getConfigurationSection("data." + group);
|
||||
for (String key : currentSection.getKeys(false)) {
|
||||
|
||||
Map<String, StorageItem> items = new HashMap<>();
|
||||
ConfigurationSection currentSection2 = dataFile.getConfig().getConfigurationSection("data." + group + "." + key);
|
||||
ConfigurationSection currentSection2 = dataFile.getConfigurationSection("data." + group + "." + key);
|
||||
for (String key2 : currentSection2.getKeys(false)) {
|
||||
String path = "data." + group + "." + key + "." + key2;
|
||||
items.put(key2, new StorageItem(dataFile.getConfig().get(path) instanceof MemorySection
|
||||
? convertToInLineList(path) : dataFile.getConfig().get(path)));
|
||||
items.put(key2, new StorageItem(dataFile.get(path) instanceof MemorySection
|
||||
? convertToInLineList(path) : dataFile.get(path)));
|
||||
}
|
||||
if (items.isEmpty()) continue;
|
||||
StorageRow row = new StorageRow(key, items);
|
||||
@ -46,8 +47,8 @@ public class StorageYaml extends Storage {
|
||||
|
||||
private String convertToInLineList(String path) {
|
||||
StringBuilder converted = new StringBuilder();
|
||||
for (String key : dataFile.getConfig().getConfigurationSection(path).getKeys(false)) {
|
||||
converted.append(key).append(":").append(dataFile.getConfig().getInt(path + "." + key)).append(";");
|
||||
for (String key : dataFile.getConfigurationSection(path).getKeys(false)) {
|
||||
converted.append(key).append(":").append(dataFile.getInt(path + "." + key)).append(";");
|
||||
}
|
||||
return converted.toString();
|
||||
}
|
||||
@ -56,19 +57,20 @@ public class StorageYaml extends Storage {
|
||||
public void prepareSaveItem(String group, StorageItem... items) {
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
toSave.put("data." + group + "." + items[0].asObject()+ "." + item.getKey(), item.asObject());
|
||||
toSave.put("data." + group + "." + items[0].asString() + "." + item.getKey(), item.asObject());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSave() {
|
||||
this.updateData(instance);
|
||||
this.updateData(plugin);
|
||||
|
||||
if (lastSave == null)
|
||||
lastSave = new HashMap<>(toSave);
|
||||
|
||||
if (toSave.isEmpty()) return;
|
||||
Map<String, Object> nextSave = new HashMap<>(toSave);
|
||||
|
||||
if (lastSave.isEmpty())
|
||||
lastSave.putAll(toSave);
|
||||
|
||||
this.makeBackup();
|
||||
this.save();
|
||||
|
||||
@ -84,19 +86,19 @@ public class StorageYaml extends Storage {
|
||||
if (toSave.containsKey(entry.getKey())) {
|
||||
Object newValue = toSave.get(entry.getKey());
|
||||
if (!entry.getValue().equals(newValue)) {
|
||||
dataFile.getConfig().set(entry.getKey(), entry.getValue());
|
||||
dataFile.set(entry.getKey(), newValue);
|
||||
}
|
||||
toSave.remove(newValue);
|
||||
toSave.remove(entry.getKey());
|
||||
} else {
|
||||
dataFile.getConfig().set(entry.getKey(), null);
|
||||
dataFile.set(entry.getKey(), null);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Object> entry : toSave.entrySet()) {
|
||||
dataFile.getConfig().set(entry.getKey(), entry.getValue());
|
||||
dataFile.set(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
dataFile.saveConfig();
|
||||
dataFile.save();
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -104,15 +106,15 @@ public class StorageYaml extends Storage {
|
||||
|
||||
@Override
|
||||
public void makeBackup() {
|
||||
File data = new File(instance.getDataFolder(), "data.yml");
|
||||
File dataClone = new File(instance.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml");
|
||||
File data = new File(plugin.getDataFolder(), "data.yml");
|
||||
File dataClone = new File(plugin.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml");
|
||||
try {
|
||||
copyFile(data, dataClone);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Deque<File> backups = new ArrayDeque<>();
|
||||
for (File file : Objects.requireNonNull(instance.getDataFolder().listFiles())) {
|
||||
for (File file : Objects.requireNonNull(plugin.getDataFolder().listFiles())) {
|
||||
if (file.getName().toLowerCase().contains("data-backup")) {
|
||||
backups.add(file);
|
||||
}
|
||||
@ -124,10 +126,9 @@ public class StorageYaml extends Storage {
|
||||
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
dataFile.saveConfig();
|
||||
dataFile.save();
|
||||
}
|
||||
|
||||
|
||||
private static void copyFile(File source, File dest) throws IOException {
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
147
src/main/java/com/songoda/epicfurnaces/tasks/FurnaceTask.java
Normal file
147
src/main/java/com/songoda/epicfurnaces/tasks/FurnaceTask.java
Normal file
@ -0,0 +1,147 @@
|
||||
package com.songoda.epicfurnaces.tasks;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleParticleHandler;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.furnace.Furnace;
|
||||
import com.songoda.epicfurnaces.settings.Settings;
|
||||
import java.util.HashSet;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class FurnaceTask extends BukkitRunnable {
|
||||
|
||||
private static FurnaceTask instance;
|
||||
|
||||
private final EpicFurnaces plugin;
|
||||
final HashSet<Location> toRemove = new HashSet();
|
||||
boolean doParticles;
|
||||
|
||||
private FurnaceTask(EpicFurnaces plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static FurnaceTask startTask(EpicFurnaces plugin) {
|
||||
if (instance == null) {
|
||||
instance = new FurnaceTask(plugin);
|
||||
instance.runTaskTimer(plugin, 0, Settings.TICK_SPEED.getInt());
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
doParticles = Settings.OVERHEAT_PARTICLES.getBoolean();
|
||||
plugin.getFurnaceManager().getFurnaces().values().stream()
|
||||
.filter(Furnace::isInLoadedChunk)
|
||||
.forEach(furnace -> {
|
||||
Location location = furnace.getLocation();
|
||||
BlockState state = location.getBlock().getState();
|
||||
|
||||
if (!(state instanceof org.bukkit.block.Furnace)) {
|
||||
toRemove.add(location);
|
||||
} else if (((org.bukkit.block.Furnace) state).getBurnTime() != 0) {
|
||||
if (furnace.getLevel().getOverheat() != 0) {
|
||||
overheat(furnace);
|
||||
}
|
||||
if (furnace.getLevel().getFuelShare() != 0) {
|
||||
fuelshare(furnace);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!toRemove.isEmpty()) {
|
||||
toRemove.stream().forEach(l -> plugin.getFurnaceManager().removeFurnace(l));
|
||||
toRemove.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void overheat(Furnace furnace) {
|
||||
if (furnace.getRadius(true) == null || furnace.getRadiusLast(true) != furnace.getLevel().getOverheat()) {
|
||||
furnace.setRadiusLast(furnace.getLevel().getOverheat(), true);
|
||||
cache(furnace, true);
|
||||
}
|
||||
|
||||
for (Location location : furnace.getRadius(true)) {
|
||||
int random = ThreadLocalRandom.current().nextInt(0, 10);
|
||||
|
||||
if (random != 1) continue;
|
||||
|
||||
Block block = location.getBlock();
|
||||
|
||||
if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR) continue;
|
||||
|
||||
if (block.getType() == Material.SNOW)
|
||||
block.setType(Material.AIR);
|
||||
else if (block.getType() == Material.ICE || block.getType() == Material.PACKED_ICE)
|
||||
block.setType(Material.WATER);
|
||||
else
|
||||
continue;
|
||||
|
||||
if (doParticles) {
|
||||
float xx = (float) (0 + (Math.random() * .75));
|
||||
float yy = (float) (0 + (Math.random() * 1));
|
||||
float zz = (float) (0 + (Math.random() * .75));
|
||||
CompatibleParticleHandler.spawnParticles(CompatibleParticleHandler.ParticleType.SMOKE_NORMAL, location, 25, xx, yy, zz, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fuelshare(Furnace furnace) {
|
||||
if (furnace.getRadius(false) == null || furnace.getRadiusLast(false) != furnace.getLevel().getOverheat()) {
|
||||
furnace.setRadiusLast(furnace.getLevel().getOverheat(), false);
|
||||
cache(furnace, false);
|
||||
}
|
||||
|
||||
for (Location location : furnace.getRadius(false)) {
|
||||
int random = ThreadLocalRandom.current().nextInt(0, 10);
|
||||
|
||||
if (random != 1) continue;
|
||||
|
||||
Block block = location.getBlock();
|
||||
|
||||
if (!block.getType().name().contains("FURNACE")) continue;
|
||||
Furnace furnace1 = plugin.getFurnaceManager().getFurnace(block);
|
||||
if (furnace == furnace1) continue;
|
||||
org.bukkit.block.Furnace furnaceBlock = ((org.bukkit.block.Furnace) block.getState());
|
||||
if (furnaceBlock.getBurnTime() == 0) {
|
||||
furnaceBlock.setBurnTime((short) 100);
|
||||
furnaceBlock.update();
|
||||
|
||||
if (doParticles) {
|
||||
|
||||
float xx = (float) (0 + (Math.random() * .75));
|
||||
float yy = (float) (0 + (Math.random() * 1));
|
||||
float zz = (float) (0 + (Math.random() * .75));
|
||||
|
||||
CompatibleParticleHandler.spawnParticles(CompatibleParticleHandler.ParticleType.SMOKE_NORMAL, location, 25, xx, yy, zz, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cache(Furnace furnace, boolean overheat) {
|
||||
Block block = furnace.getLocation().getBlock();
|
||||
int radius = 3 * (overheat ? furnace.getLevel().getOverheat() : furnace.getLevel().getFuelShare());
|
||||
int rSquared = radius * radius;
|
||||
int bx = block.getX();
|
||||
int by = block.getY();
|
||||
int bz = block.getZ();
|
||||
|
||||
for (int fx = -radius; fx <= radius; fx++) {
|
||||
for (int fy = -2; fy <= 1; fy++) {
|
||||
for (int fz = -radius; fz <= radius; fz++) {
|
||||
if ((fx * fx) + (fz * fz) <= rSquared) {
|
||||
Location location = new Location(block.getWorld(), bx + fx, by + fy, bz + fz);
|
||||
furnace.addToRadius(location, overheat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.songoda.epicfurnaces.tasks;
|
||||
|
||||
import com.songoda.core.hooks.HologramManager;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.furnace.Furnace;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class HologramTask extends BukkitRunnable {
|
||||
|
||||
private static HologramTask instance;
|
||||
|
||||
private final EpicFurnaces plugin;
|
||||
|
||||
private HologramTask(EpicFurnaces plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static HologramTask startTask(EpicFurnaces plugin) {
|
||||
if (instance == null) {
|
||||
instance = new HologramTask(plugin);
|
||||
instance.runTaskTimer(plugin, 0, 10);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!HologramManager.getManager().isEnabled()) return;
|
||||
|
||||
for (Furnace furnace : plugin.getFurnaceManager().getFurnaces().values()) {
|
||||
plugin.updateHologram(furnace);
|
||||
}
|
||||
}
|
||||
}
|
18
src/main/java/com/songoda/epicfurnaces/utils/CostType.java
Normal file
18
src/main/java/com/songoda/epicfurnaces/utils/CostType.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.songoda.epicfurnaces.utils;
|
||||
|
||||
/**
|
||||
* Represents a cost type when making a purchase from EpicFurnaces
|
||||
*/
|
||||
public enum CostType {
|
||||
|
||||
/**
|
||||
* A purchase made with an economy balance (generally an implementation of Vault)
|
||||
*/
|
||||
ECONOMY,
|
||||
|
||||
/**
|
||||
* A purchase made with a player's experience levels
|
||||
*/
|
||||
EXPERIENCE
|
||||
|
||||
}
|
196
src/main/java/com/songoda/epicfurnaces/utils/Methods.java
Normal file
196
src/main/java/com/songoda/epicfurnaces/utils/Methods.java
Normal file
@ -0,0 +1,196 @@
|
||||
package com.songoda.epicfurnaces.utils;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/25/2017.
|
||||
*/
|
||||
public class Methods {
|
||||
|
||||
public static String cleanString(String typ) {
|
||||
String type = typ.replaceAll("_", " ");
|
||||
type = ChatColor.stripColor(type.substring(0, 1).toUpperCase() + type.toLowerCase().substring(1));
|
||||
return type;
|
||||
}
|
||||
|
||||
public static String formatName(int level, int uses, boolean full) {
|
||||
String name = EpicFurnaces.getInstance().getLocale().getMessage("general.nametag.nameformat")
|
||||
.processPlaceholder("level", level).getMessage();
|
||||
|
||||
String info = "";
|
||||
if (full) {
|
||||
info += convertToInvisibleString(level + ":" + uses + ":");
|
||||
}
|
||||
|
||||
return info + formatText(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the location of the block specified.
|
||||
*
|
||||
* @param b The block whose location is to be saved.
|
||||
* @return The serialized data.
|
||||
*/
|
||||
public static String serializeLocation(Block b) {
|
||||
if (b == null)
|
||||
return "";
|
||||
return serializeLocation(b.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the location specified.
|
||||
*
|
||||
* @param location The location that is to be saved.
|
||||
* @return The serialized data.
|
||||
*/
|
||||
public static String serializeLocation(Location location) {
|
||||
if (location == null)
|
||||
return "";
|
||||
String w = location.getWorld().getName();
|
||||
double x = location.getBlockX();
|
||||
double y = location.getBlockY();
|
||||
double z = location.getBlockZ();
|
||||
String str = w + ":" + x + ":" + y + ":" + z;
|
||||
str = str.replace(".0", "").replace("/", "");
|
||||
return str;
|
||||
}
|
||||
private static Map<String, Location> serializeCache = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Deserializes a location from the string.
|
||||
*
|
||||
* @param str The string to parse.
|
||||
* @return The location that was serialized in the string.
|
||||
*/
|
||||
public static Location unserializeLocation(String str) {
|
||||
if (str == null || str.equals(""))
|
||||
return null;
|
||||
if (serializeCache.containsKey(str)) {
|
||||
return serializeCache.get(str).clone();
|
||||
}
|
||||
String cacheKey = str;
|
||||
str = str.replace("y:", ":").replace("z:", ":").replace("w:", "").replace("x:", ":").replace("/", ".");
|
||||
List<String> args = Arrays.asList(str.split("\\s*:\\s*"));
|
||||
|
||||
World world = Bukkit.getWorld(args.get(0));
|
||||
double x = Double.parseDouble(args.get(1)), y = Double.parseDouble(args.get(2)), z = Double.parseDouble(args.get(3));
|
||||
Location location = new Location(world, x, y, z, 0, 0);
|
||||
serializeCache.put(cacheKey, location.clone());
|
||||
return location;
|
||||
}
|
||||
|
||||
|
||||
public static String convertToInvisibleString(String s) {
|
||||
if (s == null || s.equals(""))
|
||||
return "";
|
||||
StringBuilder hidden = new StringBuilder();
|
||||
for (char c : s.toCharArray()) hidden.append(ChatColor.COLOR_CHAR + "").append(c);
|
||||
return hidden.toString();
|
||||
}
|
||||
|
||||
public static String formatText(String text) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
return formatText(text, false);
|
||||
}
|
||||
|
||||
public static String formatText(String text, boolean cap) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
if (cap)
|
||||
text = text.substring(0, 1).toUpperCase() + text.substring(1);
|
||||
return ChatColor.translateAlternateColorCodes('&', text);
|
||||
}
|
||||
|
||||
public static boolean isInt(String number) {
|
||||
if (number == null || number.equals(""))
|
||||
return false;
|
||||
try {
|
||||
Integer.parseInt(number);
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String makeReadable(Long time) {
|
||||
if (time == null)
|
||||
return "";
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
long days = TimeUnit.MILLISECONDS.toDays(time);
|
||||
long hours = TimeUnit.MILLISECONDS.toHours(time) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(time));
|
||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(time) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time));
|
||||
long seconds = TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time));
|
||||
|
||||
if (days != 0L)
|
||||
sb.append(" ").append(days).append("d");
|
||||
if (hours != 0L)
|
||||
sb.append(" ").append(hours).append("h");
|
||||
if (minutes != 0L)
|
||||
sb.append(" ").append(minutes).append("m");
|
||||
if (seconds != 0L)
|
||||
sb.append(" ").append(seconds).append("s");
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
|
||||
public static long parseTime(String input) {
|
||||
long result = 0;
|
||||
StringBuilder number = new StringBuilder();
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char c = input.charAt(i);
|
||||
if (Character.isDigit(c)) {
|
||||
number.append(c);
|
||||
} else if (Character.isLetter(c) && (number.length() > 0)) {
|
||||
result += convert(Integer.parseInt(number.toString()), c);
|
||||
number = new StringBuilder();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static long convert(long value, char unit) {
|
||||
switch (unit) {
|
||||
case 'd':
|
||||
return value * 1000 * 60 * 60 * 24;
|
||||
case 'h':
|
||||
return value * 1000 * 60 * 60;
|
||||
case 'm':
|
||||
return value * 1000 * 60;
|
||||
case 's':
|
||||
return value * 1000;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String formatEconomy(double amt) {
|
||||
DecimalFormat formatter = new DecimalFormat("#,###.00");
|
||||
return formatter.format(amt);
|
||||
}
|
||||
|
||||
public static String formatTitle(String text) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
|
||||
if (text.length() > 31)
|
||||
text = text.substring(0, 29) + "...";
|
||||
}
|
||||
text = formatText(text);
|
||||
return text;
|
||||
}
|
||||
}
|
11
src/main/resources/Furnace Recipes.yml
Normal file
11
src/main/resources/Furnace Recipes.yml
Normal file
@ -0,0 +1,11 @@
|
||||
# EpicFurnaces furnace Recipe file
|
||||
Recipes:
|
||||
DIAMOND_SWORD:
|
||||
result: DIAMOND
|
||||
amount: 2
|
||||
DIAMOND_PICKAXE:
|
||||
result: DIAMOND
|
||||
amount: 3
|
||||
DIAMOND_AXE:
|
||||
result: DIAMOND
|
||||
amount: 3
|
16
src/main/resources/SettingDefinitions.yml
Normal file
16
src/main/resources/SettingDefinitions.yml
Normal file
@ -0,0 +1,16 @@
|
||||
ECO-Icon: 'This is the icon players will use to upgrade with Economy.'
|
||||
XP-Icon: 'This is the icon players will use to upgrade with EXP.'
|
||||
Upgrade-with-material: 'When enabled players will be able to smelt materials defined in the config to upgrade furnaces.'
|
||||
Upgrade-with-eco: 'If enabled players will optionally be able to use Economy to upgrade their furnaces.'
|
||||
Upgrade-with-xp: 'If enabled players will optionally be able to use XP to upgrade their furnaces.'
|
||||
Turbo-level-multiplier: 'This is the amount the cost for each level, it is multiplied by the level you are currently on. So if the next level is 3 then the cost would be 100.'
|
||||
On-upgrade-particles: 'If set to true particles will be generated on upgrade.'
|
||||
Helpful-Tips: 'If this is enabled tips will be displayed to guide you on how to use the plugin.'
|
||||
Glass-Type: 'This is the id of the glass used for the background in the guis.'
|
||||
Rainbow-Glass: 'If this is enabled the glass background will be randomized colors.'
|
||||
Furnace-upgrade-cost: 'This is the material that an upgrade will cost.'
|
||||
Custom-recipes: 'If set to true custom recipes will be loaded from the recipe config.'
|
||||
Ignore-custom-recipes-for-rewards: 'If set to true custom recipes wont count towards rewards. This is to prevent abuse.'
|
||||
Reward-Icon: 'This is the icon players will use to upgrade reward.'
|
||||
Performance-Icon: 'This is the icon players will use to upgrade performance.'
|
||||
FuelDuration-Icon: 'This is the icon players will use to upgrade Fuel Duration.'
|
55
src/main/resources/en_US.lang
Normal file
55
src/main/resources/en_US.lang
Normal file
@ -0,0 +1,55 @@
|
||||
#General Messages
|
||||
|
||||
general.nametag.prefix = "&8[&6EpicFurnaces&8]"
|
||||
general.nametag.next = "&9Next"
|
||||
general.nametag.back = "&9Back"
|
||||
general.nametag.nameformat = "&eLevel %level% &fFurnace"
|
||||
general.hologram.outoffuel = "&cNo Fuel"
|
||||
general.hologram.stats = "&a%in%&7/&c%out%"
|
||||
|
||||
#Interface Messages
|
||||
|
||||
interface.furnace.upgradewithxp = "&aUpgrade with XP"
|
||||
interface.furnace.upgradewithxplore = "&7Cost: &a%cost% Levels"
|
||||
interface.furnace.upgradewitheconomy = "&aUpgrade with ECO"
|
||||
interface.furnace.upgradewitheconomylore = "&7Cost: &a$%cost%"
|
||||
interface.furnace.currentlevel = "&6Furnace Level &7%level%"
|
||||
interface.furnace.level = "&6Next Level &7%level%"
|
||||
interface.furnace.performance = "&7Performance: &6%amount%"
|
||||
interface.furnace.reward = "&7Reward: &6%amount%"
|
||||
interface.furnace.performancetitle = "&a&lPerformance"
|
||||
interface.furnace.rewardtitle = "&c&lReward"
|
||||
interface.furnace.fueldurationtitle = "&7&lFuel Duration"
|
||||
interface.furnace.fuelduration = "&7Fuel Duration: &6%amount%"
|
||||
interface.furnace.fuelshare = "&7Fuel Share: &6%amount%&7."
|
||||
interface.furnace.fuelsharetitle = "&6&lFuel Share"
|
||||
interface.furnace.fuelshareinfo = "&7This furnace will power other|&7furnaces within a &6%amount%&7 block radius."
|
||||
interface.furnace.overheat = "&7Overheat: &6%amount%&7."
|
||||
interface.furnace.overheattitle = "&6&lOverheat"
|
||||
interface.furnace.overheatinfo = "&7This furnace will melt snow |&7and ice within a &6%amount%&7 block radius."
|
||||
interface.furnace.performanceinfo = "&7This furnaces performance is |&7currently boosted an extra &6%amount%%&7. | |&7Performance boosts the speed in |&7which a furnace processes |&7materials."
|
||||
interface.furnace.rewardinfo = "&7This furnace currently |&7has a &6%amount%%&7 chance of |&7producing multiple resources."
|
||||
interface.furnace.fueldurationinfo = "&7This furnaces fuel duration is |&7currently boosted by &6%amount%%&7. | |&7Fuel Duration boosts how long |&7fuel in the furnace lasts."
|
||||
interface.furnace.smeltedx = "&7Smelted &6%amount% Materials&7."
|
||||
interface.furnace.tolevel = "&6%amount% %type%s &7away from leveling up."
|
||||
interface.furnace.remotefurnace = "&5&lRemote Control"
|
||||
interface.furnace.remotefurnacelore = "&7Left-Click to assign a nickname.|&7Right-Click to give yourself |&7remote access.|&7Current nickname is: &6%nickname%&7."
|
||||
interface.furnace.utilize = "|&7To utilize remote access|&7use the command:|&6/EF Remote %nickname%"
|
||||
interface.furnace.remotelist = "&7Players with remote access:"
|
||||
interface.furnace.alreadymaxed = "&7This furnace is already maxed out!"
|
||||
interface.button.boostedstats = "&a&lCurrently boosted!|&7Reward multiplied by &6%amount%x&7.|&7Expires in &6%time%&7."
|
||||
|
||||
#Command Messages
|
||||
|
||||
command.give.success = "&7You have been given a &6level %level% &7Furnace."
|
||||
|
||||
#Event Messages
|
||||
|
||||
event.general.nopermission = "&cYou do not have permission to do that."
|
||||
event.upgrade.cannotafford = "&cYou cannot afford this upgrade."
|
||||
event.upgrade.success = "&7You successfully upgraded this furnace to &6level %level%&7!"
|
||||
event.upgrade.maxed = "&7You maxed out this furnace at &6level %level%&7."
|
||||
event.remote.enter = "&7Enter a unique nickname for the furnace."
|
||||
event.remote.notfound = "&cRemote furnace not found."
|
||||
event.remote.nicknamesuccess = "&aNickname set successfully."
|
||||
event.remote.nicknameinuse = "&cThat nickname is already in use."
|
37
src/main/resources/levels.yml
Normal file
37
src/main/resources/levels.yml
Normal file
@ -0,0 +1,37 @@
|
||||
Level-1:
|
||||
Performance: 10%
|
||||
Reward: 10%:1
|
||||
Cost-xp: 20
|
||||
Cost-eco: 5000
|
||||
Level-2:
|
||||
Performance: 25%
|
||||
Reward: 20%:1-2
|
||||
Cost-xp: 25
|
||||
Cost-eco: 7500
|
||||
Level-3:
|
||||
Performance: 40%
|
||||
Reward: 35%:2-3
|
||||
Fuel-duration: 10%
|
||||
Cost-xp: 30
|
||||
Cost-eco: 10000
|
||||
Level-4:
|
||||
Performance: 55%
|
||||
Reward: 50%:2-4
|
||||
Fuel-duration: 25%
|
||||
Cost-xp: 35
|
||||
Cost-eco: 12000
|
||||
Level-5:
|
||||
Performance: 75%
|
||||
Reward: 70%:3-4
|
||||
Fuel-duration: 45%
|
||||
Overheat: 1
|
||||
Cost-xp: 40
|
||||
Cost-eco: 15000
|
||||
Level-6:
|
||||
Performance: 75%
|
||||
Reward: 70%:3-4
|
||||
Fuel-duration: 45%
|
||||
Overheat: 2
|
||||
Fuel-share: 1
|
||||
Cost-xp: 40
|
||||
Cost-eco: 15000
|
13
src/main/resources/plugin.yml
Normal file
13
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,13 @@
|
||||
name: EpicFurnaces
|
||||
description: EpicFurnaces
|
||||
version: maven-version-number
|
||||
softdepend: [HolographicDisplays, PlotSquared, GriefPrevention, USkyBlock, SkyBlock, WorldGuard, Factions]
|
||||
main: com.songoda.epicfurnaces.EpicFurnaces
|
||||
author: songoda
|
||||
api-version: 1.13
|
||||
commands:
|
||||
EpicFurnaces:
|
||||
description: I have no idea.
|
||||
default: true
|
||||
aliases: [ef]
|
||||
usage: /<command> [reload]
|
Loading…
Reference in New Issue
Block a user