geforkt von Mirrors/HeadDB
Sound customization & per category permission
Dieser Commit ist enthalten in:
Ursprung
9adafdc57b
Commit
1bd19efd20
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>tsp.headdb</groupId>
|
||||
<artifactId>HeadDB</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>3.1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HeadDB</name>
|
||||
|
@ -93,7 +93,6 @@ public class InventoryUtils {
|
||||
return;
|
||||
}
|
||||
if (e.getClick() == ClickType.RIGHT) {
|
||||
player.closeInventory();
|
||||
Utils.sendMessage(player, "&cLocal heads can not be added to favorites!");
|
||||
}
|
||||
}));
|
||||
@ -119,6 +118,7 @@ public class InventoryUtils {
|
||||
HeadAPI.removeFavoriteHead(player.getUniqueId(), head.getValue());
|
||||
openFavoritesMenu(player);
|
||||
Utils.sendMessage(player, "&7Removed &e" + head.getName() + " &7from favorites.");
|
||||
Utils.playSound(player, "removeFavorite");
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ -140,8 +140,15 @@ public class InventoryUtils {
|
||||
purchaseHead(player, head, 1, head.getCategory().getName(), head.getName());
|
||||
}
|
||||
if (e.getClick() == ClickType.RIGHT) {
|
||||
if (!player.hasPermission("headdb.favorites")) {
|
||||
Utils.sendMessage(player, "&cYou do not have permission for favorites!");
|
||||
Utils.playSound(player, "noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
HeadAPI.addFavoriteHead(player.getUniqueId(), head.getValue());
|
||||
Utils.sendMessage(player, "&7Added &e" + head.getName() + " &7to favorites.");
|
||||
Utils.playSound(player, "addFavorite");
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ -164,8 +171,15 @@ public class InventoryUtils {
|
||||
purchaseHead(player, head, 1, head.getCategory().getName(), head.getName());
|
||||
}
|
||||
if (e.getClick() == ClickType.RIGHT) {
|
||||
if (!player.hasPermission("headdb.favorites")) {
|
||||
Utils.sendMessage(player, "&cYou do not have permission for favorites!");
|
||||
Utils.playSound(player, "noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
HeadAPI.addFavoriteHead(player.getUniqueId(), head.getValue());
|
||||
Utils.sendMessage(player, "&7Added &e" + head.getName() + " &7to favorites.");
|
||||
Utils.playSound(player, "addFavorite");
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ -187,8 +201,15 @@ public class InventoryUtils {
|
||||
purchaseHead(player, head, 1, head.getCategory().getName(), head.getName());
|
||||
}
|
||||
if (e.getClick() == ClickType.RIGHT) {
|
||||
if (!player.hasPermission("headdb.favorites")) {
|
||||
Utils.sendMessage(player, "&cYou do not have permission for favorites!");
|
||||
Utils.playSound(player, "noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
HeadAPI.addFavoriteHead(player.getUniqueId(), head.getValue());
|
||||
Utils.sendMessage(player, "&7Added &e" + head.getName() + " &7to favorites.");
|
||||
Utils.playSound(player, "addFavorite");
|
||||
}
|
||||
}));
|
||||
}
|
||||
@ -287,6 +308,7 @@ public class InventoryUtils {
|
||||
// Don't mention receiving it for free in this case, since it is always free.
|
||||
if (economy == null) {
|
||||
Utils.sendMessage(player, String.format("&7You received &e%d &7x &e%s&7!", amount, description));
|
||||
Utils.playSound(player, "noEconomy");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -296,20 +318,24 @@ public class InventoryUtils {
|
||||
if (cost > 0) {
|
||||
if (economy.has(player, cost)) {
|
||||
economy.withdrawPlayer(player, cost);
|
||||
Utils.sendMessage(player, String.format("&7You purchased &e%d &7x &e%s &7for &e%.2f %s&7!", amount, description, cost, economy.currencyNamePlural()));
|
||||
Utils.sendMessage(player, String.format("&7You purchased &e%d &7x &e%s &7for &e%.2f&7!", amount, description, cost));
|
||||
Utils.playSound(player, "paid");
|
||||
return true;
|
||||
}
|
||||
Utils.sendMessage(player, String.format("&7You do not have enough &e%s &cto purchase &e%d &cx &e%s&7.", economy.currencyNamePlural(), amount, description));
|
||||
Utils.sendMessage(player, String.format("&cYou do not have enough to purchase &e%d &cx &e%s&7.", amount, description));
|
||||
Utils.playSound(player, "unavailable");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, the item is free.
|
||||
Utils.sendMessage(player, String.format("&7You received &e%d &7x &e%s &7for &efree&7!", amount, description));
|
||||
Utils.playSound(player, "free");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void purchaseHead(Player player, Head head, int amount, String category, String description) {
|
||||
if (!processPayment(player, amount, category, description)) return;
|
||||
|
||||
PlayerHeadPurchaseEvent event = new PlayerHeadPurchaseEvent(player, head, getCategoryCost(player, category));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
|
@ -40,23 +40,34 @@ public class MenuListener implements Listener {
|
||||
String name = ChatColor.stripColor(item.getItemMeta().getDisplayName().toLowerCase());
|
||||
if (name.equalsIgnoreCase("favorites")) {
|
||||
if (!player.hasPermission("headdb.favorites")) {
|
||||
Utils.sendMessage(player, "&cYou do not have permission for favorites!");
|
||||
player.closeInventory();
|
||||
Utils.sendMessage(player, "&cYou do not have permission for favorites!");
|
||||
Utils.playSound(player, "noPermission");
|
||||
return;
|
||||
}
|
||||
InventoryUtils.openFavoritesMenu(player);
|
||||
Utils.playSound(player, "open");
|
||||
return;
|
||||
}
|
||||
if (name.equalsIgnoreCase("local")) {
|
||||
if (!player.hasPermission("headdb.local")) {
|
||||
Utils.sendMessage(player, "&cYou do not have permission to view local heads!");
|
||||
player.closeInventory();
|
||||
Utils.sendMessage(player, "&cYou do not have permission to view local heads!");
|
||||
Utils.playSound(player, "noPermission");
|
||||
return;
|
||||
}
|
||||
InventoryUtils.openLocalMenu(player);
|
||||
Utils.playSound(player, "open");
|
||||
return;
|
||||
}
|
||||
if (name.equalsIgnoreCase("search")) {
|
||||
if (!player.hasPermission("headdb.search")) {
|
||||
player.closeInventory();
|
||||
Utils.sendMessage(player, "&cYou do not have permission for the search function!");
|
||||
Utils.playSound(player, "noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
new AnvilGUI.Builder()
|
||||
.onComplete((p, text) -> {
|
||||
InventoryUtils.openSearchDatabase(p, text);
|
||||
@ -66,12 +77,20 @@ public class MenuListener implements Listener {
|
||||
.text("Name...")
|
||||
.plugin(HeadDB.getInstance())
|
||||
.open(player);
|
||||
Utils.playSound(player, "open");
|
||||
return;
|
||||
}
|
||||
|
||||
Category category = Category.getByName(name);
|
||||
|
||||
if (category != null) {
|
||||
if (HeadDB.getInstance().getConfig().getBoolean("requireCategoryPermission") && !player.hasPermission("headdb.category." + category)) {
|
||||
Utils.sendMessage(player, "&cYou do not have permission for this category! (&e" + category.getName() + "&c)");
|
||||
Utils.playSound(player, "noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.playSound(player, "open");
|
||||
HeadAPI.openCategoryDatabase(player, category);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,17 @@
|
||||
package tsp.headdb.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import tsp.headdb.HeadDB;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Utils {
|
||||
|
||||
private static final FileConfiguration config = HeadDB.getInstance().getConfig();
|
||||
public static final Pattern UUID_PATTERN = Pattern.compile("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}");
|
||||
|
||||
/**
|
||||
@ -19,6 +24,18 @@ public class Utils {
|
||||
return UUID_PATTERN.matcher(uuid).matches();
|
||||
}
|
||||
|
||||
public static void playSound(Player player, String key) {
|
||||
// Check if sound is enabled
|
||||
if (!config.getBoolean("ui.sound.enabled")) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(),
|
||||
Sound.valueOf(config.getString("ui.sound." + key + ".name")),
|
||||
(float) config.getDouble("ui.sound." + key + ".volume"),
|
||||
(float) config.getDouble("ui.sound." + key + ".pitch"));
|
||||
}
|
||||
|
||||
public static void sendMessage(CommandSender sender, String message) {
|
||||
sender.sendMessage(colorize(message));
|
||||
}
|
||||
|
@ -4,6 +4,10 @@ refresh: 3600
|
||||
# If local heads should be enabled. Only starts keeping track of joined players when enabled!
|
||||
localHeads: true
|
||||
|
||||
# If enabled categories will require a permission to be used
|
||||
# Permission: headdb.category.<category>
|
||||
requireCategoryPermission: false
|
||||
|
||||
# Economy options
|
||||
economy:
|
||||
enable: false
|
||||
@ -67,6 +71,52 @@ ui:
|
||||
# Item used to fill unused slots in the categories menu. AIR is supported. You can use head: instead of item: here.
|
||||
fill:
|
||||
item: BLACK_STAINED_GLASS_PANE
|
||||
sound:
|
||||
# Whether the sounds should be played
|
||||
enabled: true
|
||||
|
||||
# Played when a head is taken with no economy plugin
|
||||
noEconomy:
|
||||
# The name of the sound.
|
||||
# Must be one from: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html
|
||||
name: ENTITY_EXPERIENCE_ORB_PICKUP
|
||||
volume: 1
|
||||
pitch: 1
|
||||
# Played when the player doesn't have permission for the menu
|
||||
noPermission:
|
||||
name: BLOCK_ANVIL_BREAK
|
||||
volume: 1
|
||||
pitch: 1
|
||||
# Played when they purchase a head
|
||||
paid:
|
||||
name: ENTITY_EXPERIENCE_ORB_PICKUP
|
||||
volume: 1
|
||||
pitch: 1
|
||||
# Played when the head is free
|
||||
free:
|
||||
name: ENTITY_EXPERIENCE_ORB_PICKUP
|
||||
volume: 1
|
||||
pitch: 1
|
||||
# Played when the player does not have enough funds for the head
|
||||
unavailable:
|
||||
name: BLOCK_ANVIL_BREAK
|
||||
volume: 1
|
||||
pitch: 1
|
||||
# Played when a category/menu is opened
|
||||
open:
|
||||
name: ENTITY_EXPERIENCE_ORB_PICKUP
|
||||
volume: 1
|
||||
pitch: 1
|
||||
# Played when a head is added to the favorites list
|
||||
addFavorite:
|
||||
name: ENTITY_EXPERIENCE_ORB_PICKUP
|
||||
volume: 1
|
||||
pitch: 1
|
||||
# Played when a head is removed to from favorites list
|
||||
removeFavorite:
|
||||
name: BLOCK_ANVIL_BREAK
|
||||
volume: 1
|
||||
pitch: 1
|
||||
|
||||
# Debug Mode
|
||||
debug: false
|
||||
debug: false
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren