9
0
mirror of https://github.com/Auxilor/Reforges.git synced 2025-12-25 01:49:34 +00:00

Merge pull request #12

Item lookup system support and sound disabling options
This commit is contained in:
Will FP
2022-01-26 11:46:07 +00:00
committed by GitHub
5 changed files with 59 additions and 42 deletions

View File

@@ -76,12 +76,14 @@ public class ReforgeHandler extends PluginDependent<EcoPlugin> {
if (!EconomyManager.hasAmount(player, cost)) {
player.sendMessage(this.getPlugin().getLangYml().getMessage("insufficient-money"));
player.playSound(
player.getLocation(),
Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.insufficient-money-sound.id").toUpperCase()),
1f,
(float) this.getPlugin().getConfigYml().getDouble("gui.insufficient-money-sound.pitch")
);
if (this.getPlugin().getConfigYml().getBool("gui.insufficient-money-sound.enabled")) {
player.playSound(
player.getLocation(),
Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.insufficient-money-sound.id").toUpperCase()),
1f,
(float) this.getPlugin().getConfigYml().getDouble("gui.insufficient-money-sound.pitch")
);
}
return;
}
@@ -92,13 +94,14 @@ public class ReforgeHandler extends PluginDependent<EcoPlugin> {
xpCost *= Math.pow(this.getPlugin().getConfigYml().getDouble("reforge.cost-exponent"), reforges);
if (player.getLevel() < xpCost) {
player.sendMessage(this.getPlugin().getLangYml().getMessage("insufficient-xp"));
player.playSound(
player.getLocation(),
Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.insufficient-money-sound.id").toUpperCase()),
1f,
(float) this.getPlugin().getConfigYml().getDouble("gui.insufficient-money-sound.pitch")
);
if (this.getPlugin().getConfigYml().getBool("gui.insufficient-money-sound.enabled")) {
player.playSound(
player.getLocation(),
Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.insufficient-money-sound.id").toUpperCase()),
1f,
(float) this.getPlugin().getConfigYml().getDouble("gui.insufficient-money-sound.pitch")
);
}
return;
}
@@ -120,19 +123,25 @@ public class ReforgeHandler extends PluginDependent<EcoPlugin> {
stone.setItemMeta(null);
stone.setAmount(0);
if (this.getPlugin().getConfigYml().getBool("gui.stone-sound.enabled")) {
player.playSound(
player.getLocation(),
Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.stone-sound.id").toUpperCase()),
1f,
(float) this.getPlugin().getConfigYml().getDouble("gui.stone-sound.pitch")
);
}
}
if (this.getPlugin().getConfigYml().getBool("gui.sound.enabled")) {
player.playSound(
player.getLocation(),
Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.stone-sound.id").toUpperCase()),
Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.sound.id").toUpperCase()),
1f,
(float) this.getPlugin().getConfigYml().getDouble("gui.stone-sound.pitch")
(float) this.getPlugin().getConfigYml().getDouble("gui.sound.pitch")
);
}
player.playSound(
player.getLocation(),
Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.sound.id").toUpperCase()),
1f,
(float) this.getPlugin().getConfigYml().getDouble("gui.sound.pitch")
);
}
}

View File

@@ -21,12 +21,14 @@ class CommandOpen(
sender.sendMessage(plugin.langYml.getMessage("invalid-player"))
return
}
player.playSound(
player.location,
Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()),
1f,
plugin.configYml.getDouble("gui.open-sound.pitch").toFloat()
)
if (plugin.configYml.getBool("gui.open-sound.enabled")) {
player.playSound(
player.location,
Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()),
1f,
plugin.configYml.getDouble("gui.open-sound.pitch").toFloat()
)
}
menu.open(player)
}

View File

@@ -12,12 +12,14 @@ class CommandReforge(
) : PluginCommand(plugin, "reforge", "reforges.command.reforge", true) {
override fun onExecute(player: CommandSender, args: List<String>) {
player as Player
player.playSound(
player.location,
Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()),
1f,
plugin.configYml.getDouble("gui.open-sound.pitch").toFloat()
)
if (plugin.configYml.getBool("gui.open-sound.enabled")) {
player.playSound(
player.location,
Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()),
1f,
plugin.configYml.getDouble("gui.open-sound.pitch").toFloat()
)
}
menu.open(player)
}
}

View File

@@ -7,6 +7,7 @@ import com.willfp.eco.core.gui.menu.Menu
import com.willfp.eco.core.gui.slot.FillerMask
import com.willfp.eco.core.gui.slot.MaskMaterials
import com.willfp.eco.core.gui.slot.Slot
import com.willfp.eco.core.items.Items
import com.willfp.eco.core.items.builder.ItemStackBuilder
import com.willfp.eco.util.NumberUtils
import com.willfp.reforges.ReforgesPlugin
@@ -114,12 +115,9 @@ object ReforgeGUI {
.mapNotNull { Material.getMaterial(it.uppercase()) }
.toTypedArray()
val allowMaterial =
Material.getMaterial(plugin.configYml.getString("gui.show-allowed.allow-material", false).uppercase())!!
val denyMaterial =
Material.getMaterial(plugin.configYml.getString("gui.show-allowed.deny-material", false).uppercase())!!
val closeMaterial =
Material.getMaterial(plugin.configYml.getString("gui.close.material", false).toUpperCase())!!
val allowItem = Items.lookup(plugin.configYml.getString("gui.show-allowed.allow-material")).item
val denyItem = Items.lookup(plugin.configYml.getString("gui.show-allowed.deny-material")).item
val closeItem = Items.lookup(plugin.configYml.getString("gui.close.material")).item
menu = Menu.builder(plugin.configYml.getInt("gui.rows")).apply {
setTitle(plugin.langYml.getFormattedString("menu.title"))
@@ -136,9 +134,11 @@ object ReforgeGUI {
).status
if (status == ReforgeStatus.ALLOW || status == ReforgeStatus.ALLOW_STONE) {
previous.type = allowMaterial
previous.type = allowItem.type
previous.itemMeta = allowItem.itemMeta
} else {
previous.type = denyMaterial
previous.type = denyItem.type
previous.itemMeta = denyItem.itemMeta
}
}
}.build()
@@ -172,7 +172,7 @@ object ReforgeGUI {
plugin.configYml.getInt("gui.close.location.row"),
plugin.configYml.getInt("gui.close.location.column"),
Slot.builder(
ItemStackBuilder(closeMaterial)
ItemStackBuilder(closeItem)
.setDisplayName(plugin.langYml.getFormattedString("menu.close"))
.build()
).onLeftClick { event, _, _ ->

View File

@@ -105,18 +105,22 @@ gui:
- '&7You cannot reforge this item!'
sound:
enabled: true
id: BLOCK_ANVIL_USE
pitch: 1
open-sound:
enabled: true
id: BLOCK_ANVIL_PLACE
pitch: 0.8
stone-sound:
enabled: true
id: ENTITY_ENDER_DRAGON_HURT
pitch: 0.5
insufficient-money-sound:
enabled: true
id: ENTITY_VILLAGER_NO
pitch: 0.8