Mirror von
https://github.com/TheSilentPro/HeadDB.git
synchronisiert 2024-12-26 19:02:39 +01:00
Economy and several other fixes
Dieser Commit ist enthalten in:
Ursprung
12140b8ca6
Commit
e4e815f02a
19
pom.xml
19
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>tsp.headdb</groupId>
|
<groupId>tsp.headdb</groupId>
|
||||||
<artifactId>HeadDB</artifactId>
|
<artifactId>HeadDB</artifactId>
|
||||||
<version>5.0.0-rc.2</version>
|
<version>5.0.0-rc.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HeadDB</name>
|
<name>HeadDB</name>
|
||||||
@ -129,7 +129,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.2.4</version>
|
<version>3.4.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@ -142,6 +142,21 @@
|
|||||||
<mainClass>tsp.headdb.HeadDB</mainClass>
|
<mainClass>tsp.headdb.HeadDB</mainClass>
|
||||||
</transformer>
|
</transformer>
|
||||||
</transformers>
|
</transformers>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>net.wesjd.anvilgui</pattern>
|
||||||
|
<shadedPattern>tsp.headdb.core.util.anvilgui</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
<filters>
|
||||||
|
<filter>
|
||||||
|
<artifact>*:*</artifact>
|
||||||
|
<excludeDefaults>false</excludeDefaults>
|
||||||
|
<includes>
|
||||||
|
<include>tsp.headdb.core.util.anvilgui</include>
|
||||||
|
</includes>
|
||||||
|
</filter>
|
||||||
|
</filters>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
@ -20,10 +20,10 @@ import tsp.headdb.core.storage.Storage;
|
|||||||
import tsp.headdb.core.task.UpdateTask;
|
import tsp.headdb.core.task.UpdateTask;
|
||||||
|
|
||||||
import tsp.headdb.core.util.BuildProperties;
|
import tsp.headdb.core.util.BuildProperties;
|
||||||
|
import tsp.headdb.core.util.HeadDBLogger;
|
||||||
import tsp.smartplugin.SmartPlugin;
|
import tsp.smartplugin.SmartPlugin;
|
||||||
import tsp.smartplugin.inventory.PaneListener;
|
import tsp.smartplugin.inventory.PaneListener;
|
||||||
import tsp.smartplugin.localization.TranslatableLocalization;
|
import tsp.smartplugin.localization.TranslatableLocalization;
|
||||||
import tsp.smartplugin.logger.PluginLogger;
|
|
||||||
import tsp.smartplugin.utils.PluginUtils;
|
import tsp.smartplugin.utils.PluginUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -34,7 +34,7 @@ import java.util.Optional;
|
|||||||
public class HeadDB extends SmartPlugin {
|
public class HeadDB extends SmartPlugin {
|
||||||
|
|
||||||
private static HeadDB instance;
|
private static HeadDB instance;
|
||||||
private PluginLogger logger;
|
private HeadDBLogger logger;
|
||||||
private BuildProperties buildProperties;
|
private BuildProperties buildProperties;
|
||||||
private TranslatableLocalization localization;
|
private TranslatableLocalization localization;
|
||||||
private Storage storage;
|
private Storage storage;
|
||||||
@ -45,7 +45,7 @@ public class HeadDB extends SmartPlugin {
|
|||||||
public void onStart() {
|
public void onStart() {
|
||||||
instance = this;
|
instance = this;
|
||||||
instance.saveDefaultConfig();
|
instance.saveDefaultConfig();
|
||||||
instance.logger = new PluginLogger(this, getConfig().getBoolean("debug"));
|
instance.logger = new HeadDBLogger(getConfig().getBoolean("debug"));
|
||||||
instance.logger.info("Loading HeadDB - " + instance.getDescription().getVersion());
|
instance.logger.info("Loading HeadDB - " + instance.getDescription().getVersion());
|
||||||
instance.buildProperties = new BuildProperties(this);
|
instance.buildProperties = new BuildProperties(this);
|
||||||
|
|
||||||
@ -56,7 +56,6 @@ public class HeadDB extends SmartPlugin {
|
|||||||
instance.initEconomy();
|
instance.initEconomy();
|
||||||
|
|
||||||
new PaneListener(this);
|
new PaneListener(this);
|
||||||
//new PlayerJoinListener();
|
|
||||||
|
|
||||||
instance.commandManager = new CommandManager();
|
instance.commandManager = new CommandManager();
|
||||||
loadCommands();
|
loadCommands();
|
||||||
@ -167,7 +166,7 @@ public class HeadDB extends SmartPlugin {
|
|||||||
return Optional.ofNullable(economyProvider);
|
return Optional.ofNullable(economyProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("DataFlowIssue")
|
||||||
private DecimalFormat decimalFormat = new DecimalFormat(getConfig().getString("economy.format"));
|
private DecimalFormat decimalFormat = new DecimalFormat(getConfig().getString("economy.format"));
|
||||||
|
|
||||||
public DecimalFormat getDecimalFormat() {
|
public DecimalFormat getDecimalFormat() {
|
||||||
@ -182,7 +181,7 @@ public class HeadDB extends SmartPlugin {
|
|||||||
return buildProperties;
|
return buildProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginLogger getLog() {
|
public HeadDBLogger getLog() {
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,10 @@ import java.math.BigDecimal;
|
|||||||
*
|
*
|
||||||
* @author TheSilentPro (Silent)
|
* @author TheSilentPro (Silent)
|
||||||
* @see Event#isAsynchronous()
|
* @see Event#isAsynchronous()
|
||||||
|
*
|
||||||
|
* @deprecated Possible issues.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class HeadPurchaseEvent extends Event implements Cancellable {
|
public class HeadPurchaseEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
@ -90,24 +90,12 @@ public class CommandMain extends HeadDBCommand implements CommandExecutor, TabCo
|
|||||||
// favorites
|
// favorites
|
||||||
pane.setButton(getInstance().getConfig().getInt("gui.main.meta.favorites.slot"), new Button(Utils.getItemFromConfig("gui.main.meta.favorites.item", Material.BOOK), e -> {
|
pane.setButton(getInstance().getConfig().getInt("gui.main.meta.favorites.slot"), new Button(Utils.getItemFromConfig("gui.main.meta.favorites.item", Material.BOOK), e -> {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
List<Head> heads = HeadAPI.getFavoriteHeads(player.getUniqueId());
|
if (!player.hasPermission("headdb.favorites")) {
|
||||||
PagedPane main = Utils.createPaged(player, Utils.translateTitle(getLocalization().getMessage(player.getUniqueId(), "menu.main.favorites.name").orElse("Favorites"), heads.size(), "Favorites"));
|
HeadDB.getInstance().getLocalization().sendMessage(player, "noAccessFavorites");
|
||||||
for (Head head : heads) {
|
return;
|
||||||
main.addButton(new Button(head.getItem(player.getUniqueId()), fe -> {
|
|
||||||
if (fe.isLeftClick()) {
|
|
||||||
ItemStack favoriteItem = head.getItem(player.getUniqueId());
|
|
||||||
if (fe.isShiftClick()) {
|
|
||||||
favoriteItem.setAmount(64);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.getInventory().addItem(favoriteItem);
|
|
||||||
} else if (fe.isRightClick()) {
|
|
||||||
HeadDB.getInstance().getStorage().getPlayerStorage().removeFavorite(player.getUniqueId(), head.getTexture());
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main.open(player);
|
Utils.openFavoritesMenu(player);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// search
|
// search
|
||||||
|
@ -16,7 +16,7 @@ public class VaultProvider implements BasicEconomyProvider {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> canPurchase(Player player, BigDecimal cost) {
|
public CompletableFuture<Boolean> canPurchase(Player player, BigDecimal cost) {
|
||||||
double effectiveCost = cost.doubleValue();
|
double effectiveCost = cost.doubleValue();
|
||||||
return CompletableFuture.supplyAsync(() -> economy.has(player, effectiveCost >= 0 ? effectiveCost : 0)); // Vault is really old...
|
return CompletableFuture.supplyAsync(() -> economy.has(player, effectiveCost >= 0 ? effectiveCost : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,12 +28,12 @@ public class VaultProvider implements BasicEconomyProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
if (!Bukkit.getServer().getPluginManager().isPluginEnabled("Vault")) {
|
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||||
HeadDB.getInstance().getLog().error("Vault is not installed!");
|
HeadDB.getInstance().getLog().error("Vault is not installed!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||||
if (economyProvider == null) {
|
if (economyProvider == null) {
|
||||||
HeadDB.getInstance().getLog().error("Could not find vault economy provider!");
|
HeadDB.getInstance().getLog().error("Could not find vault economy provider!");
|
||||||
return;
|
return;
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package tsp.headdb.core.listener;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import tsp.headdb.HeadDB;
|
|
||||||
|
|
||||||
public final class PlayerJoinListener implements Listener {
|
|
||||||
|
|
||||||
public PlayerJoinListener() {
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, HeadDB.getInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
//HeadDB.getInstance().getStorage().getPlayerStorage().register(new PlayerData(event.getPlayer().getUniqueId(), ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -2,11 +2,12 @@ package tsp.headdb.core.task;
|
|||||||
|
|
||||||
import tsp.headdb.HeadDB;
|
import tsp.headdb.HeadDB;
|
||||||
import tsp.headdb.core.api.HeadAPI;
|
import tsp.headdb.core.api.HeadAPI;
|
||||||
|
import tsp.headdb.implementation.head.Head;
|
||||||
import tsp.smartplugin.tasker.Task;
|
import tsp.smartplugin.tasker.Task;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@SuppressWarnings("ClassCanBeRecord")
|
|
||||||
public class UpdateTask implements Task {
|
public class UpdateTask implements Task {
|
||||||
|
|
||||||
private final long interval;
|
private final long interval;
|
||||||
@ -17,7 +18,15 @@ public class UpdateTask implements Task {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
HeadAPI.getDatabase().update((time, heads) -> HeadDB.getInstance().getLog().debug("Fetched: " + heads.size() + " Heads | Provider: " + HeadAPI.getDatabase().getRequester().getProvider().name() + " | Time: " + time + "ms (" + TimeUnit.MILLISECONDS.toSeconds(time) + "s)"));
|
HeadAPI.getDatabase().update((time, heads) -> {
|
||||||
|
int size = 0;
|
||||||
|
for (List<Head> list : heads.values()) {
|
||||||
|
for (Head ignored : list) {
|
||||||
|
size++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HeadDB.getInstance().getLog().debug("Fetched: " + size + " Heads | Provider: " + HeadAPI.getDatabase().getRequester().getProvider().name() + " | Time: " + time + "ms (" + TimeUnit.MILLISECONDS.toSeconds(time) + "s)");
|
||||||
|
});
|
||||||
HeadDB.getInstance().getStorage().getPlayerStorage().backup();
|
HeadDB.getInstance().getStorage().getPlayerStorage().backup();
|
||||||
HeadDB.getInstance().getLog().debug("UpdateTask finished!");
|
HeadDB.getInstance().getLog().debug("UpdateTask finished!");
|
||||||
}
|
}
|
||||||
|
62
src/main/java/tsp/headdb/core/util/HeadDBLogger.java
Normale Datei
62
src/main/java/tsp/headdb/core/util/HeadDBLogger.java
Normale Datei
@ -0,0 +1,62 @@
|
|||||||
|
package tsp.headdb.core.util;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import tsp.smartplugin.utils.StringUtils;
|
||||||
|
|
||||||
|
public class HeadDBLogger {
|
||||||
|
|
||||||
|
private final boolean debug;
|
||||||
|
|
||||||
|
public HeadDBLogger(boolean debug) {
|
||||||
|
this.debug = debug;
|
||||||
|
}
|
||||||
|
public void info(String message) {
|
||||||
|
this.log(LogLevel.INFO, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warning(String message) {
|
||||||
|
this.log(LogLevel.WARNING, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message) {
|
||||||
|
this.log(LogLevel.ERROR, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message) {
|
||||||
|
this.log(LogLevel.DEBUG, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(String message) {
|
||||||
|
this.log(LogLevel.TRACE, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(LogLevel level, String message) {
|
||||||
|
if ((level == LogLevel.DEBUG || level == LogLevel.TRACE) && !debug) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bukkit.getConsoleSender().sendMessage(StringUtils.colorize(level.getColor() + "[" + level.name() + "]: " + message));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDebug() {
|
||||||
|
return this.debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum LogLevel {
|
||||||
|
INFO,
|
||||||
|
WARNING,
|
||||||
|
ERROR,
|
||||||
|
DEBUG,
|
||||||
|
TRACE;
|
||||||
|
|
||||||
|
public String getColor() {
|
||||||
|
return switch (this) {
|
||||||
|
case INFO -> "\u001b[32m";
|
||||||
|
case WARNING -> "\u001b[33m";
|
||||||
|
case ERROR -> "\u001b[31m";
|
||||||
|
case DEBUG -> "\u001b[36m";
|
||||||
|
case TRACE -> "\u001b[35m";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,7 +12,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import tsp.headdb.HeadDB;
|
import tsp.headdb.HeadDB;
|
||||||
import tsp.headdb.core.api.HeadAPI;
|
import tsp.headdb.core.api.HeadAPI;
|
||||||
import tsp.headdb.core.api.event.HeadPurchaseEvent;
|
|
||||||
import tsp.headdb.core.economy.BasicEconomyProvider;
|
import tsp.headdb.core.economy.BasicEconomyProvider;
|
||||||
import tsp.headdb.core.hook.Hooks;
|
import tsp.headdb.core.hook.Hooks;
|
||||||
import tsp.headdb.implementation.category.Category;
|
import tsp.headdb.implementation.category.Category;
|
||||||
@ -90,7 +89,7 @@ public class Utils {
|
|||||||
if (item == null) {
|
if (item == null) {
|
||||||
item = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
|
item = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
//noinspection ConstantConditions
|
//noinspection DataFlowIssue
|
||||||
meta.setDisplayName("");
|
meta.setDisplayName("");
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
@ -113,6 +112,34 @@ public class Utils {
|
|||||||
return main;
|
return main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void openFavoritesMenu(Player player) {
|
||||||
|
List<Head> heads = HeadAPI.getFavoriteHeads(player.getUniqueId());
|
||||||
|
PagedPane main = Utils.createPaged(player, Utils.translateTitle(HeadDB.getInstance().getLocalization().getMessage(player.getUniqueId(), "menu.main.favorites.name").orElse("Favorites"), heads.size(), "Favorites"));
|
||||||
|
for (Head head : heads) {
|
||||||
|
main.addButton(new Button(head.getItem(player.getUniqueId()), fe -> {
|
||||||
|
if (!player.hasPermission("headdb.favorites")) {
|
||||||
|
HeadDB.getInstance().getLocalization().sendMessage(player, "noAccessFavorites");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fe.isLeftClick()) {
|
||||||
|
int amount = 1;
|
||||||
|
if (fe.isShiftClick()) {
|
||||||
|
amount = 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils.purchase(player, head, amount);
|
||||||
|
} else if (fe.isRightClick()) {
|
||||||
|
HeadDB.getInstance().getStorage().getPlayerStorage().removeFavorite(player.getUniqueId(), head.getTexture());
|
||||||
|
HeadDB.getInstance().getLocalization().sendMessage(player, "removedFavorites");
|
||||||
|
openFavoritesMenu(player);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
main.open(player);
|
||||||
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public static void addHeads(Player player, @Nullable Category category, PagedPane pane, Collection<Head> heads) {
|
public static void addHeads(Player player, @Nullable Category category, PagedPane pane, Collection<Head> heads) {
|
||||||
for (Head head : heads) {
|
for (Head head : heads) {
|
||||||
@ -133,7 +160,12 @@ public class Utils {
|
|||||||
|
|
||||||
purchase(player, head, amount);
|
purchase(player, head, amount);
|
||||||
} else if (e.isRightClick()) {
|
} else if (e.isRightClick()) {
|
||||||
HeadDB.getInstance().getStorage().getPlayerStorage().addFavorite(player.getUniqueId(), head.getTexture());
|
if (player.hasPermission("headdb.favorites")) {
|
||||||
|
HeadDB.getInstance().getStorage().getPlayerStorage().addFavorite(player.getUniqueId(), head.getTexture());
|
||||||
|
HeadDB.getInstance().getLocalization().sendMessage(player, "addedFavorites");
|
||||||
|
} else {
|
||||||
|
HeadDB.getInstance().getLocalization().sendMessage(player, "noAccessFavorites");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -151,35 +183,52 @@ public class Utils {
|
|||||||
.replace("%cost%", HeadDB.getInstance().getDecimalFormat().format(cost))
|
.replace("%cost%", HeadDB.getInstance().getDecimalFormat().format(cost))
|
||||||
);
|
);
|
||||||
return optional.get().purchase(player, cost).thenApply(success -> {
|
return optional.get().purchase(player, cost).thenApply(success -> {
|
||||||
HeadPurchaseEvent event = new HeadPurchaseEvent(player, head, cost, success);
|
Bukkit.getScheduler().runTask(HeadDB.getInstance(), () -> {
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
if (success) {
|
||||||
return !event.isCancelled() && success;
|
HeadDB.getInstance().getLocalization().sendMessage(player, "completePayment", msg -> msg
|
||||||
|
.replace("%name%", head.getName())
|
||||||
|
.replace("%cost%", cost.toString()));
|
||||||
|
} else {
|
||||||
|
HeadDB.getInstance().getLocalization().sendMessage(player, "invalidFunds", msg -> msg.replace("%name%", head.getName()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return success;
|
||||||
|
|
||||||
|
/* Note: Issues caused by sync call to async event but when run async above method fucks up.
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(HeadDB.getInstance(), () -> {
|
||||||
|
HeadPurchaseEvent event = new HeadPurchaseEvent(player, head, cost, success);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void purchase(Player player, Head head, int amount) {
|
public static void purchase(Player player, Head head, int amount) {
|
||||||
processPayment(player, head, amount).whenComplete((success, ex) -> {
|
processPayment(player, head, amount).whenComplete((success, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
HeadDB.getInstance().getLog().error("Failed to purchase head '" + head.getName() + "' for player: " + player.getName());
|
HeadDB.getInstance().getLog().error("Failed to purchase head '" + head.getName() + "' for player: " + player.getName());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
} else {
|
} else {
|
||||||
// Bukkit API, therefore task is ran sync.
|
// Bukkit API, therefore task is ran sync.
|
||||||
Bukkit.getScheduler().runTask(HeadDB.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HeadDB.getInstance(), () -> {
|
||||||
ItemStack item = head.getItem(player.getUniqueId());
|
if (success) {
|
||||||
item.setAmount(amount);
|
ItemStack item = head.getItem(player.getUniqueId());
|
||||||
player.getInventory().addItem(item);
|
item.setAmount(amount);
|
||||||
HeadDB.getInstance().getConfig().getStringList("commands.purchase").forEach(command -> {
|
player.getInventory().addItem(item);
|
||||||
if (command.isEmpty()) {
|
HeadDB.getInstance().getConfig().getStringList("commands.purchase").forEach(command -> {
|
||||||
return;
|
if (command.isEmpty()) {
|
||||||
}
|
return;
|
||||||
if (Hooks.PAPI.enabled()) {
|
}
|
||||||
command = PlaceholderAPI.setPlaceholders(player, command);
|
if (Hooks.PAPI.enabled()) {
|
||||||
}
|
command = PlaceholderAPI.setPlaceholders(player, command);
|
||||||
|
}
|
||||||
|
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -220,7 +269,6 @@ public class Utils {
|
|||||||
ConfigurationSection section = HeadDB.getInstance().getConfig().getConfigurationSection(path);
|
ConfigurationSection section = HeadDB.getInstance().getConfig().getConfigurationSection(path);
|
||||||
Validate.notNull(section, "Section can not be null!");
|
Validate.notNull(section, "Section can not be null!");
|
||||||
|
|
||||||
System.out.println("Checking for: provided material in '" + section.getName() + "' -> " + section.getString("material"));
|
|
||||||
Material material = Material.matchMaterial(section.getString("material", def.name()));
|
Material material = Material.matchMaterial(section.getString("material", def.name()));
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
material = def;
|
material = def;
|
||||||
@ -230,7 +278,7 @@ public class Utils {
|
|||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
|
||||||
if (meta != null) {
|
if (meta != null) {
|
||||||
//noinspection ConstantConditions
|
//noinspection DataFlowIssue
|
||||||
meta.setDisplayName(StringUtils.colorize(section.getString("name")));
|
meta.setDisplayName(StringUtils.colorize(section.getString("name")));
|
||||||
|
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
@ -57,7 +57,7 @@ public class Head {
|
|||||||
GameProfile profile = new GameProfile(uniqueId, name);
|
GameProfile profile = new GameProfile(uniqueId, name);
|
||||||
profile.getProperties().put("textures", new Property("textures", texture));
|
profile.getProperties().put("textures", new Property("textures", texture));
|
||||||
try {
|
try {
|
||||||
//noinspection ConstantConditions
|
//noinspection DataFlowIssue
|
||||||
Field profileField = meta.getClass().getDeclaredField("profile");
|
Field profileField = meta.getClass().getDeclaredField("profile");
|
||||||
profileField.setAccessible(true);
|
profileField.setAccessible(true);
|
||||||
profileField.set(meta, profile);
|
profileField.set(meta, profile);
|
||||||
|
@ -11,7 +11,7 @@ requireCategoryPermission: false
|
|||||||
|
|
||||||
# Economy Options
|
# Economy Options
|
||||||
economy:
|
economy:
|
||||||
enable: false
|
enabled: false
|
||||||
provider: "VAULT" # Supported: VAULT
|
provider: "VAULT" # Supported: VAULT
|
||||||
format: "##.##"
|
format: "##.##"
|
||||||
cost:
|
cost:
|
||||||
|
@ -7,6 +7,7 @@ invalidTarget: "&cInvalid target: &e%name%"
|
|||||||
invalidCategory: "&cInvalid Category!"
|
invalidCategory: "&cInvalid Category!"
|
||||||
invalidNumber: "&e%name% &cis not a number!"
|
invalidNumber: "&e%name% &cis not a number!"
|
||||||
invalidPageIndex: "&cThat page is out of bounds! Max: %pages%"
|
invalidPageIndex: "&cThat page is out of bounds! Max: %pages%"
|
||||||
|
noAccessFavorites: "&cYou do not have access to favorites!"
|
||||||
|
|
||||||
openDatabase: "" # Intentionally empty. Sent when the main gui is opened
|
openDatabase: "" # Intentionally empty. Sent when the main gui is opened
|
||||||
updateDatabase: "&7Updating..."
|
updateDatabase: "&7Updating..."
|
||||||
@ -19,10 +20,13 @@ giveCommand: "&7Gave &6x%size% %name% &7to &6%receiver%"
|
|||||||
itemTexture: "&7Texture: &6%texture%"
|
itemTexture: "&7Texture: &6%texture%"
|
||||||
itemNoTexture: "&cThis item does not have a texture!"
|
itemNoTexture: "&cThis item does not have a texture!"
|
||||||
copyTexture: "&6Click to copy texture!"
|
copyTexture: "&6Click to copy texture!"
|
||||||
|
addedFavorite: "&7Added &6%name% &7to your favorites!"
|
||||||
|
removedFavorite: "&7Removed &6%name% &7from your favorites!"
|
||||||
|
|
||||||
# Only shown if economy is enabled
|
# Only shown if economy is enabled
|
||||||
processPayment: "&7Purchasing &6%name% &7for &6%cost%&7! Please wait..."
|
processPayment: "&7Purchasing &6%name% &7for &6%cost%&7! Please wait..."
|
||||||
completePayment: "&7Received &6%name% &7for &6%cost%"
|
completePayment: "&7Received &6%name% &7for &6%cost%"
|
||||||
|
invalidFunds: "&cYou do not have enough to buy &6%name%&c!"
|
||||||
|
|
||||||
invalidLanguage: "&cInvalid Language! Available: &e%languages%"
|
invalidLanguage: "&cInvalid Language! Available: &e%languages%"
|
||||||
languageChanged: "&7Your language was set to: &6%language%"
|
languageChanged: "&7Your language was set to: &6%language%"
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
#file: noinspection YAMLSchemaValidation
|
||||||
name: ${project.name}
|
name: ${project.name}
|
||||||
description: ${project.description}
|
description: ${project.description}
|
||||||
|
|
||||||
main: tsp.headdb.HeadDB
|
main: tsp.headdb.HeadDB
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
softdepend: [Vault, Treasury]
|
depend: ["Vault"]
|
||||||
api-version: 1.19
|
api-version: 1.19
|
||||||
author: TheSilentPro (Silent)
|
author: TheSilentPro (Silent)
|
||||||
spigot-id: 84967
|
spigot-id: 84967
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren