mirror of
https://github.com/songoda/EpicBuckets.git
synced 2024-11-29 05:36:07 +01:00
Merge branch 'development' into 'master'
1.14 See merge request Songoda/epicbuckets!4
This commit is contained in:
commit
615566015b
@ -4,7 +4,7 @@ stages:
|
|||||||
variables:
|
variables:
|
||||||
name: "EpicBuckets"
|
name: "EpicBuckets"
|
||||||
path: "/builds/$CI_PROJECT_PATH"
|
path: "/builds/$CI_PROJECT_PATH"
|
||||||
version: "1.5.3"
|
version: "1.6"
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
@ -15,6 +15,9 @@ import com.songoda.epicbuckets.utils.Debugger;
|
|||||||
import com.songoda.epicbuckets.utils.ServerVersion;
|
import com.songoda.epicbuckets.utils.ServerVersion;
|
||||||
import com.songoda.epicbuckets.utils.hooks.ClaimableProtectionPluginHook;
|
import com.songoda.epicbuckets.utils.hooks.ClaimableProtectionPluginHook;
|
||||||
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
|
import com.songoda.epicbuckets.utils.hooks.ProtectionPluginHook;
|
||||||
|
import com.songoda.epicbuckets.utils.updateModules.LocaleModule;
|
||||||
|
import com.songoda.update.Plugin;
|
||||||
|
import com.songoda.update.SongodaUpdate;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -24,7 +27,14 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -68,6 +78,11 @@ public class EpicBuckets extends JavaPlugin {
|
|||||||
Locale.saveDefaultLocale("en_US");
|
Locale.saveDefaultLocale("en_US");
|
||||||
this.locale = Locale.getLocale(getConfig().getString("Locale", "en_US"));
|
this.locale = Locale.getLocale(getConfig().getString("Locale", "en_US"));
|
||||||
|
|
||||||
|
//Running Songoda Updater
|
||||||
|
Plugin plugin = new Plugin(this, 27);
|
||||||
|
plugin.addModule(new LocaleModule());
|
||||||
|
SongodaUpdate.load(plugin);
|
||||||
|
|
||||||
this.references = new References();
|
this.references = new References();
|
||||||
|
|
||||||
debugger = new Debugger();
|
debugger = new Debugger();
|
||||||
|
@ -3,7 +3,7 @@ package com.songoda.epicbuckets;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
|||||||
public class Locale {
|
public class Locale {
|
||||||
|
|
||||||
private static final List<Locale> LOCALES = Lists.newArrayList();
|
private static final List<Locale> LOCALES = Lists.newArrayList();
|
||||||
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.{1}\\w+)*)\\s*=\\s*\"(.*)\"");
|
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.\\w+)*)\\s*=\\s*\"(.*)\"");
|
||||||
private static final String FILE_EXTENSION = ".lang";
|
private static final String FILE_EXTENSION = ".lang";
|
||||||
private static JavaPlugin plugin;
|
private static JavaPlugin plugin;
|
||||||
private static File localeFolder;
|
private static File localeFolder;
|
||||||
@ -48,7 +48,7 @@ public class Locale {
|
|||||||
|
|
||||||
if (this.reloadMessages()) return;
|
if (this.reloadMessages()) return;
|
||||||
|
|
||||||
plugin.getLogger().info("Loaded locale " + fileName);
|
Bukkit.getConsoleSender().sendMessage("Loaded locale " + fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +74,9 @@ public class Locale {
|
|||||||
* Find all .lang file locales under the "locales" folder
|
* Find all .lang file locales under the "locales" folder
|
||||||
*/
|
*/
|
||||||
public static void searchForLocales() {
|
public static void searchForLocales() {
|
||||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
if (!localeFolder.exists()) {
|
||||||
|
localeFolder.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
for (File file : localeFolder.listFiles()) {
|
for (File file : localeFolder.listFiles()) {
|
||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
@ -87,7 +89,7 @@ public class Locale {
|
|||||||
if (localeExists(localeValues[0] + "_" + localeValues[1])) continue;
|
if (localeExists(localeValues[0] + "_" + localeValues[1])) continue;
|
||||||
|
|
||||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||||
plugin.getLogger().info("Found and loaded locale \"" + fileName + "\"");
|
Bukkit.getConsoleSender().sendMessage("Found and loaded locale \"" + fileName + "\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,11 +153,11 @@ public class Locale {
|
|||||||
/**
|
/**
|
||||||
* Save a default locale file from the project source directory, to the locale folder
|
* Save a default locale file from the project source directory, to the locale folder
|
||||||
*
|
*
|
||||||
* @param path the path to the file to save
|
* @param in file to save
|
||||||
* @param fileName the name of the file to save
|
* @param fileName the name of the file to save
|
||||||
* @return true if the operation was successful, false otherwise
|
* @return true if the operation was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean saveDefaultLocale(String path, String fileName) {
|
public static boolean saveDefaultLocale(InputStream in, String fileName) {
|
||||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
if (!localeFolder.exists()) localeFolder.mkdirs();
|
||||||
|
|
||||||
if (!fileName.endsWith(FILE_EXTENSION))
|
if (!fileName.endsWith(FILE_EXTENSION))
|
||||||
@ -167,7 +169,7 @@ public class Locale {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try (OutputStream outputStream = new FileOutputStream(destinationFile)) {
|
try (OutputStream outputStream = new FileOutputStream(destinationFile)) {
|
||||||
IOUtils.copy(plugin.getResource(fileName), outputStream);
|
copy(in == null ? plugin.getResource(fileName) : in, outputStream);
|
||||||
|
|
||||||
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||||
String[] localeValues = fileName.split("_");
|
String[] localeValues = fileName.split("_");
|
||||||
@ -190,7 +192,7 @@ public class Locale {
|
|||||||
* @return true if the operation was successful, false otherwise
|
* @return true if the operation was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean saveDefaultLocale(String fileName) {
|
public static boolean saveDefaultLocale(String fileName) {
|
||||||
return saveDefaultLocale("", fileName);
|
return saveDefaultLocale(null, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -244,6 +246,19 @@ public class Locale {
|
|||||||
return changed;
|
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.
|
* Get the name of the language that this locale is based on.
|
||||||
* (i.e. "en" for English, or "fr" for French)
|
* (i.e. "en" for English, or "fr" for French)
|
||||||
@ -302,7 +317,7 @@ public class Locale {
|
|||||||
public String getMessage(String node, Object... args) {
|
public String getMessage(String node, Object... args) {
|
||||||
String message = getMessage(node);
|
String message = getMessage(node);
|
||||||
for (Object arg : args) {
|
for (Object arg : args) {
|
||||||
message = message.replaceFirst("\\%.*?\\%", arg.toString());
|
message = message.replaceFirst("%.*?%", arg.toString());
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@ -360,4 +375,7 @@ public class Locale {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPrefix() {
|
||||||
|
return getMessage("general.nametag.prefix") + " ";
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,8 +3,8 @@ package com.songoda.epicbuckets.file;
|
|||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||||
import com.songoda.epicbuckets.utils.InventoryHelper;
|
import com.songoda.epicbuckets.utils.InventoryHelper;
|
||||||
|
import com.songoda.epicbuckets.utils.Materials;
|
||||||
import com.songoda.epicbuckets.utils.Validator;
|
import com.songoda.epicbuckets.utils.Validator;
|
||||||
import com.songoda.epicbuckets.utils.XMaterial;
|
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -34,8 +34,8 @@ public class ConfigManager {
|
|||||||
private String bulkShopPurchasePath = "BULK-SHOP-INVENTORY.purchase-item";
|
private String bulkShopPurchasePath = "BULK-SHOP-INVENTORY.purchase-item";
|
||||||
private String menuItemsPath = "MENU-ITEMS";
|
private String menuItemsPath = "MENU-ITEMS";
|
||||||
|
|
||||||
private List<XMaterial> ignoredMaterials;
|
private List<Materials> ignoredMaterials;
|
||||||
private List<XMaterial> psuedoMaterials;
|
private List<Materials> psuedoMaterials;
|
||||||
|
|
||||||
private LinkedHashMap<String, Integer> genbucketGroups;
|
private LinkedHashMap<String, Integer> genbucketGroups;
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ public class ConfigManager {
|
|||||||
HashMap<ItemStack, Double> chargingCostsPerItem = new HashMap<>();
|
HashMap<ItemStack, Double> chargingCostsPerItem = new HashMap<>();
|
||||||
|
|
||||||
epicBuckets.getConfig().getConfigurationSection("COST-FOR-INFINITE-USE." + bucket).getKeys(false)
|
epicBuckets.getConfig().getConfigurationSection("COST-FOR-INFINITE-USE." + bucket).getKeys(false)
|
||||||
.forEach(item -> chargingCostsPerItem.put(XMaterial.valueOf(item).parseItem(),
|
.forEach(item -> chargingCostsPerItem.put(Materials.valueOf(item).parseItem(),
|
||||||
epicBuckets.getConfig().getDouble("COST-FOR-INFINITE-USE." + bucket + "." + item)));
|
epicBuckets.getConfig().getDouble("COST-FOR-INFINITE-USE." + bucket + "." + item)));
|
||||||
|
|
||||||
infiniteUseCost.put(GenbucketType.valueOf(bucket), chargingCostsPerItem);
|
infiniteUseCost.put(GenbucketType.valueOf(bucket), chargingCostsPerItem);
|
||||||
@ -219,14 +219,14 @@ public class ConfigManager {
|
|||||||
private void setupFillItem() {
|
private void setupFillItem() {
|
||||||
boolean m = Validator.isMaterial(epicBuckets.getConfig().getString(getFillItemPath() + ".material"));
|
boolean m = Validator.isMaterial(epicBuckets.getConfig().getString(getFillItemPath() + ".material"));
|
||||||
|
|
||||||
fillItem = ((!m) ? XMaterial.BLACK_STAINED_GLASS_PANE.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(getFillItemPath() + ".material")).parseItem());
|
fillItem = ((!m) ? Materials.BLACK_STAINED_GLASS_PANE.parseItem() : Materials.valueOf(epicBuckets.getConfig().getString(getFillItemPath() + ".material")).parseItem());
|
||||||
fillItem = InventoryHelper.setDisplayName(fillItem, epicBuckets.getConfig().getString(getFillItemPath() + ".name"));
|
fillItem = InventoryHelper.setDisplayName(fillItem, epicBuckets.getConfig().getString(getFillItemPath() + ".name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupBackButton() {
|
private void setupBackButton() {
|
||||||
boolean m = Validator.isMaterial(epicBuckets.getConfig().getString(getBackButtonPath() + ".material"));
|
boolean m = Validator.isMaterial(epicBuckets.getConfig().getString(getBackButtonPath() + ".material"));
|
||||||
|
|
||||||
backButton = ((!m) ? XMaterial.BARRIER.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(getBackButtonPath() + ".material")).parseItem());
|
backButton = ((!m) ? Materials.BARRIER.parseItem() : Materials.valueOf(epicBuckets.getConfig().getString(getBackButtonPath() + ".material")).parseItem());
|
||||||
backButton = InventoryHelper.setDisplayName(backButton, epicBuckets.getConfig().getString(getBackButtonPath() + ".name"));
|
backButton = InventoryHelper.setDisplayName(backButton, epicBuckets.getConfig().getString(getBackButtonPath() + ".name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,11 +282,11 @@ public class ConfigManager {
|
|||||||
return bulkShopPurchasePath;
|
return bulkShopPurchasePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<XMaterial> getIgnoredMaterials() {
|
public List<Materials> getIgnoredMaterials() {
|
||||||
return ignoredMaterials;
|
return ignoredMaterials;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<XMaterial> getPsuedoMaterials() {
|
public List<Materials> getPsuedoMaterials() {
|
||||||
return psuedoMaterials;
|
return psuedoMaterials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package com.songoda.epicbuckets.genbucket;
|
|||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.shop.SubShop;
|
import com.songoda.epicbuckets.shop.SubShop;
|
||||||
import com.songoda.epicbuckets.utils.XMaterial;
|
import com.songoda.epicbuckets.utils.Materials;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -100,12 +100,12 @@ public abstract class Genbucket {
|
|||||||
Block b = getNextBlock();
|
Block b = getNextBlock();
|
||||||
if (isBelowVoid(moved + 1)) return false;
|
if (isBelowVoid(moved + 1)) return false;
|
||||||
if (b.getRelative(getBlockFace()).getType() != Material.AIR) {
|
if (b.getRelative(getBlockFace()).getType() != Material.AIR) {
|
||||||
if (b.getRelative(getBlockFace()).getType() != XMaterial.COBBLESTONE.parseMaterial()) {
|
if (b.getRelative(getBlockFace()).getType() != Materials.COBBLESTONE.parseMaterial()) {
|
||||||
b.setType(getGenItem().getType());
|
b.setType(getGenItem().getType());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b.getRelative(getBlockFace()).setType(XMaterial.COBBLESTONE.parseMaterial());
|
b.getRelative(getBlockFace()).setType(Materials.COBBLESTONE.parseMaterial());
|
||||||
b.setType(getGenItem().getType());
|
b.setType(getGenItem().getType());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -114,12 +114,12 @@ public abstract class Genbucket {
|
|||||||
Block b = getNextBlock(moved, blockFace);
|
Block b = getNextBlock(moved, blockFace);
|
||||||
if (isBelowVoid(moved + 1)) return false;
|
if (isBelowVoid(moved + 1)) return false;
|
||||||
if (b.getRelative(BlockFace.DOWN).getType() != Material.AIR) {
|
if (b.getRelative(BlockFace.DOWN).getType() != Material.AIR) {
|
||||||
if (b.getRelative(BlockFace.DOWN).getType() != XMaterial.COBBLESTONE.parseMaterial()) {
|
if (b.getRelative(BlockFace.DOWN).getType() != Materials.COBBLESTONE.parseMaterial()) {
|
||||||
b.setType(getGenItem().getType());
|
b.setType(getGenItem().getType());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b.getRelative(BlockFace.DOWN).setType(XMaterial.COBBLESTONE.parseMaterial());
|
b.getRelative(BlockFace.DOWN).setType(Materials.COBBLESTONE.parseMaterial());
|
||||||
b.setType(getGenItem().getType());
|
b.setType(getGenItem().getType());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ public abstract class Genbucket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void fixHole(Block block) {
|
protected void fixHole(Block block) {
|
||||||
if (block.getType() == XMaterial.AIR.parseMaterial()) block.setType(getGenItem().getType());
|
if (block.getType() == Materials.AIR.parseMaterial()) block.setType(getGenItem().getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean spongeInRange(Block block) {
|
protected boolean spongeInRange(Block block) {
|
||||||
@ -145,7 +145,7 @@ public abstract class Genbucket {
|
|||||||
|
|
||||||
for (int x = -radius; x <= radius; x++) {
|
for (int x = -radius; x <= radius; x++) {
|
||||||
for (int z = -radius; z <= radius; z++) {
|
for (int z = -radius; z <= radius; z++) {
|
||||||
if (block.getRelative(x, 0, z).getType() == XMaterial.SPONGE.parseMaterial()) return true;
|
if (block.getRelative(x, 0, z).getType() == Materials.SPONGE.parseMaterial()) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,12 +154,12 @@ public abstract class Genbucket {
|
|||||||
|
|
||||||
protected boolean placeGen(Block block) {
|
protected boolean placeGen(Block block) {
|
||||||
|
|
||||||
List<XMaterial> materials = epicBuckets.getConfigManager().getIgnoredMaterials();
|
List<Materials> materials = epicBuckets.getConfigManager().getIgnoredMaterials();
|
||||||
|
|
||||||
if (!materials.contains(XMaterial.requestXMaterial(block.getType().name(), block.getData())))
|
if (!materials.contains(Materials.requestMaterials(block.getType().name(), block.getData())))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((materials.contains(XMaterial.WATER) || materials.contains(XMaterial.LAVA)) && block.isLiquid())
|
if ((materials.contains(Materials.WATER) || materials.contains(Materials.LAVA)) && block.isLiquid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!epicBuckets.canBuild(owner, block.getLocation())) return false;
|
if (!epicBuckets.canBuild(owner, block.getLocation())) return false;
|
||||||
|
@ -33,7 +33,7 @@ public class GUIBulk extends AbstractGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void constructGUI() {
|
public void constructGUI() {
|
||||||
if (shopManager.isBulkFillInventory()) {
|
if (shopManager.isBulkFillInventory()) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
while (num != size) {
|
while (num != size) {
|
||||||
|
@ -27,7 +27,7 @@ public class GUIMain extends AbstractGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void constructGUI() {
|
public void constructGUI() {
|
||||||
if (configManager.isFillInventory()) {
|
if (configManager.isFillInventory()) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
while (num != size) {
|
while (num != size) {
|
||||||
|
@ -3,7 +3,7 @@ package com.songoda.epicbuckets.gui;
|
|||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.genbucket.Genbucket;
|
import com.songoda.epicbuckets.genbucket.Genbucket;
|
||||||
import com.songoda.epicbuckets.utils.ChatUtil;
|
import com.songoda.epicbuckets.utils.ChatUtil;
|
||||||
import com.songoda.epicbuckets.utils.XMaterial;
|
import com.songoda.epicbuckets.utils.Materials;
|
||||||
import com.songoda.epicbuckets.utils.gui.AbstractGUI;
|
import com.songoda.epicbuckets.utils.gui.AbstractGUI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -32,7 +32,7 @@ public class GUIPanel extends AbstractGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void constructGUI() {
|
public void constructGUI() {
|
||||||
|
|
||||||
inventory.clear();
|
inventory.clear();
|
||||||
resetClickables();
|
resetClickables();
|
||||||
@ -88,7 +88,7 @@ public class GUIPanel extends AbstractGUI {
|
|||||||
private void registerExtraButtons() {
|
private void registerExtraButtons() {
|
||||||
|
|
||||||
if (page > 0) {
|
if (page > 0) {
|
||||||
inventory.setItem(27, createItem(XMaterial.ARROW.parseItem(), epicBuckets.getLocale().getMessage("interface.admin.panel.previous")));
|
inventory.setItem(27, createItem(Materials.ARROW.parseItem(), epicBuckets.getLocale().getMessage("interface.admin.panel.previous")));
|
||||||
registerClickable(27, (player, inventory, cursor, slot, type) -> {
|
registerClickable(27, (player, inventory, cursor, slot, type) -> {
|
||||||
page--;
|
page--;
|
||||||
constructGUI();
|
constructGUI();
|
||||||
@ -96,9 +96,9 @@ public class GUIPanel extends AbstractGUI {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack deactiveButton = createItem(XMaterial.RED_WOOL.parseItem(), epicBuckets.getLocale().getMessage("interface.admin.panel.deactivateall"));
|
ItemStack deactiveButton = createItem(Materials.RED_WOOL.parseItem(), epicBuckets.getLocale().getMessage("interface.admin.panel.deactivateall"));
|
||||||
ItemStack pageButton = createItem(XMaterial.SIGN.parseItem(), epicBuckets.getLocale().getMessage("interface.admin.panel.page").replace("%page%", String.valueOf(page + 1)));
|
ItemStack pageButton = createItem(Materials.OAK_SIGN.parseItem(), epicBuckets.getLocale().getMessage("interface.admin.panel.page").replace("%page%", String.valueOf(page + 1)));
|
||||||
ItemStack nextButton = createItem(XMaterial.ARROW.parseItem(), epicBuckets.getLocale().getMessage("interface.admin.panel.next"));
|
ItemStack nextButton = createItem(Materials.ARROW.parseItem(), epicBuckets.getLocale().getMessage("interface.admin.panel.next"));
|
||||||
|
|
||||||
inventory.setItem(30, deactiveButton);
|
inventory.setItem(30, deactiveButton);
|
||||||
inventory.setItem(32, pageButton);
|
inventory.setItem(32, pageButton);
|
||||||
@ -134,7 +134,7 @@ public class GUIPanel extends AbstractGUI {
|
|||||||
|
|
||||||
private ItemStack createGenbucketItem(Genbucket genbucket) {
|
private ItemStack createGenbucketItem(Genbucket genbucket) {
|
||||||
|
|
||||||
ItemStack skull = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial(), 1, (short) 3);
|
ItemStack skull = new ItemStack(Materials.PLAYER_HEAD.parseMaterial(), 1, (short) 3);
|
||||||
SkullMeta meta = (SkullMeta) (skull.getItemMeta() != null ? skull.getItemMeta() : Bukkit.getItemFactory().getItemMeta(skull.getType()));
|
SkullMeta meta = (SkullMeta) (skull.getItemMeta() != null ? skull.getItemMeta() : Bukkit.getItemFactory().getItemMeta(skull.getType()));
|
||||||
meta.setOwner(genbucket.getOwner().getName());
|
meta.setOwner(genbucket.getOwner().getName());
|
||||||
meta.setDisplayName(ChatUtil.colorString(epicBuckets.getLocale().getMessage("interface.admin.panel.player").replace("%player%", genbucket.getOwner().getName())));
|
meta.setDisplayName(ChatUtil.colorString(epicBuckets.getLocale().getMessage("interface.admin.panel.player").replace("%player%", genbucket.getOwner().getName())));
|
||||||
|
@ -32,7 +32,7 @@ public class GUIShop extends AbstractGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void constructGUI() {
|
public void constructGUI() {
|
||||||
if (shop.isFillInventory()) {
|
if (shop.isFillInventory()) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
while (num != size) {
|
while (num != size) {
|
||||||
|
@ -9,7 +9,7 @@ import com.songoda.epicbuckets.genbucket.types.Horizontal;
|
|||||||
import com.songoda.epicbuckets.genbucket.types.Infused;
|
import com.songoda.epicbuckets.genbucket.types.Infused;
|
||||||
import com.songoda.epicbuckets.genbucket.types.PsuedoVertical;
|
import com.songoda.epicbuckets.genbucket.types.PsuedoVertical;
|
||||||
import com.songoda.epicbuckets.genbucket.types.Vertical;
|
import com.songoda.epicbuckets.genbucket.types.Vertical;
|
||||||
import com.songoda.epicbuckets.utils.XMaterial;
|
import com.songoda.epicbuckets.utils.Materials;
|
||||||
import com.songoda.epicbuckets.utils.itemnbtapi.NBTItem;
|
import com.songoda.epicbuckets.utils.itemnbtapi.NBTItem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -91,7 +91,7 @@ public class GenbucketPlaceListener implements Listener {
|
|||||||
e.getPlayer().sendMessage(instance.getLocale().getMessage("event.genbucket.placedwrong").replace("%genbucket%", genbucket.getGenbucketType().formatName() + " Genbucket"));
|
e.getPlayer().sendMessage(instance.getLocale().getMessage("event.genbucket.placedwrong").replace("%genbucket%", genbucket.getGenbucketType().formatName() + " Genbucket"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (genbucket.getGenbucketType() == GenbucketType.PSUEDO && !instance.getConfigManager().getPsuedoMaterials().contains(XMaterial.requestXMaterial(e.getClickedBlock().getType().name(), e.getClickedBlock().getData()))) {
|
if (genbucket.getGenbucketType() == GenbucketType.PSUEDO && !instance.getConfigManager().getPsuedoMaterials().contains(Materials.requestMaterials(e.getClickedBlock().getType().name(), e.getClickedBlock().getData()))) {
|
||||||
e.getPlayer().sendMessage(instance.getLocale().getMessage("event.genbucket.wrongmaterialpsuedo"));
|
e.getPlayer().sendMessage(instance.getLocale().getMessage("event.genbucket.wrongmaterialpsuedo"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package com.songoda.epicbuckets.shop;
|
|||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||||
import com.songoda.epicbuckets.utils.InventoryHelper;
|
import com.songoda.epicbuckets.utils.InventoryHelper;
|
||||||
|
import com.songoda.epicbuckets.utils.Materials;
|
||||||
import com.songoda.epicbuckets.utils.Validator;
|
import com.songoda.epicbuckets.utils.Validator;
|
||||||
import com.songoda.epicbuckets.utils.XMaterial;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ public class Shop {
|
|||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
shopItem = ((!m) ? XMaterial.WATER_BUCKET.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(itemPath + ".material")).parseItem());
|
shopItem = ((!m) ? Materials.WATER_BUCKET.parseItem() : Materials.valueOf(epicBuckets.getConfig().getString(itemPath + ".material")).parseItem());
|
||||||
shopItem = InventoryHelper.setLore(InventoryHelper.setDisplayName(shopItem, epicBuckets.getConfig().getString(itemPath + ".name")), epicBuckets.getConfig().getStringList(itemPath + ".lore"));
|
shopItem = InventoryHelper.setLore(InventoryHelper.setDisplayName(shopItem, epicBuckets.getConfig().getString(itemPath + ".name")), epicBuckets.getConfig().getStringList(itemPath + ".lore"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public class Shop {
|
|||||||
return subShops.get(shop);
|
return subShops.get(shop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubShop getSubShop(XMaterial mat) {
|
public SubShop getSubShop(Materials mat) {
|
||||||
for (SubShop subShop : subShops.values()) {
|
for (SubShop subShop : subShops.values()) {
|
||||||
if (subShop.getGenItem().getType() == mat.parseMaterial() &&
|
if (subShop.getGenItem().getType() == mat.parseMaterial() &&
|
||||||
subShop.getGenItem().getDurability() == mat.parseItem().getDurability()) {
|
subShop.getGenItem().getDurability() == mat.parseItem().getDurability()) {
|
||||||
|
@ -65,9 +65,9 @@ public class ShopManager {
|
|||||||
purchaseSlot = 40;
|
purchaseSlot = 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
increaseItem = ((!i) ? XMaterial.GREEN_STAINED_GLASS_PANE.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopIncreasePath() + ".material")).parseItem());
|
increaseItem = ((!i) ? Materials.GREEN_STAINED_GLASS_PANE.parseItem() : Materials.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopIncreasePath() + ".material")).parseItem());
|
||||||
decreaseItem = ((!d) ? XMaterial.RED_STAINED_GLASS_PANE.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopDecreasePath() + ".material")).parseItem());
|
decreaseItem = ((!d) ? Materials.RED_STAINED_GLASS_PANE.parseItem() : Materials.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopDecreasePath() + ".material")).parseItem());
|
||||||
purchaseItem = ((!p) ? XMaterial.YELLOW_STAINED_GLASS.parseItem() : XMaterial.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".material")).parseItem());
|
purchaseItem = ((!p) ? Materials.YELLOW_STAINED_GLASS.parseItem() : Materials.valueOf(epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".material")).parseItem());
|
||||||
purchaseItem = InventoryHelper.setDisplayName(purchaseItem, epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".name"));
|
purchaseItem = InventoryHelper.setDisplayName(purchaseItem, epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopPurchasePath() + ".name"));
|
||||||
|
|
||||||
for (String s : epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopIncreasePath() + ".slots").split(",")) {
|
for (String s : epicBuckets.getConfig().getString(epicBuckets.getConfigManager().getBulkShopIncreasePath() + ".slots").split(",")) {
|
||||||
|
@ -2,8 +2,8 @@ package com.songoda.epicbuckets.shop;
|
|||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
import com.songoda.epicbuckets.utils.InventoryHelper;
|
import com.songoda.epicbuckets.utils.InventoryHelper;
|
||||||
|
import com.songoda.epicbuckets.utils.Materials;
|
||||||
import com.songoda.epicbuckets.utils.Validator;
|
import com.songoda.epicbuckets.utils.Validator;
|
||||||
import com.songoda.epicbuckets.utils.XMaterial;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ public class SubShop {
|
|||||||
private ItemStack shopItem;
|
private ItemStack shopItem;
|
||||||
private ItemStack genItem;
|
private ItemStack genItem;
|
||||||
private ItemStack genShopItem;
|
private ItemStack genShopItem;
|
||||||
private XMaterial type;
|
private Materials type;
|
||||||
|
|
||||||
private Shop parent;
|
private Shop parent;
|
||||||
private String item;
|
private String item;
|
||||||
@ -60,7 +60,7 @@ public class SubShop {
|
|||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.type = XMaterial.valueOf(shops.getString(subShopPath + ".type"));
|
this.type = Materials.valueOf(shops.getString(subShopPath + ".type"));
|
||||||
this.shopName = shops.getString(subShopPath + ".name");
|
this.shopName = shops.getString(subShopPath + ".name");
|
||||||
this.description = shops.getStringList(subShopPath + ".description");
|
this.description = shops.getStringList(subShopPath + ".description");
|
||||||
this.genItemLore = shops.getStringList(subShopPath + ".item-lore");
|
this.genItemLore = shops.getStringList(subShopPath + ".item-lore");
|
||||||
@ -76,12 +76,12 @@ public class SubShop {
|
|||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
shopItem = ((!m) ? XMaterial.WATER_BUCKET.parseItem() : XMaterial.valueOf(shops.getString(subShopPath + ".icon")).parseItem());
|
shopItem = ((!m) ? Materials.WATER_BUCKET.parseItem() : Materials.valueOf(shops.getString(subShopPath + ".icon")).parseItem());
|
||||||
shopItem = InventoryHelper.setDisplayName(InventoryHelper.setSubShopLore(shopItem, getDescription(), this), getShopName());
|
shopItem = InventoryHelper.setDisplayName(InventoryHelper.setSubShopLore(shopItem, getDescription(), this), getShopName());
|
||||||
|
|
||||||
genItem = ((!t) ? XMaterial.WATER_BUCKET.parseItem() : XMaterial.valueOf(shops.getString(subShopPath + ".type")).parseItem());
|
genItem = ((!t) ? Materials.WATER_BUCKET.parseItem() : Materials.valueOf(shops.getString(subShopPath + ".type")).parseItem());
|
||||||
|
|
||||||
genShopItem = ((!m) ? XMaterial.WATER_BUCKET.parseItem() : XMaterial.valueOf(shops.getString(subShopPath + ".icon")).parseItem());
|
genShopItem = ((!m) ? Materials.WATER_BUCKET.parseItem() : Materials.valueOf(shops.getString(subShopPath + ".icon")).parseItem());
|
||||||
genShopItem = InventoryHelper.setDisplayName(InventoryHelper.setLore(genShopItem, getGenItemLore()), getShopName());
|
genShopItem = InventoryHelper.setDisplayName(InventoryHelper.setLore(genShopItem, getGenItemLore()), getShopName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ public class SubShop {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XMaterial getType() {
|
public Materials getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,14 @@ import java.util.stream.IntStream;
|
|||||||
|
|
||||||
public class InventoryHelper {
|
public class InventoryHelper {
|
||||||
|
|
||||||
public static List<XMaterial> convertMaterialList(List<String> toConvert, String item) {
|
public static List<Materials> convertMaterialList(List<String> toConvert, String item) {
|
||||||
List<XMaterial> converted = new ArrayList<>();
|
List<Materials> converted = new ArrayList<>();
|
||||||
for (String s : toConvert) {
|
for (String s : toConvert) {
|
||||||
if (!Validator.isMaterial(s.toUpperCase())) {
|
if (!Validator.isMaterial(s.toUpperCase())) {
|
||||||
EpicBuckets.getInstance().getDebugger().sendConsole("Invalid material " + s.toUpperCase() + " in " + item + ", skipping..");
|
EpicBuckets.getInstance().getDebugger().sendConsole("Invalid material " + s.toUpperCase() + " in " + item + ", skipping..");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
converted.add(XMaterial.valueOf(s.toUpperCase()));
|
converted.add(Materials.valueOf(s.toUpperCase()));
|
||||||
}
|
}
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,7 @@ public class Validator {
|
|||||||
|
|
||||||
public static boolean isMaterial(String mat) {
|
public static boolean isMaterial(String mat) {
|
||||||
try {
|
try {
|
||||||
XMaterial.valueOf(mat);
|
Materials.valueOf(mat);
|
||||||
return true;
|
return true;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -28,6 +28,7 @@ public abstract class AbstractGUI implements Listener {
|
|||||||
private static boolean listenersInitialized = false;
|
private static boolean listenersInitialized = false;
|
||||||
protected Player player;
|
protected Player player;
|
||||||
protected Inventory inventory = null;
|
protected Inventory inventory = null;
|
||||||
|
protected String setTitle = null;
|
||||||
protected boolean cancelBottom = false;
|
protected boolean cancelBottom = false;
|
||||||
private Map<Range, Clickable> clickables = new HashMap<>();
|
private Map<Range, Clickable> clickables = new HashMap<>();
|
||||||
private List<OnClose> onCloses = new ArrayList<>();
|
private List<OnClose> onCloses = new ArrayList<>();
|
||||||
@ -84,8 +85,7 @@ public abstract class AbstractGUI implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
if (event.getSlot() >= range.getMin() && event.getSlot() <= range.getMax()) {
|
if (event.getSlot() >= range.getMin() && event.getSlot() <= range.getMax()) {
|
||||||
entry.getValue().Clickable(player, inventory, event.getCursor(), event.getSlot(), event.getClick());
|
entry.getValue().Clickable(player, inventory, event.getCursor(), event.getSlot(), event.getClick());
|
||||||
if (EpicBuckets.getInstance().isServerVersionAtLeast(ServerVersion.V1_12))
|
player.playSound(player.getLocation(), entry.getKey().getOnClickSound(), 1F, 1F);
|
||||||
player.playSound(player.getLocation(), entry.getKey().getOnClickSound(), 1F, 1F);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,8 +116,9 @@ public abstract class AbstractGUI implements Listener {
|
|||||||
public void init(String title, int slots) {
|
public void init(String title, int slots) {
|
||||||
if (inventory == null
|
if (inventory == null
|
||||||
|| inventory.getSize() != slots
|
|| inventory.getSize() != slots
|
||||||
|| ChatColor.translateAlternateColorCodes('&', title) != inventory.getTitle()) {
|
|| ChatColor.translateAlternateColorCodes('&', title) != player.getOpenInventory().getTitle()) {
|
||||||
this.inventory = Bukkit.getServer().createInventory(new GUIHolder(), slots, title);
|
this.inventory = Bukkit.getServer().createInventory(new GUIHolder(), slots, ChatColor.translateAlternateColorCodes('&', title));
|
||||||
|
this.setTitle = ChatColor.translateAlternateColorCodes('&', title);
|
||||||
if (this.clickables.size() == 0)
|
if (this.clickables.size() == 0)
|
||||||
registerClickables();
|
registerClickables();
|
||||||
if (this.onCloses.size() == 0)
|
if (this.onCloses.size() == 0)
|
||||||
@ -128,7 +129,7 @@ public abstract class AbstractGUI implements Listener {
|
|||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void constructGUI();
|
public abstract void constructGUI();
|
||||||
|
|
||||||
protected void addDraggable(Range range, boolean option) {
|
protected void addDraggable(Range range, boolean option) {
|
||||||
this.draggableRanges.put(range, option);
|
this.draggableRanges.put(range, option);
|
||||||
@ -171,10 +172,6 @@ public abstract class AbstractGUI implements Listener {
|
|||||||
return createButton(slot, material, name, lore.toArray(new String[0]));
|
return createButton(slot, material, name, lore.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ItemStack createButton(int slot, ItemStack item, String name, ArrayList<String> lore) {
|
|
||||||
return createButton(slot, item, name, lore.toArray(new String[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void registerClickable(int min, int max, ClickType clickType, boolean bottom, Clickable clickable) {
|
protected void registerClickable(int min, int max, ClickType clickType, boolean bottom, Clickable clickable) {
|
||||||
clickables.put(new Range(min, max, clickType, bottom), clickable);
|
clickables.put(new Range(min, max, clickType, bottom), clickable);
|
||||||
}
|
}
|
||||||
@ -222,4 +219,8 @@ public abstract class AbstractGUI implements Listener {
|
|||||||
return AbstractGUI.this;
|
return AbstractGUI.this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSetTitle() {
|
||||||
|
return setTitle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.songoda.epicbuckets.utils.itemnbtapi;
|
package com.songoda.epicbuckets.utils.itemnbtapi;
|
||||||
|
|
||||||
|
import com.songoda.epicbuckets.utils.itemnbtapi.utils.MinecraftVersion;
|
||||||
|
|
||||||
public class NBTList {
|
public class NBTList {
|
||||||
|
|
||||||
private String listName;
|
private String listName;
|
||||||
@ -28,7 +30,11 @@ public class NBTList {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Object compound = ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz().newInstance();
|
Object compound = ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz().newInstance();
|
||||||
ReflectionMethod.LIST_ADD.run(listObject, compound);
|
if (MinecraftVersion.getVersion().getVersionId() >= MinecraftVersion.MC1_14_R1.getVersionId()) {
|
||||||
|
ReflectionMethod.LIST_ADD.run(listObject, 0, compound);
|
||||||
|
} else {
|
||||||
|
ReflectionMethod.LEGACY_LIST_ADD.run(listObject, compound);
|
||||||
|
}
|
||||||
return new NBTListCompound(this, compound);
|
return new NBTListCompound(this, compound);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -69,7 +75,13 @@ public class NBTList {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ReflectionMethod.LIST_ADD.run(listObject, ClassWrapper.NMS_NBTTAGSTRING.getClazz().getConstructor(String.class).newInstance(s));
|
if (MinecraftVersion.getVersion().getVersionId() >= MinecraftVersion.MC1_14_R1.getVersionId()) {
|
||||||
|
ReflectionMethod.LIST_ADD.run(listObject, 0,
|
||||||
|
ClassWrapper.NMS_NBTTAGSTRING.getClazz().getConstructor(String.class).newInstance(s));
|
||||||
|
} else {
|
||||||
|
ReflectionMethod.LEGACY_LIST_ADD.run(listObject,
|
||||||
|
ClassWrapper.NMS_NBTTAGSTRING.getClazz().getConstructor(String.class).newInstance(s));
|
||||||
|
}
|
||||||
save();
|
save();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -82,7 +94,8 @@ public class NBTList {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ReflectionMethod.LIST_SET.run(listObject, i, ClassWrapper.NMS_NBTTAGSTRING.getClazz().getConstructor(String.class).newInstance(s));
|
ReflectionMethod.LIST_SET.run(listObject, i,
|
||||||
|
ClassWrapper.NMS_NBTTAGSTRING.getClazz().getConstructor(String.class).newInstance(s));
|
||||||
save();
|
save();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -41,7 +41,8 @@ public enum ReflectionMethod {
|
|||||||
LIST_REMOVE_KEY(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{int.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "a"), new Since(MinecraftVersion.MC1_9_R1, "remove")),
|
LIST_REMOVE_KEY(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{int.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "a"), new Since(MinecraftVersion.MC1_9_R1, "remove")),
|
||||||
LIST_SIZE(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "size")),
|
LIST_SIZE(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "size")),
|
||||||
LIST_SET(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{int.class, ClassWrapper.NMS_NBTBASE.getClazz()}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "a"), new Since(MinecraftVersion.MC1_13_R1, "set")),
|
LIST_SET(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{int.class, ClassWrapper.NMS_NBTBASE.getClazz()}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "a"), new Since(MinecraftVersion.MC1_13_R1, "set")),
|
||||||
LIST_ADD(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{ClassWrapper.NMS_NBTBASE.getClazz()}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "add")),
|
LEGACY_LIST_ADD(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{ClassWrapper.NMS_NBTBASE.getClazz()}, MinecraftVersion.MC1_7_R4, MinecraftVersion.MC1_13_R2, new Since(MinecraftVersion.MC1_7_R4, "add")),
|
||||||
|
LIST_ADD(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{int.class, ClassWrapper.NMS_NBTBASE.getClazz()}, MinecraftVersion.MC1_14_R1, new Since(MinecraftVersion.MC1_14_R1, "add")),
|
||||||
LIST_GET_STRING(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{int.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "getString")),
|
LIST_GET_STRING(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{int.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "getString")),
|
||||||
LIST_GET(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{int.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "get")),
|
LIST_GET(ClassWrapper.NMS_NBTTAGLIST.getClazz(), new Class[]{int.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "get")),
|
||||||
|
|
||||||
@ -63,16 +64,21 @@ public enum ReflectionMethod {
|
|||||||
NBTFILE_WRITE(ClassWrapper.NMS_NBTCOMPRESSEDSTREAMTOOLS.getClazz(), new Class[]{ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz(), OutputStream.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "a")), //FIXME: No Spigot mapping!
|
NBTFILE_WRITE(ClassWrapper.NMS_NBTCOMPRESSEDSTREAMTOOLS.getClazz(), new Class[]{ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz(), OutputStream.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "a")), //FIXME: No Spigot mapping!
|
||||||
|
|
||||||
|
|
||||||
PARSE_NBT(ClassWrapper.NMS_MOJANGSONPARSER.getClazz(), new Class[]{String.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "parse")),;
|
PARSE_NBT(ClassWrapper.NMS_MOJANGSONPARSER.getClazz(), new Class[]{String.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "parse")),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private MinecraftVersion removedAfter;
|
||||||
private Since targetVersion;
|
private Since targetVersion;
|
||||||
private Method method;
|
private Method method;
|
||||||
private boolean loaded = false;
|
private boolean loaded = false;
|
||||||
private boolean compatible = false;
|
private boolean compatible = false;
|
||||||
|
|
||||||
ReflectionMethod(Class<?> targetClass, Class<?>[] args, MinecraftVersion addedSince, Since... methodnames) {
|
ReflectionMethod(Class<?> targetClass, Class<?>[] args, MinecraftVersion addedSince, MinecraftVersion removedAfter, Since... methodnames) {
|
||||||
|
this.removedAfter = removedAfter;
|
||||||
MinecraftVersion server = MinecraftVersion.getVersion();
|
MinecraftVersion server = MinecraftVersion.getVersion();
|
||||||
if (server.compareTo(addedSince) < 0) return;
|
if (server.compareTo(addedSince) < 0 || (this.removedAfter != null && server.getVersionId() > this.removedAfter.getVersionId()))
|
||||||
|
return;
|
||||||
compatible = true;
|
compatible = true;
|
||||||
Since target = methodnames[0];
|
Since target = methodnames[0];
|
||||||
for (Since s : methodnames) {
|
for (Since s : methodnames) {
|
||||||
@ -89,6 +95,10 @@ public enum ReflectionMethod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReflectionMethod(Class<?> targetClass, Class<?>[] args, MinecraftVersion addedSince, Since... methodnames) {
|
||||||
|
this(targetClass, args, addedSince, null, methodnames);
|
||||||
|
}
|
||||||
|
|
||||||
public Object run(Object target, Object... args) {
|
public Object run(Object target, Object... args) {
|
||||||
try {
|
try {
|
||||||
return method.invoke(target, args);
|
return method.invoke(target, args);
|
||||||
@ -115,5 +125,4 @@ public enum ReflectionMethod {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -12,7 +12,8 @@ public enum MinecraftVersion {
|
|||||||
MC1_11_R1(1111),
|
MC1_11_R1(1111),
|
||||||
MC1_12_R1(1121),
|
MC1_12_R1(1121),
|
||||||
MC1_13_R1(1131),
|
MC1_13_R1(1131),
|
||||||
MC1_13_R2(1132);
|
MC1_13_R2(1132),
|
||||||
|
MC1_14_R1(1141);
|
||||||
|
|
||||||
private static MinecraftVersion version;
|
private static MinecraftVersion version;
|
||||||
private static Boolean hasGsonSupport;
|
private static Boolean hasGsonSupport;
|
||||||
@ -23,6 +24,10 @@ public enum MinecraftVersion {
|
|||||||
this.versionId = versionId;
|
this.versionId = versionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getVersionId() {
|
||||||
|
return versionId;
|
||||||
|
}
|
||||||
|
|
||||||
public static MinecraftVersion getVersion() {
|
public static MinecraftVersion getVersion() {
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
return version;
|
return version;
|
||||||
@ -55,8 +60,4 @@ public enum MinecraftVersion {
|
|||||||
return hasGsonSupport;
|
return hasGsonSupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVersionId() {
|
|
||||||
return versionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.songoda.epicbuckets.utils.updateModules;
|
||||||
|
|
||||||
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
|
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();
|
||||||
|
EpicBuckets.getInstance().getLocale().saveDefaultLocale(in, (String) file.get("name"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
40
pom.xml
40
pom.xml
@ -16,9 +16,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.13.2</version>
|
<version>1.14</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.songoda</groupId>
|
||||||
|
<artifactId>songodaupdater</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -33,6 +38,39 @@
|
|||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
|
Loading…
Reference in New Issue
Block a user