Added a sounds.yml file where you can configure a few of the sounds played in MMOCore. Contains configurations for class select, attribute points, waypoint sounds and more.

This commit is contained in:
ASangarin 2020-12-20 00:55:31 +01:00
parent bedc83896f
commit 56257c442d
18 changed files with 193 additions and 29 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.Indyuce</groupId> <groupId>net.Indyuce</groupId>
<artifactId>MMOCore</artifactId> <artifactId>MMOCore</artifactId>
<version>1.6</version> <version>1.6.1</version>
<name>MMOCore</name> <name>MMOCore</name>
<description>Offer your players a brand new RPG experience.</description> <description>Offer your players a brand new RPG experience.</description>

View File

@ -70,6 +70,7 @@ import net.Indyuce.mmocore.manager.MMOLoadManager;
import net.Indyuce.mmocore.manager.QuestManager; import net.Indyuce.mmocore.manager.QuestManager;
import net.Indyuce.mmocore.manager.RestrictionManager; import net.Indyuce.mmocore.manager.RestrictionManager;
import net.Indyuce.mmocore.manager.SkillManager; import net.Indyuce.mmocore.manager.SkillManager;
import net.Indyuce.mmocore.manager.SoundManager;
import net.Indyuce.mmocore.manager.WaypointManager; import net.Indyuce.mmocore.manager.WaypointManager;
import net.Indyuce.mmocore.manager.data.DataProvider; import net.Indyuce.mmocore.manager.data.DataProvider;
import net.Indyuce.mmocore.manager.data.mysql.MySQLDataProvider; import net.Indyuce.mmocore.manager.data.mysql.MySQLDataProvider;
@ -102,6 +103,7 @@ public class MMOCore extends JavaPlugin {
public ConfigManager configManager; public ConfigManager configManager;
public WaypointManager waypointManager; public WaypointManager waypointManager;
public RestrictionManager restrictionManager; public RestrictionManager restrictionManager;
public SoundManager soundManager;
public RequestManager requestManager; public RequestManager requestManager;
public ConfigItemManager configItems; public ConfigItemManager configItems;
public VaultEconomy economy; public VaultEconomy economy;
@ -419,6 +421,7 @@ public class MMOCore extends JavaPlugin {
waypointManager = new WaypointManager(new ConfigFile("waypoints").getConfig()); waypointManager = new WaypointManager(new ConfigFile("waypoints").getConfig());
restrictionManager = new RestrictionManager(new ConfigFile("restrictions").getConfig()); restrictionManager = new RestrictionManager(new ConfigFile("restrictions").getConfig());
requestManager = new RequestManager(); requestManager = new RequestManager();
soundManager = new SoundManager(new ConfigFile("sounds").getConfig());
configItems = new ConfigItemManager(new ConfigFile("items").getConfig()); configItems = new ConfigItemManager(new ConfigFile("items").getConfig());
if (getConfig().isConfigurationSection("action-bar")) if (getConfig().isConfigurationSection("action-bar"))

View File

@ -0,0 +1,53 @@
package net.Indyuce.mmocore.api;
import org.bukkit.Sound;
public class SoundObject {
private final Sound sound;
private final String key;
private final float volume;
private final float pitch;
public SoundObject(String input) {
String[] split = input.split(",");
if(split.length > 2) {
input = split[0];
volume = Float.parseFloat(split[1]);
pitch = Float.parseFloat(split[1]);
} else {
volume = 1;
pitch = 1;
}
Sound sound = null;
String key = "";
try {
sound = Sound.valueOf(input.toUpperCase().replace("-", "_"));
} catch(Exception ignored) {
key = input;
}
this.sound = sound;
this.key = key;
}
public boolean hasSound() {
return key.isEmpty();
}
public Sound getSound() {
return sound;
}
public String getKey() {
return key;
}
public float getVolume() {
return volume;
}
public float getPitch() {
return pitch;
}
}

View File

@ -4,12 +4,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import net.Indyuce.mmocore.manager.SoundManager;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -175,7 +175,7 @@ public class PlayerProfessions {
new SmallParticleEffect(playerData.getPlayer(), Particle.SPELL_INSTANT); new SmallParticleEffect(playerData.getPlayer(), Particle.SPELL_INSTANT);
new ConfigMessage("profession-level-up").addPlaceholders("level", "" + level, "profession", profession.getName()) new ConfigMessage("profession-level-up").addPlaceholders("level", "" + level, "profession", profession.getName())
.send(playerData.getPlayer()); .send(playerData.getPlayer());
playerData.getPlayer().playSound(playerData.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2); MMOCore.plugin.soundManager.play(playerData.getPlayer(), SoundManager.SoundEvent.LEVEL_UP);
playerData.getStats().updateStats(); playerData.getStats().updateStats();
} }

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmocore.api.loot; package net.Indyuce.mmocore.api.loot;
import net.Indyuce.mmocore.manager.SoundManager;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Particle; import org.bukkit.Particle;
@ -60,7 +61,7 @@ public class LootChest {
* if a player is responsible of closing the chest, close it with sound * if a player is responsible of closing the chest, close it with sound
*/ */
if (player) { if (player) {
block.loc.getWorld().playSound(block.loc, Sound.ITEM_ARMOR_EQUIP_LEATHER, 1, 1); MMOCore.plugin.soundManager.play(block.loc.getBlock(), SoundManager.SoundEvent.CLOSE_LOOT_CHEST);
block.loc.getWorld().spawnParticle(Particle.CRIT, block.loc.clone().add(.5, .5, .5), 16, 0, 0, 0, .5); block.loc.getWorld().spawnParticle(Particle.CRIT, block.loc.clone().add(.5, .5, .5), 16, 0, 0, 0, .5);
MMOCore.plugin.lootChests.unregister(this); MMOCore.plugin.lootChests.unregister(this);
} }

View File

@ -10,12 +10,12 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import net.Indyuce.mmocore.manager.SoundManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -416,7 +416,7 @@ public class PlayerData extends OfflinePlayerData {
if(!isOnline()) return; if(!isOnline()) return;
if (getPlayer().getLocation().getBlockX() != x || getPlayer().getLocation().getBlockY() != y if (getPlayer().getLocation().getBlockX() != x || getPlayer().getLocation().getBlockY() != y
|| getPlayer().getLocation().getBlockZ() != z) { || getPlayer().getLocation().getBlockZ() != z) {
getPlayer().playSound(getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, .5f); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.WARP_CANCELLED);
MMOCore.plugin.configManager.getSimpleMessage("warping-canceled").send(getPlayer()); MMOCore.plugin.configManager.getSimpleMessage("warping-canceled").send(getPlayer());
giveStellium(waypoint.getStelliumCost()); giveStellium(waypoint.getStelliumCost());
cancel(); cancel();
@ -427,12 +427,12 @@ public class PlayerData extends OfflinePlayerData {
if (t++ >= 100) { if (t++ >= 100) {
getPlayer().teleport(waypoint.getLocation()); getPlayer().teleport(waypoint.getLocation());
getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false)); getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false));
getPlayer().playSound(getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, .5f); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.WARP_TELEPORT);
cancel(); cancel();
return; return;
} }
getPlayer().playSound(getPlayer().getLocation(), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound(), 1, (float) (t / Math.PI * .015 + .5)); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.WARP_CHARGE, 1, (float) (t / Math.PI * .015 + .5));
double r = Math.sin((double) t / 100 * Math.PI); double r = Math.sin((double) t / 100 * Math.PI);
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4) for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
getPlayer().getLocation().getWorld().spawnParticle(Particle.REDSTONE, getPlayer().getLocation().getWorld().spawnParticle(Particle.REDSTONE,
@ -488,7 +488,7 @@ public class PlayerData extends OfflinePlayerData {
Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(this, null, oldLevel, level)); Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(this, null, oldLevel, level));
if(isOnline()) { if(isOnline()) {
new ConfigMessage("level-up").addPlaceholders("level", "" + level).send(getPlayer()); new ConfigMessage("level-up").addPlaceholders("level", "" + level).send(getPlayer());
getPlayer().playSound(getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.LEVEL_UP);
new SmallParticleEffect(getPlayer(), Particle.SPELL_INSTANT); new SmallParticleEffect(getPlayer(), Particle.SPELL_INSTANT);
} }
getStats().updateStats(); getStats().updateStats();

View File

@ -1,9 +1,8 @@
package net.Indyuce.mmocore.api.player.social; package net.Indyuce.mmocore.api.player.social;
import org.bukkit.Sound;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import org.bukkit.Sound;
public class FriendRequest extends Request { public class FriendRequest extends Request {
private final PlayerData target; private final PlayerData target;

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmocore.gui; package net.Indyuce.mmocore.gui;
import net.Indyuce.mmocore.manager.SoundManager;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
@ -89,13 +90,13 @@ public class AttributeView extends EditableInventory {
int spent = playerData.getAttributes().countSkillPoints(); int spent = playerData.getAttributes().countSkillPoints();
if (spent < 1) { if (spent < 1) {
MMOCore.plugin.configManager.getSimpleMessage("no-attribute-points-spent").send(player); MMOCore.plugin.configManager.getSimpleMessage("no-attribute-points-spent").send(player);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.NOT_ENOUGH_POINTS);
return; return;
} }
if (playerData.getAttributeReallocationPoints() < 1) { if (playerData.getAttributeReallocationPoints() < 1) {
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-reallocation-point").send(player); MMOCore.plugin.configManager.getSimpleMessage("not-attribute-reallocation-point").send(player);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.NOT_ENOUGH_POINTS);
return; return;
} }
@ -103,7 +104,7 @@ public class AttributeView extends EditableInventory {
playerData.giveAttributePoints(spent); playerData.giveAttributePoints(spent);
playerData.giveAttributeReallocationPoints(-1); playerData.giveAttributeReallocationPoints(-1);
MMOCore.plugin.configManager.getSimpleMessage("attribute-points-reallocated", "points", "" + playerData.getAttributePoints()).send(player); MMOCore.plugin.configManager.getSimpleMessage("attribute-points-reallocated", "points", "" + playerData.getAttributePoints()).send(player);
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.RESET_ATTRIBUTES);
open(); open();
} }
@ -112,21 +113,21 @@ public class AttributeView extends EditableInventory {
if (playerData.getAttributePoints() < 1) { if (playerData.getAttributePoints() < 1) {
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point").send(player); MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point").send(player);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.NOT_ENOUGH_POINTS);
return; return;
} }
AttributeInstance ins = playerData.getAttributes().getInstance(attribute); AttributeInstance ins = playerData.getAttributes().getInstance(attribute);
if (attribute.hasMax() && ins.getBase() >= attribute.getMax()) { if (attribute.hasMax() && ins.getBase() >= attribute.getMax()) {
MMOCore.plugin.configManager.getSimpleMessage("attribute-max-points-hit").send(player); MMOCore.plugin.configManager.getSimpleMessage("attribute-max-points-hit").send(player);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.NOT_ENOUGH_POINTS);
return; return;
} }
ins.addBase(1); ins.addBase(1);
playerData.giveAttributePoints(-1); playerData.giveAttributePoints(-1);
MMOCore.plugin.configManager.getSimpleMessage("attribute-level-up", "attribute", attribute.getName(), "level", "" + ins.getBase()).send(player); MMOCore.plugin.configManager.getSimpleMessage("attribute-level-up", "attribute", attribute.getName(), "level", "" + ins.getBase()).send(player);
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.LEVEL_ATTRIBUTE);
open(); open();
} }
} }

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmocore.gui; package net.Indyuce.mmocore.gui;
import net.Indyuce.mmocore.manager.SoundManager;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -136,7 +137,7 @@ public class ClassConfirmation extends EditableInventory {
while (playerData.hasSkillBound(0)) while (playerData.hasSkillBound(0))
playerData.unbindSkill(0); playerData.unbindSkill(0);
MMOCore.plugin.configManager.getSimpleMessage("class-select", "class", profess.getName()).send(player); MMOCore.plugin.configManager.getSimpleMessage("class-select", "class", profess.getName()).send(player);
player.playSound(player.getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1); MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.SELECT_CLASS);
player.closeInventory(); player.closeInventory();
} }
} }

View File

@ -5,6 +5,7 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.Indyuce.mmocore.manager.SoundManager;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -117,14 +118,14 @@ public class ClassSelect extends EditableInventory {
return; return;
if (playerData.getClassPoints() < 1) { if (playerData.getClassPoints() < 1) {
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.CANT_SELECT_CLASS);
new ConfigMessage("cant-choose-new-class").send(player); new ConfigMessage("cant-choose-new-class").send(player);
return; return;
} }
PlayerClass profess = MMOCore.plugin.classManager.get(tag); PlayerClass profess = MMOCore.plugin.classManager.get(tag);
if (profess.equals(playerData.getProfess())) { if (profess.equals(playerData.getProfess())) {
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.CANT_SELECT_CLASS);
MMOCore.plugin.configManager.getSimpleMessage("already-on-class", "class", profess.getName()).send(player); MMOCore.plugin.configManager.getSimpleMessage("already-on-class", "class", profess.getName()).send(player);
return; return;
} }

View File

@ -11,6 +11,7 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem; import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem; import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
import net.Indyuce.mmocore.gui.api.item.Placeholders; import net.Indyuce.mmocore.gui.api.item.Placeholders;
import net.Indyuce.mmocore.manager.SoundManager;
import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem; import net.mmogroup.mmolib.api.item.NBTItem;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
@ -237,7 +238,7 @@ public class QuestViewer extends EditableInventory {
if (playerData.getQuestData().hasCurrent(quest)) { if (playerData.getQuestData().hasCurrent(quest)) {
if (event.getAction() == InventoryAction.PICKUP_HALF) { if (event.getAction() == InventoryAction.PICKUP_HALF) {
playerData.getQuestData().start(null); playerData.getQuestData().start(null);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.CANCEL_QUEST);
MMOCore.plugin.configManager.getSimpleMessage("cancel-quest").send(player); MMOCore.plugin.configManager.getSimpleMessage("cancel-quest").send(player);
open(); open();
} }
@ -295,7 +296,7 @@ public class QuestViewer extends EditableInventory {
* eventually start a new quest. * eventually start a new quest.
*/ */
MMOCore.plugin.configManager.getSimpleMessage("start-quest", "quest", quest.getName()).send(player); MMOCore.plugin.configManager.getSimpleMessage("start-quest", "quest", quest.getName()).send(player);
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.START_QUEST);
playerData.getQuestData().start(quest); playerData.getQuestData().start(quest);
open(); open();
} }

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmocore.gui; package net.Indyuce.mmocore.gui;
import net.Indyuce.mmocore.manager.SoundManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -68,7 +69,7 @@ public class SubclassConfirmation extends EditableInventory {
playerData.setClass(profess); playerData.setClass(profess);
MMOCore.plugin.configManager.getSimpleMessage("class-select", "class", profess.getName()).send(player); MMOCore.plugin.configManager.getSimpleMessage("class-select", "class", profess.getName()).send(player);
player.playSound(player.getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1); MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.SELECT_CLASS);
player.closeInventory(); player.closeInventory();
} }
} }

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.Indyuce.mmocore.manager.SoundManager;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
@ -120,7 +121,7 @@ public class SubclassSelect extends EditableInventory {
if (playerData.getClassPoints() < 1) { if (playerData.getClassPoints() < 1) {
player.closeInventory(); player.closeInventory();
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1); MMOCore.plugin.soundManager.play(getPlayer(), SoundManager.SoundEvent.CANT_SELECT_CLASS);
new ConfigMessage("cant-choose-new-class").send(player); new ConfigMessage("cant-choose-new-class").send(player);
return; return;
} }

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmocore.listener; package net.Indyuce.mmocore.listener;
import net.Indyuce.mmocore.manager.ConfigManager; import net.Indyuce.mmocore.manager.ConfigManager;
import net.Indyuce.mmocore.manager.SoundManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -34,7 +35,7 @@ public class SpellCast implements Listener {
* skill casting mode * skill casting mode
*/ */
if (action == ConfigManager.SwapAction.HOTBAR_SWAP) { if (action == ConfigManager.SwapAction.HOTBAR_SWAP) {
player.playSound(player.getLocation(), Sound.ITEM_ARMOR_EQUIP_LEATHER, 1, 1); MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.HOTBAR_SWAP);
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {
ItemStack replaced = player.getInventory().getItem(j + 9 * 3); ItemStack replaced = player.getInventory().getItem(j + 9 * 3);
player.getInventory().setItem(j + 9 * 3, player.getInventory().getItem(j)); player.getInventory().setItem(j + 9 * 3, player.getInventory().getItem(j));
@ -46,7 +47,7 @@ public class SpellCast implements Listener {
if (!((!MMOCore.plugin.configManager.canCreativeCast && player.getGameMode() == GameMode.CREATIVE) || player.getGameMode() == GameMode.SPECTATOR) if (!((!MMOCore.plugin.configManager.canCreativeCast && player.getGameMode() == GameMode.CREATIVE) || player.getGameMode() == GameMode.SPECTATOR)
&& !playerData.isCasting() && playerData.getBoundSkills().size() > 0) { && !playerData.isCasting() && playerData.getBoundSkills().size() > 0) {
playerData.skillCasting = new SkillCasting(playerData); playerData.skillCasting = new SkillCasting(playerData);
player.playSound(player.getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1, 2); MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.SPELL_CAST_BEGIN);
} }
} }
@ -102,7 +103,7 @@ public class SpellCast implements Listener {
: MMOCore.plugin.configManager.normalSwapAction; : MMOCore.plugin.configManager.normalSwapAction;
if(action != ConfigManager.SwapAction.SPELL_CAST || !playerData.isOnline()) return; if(action != ConfigManager.SwapAction.SPELL_CAST || !playerData.isOnline()) return;
if (event.getPlayer().equals(playerData.getPlayer()) && !player.isSneaking()) { if (event.getPlayer().equals(playerData.getPlayer()) && !player.isSneaking()) {
player.playSound(player.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1, 2); MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.SPELL_CAST_END);
MMOCore.plugin.configManager.getSimpleMessage("casting.no-longer").send(playerData.getPlayer()); MMOCore.plugin.configManager.getSimpleMessage("casting.no-longer").send(playerData.getPlayer());
close(); close();
} }

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmocore.listener; package net.Indyuce.mmocore.listener;
import net.Indyuce.mmocore.manager.SoundManager;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -29,7 +29,7 @@ public class WaypointsListener implements Listener {
data.unlockWaypoint(waypoint); data.unlockWaypoint(waypoint);
new SmallParticleEffect(player, Particle.SPELL_WITCH); new SmallParticleEffect(player, Particle.SPELL_WITCH);
MMOCore.plugin.configManager.getSimpleMessage("new-waypoint", "waypoint", waypoint.getName()).send(player); MMOCore.plugin.configManager.getSimpleMessage("new-waypoint", "waypoint", waypoint.getName()).send(player);
player.playSound(player.getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1.2f); MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.WARP_UNLOCK);
return; return;
} }

View File

@ -84,6 +84,7 @@ public class ConfigManager {
loadDefaultFile("stats.yml"); loadDefaultFile("stats.yml");
loadDefaultFile("waypoints.yml"); loadDefaultFile("waypoints.yml");
loadDefaultFile("restrictions.yml"); loadDefaultFile("restrictions.yml");
loadDefaultFile("sounds.yml");
loadDefaultFile("loot-chests.yml"); loadDefaultFile("loot-chests.yml");
loadDefaultFile("commands.yml"); loadDefaultFile("commands.yml");
loadDefaultFile("guilds.yml"); loadDefaultFile("guilds.yml");

View File

@ -0,0 +1,72 @@
package net.Indyuce.mmocore.manager;
import net.Indyuce.mmocore.api.SoundObject;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
public class SoundManager {
private final Map<SoundEvent, SoundObject> sounds = new HashMap<>();
public SoundManager(FileConfiguration config) {
for(SoundEvent sound : SoundEvent.values())
sounds.put(sound, new SoundObject(config.getString(sound.name().replace("_", "-").toLowerCase())));
}
public void play(Block block, SoundEvent event) {
play(block, block.getLocation(), event);
}
public void play(Block block, Location loc, SoundEvent event) {
SoundObject sound = sounds.get(event);
if(sound.hasSound())
block.getWorld().playSound(loc, sound.getSound(), sound.getVolume(), sound.getPitch());
else block.getWorld().playSound(loc, sound.getKey(), sound.getVolume(), sound.getPitch());
}
public void play(Player player, SoundEvent event) {
play(player, player.getLocation(), event);
}
public void play(Player player, Location loc, SoundEvent event) {
SoundObject sound = sounds.get(event);
if(sound.hasSound())
player.playSound(loc, sound.getSound(), sound.getVolume(), sound.getPitch());
else player.playSound(loc, sound.getKey(), sound.getVolume(), sound.getPitch());
}
public void play(Player player, SoundEvent event, float volume, float pitch) {
play(player, player.getLocation(), event, volume, pitch);
}
public void play(Player player, Location loc, SoundEvent event, float volume, float pitch) {
SoundObject sound = sounds.get(event);
if(sound.hasSound())
player.playSound(loc, sound.getSound(), volume, pitch);
else player.playSound(loc, sound.getKey(), volume, pitch);
}
public enum SoundEvent {
LEVEL_UP,
WARP_TELEPORT,
WARP_CANCELLED,
WARP_CHARGE,
WARP_UNLOCK,
HOTBAR_SWAP,
SPELL_CAST_BEGIN,
SPELL_CAST_END,
CANT_SELECT_CLASS,
SELECT_CLASS,
LEVEL_ATTRIBUTE,
RESET_ATTRIBUTES,
NOT_ENOUGH_POINTS,
CANCEL_QUEST,
START_QUEST,
CLOSE_LOOT_CHEST
}
}

View File

@ -0,0 +1,28 @@
# Format = SOUND,VOLUME,PITCH
# If only the sound name is specified, the
# volume and pitch will be set to 1.
level-up: ENTITY_PLAYER_LEVELUP,1,2
warp-cancelled: ENTITY_VILLAGER_NO,1,0.5
warp-teleport: ENTITY_ENDERMAN_TELEPORT,1,0.5
warp-charge: BLOCK_NOTE_BLOCK_BELL #Uses a special pitch method, so pitch and volume is not changeable
warp-unlock: UI_TOAST_CHALLENGE_COMPLETE,1,1.2
hotbar-swap: ITEM_ARMOR_EQUIP_LEATHER
spell-cast-begin: BLOCK_END_PORTAL_FRAME_FILL,1,2
spell-cast-end: BLOCK_FIRE_EXTINGUISH,1,2
cant-select-class: ENTITY_VILLAGER_NO
select-class: UI_TOAST_CHALLENGE_COMPLETE
level-attribute: ENTITY_PLAYER_LEVELUP
reset-attributes: ENTITY_PLAYER_LEVELUP
not-enough-points: ENTITY_VILLAGER_NO
cancel-quest: ENTITY_VILLAGER_NO
start-quest: ENTITY_EXPERIENCE_ORB_PICKUP
close-loot-chest: ITEM_ARMOR_EQUIP_LEATHER