Sell Sound

Should cover #171
This commit is contained in:
TrueDarkLord 2024-03-09 11:05:23 -07:00
parent fa47a8a089
commit 35768c9e34
No known key found for this signature in database
GPG Key ID: 02AA15A3B1FAFE4F
2 changed files with 14 additions and 0 deletions

View File

@ -23,6 +23,8 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -510,6 +512,16 @@ public class GuiListener implements Listener {
}
}
}
private void playSoldSound(@NotNull Player player) {
FileConfiguration config = Files.CONFIG.getFile();
String sound = config.getString("Settings.Sold-Item-Sound", "");
if (sound.isEmpty()) return;
try {
player.playSound(player.getLocation(), Sound.valueOf(sound), 1, 1);
} catch (Exception ignored) {}
}
@EventHandler
public void onInvClose(InventoryCloseEvent e) {
@ -889,6 +901,7 @@ public class GuiListener implements Listener {
if (Methods.isOnline(seller) && Methods.getPlayer(seller) != null) {
Player sell = Methods.getPlayer(seller);
sell.sendMessage(Messages.PLAYER_BOUGHT_ITEM.getMessage(placeholders));
playSoldSound(sell);
}
player.getInventory().addItem(i);

View File

@ -24,6 +24,7 @@ Settings:
Sounds:
Toggle: false #Disable the clicking sound.
Sound: 'CLICK' #Make sure if you use 1.8 or lower you use the 1.8 sound and 1.9 and up use 1.9 sounds. The default sound is 1.8.
Sold-Item-Sound: 'CLICK'
#Sounds are found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html
GUISettings: #Settings for things in the gui.
SellingItemLore: #The lore on items that are being sold.